Пример #1
0
<?php

// Function to scan the event queue and execute any functions required.
require_once 'base.php';
require_once W2P_BASE_DIR . '/includes/config.php';
require_once W2P_BASE_DIR . '/includes/main_functions.php';
require_once W2P_BASE_DIR . '/includes/db_adodb.php';
require_once W2P_BASE_DIR . '/classes/ui.class.php';
require_once W2P_BASE_DIR . '/classes/event_queue.class.php';
require_once W2P_BASE_DIR . '/classes/query.class.php';
$AppUI = new CAppUI();
$AppUI->setUserLocale();
$queue = new EventQueue();
$queue->scan();
/*
 This is the first piece of a simple hook system to allow for regularly 
 scheduled maintenance tasks to occur.  This could be data validation and 
 cleanup, sending email notifications, or workflow related tasks.
 
 The model for this functionality was based on Drupal's methods for laying 
 out and interacting with hooks.  It should not be considered complete at 
 this time.
*/
$moduleList = $AppUI->getLoadableModuleList();
foreach ($moduleList as $module) {
    $object = new $module['mod_main_class']();
    if (is_callable(array($object, 'hook_cron'))) {
        $object->hook_cron();
    }
}
Пример #2
0
 public function hook_cron()
 {
     global $w2Pconfig;
     if (w2PgetConfig('system_update_check', true)) {
         $lastCheck = w2PgetConfig('system_update_last_check', '');
         $nowDate = new DateTime("now");
         if ('' == $lastCheck) {
             $checkForUpdates = true;
         } else {
             $systemDate = new DateTime($lastCheck);
             $difference = 0;
             //$nowDate->diff($systemDate)->format('%d');
             $checkForUpdates = $difference >= 7 ? true : false;
         }
         if ($checkForUpdates) {
             $AppUI = new CAppUI();
             $configList = array();
             $moduleList = $AppUI->getLoadableModuleList();
             foreach ($moduleList as $module) {
                 $configList[$module['mod_directory']] = $module['mod_version'];
             }
             $configList['w2p_ver'] = $AppUI->getVersion();
             $configList['php_ver'] = PHP_VERSION;
             $configList['database'] = $w2Pconfig['dbtype'];
             $configList['server'] = $_SERVER['SERVER_SOFTWARE'];
             $configList['connector'] = php_sapi_name();
             $configList['database_ver'] = mysql_get_client_info();
             $libraries = array('tidy', 'json', 'libxml', 'mysql');
             foreach ($libraries as $library) {
                 $configList[$library . '_extver'] = phpversion($library);
             }
             if (function_exists('gd_info')) {
                 $lib_version = gd_info();
                 $configList['gd_extver'] = $lib_version['GD Version'];
             }
             if (function_exists('curl_version')) {
                 $lib_version = curl_version();
                 $configList['curl_extver'] = $lib_version['version'];
             }
             $request = new w2p_Utilities_HTTPRequest('http://stats.web2project.net');
             $request->addParameters($configList);
             $result = $request->processRequest();
             $data = json_decode($result);
             $q = new w2p_Database_Query();
             $q->addTable('config');
             if ('' == w2PgetConfig('available_version', '')) {
                 $q->addInsert('config_name', 'available_version');
                 $q->addInsert('config_value', $data->w2p_ver);
                 $q->addInsert('config_group', 'admin_system');
                 $q->addInsert('config_type', 'text');
             } else {
                 $q->addUpdate('config_value', $data->w2p_ver);
                 $q->addWhere("config_name  = 'available_version'");
             }
             $q->exec();
             $q->clear();
             $q->addTable('config');
             $q->addUpdate('config_value', date('Y-m-d H:i:s'));
             $q->addWhere("config_name  = 'system_update_last_check'");
             $q->exec();
         }
     }
 }