Exemplo n.º 1
0
 public static function init()
 {
     if (defined('litepublisher_mode') && litepublisher_mode == 'debug') {
         litepublisher::$debug = true;
     }
     if (!preg_match('/(www\\.)?([\\w\\.\\-]+)(:\\d*)?/', strtolower(trim($_SERVER['HTTP_HOST'])), $domain)) {
         die('cant resolve domain name');
     }
     self::$domain = $domain[2];
     $home = dirname(__FILE__) . DIRECTORY_SEPARATOR;
     $storage = $home . 'storage' . DIRECTORY_SEPARATOR;
     $paths = new tpaths();
     self::$paths = $paths;
     $paths->home = $home;
     $paths->lib = $home . 'lib' . DIRECTORY_SEPARATOR;
     $paths->data = $storage . 'data' . DIRECTORY_SEPARATOR;
     $paths->cache = $storage . 'cache' . DIRECTORY_SEPARATOR;
     $paths->libinclude = $home . 'lib' . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR;
     $paths->languages = $home . 'lib' . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR;
     $paths->storage = $storage;
     $paths->backup = $storage . 'backup' . DIRECTORY_SEPARATOR;
     $paths->plugins = $home . 'plugins' . DIRECTORY_SEPARATOR;
     $paths->themes = $home . 'themes' . DIRECTORY_SEPARATOR;
     $paths->files = $home . 'files' . DIRECTORY_SEPARATOR;
     $paths->js = $home . 'js' . DIRECTORY_SEPARATOR;
     self::$microtime = microtime(true);
 }
Exemplo n.º 2
0
<?php

Header('Cache-Control: no-cache, must-revalidate');
Header('Pragma: no-cache');
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);