themeUpload(); } $this -> themeArray = $this -> getThemes(); foreach($_POST as $key => $post) { if(strstr($key,"preview")) { $this -> id = str_replace("preview_", "", $key); $this -> themePreview(); } if(strstr($key,"selectmain")) { $this -> id = str_replace("selectmain_", "", $key); $this -> setTheme(); } if(strstr($key,"selectadmin")) { $this -> id = str_replace("selectadmin_", "", $key); $this -> setAdminTheme(); } } if(isset($_POST['submit_adminstyle'])) { $this -> setAdminStyle(); } if(isset($_POST['submit_style'])) { $this -> setStyle(); } } function getThemes($mode=FALSE) { $themeArray = array(); $tloop = 1; $handle = opendir(e_THEME); while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != "CVS" && $file != "templates" && is_dir(e_THEME.$file) && file_exists(e_THEME.$file."/theme.php")) { if($mode == "id") { $themeArray[$tloop] = $file; } else { $themeArray[$file]['id'] = $tloop; } $tloop++; $STYLESHEET = FALSE; if(!$mode) { $handle2 = opendir(e_THEME.$file."/"); while (false !== ($file2 = readdir($handle2))) { if ($file2 != "." && $file2 != ".." && $file != "CVS" && !is_dir(e_THEME.$file."/".$file2)) { $themeArray[$file]['files'][] = $file2; if(strstr($file2, "preview.")) { $themeArray[$file]['preview'] = e_THEME.$file."/".$file2; } if(strstr($file2, "css") && !strstr($file2, "menu.css") && strpos($file2, "e_") !== 0 && strpos($file2, "admin_") !== 0) { /* get information string */ $fp=fopen(e_THEME.$file."/".$file2, "r"); $cssContents = fread ($fp, filesize(e_THEME.$file."/".$file2)); fclose($fp); $nonadmin = preg_match('/\* Non-Admin(.*?)\*\//', $cssContents) ? true : false; preg_match('/\* info:(.*?)\*\//', $cssContents, $match); $match[1]=varset($match[1],''); $themeArray[$file]['css'][] = array("name" => $file2, "info" => $match[1], "nonadmin" => $nonadmin); if($STYLESHEET) { $themeArray[$file]['multipleStylesheets'] = TRUE; } else { $STYLESHEET = TRUE; } } } $fp=fopen(e_THEME.$file."/theme.php", "r"); $themeContents = fread ($fp, filesize(e_THEME.$file."/theme.php")); fclose($fp); preg_match('/themename(\s*?=\s*?)("|\')(.*?)("|\');/si', $themeContents, $match); $themeArray[$file]['name'] = varset($match[3],''); preg_match('/themeversion(\s*?=\s*?)("|\')(.*?)("|\');/si', $themeContents, $match); $themeArray[$file]['version'] = varset($match[3],''); preg_match('/themeauthor(\s*?=\s*?)("|\')(.*?)("|\');/si', $themeContents, $match); $themeArray[$file]['author'] = varset($match[3],''); preg_match('/themeemail(\s*?=\s*?)("|\')(.*?)("|\');/si', $themeContents, $match); $themeArray[$file]['email'] = varset($match[3],''); preg_match('/themewebsite(\s*?=\s*?)("|\')(.*?)("|\');/si', $themeContents, $match); $themeArray[$file]['website'] = varset($match[3],''); preg_match('/themedate(\s*?=\s*?)("|\')(.*?)("|\');/si', $themeContents, $match); $themeArray[$file]['date'] = varset($match[3],''); preg_match('/themeinfo(\s*?=\s*?)("|\')(.*?)("|\');/si', $themeContents, $match); $themeArray[$file]['info'] = varset($match[3],''); preg_match('/xhtmlcompliant(\s*?=\s*?)(\S*?);/si', $themeContents, $match); $xhtml = strtolower($match[2]); $themeArray[$file]['xhtmlcompliant'] = ($xhtml == "true" ? true : false); preg_match('/csscompliant(\s*?=\s*?)(\S*?);/si', $themeContents, $match); $css = strtolower($match[2]); $themeArray[$file]['csscompliant'] = ($css == "true" ? true : false); if (!$themeArray[$file]['name']) { unset($themeArray[$file]); } } closedir($handle2); } } } closedir($handle); return $themeArray; } function themeUpload() { if (!$_POST['ac'] == md5(ADMINPWCHANGE)) { exit; } global $ns; extract($_FILES); if(!is_writable(e_THEME)) { $ns->tablerender(TPVLAN_16, TPVLAN_20); } else { require_once(e_HANDLER."upload_handler.php"); $fileName = $file_userfile['name'][0]; $fileSize = $file_userfile['size'][0]; $fileType = $file_userfile['type'][0]; if(strstr($file_userfile['type'][0], "gzip")) { $fileType = "tar"; } else if (strstr($file_userfile['type'][0], "zip")) { $fileType = "zip"; } else { $ns->tablerender(TPVLAN_16, TPVLAN_17); require_once("footer.php"); exit; } if ($fileSize) { $uploaded = file_upload(e_THEME); $archiveName = $uploaded[0]['name']; if($fileType == "zip") { require_once(e_HANDLER."pclzip.lib.php"); $archive = new PclZip(e_THEME.$archiveName); $unarc = ($fileList = $archive -> extract(PCLZIP_OPT_PATH, e_THEME)); $unarc = ($fileList = $archive -> extract(PCLZIP_OPT_PATH, e_THEME, PCLZIP_OPT_SET_CHMOD, 0666)); } else { require_once(e_HANDLER."pcltar.lib.php"); $unarc = ($fileList = PclTarExtract($archiveName, e_THEME)); } if(!$unarc) { if($fileType == "zip") { $error = "PCLZIP extract error: '".$archive -> errorName(TRUE)."'"; } else { $error = "PCLTAR extract error: ".PclErrorString().", code: ".intval(PclErrorCode()); } $ns->tablerender(TPVLAN_16, TPVLAN_18." ".$archiveName." ".$error); require_once("footer.php"); exit; } $folderName = substr($fileList[0]['stored_filename'], 0, (strpos($fileList[0]['stored_filename'], "/"))); $ns->tablerender(TPVLAN_16, "
$preview
".$theme['name']." ".TPVLAN_11." ".$theme['version']." |
"; $itext = $author ? " |
".TPVLAN_4.": | ".$author." |
".TPVLAN_5.": | ".$website." |
".TPVLAN_6.": | ".$theme['date']." |
".TPVLAN_7.": | ".$theme['info']." |
".TPVLAN_8.": | ".$previewbutton.$selectmainbutton.$selectadminbutton." |
".TPVLAN_27.": | \n";
foreach($theme['css'] as $css)
{
if($mode == 2)
{
if (!$css['nonadmin']) {
$text .= "
".$css['name'].": ".($css['info'] ? $css['info'] : ($css['name'] == "style.css" ? TPVLAN_23 : TPVLAN_24))." \n"; } } if($mode == 1) { $text .= " ".$css['name'].": ".($css['info'] ? $css['info'] : ($css['name'] == "style.css" ? TPVLAN_23 : TPVLAN_24))." \n"; } } $text .= " |
".TPVLAN_22.": | |
".$css['name'].": | ".($css['info'] ? $css['info'] : ($css['name'] == "style.css" ? TPVLAN_23 : TPVLAN_24))." |
".TPVLAN_30." | ".TPVLAN_28." ".TPVLAN_29." |
".$selectadminbutton." |
".TPVLAN_41.": | $astext |
".$selectmainbutton." |
"; $text .= ($theme['xhtmlcompliant']) ? " ": ""; $text .= ($theme['csscompliant']) ? " " : ""; $text .= " |