public function save()
 {
     if ($this->lockcount > 0) {
         return;
     }
     tfilestorage::save($this);
 }
Ejemplo n.º 2
0
 public function loadfile($name)
 {
     $this->data = array();
     $filename = self::$dir . $name . '.php';
     if (file_exists($filename)) {
         return $this->loadfromstring(tfilestorage::loadfile($filename));
     }
 }
Ejemplo n.º 3
0
 public function getposteditor($post, $args)
 {
     $args->data['$lang.sourceurl'] = tlocal::admin()->get('usernews', 'sourceurl');
     if ($this->insertsource) {
         $args->sourceurl = isset($post->meta->sourceurl) ? $post->meta->sourceurl : '';
     }
     $form = tfilestorage::getfile(litepublisher::$paths->plugins . $this->dir . DIRECTORY_SEPARATOR . $this->editorfile);
     $args->raw = $post->rawcontent;
     $html = tadminhtml::i();
     $result = $post->id == 0 ? '' : $html->h2->formhead . $post->bookmark;
     $result .= $html->parsearg($form, $args);
     unset(ttheme::$vars['post']);
     return $html->fixquote($result);
 }
Ejemplo n.º 4
0
 public static function cacheini($filename)
 {
     if (isset(self::$inifiles[$filename])) {
         return self::$inifiles[$filename];
     }
     $datafile = tlocal::getcachedir() . sprintf('cacheini.%s.php', md5($filename));
     if (!tfilestorage::loadvar($datafile, $ini) || !is_array($ini)) {
         if (file_exists($filename)) {
             $ini = parse_ini_file($filename, true);
             tfilestorage::savevar($datafile, $ini);
         } else {
             $ini = array();
         }
     }
     if (!isset(self::$inifiles)) {
         self::$inifiles = array();
     }
     self::$inifiles[$filename] = $ini;
     return $ini;
 }
Ejemplo n.º 5
0
 public function parsehtml()
 {
     $html = getinstance('tadminhtml');
     $html->ini = array();
     foreach ($this->html as $filename) {
         $realfilename = $this->getrealfilename($filename);
         if (!file_exists($realfilename)) {
             $this->error(sprintf('The file "%s" not found', $realfilename));
         }
         if (!($parsed = parse_ini_file($realfilename, true))) {
             $this->error(sprintf('Error parse "%s" ini file', $realfilename));
         }
         if (count($html->ini) == 0) {
             $html->ini = $parsed;
         } else {
             foreach ($parsed as $section => $itemsini) {
                 $html->ini[$section] = isset($html->ini[$section]) ? $itemsini + $html->ini[$section] : $itemsini;
             }
         }
     }
     tfilestorage::savevar(tlocal::getcachedir() . 'adminhtml', $html->ini);
 }
Ejemplo n.º 6
0
 public function sendexceptions()
 {
     $filename = litepublisher::$paths->data . 'logs' . DIRECTORY_SEPARATOR . 'exceptionsmail.log';
     if (!file_exists($filename)) {
         return;
     }
     $time = @filectime($filename);
     if ($time === false || $time + 3600 > time()) {
         return;
     }
     $s = file_get_contents($filename);
     tfilestorage::delete($filename);
     tmailer::SendAttachmentToAdmin('[error] ' . litepublisher::$site->name, 'See attachment', 'errors.txt', $s);
     sleep(2);
 }
Ejemplo n.º 7
0
 public function save()
 {
     if ($this->lockcount) {
         return;
     }
     if ($this->dbversion) {
         $this->SaveToDB();
     } else {
         tfilestorage::save($this);
     }
 }
Ejemplo n.º 8
0
 public function loadfile($name)
 {
     $this->loaded[] = $name;
     $filename = self::getcachedir() . $name;
     if (tfilestorage::loadvar($filename, $v) && is_array($v)) {
         $this->ini = $v + $this->ini;
         if (isset($v['searchsect'])) {
             $this->joinsearch($v['searchsect']);
         }
     } else {
         $merger = tlocalmerger::i();
         $merger->parse($name);
     }
 }
