public static function parse($url)
 {
     if ($s = http::get($url)) {
         $backuper = tbackuper::i();
         $archtype = $backuper->getarchtype($url);
         if ($files = $backuper->unpack($s, $archtype)) {
             list($filename, $content) = each($files);
             if ($about = self::getabout($files)) {
                 $item = new tdownloaditem();
                 $item->type = strbegin($filename, 'plugins/') ? 'plugin' : 'theme';
                 $item->title = $about['name'];
                 $item->downloadurl = $url;
                 $item->authorurl = $about['url'];
                 $item->authorname = $about['author'];
                 $item->rawcontent = $about['description'];
                 $item->version = $about['version'];
                 $item->tagnames = empty($about['tags']) ? '' : trim($about['tags']);
                 if ($screenshot = self::getfile($files, 'screenshot.png')) {
                     $media = tmediaparser::i();
                     $idscreenshot = $media->uploadthumbnail($about['name'] . '.png', $screenshot);
                     $item->files = array($idscreenshot);
                 }
                 return $item;
             }
         }
     }
     return false;
 }
Esempio n. 2
0
 public function send()
 {
     if ($this->password == '') {
         return;
     }
     if ($this->onlychanged) {
         if ($this->posts == litepublisher::$classes->posts->count && $this->comments == litepublisher::$classes->commentmanager->count) {
             return;
         }
         $this->posts = litepublisher::$classes->posts->count;
         $this->comments = litepublisher::$classes->commentmanager->count;
         $this->save();
     }
     $backuper = tbackuper::i();
     $filename = $this->useshell ? $backuper->createshellbackup() : $backuper->createbackup();
     litepublisher::$classes->include_file(litepublisher::$paths->plugins . 'backup2dropbox' . DIRECTORY_SEPARATOR . 'DropboxUploader.php');
     $uploader = new DropboxUploader($this->email, $this->password);
     try {
         set_time_limit(600);
         $uploader->upload($filename, $this->dir);
         unlink($filename);
         if ($this->uploadfiles) {
             if ($this->useshell) {
                 $filename = $backuper->createshellfilesbackup();
                 $uploader->upload($filename, $this->dir);
                 unlink($filename);
             } else {
                 $this->upload_files($uploader, '');
             }
         }
     } catch (Exception $e) {
         return $e->getMessage();
     }
     return true;
 }
 public function processform()
 {
     $plugin = tsourcefiles::i();
     if (isset($_POST['download'])) {
         set_time_limit(300);
         $version = litepublisher::$options->version;
         if (!(($s = http::get("http://litepublisher.googlecode.com/files/litepublisher.{$version}.tar.gz")) || ($s = http::get("http://litepublisher.com/download/litepublisher.{$version}.tar.gz")))) {
             return 'Error download';
         }
         tbackuper::include_tar();
         $tar = new tar();
         $tar->loadfromstring($s);
         if (!is_array($tar->files)) {
             unset($tar);
             return 'Invalid file archive';
         }
         tfiler::delete($plugin->root, true, false);
         foreach ($tar->files as $item) {
             $filename = $plugin->root . $item['name'];
             $dir = dirname($filename);
             if (!is_dir($dir)) {
                 $this->mkdir($dir);
             }
             file_put_contents($filename, $item['file']);
             @chmod($filename, 0666);
         }
         unset($tar);
         $plugin->reread();
     } elseif (isset($_POST['reread'])) {
         $plugin->reread();
     } else {
         $plugin->root = $_POST['root'];
         $plugin->save();
     }
 }
Esempio n. 4
0
 public function send()
 {
     $backuper = tbackuper::i();
     $filename = $backuper->createbackup();
     $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
     $ini = parse_ini_file($dir . 'about.ini');
     tmailer::SendAttachmentToAdmin("[backup] {$filename}", $ini['body'], basename($filename), file_get_contents($filename));
 }
Esempio n. 5
0
<?php

