diff --git a/class2.php b/class2.php index ddf131324..9efc7c47e 100755 --- a/class2.php +++ b/class2.php @@ -452,7 +452,7 @@ if(!e107::getConfig()->hasData()) { // Core prefs error - admin log - e107::getAdminLog()->log_event('CORE_LAN8', 'CORE_LAN7', E_LOG_WARNING); + e107::getAdminLog()->add('CORE_LAN8', 'CORE_LAN7', E_LOG_WARNING); // Try for the automatic backup.. if(e107::getConfig('core_backup')->hasData()) @@ -469,7 +469,7 @@ if(!e107::getConfig()->hasData()) if(!e107::getConfig('core_old')->hasData()) { // Core could not restore from automatic backup. Execution halted. - e107::getAdminLog()->log_event('CORE_LAN8', 'CORE_LAN9', E_LOG_FATAL); + e107::getAdminLog()->add('CORE_LAN8', 'CORE_LAN9', E_LOG_FATAL); message_handler('CRITICAL_ERROR', 3, __LINE__, __FILE__); // No old system, so point in the direction of resetcore :( @@ -1869,7 +1869,7 @@ function get_user_data($uid, $extra = '') { if(e107::getPref('developer')) { - e107::getAdminLog()->log_event( + e107::getAdminLog()->add( 'Deprecated call - get_user_data()', 'Call to deprecated function get_user_data() (class2.php) '."\n".print_r(debug_backtrace(null,2), true), E_LOG_INFORMATIVE, @@ -1893,7 +1893,7 @@ function get_user_data($uid, $extra = '') //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// //SO MUCH DEPRECATED /** - * @deprecated + * @deprecated Use instead: e107::getConfig(alias)->->setPref($array)->save(); * @example Use instead: e107::getConfig(alias)->->setPref($array)->save(); Not to be used for saving plugin or theme prefs! * @param string $table * @param int|mixed $uid @@ -2460,12 +2460,12 @@ function force_userupdate($currentUser) $user_extended_struct_name = "user_{$row['user_extended_struct_name']}"; if (!isset($currentUser[$user_extended_struct_name])) { - //e107::admin_log->e_log_event(4, __FILE__."|".__FUNCTION__."@".__LINE__, 'FORCE', 'Force User update', 'Trigger field: '.$user_extended_struct_name, FALSE, LOG_TO_ROLLING); + //e107::admin_log->addEvent(4, __FILE__."|".__FUNCTION__."@".__LINE__, 'FORCE', 'Force User update', 'Trigger field: '.$user_extended_struct_name, FALSE, LOG_TO_ROLLING); return TRUE; } if (($row['user_extended_struct_type'] == 7) && ($currentUser[$user_extended_struct_name] == '0000-00-00')) { - //e107::admin_log->e_log_event(4, __FILE__."|".__FUNCTION__."@".__LINE__, 'FORCE', 'Force User update', 'Trigger field: '.$user_extended_struct_name, FALSE, LOG_TO_ROLLING); + //e107::admin_log->addEvent(4, __FILE__."|".__FUNCTION__."@".__LINE__, 'FORCE', 'Force User update', 'Trigger field: '.$user_extended_struct_name, FALSE, LOG_TO_ROLLING); return TRUE; } } diff --git a/e107_admin/admin_log.php b/e107_admin/admin_log.php index 8a08e6696..2c571a536 100644 --- a/e107_admin/admin_log.php +++ b/e107_admin/admin_log.php @@ -357,7 +357,7 @@ class admin_log_ui extends e_admin_ui // Add in a log event $message = $db_name.str_replace(array('[x]', '[y]'), array($old_string, $del_count), RL_LAN_057); $mes->addSuccess($message); - $log->log_event($db_msg, "db_Delete - earlier than {$old_string} (past {$back_count} days)[!br!]".$message.'[!br!]'.$db_table.' '.$qry, E_LOG_INFORMATIVE, ''); + $log->add($db_msg, "db_Delete - earlier than {$old_string} (past {$back_count} days)[!br!]".$message.'[!br!]'.$db_table.' '.$qry, E_LOG_INFORMATIVE, ''); } else { diff --git a/e107_admin/auth.php b/e107_admin/auth.php index 48dcdddf9..2bf4b2edc 100644 --- a/e107_admin/auth.php +++ b/e107_admin/auth.php @@ -148,7 +148,7 @@ else if ($row[0] == "authfail") { - $admin_log->e_log_event(4, __FILE__."|".__FUNCTION__."@".__LINE__, "LOGIN", LAN_ROLL_LOG_11, "U: ".$tp->toDB($_POST['authname']), FALSE, LOG_TO_ROLLING); + $admin_log->addEvent(4, __FILE__."|".__FUNCTION__."@".__LINE__, "LOGIN", LAN_ROLL_LOG_11, "U: ".$tp->toDB($_POST['authname']), FALSE, LOG_TO_ROLLING); echo "\n"; e107::getRedirect()->redirect('admin.php?failed'); @@ -458,7 +458,7 @@ class auth $text = 'CHAP: '.$username.' ('.$extra_text.')'; $title = e107::getParser()->toDB($title); $text = e107::getParser()->toDB($text); - e107::getAdminLog()->e_log_event(4, __FILE__."|".__FUNCTION__."@".__LINE__, "LOGIN", $title, $text, FALSE, LOG_TO_ROLLING); + e107::getAdminLog()->addEvent(4, __FILE__."|".__FUNCTION__."@".__LINE__, "LOGIN", $title, $text, FALSE, LOG_TO_ROLLING); $logfp = fopen(e_LOG.'authlog.txt', 'a+'); fwrite($logfp, $title.': '.$text."\n"); fclose($logfp); */ @@ -476,7 +476,7 @@ class auth $text = 'STD: '.$username.' ('.$extra_text.')'; $title = e107::getParser()->toDB($title); $text = e107::getParser()->toDB($text); - e107::getAdminLog()->e_log_event(4, __FILE__."|".__FUNCTION__."@".__LINE__, "LOGIN", $title, $text, FALSE, LOG_TO_ROLLING); + e107::getAdminLog()->addEvent(4, __FILE__."|".__FUNCTION__."@".__LINE__, "LOGIN", $title, $text, FALSE, LOG_TO_ROLLING); // $logfp = fopen(e_LOG.'authlog.txt', 'a+'); fwrite($logfp, $title.': '.$text."\n"); fclose($logfp); */ diff --git a/e107_admin/banlist.php b/e107_admin/banlist.php index a916dbe78..c67f986c9 100644 --- a/e107_admin/banlist.php +++ b/e107_admin/banlist.php @@ -962,1026 +962,3 @@ require_once(e_ADMIN.'footer.php'); exit; - -// Unused code below, but left here for reference. - - - -$e_sub_cat = 'banlist'; -require_once('auth.php'); -$frm = e107::getForm(); -// $frm = new e_form(true); - -$mes = e107::getMessage(); - -$pref = e107::getPref(); - -// Set a default to avoid issues with legacy systems -if (!isset($pref['ban_date_format'])) $pref['ban_date_format'] = '%H:%M %d-%m-%y'; - -$ipAdministrator = new banlistManager; - -// Character options for import & export -$separator_char = array(1 => ',', 2 => '|'); -$quote_char = array(1 => '(none)', 2 => "'", 3 => '"'); - - -$action = 'list'; -if (e_QUERY) -{ - $tmp = explode('-', e_QUERY); // Use '-' instead of '.' to avoid confusion with IP addresses - $action = $tmp[0]; - $sub_action = varset($tmp[1], ''); - if ($sub_action) $sub_action = preg_replace('/[^\w*@\.:]*/', '', urldecode($sub_action)); - $id = intval(varset($tmp[2], 0)); - unset($tmp); -} - -if($_GET['action']) // Temporary Fix. -{ - $action = $_GET['action']; -} - - - - - -$writeBanFile = FALSE; -if (isset($_POST['ban_ip'])) -{ - $_POST['ban_ip'] = trim($_POST['ban_ip']); - $new_ban_ip = preg_replace('/[^\w*@\.:]*/', '', urldecode($_POST['ban_ip'])); - if ($new_ban_ip != $_POST['ban_ip']) - { - $message = BANLAN_27.' '.$new_ban_ip; - //$ns->tablerender(BANLAN_9, $message); - $mes->add(BANLAN_33, $message); - $_POST['ban_ip'] = $new_ban_ip; - } - - if (isset($_POST['entry_intent']) && (isset($_POST['add_ban']) || isset($_POST['update_ban'])) && $_POST['ban_ip'] != "" && strpos($_POST['ban_ip'], ' ') === false) - { - /* $_POST['entry_intent'] says why we're here: - 'edit' - Editing blacklist - 'add' - Adding to blacklist - 'whedit' - Editing whitelist - 'whadd' - Adding to whitelist - */ - if(e107::getIPHandler()->whatIsThis($new_ban_ip) == 'ip') - { - $new_ban_ip = e107::getIPHandler()->IPencode($new_ban_ip, TRUE); // Normalise numeric IP addresses (allow wildcards) - } - $new_vals = array('banlist_ip' => $new_ban_ip); - if (isset($_POST['add_ban'])) - { - $new_vals['banlist_datestamp'] = time(); - if ($_POST['entry_intent'] == 'add') $new_vals['banlist_bantype'] = eIPHandler::BAN_TYPE_MANUAL; // Manual ban - if ($_POST['entry_intent'] == 'whadd') $new_vals['banlist_bantype'] = eIPHandler::BAN_TYPE_WHITELIST; - } - $new_vals['banlist_admin'] = ADMINID; - $new_vals['banlist_reason'] = $tp->toDB(varset($_POST['ban_reason'], '')); - $new_vals['banlist_notes'] = $tp->toDB($_POST['ban_notes']); - if (isset($_POST['ban_time']) && is_numeric($_POST['ban_time']) && (($_POST['entry_intent']== 'edit') || ($_POST['entry_intent'] == 'add'))) - { - $bt = intval($_POST['ban_time']); - $new_vals['banlist_banexpires'] = $bt ? time() + ($bt*60*60) : 0; - } - if (isset($_POST['add_ban'])) - { // Insert new value - can just pass an array - e107::getMessage()->addAuto($sql->db_Insert('banlist', $new_vals), 'insert'); - if ($_POST['entry_intent'] == 'add') - { - banlist_adminlog('01', $new_vals['banlist_ip']); // Write to banlist - } - else - { - banlist_adminlog('04', $new_vals['banlist_ip']); // Write to whitelist - } - } - else - { // Update existing value - $qry = ''; - $spacer = ''; - foreach ($new_vals as $k => $v) - { - $qry .= $spacer."`{$k}`='$v'"; - $spacer = ', '; - } - e107::getMessage()->addAuto($sql->db_Update('banlist', $qry." WHERE banlist_ip='".$_POST['old_ip']."'")); - if ($_POST['entry_intent'] == 'edit') - { - banlist_adminlog('09',$new_vals['banlist_ip']); - } - else - { - banlist_adminlog('10',$new_vals['banlist_ip']); - } - } - unset($ban_ip); - $writeBanFile = TRUE; - } -} - - - -// Remove a ban -if (($action == 'remove' || $action == 'whremove') && isset($_POST['ban_secure'])) -{ - $sql->db_Delete('generic', "gen_type='failed_login' AND gen_ip='{$sub_action}'"); - e107::getMessage()->addAuto($sql->db_Delete('banlist', "banlist_ip='{$sub_action}'"), 'delete'); - if ($action == "remove") - { - $action = 'list'; - banlist_adminlog('02', $sub_action); - } - else - { - $action = 'white'; - banlist_adminlog('05', $sub_action); - } - $writeBanFile = TRUE; -} - - - -// Update the ban expiry time/date - timed from now (only done on banlist) -if ($action == 'newtime') -{ - $end_time = $id ? time() + ($id*60*60) : 0; - e107::getMessage()->addAuto($sql->db_Update('banlist', 'banlist_banexpires='.intval($end_time)." WHERE banlist_ip='".$sub_action."'")); - banlist_adminlog('03', $sub_action); - $action = 'list'; - $writeBanFile = TRUE; -} - - -if ($writeBanFile) -{ -/************************************************ - update list of banned IPs -*************************************************/ - $ipAdministrator->writeBanListFiles('ip,htaccess'); - if (!$ipAdministrator->doesMessageFileExist()) - { - $ipAdministrator->writeBanMessageFile(); // Message file must exist - may not on fresh site - banlist_adminlog('08',''); - $mes->addSuccess(LAN_UPDATED); - } -} - - - -/** - * @todo - eliminate extract(); - */ -// Edit modes - get existing entry -if ($action == 'edit' || $action == 'whedit') -{ - $sql->select('banlist', '*', "banlist_ip='{$sub_action}'"); - $row = $sql->fetch(); - extract($row); //FIXME - kill extract() -} -else -{ - unset($banlist_ip, $banlist_reason); - if (e_QUERY && ($action == 'add' || $action == 'whadd') && strpos($_SERVER["HTTP_REFERER"], "userinfo")) - { - $banlist_ip = $sub_action; - } -} - - - -/** - * Create dropdown with options for ban time - uses internal fixed list of reasonable values - */ -function ban_time_dropdown($click_js = '', $zero_text = LAN_NEVER, $curval = -1, $drop_name = 'ban_time') -{ - $frm = e107::getForm(); - $intervals = array(0, 1, 2, 3, 6, 8, 12, 24, 36, 48, 72, 96, 120, 168, 336, 672); - - $ret = $frm->select_open($drop_name, array('other' => $click_js, 'id' => false)); - $ret .= $frm->option(' ', ''); - foreach ($intervals as $i) - { - if ($i == 0) - { - $words = $zero_text ? $zero_text : LAN_NEVER; - } - elseif (($i % 24) == 0) - { - $words = floor($i / 24).' '.BANLAN_23; - } - else - { - $words = $i.' '.BANLAN_24; - } - $ret .= $frm->option($words, $i, ($curval == $i)); - } - $ret .= ''; - return $ret; -} - - - - -/** - * Create generic dropdown from array of data - */ -function select_box($name, $data, $curval = FALSE) -{ - global $frm; - - $ret = $frm->select_open($name, array('class' => 'tbox', 'id' => false)); - foreach ($data as $k => $v) - { - $ret .= $frm->option($v, $k, ($curval !== FALSE) && ($curval == $k)); - } - $ret .= "\n"; - return $ret; -} - - - -/** - * Create dropdown with options for access counts before ban - uses internal fixed list of reasonable values - */ -function drop_box($box_name, $curval) -{ - global $frm; - - $opts = array(50, 100, 150, 200, 250, 300, 400, 500); - $ret = $frm->select_open($box_name, array('class' => 'tbox')); - foreach ($opts as $o) - { - $ret .= $frm->option($o, $o, ($curval == $o)); - } - $ret .= "\n"; - return $ret; -} - - - -$text = ''; - - -switch ($action) -{ - case 'banlog' : - if(!getperms('0')) exit; - if (isset($_POST['delete_ban_log'])) - { - $message = ($ipAdministrator->deleteLogFile() ? BANLAN_89 : BANLAN_90); - e107::getRender()->tablerender(BANLAN_88, "
".$message."
"); // FIXME - } - $from = 0; - $amount = 20; // Number per page - could make configurable later if required - if ($sub_action) $from = intval($sub_action); - -// @todo format form the 0.8 way - $text = "
-
- - - - - - - "; - - // Get entries - $banLogEntries = $ipAdministrator->getLogEntries($from, $amount, $num_entry); - if (count($banLogEntries) == 0) - { - $text .= ""; - $num_entry = 0; - } - else - { - $text .= " - "; - foreach ($banLogEntries as $ban) - { - $row = $ipAdministrator->splitLogEntry($ban); - $text .= " - - - - - - "; - } // End while - - // Next-Previous. ========================== - if ($num_entry > $amount) - { - $parms = "{$num_entry},{$amount},{$from},".e_SELF."?".$action.'-[FROM]'; - $text .= "'); - } - $text .= " - "; - } - $text .= "
".BANLAN_82."
".BANLAN_83."".BANLAN_84."".BANLAN_7."".BANLAN_85."
".strftime($pref['ban_date_format'], $row['banDate'])."".e107::getIPHandler()->ipDecode($row['banIP'])."".$ipAdministrator->getBanTypeString($row['banReason'], FALSE)."".$row['banNotes']."

".$tp->parseTemplate("{NEXTPREV={$parms}}".'

- - -
"; - - if (count($banLogEntries)) - { - $text .= "   ".str_replace('[y]', $num_entry, BANLAN_87); - } - - echo $text; - // e107::getRender()->tablerender(BANLAN_16.SEP.BANLAN_86, $text); - break; - - - case 'options' : - if (!getperms('0')) - exit(); - if (isset($_POST['update_ban_options'])) - { - $pref['enable_rdns'] = intval($_POST['ban_rdns_on_access']); - $pref['enable_rdns_on_ban'] = intval($_POST['ban_rdns_on_ban']); - $pref['ban_max_online_access'] = intval($_POST['ban_access_guest']).','.intval($_POST['ban_access_member']); - $pref['ban_retrigger'] = intval($_POST['ban_retrigger']); - $pref['ban_date_format'] = $tp->toDB($_POST['ban_date_format']); - save_prefs(); // @todo FIXME log detail of changes. Right prefs to use? - $mes->addSuccess(LAN_SETSAVED); - } - - if (isset($_POST['remove_expired_bans'])) - { - $result = $sql->db_Delete('banlist',"`banlist_bantype` < ".eIPHandler::BAN_TYPE_WHITELIST." AND `banlist_banexpires` > 0 AND `banlist_banexpires` < ".time()); - banlist_adminlog('12', $result); - $mes->addSuccess(str_replace('[y]', $result, BANLAN_48)); - } - - list($ban_access_guest, $ban_access_member) = explode(',', varset($pref['ban_max_online_access'], '100,200')); - $ban_access_member = max($ban_access_guest, $ban_access_member); - $text = " -
-
- ".BANLAN_72." - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
".BANLAN_63." -
- ".$frm->checkbox('ban_rdns_on_access', 1, $pref['enable_rdns'] == 1)." -
".BANLAN_65."
-
-
".BANLAN_64." -
- ".$frm->checkbox('ban_rdns_on_ban', 1, $pref['enable_rdns_on_ban'] == 1)." -
".BANLAN_66."
-
-
".BANLAN_67." -
".drop_box('ban_access_guest', $ban_access_guest).BANLAN_70."
-
".drop_box('ban_access_member', $ban_access_member).BANLAN_69."
-
".BANLAN_68."
-
".BANLAN_71." -
- ".$frm->checkbox('ban_retrigger', 1, $pref['ban_retrigger'] == 1)." -
".BANLAN_73."
-
-
".BANLAN_91." - ".$frm->text('ban_date_format', varset($pref['ban_date_format'], '%H:%M %d-%m-%y'), 40)." -
".BANLAN_92."
-
-
- ".$frm->admin_button('update_ban_options', LAN_UPDATE, 'update')." - -
-
-
- ".BANLAN_74." - - - - - - - - - - - -
".BANLAN_75." - ".$frm->admin_button('remove_expired_bans', BANLAN_76, 'delete')." - -
-
-
- "; - - echo $mes->render().$text; - - // e107::getRender()->tablerender(BANLAN_16.SEP.LAN_OPTIONS, $mes->render().$text); - break; - - case 'times' : - - - // e107::getRender()->tablerender(BANLAN_16.SEP.BANLAN_77, $mes->render().$text); - break; - - case 'edit' : // Edit an existing ban - case 'add' : // Add a new ban - case 'whedit' : // Edit existing whitelist entry - case 'whadd' : // Add a new whitelist entry - - if(!E107_DEBUG_LEVEL) - { - break; - } - RETURN; - - if (!isset($banlist_reason)) $banlist_reason = ''; - if (!isset($banlist_ip)) $banlist_ip = ''; - if (!isset($banlist_notes)) $banlist_notes = ''; - - $page_title = array('edit' => BANLAN_60, 'add' => BANLAN_9, 'whedit' => BANLAN_59, 'whadd' => BANLAN_58); - $rdns_warn = vartrue($pref['enable_rdns']) ? '' : '
'.BANLAN_12.'
'; - $next = ($action == 'whedit' || $action == 'whadd') ? '?white' : '?list'; - // Edit/add form first - $text .= " -
-
- ".$page_title[$action]." - - - - - - - - - - - "; - - if (($action == 'add') || ($action == 'whadd') || ($banlist_bantype <= 1) || ($banlist_bantype >= eIPHandler::BAN_TYPE_WHITELIST)) - { // Its a manual or unknown entry - only allow edit of reason on those - $text .= " - - - - - "; - } - elseif ($action == 'edit') - { - $text .= " - - - - - "; - } - - if ($action == 'edit') - { - $text .= " - - - - - "; - } - - $text .= " - - - - - "; - - if ($action == 'edit' || $action == 'add') - { - $inhelp = (($action == 'edit') ? '
'.BANLAN_26.($banlist_banexpires ? strftime($pref['ban_date_format'], $banlist_banexpires) : LAN_NEVER).'
' : ''); - - $text .= " - - - - - "; - } - - $text .= " - -
- ".BANLAN_5.": -
- ".BANLAN_13."".E_16_CAT_USER." -
-
- - ".$frm->text('ban_ip', e107::getIPHandler()->ipDecode($banlist_ip), 200)." - {$rdns_warn} -
".BANLAN_7.": - ".$frm->textarea('ban_reason', $banlist_reason, 4, 50)." -
".BANLAN_7.": {$banlist_reason}
".BANLAN_28.": ".$ipAdministrator->getBanTypeString($banlist_bantype, FALSE)." - ".$ipAdministrator->getBanTypeString($banlist_bantype, TRUE)."
".BANLAN_19.": - ".$frm->textarea('ban_notes', $banlist_notes, 4, 50)." -
".BANLAN_18.": ".ban_time_dropdown().$inhelp."
- -
- - "; - - /* FORM NOTE EXAMPLE - not needed here as this note is added as label-note (see below) - $text .= " -
- ".BANLAN_13." -
- - "; - */ - - if ($action == 'edit' || $action == 'whedit') - { - $text .= " - ".$frm->admin_button('update_ban', LAN_UPDATE, 'update'); - } - else - { - $text .= $frm->admin_button('add_ban', ($action == 'add' ? BANLAN_8 : BANLAN_53), 'create'); - } - - $text .= "
-
-
- "; - - echo $mes->render().$text; - // e107::getRender()->tablerender($page_title[$action], $mes->render().$text); - break; // End of 'Add' and 'Edit' - - - case 'transfer' : - $message = ''; - $error = false; - if (isset($_POST['ban_import'])) - { // Got a file to import - require_once(e_HANDLER.'upload_handler.php'); - if (($files = process_uploaded_files(e_UPLOAD, FALSE, array('overwrite' => TRUE, 'max_file_count' => 1, 'file_mask' => 'csv'))) === FALSE) - { // Invalid file - $error = true; - $mes->addError(BANLAN_47); - } - if(empty($files) || vartrue($files[0]['error'])) - { - $error = true; - if(varset($files[0]['message'])) - $mes->addError($files[0]['message']); - } - if(!$error) - { // Got a file of some sort - $message = process_csv(e_UPLOAD.$files[0]['name'], - intval(varset($_POST['ban_over_import'], 0)), - intval(varset($_POST['ban_over_expiry'], 0)), - $separator_char[intval(varset($_POST['ban_separator'], 1))], - $quote_char[intval(varset($_POST['ban_quote'], 3))]); - banlist_adminlog('07', 'File: '.e_UPLOAD.$files[0]['name'].'
'.$message); - } - - } - - $text = " -
-
- ".BANLAN_40." - - - - - - - - - - - - "; - - - foreach ($ipAdministrator->getValidReasonList() as $i) //FIXME $frm->label() - { - $text .= " - - - "; - } - - $text .= " - - - "; - $text .= " - - -
".BANLAN_36." 
- ".$frm->checkbox("ban_types[{$i}]", $i).$frm->label($ipAdministrator->getBanTypeString($i, FALSE), "ban_types[{$i}]", $i)." - (".$ipAdministrator->getBanTypeString($i, TRUE).") -
".BANLAN_79."".select_box('ban_separator', $separator_char).' '.BANLAN_37."".select_box('ban_quote', $quote_char).' '.BANLAN_38."
-
".$frm->admin_button('ban_export', BANLAN_39, 'export', BANLAN_39)."
- -
-
- "; - - // Now do the import options - $text .= " -
-
- ".BANLAN_41." - - - - - - - - - - - - - - - - - - - - - - - - - - -
".BANLAN_42." 
".$frm->checkbox('ban_over_import', 1, '', array('label' => BANLAN_43))."
".$frm->checkbox('ban_over_expiry', 1, '', array('label' => BANLAN_44))."
".BANLAN_46." - ".$frm->file('file_userfile[]', array('size' => '40'))." -
".BANLAN_80."".select_box('ban_separator', $separator_char).' '.BANLAN_37."".select_box('ban_quote', $quote_char).' '.BANLAN_38."
-
- ".$frm->admin_button('ban_import', BANLAN_45, 'import')." - -
- - -
-
- "; - - echo $mes->render().$text; - // e107::getRender()->tablerender(BANLAN_16.SEP.BANLAN_35, $mes->render().$text); - break; // End case 'transfer' - - case 'list' : - case 'white' : - default : - - if(!E107_DEBUG_LEVEL) - { - break; - } - - if (($action != 'list') && ($action != 'white')) - $action = 'list'; - - $edit_action = ($action == 'list' ? 'edit' : 'whedit'); - $del_action = ($action == 'list' ? 'remove' : 'whremove'); - $col_widths = array('list' => array(10, 5, 35, 30, 10, 10), 'white' => array(15, 40, 35, 10)); - $col_titles = array('list' => array(BANLAN_17, BANLAN_20, BANLAN_10, BANLAN_19, BANLAN_18, LAN_OPTIONS), - 'white' => array(BANLAN_55, BANLAN_56, BANLAN_19, LAN_OPTIONS)); - $no_values = array('list' => BANLAN_2, 'white' => BANLAN_54); - $col_defs = array('list' => array('banlist_datestamp' => 0, 'banlist_bantype' => 0, 'ip_reason' => BANLAN_7, 'banlist_notes' => 0, 'banlist_banexpires' => 0, 'ban_options' => 0), - 'white' => array('banlist_datestamp' => 0, 'ip_reason' => BANLAN_57, 'banlist_notes' => 0, 'ban_options' => 0)); - - $text = " -
-
- ".($action == 'list' ? BANLAN_3 : BANLAN_61)." - ".$frm->hidden("ban_secure", "1")." - "; - - $filter = ($action == 'white') ? 'banlist_bantype='.eIPHandler::BAN_TYPE_WHITELIST : 'banlist_bantype!='.eIPHandler::BAN_TYPE_WHITELIST; - - - if(!$ban_total = $sql->select("banlist", "*", $filter." ORDER BY banlist_ip")) - { - //$text .= "
".$no_values[$action]."
"; - $mes->addInfo($no_values[$action]); - } - else - { - $text .= " - - - "; - foreach($col_widths[$action] as $fw) - { - $text .= " - - "; - } - $text .= " - - - - "; - $cnt = 0; - foreach($col_titles[$action] as $ct) - { - $cnt ++; - $text .= "{$ct}"; - } - $text .= " - - "; - while($row = $sql->fetch()) - { - //extract($row);//FIXME - kill extract() - $row['banlist_reason'] = str_replace('LAN_LOGIN_18', BANLAN_11, $row['banlist_reason']); - $text .= ""; - foreach($col_defs[$action] as $cd => $fv) - { - $row_class = ''; - switch($cd) - { - case 'banlist_datestamp': - $val = ($row['banlist_datestamp'] ? strftime($pref['ban_date_format'], $row['banlist_datestamp']) : BANLAN_22); - break; - case 'banlist_bantype': - $val = "
".$ipAdministrator->getBanTypeString($row['banlist_bantype'], FALSE)." ".E_16_USER."
"; - break; - case 'ip_reason': - $val = e107::getIPHandler()->ipDecode($row['banlist_ip'])."
".$fv.": ".$row['banlist_reason']; - break; - case 'banlist_banexpires': - $val = ($row['banlist_banexpires'] ? strftime($pref['ban_date_format'], $row['banlist_banexpires']).(($row['banlist_banexpires'] < time()) ? ' ('.BANLAN_34.')' : '') : LAN_NEVER)."
".ban_time_dropdown("onchange=\"e107Helper.urlJump('".e_SELF."?newtime-{$row['banlist_ip']}-'+this.value)\""); - break; - case 'ban_options': - $row_class = ' class="center"'; - $val = " - ".ADMIN_EDIT_ICON." -"; - break; - case 'banlist_notes': - default: - $val = $row[$cd]; - } - - $text .= "{$val}"; - } - $text .= ''; - } - $text .= " -
- - "; - } - $text .= " -
-
- "; - - echo $mes->render().$text; - // e107::getRender()->tablerender(($action == 'list' ? BANLAN_3 : BANLAN_61), $mes->render().$text); - // End of case 'list' and the default case -} // End switch ($action) - - -require_once(e_ADMIN.'footer.php'); - - -/** - * Admin menu options - */ -function banlist_adminmenu() -{ - $action = (e_QUERY) ? e_QUERY : 'list'; - - $var['list']['text'] = BANLAN_14; // List existing bans - $var['list']['link'] = e_SELF.'?list'; - $var['list']['perm'] = '4'; - - $var['add']['text'] = BANLAN_25; // Add a new ban - $var['add']['link'] = e_SELF.'?add'; - $var['add']['perm'] = '4'; - - $var['white']['text'] = BANLAN_52; // List existing whitelist entries - $var['white']['link'] = e_SELF.'?white'; - $var['white']['perm'] = '4'; - - $var['whadd']['text'] = BANLAN_53; // Add a new whitelist entry - $var['whadd']['link'] = e_SELF.'?whadd'; - $var['whadd']['perm'] = '4'; - - $var['transfer']['text'] = BANLAN_35; - $var['transfer']['link'] = e_SELF.'?transfer'; - $var['transfer']['perm'] = '4'; - - if (getperms('0')) - { - $var['times']['text'] = BANLAN_15; - $var['times']['link'] = e_SELF.'?times'; - $var['times']['perm'] = '0'; - - $var['options']['text'] = LAN_OPTIONS; - $var['options']['link'] = e_SELF.'?options'; - $var['options']['perm'] = '0'; - - $var['banlog']['text'] = BANLAN_81; - $var['banlog']['link'] = e_SELF.'?banlog'; - $var['banlog']['perm'] = '0'; - } - e107::getNav()->admin(BANLAN_16, $action, $var); -} - - - -// Parse the date string used by the import/export - YYYYMMDD_HHMMSS -function parse_date($instr) -{ - if (strlen($instr) != 15) - return 0; - return mktime(substr($instr, 9, 2), substr($instr, 11, 2), substr($instr, 13, 2), substr($instr, 4, 2), substr($instr, 6, 2), substr($instr, 0, 4)); -} - - - -// Process the imported CSV file, update the database, delete the file. -// Return a message -function process_csv($filename, $override_imports, $override_expiry, $separator = ',', $quote = '"') -{ - $sql = e107::getDb(); - $pref['ban_durations'] = e107::getPref('ban_durations'); - $mes = e107::getMessage(); - - // echo "Read CSV: {$filename} separator: {$separator}, quote: {$quote} override imports: {$override_imports} override expiry: {$override_expiry}
"; - // Renumber imported bans - if ($override_imports) - $sql->update('banlist', "`banlist_bantype`=".eIPHandler::BAN_TYPE_TEMPORARY." WHERE `banlist_bantype` = ".eIPHandler::BAN_TYPE_IMPORTED); - $temp = file($filename); - $line_num = 0; - foreach ($temp as $line) - { // Process one entry - $line = trim($line); - $line_num++; - if ($line) - { - $fields = explode($separator, $line); - $field_num = 0; - $field_list = array('banlist_bantype' => eIPHandler::BAN_TYPE_IMPORTED); - foreach ($fields as $f) - { - $f = trim($f); - if (substr($f, 0, 1) == $quote) - { - if (substr($f, -1, 1) == $quote) - { // Strip quotes - $f = substr($f, 1, -1); // Strip off the quotes - } - else - { - $mes->addError(BANLAN_49.$line_num); - return BANLAN_49.$line_num; - } - } - // Now handle the field - $field_num++; - switch ($field_num) - { - case 1 : // IP address - $field_list['banlist_ip'] = e107::getIPHandler()->ipEncode($f); - break; - case 2 : // Original date of ban - $field_list['banlist_datestamp'] = parse_date($f); - break; - case 3 : // Expiry of ban - depends on $override_expiry - if ($override_expiry) - { - $field_list['banlist_banexpires'] = parse_date($f); - } - else - { // Use default ban time from now - $field_list['banlist_banexpires'] = $pref['ban_durations'][eIPHandler::BAN_TYPE_IMPORTED] ? time() + (60*60*$pref['ban_durations'][eIPHandler::BAN_TYPE_IMPORTED]) : 0; - } - break; - case 4 : // Original ban type - we always ignore this and force to 'imported' - break; - case 5 : // Ban reason originally generated by E107 - $field_list['banlist_reason'] = $f; - break; - case 6 : // Any user notes added - $field_list['banlist_notes'] = $f; - break; - default : // Just ignore any others - } - } - $qry = "REPLACE INTO `#banlist` (".implode(',', array_keys($field_list)).") values ('".implode("', '", $field_list)."')"; - // echo count($field_list)." elements, query: ".$qry."
"; - if (!$sql->gen($qry)) - { - $mes->addError(BANLAN_50.$line_num); - return BANLAN_50.$line_num; - } - } - } - // Success here - may need to delete old imported bans - if ($override_imports) - $sql->delete('banlist', "`banlist_bantype` = ".eIPHandler::BAN_TYPE_TEMPORARY); - @unlink($filename); // Delete file once done - $mes->addSuccess(str_replace('[y]', $line_num, BANLAN_51).$filename); - return str_replace('[y]', $line_num, BANLAN_51).$filename; -} - - - -/** - * Log event to admin log - * - * @param string $msg_num - exactly two numeric characters corresponding to a log message - * @param string $woffle - information for the body of the log entre - * - * @return none - */ -function banlist_adminlog($msg_num = '00', $woffle = '') -{ - e107::getAdminLog()->log_event('BANLIST_'.$msg_num, $woffle, E_LOG_INFORMATIVE, ''); -} - - -/** - * Handle page DOM within the page header - * - * @return string JS source - */ -function headerjs() -{ -/* - require_once(e_HANDLER.'js_helper.php'); - $ret = " - - - "; - - return $ret; - -*/ -} - -require_once(e_ADMIN."footer.php"); -exit; -?> diff --git a/e107_admin/banlist_export.php b/e107_admin/banlist_export.php index 96f107fba..fb89f612b 100644 --- a/e107_admin/banlist_export.php +++ b/e107_admin/banlist_export.php @@ -135,7 +135,7 @@ function do_export($filename, $type_list='',$format_array=array(), $sep = ',', $ // Log event to admin log function banlist_adminlog($msg_num='00', $woffle='') { - e107::getAdminLog()->log_event('BANLIST_'.$msg_num, $woffle, E_LOG_INFORMATIVE, ''); + e107::getAdminLog()->add('BANLIST_'.$msg_num, $woffle, E_LOG_INFORMATIVE, ''); } diff --git a/e107_admin/frontpage.php b/e107_admin/frontpage.php index 2d4d06937..456907a5f 100644 --- a/e107_admin/frontpage.php +++ b/e107_admin/frontpage.php @@ -716,7 +716,7 @@ require_once(e_ADMIN.'footer.php'); */ function frontpage_adminlog($msg_num = '00', $woffle = '') { - e107::getAdminLog()->log_event('FRONTPG_'.$msg_num, $woffle, E_LOG_INFORMATIVE, ''); + e107::getAdminLog()->add('FRONTPG_'.$msg_num, $woffle, E_LOG_INFORMATIVE, ''); } diff --git a/e107_admin/image.php b/e107_admin/image.php index 4f3168ae5..b6b30699e 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -2918,7 +2918,7 @@ class media_admin_ui extends e_admin_ui { if(!$sc_path) return array(); $path = e107::getParser()->replaceConstants($sc_path); - $info = e107::getFile()->get_file_info($path,true); + $info = e107::getFile()->getFileInfo($path,true); return array( 'media_type' => $info['mime'], 'media_datestamp' => time(), @@ -3042,7 +3042,7 @@ class media_admin_ui extends e_admin_ui { $mes = e107::getMessage(); $tp = e107::getParser(); - $f = e107::getFile()->get_file_info($oldpath,TRUE); + $f = e107::getFile()->getFileInfo($oldpath,TRUE); $mes->addDebug("checkDupe(): newpath=".$newpath."
oldpath=".$oldpath."
".print_r($newpath,TRUE)); if(file_exists($newpath) || e107::getDb()->select("core_media","*","media_url = '".$tp->createConstants($newpath,'rel')."' LIMIT 1") ) @@ -3399,7 +3399,7 @@ class media_admin_ui extends e_admin_ui } // End Resize routine. --------------------- - $f = $fl->get_file_info($oldpath); + $f = $fl->getFileInfo($oldpath); if(!$f['mime']) { @@ -3510,27 +3510,21 @@ class media_admin_ui extends e_admin_ui $mes = e107::getMessage(); $tmp = array(); - $tmp['image_post'] = intval($_POST['image_post']); - $tmp['resize_method'] = $tp->toDB($_POST['resize_method']); - $tmp['im_path'] = trim($tp->toDB($_POST['im_path'])); - $tmp['image_post_class'] = intval($_POST['image_post_class']); - $tmp['image_post_disabled_method'] = intval($_POST['image_post_disabled_method']); - $tmp['enable_png_image_fix'] = intval($_POST['enable_png_image_fix']); + $tmp['image_post'] = (int) $_POST['image_post']; + $tmp['resize_method'] = $tp->toDB($_POST['resize_method']); + $tmp['im_path'] = trim($tp->toDB($_POST['im_path'])); + $tmp['image_post_class'] = (int) $_POST['image_post_class']; + $tmp['image_post_disabled_method'] = (int) $_POST['image_post_disabled_method']; + $tmp['enable_png_image_fix'] = (int) $_POST['enable_png_image_fix']; if($_POST['img_import_resize_w'] && $_POST['img_import_resize_h']) { $tmp['img_import_resize'] = intval($_POST['img_import_resize_w'])."x".intval($_POST['img_import_resize_h']); - } - - if ($admin_log->logArrayDiffs($tmp, $pref, 'IMALAN_04')) - { - save_prefs(); // Only save if changes - $mes->add(IMALAN_9, E_MESSAGE_SUCCESS); } - else - { - $mes->add(IMALAN_20, E_MESSAGE_INFO); - } + + e107::getConfig()->setPref($tmp)->save(true,true,true); + + } diff --git a/e107_admin/mailout.php b/e107_admin/mailout.php index 80d5f6c28..11e1fb410 100644 --- a/e107_admin/mailout.php +++ b/e107_admin/mailout.php @@ -624,7 +624,7 @@ class mailout_main_ui extends e_admin_ui else { $mes->addSuccess(LAN_MAILOUT_81. ' ('.$sendto.')'); - e107::getAdminLog()->log_event('MAIL_01', $sendto, E_LOG_INFORMATIVE,''); + e107::getAdminLog()->add('MAIL_01', $sendto, E_LOG_INFORMATIVE,''); } @@ -750,7 +750,7 @@ class mailout_main_ui extends e_admin_ui if ($this->mailAdmin->activateEmail($mailId, FALSE, $notify, $first, $last)) { e107::getMessage()->addSuccess(LAN_MAILOUT_185); - $log->log_event('MAIL_06','ID: '.$mailId,E_LOG_INFORMATIVE,''); + $log->add('MAIL_06','ID: '.$mailId,E_LOG_INFORMATIVE,''); } else { diff --git a/e107_admin/plugin.php b/e107_admin/plugin.php index e1dc06a74..49626d3da 100755 --- a/e107_admin/plugin.php +++ b/e107_admin/plugin.php @@ -367,7 +367,7 @@ class plugin_ui extends e_admin_ui // $name = deftrue($info['plugin_name'],$info['plugin_name']). " v".$info['plugin_version']. "({e_PLUGIN}".$info['plugin_path'].")"; - // $log->log_event('PLUGMAN_01', $name, E_LOG_INFORMATIVE, ''); + // $log->add('PLUGMAN_01', $name, E_LOG_INFORMATIVE, ''); // make sure ALL plugin/addon pref lists get update and are current e107::getPlug()->clearCache()->buildAddonPrefLists(); @@ -2804,7 +2804,7 @@ class pluginManager{ $name = deftrue($info['plugin_name'],$info['plugin_name']). " v".$info['plugin_version']. "({e_PLUGIN}".$info['plugin_path'].")"; - $log->log_event('PLUGMAN_01', $name, E_LOG_INFORMATIVE, ''); + $log->add('PLUGMAN_01', $name, E_LOG_INFORMATIVE, ''); $this->show_message($text, E_MESSAGE_SUCCESS); } diff --git a/e107_admin/prefs.php b/e107_admin/prefs.php index 2b5be4b03..d98962cab 100644 --- a/e107_admin/prefs.php +++ b/e107_admin/prefs.php @@ -291,7 +291,7 @@ function sendTest() else { $mes->addSuccess(LAN_MAILOUT_81. ' ('.$sendto.')'); - $log->log_event('MAIL_01',$sendto,E_LOG_INFORMATIVE,''); + $log->add('MAIL_01',$sendto,E_LOG_INFORMATIVE,''); } } diff --git a/e107_admin/themeold.php b/e107_admin/themeold.php deleted file mode 100644 index 5411ac37f..000000000 --- a/e107_admin/themeold.php +++ /dev/null @@ -1,925 +0,0 @@ -getMarketplace(); - echo $mp->renderLoginForm(); - exit; - break; - - /* - case 'download': - $string = base64_decode($_GET['src']); - parse_str($string, $p); - $mp = $themec->getMarketplace(); - $mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass); - // Server flush useless. It's ajax ready state 4, we can't flush (sadly) before that (at least not for all browsers) - echo "
Connecting...\n"; flush();
-			// download and flush
-			$mp->download($p['id'], $p['mode'], $p['type']);
-			echo "
"; flush(); - exit; - break; - */ - - case 'info': - if(!empty($_GET['src'])) - { - $string = base64_decode($_GET['src']); - parse_str($string,$p); - $themeInfo = e107::getSession()->get('thememanager/online/'.intval($p['id'])); - echo $themec->renderThemeInfo($themeInfo); - } - break; - - case 'preview': - // Theme Info Ajax - $tm = (string) $_GET['id']; - $data = $themec->getThemeInfo($tm); - echo $themec->renderThemeInfo($data); - // exit; - break; - - } -/* - if(vartrue($_GET['src'])) // Process Theme Download. - { - $string = base64_decode($_GET['src']); - parse_str($string,$p); - - if(vartrue($_GET['info'])) - { - echo $themec->renderThemeInfo($p); - // print_a($p); - exit; - } - - $remotefile = $p['url']; - - e107::getFile()->download($remotefile,'theme'); - exit; - - } -*/ - // Theme Info Ajax - // FIXME addd action=preview to the url, remove this block - if(!empty($_GET['id'])) - { - $tm = (string) $_GET['id']; - $data = $themec->getThemeInfo($tm); - echo $themec->renderThemeInfo($data); - } - - require_once(e_ADMIN."footer.php"); - exit; - -} -else -{ - require_once("auth.php"); - - /* - echo ' - - '; - */ -} - - - - - - - -if($mode == 'download' && !empty($_GET['src'])) -{ - define('e_IFRAME', true); - $frm = e107::getForm(); - $mes = e107::getMessage(); - $string = base64_decode($_GET['src']); - parse_str($string, $data); - - if(!empty($data['price'])) - { - e107::getRedirect()->go($data['url']); - return true; - } - - if(deftrue('e_DEBUG_MARKETPLACE')) - { - echo "DEBUG MODE ACTIVE (no downloading)
"; - echo '$_GET: '; - print_a($_GET); - - echo 'base64 decoded and parsed as $data:'; - print_a($data); - return false; - } - - - $mp = $themec->getMarketplace(); - $mes->addSuccess(TPVLAN_85); - - if($mp->download($data['id'], $data['mode'], 'theme')) // download and unzip theme. - { - // Auto install? - // $text = e107::getPlugin()->install($data['plugin_folder']); - // $mes->addInfo($text); - echo $mes->render('default', 'success'); - e107::getTheme()->clearCache(); - } - else - { - echo $mes->addError('Unable to continue')->render('default', 'error'); - } - - echo $mes->render('default', 'debug'); - -} -elseif(!empty($_POST['selectadmin'])) -{ - $mode = "admin"; -} - -if(!empty($_POST['upload'])) -{ - $mode = "upload"; -} -elseif(!empty($_POST['selectmain']) || isset($_POST['setUploadTheme'])) -{ - $mode = "main"; -} - -if($mode == 'convert') -{ - new theme_builder; -} -else -{ - $themec -> showThemes($mode); -} - - - -// Launch demo modal - - - - -require_once("footer.php"); - -function theme_adminmenu() -{ - //global $mode; - - $mode = varset($_GET['mode'],'main'); - - // $e107 = &e107::getInstance(); - - $var['main']['text'] = TPVLAN_33; - $var['main']['link'] = e_SELF; - - $var['admin']['text'] = TPVLAN_34; - $var['admin']['link'] = e_SELF."?mode=admin"; - - $var['choose']['text'] = TPVLAN_51; - $var['choose']['link'] = e_SELF."?mode=choose"; - - $var['online']['text'] = TPVLAN_62; - $var['online']['link'] = e_SELF."?mode=online"; - - $var['upload']['text'] = TPVLAN_38; - $var['upload']['link'] = e_SELF."?mode=upload"; - - $var['convert']['text'] = ADLAN_CL_6; - $var['convert']['link'] = e_SELF."?mode=convert"; - - // $selected = (e_QUERY) ? e_QUERY : "main"; - $icon = e107::getParser()->toIcon('e-themes-24'); - $caption = $icon."".TPVLAN_26.""; - - - e107::getNav()->admin($caption, $mode, $var); -} - -class theme_builder -{ - var $themeName = ""; - var $remove = array(); - - function __construct() - { - - $ns = e107::getRender(); - $tp = e107::getParser(); - - e107::getMessage()->addDebug("Disable debug to save generated files. "); - - - $this->themeName = $tp->filter($_GET['newtheme'],'w'); - - if(!empty($_GET['src'])) - { - $this->themeSrc = $tp->filter($_GET['src'],'w'); - $this->copyTheme(); - /* $src = $tp->filter($_GET['src'],'w'); - $name = $tp->filter($_GET['f']); - $title = $tp->filter($_GET['t']); - - $this->copyTheme($src,$name,$title);*/ - - } - - - - if(vartrue($_GET['step']) == 3) - { - $this->step3(); - return; - } - - if(vartrue($_GET['step']) == 2) - { - $this->step2(); - } - else - { - $ret = $this->step1(); - $ret2 = $this->copyThemeForm(); - - $tabs = array( - 0 => array('caption'=>$ret['caption'], 'text'=>$ret['text']), - 1 => array('caption'=>$ret2['caption'], 'text'=>$ret2['text']), - - ); - - $ns->tablerender(ADLAN_140.SEP.ADLAN_CL_6,e107::getForm()->tabs($tabs)); - } - - - - - - } - - function step1() - { - - $fl = e107::getFile(); - $frm = e107::getForm(); - $ns = e107::getRender(); - $mes = e107::getMessage(); - - $plugFolders = $fl->get_dirs(e_THEME); - foreach($plugFolders as $dir) - { - if(file_exists(e_THEME.$dir."/theme.xml") || $dir == 'templates') - { - continue; - } - $newDir[$dir] = $dir; - } - - $mes->addInfo(' '.TPVLAN_64.'
- '.TPVLAN_65.' - - '); - - $text = $frm->open('createPlugin','get',e_SELF."?mode=convert"); - $text .= " - - - - - - - - - "; - - /* - $text .= " - - - - "; - */ - - $text .= " -
".TPVLAN_68."".$frm->select("newtheme",$newDir)."
Create Files".$frm->checkbox('createFiles',1,1)."
-
- ".$frm->admin_button('step', 2,'other',LAN_GO)." -
"; - - $text .= $frm->close(); - - return array('caption'=>TPVLAN_88, 'text'=>$mes->render() . $text); - - $ns->tablerender(TPVLAN_26.SEP.TPVLAN_88.SEP. TPVLAN_CONV_1, $mes->render() . $text); - - } - - function step2() - { - $ns = e107::getRender(); - $mes = e107::getMessage(); - $frm = e107::getForm(); - - - - - $data = array( - 'main' => array('name','lang','version','date', 'compatibility'), - 'author' => array('name','url'), - 'summary' => array('summary'), - 'description' => array('description'), - - 'keywords' => array('one','two'), - 'category' => array('category'), - 'livedemo' => array('livedemo'), - 'copyright' => array('copyright'), - 'stylesheets' => array('stylesheets') - // 'adminLinks' => array('url','description','icon','iconSmall','primary'), - // 'sitelinks' => array('url','description','icon','iconSmall') - ); - - $legacyFile = e_THEME.$this->themeName."/theme.php"; - - - - $newThemeXML = e_THEME.$this->themeName."/theme.xml"; - if(file_exists($newThemeXML)) - { - $info = e107::getTheme()->getThemeInfo($this->themeName); - - e107::getDebug()->log($info); - - if($this->themeSrc) // New theme copied from another - { - $defaults = array( - "main-name" => ucfirst($this->themeName), - 'category-category' => vartrue($info['category']), - ); - } - else - { - $defaults = array( - "main-name" => vartrue($info['name']), - "main-date" => vartrue($info['date']), - "main-version" => vartrue($info['version']), - "author-name" => vartrue($info['author']), - "author-url" => vartrue($info['website']), - "description-description" => vartrue($info['description']), - "summary-summary" => vartrue($info['summary']), - 'category-category' => vartrue($info['category']), - // "custompages" => vartrue($leg['CUSTOMPAGES']), - ); - } - - if(!empty($info['keywords']['word'])) - { - $defaults['keywords-one'] = $info['keywords']['word'][0]; - $defaults['keywords-two'] = $info['keywords']['word'][1]; - } - - } - elseif(file_exists($legacyFile)) - { - $legacyData = file_get_contents($legacyFile); - - $regex = '/\$([\w]*)\s*=\s*("|\')([\w @.\/:<\>,\'\[\] !()]*)("|\');/im'; - preg_match_all($regex, $legacyData, $matches); - - $leg = array(); - - foreach($matches[1] as $i => $m) - { - $leg[$m] = strip_tags($matches[3][$i]); - if(substr($m,0,5) == 'theme' || $m == "CUSTOMPAGES") - { - $search[] = $matches[0][$i]; - } - } - - $defaults = array( - "main-name" => vartrue($leg['themename']), - "author-name" => vartrue($leg['themeauthor']), - "author-url" => vartrue($leg['themewebsite']), - "description-description" => '', - "summary-summary" => vartrue($leg['themeinfo']), - "custompages" => vartrue($leg['CUSTOMPAGES']), - ); - - $search[] = "Steve Dunstan"; - $search[] = "jalist@e107.org"; - - $_SESSION['themebulder-remove'] = $search; - - $mes->addInfo("Loading theme.php file"); - } - - $text = $frm->open('newtheme-step3','post', e_SELF.'?mode=convert&src='.$this->themeSrc.'&newtheme='.$this->themeName.'&step=3'); - $text .= ""; - foreach($data as $key=>$val) - { - $text.= ""; - - - } - - - $text .= "
$key -
"; - foreach($val as $type) - { - $nm = $key.'-'.$type; - $name = "xml[$nm]"; - $size = (count($val)==1) ? 'col-md-7' : 'col-md-2'; - $text .= "
".$this->xmlInput($name, $key."-". $type, vartrue($defaults[$nm]))."
"; - } - - $text .= "
"; - $text .= " -
" - .$frm->hidden('newtheme', $this->themeName); - $text .= $frm->hidden('xml[custompages]', trim(vartrue($leg['CUSTOMPAGES']))) - .$frm->admin_button('step', 3,'other',LAN_GENERATE)." -
"; - - $text .= $frm->close(); - - // return array('caption'=>TPVLAN_88.SEP. TPVLAN_CONV_2, 'text'=>$mes->render() . $text); - - $ns->tablerender(TPVLAN_26.SEP.ADLAN_CL_6.SEP. TPVLAN_CONV_2, $mes->render() . $text); - } - - - function step3() - { - $ns = e107::getRender(); - $mes = e107::getMessage(); - - // print_a($_POST); - - if(!empty($_POST['xml'])) - { - $xmlText = $this->createXml($_POST['xml']); - $ns->tablerender("theme.xml", $mes->render(). "
".$xmlText."
"); - } - - - $legacyFile = e_THEME.$this->themeName."/theme.php"; - if(file_exists($legacyFile) && empty($this->themeSrc)) - { - $legacyData = file_get_contents($legacyFile); - $legacyData = e107::getTheme()->upgradeThemeCode($legacyData); - - $output = nl2br(htmlentities($legacyData)); - - $ns->tablerender("theme.php (updated)", $output); - } - - - } - - - - - function createXml($data) - { - $ns = e107::getRender(); - $mes = e107::getMessage(); - $tp = e107::getParser(); - - foreach($data as $key=>$val) - { - $key = strtoupper(str_replace("-","_",$key)); - $newArray[$key] = $val; - } - - if(!empty($newArray['CUSTOMPAGES'])) - { - $newArray['CUSTOMPAGES'] = trim($newArray['CUSTOMPAGES']); - $LAYOUTS = "\n\n"; - $LAYOUTS .= " {CUSTOMPAGES}\n"; - $LAYOUTS .= " "; - } - else - { - $LAYOUTS = ""; - } - - if(!empty($newArray['STYLESHEETS_STYLESHEETS'])) - { - $STYLESHEETS = ''; - foreach($newArray['STYLESHEETS_STYLESHEETS'] as $val) - { - if(empty($val['file'])) - { - continue; - } - - $STYLESHEETS .= "\t\t\n"; - } - - if(!empty($STYLESHEETS)) - { - $STYLESHEETS = "\n\t\n".$STYLESHEETS."\t"; - } - - unset($newArray['STYLESHEETS_STYLESHEETS']); - } - else - { - $STYLESHEETS = ""; - } - - $newArray['STYLESHEETS'] = $STYLESHEETS; - - // print_a($newArray); - - -$template = <<