From d9697e47185b8335c2c9f7bdc1b7c69ab8f428a9 Mon Sep 17 00:00:00 2001 From: e107steved Date: Thu, 20 Nov 2008 20:35:24 +0000 Subject: [PATCH] Update file_class to make it more flexible; fix some calls and a couple of other things along the way --- e107_admin/download.php | 15 +- e107_admin/emoticon.php | 80 +++++---- e107_admin/lancheck.php | 11 +- e107_admin/links.php | 19 ++- e107_files/e107.css | 2 +- e107_files/shortcode/imageselector.sc | 4 +- e107_handlers/file_class.php | 155 ++++++++++++------ e107_handlers/ren_help.php | 12 +- .../content/handlers/content_form_class.php | 21 +-- e107_plugins/featurebox/admin_config.php | 9 +- e107_plugins/links_page/link_class.php | 12 +- e107_plugins/list_new/admin_list_config.php | 9 +- news.php | 9 +- 13 files changed, 208 insertions(+), 150 deletions(-) diff --git a/e107_admin/download.php b/e107_admin/download.php index a215c30d7..8d7ce014f 100644 --- a/e107_admin/download.php +++ b/e107_admin/download.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/download.php,v $ -| $Revision: 1.13 $ -| $Date: 2008-09-23 19:31:50 $ +| $Revision: 1.14 $ +| $Date: 2008-11-20 20:34:44 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -111,11 +111,13 @@ if ($sql->db_Select("rbinary")) -if($image_array = $fl->get_files(e_FILE."downloadimages/", ".gif|.jpg|.png|.GIF|.JPG|.PNG","standard",2)){ +if($image_array = $fl->get_files(e_FILE.'downloadimages/', '\.gif$|\.jpg$|\.png$|\.GIF$|\.JPG$|\.PNG$','standard',2)) +{ sort($image_array); } -if($thumb_array = $fl->get_files(e_FILE."downloadthumbs/", ".gif|.jpg|.png|.GIF|.JPG|.PNG","standard",2)){ +if($thumb_array = $fl->get_files(e_FILE.'downloadimages/', '\.gif$|\.jpg$|\.png$|\.GIF$|\.JPG$|\.PNG$','standard',2)) +{ sort($thumb_array); } @@ -1686,8 +1688,9 @@ class download require_once(e_HANDLER."file_class.php"); $fl = new e_file; - $rejecthumb = array('$.','$..','/','CVS','thumbs.db','*._$',"thumb_", 'index', 'null*'); - $imagelist = $fl->get_files(e_FILE."downloadimages/","",$rejecthumb); +// $rejecthumb = array('$.','$..','/','CVS','thumbs.db','*._$',"thumb_", 'index', 'null*'); +// $imagelist = $fl->get_files(e_FILE."downloadimages/","",$rejecthumb); + $imagelist = $fl->get_files(e_FILE.'downloadimages/'); // Standard reject filter should work if($sub_action == "edit" && !defined("SUBMITTED")) { diff --git a/e107_admin/emoticon.php b/e107_admin/emoticon.php index 57d553996..72776efb1 100644 --- a/e107_admin/emoticon.php +++ b/e107_admin/emoticon.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/emoticon.php,v $ -| $Revision: 1.8 $ -| $Date: 2008-11-02 11:19:30 $ +| $Revision: 1.9 $ +| $Date: 2008-11-20 20:34:44 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -153,11 +153,11 @@ class emotec ".EMOLAN_9." "; - $reject = array('^\.$','^\.\.$','^\/$','^CVS$','thumbs\.db','.*\._$', 'emoteconf*', '\.bak$'); + $reject = '~^emoteconf|\.html$|\.php$|\.txt$'; // Files to exclude foreach($this -> packArray as $pack) { - $can_scan = FALSE; - $emoteArray = $fl -> get_files(e_IMAGE."emotes/".$pack, "", $reject); + $can_scan = FALSE; + $emoteArray = $fl -> get_files(e_IMAGE.'emotes/'.$pack, $reject); $text .= " @@ -167,16 +167,17 @@ class emotec foreach($emoteArray as $emote) { - if (strstr($emote['fname'], ".pak") - || strstr($emote['fname'], ".xml") - || strstr($emote['fname'], "phpBB")) - { - $can_scan = TRUE; // Allow re-scan of config files - } - elseif (!strstr($emote['fname'], ".txt") && !strstr($emote['fname'], ".bak") && !strstr($emote['fname'], ".html") && !strstr($emote['fname'], ".php") ) - { // Emote file found - $text .= " "; - } + if (strstr($emote['fname'], ".pak") + || strstr($emote['fname'], ".xml") + || strstr($emote['fname'], "phpBB")) + { + $can_scan = TRUE; // Allow re-scan of config files + } +// elseif (!strstr($emote['fname'], ".txt") && !strstr($emote['fname'], ".bak") && !strstr($emote['fname'], ".html") && !strstr($emote['fname'], ".php") ) + else + { // Emote file found (might get other non-image files, but shouldn't) + $text .= " "; + } } $text .= " @@ -207,17 +208,18 @@ class emotec $emotecode = $sysprefs -> getArray($corea); - $reject = array('^\.$','^\.\.$','^\/$','^CVS$','thumbs\.db','.*\._$', 'emoteconf*', '*\.txt', '*\.html', '*\.pak', '*php*', '.cvsignore', '\.bak$'); - $emoteArray = $fl -> get_files(e_IMAGE."emotes/".$packID, "", $reject); +// $reject = array('^\.$','^\.\.$','^\/$','^CVS$','thumbs\.db','.*\._$', 'emoteconf*', '*\.txt', '*\.html', '*\.pak', '*php*', '.cvsignore', '\.bak$'); + $reject = '~^emoteconf|\.html$|\.php$|\.txt$|\.pak$|\.xml|\.phpBB'; // Files to exclude + $emoteArray = $fl -> get_files(e_IMAGE."emotes/".$packID, $reject); $eArray = array(); foreach($emoteArray as $value) { - if(!strstr($value['fname'], ".php") +/* if(!strstr($value['fname'], ".php") && !strstr($value['fname'], ".txt") && !strstr($value['fname'], ".pak") && !strstr($value['fname'], ".bak") && !strstr($value['fname'], ".xml") - && !strstr($value['fname'], "phpBB") && !strstr($value['fname'], ".html")) + && !strstr($value['fname'], "phpBB") && !strstr($value['fname'], ".html")) */ { $eArray[] = array('path' => $value['path'], 'fname' => $value['fname']); } @@ -281,17 +283,18 @@ class emotec $corea = "emote_".$packID; $emotecode = $sysprefs -> getArray($corea); - $reject = array('^\.$','^\.\.$','^\/$','^CVS$','thumbs\.db','.*\._$', 'emoteconf*', '*\.txt', '*\.html', '*\.pak', '*php*', '.cvsignore', '\.bak$'); - $emoteArray = $fl -> get_files(e_IMAGE."emotes/".$packID, "", $reject); +// $reject = array('^\.$','^\.\.$','^\/$','^CVS$','thumbs\.db','.*\._$', 'emoteconf*', '*\.txt', '*\.html', '*\.pak', '*php*', '.cvsignore', '\.bak$'); + $reject = '~^emoteconf|\.html$|\.php$|\.txt$|\.pak$|\.xml|\.phpBB'; // Files to exclude + $emoteArray = $fl -> get_files(e_IMAGE."emotes/".$packID, $reject); $eArray = array(); foreach($emoteArray as $value) { - if(!strstr($value['fname'], ".php") +/* if(!strstr($value['fname'], ".php") && !strstr($value['fname'], ".txt") && !strstr($value['fname'], ".pak") && !strstr($value['fname'], ".bak") && !strstr($value['fname'], ".xml") - && !strstr($value['fname'], "phpBB") && !strstr($value['fname'], ".html")) + && !strstr($value['fname'], "phpBB") && !strstr($value['fname'], ".html")) */ { $eArray[] = $value['fname']; } @@ -335,21 +338,12 @@ class emotec $packID = $_POST['packID']; unset($_POST['sub_conf'], $_POST['packID']); -/* - foreach($_POST as $key => $value) // $key is file name, with '.' already replaced by '!' - { - unset($_POST[$key]); -// $key = str_replace("_", "!", $key); // Why? -// $key = str_replace(".", "!", $key); // Don't think we need this, either - $_POST[$key] = $value; - } -*/ $encoded_emotes = $tp -> toDB($_POST); $tmp = addslashes(serialize($encoded_emotes)); if ($sql->db_Select("core", "*", "e107_name='emote_".$packID."'")) { - admin_update($sql->db_Update("core", "e107_value='$tmp' WHERE e107_name='emote_".$packID."' "), 'update', EMOLAN_16); + admin_update($sql->db_Update("core", "`e107_value`='{$tmp}' WHERE `e107_name`='emote_".$packID."' "), 'update', EMOLAN_16); } else { @@ -396,17 +390,17 @@ class emotec return FALSE; } - if (array_key_exists($value,$pack_local)) - { - unset($pack_local[$value]); - } + if (array_key_exists($value,$pack_local)) + { + unset($pack_local[$value]); + } if (($do_one == $value) || !$do_one && (!$sql -> db_Select("core", "*", "e107_name='emote_".$value."' "))) { // Pack info not in DB, or to be re-scanned $no_error = TRUE; $File_type = 'Unknown'; // Array of all files in the directory of the selected emote pack - $fileArray = $fl -> get_files(e_IMAGE."emotes/".$value); + $fileArray = $fl -> get_files(e_IMAGE."emotes/".$value); // We actually want all the files in the directory $confFile = ''; foreach($fileArray as $k => $file) { @@ -455,10 +449,6 @@ class emotec if($confFile['type'] == "xml") { $filename = e_IMAGE."emotes/".$value."/".$confFile['file']; - -// $handle = fopen ($filename, "r"); -// $contents = fread ($handle, filesize ($filename)); // Get the XML file for the emote pack -// fclose ($handle); $contents = file_get_contents($filename); $confArray = array(); $xml_type = 0; @@ -481,6 +471,7 @@ class emotec } elseif (strpos($contents, ""; preg_match_all("#\(.*?)\<\/emoticon\>#si", $contents, $match); $xml_type = 2; @@ -543,7 +534,10 @@ class emotec } } // Only add if the file exists. OK if no definition - might want to be added - if ($file) $confArray[$file] = $codet; + if ($file) + { + $confArray[$file] = $codet; + } } } else diff --git a/e107_admin/lancheck.php b/e107_admin/lancheck.php index 5da2383d8..dfa884a76 100644 --- a/e107_admin/lancheck.php +++ b/e107_admin/lancheck.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/lancheck.php,v $ -| $Revision: 1.9 $ -| $Date: 2008-01-08 20:22:54 $ +| $Revision: 1.10 $ +| $Date: 2008-11-20 20:34:44 $ | $Author: e107steved $ | With code from Izydor and Lolo. +----------------------------------------------------------------------------+ @@ -345,7 +345,7 @@ function get_comp_lan_phrases($comp_dir,$lang,$depth=0) $fl = new e_file; $ret = array(); - if($lang_array = $fl->get_files($comp_dir, ".php","standard",$depth)){ + if($lang_array = $fl->get_files($comp_dir, '\.php','standard',$depth)){ sort($lang_array); } @@ -381,7 +381,7 @@ function get_comp_lan_phrases($comp_dir,$lang,$depth=0) } -// for plugins and themes - checkes what kind of language files directory structure we have +// for plugins and themes - checks what kind of language files directory structure we have function check_lanfiles($mode,$comp_name,$base_lan="English",$target_lan){ global $ns,$sql; @@ -672,3 +672,6 @@ function lancheck_adminmenu() { show_admin_menu(ADLAN_132, $action, $var); } + + $ns -> tablerender(LAN_CHECK_1, 'No data'); + require_once(e_ADMIN."footer.php"); diff --git a/e107_admin/links.php b/e107_admin/links.php index 3c626b404..e72e06817 100644 --- a/e107_admin/links.php +++ b/e107_admin/links.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/links.php,v $ -| $Revision: 1.14 $ -| $Date: 2008-11-14 06:01:06 $ -| $Author: e107coders $ +| $Revision: 1.15 $ +| $Date: 2008-11-20 20:34:44 $ +| $Author: e107steved $ | | links.php?debug shows stored data for each link after name (before constant conversion) +----------------------------------------------------------------------------+ @@ -487,10 +487,10 @@ class links require_once(e_HANDLER."file_class.php"); $fl = new e_file; - if($iconlist = $fl->get_files(e_IMAGE."icons/", ".jpg|.gif|.png|.JPG|.GIF|.PNG")){ + if($iconlist = $fl->get_files(e_IMAGE."icons/", '\.jpg|\.gif|\.png|\.JPG|\.GIF|\.PNG')) + { sort($iconlist); } - $text = "
"; @@ -506,7 +506,7 @@ class links @@ -536,10 +536,11 @@ class links "; - $rejectlist = array('$.','$..','/','CVS','thumbs.db','Thumbs.db','*._$', 'index', 'null*', 'blank*'); +// $rejectlist = array('$.','$..','/','CVS','thumbs.db','Thumbs.db','*._$', 'index', 'null*', 'blank*'); $iconpath = e_PLUGIN."links_page/link_images/"; - $iconlist = $fl->get_files($iconpath,"",$rejectlist); + $iconlist = $fl->get_files($iconpath); $iconpath = e_PLUGIN_ABS."links_page/link_images/"; // Absolute paths now we've got the files $text .= " @@ -841,8 +841,8 @@ class linkclass { $row['link_category_description'] = ""; $row['link_category_icon'] = ""; } - $rejectlist = array('$.','$..','/','CVS','thumbs.db','Thumbs.db','*._$', 'index', 'null*'); - $iconlist = $fl->get_files(e_PLUGIN."links_page/cat_images/","",$rejectlist); +// $rejectlist = array('$.','$..','/','CVS','thumbs.db','Thumbs.db','*._$', 'index', 'null*'); + $iconlist = $fl->get_files(e_PLUGIN."links_page/cat_images/"); $text = "
".$rs->form_open("post", e_SELF.(e_QUERY ? "?".e_QUERY : ""), "linkform", "", "enctype='multipart/form-data'", "")." diff --git a/e107_plugins/list_new/admin_list_config.php b/e107_plugins/list_new/admin_list_config.php index 46c1b3eb9..93edd0c30 100644 --- a/e107_plugins/list_new/admin_list_config.php +++ b/e107_plugins/list_new/admin_list_config.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/list_new/admin_list_config.php,v $ -| $Revision: 1.3 $ -| $Date: 2008-03-09 20:33:18 $ +| $Revision: 1.4 $ +| $Date: 2008-11-20 20:35:24 $ | $Author: e107steved $ +---------------------------------------------------------------+ */ @@ -52,8 +52,9 @@ if(isset($_POST['update_menu'])){ $list_pref = $rc -> getListPrefs(); -$rejectlist = array('$.','$..','/','CVS','thumbs.db','Thumbs.db','*._$', 'index', 'null*'); -$iconlist = $fl->get_files($listplugindir."images/", "", $rejectlist); +//$rejectlist = array('$.','$..','/','CVS','thumbs.db','Thumbs.db','*._$', 'index', 'null*'); +//$iconlist = $fl->get_files($listplugindir."images/", "", $rejectlist); +$iconlist = $fl->get_files($listplugindir."images/"); //render message if set if(isset($message)){ diff --git a/news.php b/news.php index a017c2502..e2e57823f 100644 --- a/news.php +++ b/news.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/news.php,v $ -| $Revision: 1.10 $ -| $Date: 2007-12-11 20:38:56 $ +| $Revision: 1.11 $ +| $Date: 2008-11-20 20:34:44 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -597,8 +597,9 @@ if ($action != "item") { if(is_dir("remotefile")) { require_once(e_HANDLER."file_class.php"); $file = new e_file; - $reject = array('$.','$..','/','CVS','thumbs.db','*._$', 'index', 'null*', 'Readme.txt'); - $crem = $file -> get_files(e_BASE."remotefile", "", $reject); +// $reject = array('$.','$..','/','CVS','thumbs.db','*._$', 'index', 'null*', 'Readme.txt'); +// $crem = $file -> get_files(e_BASE."remotefile", "", $reject); + $crem = $file -> get_files(e_BASE."remotefile", '~Readme\.txt'); if(count($crem)) { foreach($crem as $loadrem) { if(strstr($loadrem['fname'], "load_")) {
".LCLAN_15.": - +
".LCLAN_18.": - + - -