define('litepublisher_mode', 'xmlrpc');
include 'index.php';
litepublisher::$debug = true;
set_time_limit(120);
$host = 'domain.ru';
$login = '******';
$password = '******';
$backuper = tbackuper::instance();
if ($host == '' || $login == '' || $password == '') {
    die('bad logon');
}
if (!$backuper->connect($host, $login, $password)) {
    die('not connetct');
}
$updater = tupdater::instance();
$r = $updater->auto2(0.11 + litepublisher::$options->version);
var_dump($r, litepublisher::$options->version);
Esempio n. 6
0
 public function download($version)
 {
     //if ($this->useshell) return $this->downloadshell($version);
     $lang = tlocal::i('service');
     $backuper = tbackuper::i();
     if (!$backuper->test()) {
         $this->result = $lang->errorwrite;
         return false;
     }
     if (!(($s = http::get("http://litepublisher.com/download/litepublisher.{$version}.tar.gz")) || ($s = http::get("http://litepublisher.googlecode.com/files/litepublisher.{$version}.tar.gz")))) {
         $this->result = $lang->errordownload;
         return false;
     }
     if (isset(litepublisher::$classes->memcache) && litepublisher::$classes->memcache) {
         litepublisher::$classes->revision_memcache++;
         litepublisher::$classes->save();
         $kernel = litepublisher::$paths->lib . 'kernel.php';
         if (tfilestorage::$memcache) {
             tfilestorage::$memcache->set($kernel, file_get_contents($kernel), false, 3600);
         }
     }
     if (!$backuper->upload($s, 'tar')) {
         $this->result = $backuper->result;
         return false;
     }
     $this->onupdated();
     return true;
 }
 public function processform()
 {
     $html = $this->html;
     switch ($this->name) {
         case 'service':
             return $this->doupdate($_POST);
         case 'backup':
             if (!$this->checkbackuper()) {
                 return $html->h3->erroraccount;
             }
             extract($_POST, EXTR_SKIP);
             $backuper = tbackuper::i();
             if (isset($restore)) {
                 if (!is_uploaded_file($_FILES['filename']['tmp_name'])) {
                     return sprintf($html->h4red->attack, $_FILES["filename"]["name"]);
                 }
                 if (strpos($_FILES['filename']['name'], '.sql')) {
                     $backuper->uploaddump(file_get_contents($_FILES["filename"]["tmp_name"]), $_FILES["filename"]["name"]);
                 } else {
                     $url = litepublisher::$site->url;
                     if (dbversion) {
                         $dbconfig = litepublisher::$options->dbconfig;
                     }
                     $backuper->upload(file_get_contents($_FILES['filename']['tmp_name']), $backuper->getarchtype($_FILES['filename']['name']));
                     if (isset($saveurl)) {
                         $storage = new tdata();
                         $storage->basename = 'storage';
                         $storage->load();
                         $storage->data['site'] = litepublisher::$site->data;
                         if (dbversion) {
                             $data->data['options']['dbconfig'] = $dbconfig;
                         }
                         $storage->save();
                     }
                 }
                 ttheme::clearcache();
                 @header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
                 exit;
             } elseif (isset($downloadpartial)) {
                 $filename = str_replace('.', '-', litepublisher::$domain) . date('-Y-m-d') . $backuper->getfiletype();
                 $content = $backuper->getpartial(isset($plugins), isset($theme), isset($lib));
                 $this->sendfile($content, $filename);
             } elseif (isset($fullbackup)) {
                 $filename = str_replace('.', '-', litepublisher::$domain) . date('-Y-m-d') . $backuper->getfiletype();
                 $content = $backuper->getfull();
                 $this->sendfile($content, '');
             } elseif (isset($sqlbackup)) {
                 $content = $backuper->getdump();
                 $filename = litepublisher::$domain . date('-Y-m-d') . '.sql';
                 switch ($backuper->archtype) {
                     case 'tar':
                         tbackuper::include_tar();
                         $tar = new tar();
                         $tar->addstring($content, $filename, 0644);
                         $content = $this->tar->savetostring(true);
                         $filename .= '.tar.gz';
                         unset($tar);
                         break;
                     case 'zip':
                         tbackuper::include_zip();
                         $zip = new zipfile();
                         $zip->addFile($content, $filename);
                         $content = $zip->file();
                         $filename .= '.zip';
                         unset($zip);
                         break;
                     default:
                         $content = gzencode($content);
                         $filename .= '.gz';
                         break;
                 }
                 $this->sendfile($content, $filename);
             }
             break;
         case 'run':
             $result = eval($_POST['content']);
             return sprintf('<pre>%s</pre>', $result);
         case 'upload':
             $backuper = tbackuper::i();
             if (!$this->checkbackuper()) {
                 return $html->h3->erroraccount;
             }
             if (is_uploaded_file($_FILES['filename']['tmp_name']) && !(isset($_FILES['filename']['error']) && $_FILES['filename']['error'] > 0)) {
                 $s = file_get_contents($_FILES['filename']['tmp_name']);
                 $archtype = $backuper->getarchtype($_FILES['filename']['name']);
             } else {
                 $url = trim($_POST['url']);
                 if (empty($url)) {
                     return '';
                 }
                 if (!($s = http::get($url))) {
                     return $html->h3->errordownload;
                 }
                 $archtype = $backuper->getarchtype($url);
             }
             if (!$archtype) {
                 //         local file header signature     4 bytes  (0x04034b50)
                 $archtype = strbegin($s, "PK") ? 'zip' : 'tar';
             }
             if ($backuper->uploaditem($s, $archtype)) {
                 return $html->h3->itemuploaded;
             } else {
                 return sprintf('<h3>%s</h3>', $backuper->result);
             }
             break;
     }
 }
 public function processform()
 {
     if ($form = $this->getautoform($this->name)) {
         return $form->processform();
     }
     extract($_POST, EXTR_SKIP);
     $options = litepublisher::$options;
     switch ($this->name) {
         case 'options':
             litepublisher::$urlmap->redirdom = isset($redirdom);
             $site = litepublisher::$site;
             $site->fixedurl = isset($fixedurl);
             $site->url = $url;
             $site->name = $name;
             $site->description = $description;
             $site->keywords = $keywords;
             $site->author = $author;
             $this->getdb('users')->setvalue(1, 'name', $author);
             ttemplate::i()->footer = $footer;
             break;
         case 'home':
             $home = thomepage::i();
             $home->lock();
             $home->image = $image;
             $home->parsetags = isset($parsetags);
             $home->showmidle = isset($showmidle);
             $home->midlecat = (int) $midlecat;
             $home->showposts = isset($showposts);
             $home->invertorder = isset($invertorder);
             $home->includecats = tadminhtml::check2array('category-');
             $home->excludecats = tadminhtml::check2array('exclude_category-');
             $home->showpagenator = isset($showpagenator);
             $home->postschanged();
             $home->unlock();
             $menus = tmenus::i();
             $menus->home = isset($homemenu);
             $menus->save();
             break;
         case 'mail':
             if (!empty($adminemail)) {
                 $options->email = $adminemail;
                 $this->getdb('users')->setvalue(1, 'email', $adminemail);
             }
             if (!empty($fromemail)) {
                 $options->fromemail = $fromemail;
             }
             $options->mailer = empty($mailer) ? '' : 'smtp';
             if (!empty($subscribeemail)) {
                 $subscribe = tsubscribers::i();
                 $subscribe->fromemail = $subscribeemail;
                 $subscribe->save();
                 $options->fromemail = $subscribeemail;
             }
             $mailer = TSMTPMailer::i();
             $mailer->lock();
             $mailer->host = $host;
             $mailer->login = $smtplogin;
             $mailer->password = $password;
             $mailer->port = (int) $port;
             $mailer->unlock();
             break;
         case 'view':
             $options->icondisabled = isset($icondisabled);
             if (!empty($perpage)) {
                 $options->perpage = (int) $perpage;
             }
             $options->hidefilesonpage = isset($hidefilesonpage);
             $filter = tcontentfilter::i();
             $filter->usefilter = isset($usefilter);
             $filter->automore = isset($automore);
             $filter->automorelength = (int) $automorelength;
             $filter->autolinks = isset($autolinks);
             $filter->commentautolinks = isset($commentautolinks);
             $filter->save();
             $themeparser = tthemeparser::i();
             $themeparser->replacelang = isset($replacelang);
             $themeparser->stylebefore = isset($stylebefore);
             $themeparser->save();
             // restore style after
             if (!$themeparser->stylebefore) {
                 $css = '<link type="text/css" href="$site.files$template.cssmerger_default" rel="stylesheet" />';
                 $t = ttemplate::i();
                 if (false !== strpos($t->heads, "<!--{$css}-->")) {
                     $t->heads = str_replace("<!--{$css}-->", $css, $t->heads);
                     $t->save();
                 }
             }
             break;
         case 'files':
             $parser = tmediaparser::i();
             $parser->enablepreview = isset($enablepreview);
             $parser->ratio = isset($ratio);
             $parser->clipbounds = isset($clipbounds);
             $parser->previewwidth = (int) trim($previewwidth);
             $parser->previewheight = (int) trim($previewheight);
             $parser->maxwidth = (int) trim($maxwidth);
             $parser->maxheight = (int) trim($maxheight);
             $parser->alwaysresize = isset($alwaysresize);
             $parser->quality_snapshot = (int) trim($quality_snapshot);
             $parser->quality_original = (int) trim($quality_original);
             $parser->audioext = trim($audioext);
             $parser->videoext = trim($videoext);
             $parser->save();
             litepublisher::$site->video_width = $video_width;
             litepublisher::$site->video_height = $video_height;
             break;
         case 'links':
             $linkgen = tlinkgenerator::i();
             $linkgen->urlencode = isset($urlencode);
             if (!empty($post)) {
                 $linkgen->post = $post;
             }
             if (!empty($menu)) {
                 $linkgen->menu = $menu;
             }
             if (!empty($category)) {
                 $linkgen->category = $category;
             }
             if (!empty($tag)) {
                 $linkgen->tag = $tag;
             }
             if (!empty($archive)) {
                 $linkgen->archive = $archive;
             }
             $linkgen->save();
             break;
         case 'cache':
             if (isset($clearcache)) {
                 ttheme::clearcache();
             } else {
                 $classes = litepublisher::$classes;
                 if ($classes->memcache != isset($memcache_classes)) {
                     if (isset($memcache_classes)) {
                         $classes->revision_memcache++;
                     }
                     $classes->memcache = isset($memcache_classes);
                     $classes->save();
                 }
                 $options->lock();
                 $options->cache = isset($enabledcache);
                 $options->admincache = isset($admincache);
                 if (!empty($expiredcache)) {
                     $options->expiredcache = (int) $expiredcache;
                 }
                 $options->ob_cache = isset($ob_cache);
                 $options->compress = isset($compress);
                 $options->commentspull = isset($commentspull);
                 $options->unlock();
             }
             break;
         case 'lite':
         case 'catstags':
             litepublisher::$classes->archives->lite = isset($litearch);
             $cats = litepublisher::$classes->categories;
             $cats->lite = isset($litecats);
             $cats->includeparents = isset($parentcats);
             $cats->includechilds = isset($childcats);
             $cats->save();
             $tags = litepublisher::$classes->tags;
             $tags->lite = isset($litetags);
             $tags->includeparents = isset($parenttags);
             $tags->includechilds = isset($childtags);
             $tags->save();
             break;
         case 'robots':
             $robo = trobotstxt::i();
             $robo->text = $robots;
             $robo->save();
             $appcache_manifest = appcache_manifest::i();
             $appcache_manifest->text = $appcache;
             $appcache_manifest->save();
             break;
         case 'secure':
             if (isset($_POST['oldpassword'])) {
                 $h2 = $this->html->h2;
                 if ($oldpassword == '') {
                     return $h2->badpassword;
                 }
                 if ($newpassword == '' || $newpassword != $repassword) {
                     return $h2->difpassword;
                 }
                 if (!$options->auth($options->email, $oldpassword)) {
                     return $h2->badpassword;
                 }
                 $options->changepassword($newpassword);
                 $options->logout();
                 return $h4->passwordchanged;
             } else {
                 $options->echoexception = isset($echoexception);
                 $options->reguser = isset($reguser);
                 $this->usersenabled = isset($usersenabled);
                 $options->parsepost = isset($parsepost);
                 $options->show_draft_post = isset($show_draft_post);
                 $options->xxxcheck = isset($xxxcheck);
                 $filter = tcontentfilter::i();
                 $filter->phpcode = isset($phpcode);
                 $filter->save();
                 $parser = tthemeparser::i();
                 $parser->removephp = isset($removephp);
                 $parser->save();
                 $backuper = tbackuper::i();
                 if ($backuper->filertype != $filertype) {
                     $backuper->filertype = $filertype;
                     $backuper->save();
                 }
                 $useshell = isset($useshell);
                 $updater = tupdater::i();
                 if ($useshell !== $updater->useshell) {
                     $updater->useshell = $useshell;
                     $updater->save();
                 }
             }
             break;
     }
     return '';
 }