Ejemplo n.º 9
0
 public function delete_tml($id_tml)
 {
     $this->db->update("id_tml = 1", "id_tml = {$id_tml}");
     $filename = $this->getfilename($id_tml);
     tfilestorage::delete($filename . '.php');
     tfilestorage::delete($filename . '.bak.php');
 }
Ejemplo n.º 10
0
 public function delete($name)
 {
     if (!isset($this->items[$name])) {
         return false;
     }
     $item = $this->items[$name];
     unset($this->items[$name]);
     $this->save();
     $datafile = false;
     if (class_exists($item['class'])) {
         $plugin = getinstance($item['class']);
         if ($plugin instanceof tplugin) {
             $datafile = litepublisher::$paths->data . $plugin->getbasename();
         }
     }
     litepublisher::$classes->lock();
     if (!empty($item['adminclass'])) {
         litepublisher::$classes->delete($item['adminclass']);
     }
     litepublisher::$classes->delete($item['class']);
     litepublisher::$classes->unlock();
     if ($datafile) {
         tfilestorage::delete($datafile . '.php');
         tfilestorage::delete($datafile . '.bak.php');
     }
     $this->deleted($name);
 }
Ejemplo n.º 11
0
 public function build($body, $buttons)
 {
     $args = new targs();
     $args->style = $this->style;
     $args->checkboxes = implode("\n", $this->checkboxes);
     $args->head = $this->head;
     $args->body = $body;
     $args->buttons = $buttons;
     $tml = tfilestorage::getfile(litepublisher::$paths->languages . 'tablecolumns.ini');
     $theme = ttheme::i();
     return $theme->parsearg($tml, $args);
 }
Ejemplo n.º 12
0
 public function getsame($id)
 {
     if (dbversion) {
         $items = $this->db->getvalue($id, 'items');
         if (is_string($items)) {
             return $items == '' ? array() : explode(',', $items);
         } else {
             $result = $this->findsame($id);
             $this->db->add(array('id' => $id, 'items' => implode(',', $result)));
             return $result;
         }
     } else {
         $filename = litepublisher::$paths->data . 'posts' . DIRECTORY_SEPARATOR . $id . DIRECTORY_SEPARATOR . 'same.php';
         $data = null;
         if (tfilestorage::loadvar($filename, $data)) {
             if ($data['revision'] == $this->revision) {
                 return $data['items'];
             }
         }
         $result = $this->findsame($id);
         $data = array('revision' => $this->revision, 'items' => $result);
         tfilestorage::savevar($filename, $data);
         return $result;
     }
 }
Ejemplo n.º 13
0
 } else {
     if ($memcache) {
         $filename = litepublisher::$paths->lib . 'kernel.php';
         if ($s = $memcache->get($filename)) {
             eval('?>' . $s);
         } else {
             $s = file_get_contents($filename);
             eval('?>' . $s);
             $memcache->set($filename, $s, false, 3600);
         }
     } else {
         require_once litepublisher::$paths->lib . 'kernel.php';
     }
 }
 define('dbversion', true);
 tfilestorage::$memcache = $memcache;
 if (!tstorage::loaddata()) {
     if (file_exists(litepublisher::$paths->data . 'storage.php') && filesize(litepublisher::$paths->data . 'storage.php')) {
         die('Storage not loaded');
     }
     //if (!litepublisher::$options->installed) require_once(litepublisher::$paths->lib .'install' . DIRECTORY_SEPARATOR . 'install.php');
     require_once litepublisher::$paths->lib . 'install' . DIRECTORY_SEPARATOR . 'install.php';
 }
 litepublisher::$classes = tclasses::i();
 litepublisher::$options = toptions::i();
 litepublisher::$db = tdatabase::i();
 litepublisher::$site = tsite::i();
 litepublisher::$urlmap = turlmap::i();
 if (!defined('litepublisher_mode')) {
     litepublisher::$urlmap->request(strtolower($_SERVER['HTTP_HOST']), $_SERVER['REQUEST_URI']);
 }
