function token($options) { if ($options[0] == "thumb") { $sub_opts = explode("|", $options[1]); foreach ($sub_opts as $opt) { $this_opts[] = explode("=", $opt); } unset($options); foreach ($this_opts as $option) { $options[$option['0']] = $option[1]; } if (isset($options['file']) && file_exists(path::file("images") . $options['file'])) { if (!isset($options['maxw'])) { $options['maxw'] = 20000; } else { $options['maxw'] = intval($options['maxw']); } if (!isset($options['maxh'])) { $options['maxh'] = 20000; } else { $options['maxh'] = intval($options['maxh']); } return $this->create_thumb($options['file'], $options['maxw'], $options['maxh']) . print_a($options, true); } } }
/** * */ function __construct() { $html = ''; if (!empty($_GET['debug']) && getperms('0')) { $debug = true; // For future use. $text = <<<TEMPL \t[html][code]Something goes here [b]bold print[/b][/code][/html] TEMPL; $_POST['content'] = $text; $_POST['mode'] = 'tohtml'; } else { $debug = false; } if ($_POST['mode'] == 'tohtml') { $html = $this->toHtml($_POST['content']); } if ($_POST['mode'] == 'tobbcode') { $html = $this->toBBcode($_POST['content']); } if ($debug == true) { print_a($html); echo "<hr />"; echo $html; } elseif ($this->gzipCompression == true) { header('Content-Encoding: gzip'); $gzipoutput = gzencode($html, 6); header('Content-Length: ' . strlen($gzipoutput)); echo $gzipoutput; } else { echo $html; } }
function debug() { echo "<h3>Event Functions</h3>"; print_a($this->functions); echo "<h3>Event Includes</h3>"; print_a($this->includes); }
/** * Update the current Repo. of this e107 installation. (eg. e107 on github) */ function gitrepo() { $mes = e107::getMessage(); $fl = e107::getFile(); if (is_dir(e_BASE . ".git")) { $gitPath = defset('e_GIT', 'git'); // addo to e107_config.php to // Change Dir. $cmd = 'cd ' . e_ROOT; $mes->addDebug($cmd); $text = `{$cmd} 2>&1`; // Remove any local changes. $cmd = $gitPath . ' reset --hard'; $mes->addDebug($cmd); $text .= `{$cmd} 2>&1`; // Run Pull request $cmd = $gitPath . ' pull'; $mes->addDebug($cmd); $text .= `{$cmd} 2>&1`; $return = print_a($text, true); $mes->addSuccess($return); if (unlink(e_BASE . "install.php")) { $mes->addDebug("Removed install.php"); } } else { $mes->addError("No git repo found"); //TODO LAN } $fl->chmod(e_BASE . "cron.php", 0755); $fl->chmod(e_HANDLER . "bounce_handler.php", 0755); }
/** * print_a表示 * * <pre> * デバック用表示(print_a)します * * Example * </pre> * <code> * {$body|printa} * </code> * * @category BEAR * @package BEAR_Smarty * @subpackage Plugin * @author Akihito Koriyama <*****@*****.**> * @copyright 2008-2011 Akihito Koriyama All rights reserved. * @license http://opensource.org/licenses/bsd-license.php BSD * @version SVN: Release: @package_version@ $Id: modifier.printa.php 2538 2011-06-12 17:37:53Z koriyama@bear-project.net $ * @link http://www.bear-project.net/ * @param string $string 文字列 * * @return $string */ function smarty_modifier_printa($string) { if (!function_exists('print_a')) { include 'BEAR/vendors/debuglib.php'; } $string = print_a($string, "return:true"); return $string; }
/** * 変数画面出力 * * @param array $values 値 * @param array $options オプション * * @return BEAR_Ro */ function outputPrint($values, array $options) { $body = print_a($values, 'return:1'); $headers = array('X-BEAR-Output: PRINT' => 'Content-Type: text/html; charset=utf-8'); $ro = BEAR::factory('BEAR_Ro'); $ro->setBody($body); $ro->setHeaders($headers); return $ro; }
/** * Process Posted Data. * @param $ui admin-ui object */ public function process($ui, $id = 0) { $data = $ui->getPosted(); $action = $ui->getAction(); // current mode: create, edit, list //e107::getHybridAuth('twitter'); e107::getMessage()->addDebug("e107_plugins/social/e_admin.php :: process method called."); e107::getMessage()->addDebug("ID: " . $id); e107::getMessage()->addDebug("Action: " . $action); e107::getMessage()->addDebug(print_a($data, true)); }
/** * Outputs a debug message, and optionally a variable's content. * * @param string $msg Message to output. * @param mixed $var Variable to be shown. */ function d($msg, $var = NULL) { echo '<span>Debug: ' . nl2br($msg) . '</span><br>'; if (!is_null($var)) { if (is_array($var)) { print_a($var, 0, TRUE); } else { print_a(array(gettype($var) => $var), 0, TRUE); } } }
function __construct() { $mes = e107::getMessage(); $frm = e107::getForm(); $tp = e107::getParser(); // $this->simulation(); $mailoutPlugins = e107::getConfig()->get('e_mailout_list'); if (empty($_GET['id'])) { return; } $tmp = base64_decode($_GET['id']); parse_str($tmp, $data); $data['plugin'] = $tp->filter($data['plugin'], 'str'); $data['email'] = $tp->filter($data['email'], 'email'); e107::getMessage()->addDebug(print_a($data, true)); $plugin = vartrue($data['plugin'], false); if (empty($data) || !e107::isInstalled($plugin) || !in_array($plugin, $mailoutPlugins)) { $this->invalidURL(); return; } $ml = e107::getAddon($plugin, 'e_mailout'); if (!empty($data['userclass'])) { $data['userclass'] = intval($data['userclass']); $listName = e107::getUserClass()->getName($data['userclass']); } else { $listName = $ml->mailerName; } if (vartrue($_POST['remove']) && !empty($data)) { if ($ml->unsubscribe('process', $data) != false) { $text = "<p><b>" . $data['email'] . "</b> has been removed from " . $listName . ".</p>"; $mes->addSuccess($text); } else { $text = "<p>There was a problem when attempting to remove <b>" . $data['email'] . "</b> from " . $listName . ".</p>"; $mes->addError($text); } echo "<div class='container'>" . $mes->render() . "</div>"; return; } if ($ml->unsubscribe('check', $data) != false) { $text = "<p>We are very sorry for the inconvenience. <br />Please click the button below to remove <b>" . $data['email'] . "</b> from <i>" . $listName . "</i>.</p>"; $text .= $frm->open('unsub', 'post', e_REQUEST_URI); $text .= $frm->button('remove', 'Remove ', 'submit'); $text .= $frm->close(); $mes->setTitle('Unsubscribe', E_MESSAGE_INFO)->addInfo($text); echo "<div class='container'>" . $mes->render() . "</div>"; return; } else { $this->invalidURL(); return; } }
/** * Available parameters (GET string format) * - cols (integer): number of items per column, default 1 * - no_fill_empty (boolean): don't fill last column with empty items (if required), default 0 * - tablestyle (string): mode to be used with <code>tablerender()</code>, default 'featurebox' * - notablestyle (null): if isset - disable <code>tablerender()</code> * - force (boolean): force category model load , default false * - ids (string): comma separated id list - load specific featurebox items, default empty * * @param string $parm parameters * @param string $mod category template * @example {FEATUREBOX=cols=2|tabs} */ function sc_featurebox($parm = null, $mod = '') { if ($parm == null && $mod == '') { $type = vartrue(e107::getPlugPref('featurebox', 'menu_category'), 'bootstrap_carousel'); $text = e107::getParser()->parseTemplate("{FEATUREBOX|" . $type . "}"); return $text; } // TODO cache if (!e107::isInstalled('featurebox')) { return ''; } if (!$mod) { $ctemplate = 'default'; } else { $ctemplate = $mod; } parse_str($parm, $parm); $category = $this->getCategoryModel($ctemplate, vartrue($parm['force']) ? true : false); $defopt = array('force' => 0, 'no_fill_empty' => 0, 'tablestyle' => 'featurebox', 'cols' => 1, 'ids' => '', 'notablestyle' => null); // reset to default, update current $category->setParams($defopt)->updateParams($parm); if (!$category->hasData()) { return ''; } $tmpl = $this->getFboxTemplate($ctemplate); $type = vartrue($tmpl['js_type'], ''); // Legacy support (prototype.js) if (vartrue($tmpl['js'])) { $tmp = explode(',', $tmpl['js']); foreach ($tmp as $file) { e107::js('footer', $file, $type); } } $tp = e107::getParser(); if (vartrue($tmpl['js_inline'])) { $data = $tp->toText($category->getData('fb_category_parms')); $jsInline = str_replace("{FEATUREBOX_PARMS}", "{" . trim($data) . "}", $tmpl['js_inline']); e107::js('footer-inline', $jsInline, $type, 3); } // Fix - don't use tablerender if no result (category could contain hidden items) $ret = $this->render($category, $ctemplate, $parm); if (empty($ret)) { e107::getMessage()->addDebug('Featurebox returned nothing.')->addDebug('Category: ' . print_a($category, true))->addDebug('Template: ' . $ctemplate)->addDebug('Param: ' . print_a($parm, true)); return ''; } $ret = $tp->parseTemplate($tmpl['list_start'], true, $category) . $ret . $tp->parseTemplate($tmpl['list_end'], true, $category); if (isset($parm['notablestyle'])) { return $ret; } return e107::getRender()->tablerender(LAN_PLUGIN_FEATUREBOX_NAME, $ret, vartrue($parm['tablestyle'], 'featurebox'), true); }
/** * Process Posted Data. * @param $ui admin-ui object */ public function process($ui) { $data = $ui->getPosted(); e107::getMessage()->addDebug(print_a($data, true)); if ($data['news_id'] && $this->active) { $excerpt = e107::getParser()->text_truncate(strip_tags(e107::getParser()->post_toHTML($data['news_body'])), 100, '...'); // $id=mysql_insert_id(); $permLink = e107::getInstance()->base_path . "comment.php?comment.news." . intval($data['news_id']); require_once e_PLUGIN . "trackback/trackbackClass.php"; $trackback = new trackbackClass(); if ($data['x_trackback_urls']) { $urlArray = explode("\n", $data['x_trackback_urls']); foreach ($urlArray as $pingurl) { if (!($terror = $trackback->sendTrackback($permLink, $pingurl, $data['news_title'], $excerpt))) { e107::getMessage()->add("Successfully pinged {$pingurl}.", E_MESSAGE_SUCCESS); } else { e107::getMessage()->add("was unable to ping {$pingurl}<br />[ Error message returned was : '{$terror}'. ]", E_MESSAGE_ERROR); } } } /* if(isset($_POST['pingback_urls'])) { if ($urlArray = $trackback->getPingUrls($data['news_body'])) //FIXME - missing method!!! { foreach($urlArray as $pingurl) { if ($trackback->sendTrackback($permLink, $pingurl, $data['news_title'], $excerpt)) { e107::getMessage()->add("Successfully pinged {$pingurl}.", E_MESSAGE_SUCCESS); } else { e107::getMessage()->add("Pingback to {$pingurl} failed ...", E_MESSAGE_ERROR); } } } else { e107::getMessage()->add("No pingback addresses were discovered", E_MESSAGE_INFO, $smessages); } } */ } /* end trackback */ }
function init() { if (!empty($_POST['version'])) { $this->version = $_POST['version']; } if (!empty($_POST['baseUrl'])) { $this->baseUrl = $_POST['baseUrl']; } if (!empty($_POST['basePath'])) { $this->basePath = $_POST['basePath']; } if (!empty($_POST)) { e107::getMessage()->addDebug(print_a($_POST, true)); } }
public function actionTest() { echo 'Login controller<br /><br />'; if (isset($_GET['lgt'])) { e107::getUser()->logout(); } echo 'Logged in: ' . (e107::getUser()->isUser() ? 'true' : 'false'); $provider = e107::getUser()->getProvider(); if ($provider) { print_a($provider->getUserProfile()); } echo '<br /><br /><a href="' . e107::getUrl()->create('system/xup/test?lgt') . '">Test logout</a>'; echo '<br /><a href="' . e107::getUrl()->create('system/xup/login?provider=Facebook') . '">Test login with Facebook</a>'; echo '<br /><a href="' . e107::getUrl()->create('system/xup/signup?provider=Facebook') . '">Test signup with Facebook</a>'; }
function render2() { $mes = e107::getMessage(); $admin_cat = e107::getNav()->adminCats(); $text = "<div class='center'>\n \t \n \t\t\t<ul class='nav nav-tabs'>"; foreach ($admin_cat['id'] as $cat_key => $cat_id) { // $text .= "<li id='tab-main_".$cat_key."' ><span style='white-space:nowrap'><img class='icon S16' src='".$admin_cat['img'][$cat_key]."' alt='' style='margin-right:3px' /><a href='#core-main_".$cat_key."'>".$admin_cat['title'][$cat_key]."</a></span></li>"; $text .= "<li id='tab-main_" . $cat_key . "' ><a data-toggle='tab' href='#core-main_" . $cat_key . "'>" . $admin_cat['title'][$cat_key] . "</a></li>"; } $text .= "</ul>"; $text .= "<div id='tab-content'>"; print_a($admin_cat); foreach ($admin_cat['id'] as $cat_key => $cat_id) { $text_check = FALSE; $text_cat = ""; if ($cat_key != 5) { foreach ($newarray as $key => $funcinfo) { if ($funcinfo[4] == $cat_key) { $text_rend = e107::getNav()->renderAdminButton($funcinfo[0], $funcinfo[1], $funcinfo[2], $funcinfo[3], $funcinfo[6], 'div'); if ($text_rend) { $text_check = TRUE; } $text_cat .= $text_rend; } } } else { $text_rend = e107::getNav()->pluginLinks(E_32_PLUGMANAGER, "div"); if ($text_rend) { $text_check = TRUE; } $text_cat .= $text_rend; } //$text_cat .= render_clean(); if ($text_check) { $text .= "<div class='tab-pane adminform' id='core-main_" . $cat_key . "'>\n"; $text .= " <div class='main_caption bevel'><b>" . $admin_cat['title'][$cat_key] . "</b></div>"; $text .= $text_cat; $text .= "</div><!-- End tab-pane -->"; } } $text .= "</div></div>"; $ns->tablerender(ADLAN_47 . " " . ADMINNAME, $mes->render() . $text); }
public function init() { if (e_AJAX_REQUEST) { $tp = e107::getParser(); if (!empty($_POST['pk']) && !empty($_POST['value'])) { $cfg = e107::getConfig(); list($plug, $key) = explode("|", $_POST['pk']); if (is_string($cfg->get('e_url_alias'))) { $cfg->setPostedData('e_url_alias', array(e_LAN => array($plug => array($key => $tp->filter($_POST['value'])))), false); } else { $cfg->setPref('e_url_alias/' . e_LAN . '/' . $plug . "/" . $key, $tp->filter($_POST['value'])); } $cfg->save(true, true, true); } // file_put_contents(e_LOG."e_url.log", print_r($cfg->get('e_url_alias'),true)); exit; } $htaccess = file_exists(e_BASE . ".htaccess"); if (function_exists('apache_get_modules')) { $modules = apache_get_modules(); $modRewrite = in_array('mod_rewrite', $modules); } else { $modRewrite = true; //we don't really know. } if ($modRewrite === false) { e107::getMessage()->addInfo("Apache mod_rewrite was not found on this server and is required to use this feature. "); e107::getMessage()->addDebug(print_a($modules, true)); } if ($htaccess && $modRewrite && !deftrue('e_MOD_REWRITE')) { e107::getMessage()->addInfo("Mod-rewrite is disabled. To enable, please add the following line to your <b>e107_config.php</b> file:<br /><pre>define('e_MOD_REWRITE',true);</pre>"); } if (is_array($_POST['rebuild'])) { $table = key($_POST['rebuild']); list($primary, $input, $output) = explode("::", $_POST['rebuild'][$table]); $this->rebuild($table, $primary, $input, $output); } $this->api = e107::getInstance(); $this->addTitle(LAN_EURL_NAME); if ($this->getAction() != 'settings') { return; } }
/** * 初期化 * * @return void */ public function onInit(array $args) { $q = $args['q']; $argv = explode(' ', $q); switch (true) { case $q == 'help': $help = <<<END Commands: clear clear screen config show application configulation. info show server info. bear bear command, type bear -h for more info. END; $this->_ajax->addAjax('js', array('shell' => "<pre>{$help}</pre>")); break; case $q == 'clear': $this->_ajax->addAjax('js', array('clear' => '')); break; case $q == 'config': $app = BEAR::get('app'); $info = '<strong>app<strong><br />' . print_a($app, 'return:1'); $this->_ajax->addAjax('js', array('shell' => $info)); break; case $q == 'info': $info = '<strong>$_SERVER<strong><br />'; $info .= print_a($_SERVER, 'return:1'); $info .= '<strong>$_ENV<strong><br />'; $info .= print_a($_ENV, 'return:1'); $info .= '<strong>$_COOKIE<strong><br />'; $info .= print_a($_COOKIE, 'return:1'); $this->_ajax->addAjax('js', array('shell' => $info)); break; case isset($argv[0]) && $argv[0] === 'bear': //bearコマンド $this->_shell($argv); break; default: $this->_ajax->addAjax('js', array('shell' => "BEAR: {$argv[0]}: Command not found<br/>")); break; } }
public function actionTest() { echo '<h3>Social Login Tester</h3>'; if (getperms('0')) { echo e107::getMessage()->addError("Please logout of e107 before testing the new-user login/signup procedure.")->render(); return; } if (isset($_GET['lgt'])) { e107::getUser()->logout(); } $profileData = null; $provider = e107::getUser()->getProvider(); if ($provider) { $profileData = $provider->getUserProfile(); if (!empty($profileData)) { print_a($profileData); } } echo 'Logged in: ' . (e107::getUser()->isUser() && !empty($profileData) ? '<span class="label label-success">true</span>' : '<span class="label label-danger">false</span>'); $testUrl = SITEURL . "?route=system/xup/test"; $providers = e107::getPref('social_login', array()); foreach ($providers as $key => $var) { if ($var['enabled'] == 1) { echo '<h3>' . $key . '</h3><ul>'; echo '<li><a class="btn btn-default" href="' . e107::getUrl()->create('system/xup/login?provider=' . $key . '&back=' . base64_encode($testUrl)) . '">Test login only with ' . $key . '</a></li>'; echo '<li><a class="btn btn-default" href="' . e107::getUrl()->create('system/xup/signup?provider=' . $key . '&back=' . base64_encode($testUrl)) . '">Test signup/login with ' . $key . '</a></li>'; echo "</ul>"; } // print_a($var); } echo '<br /><br /><a class="btn btn-default" href="' . e107::getUrl()->create('system/xup/test?lgt') . '">Test logout</a>'; /* echo '<h3>Facebook</h3>'; echo '<br /><a href="'.e107::getUrl()->create('system/xup/login?provider=Facebook').'">Test login with Facebook</a>'; echo '<br /><a href="'.e107::getUrl()->create('system/xup/signup?provider=Facebook').'">Test signup with Facebook</a>'; echo '<h3>Twitter</h3>'; echo '<br /><a href="'.e107::getUrl()->create('system/xup/login?provider=Twitter').'">Test login with Twitter</a>'; echo '<br /><a href="'.e107::getUrl()->create('system/xup/signup?provider=Twitter').'">Test signup with Twitter</a>'; */ }
function get_field($field, $where_field, $where_value, $debug = FALSE) { $this->db->select($field)->from($this->table)->where($where_field, $where_value); $query_db = $this->db->get(); if ($debug) { print_a('Arguments~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'); print_a($field); print_a($where_field); print_a($where_value); print_a('SQL returned handle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'); print_a($query_db); print_a('DB data~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'); print_a($query_db->row_array()); } else { if ($query_db->num_rows) { $results = $query_db->row_array(); return $results[$field]; } return FALSE; } }
/** * print_a() * * Funktion um ein Array optisch darzustellen * @author designerscripte.net * @category system * @version 2.5.0 * @param array $TheArray Array * @return echo optisch dargestelltes array */ function print_a($TheArray) { // Note: the function is recursive echo '<table border=1 cellpadding=1 style="border-collapse: collapse; font: 8pt Arial;">' . "\n"; $Keys = array_keys($TheArray); foreach ($Keys as $OneKey) { echo '<tr>' . "\n"; echo '<td bgcolor="#727450" style="color: #ededed;">' . "\n"; echo '<B>' . $OneKey . '</B>'; echo '</td>' . "\n"; echo '<td bgcolor="#C4C2A6">' . "\n"; if (is_array($TheArray[$OneKey])) { print_a($TheArray[$OneKey]); } else { echo $TheArray[$OneKey]; } echo '</td>' . "\n"; echo '</tr>' . "\n"; } echo '</table>' . "\n"; }
function print_a($TheArray) { // Note: the function is recursive echo "<table border=0 cellspacing=1 cellpadding=1>\n"; $Keys = array_keys($TheArray); foreach ($Keys as $OneKey) { echo "<tr>\n"; echo "<td bgcolor='#AAAAAA' valign='top'>"; echo "<B>" . $OneKey . "</B>"; echo "</td>\n"; echo "<td bgcolor='#EEEEEE' valign='top'>"; if (is_array($TheArray[$OneKey])) { print_a($TheArray[$OneKey]); } else { echo str_replace("\n", "<br>\n", $TheArray[$OneKey]); } echo "</td>\n"; echo "</tr>\n"; } echo "</table>\n"; }
/** * Get All Products By Filter. * For Product list page. * @param Request $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @author Vini Dubey * @since 29-04-2016 */ public function productList(Request $request) { // $postData = $request->all(); // echo'<pre>';print_r("hgjkgy");die("Fchg"); // print_r($_GET['cc']);die("Fchg"); $objCurl = CurlRequestHandler::getInstance(); $mytoken = env("API_TOKEN"); // $url = env("API_URL") .'/'. "product-ajax-handler"; // $data = array('api_token' => $mytoken,'method' => 'product-filter-option'); // $curlResponse = $objCurl->curlUsingPost($url, $data); // if ($curlResponse) { // return view('Product.Views.productList', ['productFilterData' => $curlResponse->data]); // } $url = env("API_URL") . '/' . "product-list"; $user_id = ''; if (Session::has('fs_customer')) { $user_id = Session::get('fs_customer')['id']; } $subcategoryName = urlencode($request->input('subcatName')); $categoryName = urlencode($request->input('catName')); $option = $request->input('option'); $limit = 6; $pageNumber = $request->input('pageNumber'); $priceRangeFrom = $request->input('priceRangeFrom'); $priceRangeUpto = $request->input('priceRangeUpto'); $gender = $request->input('gender'); $sortBy = $request->input('sort_by'); $data = array('api_token' => $mytoken, 'id' => $user_id, 'subcategory_name' => $subcategoryName, 'category_name' => $categoryName, 'option' => $option, 'limit' => $limit, 'page_number' => 1, 'price_range_from' => $priceRangeFrom, 'price_range_upto' => $priceRangeUpto, 'sort_by' => $sortBy); // $data = array('api_token' => $mytoken, 'id' => 1, 'subcategory_name' => $subcategoryName, 'category_name' => $categoryName, // 'option' => 1, 'limit' => $limit, 'page_number' => 1); // echo'<pre>';print_r($data);die("fch"); // $data = array('api_token' => $mytoken, 'id' => 1,'subcategory_name' => "Women's Clothing", 'category_name' => "Apparel", // 'option' => 1, 'limit' => 6, 'page_number' => 1, 'price_range_from' => 500, // 'price_range_upto'=> 13000, 'sort_by' => "price-desc"); $curlResponse = $objCurl->curlUsingPost($url, $data); print_a($curlResponse); if ($curlResponse) { return view('Product.Views.productList', ['productList' => $curlResponse->data]); } }
function print_a($TheArray, $arrayname = "") { $started = false; if (ob_get_level() == 0) { ob_start(); $started = true; } if (!empty($arrayname)) { echo "<strong><u>{$arrayname}</u>:</strong><br>"; } echo "<table border=1>\n"; $Keys = array_keys($TheArray); $i = 0; foreach ($Keys as $OneKey) { $i++; echo "<tr>\n"; echo "<td bgcolor='#727450'>"; echo "<B>" . $OneKey . "</B>"; echo "</td>\n"; echo "<td bgcolor='#C4C2A6'>"; if (is_array($TheArray[$OneKey])) { print_a($TheArray[$OneKey]); } else { echo $TheArray[$OneKey]; } echo "</td>\n"; echo "</tr>\n"; if ($i % 100 == 0) { ob_flush(); flush(); } } echo "</table>\n"; if ($started === true) { ob_end_flush(); } }
/** * Callback looks up and substitutes a shortcode */ function doCode($matches) { // print_a($matches); if (in_array($matches[0], $this->ignoreCodes)) { return $matches[0]; } // XXX remove all globals, $sc_style removed global $pref, $e107cache, $menu_pref, $parm, $sql; $parmArray = false; if ($this->eVars) { if ($this->eVars->isVar($matches[1])) { return $this->eVars->{$matches}[1]; } } if (strpos($matches[1], E_NL) !== false) { return $matches[0]; } if (preg_match('/^([A-Z_]*):(.*)/', $matches[1], $newMatch)) { $code = $newMatch[1]; $parmStr = trim($newMatch[2]); $debugParm = $parmStr; parse_str($parmStr, $parm); $parmArray = true; } elseif (strpos($matches[1], '=')) { list($code, $parm) = explode('=', $matches[1], 2); } else { $code = $matches[1]; $parm = ''; } //look for the $sc_mode if (strpos($code, '|')) { list($code, $sc_mode) = explode("|", $code, 2); $code = trim($code); $sc_mode = trim($sc_mode); } else { $sc_mode = ''; } if ($parmArray == false) { $parm = trim($parm); $parm = str_replace(array('[[', ']]'), array('{', '}'), $parm); } if (E107_DBG_BBSC || E107_DBG_SC || E107_DBG_TIMEDETAILS) { $sql->db_Mark_Time("SC {$code}"); } if (E107_DBG_SC) { $dbg = "<strong>"; $dbg .= '{'; $dbg .= $code; $dbg .= $parm ? '=' . htmlentities($parm) : ""; $dbg .= '}'; $dbg .= "</strong>"; // echo $dbg; return $dbg; // trigger_error('starting shortcode {'.$code.'}', E_USER_ERROR); // no longer useful - use ?[debug=bbsc] } $scCode = ''; $scFile = ''; $_path = ''; $ret = ''; $_method = 'sc_' . strtolower($code); if (is_object($this->addedCodes) && method_exists($this->addedCodes, $_method)) { $ret = $this->addedCodes->{$_method}($parm, $sc_mode); if (E107_DBG_BBSC || E107_DBG_SC || E107_DBG_TIMEDETAILS) { $_class = get_class($this->addedCodes); // "(class loaded)"; // debug. $_function = $_method; $_path = "(already loaded)"; } } elseif (is_array($this->addedCodes) && array_key_exists($code, $this->addedCodes)) { $scCode = $this->addedCodes[$code]; // $_path = print_a($this->backTrace,true); //XXX $_path = print_a($this,true); } elseif (array_key_exists($code, $this->scList)) { $scCode = $this->scList[$code]; $_path = "(loaded earlier)"; // debug. } else { //.sc file not yet loaded, or shortcode is new function type if ($this->parseSCFiles == true) { if (array_key_exists($code, $this->registered_codes)) { //shortcode is registered, let's proceed. if (isset($this->registered_codes[$code]['perms'])) { if (!check_class($this->registered_codes[$code]['perms'])) { return ''; } } switch ($this->registered_codes[$code]['type']) { case 'class': //It is batch shortcode. Load the class and call the method $_class = $this->registered_codes[$code]['class']; $_method = 'sc_' . strtolower($code); if (!$this->isScClass($_class)) { if (!class_exists($_class) && $this->registered_codes[$code]['path']) { include_once $this->registered_codes[$code]['path']; } $this->initShortcodeClass($_class, false); if (!$this->isScClass($_class)) { return ''; } // egister passed eVars object on init - call it manually? // $this->callScFunc($_class, 'setVars', $this->var); } // FIXME - register passed eVars object - BAD solution - called on EVERY sc method call // XXX - removal candidate - I really think it should be done manually (outside the parser) // via e107::getScBatch(name)->setParserVars($eVars); // $this->callScFunc($_class, 'setParserVars', $this->eVars); $wrapper = $this->callScFunc($_class, 'wrapper', null); $ret = $this->callScFuncA($_class, $_method, array($parm, $sc_mode)); /*if (method_exists($this->scClasses[$_class], $_method)) { $ret = $this->scClasses[$_class]->$_method($parm, $sc_mode); } else { echo $_class.'::'.$_method.' NOT FOUND!<br />'; }*/ break; case 'override': case 'func': case 'plugin': //It is a function, so include the file and call the function $_function = $this->registered_codes[$code]['function']; if (!function_exists($_function) && $this->registered_codes[$code]['path']) { include_once $this->registered_codes[$code]['path'] . strtolower($code) . '.php'; } if (function_exists($_function)) { $ret = call_user_func($_function, $parm, $sc_mode); } break; case 'plugin_legacy': $scFile = e_PLUGIN . strtolower($this->registered_codes[$code]['path']) . '/' . strtolower($code) . '.sc'; break; // case 'override': // $scFile = e_CORE.'override/shortcodes/'.strtolower($code).'.sc'; // break; // case 'override': // $scFile = e_CORE.'override/shortcodes/'.strtolower($code).'.sc'; // break; case 'theme': $scFile = THEME . strtolower($code) . '.sc'; break; } } else { // Code is not registered, let's look for .sc or .php file // .php file takes precedence over .sc file if (is_readable(e_CORE . 'shortcodes/single/' . strtolower($code) . '.php')) { $_function = strtolower($code) . '_shortcode'; $_class = strtolower($code); $_path = e_CORE . 'shortcodes/single/' . strtolower($code) . '.php'; include_once e_CORE . 'shortcodes/single/' . strtolower($code) . '.php'; if (class_exists($_class, false)) { // SecretR - fix array(parm, sc_mode) causing parm to become an array, see issue 424 $ret = call_user_func(array($_class, $_function), $parm, $sc_mode); } elseif (function_exists($_function)) { $ret = call_user_func($_function, $parm, $sc_mode); } } else { $scFile = e_CORE . 'shortcodes/single/' . strtolower($code) . '.sc'; $_path = $scFile; } } if ($scFile && file_exists($scFile)) { $scCode = file_get_contents($scFile); $this->scList[$code] = $scCode; $_path = $scFile; } else { // $ret = 'Missing!'; $_path .= " MISSING!"; } } if (!isset($scCode)) { if (E107_DBG_BBSC) { trigger_error('shortcode not found:{' . $code . '}', E_USER_ERROR); } return $matches[0]; } if (E107_DBG_SC && $scFile) { // echo (isset($scFile)) ? "<br />sc_file= ".str_replace(e_CORE.'shortcodes/single/', '', $scFile).'<br />' : ''; // echo "<br />sc= <b>$code</b>"; } } if ($scCode) { $ret = @eval($scCode); if ($ret === false && E107_DEBUG_LEVEL > 0) { $string = print_a($scCode, true); e107::getMessage()->addDebug('Could not parse Shortcode ' . $scFile . ' :: {' . $code . '} ' . $string); } } if (isset($ret) && ($ret != '' || is_numeric($ret))) { // Wrapper support - see contact_template.php if (isset($this->wrappers[$code]) && !empty($this->wrappers[$code])) { list($pre, $post) = explode("{---}", $this->wrappers[$code], 2); $ret = $pre . $ret . $post; } else { //if $sc_mode exists, we need it to parse $sc_style if ($sc_mode) { $code = $code . '|' . $sc_mode; } if (is_array($this->sc_style) && array_key_exists($code, $this->sc_style)) { $pre = $post = ''; // old way - pre/post keys if (is_array($this->sc_style[$code])) { if (isset($this->sc_style[$code]['pre'])) { $pre = $this->sc_style[$code]['pre']; } if (isset($this->sc_style[$code]['post'])) { $post = $this->sc_style[$code]['post']; } } else { list($pre, $post) = explode("{---}", $this->sc_style[$code], 2); } $ret = $pre . $ret . $post; } } } if (E107_DBG_SC || E107_DBG_TIMEDETAILS) { $sql->db_Mark_Time("(After SC {$code})"); } if (E107_DBG_BBSC || E107_DBG_SC || E107_DBG_TIMEDETAILS) { global $db_debug; $other = array(); if ($_class) { $other['class'] = $_class; } if (vartrue($_function)) { $other['function'] = $_function; } if (vartrue($_path)) { $other['path'] = str_replace('../', '', $_path); } if ($this->debug_legacy) { $other = $this->debug_legacy; } $info = isset($this->registered_codes[$code]) ? print_a($this->registered_codes[$code], true) : print_a($other, true); $tmp = isset($debugParm) ? $debugParm : $parm; $db_debug->logCode(2, $code, $tmp, $info); } return isset($ret) ? $ret : ''; }
$array['payment']['currency'] = $_POST['paymentCurrency']; $array['payment']['action'] = $_POST['paymentFonction']; $array['payment']['mode'] = $_POST['paymentMode']; $array['payment']['contractNumber'] = $_POST['paymentContractNumber']; $array['payment']['differedActionDate'] = $_POST['paymentDifferedActionDate']; // TRANSACTION INFO $array['transactionID'] = $_POST['transactionID']; $array['comment'] = $_POST['comment']; //PRIVATE DATA (optional) $privateData1 = array(); $privateData1['key'] = $_POST['privateDataKey1']; $privateData1['value'] = $_POST['privateDataValue1']; $payline->setPrivate($privateData1); $privateData2 = array(); $privateData2['key'] = $_POST['privateDataKey2']; $privateData2['value'] = $_POST['privateDataValue2']; $payline->setPrivate($privateData2); $privateData3 = array(); $privateData3['key'] = $_POST['privateDataKey3']; $privateData3['value'] = $_POST['privateDataValue3']; $payline->setPrivate($privateData3); //SEQUENCE NUMBER $array['sequenceNumber'] = $_POST['sequenceNumber']; // RESPONSE $response = $payline->do_refund($array); require '../demos/result/header.html'; echo '<H3>REQUEST</H3>'; print_a($array); echo '<H3>RESPONSE</H3>'; print_a($response, 0, true); require '../demos/result/footer.html';
public function beforeUpdate($new_data, $old_data, $id) { if (!empty($new_data['perms'])) { $new_data['userclass_perms'] = implode(".", $new_data['perms']); } e107::getMessage()->addDebug(print_a($new_data, true)); return $new_data; }
] }); TMPL; $output = str_replace("{e_PLUGIN_ABS}", e_PLUGIN_ABS, $text); */ $wy = new wysiwyg(); $gen = $wy->renderConfig(); if (ADMIN && e_QUERY == 'debug') { define('e_IFRAME', true); require_once HEADERF; echo "<table class='table'><tr><td>"; print_a($output); echo "</td>\n\t<td>\n\t" . print_a($gen, true) . "\n\t</td>\n\t</tr></table>"; require_once FOOTERF; } else { //ob_start(); //ob_implicit_flush(0); //header("last-modified: " . gmdate("D, d M Y H:i:s",mktime(0,0,0,15,2,2004)) . " GMT"); header('Content-type: text/javascript', TRUE); header('Content-Encoding: gzip'); $minified = e107::minify($gen); $gzipoutput = gzencode($minified, 6); header('Content-Length: ' . strlen($gzipoutput)); echo $gzipoutput; } exit; // echo_gzipped_page(); class wysiwyg
function show_vars($show_all_vars = false, $show_object_vars = false, $limit = 5) { if($limit === 0) $limit = false; if(isset($GLOBALS['no_vars'])) return; $script_globals = _script_globals(); print ' <style type="text/css" media="screen"> .vars-container { font-family: Verdana, Arial, Helvetica, Geneva, Swiss, SunSans-Regular, sans-serif; font-size: 8pt; padding:5px; } .varsname { font-weight:bold; } .showvars { background:white; border-style:dotted; border-width:1px; padding:2px; font-family: Verdana, Arial, Helvetica, Geneva, Swiss, SunSans-Regular, sans-serif; font-size:10pt; font-weight:bold;" } </style> <style type="text/css" media="print"> .showvars { display:none; visibility:invisible; } </style> '; print '<br /> <div class="showvars"> DEBUG <span style="color:red;font-weight:normal;font-size:9px;">(runtime: '.script_runtime().' sec)</span> '; $vars_arr['script_globals'] = array('global script variables', '#7ACCC8'); $vars_arr['_GET'] = array('$_GET', '#7DA7D9'); $vars_arr['_POST'] = array('$_POST', '#F49AC1'); $vars_arr['_FILES'] = array('$_FILES', '#82CA9C'); $vars_arr['_SESSION'] = array('$_SESSION', '#FCDB26'); $vars_arr['_COOKIE'] = array('$_COOKIE', '#A67C52'); if($show_all_vars) { $vars_arr['_SERVER'] = array('SERVER', '#A186BE'); $vars_arr['_ENV'] = array('ENV', '#7ACCC8'); } foreach ($vars_arr as $vars_name => $vars_data) { if($vars_name != 'script_globals') global $$vars_name; if($$vars_name) { print '<div class="vars-container" style="background-color:'.$vars_data[1].';"><span class="varsname">'.$vars_data[0].'</span><br />'; print_a($$vars_name, NULL, $show_object_vars, $limit); print '</div>'; } } print '</div>'; }
function update_706_to_800($type = '') { global $pref, $e107info; global $sysprefs, $eArrayStorage; //$mes = new messageLog; // Combined logging and message displaying handler //$mes = e107::getMessage(); $log = e107::getAdminLog(); // Used for combined logging and message displaying $sql = e107::getDb(); $sql2 = e107::getDb('sql2'); $tp = e107::getParser(); $ns = e107::getRender(); e107::getCache()->clearAll('db'); e107::getCache()->clearAll('system'); // List of unwanted $pref values which can go $obs_prefs = array('frontpage_type', 'rss_feeds', 'log_lvcount', 'zone', 'upload_allowedfiletype', 'real', 'forum_user_customtitle', 'utf-compatmode', 'frontpage_method', 'standards_mode', 'image_owner', 'im_quality', 'signup_option_timezone', 'modules', 'plug_sc', 'plug_bb', 'plug_status', 'plug_latest', 'subnews_hide_news', 'upload_storagetype'); // List of DB tables not required (includes a few from 0.6xx) $obs_tables = array('flood', 'headlines', 'stat_info', 'stat_counter', 'stat_last', 'session', 'preset', 'tinymce'); // List of DB tables newly required (defined in core_sql.php) (The existing dblog table gets renamed) // No Longer required. - automatically checked against core_sql.php. // $new_tables = array('audit_log', 'dblog', 'news_rewrite', 'core_media', 'core_media_cat','cron', 'mail_recipients', 'mail_content'); // List of core prefs that need to be converted from serialized to e107ArrayStorage. $serialized_prefs = array("'emote'", "'menu_pref'", "'search_prefs'", "'emote_default'", "'pm_prefs'"); $create_dir = array(e_MEDIA, e_SYSTEM, e_CACHE, e_CACHE_CONTENT, e_CACHE_IMAGE, e_CACHE_DB, e_LOG, e_BACKUP, e_CACHE_URL, e_TEMP, e_IMPORT); foreach ($create_dir as $dr) { if (!is_dir($dr)) { mkdir($dr, 0755); } } // List of changed DB tables (defined in core_sql.php) // No Longer required. - automatically checked against core_sql.php. // (primarily those which have changed significantly; for the odd field write some explicit code - it'll run faster) // $changed_tables = array('user', 'dblog', 'admin_log', 'userclass_classes', 'banlist', 'menus', // 'plugin', 'news', 'news_category', 'online', 'page', 'links', 'comments'); // List of changed DB tables from core plugins (defined in pluginname_sql.php file) // key = plugin directory name. Data = comma-separated list of tables to check // (primarily those which have changed significantly; for the odd field write some explicit code - it'll run faster) // No Longer required. - automatically checked by db-verify /* $pluginChangedTables = array('linkwords' => 'linkwords', 'featurebox' => 'featurebox', 'links_page' => 'links_page', 'poll' => 'polls', 'content' => 'pcontent' ); */ /* $setCorePrefs = array( //modified prefs during upgrade. 'adminstyle' => 'infopanel', 'admintheme' => 'bootstrap', 'admincss' => 'admin_style.css', 'resize_dimensions' => array( 'news-image' => array('w' => 250, 'h' => 250), 'news-bbcode' => array('w' => 250, 'h' => 250), 'page-bbcode' => array('w' => 250, 'h' => 250) ) ); */ $do_save = TRUE; // List of changed menu locations. $changeMenuPaths = array(array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'sitebutton_menu'), array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'compliance_menu'), array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'powered_by_menu'), array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'sitebutton_menu'), array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'counter_menu'), array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'latestnews_menu'), array('oldpath' => 'compliance_menu', 'newpath' => 'siteinfo', 'menu' => 'compliance_menu'), array('oldpath' => 'powered_by_menu', 'newpath' => 'siteinfo', 'menu' => 'powered_by_menu'), array('oldpath' => 'sitebutton_menu', 'newpath' => 'siteinfo', 'menu' => 'sitebutton_menu'), array('oldpath' => 'counter_menu', 'newpath' => 'siteinfo', 'menu' => 'counter_menu'), array('oldpath' => 'usertheme_menu', 'newpath' => 'user', 'menu' => 'usertheme_menu'), array('oldpath' => 'userlanguage_menu', 'newpath' => 'user', 'menu' => 'userlanguage_menu'), array('oldpath' => 'lastseen_menu', 'newpath' => 'online', 'menu' => 'lastseen_menu'), array('oldpath' => 'other_news_menu', 'newpath' => 'news', 'menu' => 'other_news_menu'), array('oldpath' => 'other_news_menu', 'newpath' => 'news', 'menu' => 'other_news2_menu'), array('oldpath' => 'user_menu', 'newpath' => 'user', 'menu' => 'usertheme_menu'), array('oldpath' => 'user_menu', 'newpath' => 'user', 'menu' => 'userlanguage_menu'), array('oldpath' => 'poll_menu', 'newpath' => 'poll', 'menu' => 'poll_menu'), array('oldpath' => 'banner_menu', 'newpath' => 'banner', 'menu' => 'banner_menu'), array('oldpath' => 'online_menu', 'newpath' => 'online', 'menu' => 'online_menu')); // List of DB tables (key) and field (value) which need changing to accommodate IPV6 addresses $ip_upgrade = array('download_requests' => 'download_request_ip', 'submitnews' => 'submitnews_ip', 'tmp' => 'tmp_ip', 'chatbox' => 'cb_ip'); $db_parser = new db_table_admin(); // Class to read table defs and process them $do_save = FALSE; // Set TRUE to update prefs when update complete $updateMessages = array(); // Used to log actions for the admin log - TODO: will go once all converted to new class $just_check = $type == 'do' ? FALSE : TRUE; // TRUE if we're just seeing whether an update is needed // if (!$just_check) // { // foreach(vartrue($setCorePrefs) as $k=>$v) // { // $pref[$k] = $v; // } // } if (!$just_check) { $log->logMessage(LAN_UPDATE_14 . $e107info['e107_version'], E_MESSAGE_NODISPLAY); } $statusTexts = array(E_MESSAGE_SUCCESS => 'Success', E_MESSAGE_ERROR => 'Fail', E_MESSAGE_INFO => 'Info'); if (isset($pref['forum_user_customtitle']) && !isset($pref['signup_option_customtitle'])) { if ($just_check) { return update_needed('pref: forum_user_customtitle needs to be renamed'); } $pref['signup_option_customtitle'] = $pref['forum_user_customtitle']; unset($pref['forum_user_customtitle']); $log->logMessage(LAN_UPDATE_20 . 'customtitle', E_MESSAGE_SUCCESS); $do_save = TRUE; } // convert all serialized core prefs to e107 ArrayStorage; $serialz_qry = "SUBSTRING( e107_value,1,5)!='array' AND e107_value !='' "; $serialz_qry .= "AND e107_name IN (" . implode(",", $serialized_prefs) . ") "; if (e107::getDb()->select("core", "*", $serialz_qry)) { if ($just_check) { return update_needed('Convert serialized core prefs'); } while ($row = e107::getDb()->fetch(MYSQL_ASSOC)) { $status = e107::getDb('sql2')->update('core', "e107_value=\"" . convert_serialized($row['e107_value']) . "\" WHERE e107_name='" . $row['e107_name'] . "'") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; $log->addDebug(LAN_UPDATE_22 . $row['e107_name'] . ": " . $status); } } if (e107::getDb()->select("core", "*", "e107_name='pm_prefs' LIMIT 1")) { if ($just_check) { return update_needed('Rename the pm prefs'); } e107::getDb()->update("core", "e107_name='plugin_pm' WHERE e107_name = 'pm_prefs'"); } //@TODO de-serialize the user_prefs also. // Banlist if (!$sql->field('banlist', 'banlist_id')) { if ($just_check) { return update_needed('Banlist table requires updating.'); } $sql->gen("ALTER TABLE #banlist DROP PRIMARY KEY"); $sql->gen("ALTER TABLE `#banlist` ADD `banlist_id` INT( 11 ) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST"); } // Move the maximum online counts from menu prefs to a separate pref - 'history' e107::getCache()->clearAll('system'); $menuConfig = e107::getConfig('menu', true, true); if ($menuConfig->get('most_members_online') || $menuConfig->get('most_guests_online') || $menuConfig->get('most_online_datestamp')) { $status = E_MESSAGE_DEBUG; if ($just_check) { return update_needed('Move online counts from menupref'); } $newPrefs = e107::getConfig('history'); foreach (array('most_members_online', 'most_guests_online', 'most_online_datestamp') as $v) { if (FALSE === $newPrefs->get($v, FALSE)) { if (FALSE !== $menuConfig->get($v, FALSE)) { $newPrefs->set($v, $menuConfig->get($v)); } else { $newPrefs->set($v, 0); } } $menuConfig->remove($v); } $result = $newPrefs->save(false, true, false); if ($result === TRUE) { $resultMessage = 'Historic member counts updated'; $result = $menuConfig->save(false, true, false); // Only re-save if successul. } elseif ($result === FALSE) { $resultMessage = 'moving historic member counts'; $status = E_MESSAGE_ERROR; } else { // No change $resultMessage = 'Historic member counts already updated'; $status = E_MESSAGE_INFO; } // $result = $menuConfig->save(false, true, false); // Save updated menuprefs - without the counts - don't delete them if it fails. //$updateMessages[] = $statusTexts[$status].': '.$resultMessage; // Admin log message $log->logMessage($resultMessage, $status); // User message } // ++++++++ Modify Menu Paths +++++++. if (varset($changeMenuPaths)) { foreach ($changeMenuPaths as $val) { $qry = "SELECT menu_path FROM `#menus` WHERE menu_name = '" . $val['menu'] . "' AND (menu_path='" . $val['oldpath'] . "' || menu_path='" . $val['oldpath'] . "/' ) LIMIT 1"; if ($sql->gen($qry)) { if ($just_check) { return update_needed('Menu path changed required: ' . $val['menu'] . ' '); } $updqry = "menu_path='" . $val['newpath'] . "/' WHERE menu_name = '" . $val['menu'] . "' AND (menu_path='" . $val['oldpath'] . "' || menu_path='" . $val['oldpath'] . "/' ) "; $status = $sql->update('menus', $updqry) ? E_MESSAGE_DEBUG : E_MESSAGE_ERROR; $log->logMessage(LAN_UPDATE_23 . '<b>' . $val['menu'] . '</b> : ' . $val['oldpath'] . ' => ' . $val['newpath'], $status); // LAN_UPDATE_25; // catch_error($sql); } } } // Leave this one here.. just in case.. //delete record for online_extended_menu (now only using one online menu) if ($sql->db_Select('menus', '*', "menu_path='online_extended_menu' || menu_path='online_extended_menu/'")) { if ($just_check) { return update_needed("The Menu table needs to have some paths corrected in its data."); } $row = $sql->db_Fetch(); //if online_extended is activated, we need to activate the new 'online' menu, and delete this record if ($row['menu_location'] != 0) { $status = $sql->update('menus', "menu_name='online_menu', menu_path='online/' WHERE menu_path='online_extended_menu' || menu_path='online_extended_menu/' ") ? E_MESSAGE_DEBUG : E_MESSAGE_ERROR; $log->logMessage(LAN_UPDATE_23 . "<b>online_menu</b> : online/", $status); } else { //else if the menu is not active //we need to delete the online_extended menu row, and change the online_menu to online $sql->delete('menus', " menu_path='online_extended_menu' || menu_path='online_extended_menu/' "); $log->logMessage(LAN_UPDATE_31, E_MESSAGE_DEBUG); } catch_error($sql); } //change menu_path for online_menu (if it still exists) if ($sql->db_Select('menus', 'menu_path', "menu_path='online_menu' || menu_path='online_menu/'")) { if ($just_check) { return update_needed('change menu_path for online menu'); } $status = $sql->update('menus', "menu_path='online/' WHERE menu_path='online_menu' || menu_path='online_menu/' ") ? E_MESSAGE_DEBUG : E_MESSAGE_ERROR; $log->logMessage(LAN_UPDATE_23 . "<b>online_menu</b> : online/", $status); catch_error($sql); } if (!$just_check) { // Alert Admin to delete deprecated menu folders. $chgPath = array(); foreach ($changeMenuPaths as $cgpArray) { if (is_dir(e_PLUGIN . $cgpArray['oldpath'])) { if (!in_array($cgpArray['oldpath'], $chgPath)) { $chgPath[] = $cgpArray['oldpath']; } } } if (count($chgPath)) { $log->addWarning(LAN_UPDATE_57 . ' '); array_unique($chgPath); asort($chgPath); foreach ($chgPath as $cgp) { $log->addWarning(e_PLUGIN_ABS . "<b>" . $cgp . "</b>"); } } } //--------------------------------------------------------- // Comments - split user field //--------------------------------------------------------- if ($sql->db_Field('comments', 'comment_author')) { if ($just_check) { return update_needed('Comment table author field update'); } if (!$sql->db_Field('comments', 'comment_author_id') && !$sql->gen("ALTER TABLE `#comments`\r\n\t\t\t\tADD COLUMN comment_author_id int(10) unsigned NOT NULL default '0' AFTER `comment_author`,\r\n\t\t\t\tADD COLUMN comment_author_name varchar(100) NOT NULL default '' AFTER `comment_author_id`")) { // Flag error // $commentMessage = LAN_UPDAXXTE_34; $log->logMessage(LAN_UPDATE_21 . "comments", E_MESSAGE_ERROR); } else { if (FALSE === $sql->update('comments', "comment_author_id=SUBSTRING_INDEX(`comment_author`,'.',1), comment_author_name=SUBSTRING(`comment_author` FROM POSITION('.' IN `comment_author`)+1)")) { // Flag error $log->logMessage(LAN_UPDATE_21 . 'comments', E_MESSAGE_ERROR); } else { // Delete superceded field - comment_author if (!$sql->gen("ALTER TABLE `#comments` DROP COLUMN `comment_author`")) { // Flag error $log->logMessage(LAN_UPDATE_24 . 'comments - comment_author', E_MESSAGE_ERROR); } } } $log->logMessage(LAN_UPDATE_21 . 'comments', E_MESSAGE_DEBUG); } // Add index to download history // Deprecated by db-verify-class // if (FALSE !== ($temp = addIndexToTable('download_requests', 'download_request_datestamp', $just_check, $updateMessages))) // { // if ($just_check) // { // return update_needed($temp); // } // } // Extra index to tmp table // Deprecated by db-verify-class // if (FALSE !== ($temp = addIndexToTable('tmp', 'tmp_time', $just_check, $updateMessages))) // { // if ($just_check) // { // return update_needed($temp); // } // } // Extra index to rss table (if used) // Deprecated by db-verify-class // if (FALSE !== ($temp = addIndexToTable('rss', 'rss_name', $just_check, $updateMessages, TRUE))) // { // if ($just_check) // { // return update_needed($temp); // } // } // Front page prefs (logic has changed) if (!isset($pref['frontpage_force'])) { if ($just_check) { return update_needed('Change front page prefs'); } $pref['frontpage_force'] = array(e_UC_PUBLIC => ''); $fpdef = vartrue($pref['frontpage']['all']) == 'index.php' ? 'index.php' : 'news.php'; $pref['frontpage'] = array(e_UC_PUBLIC => $fpdef); // $_pdateMessages[] = LAN_UPDATE_38; //FIXME $log->logMessage(LAN_UPDATE_20 . "frontpage", E_MESSAGE_DEBUG); $do_save = TRUE; } // Check need for user timezone before we delete the field if (vartrue($pref['signup_option_timezone'])) { if ($sql->db_Field('user', 'user_timezone', '', TRUE) && !$sql->db_Field('user_extended', 'user_timezone', '', TRUE)) { if ($just_check) { return update_needed('Move user timezone info'); } if (!copy_user_timezone()) { // Error doing the transfer //$updateMessages[] = LAN_UPDATE_42; $log->logMessage(LAN_UPDATE_42, E_MESSAGE_ERROR); return FALSE; } //$updateMessages[] = LAN_UPDATE_41; $log->logMessage(LAN_UPDATE_41, E_MESSAGE_DEBUG); } } // Tables defined in core_sql.php to be RENAMED. // Next bit will be needed only by the brave souls who used an early CVS - probably delete before release if ($sql->isTable('rl_history') && !$sql->isTable('dblog')) { if ($just_check) { return update_needed('Rename rl_history to dblog'); } $sql->gen('ALTER TABLE `' . MPREFIX . 'rl_history` RENAME `' . MPREFIX . 'dblog`'); //$updateMessages[] = LAN_UPDATE_44; $log->logMessage(LAN_UPDATE_44, E_MESSAGE_DEBUG); catch_error($sql); } //--------------------------------- if ($sql->isTable('dblog') && !$sql->isTable('admin_log')) { if ($just_check) { return update_needed('Rename dblog to admin_log'); } $sql->gen('ALTER TABLE `' . MPREFIX . 'dblog` RENAME `' . MPREFIX . 'admin_log`'); catch_error($sql); //$updateMessages[] = LAN_UPDATE_43; $log->logMessage(LAN_UPDATE_43, E_MESSAGE_DEBUG); } // New tables required (list at top. Definitions in core_sql.php) // ALL DEPRECATED by db_verify class.. see below. /* foreach ($new_tables as $nt) { if (!$sql->isTable($nt)) { if ($just_check) return update_needed('Add table: '.$nt); // Get the definition $defs = $db_parser->get_table_def($nt,e_ADMIN.'sql/core_sql.php'); if (count($defs)) // **** Add in table here { $status = $sql->gen('CREATE TABLE `'.MPREFIX.$defs[0][1].'` ('.$defs[0][2].') TYPE='.$defs[0][3]) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; // $updateMessages[] = LAN_UPDATE_45.$defs[0][1]; $log->logMessage(LAN_UPDATE_27.$defs[0][1], $status); // catch_error($sql); } else { // error parsing defs file $log->logMessage(LAN_UPDATE_46.$defs[0][1], E_MESSAGE_ERROR); } unset($defs); } } // Tables whose definition needs changing significantly $debugLevel = E107_DBG_SQLDETAILS; foreach ($changed_tables as $ct) { $req_defs = $db_parser->get_table_def($ct,e_ADMIN."sql/core_sql.php"); $req_fields = $db_parser->parse_field_defs($req_defs[0][2]); // Required definitions if ($debugLevel) { $log->logMessage("Required table structure: <br />".$db_parser->make_field_list($req_fields), E_MESSAGE_DEBUG); } if ((($actual_defs = $db_parser->get_current_table($ct)) === FALSE) || !is_array($actual_defs)) // Adds current default prefix { $log->logMessage("Couldn't get table structure: ".$ct, E_MESSAGE_DEBUG); } else { // echo $db_parser->make_table_list($actual_defs); $actual_fields = $db_parser->parse_field_defs($actual_defs[0][2]); if ($debugLevel) { $log->logMessage("Actual table structure: <br />".$db_parser->make_field_list($actual_fields), E_MESSAGE_DEBUG); } $diffs = $db_parser->compare_field_lists($req_fields,$actual_fields); if (count($diffs[0])) { // Changes needed if ($just_check) return update_needed("Field changes rqd; table: ".$ct); // Do the changes here if ($debugLevel) { $log->logMessage("List of changes found:<br />".$db_parser->make_changes_list($diffs), E_MESSAGE_DEBUG); } $qry = 'ALTER TABLE '.MPREFIX.$ct.' '.implode(', ',$diffs[1]); if ($debugLevel) { $log->logMessage("Update Query used: ".$qry, E_MESSAGE_DEBUG); } $status = $sql->gen($qry) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; $log->logMessage(LAN_UPDATE_21.$ct, $status); catch_error($sql); } } } // Plugin tables whose definition needs changing significantly foreach ($pluginChangedTables as $plugName => $plugList) { if (e107::isInstalled($plugName)) { $ttc = explode(',',$plugList); foreach ($ttc as $ct) { $sqlDefs = e_PLUGIN.$plugName.'/'.str_replace('_menu','',$plugName).'_sql.php'; // Filename containing definitions // echo "Looking at file: {$sqlDefs}, table {$ct}<br />"; $req_defs = $db_parser->get_table_def($ct,$sqlDefs); if (!is_array($req_defs)) { echo "Couldn't get definitions from file {$sqlDefs}<br />"; continue; } $req_fields = $db_parser->parse_field_defs($req_defs[0][2]); // Required definitions if (E107_DBG_SQLDETAILS) { $message = "Required plugin table structure: <br />".$db_parser->make_field_list($req_fields); $log->logMessage($message, E_MESSAGE_DEBUG); } if ((($actual_defs = $db_parser->get_current_table($ct)) === FALSE) || !is_array($actual_defs)) // Adds current default prefix { // echo "Couldn't get table structure: {$ct}<br />"; } else { // echo $db_parser->make_table_list($actual_defs); $actual_fields = $db_parser->parse_field_defs($actual_defs[0][2]); if (E107_DBG_SQLDETAILS) { $message= "Actual table structure: <br />".$db_parser->make_field_list($actual_fields); $log->logMessage($message, E_MESSAGE_DEBUG); } $diffs = $db_parser->compare_field_lists($req_fields,$actual_fields); if (count($diffs[0])) { // Changes needed if (E107_DBG_SQLDETAILS) { $message = "List of changes found:<br />".$db_parser->make_changes_list($diffs); $log->logMessage($message, E_MESSAGE_DEBUG); } if ($just_check) return update_needed("Field changes rqd; plugin table: ".$ct); // Do the changes here $qry = 'ALTER TABLE '.MPREFIX.$ct.' '.implode(', ',$diffs[1]); if (E107_DBG_SQLDETAILS) { $message = "Update Query used: ".$qry."<br />"; $log->logMessage($message, E_MESSAGE_DEBUG); } $sql->gen($qry); $updateMessages[] = LAN_UPDATE_51.$ct; $log->logMessage(LAN_UPDATE_51.$ct, E_MESSAGE_SUCCESS); catch_error($sql); } } } } } */ // Obsolete tables (list at top) $sql->mySQLtableList = false; // clear the cached table list. foreach ($obs_tables as $ot) { if ($sql->isTable($ot)) { if ($just_check) { return update_needed("Delete table: " . $ot); } $status = $sql->gen('DROP TABLE `' . MPREFIX . $ot . '`') ? E_MESSAGE_DEBUG : E_MESSAGE_ERROR; $log->logMessage(LAN_UPDATE_25 . $ot, $status); } } // Tables where IP address field needs updating to accommodate IPV6 // Set to varchar(45) - just in case something uses the IPV4 subnet (see http://en.wikipedia.org/wiki/IPV6#Notation) foreach ($ip_upgrade as $t => $f) { if ($sql->isTable($t)) { // Check for table - might add some core plugin tables in here if ($field_info = $sql->db_Field($t, $f, '', TRUE)) { if (strtolower($field_info['Type']) != 'varchar(45)') { if ($just_check) { return update_needed('Update IP address field ' . $f . ' in table ' . $t); } $status = $sql->gen("ALTER TABLE `" . MPREFIX . $t . "` MODIFY `{$f}` VARCHAR(45) NOT NULL DEFAULT '';") ? E_MESSAGE_DEBUG : E_MESSAGE_ERROR; $log->logMessage(LAN_UPDATE_26 . $t . ' - ' . $f, $status); // catch_error($sql); } } else { // Got a strange error here } } } // Obsolete prefs (list at top) // Intentionally do this last - we may check some of them during the update $accum = array(); foreach ($obs_prefs as $p) { if (isset($pref[$p])) { if ($just_check) { return update_needed('Remove obsolete prefs'); } unset($pref[$p]); $do_save = TRUE; $log->addDebug('Removed obsolete pref: ' . $p); // $accum[] = $p; } } /* -------------- Upgrade Entire Table Structure - Multi-Language Supported ----------------- */ // ONLY ever add fields, never deletes. require_once e_HANDLER . "db_verify_class.php"; $dbv = new db_verify(); if ($plugUpgradeReq = e107::getPlugin()->updateRequired()) { $exclude = array_keys($plugUpgradeReq); // search xxxxx_setup.php and check for 'upgrade_required()' == true. asort($exclude); } else { $exclude = false; } $dbv->compareAll($exclude); // core & plugins, but not plugins calling for an update with xxxxx_setup.php if (count($dbv->errors)) { if ($just_check) { $mes = e107::getMessage(); $log->addDebug(print_a($dbv->errors, true)); return update_needed("Database Tables require updating."); } $dbv->compileResults(); $dbv->runFix(); // Fix entire core database structure and plugins too. } // print_a($dbv->results); // print_a($dbv->fixList); //TODO - send notification messages to Log. if ($sql->field('page', 'page_theme') && $sql->gen("SELECT * FROM `#page` WHERE page_theme != '' AND menu_title = '' LIMIT 1")) { if ($just_check) { return update_needed("Pages/Menus Table requires updating."); } if ($sql->update('page', "menu_name = page_theme, menu_title = page_title, menu_text = page_text, menu_template='default', page_title = '', page_text = '' WHERE page_theme !='' AND menu_title = '' AND menu_text = '' ")) { $sql->gen("ALTER TABLE `#page` DROP page_theme "); $mes = e107::getMessage(); $log->addDebug("Successfully updated pages/menus table to new format. "); } } if ($sql->field('plugin', 'plugin_releaseUrl')) { if ($just_check) { return update_needed('plugin_releaseUrl is deprecated and needs to be removed. '); } if ($sql->gen("ALTER TABLE `#plugin` DROP `plugin_releaseUrl`")) { $log->addDebug("Successfully removed plugin_releaseUrl. "); } } // --- Notify Prefs // $notify_prefs = $sysprefs -> get('notify_prefs'); // $notify_prefs = $eArrayStorage -> ReadArray($notify_prefs); e107::getCache()->clearAll('system'); $notify_prefs = e107::getConfig('notify', true, true)->getPref(); $nt_changed = 0; if (vartrue($notify_prefs['event'])) { foreach ($notify_prefs['event'] as $e => $d) { if (isset($d['type'])) { if ($just_check) { return update_needed('Notify pref: ' . $e . ' outdated'); } switch ($d['type']) { case 'main': $notify_prefs['event'][$e]['class'] = e_UC_MAINADMIN; break; case 'class': // Should already have class defined break; case 'email': $notify_prefs['event'][$e]['class'] = 'email'; break; case 'off': // Need to disable // Need to disable default: $notify_prefs['event'][$e]['class'] = e_UC_NOBODY; // Just disable if we don't know what else to do } $nt_changed++; $notify_prefs['event'][$e]['legacy'] = 1; unset($notify_prefs['event'][$e]['type']); } } } if ($nt_changed) { $s_prefs = $tp->toDB($notify_prefs); $s_prefs = $eArrayStorage->WriteArray($s_prefs); // Could we use $sysprefs->set($s_prefs,'notify_prefs') instead - avoids caching problems ???? $status = $sql->update("core", "e107_value='" . $s_prefs . "' WHERE e107_name='notify_prefs'") !== FALSE ? E_MESSAGE_DEBUG : E_MESSAGE_ERROR; $message = str_replace('--COUNT--', $nt_changed, LAN_UPDATE_20); $log->logMessage($message, $status); } // --------------- Saved emails - copy across if (!$just_check && $sql->db_Select('generic', '*', "gen_type='massmail'")) { if ($just_check) { return update_needed('Copy across saved emails'); } require_once e_HANDLER . 'mail_manager_class.php'; $mailHandler = new e107MailManager(); $i = 0; while ($row = $sql->db_Fetch(MYSQL_ASSOC)) { $mailRecord = array('mail_create_date' => $row['gen_datestamp'], 'mail_creator' => $row['gen_user_id'], 'mail_title' => $row['gen_ip'], 'mail_subject' => $row['gen_ip'], 'mail_body' => $row['gen_chardata'], 'mail_content_status' => MAIL_STATUS_SAVED); $mailHandler->mailtoDb($mailRecord, TRUE); $mailHandler->saveEmail($mailRecord, TRUE); $sql2->delete('generic', 'gen_id=' . intval($row['gen_id'])); // Delete as we go in case operation fails part way through $i++; } unset($mailHandler); $log->logMessage(str_replace('--COUNT--', $i, LAN_UPDATE_28)); } // ------------------- Populate Plugin Table With Changes ------------------ if (!isset($pref['shortcode_legacy_list'])) { if ($just_check) { return update_needed('Legacy shortcode conversion'); } // Reset, legacy and new shortcode list will be generated in plugin update routine $pref['shortcode_legacy_list'] = array(); $pref['shortcode_list'] = array(); save_prefs(); $ep = e107::getPlugin(); $ep->update_plugins_table($mode); // scan for e_xxx changes and save to plugin table. $ep->save_addon_prefs($mode); // generate global e_xxx_list prefs from plugin table. } // This has to be done after the table is upgraded if ($sql->select('plugin', 'plugin_category', "plugin_category = ''")) { if ($just_check) { return update_needed('Update plugin table'); } require_once e_HANDLER . 'plugin_class.php'; $ep = new e107plugin(); $ep->update_plugins_table('update'); // $_pdateMessages[] = LAN_UPDATE_XX24; // catch_error($sql); } //-- Media-manger import -------------------------------------------------- // Autogenerate filetypes.xml if not found. if (!is_readable(e_SYSTEM . "filetypes.xml")) { $data = '<?xml version="1.0" encoding="utf-8"?> <e107Filetypes> <class name="253" type="zip,gz,jpg,jpeg,png,gif,xml" maxupload="2M" /> </e107Filetypes>'; file_put_contents(e_SYSTEM . "filetypes.xml", $data); } $root_media = str_replace(basename(e_MEDIA) . "/", "", e_MEDIA); $user_media_dirs = array("images", "avatars", "avatars/default", "avatars/upload", "files", "temp", "videos", "icons"); // check for old paths and rename. if (is_dir($root_media . "images") || is_dir($root_media . "temp")) { foreach ($user_media_dirs as $md) { @rename($root_media . $md, e_MEDIA . $md); } } // create sub-directories if they do not exist. if (!is_dir(e_MEDIA . "images") || !is_dir(e_MEDIA . "temp") || !is_dir(e_AVATAR_UPLOAD) || !is_dir(e_AVATAR_DEFAULT)) { foreach ($user_media_dirs as $md) { if (!is_dir(e_MEDIA . $md)) { mkdir(e_MEDIA . $md); } } } // Move Avatars to new location $av1 = e107::getFile()->get_files(e_FILE . 'public/avatars', '.jpg|.gif|.png|.GIF|.jpeg|.JPG|.PNG'); $av2 = e107::getFile()->get_files(e_IMAGE . 'avatars', '.jpg|.gif|.png|.GIF|.jpeg|.JPG|.PNG'); $avatar_images = array_merge($av1, $av2); if (count($avatar_images)) { if ($just_check) { return update_needed('Avatar paths require updating.'); } foreach ($avatar_images as $av) { $apath = strstr($av['path'], 'public/') ? e_AVATAR_UPLOAD : e_AVATAR_DEFAULT; @rename($av['path'] . $av['fname'], $apath . $av['fname']); } } // ------------------------------- if (!e107::isInstalled('download') && $sql->gen("SELECT * FROM #links WHERE link_url LIKE 'download.php%' AND link_class != '" . e_UC_NOBODY . "' LIMIT 1")) { if ($just_check) { return update_needed('Download Plugin needs to be installed.'); } // e107::getSingleton('e107plugin')->install('download',array('nolinks'=>true)); e107::getSingleton('e107plugin')->refresh('download'); } if (!e107::isInstalled('banner') && $sql->isTable('banner')) { if ($just_check) { return update_needed('Banner Table found, but plugin not installed. Needs to be refreshed.'); } e107::getSingleton('e107plugin')->refresh('banner'); } // --------------------------------- $med = e107::getMedia(); // Media Category Update if ($sql->db_Field("core_media_cat", "media_cat_nick")) { $count = $sql->gen("SELECT * FROM `#core_media_cat` WHERE media_cat_nick = '_common' "); if ($count == 1) { if ($just_check) { return update_needed('Media-Manager Categories needs to be updated.'); } $sql->update('core_media_cat', "media_cat_owner = media_cat_nick, media_cat_category = media_cat_nick WHERE media_cat_nick REGEXP '_common|news|page|_icon_16|_icon_32|_icon_48|_icon_64' "); $sql->update('core_media_cat', "media_cat_owner = '_icon', media_cat_category = media_cat_nick WHERE media_cat_nick REGEXP '_icon_16|_icon_32|_icon_48|_icon_64' "); $sql->update('core_media_cat', "media_cat_owner = 'download', media_cat_category='download_image' WHERE media_cat_nick = 'download' "); $sql->update('core_media_cat', "media_cat_owner = 'download', media_cat_category='download_thumb' WHERE media_cat_nick = 'downloadthumb' "); $sql->update('core_media_cat', "media_cat_owner = 'news', media_cat_category='news_thumb' WHERE media_cat_nick = 'newsthumb' "); $log->addDebug("core-media-cat Categories and Ownership updated"); if ($sql->gen("ALTER TABLE `" . MPREFIX . "core_media_cat` DROP `media_cat_nick`")) { $log->addDebug("core-media-cat `media_cat_nick` field removed."); } // $query = "INSERT INTO `".MPREFIX."core_media_cat` (`media_cat_id`, `media_cat_owner`, `media_cat_category`, `media_cat_title`, `media_cat_diz`, `media_cat_class`, `media_cat_image`, `media_cat_order`) VALUES // (0, 'gallery', 'gallery_1', 'Gallery 1', 'Visible to the public at /gallery.php', 0, '', 0); /// "; // // if(mysql_query($query)) // { // $log->addDebug("Added core-media-cat Gallery."); // } } } // Media Update $count = $sql->gen("SELECT * FROM `#core_media` WHERE media_category = 'newsthumb' OR media_category = 'downloadthumb' LIMIT 1 "); if ($count == 1) { if ($just_check) { return update_needed('Media-Manager Data needs to be updated.'); } $sql->update('core_media', "media_category='download_image' WHERE media_category = 'download' "); $sql->update('core_media', "media_category='download_thumb' WHERE media_category = 'downloadthumb' "); $sql->update('core_media', "media_category='news_thumb' WHERE media_category = 'newsthumb' "); $log->addDebug("core-media Category names updated"); } // Media Update - core media and core-file. $count = $sql->gen("SELECT * FROM `#core_media` WHERE media_category = '_common' LIMIT 1 "); if ($count == 1) { if ($just_check) { return update_needed('Media-Manager Category Data needs to be updated.'); } $sql->update('core_media', "media_category='_common_image' WHERE media_category = '_common' "); $log->addDebug("core-media _common Category updated"); } // Media Update - core media and core-file. CATEGORY $count = $sql->gen("SELECT * FROM `#core_media_cat` WHERE media_cat_category = '_common' LIMIT 1 "); if ($count == 1) { if ($just_check) { return update_needed('Media-Manager Category Data needs to be updated.'); } $sql->update('core_media_cat', "media_cat_category='_common_image' WHERE media_cat_category = '_common' "); $sql->gen("INSERT INTO `" . MPREFIX . "core_media_cat` VALUES(0, '_common', '_common_file', '(Common Area)', 'Media in this category will be available in all areas of admin. ', 253, '', 0);"); $sql->gen("INSERT INTO `" . MPREFIX . "core_media_cat` VALUES(0, 'download', 'download_file', 'Download Files', '', 253, '', 0);"); $log->addDebug("core-media-cat _common Category updated"); } $count = $sql->gen("SELECT * FROM `#core_media_cat` WHERE `media_cat_owner` = '_common' LIMIT 1 "); if ($count != 1) { if ($just_check) { return update_needed('Add Media-Manager Categories and Import existing images.'); } $e107_core_media_cat = array(array('media_cat_id' => 0, 'media_cat_owner' => '_common', 'media_cat_category' => '_common_image', 'media_cat_title' => '(Common Images)', 'media_cat_sef' => '', 'media_cat_diz' => 'Media in this category will be available in all areas of admin.', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '0'), array('media_cat_id' => 0, 'media_cat_owner' => '_common', 'media_cat_category' => '_common_file', 'media_cat_title' => '(Common Files)', 'media_cat_sef' => '', 'media_cat_diz' => 'Media in this category will be available in all areas of admin.', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '0'), array('media_cat_id' => 0, 'media_cat_owner' => 'news', 'media_cat_category' => 'news', 'media_cat_title' => 'News', 'media_cat_sef' => '', 'media_cat_diz' => 'Will be available in the news area.', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '1'), array('media_cat_id' => 0, 'media_cat_owner' => 'page', 'media_cat_category' => 'page', 'media_cat_title' => 'Custom Pages', 'media_cat_sef' => '', 'media_cat_diz' => 'Will be available in the custom pages area of admin.', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '0'), array('media_cat_id' => 0, 'media_cat_owner' => 'download', 'media_cat_category' => 'download_image', 'media_cat_title' => 'Download Images', 'media_cat_sef' => '', 'media_cat_diz' => '', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '0'), array('media_cat_id' => 0, 'media_cat_owner' => 'download', 'media_cat_category' => 'download_thumb', 'media_cat_title' => 'Download Thumbnails', 'media_cat_sef' => '', 'media_cat_diz' => '', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '0'), array('media_cat_id' => 0, 'media_cat_owner' => 'download', 'media_cat_category' => 'download_file', 'media_cat_title' => 'Download Files', 'media_cat_sef' => '', 'media_cat_diz' => '', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '0'), array('media_cat_id' => 0, 'media_cat_owner' => 'news', 'media_cat_category' => 'news_thumb', 'media_cat_title' => 'News Thumbnails (Legacy)', 'media_cat_sef' => '', 'media_cat_diz' => 'Legacy news thumbnails.', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '1')); foreach ($e107_core_media_cat as $insert) { $sql->insert('core_media_cat', $insert); } // $sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, '_common', '_common_image', '(Common Images)', '', 'Media in this category will be available in all areas of admin. ', 253, '', 1);"); // $sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, '_common', '_common_file', '(Common Files)', '', 'Media in this category will be available in all areas of admin. ', 253, '', 2);"); // $sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'news', 'news', 'News', '', 'Will be available in the news area. ', 253, '', 3);"); // $sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'page', 'page', 'Custom Pages', '', 'Will be available in the custom pages area of admin. ', 253, '', 4);"); // $sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'download', 'download_image','', 'Download Images', '', 253, '', 5);"); // $sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'download', 'download_thumb', '', 'Download Thumbnails', '', 253, '', 6);"); // $sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'download', 'download_file', '', 'Download Files', '', 253, '', 7);"); // mysql_query("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'gallery', 'gallery_1', 'Gallery', 'Visible to the public at /gallery.php', 0, '', 0);"); // $sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'news', 'news_thumb', 'News Thumbnails (Legacy)', '', 'Legacy news thumbnails. ', 253, '', 8);"); $med->import('news_thumb', e_IMAGE . 'newspost_images', "^thumb_"); $med->import('news', e_IMAGE . 'newspost_images'); $med->import('page', e_IMAGE . 'custom'); } else { // $log->addDebug("Media COUNT was ".$count. " LINE: ".__LINE__); } // Check for Legacy Download Images. $fl = e107::getFile(); $dl_images = $fl->get_files(e_FILE . 'downloadimages'); if (count($dl_images) && !$sql->gen("SELECT * FROM `#core_media` WHERE `media_category` = 'download_image' ")) { if ($just_check) { return update_needed('Import Download Images into Media Manager'); } $med->import('download_image', e_FILE . 'downloadimages'); $med->import('download_thumb', e_FILE . 'downloadthumbs'); } $dl_files = $fl->get_files(e_FILE . 'downloads', "", "standard", 5); // don't use e_DOWNLOAD or a loop may occur. $publicFilter = array('_FT', '^thumbs\\.db$', '^Thumbs\\.db$', '.*\\._$', '^\\.htaccess$', '^\\.cvsignore$', '^\\.ftpquota$', '^index\\.html$', '^null\\.txt$', '\\.bak$', '^.tmp'); // Default file filter (regex format) // $publicFilter = array(1); $public_files = $fl->get_files(e_FILE . 'public', '', $publicFilter); if ((count($dl_files) || count($public_files)) && !$sql->gen("SELECT * FROM `#core_media` WHERE `media_category` = 'download_file' ")) { if ($just_check) { return update_needed('Import ' . count($dl_files) . ' Download File(s) and ' . count($public_files) . ' Public File(s) into Media Manager'); } if ($sql->gen("SELECT download_url FROM `#download` ")) { $allowed_types = array(); while ($row = $sql->fetch()) { $ext = strrchr($row['download_url'], "."); $suffix = ltrim($ext, "."); if (!isset($allowed_types[$suffix])) { $allowed_types[$suffix] = $suffix; } } $allowed_types = array_unique($allowed_types); } else { $allowed_types = array('zip', 'gz', 'pdf'); } $fmask = '[a-zA-z0-9_-]+\\.(' . implode('|', $allowed_types) . ')$'; $med->import('download_file', e_DOWNLOAD, $fmask); $med->import('_common_file', e_FILE . 'public', $fmask); } $count = $sql->gen("SELECT * FROM `#core_media_cat` WHERE media_cat_owner='_icon' "); if (!$count) { if ($just_check) { return update_needed('Add icons to media-manager'); } $query = "INSERT INTO `" . MPREFIX . "core_media_cat` (`media_cat_id`, `media_cat_owner`, `media_cat_category`, `media_cat_title`, `media_cat_diz`, `media_cat_class`, `media_cat_image`, `media_cat_order`) VALUES\r\n\t\t(0, '_icon', '_icon_16', 'Icons 16px', 'Available where icons are used in admin. ', 253, '', 0),\r\n\t\t(0, '_icon', '_icon_32', 'Icons 32px', 'Available where icons are used in admin. ', 253, '', 0),\r\n\t\t(0, '_icon', '_icon_48', 'Icons 48px', 'Available where icons are used in admin. ', 253, '', 0),\r\n\t\t(0, '_icon', '_icon_64', 'Icons 64px', 'Available where icons are used in admin. ', 253, '', 0);\r\n\t\t"; if (!$sql->gen($query)) { // echo "mysyql error"; // error or already exists. } $med->importIcons(e_PLUGIN); $med->importIcons(e_IMAGE . "icons/"); $med->importIcons(e_THEME . $pref['sitetheme'] . "/images/"); $log->addDebug("Icon category added"); } // Search Clean up ---------------------------------- $searchPref = e107::getConfig('search'); if ($searchPref->getPref('core_handlers/news')) { if ($just_check) { return update_needed('Core search handlers need to be updated.'); } $searchPref->removePref('core_handlers/news')->save(false, true, false); } if ($searchPref->getPref('core_handlers/downloads')) { if ($just_check) { return update_needed('Core search handlers need to be updated.'); } $searchPref->removePref('core_handlers/downloads')->save(false, true, false); } if ($searchPref->getPref('core_handlers/pages')) { if ($just_check) { return update_needed('Core search handlers need to be updated.'); } $searchPref->removePref('core_handlers/pages')->save(false, true, false); e107::getSingleton('e107plugin')->refresh('page'); } // Clean up news keywords. - remove spaces between commas. if ($sql->select('news', 'news_id', "news_meta_keywords LIKE '%, %' LIMIT 1")) { if ($just_check) { return update_needed('News keywords contain spaces between commas and needs to be updated. '); } $sql->update('news', "news_meta_keywords = REPLACE(news_meta_keywords, ', ', ',')"); } // Any other images should be imported manually via Media Manager batch-import. // ------------------------------------------------------------------ // Check that custompages have been imported from current theme.php file if (!$just_check) { if (!is_array($pref['sitetheme_layouts']) || !vartrue($pref['sitetheme_deflayout'])) { $th = e107::getSingleton('themeHandler'); $tmp = $th->getThemeInfo($pref['sitetheme']); if ($th->setTheme($pref['sitetheme'], false)) { $log->addDebug("Updated SiteTheme prefs"); } else { $log->addDebug("Couldn't update SiteTheme prefs"); } } $log->toFile('upgrade_v1_to_v2'); if ($do_save) { save_prefs(); $log->logMessage(LAN_UPDATE_50); // $log->logMessage(implode(', ', $accum), E_MESSAGE_NODISPLAY); //$updateMessages[] = LAN_UPDATE_50.implode(', ',$accum); // Note for admin log } $log->flushMessages('UPDATE_01'); // Write admin log entry, update message handler } else { $log->toFile('upgrade_v1_to_v2_check'); } //FIXME grab message-stack from $log for the log. //if ($just_check) return TRUE; //e107::getLog()->add('UPDATE_01',LAN_UPDATE_14.$e107info['e107_version'].'[!br!]'.implode('[!br!]',$updateMessages),E_LOG_INFORMATIVE,''); // Log result of actual update return $just_check; }
/** * デバック表示描画 * * @return BEAR_Ro * @ignore */ protected function _p() { $trace = debug_backtrace(); $trace = $trace[1]; $place = " in <span style=\"color: gray;\">{$trace['file']}</span> on line {$trace['line']} "; if ($this->hasChainLink()) { $linkBody = $this->getLinkedBody(); } else { $body = $this->getBody(); } $headers = $this->_ro->getHeaders(); $request = $headers['_request']; foreach ($headers as $key => $header) { if (substr($key, 0, 1) == '_') { unset($headers[$key]); } } $linkLabel = ''; if ($this->_chainLink) { foreach ($this->_chainLink as $links) { $linkLabel .= '->' . (count($links) > 1 ? '(' . implode(',', $links) . ')' : $links[0]); } } $label = $this->_config['uri'] . $linkLabel; $labelField = '<fieldset style="color:#4F5155; border:1px solid black;padding:2px;width:10px;">'; $labelField .= '<legend style="color:black;font-size:9pt;font-weight:bold;font-family:sans-serif;">' . $label . '</legend>'; echo $labelField; if (isset($linkBody)) { print_a($linkBody); } else { $resource = array('code' => $this->getCode(), 'header' => $headers, 'body' => $this->getBody(), 'link' => $this->getLinks()); print_a($resource); } echo '</fieldset>'; $linkLabel = $linkLabel ? ' and link(s)' : ''; echo "by \"{$request}\"{$linkLabel} {$place}<br /><br />"; return $this; }
function compareit($needle, $haystack, $value = '', $disabled = false, $reverse = false) { // return "Need=".$needle."<br />hack=".$haystack."<br />val=".$val; $foundSimilar = FALSE; $foundCommon = FALSE; $ar = $this->commonPhrases; $commonArray = array_keys($ar); // Check if a common phrases was used. foreach ($ar as $def => $common) { similar_text($value, $common, $p); if (strtoupper(trim($value)) == strtoupper($common)) { //$text .= "<div style='color:yellow'><b>$common</b></div>"; $foundCommon = true; break; } elseif ($p > 75) { $foundSimilar = true; break; } $p = 0; } $text = ''; $text2 = ''; foreach ($haystack as $script) { $lines = explode("\n", $script); $text .= "<td>"; $text2 .= $reverse == true ? "<td>" : ""; $count = 1; foreach ($lines as $ln) { if (preg_match("/\\b" . $needle . "\\b/i", $ln, $mtch)) { if ($disabled) { $text .= ADMIN_WARNING_ICON; $label = " <span class='label label-important'>Must be re-enabled</span>"; $this->errors++; // $text .= "blabla"; // $class = 'alert alert-warning'; } elseif ($reverse == true) { $text .= ADMIN_TRUE_ICON; } $text .= " Line:<b>" . $count . "</b> "; // "' Found"; if ($reverse == true) { $text2 .= print_a($ln, true); } $found = true; } $count++; } if ($reverse == true && in_array($needle, $commonArray)) { $found = false; $text = "<td>"; $text2 = "<td>"; } if (empty($found)) { // echo "<br />Unused: ".$needle; if ($reverse == true) { if (in_array($needle, $commonArray)) { // print_a($needle); //$color = "background-color:#E9EAF2"; $class = ''; $text .= ADMIN_TRUE_ICON; $value = "<span class='label label-success'>" . LANG_LAN_130 . "</span>"; // Common Term. } else { // $color = "background-color:yellow"; $text .= "<a href='#' title=\"Missing\">" . ADMIN_WARNING_ICON . "</a>"; $this->errors++; $value = LANG_LAN_131; $class = "alert alert-warning"; } } elseif (empty($disabled)) { // $color = "background-color:pink"; $class = ' '; $label = " <span class='label label-important'>Unused</span>"; $text .= "-"; $this->errors++; } if (!$disabled) { $_SESSION['language-tools-unused'][] = $needle; } } $text .= "</td>"; $text2 .= $reverse == true ? "</td>" : ""; } if ($foundCommon && $found) { //$color = "background-color:yellow"; // $class = "alert alert-warning"; $label .= "<div class='label label-important'><i>" . $common . "</i> " . LANG_LAN_132 . "<br />(" . LANG_LAN_133 . " <b>" . $def . "</b> " . LANG_LAN_134 . ")</div>"; // return "<tr><td style='width:25%;'>".$needle .$disabled. "</td><td></td></tr>"; } elseif ($foundSimilar && $found && substr($def, 0, 4) == "LAN_") { // $color = "background-color:#E9EAF2"; $label .= " <span class='label label-warning' style='cursor:help' title=\"" . $common . "\">" . round($p) . "% like " . $def . "</span> "; // $disabled .= " <a class='e-tip' href='#' title=\"".$common."\">" . $def."</a>"; // $common; } if ($disabled !== false) { $color = "font-style:italic"; $class = 'muted text-important '; $label .= " <span class='label label-inverse'>Disabled</span>"; } if (empty($found) && $disabled === true) { // $needle = "<span class='e-tip' style='cursor:help' title=\"".$value."\">".$needle."</span>"; } return "<tr><td class='" . $class . "' style='width:15%;{$color}'>" . $needle . $label . "</td>\n\t<td class='" . $class . "'>" . print_r($value, true) . "</td>\n\t" . $text . $text2 . "</tr>"; }