Exemple #1
0
 $smarty->assign("T_CURRENT_THEME", $currentSetTheme);
 $smarty->assign("T_MAX_FILESIZE", FileSystemTree::getUploadMaxSize());
 $smarty->assign("T_BROWSERS", themes::$browsers);
 $entityName = 'themes';
 require "entity.php";
 if (isset($_GET['set_browser']) && in_array($_GET['set_browser'], $legalValues) && eF_checkParameter($_GET['set_browser'], 'id') && isset($_GET['browser']) && in_array($_GET['browser'], array_keys(themes::$browsers))) {
     try {
         unset($_SESSION['s_theme']);
         $theme = new themes($_GET['set_browser']);
         foreach ($themes as $key => $value) {
             //$value = new themes($value['id']);
             unset($value->options['browsers'][$_GET['browser']]);
             $value->persist();
         }
         $theme->options['browsers'][$_GET['browser']] = 1;
         $theme->persist();
         $url = '';
         if (detectBrowser() == $_GET['browser']) {
             if ($theme->options['sidebar_interface'] > 0) {
                 $url = basename($_SERVER['PHP_SELF']) . '?ctg=themes&tab=set_theme';
             } else {
                 $url = basename($_SERVER['PHP_SELF'], '.php') . 'page.php?ctg=themes&tab=set_theme';
             }
         }
         echo json_encode(array('status' => 1, 'browser' => $_GET['browser'], 'url' => $url));
     } catch (Exception $e) {
         handleAjaxExceptions($e);
     }
     exit;
 }
 if (isset($_GET['set_theme']) && in_array($_GET['set_theme'], $legalValues) && eF_checkParameter($_GET['set_theme'], 'id')) {
     if ($options['custom_blocks']) {
         $basedir = G_EXTERNALPATH;
         if (!is_dir($basedir) && !mkdir($basedir, 0755)) {
             throw new EfrontFileException(_COULDNOTCREATEDIRECTORY . ': ' . $fullPath, EfrontFileException::CANNOT_CREATE_DIR);
         }
         $blocks = unserialize($options['custom_blocks']);
         foreach ($blocks as $value) {
             $value['name'] = rand() . time();
             //Use a random name
             $block = array('name' => $value['name'], 'title' => $value['title']);
             file_put_contents($basedir . $value['name'] . '.tpl', $value['content']);
             isset($customBlocks) && sizeof($customBlocks) > 0 ? $customBlocks[] = $block : ($customBlocks = array($block));
         }
         $currentSetTheme = new themes($GLOBALS['configuration']['theme']);
         $currentSetTheme->layout['custom_blocks'] = $customBlocks;
         $currentSetTheme->persist();
     }
 } catch (Exception $e) {
 }
 //Try to restore custom logo
 try {
     $logoFile = new EfrontFile($options['logo']);
     if (strpos($logoFile['path'], G_LOGOPATH) === false) {
         copy($logoFile['path'], G_LOGOPATH . $logoFile['name']);
     }
 } catch (Exception $e) {
 }
 //Try to restore custom favicon
 try {
     if (strpos($faviconFile['path'], G_LOGOPATH) === false) {
         $faviconFile = new EfrontFile($options['logo']);