function cos_upgrade_to($version) { common::echoMessage("Will now pull source, and checkout latest tag", 'y'); $command = "git fetch --tags && git checkout master && git pull && git checkout {$version}"; $ret = common::execCommand($command); if ($ret) { common::abort('Aborting upgrade'); } common::echoMessage("Will upgrade vendor with composer according to version", 'y'); $command = "composer update"; $ret = common::systemCommand($command); if ($ret) { common::abort('Composer update failed.'); } common::echoMessage("Will upgrade all modules and templates the versions in the profile", 'y'); // Upgrade all modules and templates $profile = conf::getModuleIni('system_profile'); if (!$profile) { $profile = 'default'; } upgrade_from_profile(array('clone_only' => 1, 'profile' => $profile)); // reload any changes common::echoMessage("Reloading all configuration files", 'y'); $p = new profile(); $p->reloadProfile($profile); common::echoMessage("Load modules changes into database", 'y'); cos_config_reload(); }
/** * connect to a database * @param type $options * * array('url', 'username', 'password', 'dont_die', 'db_init') * * @return string */ public static function connect($options = null) { self::$debug[] = "Trying to connect with " . conf::$vars['coscms_main']['url']; if (isset($options['url'])) { $url = $options['url']; $username = $options['username']; $password = $options['password']; } else { $url = conf::getMainIni('url'); $username = conf::getMainIni('username'); $password = conf::getMainIni('password'); } if (conf::getMainIni('db_dont_persist') == 1) { $con_options = array(); } else { $con_options = array('PDO::ATTR_PERSISTENT' => true); } try { self::$dbh = new PDO($url, $username, $password, $options); // Exception mode self::$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // set SSL self::setSsl(); // init if (conf::getModuleIni('db_init')) { self::$dbh->exec(conf::getModuleIni('db_init')); } // Catch Exception } catch (PDOException $e) { if (!$options) { self::fatalError('Connection failed: ' . $e->getMessage()); } else { if (isset($options['dont_die'])) { self::$debug[] = $e->getMessage(); self::$debug[] = 'No connection'; return "NO_DB_CONN"; } } } self::$con = true; self::$debug[] = 'Connected!'; }
function create($str) { $font = conf::getModuleIni('image_captcha_font'); //'fonts/captcha.ttf';' $f_color = conf::getModuleIni('image_captcha_font_color'); //'fonts/captcha.ttf';' if (!$f_color) { $f_color = 'FFFFFF'; } $b_color = conf::getModuleIni('image_captcha_bg_color'); //'fonts/captcha.ttf';' if (!$b_color) { $b_color = '000000'; } $this->_capTextColor = $f_color; $this->_capBgColor = $b_color; $this->_capFont = conf::pathHtdocs() . '/' . $font; $this->SendHeader(); $this->setStr($str); $this->MakeCaptcha(); }
/** * method for getting all parsed blocks * @todo clearify what is going on * @param string $block * @return array blocks containing strings with html to display */ public static function parseBlock($block) { $blocks = array(); if (isset(conf::$vars['coscms_main'][$block], conf::$vars['coscms_main']['module'][$block])) { $blocks = array_merge(conf::$vars['coscms_main'][$block], conf::$vars['coscms_main']['module'][$block]); } else { if (isset(conf::$vars['coscms_main'][$block])) { $blocks = conf::$vars['coscms_main'][$block]; } else { if (isset(conf::$vars['coscms_main']['module'][$block])) { $blocks = conf::$vars['coscms_main']['module'][$block]; } else { return $blocks; } } } $ret_blocks = array(); foreach ($blocks as $val) { // numeric is custom block added to database if (is_numeric($val)) { moduleloader::includeModule('blocks'); $row = blocks::getOne($val); $row['content_block'] = moduleloader::getFilteredContent(conf::getModuleIni('blocks_filters'), $row['content_block']); $row['title'] = htmlspecialchars($row['title']); $content = view::get('blocks', 'block_html', $row); $ret_blocks[] = $content; continue; } if ($val == 'module_menu') { $ret_blocks[] = self::getMainMenu(); continue; } $func = explode('/', $val); $num = count($func) - 1; $func = explode('.', $func[$num]); $func = 'block_' . $func[0]; $path_to_function = conf::pathModules() . "/{$val}"; include_once $path_to_function; ob_start(); $ret = $func(); if ($ret) { $ret_blocks[] = $ret; } else { $ret_blocks[] = ob_get_contents(); ob_end_clean(); } } return $ret_blocks; }
/** * Check tags to see if we should upgrade. * @return boolean $res */ public function upgradePossible() { $locale = git::getTagsInstallLatest(); $repo = conf::getModuleIni('system_repo'); $remote = git::getTagsRemoteLatest($repo); if ($remote > $locale) { return true; } return false; }
/** * Checks access control against a module ini setting * e.g. in blog.ini default is: blog_allow = 'admin' * then you should call checkAccessControl('blog_allow') in order to prevent * others than 'admin' in using the page * * If a user does not have perms then the default 403 page will be set, * and a 403 header will be sent. * * @param string $allow user or admin or super * @param boolean $setErrorModule set error module or not * @return boolean true if user has required accessLevel. * false if not. * */ public static function checkAccessControl($allow, $setErrorModule = true) { // we check to see if we have a ini setting for // the type to be allowed to an action // allow_edit_article = super $allow = conf::getModuleIni($allow); // is allow is empty means the access control // is not set and we grant access if (empty($allow)) { return true; } // anon is anonymous user. Anyone if allowed if ($allow == 'anon') { return true; } // check if we have a user if ($allow == 'user') { if (self::isUser()) { return true; } else { if ($setErrorModule) { moduleloader::$status[403] = 1; } return false; } } // check other than users. 'admin' and 'super' is set // in special session vars when logging in. User is // someone who just have a valid $_SESSION['id'] set if (!isset($_SESSION[$allow]) || $_SESSION[$allow] != 1) { if ($setErrorModule) { moduleloader::$status[403] = 1; } return false; } else { return true; } }
/** * load assets specified in ini settings from template */ public static function loadTemplateIniAssets() { $css = conf::getModuleIni('template_rel_css'); if ($css) { foreach ($css as $val) { self::setRelAsset('css', $val); } } $js = conf::getModuleIni('template_rel_js'); if ($js) { foreach ($js as $val) { self::setRelAsset('js', $val); } } $js = conf::getModuleIni('template_js'); if ($js) { foreach ($js as $val) { self::setJs($val); } } }
/** * echo the header */ public static function header() { $lang = conf::getMainIni('lang'); if (!$lang) { $lang = 'en'; } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!--[if lt IE 9]> <script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script> <![endif]--> <title><?php echo assets::getTitle(); ?> </title> <?php assets::setRelAsset('css', '//maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css'); assets::setRelAsset('css', '//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.min.css'); //assets::setRelAsset('css', '/bower_components/normalize.css/normalize.css'); assets::setRelAsset('js', '//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'); assets::setRelAsset('js', '//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js'); assets::setRelAsset('css', '//cdn.jsdelivr.net/highlight.js/8.7/styles/default.min.css'); if (!conf::getModuleIni('uikit_highlight_disable')) { assets::setRelAsset('js', '//cdn.jsdelivr.net/highlight.js/8.7/highlight.min.js'); } echo assets::getRelAssets(); echo assets::getJsHead(); echo meta::getMeta(); //assets::setTemplateCss('uikit', null, 10); // assets::setJs('/bower_components/jquery-ui-touch-punch/jquery.ui.touch-punch.min.js', 0); echo favicon::getFaviconHTML(); echo assets::getCompressedCss(); echo assets::getInlineCss(); if (!conf::getModuleIni('uikit_highlight_disable')) { ?> <script>hljs.initHighlightingOnLoad();</script> <?php } ?> <script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/2.22.0/js/uikit.min.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/2.22.0/css/components/notify.gradient.css" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/2.22.0/js/components/notify.min.js"></script> </head> <body> <style> a.uk-aktive { color: #333; } .main { overflow-y: scroll; } </style><?php }