frm = new e_form(); $this->fl = e107::getFile(); if(isset($_POST['upload'])) { $this->themeUpload(); } if(vartrue($_POST['installContent'])) { $this->installContent($_POST['installContent']); } $this->themeArray = (defined('E107_INSTALL')) ? $this->getThemes('xml') : $this->getThemes(); // print_a($this -> themeArray); foreach ($_POST as $key=>$post) { if(strstr($key, "preview")) { // $this -> id = str_replace("preview_", "", $key); $this->id = key($post); $this->themePreview(); } if(strstr($key, "selectmain")) { // $this -> id = str_replace("selectmain_", "", $key); $this->id = key($post); if($this->setTheme()) { $mes->addSuccess(TPVLAN_3); } else { $mes->addError(TPVLAN_3); } } if(strstr($key, "selectadmin")) { $this->id = key($post); $this->setAdminTheme(); $this->refreshPage('admin'); } } if(isset($_POST['submit_adminstyle'])) { $this->id = $_POST['curTheme']; if($this->setAdminStyle()) { eMessage::getInstance()->add(TPVLAN_43, E_MESSAGE_SUCCESS); } e107::getConfig()->save(true); } if(isset($_POST['submit_style'])) { $this->id = $_POST['curTheme']; $this->setLayouts(); // Update the layouts in case they have been manually changed. $this->SetCustomPages($_POST['custompages']); $this->setStyle(); e107::getConfig()->save(true); } if(isset($_POST['installplugin'])) { $key = key($_POST['installplugin']); include_lan(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_plugin.php"); require_once (e_HANDLER."plugin_class.php"); $eplug = new e107plugin; $message = $eplug->install_plugin($key); $mes->add($message, E_MESSAGE_SUCCESS); } if(isset($_POST['setMenuPreset'])) { $key = key($_POST['setMenuPreset']); include_lan(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_menus.php"); require_once (e_HANDLER."menumanager_class.php"); $men = new e_menuManager(); $men->curLayout = $key; //menu_layout is left blank when it's default. $men->dbLayout = ($men->curLayout != $pref['sitetheme_deflayout']) ? $men->curLayout : ""; if($areas = $men->menuSetPreset()) { foreach ($areas as $val) { $ar[$val['menu_location']][] = $val['menu_name']; } foreach ($ar as $k=>$v) { $message .= MENLAN_14." ".$k." : ".implode(", ", $v)."
"; } $mes->add(MENLAN_43." : ".$key."
".$message, E_MESSAGE_SUCCESS); } } } function getThemes($mode = FALSE) { $themeArray = array(); $tloop = 1; $fl = e107::getFile(); $array = $fl->get_dirs(e_THEME); foreach($array as $file) { if(($mode == 'xml') && !is_readable(e_THEME.$file."/theme.xml")) { continue; } if($file != "." && $file != ".." && $file != "CVS" && $file != "templates" && is_dir(e_THEME.$file) && is_readable(e_THEME.$file."/theme.php")) { if($mode == "id") { $themeArray[$tloop] = $file; } else { $themeArray[$file] = $this->getThemeInfo($file); $themeArray[$file]['id'] = $tloop; } $tloop++; } } // echo "
";
	//	 print_r($themeArray);
	//	 echo "
