private static function checkForUpdates() { $module = Model::instance(); $systemInfo = $module->getIpNotifications(); if ($systemInfo != '') { //send an email $md5 = \Ip\ServiceLocator::storage()->get('Ip', 'lastSystemMessageSent'); if (!$md5 || $md5 != md5(serialize($systemInfo))) { //we have a new message $message = ''; $messages = $systemInfo; if (is_array($messages)) { foreach ($messages as $messageVal) { $message .= '<p>' . $messageVal->message . '</p>'; } $onlyStatusMessages = true; foreach ($messages as $messageVal) { if ($messageVal->type != 'status') { $onlyStatusMessages = false; } } if ($onlyStatusMessages) { return; //TODO replace to something that would not terminate execution of following scripts if they will be there some day } } else { return; //TODO replace to something that would not terminate execution of following scripts if they will be there some day } ipEvent('ipSystemMessages', array('messages' => $messages)); \Ip\ServiceLocator::storage()->set('Ip', 'lastSystemMessageSent', md5(serialize($systemInfo))); } } }
/** * @return array|string */ public static function getIpNotifications() { if (!function_exists('curl_init')) { return array(); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, \Ip\Internal\System\Model::instance()->getImpressPagesAPIUrl()); curl_setopt($ch, CURLOPT_POST, 1); $postFields = 'module_group=service&module_name=communication&action=getInfo&version=1&afterLogin='******'&systemVersion=' . \Ip\ServiceLocator::storage()->get('Ip', 'version'); $plugins = \Ip\Internal\Plugins\Model::getActivePlugins(); foreach ($plugins as $plugin) { $postFields .= '&plugins[' . $plugin['name'] . ']=' . $plugin['version']; } curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields); curl_setopt($ch, CURLOPT_REFERER, ipConfig()->baseUrl()); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $answer = curl_exec($ch); $notices = json_decode($answer); if (!is_array($notices)) { // json decode error or wrong answer ipLog()->error('System.updateCheckInvalidResponse', array('curl_error' => curl_error($ch), 'response' => $answer)); return array(); } return $notices; }
public static function ipBeforeApplicationClosed() { /* Automatic execution of cron. The best solution is to setup cron service to launch file www.yoursite.com/ip_cron.php few times a day. By default fake cron is enabled */ if (\Ip\Internal\Admin\Model::isSafeMode() || !ipGetOption('Config.automaticCron', 1)) { return; } $lastExecution = \Ip\ServiceLocator::storage()->get('Cron', 'lastExecutionStart'); if ($lastExecution && date('Y-m-d H') == date('Y-m-d H', $lastExecution)) { // we execute cron once an hour and cron has been executed this hour return; } if (function_exists('curl_init')) { $ch = curl_init(); $url = ipConfig()->baseUrl() . '?pa=Cron&pass='******'Config.cronPassword')); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_REFERER, ipConfig()->baseUrl()); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, ipGetOption('Config.cronTimeout', 10)); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); $fakeCronAnswer = curl_exec($ch); if ($fakeCronAnswer != __('OK', 'Ip-admin', false)) { ipLog()->error('Cron.failedFakeCron', array('result' => $fakeCronAnswer, 'type' => 'curl', 'error' => curl_error($ch))); } } else { $request = new \Ip\Request(); $request->setQuery(array('pa' => 'Cron', 'pass' => ipGetOption('Config.cronPassword'))); $fakeCronAnswer = \Ip\ServiceLocator::application()->handleRequest($request)->getContent(); if ($fakeCronAnswer != __('OK', 'Ip-admin', false)) { ipLog()->error('Cron.failedFakeCron', array('result' => $fakeCronAnswer, 'type' => 'subrequest')); } } }
public function getIpNotifications() { $systemInfo = Model::getIpNotifications(); if (isset($_REQUEST['afterLogin'])) { // Request after login. if ($systemInfo == '') { $_SESSION['ipSystem']['show_system_message'] = false; // Don't display system alert at the top. return null; } else { $md5 = \Ip\ServiceLocator::storage()->get('Ip', 'lastSystemMessageShown'); if ($systemInfo && (!$md5 || $md5 != md5(serialize($systemInfo)))) { // We have a new message. $newMessage = false; foreach (json_decode($systemInfo) as $infoValue) { if ($infoValue->type != 'status') { $newMessage = true; } } $_SESSION['ipSystem']['show_system_message'] = $newMessage; // Display system alert. } else { // This message was already seen. $_SESSION['ipSystem']['show_system_message'] = false; // Don't display system alert at the top. return null; } } } else { // administrator/system tab. \Ip\ServiceLocator::storage()->set('Ip', 'lastSystemMessageShown', md5(serialize($systemInfo))); $_SESSION['ipSystem']['show_system_message'] = false; // Don't display system alert at the top. } return new \Ip\Response\Json($systemInfo); }
/** * Get all web site options * * @return array Configuration options */ function getAllOptions() { $optionValues = \Ip\ServiceLocator::storage()->getAll('Config'); $options = array(); foreach ($optionValues as $option) { $options[$option['key']] = $option['value']; } return $options; }
if (!empty($description)) { ?> <meta property="og:description" content="<?php echo escAttr($description); ?> " /> <?php } if (!empty($siteName)) { ?> <meta property="og:site_name" content="<?php echo escAttr($siteName); ?> " /> <?php } if (!empty($images)) { ?> <?php foreach ($images as $imageUrl) { ?> <meta property="og:image" content="<?php echo escAttr($imageUrl); ?> ?v=0<?php echo \Ip\ServiceLocator::storage()->get('Ip', 'cacheVersion', 1); ?> " /> <?php } }
protected function getCacheVersion() { return \Ip\ServiceLocator::storage()->get('Ip', 'cacheVersion', 1); }
public function installTheme($themeName) { $themes = $this->getAvailableThemes(); if (!isset($themes[$themeName])) { throw new \Ip\Exception("Theme '" . esc($themeName) . "' does not exist."); } $theme = $themes[$themeName]; ipEvent('ipBeforeThemeInstalled', array('themeName' => $themeName)); \Ip\ServiceLocator::storage()->set('Ip', 'theme', $themeName); $service = Service::instance(); $service->saveWidgetOptions($theme); //write down default theme options $options = $theme->getOptionsAsArray(); foreach ($options as $option) { if (empty($option['name']) || empty($option['default'])) { continue; } $configModel = ConfigModel::instance(); $newValue = $configModel->getConfigValue($themeName, $option['name'], $option['default']); $configModel->setConfigValue($themeName, $option['name'], $newValue); } ipEvent('ipThemeInstalled', array('themeName' => $themeName)); }
/** * Get Key-Value storage object * * @return \Ip\Storage Storage object */ function ipStorage() { return \Ip\ServiceLocator::storage(); }