function render_template($locals, $fileName) { extract($locals); ob_start(); include root() . 'views/' . $fileName . '.php'; return ob_get_clean(); }
function pad_write($p, $o, $res) { $pad = 'pad' . ses('USE') . date('ymd'); $f = 'plug/_data/' . $pad . '.txt'; write_file($f, ajxg($res)); return lkt('popbt', root() . $f, $pad); }
public static function combine($type, $files, $compress = false) { $root = root('panel.assets') . DS . $type; $cache = new Media($root . DS . 'panel.' . $type); $media = new Collection(array_map(function ($file) use($root) { return new Media($root . DS . str_replace('/', DS, $file)); }, $files)); // get the max modification date $modified = max($media->pluck('modified')); if (is_writable($root) and (!$cache->exists() or $cache->modified() < $modified)) { $cache->remove(); $content = ''; foreach ($media as $asset) { $content .= $asset->read() . PHP_EOL; } if ($compress) { $content = static::compress($content); } f::write($root . DS . 'panel.' . $type, $content); } if ($cache->exists()) { return $type('panel/assets/' . $type . '/panel.' . $type); } return $type(array_map(function ($item) use($type) { return 'panel/assets/' . $type . '/' . $item; }, $files)); }
/** * Simple Debug info * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @return void */ public function systeminfo() { $objSQL = Core_Classes_coreObj::getDBO(); $objTPL = Core_Classes_coreObj::getTPL(); $objTime = Core_Classes_coreObj::getTime(); $objForm = Core_Classes_coreObj::getForm(); $objTPL->set_filenames(array('body' => cmsROOT . Core_Classes_Page::$THEME_ROOT . 'block.tpl')); // checkers // grab some info about GD if (function_exists('gd_info')) { $a = gd_info(); $gdVer = preg_replace('/[[:alpha:][:space:]()]+/', '', $a['GD Version']); } else { $gdVer = 'Not Installed.'; } $info = '<div class="alert alert-info"><strong>Important!</strong> This panel needs more updating to output more useful data that has been made avaliable during the last overhaul</div>'; $content = 'This panel gives the CMS dev team some information about your setup. ;--System Setup CMS Version: ' . CMS_VERSION . ' PHP Version: ' . PHP_VERSION . ' (' . (@ini_get('safe_mode') == '1' || strtolower(@ini_get('safe_mode')) == 'on' ? 'Safe Mode Enabled' : 'Safe Mode Disabled') . ') MySQL Version: ' . mysql_get_server_info() . ' GD Version: ' . $gdVer . ' ;--CMS Setup Install Path: /' . root() . ' ' . json_encode($objSQL->fetchAll('SELECT * FROM `#__config`')) . ''; Core_Classes_coreObj::getAdminCP()->setupBlock('body', array('cols' => 3, 'vars' => array('TITLE' => 'System Info', 'CONTENT' => $info . $objForm->textarea('sysInfo', $content, array('style' => 'width: 99%', 'rows' => 20)), 'ICON' => 'fa-icon-user'))); }
/** * Bind paths * * @return void */ public function bindPaths() { $root = root(); $source = $root . '/' . Conf::get('source', 'source'); $paths = ['root' => $root, 'source' => $source, 'posts' => $source . '/posts', 'pages' => $source . '/pages', 'themes' => $source . '/themes', 'theme' => $source . '/themes/' . Conf::get('theme'), 'plugins' => $root . '/' . Conf::get('plugins', 'plugins')]; foreach ($paths as $key => $value) { App::instance("path.{$key}", $value); } }
function plug_imtx($p, $o) { $rid = 'plg' . randid(); ses('out', '/plug/_data/imtx.png'); $j = $rid . '_plug__2_imtx_imt*j_' . $w . '_' . $h . '_txtarec'; $sj = 'SaveJ(\'' . $j . '\')'; $ret .= txarea('txtarec', $p, 44, 14, atc('console') . atb('onkeyup', $sj) . atb('onclick', $sj)); $ret .= lj('', $j, picto('reload')) . ' '; return $ret . divd($rid, image(root() . ses('out'))); }
function chatdata($p) { $dr = root() . 'msql/users/'; $dfb['_menus_'] = array('time', 'name', 'msg'); $r = read_vars($dr, ses('qb') . '_chat_' . $p, $dfb); if ($r) { unset($r['_menus_']); } return $r; }
public function login_process() { $objUser = Core_Classes_coreObj::getUser(); $objLogin = Core_Classes_coreObj::getLogin(); $objPage = Core_Classes_coreObj::getPage(); if ($objLogin->process() !== true) { $this->login_form(); return; } $objPage->redirect(doArgs('referer', '/' . root(), $_SESSION['login']), 0); }
function __construct($parent = null, $params_json = "{}") { $this->interactive = true; $this->game = 0; $this->round = 0; parent::__construct($parent, $params_json); $this->name = "game"; $db_dices = root($this)->db->load("Dice"); if (count($db_dices)) { $this->interactive = false; } }
public function __construct() { $root = root(); $config_path = $this->app('config_path') ?: 'config.yml'; $this->path = $root . '/' . $config_path; if (!is_readable($this->path)) { // @codeCoverageIgnoreStart throw new \LogicException('cannot read config file: ' . $this->path); // @codeCoverageIgnoreEnd } $this->data = Yaml::parse(file_get_contents($this->path)); }
/** * Fetch template HTML and parse vars. * * @param array $vars Vars to pass to template. * * @return string */ private function fetchTemplate($vars = array()) { $html = rfile_get_contents(appdir('template/mail/' . $this->template . '.html')); foreach ($this->vars as $key => $var) { $html = str_replace('{{ ' . $key . ' }}', $var, $html); } $css = array(); preg_match_all('/\\{\\%css\\:\\ (.*?)\\ \\%\\}/', $html, $css); if (!empty($css[1][0])) { $style = rfile_get_contents(root('www/asset/css/' . $css[1][0])); $html = str_replace($css[0][0], '<style>' . $style . '</style>', $html); } return $html; }
/** * Pretty wrapper to print_r() * * @version 3.0 * @since 1.0.0 * @author Dan Aldridge * * @param variable $var * @param string $info * @param string $color Changes the debug header color * @param bool $specialFX * * @return string */ function dump(&$var, $info = false, $color = '', $specialFX = true) { if (file_exists('debug')) { return; } $objPage = Core_Classes_coreObj::getPage(); $scope = false; $prefix = 'unique'; $suffix = 'value'; $return = null; $specialFX = $specialFX !== false ? true : false; if (is_object($objPage)) { if ($specialFX) { /*$objPage->addJSFile(array( 'src' => '/'.root().'assets/javascript/tree.js', 'priority' => LOW, ));*/ } } else { static $run; if (!isset($run) || $run != true) { echo '<link rel="stylesheet" type="text/css" href="/' . root() . 'assets/styles/debug.css" />' . "\n"; } $run = true; } $vals = $scope ? $scope : $GLOBALS; $old = $var; $var = $new = $prefix . rand() . $suffix; $vname = false; foreach ($vals as $key => $val) { if ($val === $new) { $vname = $key; } } $var = $old; $debug = debug_backtrace(); $call_info = array_shift($debug); $code_line = $call_info['line']; $file = explode(stristr(PHP_OS, 'WIN') ? '\\' : '/', $call_info['file']); $file = array_pop($file); $id = substr(md5(microtime()), 0, 6); $return .= sprintf('<div class="debug"><div><div class="header" style="background-color: ' . $color . ';"></div>DEBUG! (<strong>%s : %s</strong>)', $file, $code_line); if ($info != false) { $return .= ' | <strong style="color: red;">' . $info . ':</strong>'; } $return .= '</div><ul id="debug_' . $id . '"' . ($specialFX ? ' data-switch="true"' : '') . '>' . doDump($var, '$' . $vname) . '</ul>'; $return .= '</div>'; return $return; }
protected function form($user = null) { $mode = $user ? 'edit' : 'add'; $fields = data::read(root('panel.app') . DS . 'forms' . DS . 'user.' . $mode . '.php', 'yaml'); $content = $user ? $user->data() : array(); // add all languages $fields['language']['options'] = array(); $fields['language']['default'] = c::get('panel.language', 'en'); foreach (app::languages() as $code => $lang) { $fields['language']['options'][$code] = $lang->title(); } // make sure the password is never shown in the form unset($content['password']); return new Form($fields, $content); }
function _codemirrorHighlight($content, $language = '') { $objPage = Core_Classes_coreObj::getPage(); if (is_empty($content)) { return false; } $objPage->addCSSFile(array('href' => '/' . root() . 'assets/styles/codemirror-min.css', 'priority' => LOW)); $objPage->addJSFile(array('src' => '/' . root() . 'assets/javascript/codemirror-min.js', 'priority' => LOW), 'footer'); $objPage->addJSFile(array('src' => '/' . root() . 'assets/javascript/codemirror-langs-min.js', 'priority' => LOW), 'footer'); $objPage->addJSFile(array('src' => '/' . root() . 'assets/javascript/codemirror/highlighter.js', 'priority' => LOW), 'footer'); $language = grabLangInfo($language, 'mime'); $content = trim($content); $content = html_entity_decode($content, ENT_NOQUOTES); $content = str_replace('<?php', '<?php', $content); //return $content; return dump($content) . "\n<pre><span data-lang=\"" . $language . "\" data-codemir3ror=\"true\">" . $content . "</span></pre>\n"; }
function call($params) { $houses = findall(root($this), "House"); $this->numhouses = count($houses); //return json_encode( $houses ); //return $this->numhouses; if (count($houses) > 0) { $this->dice1 = rand(1, 6); $this->dice2 = rand(1, 6); //save to db root($this)->db->save($this); //root( $this )->db->save( $house ); return json_encode(clean($this)); } else { //dialog return false; } }
/** * Shows a message and then exit the current page with a footer. * * @version 2.0 * @since 0.6.0 */ function msgDie($msg_type, $message, $line = null, $file = null, $query = null, $footer = true) { $objTPL = Core_Classes_coreObj::getTPL(); $objPage = Core_Classes_coreObj::getPage(); //if(!is_object($objTPL) || !is_object($objPage)){ echo $message; exit; } $objTPL->set_filenames(array('__msgBody' => cmsROOT . 'modules/core/views/module/message/default.tpl')); $query = !is_empty($query) ? $query : null; $line = !is_empty($line) ? $line : null; $file = !is_empty($file) ? $file : null; switch (strtolower($msg_type)) { case 'fail': $img = '/' . root() . 'images/fail.png'; $type = 'error'; break; case 'ok': $img = '/' . root() . 'images/ok.png'; $type = 'status'; break; case 'info': $img = '/' . root() . 'images/info.png'; $type = 'warning'; break; default: $img = null; break; } $objTPL->assign_vars(array('L_MSG_TYPE' => langVar('MSG_' . strtoupper($msg_type)), 'L_MSG' => $message, 'QUERY' => $query, 'LINE' => 'Line: ' . $line, 'FILE' => 'File: ' . $file, 'IMG' => isset($img) && !is_empty($img) ? '<img src="' . $img . '" style="height: 48px; width: 48px;">' : '', 'ALIGN' => 'center', 'TYPE' => $type)); $gen_time = '0'; $objTPL->parse('__msgBody'); if ($footer) { $objPage->showFooter(); } exit; }
public function __construct($file, $data = array()) { parent::__construct($file, $data); $this->root = root('panel.app.layouts'); }
function call($params) { $num = count($this->houses); $bank = find(root($this), "Bank"); if ($this->cost and $num < 4 and $bank->amount > $this->cost) { $bank->amount -= $this->cost; $house = $this->add(new House($this, '{}')); root($this)->db->save($house); return json_encode(clean($house)); } else { return false; } }
/** * Makes the menu into a multidimensional array for processing * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @return void */ public function getNav() { $objSQL = Core_Classes_coreObj::getDBO(); $objTPL = Core_Classes_coreObj::getTPL(); $acpROOT = '/' . root() . 'admin/'; $query = $objSQL->queryBuilder()->select('id', 'link_url', 'link_title', 'parent_id')->from('#__menus')->orderBy('`menu_name`, `order`')->where('menu_name', '=', 'admin_menu')->build(); $results = $objSQL->fetchAll($query, 'id'); if (count($results) <= 0) { trigger_error('No results could be found for the admin menu'); return false; } foreach ($results as $id => $result) { $results[$id]['link_url'] = $result['link_url'] = str_replace('{ADMIN_ROOT}', $acpROOT, $result['link_url']); if ($result['parent_id'] !== '0') { if (!isset($results[$result['parent_id']]['subs'])) { $results[$result['parent_id']]['subs'] = array(); } $results[$result['parent_id']]['subs'][$id] = $result; unset($results[$id]); } } $this->generateNav($results); }
public function contactInfoCSS() { header('Content-type: text/css'); $css = <<<CSS .ico{ height: 21px; margin: 0 12px 0 14px; background-position: 0 center !important; padding: 0 0 0 20px; } .label{ padding-left: 25px; width: 30%; margin: 12px; line-height: 22px; cursor: n-resize; } .formTbl{ width: 100%; border: 0; } #close{ width: 23px; } CSS; $settings = $this->contactInfoSettings(); $cssTPL = '.%s { background: url("/' . root() . 'images/social/%s") no-repeat scroll 5px center transparent; }' . "\n"; foreach ($settings as $s) { if (!is_array($s)) { continue; } $css .= sprintf($cssTPL, $s['code'], $s['ico']); } die($css); }
function getAllVisibleNews() { $allNews = getVisibleNews(); $return = ""; foreach ($allNews as $news) { $return .= '<div class="article"><div class="article-header">' . ' <h1>' . $news["title"] . '</h1>' . '</div>' . $news["description"] . '<a href="' . root() . '/' . $news["link"] . '">Lire la suite</a>' . '<div class="social-media-end">' . '</div>' . '</div>'; } return $return; }
public static function form($id, $data = array()) { $fields = data::read(root('panel.app') . DS . 'forms' . DS . $id . '.php', 'yaml'); return new Form($fields, $data); }
function goodroot($f, $h = '') { //jcim() if ($h == 1) { $h = host() . '/'; } elseif ($h) { $h = http($h) . '/'; } if (substr($f, 0, 4) == 'http') { return $f; } elseif (substr($f, 0, 3) == '../') { return $f; } elseif (strpos($f, '/') === false) { return $h . 'img/' . $f; } elseif (strpos($f, 'users/') === false) { return $h . 'users/' . $f; } else { return root($f); } }
/** * Gets the comment count on the specified id * * @version 1.0.0 * @since 1.0.0 * @author Richard Clifford, Dan Aldridge * * @return bool */ function makeSubmitForm() { $rand = rand(1, 99); $objTPL = coreObj::getTPL(); $objPage = coreObj::getPage(); $objSession = coreObj::getSession(); $objForm = coreObj::getForm(); $objTPL->set_filenames(array('submitCommentsForm_' . $rand => 'modules/core/template/comments/submitComment.tpl')); $objPage->addJSFile('/' . root() . 'scripts/comments.js'); $sess_id = $_SESSION[$this->module]['comment_' . $this->module_id] = md5(time() . $rand); $objTPL->assign_vars(array('FORM_START' => $objForm->start('comments', array('method' => 'POST', 'action' => $this->aURL[0] . '?mode=postComment')), 'FORM_END' => $objForm->finish(), 'SUBMIT' => $objForm->button('submit', 'Submit'), 'L_SUBMIT_COMMENT' => 'Submit a comment:', 'TEXTAREA' => $objForm->textarea('comment', ''), 'HIDDEN' => $objForm->inputbox('sessid', 'hidden', $sess_id) . $objForm->inputbox('module', 'hidden', $this->module))); //and then output the comments to the parent template $objTPL->assign_var_from_handle('_NEW_COMMENT', 'submitCommentsForm_' . $rand); return true; }
function script($name) { return root() . '/scripts/' . $name; }
/** * Panel Constructor * * @version 1.0 * @since 1.0.0 * @author Dan Aldridge * * @return void */ public function __construct() { Core_Classes_coreObj::getPage()->addBreadcrumbs(array(array('url' => '/' . root() . 'admin/core/themes/', 'name' => 'Themes'))); }
/** * Outputs the debug onto the page * * @version 1.0 * @since 1.0.0 * @author Daniel Noel-Davies * * @return string */ public function output() { $tabs = ''; $content = ''; $output = ''; $debugTabs = array(); $objPlugin = Core_Classes_coreObj::getPlugins(); $objPage = Core_Classes_coreObj::getPage(); $objPage->addJSFile(array('src' => '/' . root() . 'assets/javascript/tabs.js'), 'footer'); $objPage->addJSFile(array('src' => '/' . root() . 'assets/javascript/debug.js'), 'footer'); // Setup the tabs $tab = $this->getGlobals(true); $debugTabs['globals'] = array('title' => 'Globals', 'content' => $tab['content']); // Setup the tabs $tab = $this->getDumpOutput(true); $debugTabs['debuglog'] = array('title' => 'Dev Debug', 'content' => $tab['content']); // Setup the tabs $tab = $this->getConfig(true); $debugTabs['config'] = array('title' => 'Config', 'content' => $tab['content']); $tab = $this->getPHPErrors(true); $debugTabs['errors'] = array('title' => sprintf('PHP / CMS Errors <div class="label label-info">%s</div>', $tab['count']), 'content' => $tab['content']); $tab = $this->getMemoryUse(true); $debugTabs['memory'] = array('title' => sprintf('Memory Usage <div class="label label-info">%s</div>', $tab['count']), 'content' => $tab['content']); $tab = $this->getSQLQueries(true); $debugTabs['queries'] = array('title' => sprintf('SQL Queries <div class="label label-info">%s</div>', $tab['count']), 'content' => $tab['content']); $tab = $this->getIncludedFiles(true); $debugTabs['included'] = array('title' => sprintf('Included Files <div class="label label-info">%s</div>', $tab['count']), 'content' => $tab['content']); $tab = $this->getTemplateInfo(true); $debugTabs['templateFiles'] = array('title' => sprintf('Template Info'), 'content' => $tab['content']); $tab = $this->getOtherTab(true); $debugTabs['other'] = array('title' => sprintf('Others', $tab['count']), 'content' => $tab['content']); // Allow developers to hook into the debug bar $extraTabs = $objPlugin->hook('CMS_DEBUGBAR_TABS'); if (is_array($extraTabs) && count($extraTabs) > 1) { foreach ($extraTabs as $tab) { $debugTabs = array_merge($debugTabs, $tab); } } $counter = 0; foreach ($debugTabs as $k => $tab) { $tabs .= sprintf('<li class="tab"><a href="javascript:;" data-toggle="tab" data-target="#%1$s">%2$s</a></li>' . "\n", $k, $tab['title']); $content .= sprintf('<div class="tab-pane content fade" id="%1$s">%2$s</div>' . "\n", $k, $tab['content']); } return sprintf('<div id="debug-tabs" data-tabs="true"><ul class="nav nav-tabs">%s</ul><div class="tab-content well">%s</div></div>' . "\n", $tabs, $content); }
<?php /** * Created by PhpStorm. * User: Thomas * Date: 26/12/2015 * Time: 14:44 */ require_once 'vue_page-builder.php'; require_once root() . '/controleurs/controleur_display_profile.php'; require_once root() . '/controleurs/objetsphp/rss/controleur_rssfeed.php'; $script = array("http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js", "javascript/scroll_to_back_to_top.js", "javascript/operations_posts.js"); head($_GET[id], 'Page de profile', 'profile, compte, utilisateur', '', $script); if (!(isset($_GET[id]) || '' !== $_GET[id])) { header('Location: ../index.php'); exit; } $liens[] = '../index.php'; $noms[] = 'accueil'; $images[] = 'static/images/favicon.svg'; createMenu($liens, $noms, $images); $fluxArray = array(); $rssurls = getRss($_GET['id']); foreach ($rssurls as $url) { try { $feed = new RssFeed($url); $fluxArray[] = $feed; } catch (Exception $e) { echo $e->getMessage() . "\n"; continue; }
<?php //philum_plugin_microsys //second door session_start(); $prg = root() . 'prog'; if ($_SESSION['dev'] == 'dev' or $_SESSION['dev'] == 'lab') { $prg .= 'b'; } require_once root() . 'params/_connectx.php'; require_once $prg . '/boot.php'; require_once $prg . '/spe.php'; //require_once($prg.'/lib.php'); $_SESSION["dayx"] = time(); $_SESSION['daya'] = $_SESSION["dayx"]; //xml function parse_msg_xml($msg) { $ar1 = array("&", "<", ">"); //'"', $ar2 = array('&', "<", ">"); //"'", $msg = str_replace($ar1, $ar2, $msg); if ($_GET["flash"]) { $msg = utf8_encode($msg); } return $msg; } /*------*/ # Boot //refresh_cache
/** * Returns an fully parsed avatar * * @version 1.0 * @since 1.0.0 * @author xLink * * @param int $uid * @param int $size * * @return string HTML of the parsed avatar. */ public function parseAvatar($uid, $size = 100) { $defaultAvatar = '/' . root() . 'images/no_avatar.png'; $avatar = $this->getUserInfo($uid, 'avatar'); if (is_empty($avatar)) { $avatar = $defaultAvatar; $_avatar = '<img src="%1$s" height="%2$s" width="%3$s" class="avatar corners" />'; return sprintf($_avatar, $avatar, $size, $size); } $avatar = secureMe(preg_replace('_^/images/_', '/' . root() . 'images/', $avatar)); $username = $this->getUserInfo($uid, 'username'); $username_avatar = $username . '_avatar'; $user = strtolower($username); $_avatar = '<a href="%1$s" class="lightwindow" title="%4$s\'s Avatar" data-avatar="%5$s">' . '<img src="%1$s" height="%2$s" width="%2$s" name="%3$s" id="%3$s" title="%4$s\'s Avatar" class="avatar corners" data-avatar="%4$s" /></a>'; return sprintf($_avatar, $avatar, $size, $username_avatar, $username, $user); }