示例#1
0
 /**
  * Public function that creates a single instance
  */
 public static function getInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
示例#2
0
 public function get_licenses($context)
 {
     $elearning_id = "";
     $customer_id = "";
     foreach ($context as $c) {
         if ($c instanceof elearning_context) {
             $elearning_id = $c->get_context_object();
         } else {
             if ($c instanceof unternehmens_context) {
                 $customer_id = $c->get_context_object();
             }
         }
     }
     $licenses = array();
     foreach ($this->license_xml->license as $xml) {
         $license = new license($xml);
         if ($license->get_course_id() == $elearning_id && $license->get_customer_id() == $customer_id) {
             $licenses[] = $license;
         }
     }
     return $licenses;
 }
示例#3
0
<?php

if (!file_exists("htmllib/lib/displayinclude.php")) {
    chdir("../..");
}
include_once "htmllib/lib/displayinclude.php";
if (!os_isSelfSystemOrLxlabsUser()) {
    exit;
}
initProgram('admin');
license::doupdateLicense();
print "License Checked. HyperVM is free.\n";
示例#4
0
文件: module.php 项目: tareqy/Caracal
 /**
  * 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;
 }
示例#5
0
 /**
  * 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;
 }
示例#6
0
 /**
  * Displays package information for the specified package
  *
  * @param array   $package associative array containing package information.
  * @param string  $php     optional. The PHP version on which to filter.
  *                         If not specified, defaults to 'all'.
  * @param integer $count   optional. The ordinal index of the package
  *                         being displayed.
  *
  * @return null
  */
 protected function displayPackage(array $package, $php = 'all', $count = 0)
 {
     $packageClass = $count === 0 ? 'package package-first' : 'package';
     echo " <div class=\"{$packageClass}\">\n";
     echo "  <div class=\"package-info\">\n";
     // name
     $packageName = htmlspecialchars($package['name']);
     echo "   <div class=\"package-title\">\n";
     echo "    <a href=\"package/{$packageName}\">{$packageName}</a>\n";
     echo "   </div>\n";
     // summary
     $packageSummary = trim(htmlspecialchars($package['summary']));
     echo "   <div class=\"package-description\">\n";
     echo "    <p>{$packageSummary}</p>\n";
     echo "   </div>\n";
     // deprecated note
     if (!empty($package['newpk_id'])) {
         echo "   <div class=\"package-notes\">\n";
         $newPackageName = $this->dbh->getOne('SELECT name FROM packages WHERE id = ' . $this->dbh->quote($package['newpk_id'], 'text') . ' ORDER BY id DESC LIMIT 1');
         $newPackageName = htmlspecialchars($newPackageName);
         echo "    <p>This package has been deprecated in favor of " . "<a href=\"/package/{$newPackageName}\">" . $newPackageName . "</a>.</p>";
         echo "   </div>\n";
     }
     echo "  </div>\n";
     echo "  <div class=\"package-more-info\">\n";
     echo "   <table class=\"package-data\">\n";
     echo "    <tbody>\n";
     // status
     switch ($package['status']) {
         case 'stable':
             $state = '<span class="package-stable">stable</span>';
             break;
         case 'beta':
             $state = '<span class="package-beta">beta</span>';
             break;
         case 'alpha':
         default:
             $state = '<span class="package-alpha">alpha</span>';
             break;
     }
     $timestamp = strtotime($package['releasedate']);
     $packageVersion = htmlspecialchars($package['version']);
     $packageDateIso = htmlspecialchars(date('c', $timestamp));
     $packageDate = htmlspecialchars(date('Y-m-d', $timestamp));
     echo "     <tr>\n";
     echo "      <th>Status:</th>\n";
     echo "      <td>" . $packageVersion . " " . "(" . $state . ") " . "released on <abbr class=\"date\" title=\"{$packageDateIso}\">" . $packageDate . "</abbr>" . "</td>\n";
     echo "     </tr>\n";
     // license
     $packageLicense = htmlspecialchars($package['license']);
     $packageLicenseStatus = license::isGood($package['license']);
     $packageLicenseLink = license::getLink($package['license']);
     $packageLicenseClass = $packageLicenseStatus ? 'package-license-good' : 'package-license-bad';
     echo "     <tr>\n";
     echo "      <th>License:</th>\n";
     echo "      <td>";
     echo "<span class=\"{$packageLicenseClass}\">";
     if ($packageLicenseLink === null) {
         echo $packageLicense;
     } else {
         echo "<a href=\"{$packageLicenseLink}\">{$packageLicense}</a>";
     }
     echo "</span>";
     echo "</td>\n";
     echo "     </tr>\n";
     // maintained
     echo "     <tr>\n";
     echo "      <th>Maintained:</th>\n";
     echo "      <td>";
     if ($package['unmaintained'] == 0) {
         echo "Yes";
     } else {
         echo "<span class=\"package-unmaintained\">No</span>";
     }
     echo "</td>\n";
     echo "     </tr>\n";
     // bugs
     if ($package['numbugs'] == 0) {
         $packageBugs = 'none';
     } else {
         $packageBugs = $package['numbugs'];
     }
     $packageBugsLink = 'bugs/search.php?cmd=display&amp;package_name[]=' . urlencode($package['name']);
     echo "     <tr>\n";
     echo "      <th>Open Bugs:</th>\n";
     echo "      <td>";
     echo "<a href=\"{$packageBugsLink}\">{$packageBugs}</a>";
     echo "</td>\n";
     echo "     </tr>\n";
     echo "    </tbody>\n";
     echo "   </table>\n";
     echo "  </div>\n";
     echo " </div>\n";
 }