Beispiel #1
0
 public function getSystemInfo()
 {
     $answer = '';
     if (function_exists('curl_init')) {
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, 'http://service.impresspages.org');
         curl_setopt($ch, CURLOPT_POST, 1);
         $postFields = 'module_name=communication&module_group=service&action=getInfo&version=1&afterLogin='******'&systemVersion=' . \DbSystem::getSystemVariable('version');
         $groups = \Modules\developer\modules\Db::getGroups();
         foreach ($groups as $groupKey => $group) {
             $modules = \Modules\developer\modules\Db::getModules($group['id']);
             foreach ($modules as $moduleKey => $module) {
                 $postFields .= '&modules[' . $group['name'] . '][' . $module['name'] . ']=' . $module['version'];
             }
         }
         curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
         curl_setopt($ch, CURLOPT_REFERER, BASE_URL);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_TIMEOUT, 1);
         $answer = curl_exec($ch);
         if (json_decode($answer) === null) {
             //json decode error
             return '';
         }
     }
     return $answer;
 }
 private function _checkCompatability($moduleGroup, $moduleName, $version)
 {
     $answer = '';
     if (function_exists('curl_init')) {
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, 'http://service.impresspages.org');
         curl_setopt($ch, CURLOPT_POST, 1);
         $postFields = 'module_name=communication&module_group=service&action=checkCompatability&newModuleGroup=' . $moduleGroup . '&newModuleName=' . $moduleName . '&newModuleVersion=' . $version . '&version=1';
         $postFields .= '&systemVersion=' . \DbSystem::getSystemVariable('version');
         $groups = \Modules\developer\modules\Db::getGroups();
         foreach ($groups as $groupKey => $group) {
             $modules = \Modules\developer\modules\Db::getModules($group['id']);
             foreach ($modules as $moduleKey => $module) {
                 $postFields .= '&modules[' . $group['name'] . '][' . $module['name'] . ']=' . $module['version'];
             }
         }
         curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
         curl_setopt($ch, CURLOPT_REFERER, BASE_URL);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_TIMEOUT, 1);
         $json = curl_exec($ch);
         if (json_decode($json) !== null) {
             //json decode succeded
             $array = json_decode($json, true);
             if ($array['status'] != 'success') {
                 $answer = $array['errorMessage'];
             }
         }
     }
     return $answer;
 }
Beispiel #3
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;
 }
Beispiel #4
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));
             }
         }
     }
 }
Beispiel #5
0
 function manage()
 {
     global $cms;
     global $parametersMod;
     global $log;
     $answer = '';
     if (isset($_GET['action'])) {
         switch ($_GET['action']) {
             case "cache_clear":
                 $log->log('administrator/system', 'Cache was cleared');
                 $module = new Module();
                 $module->clearCache();
                 $answer .= '
   <div class="note">
     ' . $parametersMod->getValue('administrator', 'system', 'admin_translations', 'cache_cleared') . '
   </div>
         ';
                 break;
         }
     }
     $answer .= HtmlOutput::header();
     $answer .= '<div class="content">';
     $answer .= '<h1>ImpressPages CMS ' . htmlspecialchars(\DbSystem::getSystemVariable('version')) . '</h1>';
     $answer .= '</div>';
     $answer .= '<div class="content">';
     $answer .= '<h1>' . htmlspecialchars($parametersMod->getValue('administrator', 'system', 'admin_translations', 'cache')) . '</h1>';
     $answer .= $parametersMod->getValue('administrator', 'system', 'admin_translations', 'cache_comments');
     $answer .= '<a href="' . $cms->generateUrl($cms->curModId, 'action=cache_clear') . '" class="button">' . htmlspecialchars($parametersMod->getValue('administrator', 'system', 'admin_translations', 'cache_clear')) . '</a><br /><br /><br />';
     $answer .= '</div>';
     $answer .= '<div id="systemInfo" class="content" style="display: none;">';
     $answer .= '<h1>' . htmlspecialchars($parametersMod->getValue('standard', 'configuration', 'system_translations', 'system_message')) . '</h1>';
     $answer .= ' <script type="text/javascript" src="' . BASE_URL . MODULE_DIR . 'administrator/system/script.js"></script>';
     $answer .= '</div>';
     $answer .= HtmlOutput::footer();
     return $answer;
 }