/** * Read configuration, initialise connection to LDAP database * * @return AUTH_xxxx result code */ public function auth_login() { $this->copyAttribs = array(); $this->copyMethods = array(); $sql = e107::getDB('altAuth'); $sql->db_Select('alt_auth', '*', "auth_type = 'ldap' "); while ($row = $sql->db_Fetch()) { $ldap[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval'])); if (strpos($row['auth_parmname'], 'ldap_xf_') === 0 && $ldap[$row['auth_parmname']]) { $this->copyAttribs[substr($row['auth_parmname'], strlen('ldap_xf_'))] = $ldap[$row['auth_parmname']]; // Key = LDAP attribute. Value = e107 field name } elseif (strpos($row['auth_parmname'], 'ldap_pm_') === 0 && $ldap[$row['auth_parmname']] && $ldap[$row['auth_parmname']] != 'none') { // Any fields with non-null 'copy' methods $this->copyMethods[substr($row['auth_parmname'], strlen('ldap_pm_'))] = $ldap[$row['auth_parmname']]; // Key = e107 field name. Value = copy method } unset($row['auth_parmname']); } $this->server = explode(',', $ldap['ldap_server']); $this->serverType = $ldap['ldap_servertype']; $this->dn = $ldap['ldap_basedn']; $this->ou = $ldap['ldap_ou']; $this->usr = $ldap['ldap_user']; $this->pwd = $ldap['ldap_passwd']; $this->ldapVersion = $ldap['ldap_version']; $this->filter = isset($ldap['ldap_edirfilter']) ? $ldap['ldap_edirfilter'] : ""; if (!function_exists('ldap_connect')) { return AUTH_NORESOURCE; } if (!$this->connect()) { return AUTH_NOCONNECT; } $this->Available = TRUE; return AUTH_SUCCESS; }
public function __construct() { define('EUF_CATEGORY', 0); define('EUF_TEXT', 1); define('EUF_RADIO', 2); define('EUF_DROPDOWN', 3); define('EUF_DB_FIELD', 4); define('EUF_TEXTAREA', 5); define('EUF_INTEGER', 6); define('EUF_DATE', 7); define('EUF_LANGUAGE', 8); define('EUF_PREDEFINED', 9); // should be EUF_LIST IMO define('EUF_CHECKBOX', 10); define('EUF_PREFIELD', 11); // should be EUF_PREDEFINED, useful when creating fields from e.g. plugin XML $this->typeArray = array('text' => 1, 'radio' => 2, 'dropdown' => 3, 'db field' => 4, 'textarea' => 5, 'integer' => 6, 'date' => 7, 'language' => 8, 'list' => 9, 'checkbox' => 10, 'predefined' => 11); $this->user_extended_types = array(1 => UE_LAN_1, 2 => UE_LAN_2, 3 => UE_LAN_3, 4 => UE_LAN_4, 5 => UE_LAN_5, 6 => UE_LAN_6, 7 => LAN_DATE, 8 => UE_LAN_8, 9 => UE_LAN_9, 10 => UE_LAN_10); //load array with field names from main user table, so we can disallow these // user_new, user_timezone deleted for 0.8 $this->reserved_names = array('id', 'name', 'loginname', 'customtitle', 'password', 'sess', 'email', 'signature', 'image', 'hideemail', 'join', 'lastvisit', 'currentvisit', 'chats', 'comments', 'forums', 'ip', 'ban', 'prefs', 'viewed', 'visits', 'admin', 'login', 'class', 'baseclasslist', 'perms', 'pwchange', 'xup'); $sql = e107::getDB(); // Read in all the field and category fields // At present we load all fields into common array - may want to split system and non-system $this->catDefinitions = array(); // Categories array $this->fieldDefinitions = array(); // Field definitions array $this->nameIndex = array(); // Index of names => field IDs $this->systemCount = 0; $this->userCount = 0; if ($sql->select('user_extended_struct', '*', "user_extended_struct_text != '_system_' ORDER BY user_extended_struct_order ASC")) { while ($row = $sql->fetch(MYSQL_ASSOC)) { if ($row['user_extended_struct_type'] == 0) { // Its a category $this->catDefinitions[$row['user_extended_struct_id']] = $row; } else { // Its a field definition $this->fieldDefinitions[$row['user_extended_struct_id']] = $row; $this->nameIndex['user_' . $row['user_extended_struct_name']] = $row['user_extended_struct_id']; // Create name to ID index if ($row['user_extended_struct_text'] == '_system_') { $this->systemCount++; } else { $this->userCount++; } } } } }
function __construct() { require_once e_PLUGIN . "log/consolidate.php"; $this->lgc = new logConsolidate(); $sql = e107::getDB(); $logfile = e_LOG . 'logp_' . date('z.Y', time()) . '.php'; /* get today's logfile ... */ $pageInfo = array(); if (is_readable($logfile)) { require $logfile; } $logfile = e_LOG . 'logi_' . date('z.Y', time()) . '.php'; // $logfile = e_PLUGIN.'log/logs/logi_'.date('z.Y', time()).'.php'; if (is_readable($logfile)) { require $logfile; // e107::getMessage()->addDebug("Loading Log File: ".$logfile); } if ($sql->select('logstats', 'log_data', "log_id='pageTotal'")) { $row = $sql->fetch(); $this->dbPageInfo = unserialize($row['log_data']); // e107::getMessage()->addDebug("Loading Logstats from DB: ".print_a($this->dbPageInfo,true)); } else { $this->dbPageInfo = array(); } /* temp consolidate today's info (if it exists)... */ if (is_array($pageInfo)) { foreach ($pageInfo as $key => $info) { $key = preg_replace("/\\?.*/", "", $key); if (array_key_exists($key, $this->dbPageInfo)) { $this->dbPageInfo[$key]['ttlv'] += $info['ttl']; $this->dbPageInfo[$key]['unqv'] += $info['unq']; } else { $this->dbPageInfo[$key]['url'] = $info['url']; $this->dbPageInfo[$key]['ttlv'] = $info['ttl']; $this->dbPageInfo[$key]['unqv'] = $info['unq']; } } } }
function show_rules() { $pref = e107::getPref(); $ns = e107::getRender(); $sql = e107::getDB(); $tp = e107::getParser(); $frm = e107::getForm(); /* $sql->select("wmessage"); list($null) = $sql->fetch(); list($null) = $sql->fetch(); list($null) = $sql->fetch(); list($id, $guestrules, $wm_active4) = $sql->fetch(); list($id, $memberrules, $wm_active5) = $sql->fetch(); list($id, $adminrules, $wm_active6) = $sql->fetch(); */ if ($sql->select('generic', '*', "gen_type='forum_rules_guest'")) { $guest_rules = $sql->fetch(); } if ($sql->select('generic', '*', "gen_type='forum_rules_member'")) { $member_rules = $sql->fetch(); } if ($sql->select('generic', '*', "gen_type='forum_rules_admin'")) { $admin_rules = $sql->fetch(); } $guesttext = $tp->toForm(vartrue($guest_rules['gen_chardata'])); $membertext = $tp->toForm(vartrue($member_rules['gen_chardata'])); $admintext = $tp->toForm(vartrue($admin_rules['gen_chardata'])); $text = "\n\t\t\t<form method='post' action='" . e_SELF . "?rules' id='wmform'>\n\t\t\t<table class='table adminform'>\n\t\t\t<colgroup span='2'>\n \t\t\t<col class='col-label' />\n \t\t\t<col class='col-control' />\n \t\t</colgroup>\n\t\t\t<tr>\n\t\t\t\t<td>" . WMGLAN_1 . ": <br />\n\t\t\t\t" . WMGLAN_6 . ":"; if (vartrue($guest_rules['gen_intdata'])) { $text .= "<input type='checkbox' name='guest_active' value='1' checked='checked' />"; } else { $text .= "<input type='checkbox' name='guest_active' value='1' />"; } $text .= "</td>\n\t\t\t\t\n\t\t\t\t<td>\n\t\t\t\t\t" . $frm->bbarea('guestrules', $guesttext) . " \n\t\t\t\t</td>\n\t\t\t</tr>\n\n\t\t\t<tr>\n\t\t\t\t<td>" . WMGLAN_2 . ": <br />\n\t\t\t\t" . WMGLAN_6 . ":"; if (vartrue($member_rules['gen_intdata'])) { $text .= "<input type='checkbox' name='member_active' value='1' checked='checked' />"; } else { $text .= "<input type='checkbox' name='member_active' value='1' />"; } $text .= "</td>\n\t\t\t\t\n\t\t\t\t<td>\n\t\t\t\t\t" . $frm->bbarea('memberrules', $membertext) . "\n\t\t\t\t</td>\n\t\t\t</tr>\n\n\t\t\t<tr>\n\t\t\t\t<td>" . WMGLAN_3 . ": <br />\n\t\t\t\t" . WMGLAN_6 . ": "; if (vartrue($admin_rules['gen_intdata'])) { $text .= "<input type='checkbox' name='admin_active' value='1' checked='checked' />"; } else { $text .= "<input type='checkbox' name='admin_active' value='1' />"; } $text .= "</td>\n\t\t\t\t<td>\n\t\t\t\t\t" . $frm->bbarea('adminrules', $admintext) . " \n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t\t<div class='buttons-bar center'>\n\t\t\t\t" . $frm->admin_button('frsubmit', LAN_UPDATE, 'submit') . "\n\t\t\t</div>\n\t\t\t</form>"; $ns->tablerender(WMGLAN_5, $text); echo "\n\t\t\t<script type=\"text/javascript\">\n\t\t\tfunction addtext1(sc){\n\t\t\t\tdocument.getElementById('wmform').guestrules.value += sc;\n\t\t\t}\n\t\t\tfunction addtext2(sc){\n\t\t\t\tdocument.getElementById('wmform').memberrules.value += sc;\n\t\t\t}\n\t\t\tfunction addtext3(sc){\n\t\t\t\tdocument.getElementById('wmform').adminrules.value += sc;\n\t\t\t}\n\t\t\tfunction help1(help){\n\t\t\t\tdocument.getElementById('wmform').helpguest.value = help;\n\t\t\t}\n\t\t\tfunction help2(help){\n\t\t\t\tdocument.getElementById('wmform').helpmember.value = help;\n\t\t\t}\n\t\t\tfunction help3(help){\n\t\t\t\tdocument.getElementById('wmform').helpadmin.value = help;\n\t\t\t}\n\t\t\t</script>\n\t\t\t"; }
function sc_admin_siteinfo($parm = '') { if ($parm == 'creditsonly' && e_PAGE != "credits.php" && e_PAGE != "phpinfo.php") { return; } if (ADMIN) { global $ns, $pref, $themename, $themeversion, $themeauthor, $themedate, $themeinfo, $mySQLdefaultdb; if (file_exists(e_ADMIN . 'ver.php')) { include e_ADMIN . 'ver.php'; } if ($parm == "version") { return $e107info['e107_version']; } $obj = e107::getDateConvert(); $install_date = $obj->convert_date($pref['install_date'], 'long'); if (is_readable(THEME . "theme.xml")) { $xml = e107::getXml(); $data = $xml->loadXMLfile(THEME . "theme.xml", true); $themename = $data['@attributes']['name']; $themeversion = $data['@attributes']['version']; $themedate = $data['@attributes']['date']; $themeauthor = $data['author']['@attributes']['name']; } $text = "<b>" . FOOTLAN_1 . "</b>\n\t\t\t<br />" . SITENAME . "\n\t\t\t<br /><br />\n\t\t\t<b>" . FOOTLAN_2 . "</b>\n\t\t\t<br />\n\t\t\t<a href=\"mailto:" . SITEADMINEMAIL . "\">" . SITEADMIN . "</a>\n\t\t\t<br />\n\t\t\t<br />\n\t\t\t<b>e107</b>\n\t\t\t<br />\n\t\t\t" . FOOTLAN_3 . " " . $e107info['e107_version'] . "\n\t\t\t<br /><br />\n\t\t\t<b>" . FOOTLAN_20 . "</b>\n\t\t\t<br />\n\t\t\t[" . e_SECURITY_LEVEL . "] " . defset('LAN_SECURITYL_' . e_SECURITY_LEVEL, 'n/a') . " \n\t\t\t<br /><br />\n\t\t\t<b>" . FOOTLAN_18 . "</b>\n\t\t\t<br />" . $pref['sitetheme'] . "<br /><br />\n\t\t\t<b>" . FOOTLAN_5 . "</b>\n\t\t\t<br />\n\t\t\t" . $themename . " v" . $themeversion . " " . ($themeauthor ? FOOTLAN_6 . ' ' . $themeauthor : '') . " " . ($themedate ? "(" . $themedate . ")" : ""); $text .= $themeinfo ? "<br />" . FOOTLAN_7 . ": " . $themeinfo : ''; $text .= "<br /><br />\n\t\t\t<b>" . FOOTLAN_8 . "</b>\n\t\t\t<br />\n\t\t\t" . $install_date . "\n\t\t\t<br /><br />\n\t\t\t<b>" . FOOTLAN_9 . "</b>\n\t\t\t<br />" . preg_replace("/PHP.*/i", "", $_SERVER['SERVER_SOFTWARE']) . "<br />(" . FOOTLAN_10 . ": " . $_SERVER['SERVER_NAME'] . ")\n\t\t\t<br /><br />\n\t\t\t<b>" . FOOTLAN_11 . "</b>\n\t\t\t<br />\n\t\t\t" . phpversion() . "\n\t\t\t<br /><br />\n\t\t\t<b>" . FOOTLAN_12 . "</b>\n\t\t\t<br />\n\t\t\t" . e107::getDB()->mySqlServerInfo . "<br />\n\t\t\t" . FOOTLAN_16 . ": " . $mySQLdefaultdb . "\n\t\t\t<br /><br />\n\t\t\t<b>" . FOOTLAN_17 . "</b>\n\t\t\t<br />utf-8\n\t\t\t<br /><br />\n\t\t\t<b>" . FOOTLAN_19 . "</b>\n\t\t\t<br />\n\t\t\t" . date('r') . "<br />"; return $ns->tablerender(FOOTLAN_13, $text, '', TRUE); } }
/** * Render menu * * @param string $mpath menu path * @param string $mname menu name * @param string $parm menu parameters * @param boolean $return * return string if required */ public function renderMenu($mpath, $mname = '', $parm = '', $return = false) { // global $sql; // required at the moment. global $sc_style, $e107_debug; $sql = e107::getDb(); $ns = e107::getRender(); $tp = e107::getParser(); if ($tmp = e107::unserialize($parm)) { $parm = $tmp; unset($tmp); } $this->_current_parms = $parm; $this->_current_menu = $mname; if ($return) { ob_start(); } if (e_DEBUG === true) { echo "\n<!-- Menu Start: " . $mname . " -->\n"; } e107::getDB()->db_Mark_Time($mname); if (is_numeric($mpath) || $mname === false) { $query = $mname === false ? "menu_name = '" . $mpath . "' " : "page_id=" . intval($mpath) . " "; // load by ID or load by menu-name (menu_name) $sql->select("page", "*", $query); $page = $sql->fetch(); if (!empty($page['menu_class']) && !check_class($page['menu_class'])) { echo "\n<!-- Menu not rendered due to userclass settings -->\n"; return; } $caption = vartrue($page['menu_icon']) ? $tp->toIcon($page['menu_icon']) : ''; $caption .= $tp->toHTML($page['menu_title'], true, 'parse_sc, constants'); if (vartrue($page['menu_template'])) { $template = e107::getCoreTemplate('menu', $page['menu_template'], true, true); // override and merge required. ie. when menu template is not in the theme, but only in the core. $page_shortcodes = e107::getScBatch('page', null, 'cpage'); $page_shortcodes->setVars($page); $head = $tp->parseTemplate($template['start'], true); $foot = $tp->parseTemplate($template['end'], true); // print_a($template['body']); $text = $head . $tp->parseTemplate($template['body'], true, $page_shortcodes) . $template['end']; // echo "TEMPLATE= ($mpath)".$page['menu_template']; // if($template['noTableRender'] !==true) // XXX Deprecated - causes confusion while themeing. use {SETSTYLE=none} instead. // { $ns->tablerender($caption, $text, 'cmenu-' . $page['menu_template']); // } // else // { // echo $text; // } } else { $text = $tp->toHTML($page['menu_text'], true, 'parse_sc, constants'); $ns->tablerender($caption, $text, 'cmenu'); } } else { // not sure what would break this, but it's good idea to go away e107::loadLanFiles($mpath); //include once is not an option anymore //e107_include will break many old menus (evil globals), so we'll wait for a while... //e107_include(e_PLUGIN.$mpath."/".$mname.".php"); //if(substr($mpath,-1)!='/') //{ // $mpath .= '/'; //} $mpath = trim($mpath, '/') . '/'; // faster... $e107_debug ? include e_PLUGIN . $mpath . $mname . '.php' : @(include e_PLUGIN . $mpath . $mname . '.php'); } e107::getDB()->db_Mark_Time("(After " . $mname . ")"); if ($error_handler->debug == true) { echo "\n<!-- Menu End: " . $mname . " -->\n"; } if ($return) { $ret = ob_get_contents(); ob_end_clean(); return $ret; } }
/** * Clear page access from DB entry (doesn't modify today's stats) * * @param string $toremove - the page name to remove * * @return boolean TRUE for success, FALSE if no entry found */ function remove_entry($toremove) { // Note - only removes info from the database - not from the current page file $sql = e107::getDB(); if ($sql->select("logstats", "*", "log_id='pageTotal'")) { $row = $sql->db_Fetch(); $dbPageInfo = unserialize($row[2]); unset($dbPageInfo[$toremove]); $dbPageDone = serialize($dbPageInfo); $sql->db_Update("logstats", "log_data='{$dbPageDone}' WHERE log_id='pageTotal' "); return TRUE; } return FALSE; }
/** * Get configuration parameters for an authentication method * * @param string $prefix - the method * * @return array */ function altAuthGetParams($prefix) { $sql = e107::getDB(); $sql->db_Select('alt_auth', '*', "auth_type = '" . $prefix . "' "); $parm = array(); while ($row = $sql->db_Fetch()) { $parm[$row['auth_parmname']] = base64_decode(base64_decode($row['auth_parmval'])); } return $parm; }
/* </div> </div> </div> */ $text .= $ns->tablerender("e107 News", $panelRSS, "core-infopanel_news", true); // ---------------------Latest Stuff --------------------------- require_once e_CORE . "shortcodes/batch/admin_shortcodes.php"; $text .= $ns->tablerender(ADLAN_LAT_1, $tp->parseTemplate("{ADMIN_LATEST=norender}"), "core-infopanel_latest", true); $text .= $ns->tablerender(LAN_STATUS, $tp->parseTemplate("{ADMIN_STATUS=norender}"), "core-infopanel_latest", true); // ---------------------- Who's Online ------------------------ // TODO Could use a new _menu item instead. $nOnline = e107::getDB()->db_Select('online', '*'); $panelOnline = "\n\t\n\t\t<table class='table adminlist'>\n\t\t<colgroup>\n\t\t\t<col style='width: 10%' />\n <col style='width: 25%' />\n\t\t\t<col style='width: 10%' />\n\t\t\t<col style='width: 40%' />\n\t\t\t<col style='width: auto' />\n\t\t</colgroup>\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>Timestamp</th>\n\t\t\t\t<th>Username</th>\n\t\t\t\t<th>IP</th>\n\t\t\t\t<th>Page</th>\n\t\t\t\t<th>Agent</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>"; if (e107::getDB()->db_Select('online', '*', "online_ip !='' LIMIT 20")) { $newsarray = $e107->sql->db_getList(); foreach ($newsarray as $key => $val) { $panelOnline .= "<tr>\n\t\t\t\t<td class='nowrap'>" . e107::getDateConvert()->convert_date($val['online_timestamp'], '%H:%M:%S') . "</td>\n\t\t\t\t\t<td>" . renderOnlineName($val['online_user_id']) . "</td>\n\t\t\t\t\t<td>" . e107::getIPHandler()->ipDecode($val['online_ip']) . "</td>\n\t\t\t\t\t<td><a href='" . $val['online_location'] . "' title='" . $val['online_location'] . "'>" . $tp->text_truncate($val['online_location'], 50, '...') . "</a></td>\n\t\t\t\t\t<td>" . $tp->text_truncate(str_replace("/", " / ", $val['online_agent']), 20, '...') . "</td>\n\t\t\t\t</tr>\n\t\t\t\t"; } } $panelOnline .= "</tbody></table>\n\t"; $text .= $ns->tablerender('Visitors Online : ' . $nOnline, $panelOnline, 'core-infopanel_online', true); // --------------------- User Selected Menus ------------------- if (varset($pref['core-infopanel-menus'])) { foreach ($pref['core-infopanel-menus'] as $val) { $id = $frm->name2id('core-infopanel_' . $val); $inc = $tp->parseTemplate("{PLUGIN={$val}|TRUE}"); $text .= $inc; // $text .= $ns->tablerender("", $inc, $id,true); }
function manage_tables($action, $var) { $sql = e107::getDB(); $mes = e107::getMessage(); if (!is_array($var)) { return FALSE; } // Return if nothing to do $error = false; $error_data = array(); switch ($action) { case 'add': foreach ($var as $tab) { $tab = str_replace("TYPE=MyISAM", "ENGINE=MyISAM", $tab); $tab = str_replace("IF NOT EXISTS", "", $tab); if (!preg_match("/MyISAM.*CHARSET ?= ?utf8/i", $tab)) { $tab = str_replace("MyISAM", "MyISAM DEFAULT CHARSET=utf8", $tab); } $mes->addDebug($tab); if (false === $sql->db_Query($tab)) { $error = true; $error_data[] = $tab; } } break; case 'upgrade': foreach ($var as $tab) { if (false === $sql->db_Query_all($tab)) { $error = true; $error_data[] = $tab; } } break; case 'remove': foreach ($var as $tab) { $qry = 'DROP TABLE ' . MPREFIX . $tab; if (!$sql->db_Query_all($qry)) { $error = true; $error_data[] = $tab; } } break; } // doesn't exit the loop now, returns true on success // or error queries (string) return !$error ? true : (!empty(${$error_data}) ? implode('<br />', $error_data) : false); }
function manage_tables($action, $var) { $sql = e107::getDB(); if (!is_array($var)) { return FALSE; } // Return if nothing to do $error = false; $error_data = array(); switch ($action) { case 'add': foreach ($var as $tab) { if (false === $sql->db_Query($tab)) { $error = true; $error_data[] = $tab; } } break; case 'upgrade': foreach ($var as $tab) { if (false === $sql->db_Query_all($tab)) { $error = true; $error_data[] = $tab; } } break; case 'remove': foreach ($var as $tab) { $qry = 'DROP TABLE ' . MPREFIX . $tab; if (!$sql->db_Query_all($qry)) { $error = true; $error_data[] = $tab; } } break; } // doesn't exit the loop now, returns true on success // or error queries (string) return !$error ? true : (!empty(${$error_data}) ? implode('<br />', $error_data) : false); }
<?php require_once "../../class2.php"; e107::js('test', 'js/my.js', 'jquery'); e107::css('test', 'css/my.css'); e107::lan('test'); e107::meta('keywords', 'some words'); require_once HEADERF; $sql = e107::getDB(); $tp = e107::getParser(); $frm = e107::getForm(); $ns = e107::getRender(); require_once "functions.php"; require_once "database.php"; $text = ""; if (isset($_POST['required_amount'])) { $db_class = new database(); $db_class->setDb($sql); $today = date("Y-m-d H:i:s"); $db_class->setDate($today); $db_class->setEmail($_POST['email']); $db_class->setDiscount($_POST['discount']); $db_class->setCurrency($_POST['select_currency']); $db_class->setExchangerate($_POST['exchange_rate']); $db_class->setSurchargepercent($_POST['surcharge_percentage']); $db_class->setPurchasedcurrency($_POST['required_amount']); if ($_POST['select_currency'] == 'EUR') { $extrainfo = 'We have applied a 2.0% discount'; $newprice = $_POST['due_amount'] * ((100 - $_POST['discount']) / 100); $db_class->setAmountdue($newprice); } else {
/** * Render menu * * @param string $mpath menu path * @param string $mname menu name * @param string $parm menu parameters * @param boolean $return * return string if required */ public function renderMenu($mpath, $mname, $parm = '', $return = false) { global $sql; // required at the moment. global $ns, $tp, $sc_style, $e107_debug; $e107 = e107::getInstance(); if ($return) { ob_start(); } if (vartrue($error_handler->debug)) { echo "\n<!-- Menu Start: " . $mname . " -->\n"; } e107::getDB()->db_Mark_Time($mname); if (is_numeric($mpath)) { $sql->db_Select("page", "*", "page_id=" . intval($mpath) . " "); $page = $sql->db_Fetch(); $caption = $e107->tp->toHTML($page['page_title'], true, 'parse_sc, constants'); $text = $e107->tp->toHTML($page['page_text'], true, 'parse_sc, constants'); e107::getRender()->tablerender($caption, $text); } else { // not sure what would break this, but it's good idea to go away e107::loadLanFiles($mpath); //include once is not an option anymore //e107_include will break many old menus (evil globals), so we'll wait for a while... //e107_include(e_PLUGIN.$mpath."/".$mname.".php"); //if(substr($mpath,-1)!='/') //{ // $mpath .= '/'; //} $mpath = trim($mpath, '/') . '/'; // faster... $e107_debug ? include e_PLUGIN . $mpath . $mname . '.php' : @(include e_PLUGIN . $mpath . $mname . '.php'); /*if(file_exists(e_PLUGIN.$mpath."/".$mname.".php")) { include_once (e_PLUGIN.$mpath."/".$mname.".php"); }*/ } e107::getDB()->db_Mark_Time("(After " . $mname . ")"); if ($error_handler->debug == true) { echo "\n<!-- Menu End: " . $mname . " -->\n"; } if ($return) { $ret = ob_get_contents(); ob_end_clean(); return $ret; } }
function checkAllPlugins() { global $pref; $sql = e107::getDB(); if ($sql->db_Select_Gen("SELECT * FROM #plugin WHERE plugin_installflag = 1 AND plugin_releaseUrl !=''")) { while ($row = $sql->db_Fetch()) { $options = array('curFolder' => $row['plugin_path'], 'curVersion' => $row['plugin_version'], 'releaseUrl' => $row['plugin_releaseUrl']); $this->setOptions($options); $this->releaseCheck('plugin', FALSE); } } }
private function getStats($type) { if (file_exists(e_PLUGIN . "awstats/awstats.graph.php")) { require_once e_PLUGIN . "awstats/awstats.graph.php"; $stat = new awstats(); if ($data = $stat->getData()) { return $data; } // return; } if ($type == 'demo') { $data = array(); $data['labels'] = array("January", "February", "March", "April", "May", "June", "July"); $data['datasets'][] = array('fillColor' => "rgba(220,220,220,0.5)", 'strokeColor' => "rgba(220,220,220,1)", 'pointColor ' => "rgba(220,220,220,1)", 'pointStrokeColor' => "#fff", 'data' => array(65, 59, 90, 81, 56, 55, 40), 'title' => "Visits"); $data['datasets'][] = array('fillColor' => "rgba(151,187,205,0.5)", 'strokeColor' => "rgba(151,187,205,1)", 'pointColor ' => "rgba(151,187,205,1)", 'pointStrokeColor' => "#fff", 'data' => array(28, 48, 40, 19, 96, 27, 100), 'title' => "Unique Visits"); return $data; } $sql = e107::getDB(); $td = date("Y-m-j", time()); $dayarray[$td] = array(); $pagearray = array(); $qry = "\n\t\tSELECT * from #logstats WHERE log_id REGEXP('[[:digit:]]+\\-[[:digit:]]+\\-[[:digit:]]+')\n\t\tORDER BY CONCAT(LEFT(log_id,4), SUBSTRING(log_id, 6, 2), LPAD(SUBSTRING(log_id, 9), 2, '0'))\n\t\tDESC LIMIT 0,9\n\t\t"; if ($amount = $sql->gen($qry)) { $array = $sql->db_getList(); $ttotal = 0; $utotal = 0; foreach ($array as $key => $value) { extract($value); if (is_array($log_data)) { $entries[0] = $log_data['host']; $entries[1] = $log_data['date']; $entries[2] = $log_data['os']; $entries[3] = $log_data['browser']; $entries[4] = $log_data['screen']; $entries[5] = $log_data['referer']; } else { $entries = explode(chr(1), $log_data); } $dayarray[$log_id]['daytotal'] = $entries[0]; $dayarray[$log_id]['dayunique'] = $entries[1]; unset($entries[0]); unset($entries[1]); foreach ($entries as $entry) { if ($entry) { list($url, $total, $unique) = explode("|", $entry); if (strstr($url, "/")) { $urlname = preg_replace("/\\.php|\\?.*/", "", substr($url, strrpos($url, "/") + 1)); } else { $urlname = preg_replace("/\\.php|\\?.*/", "", $url); } $dayarray[$log_id][$urlname] = array('url' => $url, 'total' => $total, 'unique' => $unique); if (!isset($pagearray[$urlname]['total'])) { $pagearray[$urlname]['total'] = 0; } if (!isset($pagearray[$urlname]['unique'])) { $pagearray[$urlname]['unique'] = 0; } $pagearray[$urlname]['total'] += $total; $pagearray[$urlname]['unique'] += $unique; $ttotal += $total; $utotal += $unique; } } } } $logfile = e_LOG . 'logp_' . date('z.Y', time()) . '.php'; // was logi_ ?? if (is_readable($logfile)) { require $logfile; } if (vartrue($pageInfo)) { foreach ($pageInfo as $fkey => $fvalue) { $dayarray[$td][$fkey]['total'] += $fvalue['ttl']; $dayarray[$td][$fkey]['unique'] += $fvalue['unq']; $dayarray[$td]['daytotal'] += $fvalue['ttl']; $dayarray[$td]['dayunique'] += $fvalue['unq']; $pagearray[$fkey]['total'] += $fvalue['ttl']; $pagearray[$fkey]['unique'] += $fvalue['unq']; $ttotal += $fvalue['ttl']; $utotal += $fvalue['unq']; } } $visitors = array(); $unique = array(); ksort($dayarray); foreach ($dayarray as $k => $v) { $unix = strtotime($k); $visitors[] = intval(vartrue($v['daytotal'])); $unique[] = intval(vartrue($v['dayunique'])); $label[] = "'" . date("D", $unix) . "'"; } $data = array(); $data['labels'] = $label; //visitors $data['datasets'][] = array('fillColor' => "rgba(220,220,220,0.5)", 'strokeColor' => "rgba(220,220,220,1)", 'pointColor ' => "rgba(220,220,220,1)", 'pointStrokeColor' => "#fff", 'data' => $visitors); //Unique Visitors $data['datasets'][] = array('fillColor' => "rgba(151,187,205,0.5)", 'strokeColor' => "rgba(151,187,205,1)", 'pointColor ' => "rgba(151,187,205,1)", 'pointStrokeColor' => "#fff", 'data' => $unique); return $data; }
/** * Import an e107 XML file into site preferences and DB tables * * @param path $file - e107 XML file path * @param string $mode[optional] - add|replace * @param boolean $noLogs [optional] tells pref handler to disable admin logs when true (install issues) * @param boolean $debug [optional] * @return array with keys 'success' and 'failed' - DB table entry status. */ public function e107Import($file, $mode = 'replace', $noLogs = false, $debug = FALSE, $sql = null) { if ($sql == null) { $sql = e107::getDB(); } $xmlArray = $this->loadXMLfile($file, 'advanced'); if ($debug) { //$message = print_r($xmlArray); echo "<pre>" . var_export($xmlArray, TRUE) . "</pre>"; return; } $ret = array(); if (vartrue($xmlArray['prefs'])) { foreach ($xmlArray['prefs'] as $type => $array) { $pArray = $this->e107ImportPrefs($xmlArray, $type); if ($mode == 'replace') { e107::getConfig($type)->setPref($pArray); } else { foreach ($pArray as $pname => $pval) { e107::getConfig($type)->add($pname, $pval); // don't parse x/y/z } } if ($debug == FALSE) { e107::getConfig($type)->setParam('nologs', $noLogs)->save(FALSE, TRUE); } } } if (vartrue($xmlArray['database'])) { foreach ($xmlArray['database']['dbTable'] as $val) { $table = $val['@attributes']['name']; if (!isset($val['item'])) { continue; } foreach ($val['item'] as $item) { $insert_array = array(); foreach ($item['field'] as $f) { $fieldkey = $f['@attributes']['name']; $fieldval = isset($f['@value']) ? $f['@value'] : ""; $insert_array[$fieldkey] = $fieldval; } if ($mode == "replace" && $sql->replace($table, $insert_array) !== FALSE) { $ret['success'][] = $table; } elseif ($mode == "add" && $sql->insert($table, $insert_array) !== FALSE) { $ret['success'][] = $table; } else { $ret['failed'][] = $table; } } } } return $ret; }
/** * Update expiry time for IP addresses that have accessed the site while banned. * Processes the entries in the 'ban retrigger' action file, and deletes the file * * Needs to be called from a cron job, at least once per hour, and ideally every few minutes. Otherwise banned users who access * the site in the period since the last call to this routine may be able to get in because their ban has expired. (Unlikely to be * an issue in practice) * * @return int number of IP addresses updated * * @todo - implement cron job and test */ public function banRetriggerAction() { //if (!e107::getPref('ban_retrigger')) return 0; // Should be checked earlier $numEntry = 0; // Make sure this variable declared before passing it - total number of log entries. $ipAction = array(); // Array of IP addresses to action $fileName = $this->ourConfigDir . eIPHandler::BAN_FILE_RETRIGGER_NAME . eIPHandler::BAN_FILE_EXTENSION; $entries = file($fileName); if (!is_array($entries)) { return 0; // Probably no retrigger actions } @unlink($fileName); // Delete the action file now we've read it in. // Scan the list completely before doing any processing - this will ensure we only process the most recent entry for each IP address while (count($entries) > 0) { $line = array_shift($entries); $info = $this->splitLogEntry($line); if ($info['banReason'] < 0) { $ipAction[$info['banIP']] = array('date' => $info['banDate'], 'reason' => $info['banReason']); // This will result in us gathering the most recent access from each IP address } } if (count($ipAction) == 0) { return 0; } // Nothing more to do // Now run through the database updating times $numRet = 0; $pref['ban_durations'] = e107::getPref('ban_durations'); $ourDb = e107::getDB(); // Should be able to use $sql, $sql2 at this point $writeDb = e107::getDB('sql2'); foreach ($ipAction as $ipKey => $ipInfo) { if ($ourDb->select('banlist', '*', "`banlist_ip`='" . $ipKey . "'") === 1) { if ($row = $ourDb->fetch()) { // @todo check next line $writeDb->db_Update('banlist', '`banlist_banexpires` = ' . intval($row['banlist_banexpires'] + $pref['ban_durations'][$row['banlist_banreason']])); $numRet++; } } } if ($numRet) { $this->writeBanListFiles('ip'); // Just rewrite the ban list - the actual IP addresses won't have changed } return $numRet; }
function modsPage() { $ns = e107::getRender(); $sql = e107::getDB(); //$e107 = e107::getInstance(); $forumList = $this->forumObj->forum_getforums('all'); $parentList = $this->forumObj->forum_getparents('list'); $subList = $this->forumObj->forumGetSubs('bysub'); $frm = e107::getForm(); $tp = e107::getParser(); $txt = "<form method='post' action='" . e_SELF . "?" . e_QUERY . "'>\n\t\t<table class='table adminlist'>\n\t\t<colgroup span='2'>\n \t\t<col class='col-label' />\n \t\t<col class='col-control' />\n \t</colgroup>"; foreach ($parentList as $p) { $txt .= "\n\t\t\t<tr>\n\t\t\t\t<td colspan='2' ><strong>" . $tp->toHTML($p['forum_name']) . "</strong></td>\n\t\t\t</tr>\n\t\t\t"; foreach ($forumList[$p['forum_id']] as $f) { $txt .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td>{$f['forum_name']}</td>\n\t\t\t\t\t<td>" . e107::getUserClass()->uc_dropdown("mods[{$f['forum_id']}]", $f['forum_moderators'], 'admin,classes') . "</td>\n\t\t\t\t</tr>\n\t\t\t\t"; foreach ($subList[$f['forum_id']] as $s) { $txt .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td> {$s['forum_name']}</td>\n\t\t\t\t\t\t<td>" . e107::getUserClass()->uc_dropdown("mods[{$s['forum_id']}]", $s['forum_moderators'], 'admin,classes') . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t"; } } } $txt .= "\n\t\t\t</table>\n\t\t\t<div class='buttons-bar center'>\n\t\t\t\t" . $frm->admin_button('setMods', LAN_UPDATE, 'update') . "\n\t\t\t</div>\n\t\t\t</form>"; return $txt; }