Anonymous | Login | Signup for a new account | 2023-09-29 05:03 CDT | ![]() |
Main | My View | View Issues | Change Log | Roadmap | Docs | Wiki | Repositories |
Viewing Issue Simple Details [ Jump to Notes ] [ Wiki ] | [ View Advanced ] [ Issue History ] [ Print ] | |||||
ID | Category | Type | Reproducibility | Date Submitted | Last Update | |
0000378 | [In-Portal CMS] Optimization | task | always | 2009-10-12 06:51 | 2009-11-03 07:19 | |
Reporter | alex | View Status | public | Project Name | In-Portal CMS | |
Assigned To | Developer | |||||
Priority | normal | Resolution | open | Fixed in Version | ||
Status | active | Product Version | 5.0.1 | Target Version | Icebox | |
Time Estimate | No estimate | |||||
Summary | 0000378: Hit countring improvements | |||||
Description |
Tag RegisterHit is used for counting hit count for each category item. There is only one problem with it, because it stores ids of items, that were already visited in this session to session and there fore forces session to be created and additional server resources to be used. I propose to create Hits table, where all hits (per session) should be stored (for logged in users) and (per ip) for not logged in users. We could clear it's contents once a day (previous day records only, not whole table). Table should be used for checking, that user is already voted or not. |
|||||
Additional Information |
Table: CREATE TABLE `btr_Hits` ( `HitId` int(11) unsigned NOT NULL auto_increment, `BlogId` int(10) unsigned NOT NULL, `IPAddress` varchar(15) NOT NULL, `IPLong` int(11) NOT NULL, `CreatedById` int(11) NOT NULL, `CreatedOn` int(11) default NULL, `SessionKey` int(10) unsigned NOT NULL, PRIMARY KEY (`HitId`), KEY `BlogId` (`BlogId`), KEY `IPAddress` (`IPAddress`), KEY `CreatedById` (`CreatedById`), KEY `CreatedOn` (`CreatedOn`), KEY `IPLong` (`IPLong`), KEY `SessionKey` (`SessionKey`) ); Tag RegisterHit: /** * Registers hit on detail page * * @param Array $params * @return string */ function RegisterHit($params) { $object =& $this->getObject($params); /* @var $object kDBItem */ $user_id = $this->Application->RecallVar('user_id'); $user_ip = $_SERVER['REMOTE_ADDR']; $sql = 'SELECT ' . $this->Application->getUnitOption('hit', 'IDField') . ' FROM ' . $this->Application->getUnitOption('hit', 'TableName') . ' WHERE (BlogId = ' . $object->GetID() . ')'; if ($this->Application->LoggedIn()) { // for logged-in - session id + user id $sql .= ' AND (CreatedById = ' . $user_id . ') AND (SessionKey = ' . $this->Application->GetSID() . ')'; } else { // non-logged in view range is day (from now minus 24 hours) $to_date = adodb_mktime(); $from_date = strtotime('-1 day', $to_date); $sql .= ' AND (IPLong = ' . ip2long($user_ip) . ') AND (CreatedOn BETWEEN ' . $from_date . ' AND ' . $to_date . ')'; } $already_viewed = $this->Conn->GetOne($sql); if (!$already_viewed) { $hit =& $this->Application->recallObject('hit', null, Array ('skip_autoload' => true)); /* @var $hit kDBItem */ $hit->SetDBField('BlogId', $object->GetID()); $hit->Create(); } return ''; } Database query for deleting old hits: $sql = 'DELETE FROM ' . TABLE_PREFIX . 'Hits WHERE CreatedOn < ' . strtotime('-1 day'); $this->Conn->Query($sql); |
|||||
Tags | No tags attached. | |||||
Reference | ||||||
Change Log Message | ||||||
Estimate Points | 0 | |||||
Attached Files | ||||||
|
![]() |
|
There are no notes attached to this issue. |
![]() |
|||
Date Modified | Username | Field | Change |
2009-11-03 07:19 | alex | Target Version | => Icebox |
2009-10-12 06:51 | alex | New Issue |
Main | My View | View Issues | Change Log | Roadmap | Docs | Wiki | Repositories |
Web Development by Intechnic![]() In-Portal Open Source CMS |