"; return $themeArray; } function getThemeInfo($file) { $mes = e107::getMessage(); $reject = array('e_.*'); $handle2 = e107::getFile()->get_files(e_THEME.$file."/", "\.php|\.css|\.xml|preview\.jpg|preview\.png", $reject, 1); foreach ($handle2 as $fln) { $file2 = str_replace(e_THEME.$file."/", "", $fln['path']).$fln['fname']; $themeArray[$file]['files'][] = $file2; if(strstr($file2, "preview.")) { $themeArray[$file]['preview'] = e_THEME.$file."/".$file2; } // ---------------- get information string for css file - Legacy mode (no theme.xml) if(strstr($file2, ".css") && !strstr($file2, "menu.css") && strpos($file2, "e_") !== 0) { if($cssContents = file_get_contents(e_THEME.$file."/".$file2)) { $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); } else { // $mes->addDebug("Couldn't read file: ".e_THEME.$file."/".$file2); } } } // end while.. // Load Theme information and merge with existing array. theme.xml (v2.x theme) is given priority over theme.php (v1.x). if(in_array("theme.xml", $themeArray[$file]['files'])) { $themeArray[$file] = array_merge($themeArray[$file], $this->parse_theme_xml($file)); } elseif(in_array("theme.php", $themeArray[$file]['files'])) { $themeArray[$file] = array_merge($themeArray[$file], $this->parse_theme_php($file)); } if(count($themeArray[$file]['css']) > 1) { $themeArray[$file]['multipleStylesheets'] = TRUE; } return $themeArray[$file]; } /** * Validate and return the name of the categories. * * @param string [optional] $categoryfromXML * @return string */ function getThemeCategory($categoryfromXML = '') { if(!$categoryfromXML) { return 'generic'; } $tmp = explode(",", $categoryfromXML); $category = array(); foreach ($tmp as $cat) { $cat = trim($cat); if(in_array($cat, $this->allowedCategories)) { $category[] = $cat; } else { $category[] = 'generic'; } } return implode(', ', $category); } function themeUpload() { if(!$_POST['ac'] == md5(ADMINPWCHANGE)) { exit; } $mes = e107::getMessage(); $ns = e107::getRender(); extract($_FILES); //print_a($_FILES); if(!is_writable(e_THEME)) { $mes->addInfo(TPVLAN_20); return FALSE; } else { // FIXME - temporary fixes to upload process, check required. // Probably in need of a rewrite to use process_uploaded_files(); require_once (e_HANDLER."upload_handler.php"); $fileName = $_FILES['file_userfile']['name'][0]; $fileSize = $_FILES['file_userfile']['size'][0]; $fileType = $_FILES['file_userfile']['type'][0]; // type is returned as mime type (application/octet-stream) not as zip/rar // There may be a better way to do this.. MIME may not be secure enough // process_uploaded_files() ? $mime_zip = array("application/octet-stream", "application/zip", "multipart/x-zip"); $mime_gzip = array("application/x-gzip", "multipart/x-gzip"); // rar? if(in_array($fileType, $mime_zip)) { $fileType = "zip"; } elseif(in_array($fileType, $mime_gzip)) { $fileType = "gzip"; } else { $mes->addError(TPVLAN_17); return FALSE; } 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, PCLZIP_OPT_SET_CHMOD, 0666)); // FIXME - detect folder structure similar to 'Find themes' } else { require_once (e_HANDLER."pcltar.lib.php"); $unarc = ($fileList = PclTarExtract($archiveName, e_THEME)); // FIXME - detect folder structure similar to 'Find themes' } if(!$unarc) { if($fileType == "zip") { $error = TPVLAN_46." '".$archive->errorName(TRUE)."'"; } else { $error = TPVLAN_47.PclErrorString().", ".TPVLAN_48.intval(PclErrorCode()); } $mes->addError(TPVLAN_18." ".$archiveName." ".$error); return FALSE; } $folderName = substr($fileList[0]['stored_filename'], 0, (strpos($fileList[0]['stored_filename'], "/"))); $mes->addSuccess(TPVLAN_19); if(varset($_POST['setUploadTheme'])) { $themeArray = $this->getThemes(); $this->id = $themeArray[$folderName]['id']; if($this->setTheme()) { $mes->addSuccess(TPVLAN_3); } else { $mes->addError("Could not change site theme."); // TODO LAN } } @unlink(e_THEME.$archiveName); } } } private function search($name, $searchVal, $submitName, $filterName='', $filterArray=false, $filterVal=false) { $frm = e107::getForm(); return $frm->search($name, $searchVal, $submitName, $filterName, $filterArray, $filterVal); $text = ' '.$frm->text($name, $searchVal,20,'class=search-query').' '; // $text .= $this->admin_button($submitName,LAN_SEARCH,'search'); return $text; } /** * Temporary, e107::getMarketplace() coming soon * @return e_marketplace */ public function getMarketplace() { if(null === $this->mp) { require_once(e_HANDLER.'e_marketplace.php'); $this->mp = new e_marketplace(); // autodetect the best method } return $this->mp; } function renderOnline($ajax=false) { global $e107SiteUsername, $e107SiteUserpass; $xml = e107::getXml(); $mes = e107::getMessage(); $frm = e107::getForm(); $ns = e107::getRender(); $mp = $this->getMarketplace(); $from = intval(varset($_GET['frm'])); $limit = 96; // FIXME - ajax pages load $srch = preg_replace('/[^\w]/','', vartrue($_GET['srch'])); // check for cURL if(!function_exists(curl_init)) { $mes->addWarning("cURL is currently required to use this feature. Contact your webhosting provider to enable cURL"); // TODO LAN? } // auth $mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass); // do the request, retrieve and parse data $xdata = $mp->call('getList', array( 'type' => 'theme', 'params' => array('limit' => $limit, 'search' => $srch, 'from' => $from) )); $total = $xdata['params']['count']; // OLD BIT OF CODE -------------------------------> /*$file = "http://e107.org/feed?type=theme&frm=".$from."&srch=".$srch."&limit=".$limit; $mes->addDebug("File = ".$file); $xml->setOptArrayTags('theme,screenshots/image'); // make sure 'theme' tag always returns an array // $xdata = $xml->loadXMLfile($file,'advanced',true); $xdata = $xml->loadXMLfile($file,true,false); $total = $xdata['@attributes']['total'];*/ // OLD BIT OF CODE -------------------------------> $amount =$limit; /* if($total > $amount) { //$parms = $total.",".$amount.",".$from.",".e_SELF.'?mode='.$_GET['mode'].'&frm=[FROM]'; $url = rawurlencode(e_SELF.'?mode='.$_GET['mode'].'&frm=[FROM]'); $parms = "total=".$total."&amount=".$amount."¤t=".$from."&url=".$url."&caption=off&tmpl=basic&navcount=4&glyphs=1"; $text .= "
".$tp->parseTemplate("{NEXTPREV=$parms}",TRUE)."
"; } */ // print_a($xdata); $c = 1; $text = "