Exemple #1
0
 public function loadall_tml()
 {
     $polls = tpolls::i();
     $filelist = tfiler::getfiles(litepublisher::$paths->data . 'polls');
     foreach ($filelist as $filename) {
         if (preg_match('/^(\\d*+)\\.php$/', $filename, $m)) {
             $id = (int) $m[1];
             $tml = $polls->get_tml($id);
         }
     }
     ksort($polls->tml_items, SORT_NUMERIC);
 }
 public function sendfile()
 {
     $themename = isset($_POST['themename']) ? trim($_POST['themename']) : '';
     if ($themename != '') {
         $themename = tlinkgenerator::i()->filterfilename($themename);
     }
     if ($themename == '') {
         $themename = time();
     }
     $path = "themes/generator-{$themename}/";
     litepublisher::$classes->include_file(litepublisher::$paths->libinclude . 'zip.lib.php');
     $zip = new zipfile();
     $themedir = litepublisher::$paths->plugins . 'themegenerator' . DIRECTORY_SEPARATOR . $this->type . DIRECTORY_SEPARATOR;
     $args = new targs();
     $colors = "[themecolors]\nthemename = \"{$themename}\"\n";
     foreach ($this->colors as $name => $value) {
         $colors .= "{$name} = \"{$value}\"\n";
         $args->{$name} = $value;
     }
     foreach (array('headerurl', 'logourl') as $name) {
         if (strbegin($this->colors[$name], 'http://')) {
             $basename = substr($this->colors[$name], strrpos($this->colors[$name], '/') + 1);
             $filename = litepublisher::$paths->files . 'themegen' . DIRECTORY_SEPARATOR . $basename;
             $zip->addFile(file_get_contents($filename), $path . 'images/' . $basename);
             $args->{$name} = 'images/' . $basename;
         }
     }
     $res = $this->res;
     $css = strtr(tfilestorage::getfile($res . 'scheme.tml'), $args->data);
     $zip->addFile($colors, $path . 'colors.ini');
     $filelist = tfiler::getfiles($themedir);
     foreach ($filelist as $filename) {
         $content = tfilestorage::getfile($themedir . $filename);
         switch ($filename) {
             case 'style.css':
                 $content .= $css;
                 break;
             case 'about.ini':
                 $content = str_replace('name = generator', "name = generator-{$themename}", $content);
                 break;
         }
         $zip->addFile($content, $path . $filename);
     }
     $result = $zip->file();
     if (ob_get_level()) {
         @ob_end_clean();
     }
     header('HTTP/1.1 200 OK', true, 200);
     header('Content-type: application/octet-stream');
     header('Content-Disposition: attachment; filename=generator.theme.' . $themename . '.zip');
     header('Content-Length: ' . strlen($result));
     header('Last-Modified: ' . date('r'));
     Header('Cache-Control: no-cache, must-revalidate');
     Header('Pragma: no-cache');
     echo $result;
     exit;
 }
 public function getcontent()
 {
     $datadir = litepublisher::$paths->data . 'keywords' . DIRECTORY_SEPARATOR;
     $selfdir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
     $tml = parse_ini_file($selfdir . 'keywords.templates.ini', false);
     $about = tplugins::getabout(tplugins::getname(__FILE__));
     $html = $this->html;
     $lang = $this->lang;
     $args = targs::i();
     if (isset($_GET['filename'])) {
         $filename = $_GET['filename'];
         if (!@file_exists($datadir . $filename)) {
             return $html->h3->notfound;
         }
         $args->filename = $filename;
         $args->content = file_get_contents($datadir . $filename);
         $args->formtitle = $about['edithead'];
         return $html->adminform('[editor=content]', $args);
     }
     $page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
     $result = '';
     if ($page == 1) {
         $widget = tkeywordswidget::i();
         $widgets = twidgets::i();
         $idwidget = $widgets->find($widget);
         $args->count = $widget->count;
         $args->trace = $widget->trace;
         $args->notify = $widget->notify;
         $args->optionsform = 1;
         $args->title = $widget->gettitle($idwidget);
         $args->blackwords = tadminhtml::specchars(implode("\n", tkeywordsplugin::i()->blackwords));
         $lang = tplugins::getlangabout(__FILE__);
         $args->formtitle = $about['name'];
         $result .= $html->adminform('[text=title]
   [text=count]
   [checkbox=trace]
   [checkbox=notify]
   [editor=blackwords]
   [hidden=optionsform]', $args);
     }
     $from = 100 * ($page - 1);
     $filelist = tfiler::getfiles($datadir);
     sort($filelist);
     $count = ceil(count($filelist) / 100);
     $links = $this->getlinkpages($page, $count);
     $result .= $links;
     $filelist = array_slice($filelist, $from, 100, true);
     $list = '';
     $args->url = litepublisher::$site->url . '/admin/plugins/' . litepublisher::$site->q . 'plugin=' . basename(dirname(__FILE__));
     foreach ($filelist as $filename) {
         if (!preg_match('/^\\d+?\\.\\d+?\\.php$/', $filename)) {
             continue;
         }
         $args->filename = $filename;
         $args->content = file_get_contents($datadir . $filename);
         $list .= $html->parsearg($tml['item'], $args);
     }
     $args->list = $list;
     $result .= $html->parsearg($tml['form'], $args);
     $result .= $links;
     return $result;
 }
 private function getbackupfilelist()
 {
     $list = tfiler::getfiles(litepublisher::$paths->backup);
     if (!count($list)) {
         return '';
     }
     $items = array();
     $html = $this->html;
     foreach ($list as $filename) {
         if (strend($filename, '.gz') || strend($filename, '.zip')) {
             $items[]['filename'] = $filename;
         }
     }
     if (!count($items)) {
         return '';
     }
     $lang = $this->lang;
     return $this->html->h4->backupheadern . $this->html->buildtable($items, array(array('right', $lang->download, "<a href=\"{$this->adminurl}=\$filename&action=download\">\$filename</a>"), array('right', $lang->delete, "<a href=\"{$this->adminurl}=\$filename&action=delete\">{$lang->delete}</a>")));
 }