/** * Check license for current module * @return boolean */ protected function checkLicense() { $result = false; $license = isset($_REQUEST['key']) ? fix_chars($_REQUEST['key']) : null; if (class_exists('license')) { $license = license::getInstance(); $result = $license->isLicenseValid($this->name, $license); } return $result; }
/** * Check if specified activity is alive. * * @return boolean */ public function isAlive() { global $db; $manager = ActivityManager::getInstance(); $log_manager = ActivityLogManager::getInstance(); // collect data $result = false; $activity_name = isset($_REQUEST['activity']) ? fix_chars($_REQUEST['activity']) : null; $function_name = isset($_REQUEST['function']) ? fix_chars($_REQUEST['function']) : null; // check license if module is loaded if (class_exists('license')) { $license = license::getInstance(); $license_number = fix_chars($_REQUEST['license']); if (!$license->isLicenseValid($this->name, $license_number)) { return $result; } } // get activity $activity = $manager->getSingleItem($manager->getFieldNames(), array('activity' => $activity_name, 'function' => $function_name)); // prepare log conditions $conditions = array(); if (is_object($activity)) { $conditions['activity'] = $activity->id; $conditions['timestamp'] = array('operator' => '>=', 'value' => $db->format_timestamp(time() - $activity->timeout)); if (!$activity->ignore_address) { $conditions['address'] = $_SERVER['REMOTE_ADDR']; } } if ($_SESSION['logged']) { $conditions['user'] = $_SESSION['uid']; } // get logs from database $logs = $log_manager->getItems(array('id'), $conditions); $result = count($logs) > 0; // show result if (_AJAX_REQUEST) { print json_encode($result); } return $result; }