registerClass('Inp1Parser',MODULES_PATH.'/kernel/units/general/inp1_parser.php','Inp1Parser'); $this->registerClass('InpSession',MODULES_PATH.'/kernel/units/general/inp_ses_storage.php','Session'); $this->registerClass('InpSessionStorage',MODULES_PATH.'/kernel/units/general/inp_ses_storage.php','SessionStorage'); $this->registerClass('kCatDBItem',MODULES_PATH.'/kernel/units/general/cat_dbitem.php'); $this->registerClass('kCatDBList',MODULES_PATH.'/kernel/units/general/cat_dblist.php'); $this->registerClass('kCatDBEventHandler',MODULES_PATH.'/kernel/units/general/cat_event_handler.php'); $this->registerClass('InpDBEventHandler',MODULES_PATH.'/kernel/units/general/inp_db_event_handler.php','kDBEventHandler'); $this->registerClass('InpTempTablesHandler',MODULES_PATH.'/kernel/units/general/inp_temp_handler.php','kTempTablesHandler'); $this->registerClass('InpCustomFieldsHelper',MODULES_PATH.'/kernel/units/general/custom_fields.php','InpCustomFieldsHelper'); $this->registerClass('kCountryStatesHelper',MODULES_PATH.'/kernel/units/general/country_states.php','CountryStatesHelper'); $this->registerClass('kBracketsHelper',MODULES_PATH.'/kernel/units/general/brackets.php','BracketsHelper'); } /** * Checks if user is logged in, and creates * user object if so. User object can be recalled * later using "u" prefix. Also you may * get user id by getting "u_id" variable. * * @access private */ function ValidateLogin() { $session =& $this->recallObject('Session'); $user_id = $session->GetField('PortalUserId'); if (!$user_id) $user_id = -2; $this->SetVar('u_id', $user_id); $this->StoreVar('user_id', $user_id); } function RunScheduledEvents() { $events = Array('ls:OnCheckExpiredPaidListings', 'u:OnCheckExpiredMembership'); $run_interval = 60 * 30; // in seconds if(rand(0, 100) < 90) { return; } $sql = 'SELECT Data FROM '.TABLE_PREFIX.'Cache WHERE VarName = "LastMaintainRun"'; $last_maintain = $this->DB->GetOne($sql); if($last_maintain && $last_maintain > mktime() - $run_interval) { return; } elseif($last_maintain) { $sql = 'UPDATE '.TABLE_PREFIX.'Cache SET Data = "'.mktime().'" WHERE VarName = "LastMaintainRun"'; } else { $sql = 'INSERT INTO '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("LastMaintainRun", "'.mktime().'", "'.mktime().'")'; } $this->DB->Query($sql); foreach($events as $scheduled_event) { $event = new kEvent($scheduled_event); $this->HandleEvent($event); unset($event); } } /** * Raise specific events based on non-standard (no described in config files) * params given in url if no other params are given * @todo by now is called before $event_manager->ProcessRequrest() method anyway * @author Alex */ function ProcessSpecialURL() { $affiliate = $this->GetVar('affiliate'); if($affiliate) { $user_idfield = $this->getUnitOption('u','IDField'); $user_table = $this->getUnitOption('u','TableName'); $sql = 'SELECT %s FROM %s WHERE (CRC32(Email) = %s) AND (Status = 1)'; $user_id = $this->DB->GetOne( sprintf($sql, $user_idfield, $user_table, $this->DB->qstr($affiliate) ) ); if($user_id) // user is found with such email { $affiliate_user = $this->recallObject('u.affiliate', null, Array('skip_autoload'=>true) ); $affiliate_user->Load($user_id); $user_groups = $affiliate_user->getMembershipGroups(true); $affiliate_group_id = $this->ConfigValue('Comm_AffiliateGroup'); if( is_array($user_groups) && in_array($affiliate_group_id, $user_groups) ) // user is really affiliate for a moment { $affiliate_storage_method = $this->ConfigValue('Comm_AffiliateStorageMethod'); switch($affiliate_storage_method) { case 1: // per session $this->StoreVar('affiliate_id', $user_id); break; case 2: // in cookie setcookie('affiliate_id', $user_id); break; } } } $this->Redirect(); } } } ?>