Ejemplo n.º 14
0
 public function setitem($id, $item)
 {
     if (isset($this->items[$id]) && $this->items[$id] == $item) {
         return;
     }
     $this->items[$id] = $item;
     if ($this->owner->dbversion) {
         $item['id'] = $id;
         $this->db->addupdate($item);
     } else {
         tfilestorage::savevar($this->getfilename($id), $item);
     }
 }
Ejemplo n.º 15
0
 public function getcontent()
 {
     $result = '';
     $polls = tpolls::i();
     $html = tadminhtml::i();
     $lang = tlocal::admin('polls');
     $args = new targs();
     $dir = litepublisher::$paths->data . 'polls';
     $adminurl = $this->adminurl;
     if ($action = $this->action) {
         $id = $this->idget();
         switch ($action) {
             case 'delete':
                 $man = tpollsman::i();
                 if ($id == $man->pollpost) {
                     return $html->h4->deletepullpost;
                 }
                 if ($this->confirmed) {
                     tfilestorage::delete($dir . DIRECTORY_SEPARATOR . "{$id}.php");
                     tfilestorage::delete($dir . DIRECTORY_SEPARATOR . "{$id}.bak.php");
                     unset($polls->tml_items[$id]);
                     $polls->db->update('id_tml = ' . $man->pollpost, "id_tml = {$id}");
                     $result .= $html->h4->deleted;
                 } else {
                     $result .= $html->confirmdelete($id, $adminurl, $lang->confirmdelete);
                 }
                 break;
             case 'edit':
                 if ($tml = $polls->get_tml($id)) {
                     $args->add($tml);
                     $args->id = $id;
                     $args->name = tcontentfilter::unescape($tml['name']);
                     $args->title = tcontentfilter::unescape($tml['title']);
                     //$args->items = implode("\n", $tml['items']);
                     $tabs = new tuitabs();
                     //$tabs->add($lang->pollitems, "[editor=items]");
                     $tabs->add($lang->opened, "[editor=opened]");
                     $tabs->add($lang->closed, "[editor=closed]");
                     $args->formtitle = $lang->edittemplate;
                     $result .= $html->adminform('
       [text=name]
       [text=title]' . $tabs->get(), $args);
                 }
                 break;
             case 'add':
                 $types = array_keys(tpolltypes::i()->items);
                 $args->type = tadminhtml::array2combo(array_combine($types, $types), $types[0]);
                 $args->name = '';
                 $args->title = '';
                 $args->newitems = '';
                 $args->formtitle = $lang->newtemplate;
                 $result .= $html->adminform('[text=name]
     [text=title]
     [combo=type]
     [editor=newitems]', $args);
                 break;
         }
     }
     $result .= $html->h3("<a href='{$adminurl}=0&amp;action=add'>{$lang->addtemplate}</a>");
     $result .= $html->h4->alltemplates;
     $args->adminurl = $adminurl;
     $table = '';
     $tr = '<tr>
 <td><a href="$adminurl=$id&amp;action=edit">$name</a></td>
 <td><a href="$adminurl=$id&amp;action=delete">$lang.delete</a></td>
 </tr>';
     $polls->loadall_tml();
     foreach ($polls->tml_items as $id => $tml) {
         $args->id = $id;
         $args->name = $tml['name'];
         $args->title = $tml['title'];
         $table .= $html->parsearg($tr, $args);
     }
     $head = "<tr>\n    <th>{$lang->edit}</th>\n    <th>{$lang->delete}</th>\n    </tr>";
     $result .= $html->gettable($head, $table);
     return $result;
 }
Ejemplo n.º 16
0
 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;
 }
Ejemplo n.º 17
0
 public function delete($id)
 {
     if (!$this->itemexists($id)) {
         return false;
     }
     if ($id == $this->idhome) {
         return false;
     }
     if ($this->haschilds($id)) {
         return false;
     }
     if ($this->items[$id]['idurl'] > 0) {
         litepublisher::$urlmap->delete($this->items[$id]['url']);
     }
     $this->lock();
     unset($this->items[$id]);
     $this->sort();
     $this->unlock();
     $this->deleted($id);
     tfilestorage::delete($this->dir . $id . '.php');
     tfilestorage::delete($this->dir . $id . '.bak.php');
     litepublisher::$urlmap->clearcache();
     return true;
 }