Esempio n. 1
0
 function clearCache()
 {
     global $cms;
     global $parametersMod;
     global $site;
     $cachedUrl = \DbSystem::getSystemVariable('cached_base_url');
     // get system variable
     $site->dispatchEvent('administrator', 'system', 'clear_cache', array('old_url' => $cachedUrl, 'new_url' => BASE_URL));
     $errors = false;
     if ($cachedUrl != BASE_URL) {
         //update robots.txt file.
         $robotsFile = 'robots.txt';
         $data = file($robotsFile, FILE_IGNORE_NEW_LINES);
         $newData = '';
         foreach ($data as $dataKey => $dataVal) {
             $tmpVal = $dataVal;
             $tmpVal = trim($tmpVal);
             $tmpVal = preg_replace('/^Sitemap:(.*)/', 'Sitemap: ' . BASE_URL . 'sitemap.php', $tmpVal);
             $newData .= $tmpVal . "\n";
         }
         if (is_writable($robotsFile)) {
             file_put_contents($robotsFile, $newData);
         } else {
             trigger_error('robots.txt file need to be updated. Do it manually or make it writable and clear cache once again.');
             $errors = true;
         }
     }
     $sql = "select m.name as m_name, mg.name as mg_name from `" . DB_PREF . "module_group` mg, `" . DB_PREF . "module` m where m.group_id = mg.id";
     $rs = mysql_query($sql);
     if ($rs) {
         while ($lock = mysql_fetch_assoc($rs)) {
             if (file_exists(BASE_DIR . MODULE_DIR . $lock['mg_name'] . '/' . $lock['m_name'] . "/system.php")) {
                 require_once BASE_DIR . MODULE_DIR . $lock['mg_name'] . '/' . $lock['m_name'] . "/system.php";
                 eval('$module_system = new \\Modules\\' . $lock['mg_name'] . '\\' . $lock['m_name'] . '\\System();');
                 if (method_exists($module_system, 'clearCache')) {
                     $module_system->clearCache($cachedUrl);
                 }
             }
         }
         if ($errors == false) {
             \DbSystem::replaceUrls($cachedUrl, BASE_URL);
             \DbSystem::setSystemVariable('cached_base_url', BASE_URL);
             // update system variable
         }
     }
     if ($errors == false) {
         $site->dispatchEvent('administrator', 'system', 'cache_cleared', array('old_url' => $cachedUrl, 'new_url' => BASE_URL));
     }
 }
Esempio n. 2
0
 function makeActions()
 {
     if (isset($_REQUEST['action'])) {
         switch ($_REQUEST['action']) {
             case 'getSystemInfo':
                 $module = new Module();
                 $systemInfo = $module->getSystemInfo();
                 if (isset($_REQUEST['afterLogin'])) {
                     // request after login.
                     if ($systemInfo == '') {
                         $_SESSION['modules']['administrator']['system']['show_system_message'] = false;
                         //don't display system alert at the top.
                         return;
                     } else {
                         $md5 = \DbSystem::getSystemVariable('last_system_message_shown');
                         if ($systemInfo && (!$md5 || $md5 != md5($systemInfo))) {
                             //we have a new message
                             $newMessage = false;
                             foreach (json_decode($systemInfo) as $infoKey => $infoValue) {
                                 if ($infoValue->type != 'status') {
                                     $newMessage = true;
                                 }
                             }
                             $_SESSION['modules']['administrator']['system']['show_system_message'] = $newMessage;
                             //display system alert
                         } else {
                             //this message was already seen.
                             $_SESSION['modules']['administrator']['system']['show_system_message'] = false;
                             //don't display system alert at the top.
                             return;
                         }
                     }
                 } else {
                     //administrator/system tab.
                     \DbSystem::setSystemVariable('last_system_message_shown', md5($systemInfo));
                     $_SESSION['modules']['administrator']['system']['show_system_message'] = false;
                     //don't display system alert at the top.
                 }
                 echo $systemInfo;
                 break;
         }
     }
     \Db::disconnect();
     exit;
 }
Esempio n. 3
0
 function execute($options)
 {
     global $parametersMod;
     global $dbSite;
     global $log;
     global $site;
     if ($options->firstTimeThisWeek) {
         $module = new Module();
         $systemInfo = $module->getSystemInfo();
         if ($systemInfo != '') {
             //send an email
             $md5 = \DbSystem::getSystemVariable('last_system_message_sent');
             if (!$md5 || $md5 != md5($systemInfo)) {
                 //we have a new message
                 $message = '';
                 $messages = json_decode($systemInfo);
                 if (is_array($messages)) {
                     foreach ($messages as $messageKey => $messageVal) {
                         $message .= '<p>' . $messageVal->message . '</p>';
                     }
                     $onlyStatusMessages = true;
                     foreach ($messages as $messageKey => $messageVal) {
                         if ($messageVal->type != 'status') {
                             $onlyStatusMessages = false;
                         }
                     }
                     if ($onlyStatusMessages) {
                         return;
                     }
                 } else {
                     return;
                 }
                 if (defined('ERRORS_SEND') && ERRORS_SEND != '') {
                     require_once BASE_DIR . MODULE_DIR . 'administrator/email_queue/module.php';
                     $queue = new \Modules\administrator\email_queue\Module();
                     $queue->addEmail($parametersMod->getValue('standard', 'configuration', 'main_parameters', 'email'), $parametersMod->getValue('standard', 'configuration', 'main_parameters', 'name'), ERRORS_SEND, '', $parametersMod->getValue('standard', 'configuration', 'main_parameters', 'name'), $message, false, true);
                     $queue->send();
                 }
                 \DbSystem::setSystemVariable('last_system_message_sent', md5($systemInfo));
             }
         }
     }
 }