Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 public function add($name, $filename)
 {
     $icons = ticons::i();
     $parser = tmediaparser::i();
     $icons->items[$name] = $parser->uploadicon($filename, file_get_contents($this->dir . $filename), true);
     $icons->save();
 }
Ejemplo n.º 3
0
error_reporting(E_ALL | E_NOTICE | E_STRICT | E_WARNING);
ini_set('display_errors', 1);
define('litepublisher_mode', 'xmlrpc');
include 'index.php';
litepublisher::$debug = true;
set_time_limit(300);
$p = tmediaparser::i();
if ($p->maxwidth == 0 || $p->maxheight == 0) {
    die('0 max sizes');
}
$files = tfiles::i();
if ($items = $files->db->getitems("media = 'image' and parent = 0 and (width > {$p->maxwidth} or height > {$p->maxheight})")) {
    echo count($items), ' count<br>';
    foreach ($items as $item) {
        $srcfilename = litepublisher::$paths->files . $item['filename'];
        if ($source = tmediaparser::readimage($srcfilename)) {
            $sourcex = imagesx($source);
            $sourcey = imagesy($source);
            $x = $p->maxwidth;
            $y = $p->maxheight;
            $ratio = $sourcex / $sourcey;
            if ($x / $y > $ratio) {
                $x = $y * $ratio;
            } else {
                $y = $x / $ratio;
            }
            $dest = imagecreatetruecolor($x, $y);
            imagecopyresampled($dest, $source, 0, 0, 0, 0, $x, $y, $sourcex, $sourcey);
            imagejpeg($dest, $srcfilename, 95);
            imagedestroy($dest);
            @chmod($srcfilename, 0666);
Ejemplo n.º 4
0
 public function uploadlogo($name, $filename, $padding, $height)
 {
     if (!($source = tmediaparser::readimage($filename))) {
         return false;
     }
     $sourcex = imagesx($source);
     $sourcey = imagesy($source);
     if ($height == $sourcey) {
         if (!($result = tmediaparser::move_uploaded($name, $filename, 'themegen'))) {
             return false;
         }
         @chmod(litepublisher::$paths->files . str_replace('/', DIRECTORY_SEPARATOR, $result), 0666);
         return array('url' => litepublisher::$site->files . '/files/' . $result, 'width' => $sourcex + $padding);
     }
     $result = tmediaparser::prepare_filename($name, 'themegen');
     $realfilename = litepublisher::$paths->files . str_replace('/', DIRECTORY_SEPARATOR, $result);
     $x = ceil($sourcex * ($height / $sourcey));
     $dest = imagecreatetruecolor($x, $height);
     imagealphablending($dest, false);
     imagesavealpha($dest, true);
     $transparent = imagecolorallocatealpha($dest, 255, 255, 255, 127);
     imagefilledrectangle($dest, 0, 0, $x, $height, $transparent);
     imagecopyresampled($dest, $source, 0, 0, 0, 0, $x, $height, $sourcex, $sourcey);
     imagepng($dest, $realfilename);
     imagedestroy($dest);
     imagedestroy($source);
     @chmod($realfilename, 0666);
     return array('url' => litepublisher::$site->files . '/files/' . $result, 'width' => $x + $padding);
 }
Ejemplo n.º 5
0
 public function files_upload(array $args)
 {
     if ('POST' != $_SERVER['REQUEST_METHOD']) {
         return $this->forbidden();
     }
     if (!isset($_FILES['Filedata']) || !is_uploaded_file($_FILES['Filedata']['tmp_name']) || $_FILES['Filedata']['error'] != 0) {
         return $this->forbidden();
     }
     //psevdo logout
     litepublisher::$options->user = null;
     if (!litepublisher::$options->hasgroup('author')) {
         return $this->forbidden();
     }
     if (in_array(litepublisher::$options->groupnames['author'], litepublisher::$options->idgroups) && ($r = tauthor_rights::i()->canupload())) {
         return $r;
     }
     $parser = tmediaparser::i();
     $id = $parser->uploadfile($_FILES['Filedata']['name'], $_FILES['Filedata']['tmp_name'], '', '', '', false);
     if (isset($_POST['idperm'])) {
         $idperm = (int) $_POST['idperm'];
         if ($idperm > 0) {
             tprivatefiles::i()->setperm($id, (int) $_POST['idperm']);
         }
     }
     $this->uploaded($id);
     $files = tfiles::i();
     $item = $files->db->getitem($id);
     $files->items[$id] = $item;
     $result = array('id' => $id, 'item' => $item);
     if ($item['preview'] > 0) {
         $result['preview'] = $files->db->getitem($item['preview']);
     }
     return $result;
 }
Ejemplo n.º 6
0
 public function processform()
 {
     $files = tfiles::i();
     $html = $this->html;
     if (empty($_GET['action'])) {
         $isauthor = 'author' == litepublisher::$options->group;
         if ($_POST['uploadmode'] == 'file') {
             if (isset($_FILES['filename']['error']) && $_FILES['filename']['error'] > 0) {
                 return $html->h4(tlocal::get('uploaderrors', $_FILES['filename']['error']));
             }
             if (!is_uploaded_file($_FILES['filename']['tmp_name'])) {
                 return sprintf($this->html->h4red->attack, $_FILES["filename"]["name"]);
             }
             if ($isauthor && ($r = tauthor_rights::i()->canupload())) {
                 return $r;
             }
             $overwrite = isset($_POST['overwrite']);
             $parser = tmediaparser::i();
             $id = $parser->uploadfile($_FILES['filename']['name'], $_FILES['filename']['tmp_name'], $_POST['title'], $_POST['description'], $_POST['keywords'], $overwrite);
         } else {
             //downloadurl
             $content = http::get($_POST['downloadurl']);
             if ($content == false) {
                 return $this->html->h2->errordownloadurl;
             }
             $filename = basename(trim($_POST['downloadurl'], '/'));
             if ($filename == '') {
                 $filename = 'noname.txt';
             }
             if ($isauthor && ($r = tauthor_rights::i()->canupload())) {
                 return $r;
             }
             $overwrite = isset($_POST['overwrite']);
             $parser = tmediaparser::i();
             $id = $parser->upload($filename, $content, $_POST['title'], $_POST['description'], $_POST['keywords'], $overwrite);
         }
         if (isset($_POST['idperm'])) {
             tprivatefiles::i()->setperm($id, (int) $_POST['idperm']);
         }
         return $this->html->h4->success;
     } elseif ($_GET['action'] == 'edit') {
         $id = $this->idget();
         if (!$files->itemexists($id)) {
             return $this->notfound;
         }
         $files->edit($id, $_POST['title'], $_POST['description'], $_POST['keywords']);
         if (isset($_POST['idperm'])) {
             tprivatefiles::i()->setperm($id, (int) $_POST['idperm']);
         }
         return $this->html->h4->edited;
     }
     return '';
 }
Ejemplo n.º 7
0
 public function uninstall()
 {
     $parser = tmediaparser::i();
     $parser->unbind($this);
 }
Ejemplo n.º 8
0
 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 '';
 }
 public function processform()
 {
     if (!($id = $this->getidfile())) {
         return $this->notfound;
     }
     $files = tfiles::i();
     $item = $files->getitem($id);
     if (isset($_POST['delete'])) {
         $files->delete($item['preview']);
         $files->setvalue($id, 'preview', 0);
         return $this->html->h4->deleted;
     }
     $isauthor = 'author' == litepublisher::$options->group;
     if (isset($_FILES['filename']['error']) && $_FILES['filename']['error'] > 0) {
         $error = tlocal::get('uploaderrors', $_FILES["filename"]["error"]);
         return "<h3>{$error}</h3>\n";
     }
     if (!is_uploaded_file($_FILES['filename']['tmp_name'])) {
         return sprintf($this->html->h4red->attack, $_FILES["filename"]["name"]);
     }
     if ($isauthor && ($r = tauthor_rights::i()->canupload())) {
         return $r;
     }
     $filename = $_FILES['filename']['name'];
     $tempfilename = $_FILES['filename']['tmp_name'];
     $parser = tmediaparser::i();
     $filename = tmediaparser::linkgen($filename);
     $parts = pathinfo($filename);
     $newtemp = $parser->gettempname($parts);
     if (!move_uploaded_file($tempfilename, litepublisher::$paths->files . $newtemp)) {
         return sprintf($this->html->h4->attack, $_FILES["filename"]["name"]);
     }
     $resize = !isset($_POST['noresize']);
     $idpreview = $parser->add(array('filename' => $filename, 'tempfilename' => $newtemp, 'enabledpreview' => $resize, 'ispreview' => $resize));
     if ($idpreview) {
         if ($item['preview'] > 0) {
             $files->delete($item['preview']);
         }
         $files->setvalue($id, 'preview', $idpreview);
         $files->setvalue($idpreview, 'parent', $id);
         if ($item['idperm'] > 0) {
             $files->setvalue($idpreview, 'idperm', $item['idperm']);
             tprivatefiles::i()->setperm($idpreview, (int) $item['idperm']);
         }
         return $this->html->h4->success;
     }
 }