Exemple #1
0
 static function render()
 {
     $Page = self::PageFromRequest();
     if (!$Page->is()) {
         // search for redirect
         $sql = "SELECT * FROM page_redirect WHERE request = " . D()->quote(appRequestUri) . " ";
         if ($vs = D()->row($sql)) {
             if (is_numeric($vs['redirect'])) {
                 $url = $_SERVER['SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . Page($vs['redirect'])->url();
             } else {
                 $url = $vs['redirect'];
             }
             header('HTTP/1.1 301');
             // better 302 (temporary)?
             header('Location: ' . $url);
             abort();
         }
         // not found
         header("HTTP/1.1 404 Not Found");
         $Page = Page(G()->SET['cms']['pageNotFound']->v);
     }
     self::$MainPage = self::$RequestedPage = $Page;
     if (!self::$MainPage->access()) {
         // no access
         header("HTTP/1.1 401 Unauthorized");
         self::$MainPage = Page(G()->SET['cms']['pageNoAccess']->v);
     }
     globalTemplate(appPATH . 'qg/html-template.php');
     html::$content .= Page()->get();
     if (self::$MainPage->access() > 1) {
         html::addBodyFile(sysPATH . 'cms/view/frontend.php');
     }
     D()->log->Entry(liveLog::$id)->page_id = Page();
     qg::fire('cms-ready');
 }
Exemple #2
0
 function getHtml($Recipient = null, $ZendMail = null)
 {
     $html = $this->html;
     $data = $Recipient ? unserialize($Recipient->data) : array();
     qg::fire('mail::gethtml', array('Mail' => $this, 'Recipient' => $Recipient, 'html' => &$html, 'data' => &$data, 'ZendMail' => $ZendMail));
     if ($data) {
         $T = new template($data);
         $html = $T->renderMarker($html);
     }
     if ($ZendMail) {
         // deprecated
         preg_match_all("#<img.*?src=['\"]file://([^'\"]+)#i", $html, $matches);
         $matches = array_unique($matches[1]);
         if ($matches) {
             $ZendMail->setType(Zend_Mime::MULTIPART_RELATED);
             foreach ($matches as $key => $filename) {
                 if (!is_readable($filename) || !image::able($filename)) {
                     continue;
                 }
                 $at = $ZendMail->createAttachment(file_get_contents($filename));
                 $at->type = extensionToMime(preg_replace('/.*\\.([^.]+$)/', '$1', $filename));
                 $at->disposition = Zend_Mime::DISPOSITION_INLINE;
                 $at->id = 'i' . md5_file($filename);
                 $html = str_replace('file://' . $filename, 'cid:' . $at->id, $html);
                 trigger_error('error: auto inline images are deprecated!');
             }
         }
     }
     return $html;
 }
 static function uninstall($id)
 {
     $name = D()->module->Entry($id)->name;
     if ($name) {
         rrmdir(sysPATH . $name);
         D()->query("DELETE FROM module WHERE id = '" . (int) $id . "' ");
         qg::setInstalled($name, false);
         return 1;
     }
 }
 function getHtml($Recipient = null, $ZendMail = null)
 {
     $html = $this->html;
     $data = $Recipient ? unserialize($Recipient->data) : array();
     qg::fire('mail::gethtml', array('Mail' => $this, 'Recipient' => $Recipient, 'html' => &$html, 'data' => &$data, 'ZendMail' => $ZendMail));
     if ($data) {
         $T = new template($data);
         $html = $T->renderMarker($html);
     }
     return $html;
 }
Exemple #5
0
 static function login($id)
 {
     $id = (int) (string) $id;
     if (!D()->one("SELECT id FROM usr WHERE id = " . $id)) {
         return false;
     }
     $old_session = $_SESSION;
     self::logout();
     $_SESSION['liveUser'] = $id;
     Client()->addUsr($id);
     Client()->usr_id = $id;
     qg::fire('login', array('session_old' => $old_session));
     return true;
 }
 static function render()
 {
     $Page = self::PageFromRequest();
     if (!$Page->is()) {
         // search for redirect
         if ($redirect = D()->one("SELECT redirect FROM page_redirect WHERE request = " . D()->quote(appRequestUri))) {
             if (is_numeric($redirect)) {
                 $url = $_SERVER['SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . Page($redirect)->url();
             } else {
                 $url = $redirect;
             }
             header('HTTP/1.1 301');
             // better 302 (temporary) ?
             header('Location: ' . $url);
             exit;
         }
         // not found
         header("HTTP/1.1 404 Not Found");
         $Page = Page(G()->SET['cms']['pageNotFound']->v);
     }
     self::$MainPage = self::$RequestedPage = $Page;
     if (!self::$MainPage->access()) {
         // no access
         header("HTTP/1.1 401 Unauthorized");
         self::$MainPage = Page(G()->SET['cms']['pageNoAccess']->v);
     }
     if (!self::$MainPage->isReadable()) {
         // offline
         header("HTTP/1.1 401 Unauthorized");
         self::$MainPage = Page(G()->SET['cms']['pageOffline']->v);
     }
     qg::fire('deliverHtml');
     // deprecated
     //qg::fire('cms::render-before'); // todo
     html::$content .= self::$MainPage->get();
     self::$MainPage->access() > 1 && html::addBodyFile(sysPATH . 'cms/view/frontend.php');
     qg::fire('cms-ready');
     // deprecated
     $tpl = new template();
     echo $tpl->get(appPATH . 'qg/html-template.php');
     //qg::fire('cms::render-after'); // todo
 }
 function delete($id)
 {
     $id = $this->entryId($id);
     $values = $this->entryId2Array($id);
     qg::fire('dbTable::delete-before', array('Table' => $this, 'data' => &$values, 'id' => &$id, 'prevent' => &$prevent));
     if ($prevent === true) {
         return false;
     }
     $Statement = $this->Db->query("DELETE FROM " . $this . " WHERE " . $this->entryId2where($id));
     if (!$Statement->rowCount()) {
         return;
     }
     qg::fire('dbTable::delete-after', array('Table' => $this, 'data' => &$values, 'id' => $id));
     // todo, test, not very good implementation
     foreach ($this->Childs() as $Field) {
         switch ($Field->vs['on_parent_delete']) {
             case 'cascade':
                 foreach ($this->Db->query("SELECT * FROM " . $Field->Table . " WHERE " . $Field . " = " . $this->Db->quote($id)) as $row) {
                     $Field->Table->delete($row);
                 }
                 break;
             case 'setnull':
                 //$F->updateIf($E, null);	// todo
                 break;
         }
     }
     return true;
 }
Exemple #8
0
<?php

qg::on('deliverHtml', function () {
    if (G()->SET['m']['js.webshims']['enable']->setType('bool')->v) {
        $url = sysURL . 'js.webshims/js-webshim/minified/';
        html::addJsFile($url . 'polyfiller.js', 'core');
        html::$js .= "\$.webshims.cfg.basePath = '" . $url . "shims/';";
        html::$js .= "\$.webshims.polyfill('forms forms-ext');";
    }
});
Exemple #9
0
<?php

qg::on('action', function () {
    if (strpos(appRequestUri, 'editor/') === 0 && isset($_GET['file'])) {
        /* wird bereits geprüft zzz
        			if (!isset($_GET['file'])) {
                      echo 'no file'; exit();
                    }
                    */
        $file = urldecode($_GET['file']);
        if (!isset($_SESSION['fileEditor']['allow'][$file]) && !Usr()->superuser) {
            echo 'no access';
            exit;
        }
        !is_dir(dirname($file)) && mkdir(dirname($file));
        !is_file($file) && touch($file);
        if ($ask = G()->ASK) {
            $done = 0;
            if (isset($ask['save']) && is_file($file)) {
                copy($file, appPATH . 'cache/tmp/pri/fileEditorBackup_' . urlencode($file) . '_' . date('dmYhi'));
                if (file_put_contents($file, $ask['save']) && is_writable($file)) {
                    $done = 1;
                }
            }
            Answer($done);
        }
        globalTemplate(sysPATH . 'fileEditor/view/html-template.php');
        include sysPATH . 'fileEditor/view/codemirror.php';
        exit;
    }
});
Exemple #10
0
<?php

namespace qg;

qg::need('Zend');
copy(sysPATH . 'core/util/app.htaccess', appPATH . '.htaccess');
is_dir(appPATH . 'cache') || mkdir(appPATH . 'cache');
is_dir(appPATH . 'cache/pri') || mkdir(appPATH . 'cache/pri');
file_put_contents(appPATH . 'cache/pri/.htaccess', 'deny from all');
is_dir(appPATH . 'cache/tmp') || mkdir(appPATH . 'cache/tmp');
is_dir(appPATH . 'cache/tmp/pri') || mkdir(appPATH . 'cache/tmp/pri');
file_put_contents(appPATH . 'cache/tmp/pri/.htaccess', 'deny from all');
is_dir(appPATH . 'qg') || mkdir(appPATH . 'qg');
is_dir(appPATH . 'qg/file') || mkdir(appPATH . 'qg/file');
file_put_contents(appPATH . 'qg/.htaccess', 'deny from all');
if (isset(G()->SET)) {
    G()->SET['qg']->make('dbFile_dpr_dependent', 1)->setType('bool');
}
Exemple #11
0
 function getRaw($vars = array())
 {
     if (!$this->is) {
         trigger_error('Seite existiert nicht!');
         return;
     }
     $modPath = sysPATH . $this->vs['module'] . '/';
     // dont use the getter;
     $Cont = $this;
     $res = is_file($modPath . 'control.php') ? include $modPath . 'control.php' : null;
     if (is_file($modPath . 'index.php')) {
         $T = new template($res);
         $T->assign('vars', $vars);
         $T->assign('Cont', $this);
         $str = $T->get($modPath . 'index.php');
         qg::fire('cms::parseTemplate', array('Cont' => $Cont, 'string' => &$str));
     } else {
         $str = '<div>' . ($this->edit ? L('Das Modul ist nicht existiert nicht!') : '') . '</div>';
     }
     is_file($modPath . 'pub/main.js') && html::addJsFile($this->modUrl . 'pub/main.js');
     is_file($modPath . 'pub/main.css') && html::addCSSFile($this->modUrl . 'pub/main.css');
     return $str;
 }
 static function syncRemote()
 {
     D()->query("UPDATE module SET server_time = 0");
     foreach (qg::remoteAll() as $vs) {
         $row = D()->row("SELECT * FROM module WHERE name = " . D()->quote($vs['name']));
         if (!$row) {
             $row = D()->module->insert(array('name' => $vs['name']));
         }
         $E = D()->module->Entry($row);
         $E->server_version = $vs['version'];
         $E->server_time = $vs['time'];
         $E->server_size = $vs['size'];
     }
 }
Exemple #13
0
<?php

namespace qg;

qg::on('action', function () {
    if (!isset($_GET['file']) || strpos(appRequestUri, 'editor') !== 0) {
        return;
    }
    $file = urldecode($_GET['file']);
    if (!isset($_SESSION['fileEditor']['allow'][$file]) && !Usr()->superuser) {
        echo 'no access';
        exit;
    }
    !is_dir(dirname($file)) && mkdir(dirname($file));
    !is_file($file) && touch($file);
    if ($ask = G()->ASK) {
        $done = 0;
        if (isset($ask['save']) && is_file($file)) {
            copy($file, appPATH . 'cache/tmp/pri/fileEditorBackup_' . urlencode($file) . '_' . date('dmYhi'));
            if (file_put_contents($file, $ask['save']) && is_writable($file)) {
                $done = 1;
            }
        }
        Answer($done);
    }
    /* neu */
    $T = new template(array('file' => $file));
    echo $T->get(sysPATH . 'fileEditor/view/codemirror.php');
    exit;
});
Exemple #14
0
    extract($e, EXTR_REFS);
    // Table, id, data
    if ($Table->Db->{'_vers_' . $Table->_name}) {
        D()->query(" REPLACE INTO _vers_" . $Table->_name . " " . " SELECT *, " . liveLog::$id . " AS _vers_log, " . vers::$space . " AS _vers_space, 0 AS _vers_deleted " . " FROM " . $Table->_name . " WHERE " . $Table->entryId2where($id));
    }
});
qg::on('dbTable::delete-after', function ($e) {
    extract($e, EXTR_REFS);
    // Table, id, data
    if ($Table->Db->{'_vers_' . $Table->_name}) {
        D()->query(" REPLACE INTO _vers_" . $Table->_name . " " . " SET " . $Table->valuesToSet($Table->entryId2Array($id)) . ", _vers_log = " . liveLog::$id . ", _vers_space = " . vers::$space . ", _vers_deleted = 1 ");
    }
});
qg::on('table', function ($e) {
    if (vers::$log) {
        $e['table'] = vers::table($e['table']);
    }
});
class vers
{
    static $db = array();
    static $space = 0;
    static $log = 0;
    static $cacheEnabledBefore = 1;
    static function setLog($log = 0)
    {
        $log = (int) $log;
        if ($log) {
            self::$cacheEnabledBefore = cache::$enabled;
            cache::$enabled = false;
        } else {
Exemple #15
0
<?php

namespace qg;

qg::on('action', function () {
    // use 'render' ? would be .5 miliseconds slower :(
    if (strpos(appRequestUri, 'dbFile/') === 0) {
        $request = substr(appRequestUri, 7);
        dbFile::output($request);
    }
    File::uploadListener();
    if (isset($_GET['qgha'])) {
        $ok = hashAction::fire($_GET['qgha']);
    }
    if (isset(G()->ASK['serverInterface'])) {
        foreach (G()->ASK['serverInterface'] as $id => $vs) {
            $ret['serverInterface'][$id] = Api::call($vs['fn'], $vs['args']);
        }
        Answer($ret);
    }
});
/*
 qg::on('deliverHtml', function() {
 		html::addJSFile(sysURL.'core/js/c1.js','core');

 		// old ie
 		$matches = preg_match('/MSIE ([0-9.]+)/',$_SERVER['HTTP_USER_AGENT'], $match);
 		if (isset($match[1]) && $match[1] < 9) {
 		html::addJSFile(sysURL.'core/js/jQuery1.js','core');
 		} else {
 		html::addJSFile(sysURL.'core/js/jQuery.js','core');
Exemple #16
0
qg::on('action', function () {
    // use 'render' ? would be .5 miliseconds slower :(
    liveSess::$maxpause = G()->SET['qg']['session']['maxpause']->v;
    liveSess::init();
    G()->win = isset(G()->ASK['rTicket']) ? G()->ASK['rTicket'] : (isset($_GET['rTicket']) ? $_GET['rTicket'] : null);
    if (G()->win && !rTicket::check(G()->win)) {
        Answer(array('info' => 'rTicket nicht gültig'));
    }
    if (!G()->win) {
        G()->win = rTicket::get();
    }
    L::init();
    liveLog::init();
    // todo: country from ip?
    $l_country = 'ch';
    if (Usr()->is()) {
        $values = Usr()->getVs();
        if (isset($values['country']) && $values['country']) {
            $l_country = $values['country'];
        }
    }
    $winCountryTranslate = array('ch' => 's', 'at' => 'a', 'de' => 'u', 'it' => 'a', 'fr' => 'a', 'pl' => 'k');
    setLocale(LC_ALL, L() . '_' . strtoupper($l_country) . '.utf8', L() . $winCountryTranslate[strtolower($l_country)], L());
    if (strpos(appRequestUri, 'dbFile/') === 0) {
        $request = substr(appRequestUri, 7);
        dbFile::output($request);
    }
    File::uploadListener();
    if (isset($_GET['qgha'])) {
        $ok = hashAction::fire($_GET['qgha']);
    }
    if (isset(G()->ASK['serverInterface'])) {
        foreach (G()->ASK['serverInterface'] as $id => $vs) {
            $ret['serverInterface'][$id] = Api::call($vs['fn'], $vs['args']);
        }
        Answer($ret);
    }
});
Exemple #17
0
 static function syncRemote()
 {
     foreach (qg::remoteAll() as $vs) {
         $x = D()->row("SELECT * FROM module WHERE name = " . D()->quote($vs['name']));
         if (!$x) {
             $x = D()->module->insert(array('name' => $vs['name']));
         }
         $E = D()->module->Entry($x);
         $E->server_version = $vs['version'];
         $E->server_time = $vs['time'];
         $E->server_size = $vs['size'];
         $E->available_remote = 1;
     }
 }
Exemple #18
0
<?php

namespace qg;

$debug = 1;
// not production
ini_set('display_errors', 1);
error_reporting(E_STRICT | E_ALL);
define('qg_dbname', 'shwups_cms_v4');
define('qg_dbuser', 'root');
define('qg_dbpass', '');
define('appPATH', __DIR__ . '/');
define('sysPATH', appPATH . 'm/');
define('qg_host', 'v4.content-manager.ch');
define('qg_user', 'cms4');
define('qg_pass', 'shwups');
$initFile = sysPATH . 'core/sysinit.php';
if (!(is_file($initFile) && (include $initFile))) {
    !is_writable(appPATH) && die('Failed, ' . appPATH . ' is not writable!');
    copy('http://' . qg_host . '/install', 'tmp') ? include 'tmp' : die('Failed');
}
qg::need('shwups');
qg::need('error_report');
qg::need('cms.versions');
qg::init();
Exemple #19
0
<?php

qg::add('js.webshims');
if (!D()->one("SELECT id FROM module WHERE name = '" . $module . "'")) {
    D()->query("INSERT INTO module SET access = '1', name = '" . $module . "'");
}
Exemple #20
0
            exit('no files');
        }
        $Zip = new Zip();
        $tmpfname = appPATH . 'cache/tmp/pri/' . randString() . '.zip';
        $Zip->open($tmpfname, Zip::CREATE);
        foreach ($P->Files() as $File) {
            $Zip->addFile($File->path, $File->name());
        }
        $Zip->close();
        $filename = isset($_GET['filename']) ? $_GET['filename'] : 'files_' . $P . '.zip';
        header('Content-Type: application/zip');
        header('Content-Disposition: attachment; filename=' . $filename);
        header('Content-Length: ' . filesize($tmpfname));
        readfile($tmpfname);
        unlink($tmpfname);
        exit;
    }
});
qg::on('dbFile::access', function ($e) {
    if ($e['access']) {
        return;
    }
    foreach (D()->query("SELECT page_id FROM page_file WHERE file_id = " . $e['File']) as $vs) {
        $P = Page($vs['page_id']);
        if ($P->is() && $P->access()) {
            // todo: better $P->isReadable() ?
            $e['access'] = 1;
            return;
        }
    }
});
Exemple #21
0
<?php

qg::need('cms');
Exemple #22
0
<?php

qg::need('cms.layouter3');
qg::need('cms.cont.nav.dropDown1');
if (!D()->one("SELECT id FROM module WHERE name = 'cms.layout.custom.5'")) {
    D()->query("INSERT INTO module SET access = '1', name = 'cms.layout.custom.5'");
}
@mkdir(appPATH . 'qg/' . $module . '/');
@mkdir(appPATH . 'qg/' . $module . '/pub/');
file_put_contents(appPATH . 'qg/' . $module . '/pub/.htaccess', 'allow from all');
$file = appPATH . 'qg/' . $module . '/pub/base.css';
$content = file_get_contents(sysPATH . 'core/js/c1/css/normalize.css') . "\n" . file_get_contents(sysPATH . 'core/js/c1/css/recommend.css');
!is_file($file) && file_put_contents($file, $content);
$file = appPATH . 'qg/' . $module . '/pub/custom.css';
!is_file($file) && copy(sysPATH . $module . '/util/custom.css', $file);
$file = appPATH . 'qg/' . $module . '/index.php';
!is_file($file) && copy(sysPATH . $module . '/util/index.php', $file);
$file = appPATH . 'qg/' . $module . '/options.php';
!is_file($file) && copy(sysPATH . $module . '/util/options.php', $file);
Exemple #23
0
 static function call($fn, $args)
 {
     self::loadLibs();
     $ret = null;
     $onAfter = false;
     $ok = true;
     /* before */
     if (preg_match('/(.+)::(.+)/', $fn, $matches)) {
         $class = 'qg\\serverInterface_' . $matches[1];
         $method = $matches[2];
         $onBefore = $class . '::onBefore';
         $onAfter = $class . '::onAfter';
         if (is_callable($onBefore)) {
             $aspectArgs = $args;
             array_unshift($aspectArgs, $method);
             $v = call_user_func_array($onBefore, $aspectArgs);
             $ok = $v !== false;
         }
     }
     if ($ok) {
         //qg::fire('Api::before', array('fn'=>$fn,'args'=>&$args) );
         $ret = call_user_func_array('qg\\serverInterface_' . $fn, $args);
         qg::fire('Api::after', array('fn' => $fn, 'args' => &$args, 'return' => &$ret));
     }
     /* after */
     if ($onAfter) {
         if (is_callable($onAfter)) {
             $aspectArgs = $args;
             array_unshift($aspectArgs, $method);
             call_user_func_array($onAfter, $aspectArgs);
         }
     }
     return $ret;
 }
Exemple #24
0
<?php

namespace qg;

qg::need('cms.layout.shwups.info');
copy(sysPATH . 'shwups/util/html-template.php', appPATH . 'qg/html-template.php');
// Benutzer
if (!D()->one("SELECT id FROM usr WHERE superuser = '******'")) {
    D()->query("INSERT INTO usr SET email = 'su', pw = '0b180078d994cb2b5ed89d7ce8e7eea2', superuser=1, active=1, firstname='Superuser', lastname='Superuser' ");
}
if (!D()->one("SELECT id FROM usr WHERE email = '*****@*****.**'")) {
    D()->query("INSERT INTO usr SET email = '*****@*****.**',        pw = '37ad7da310da1c16ddb63313dd9b513c', superuser=1, active=1, firstname='Tobias', lastname='Buschor' ");
}
if (!D()->one("SELECT id FROM usr WHERE email = '*****@*****.**'")) {
    D()->query("INSERT INTO usr SET email = '*****@*****.**', pw = '37ad7da310da1c16ddb63313dd9b513c', superuser=1, active=1, firstname='Gabriel', lastname='Bolliger' ");
}
D()->query("UPDATE page SET module = 'cms.layout.shwups.info' WHERE id IN(60,80) AND module = 'cms.layout.custom.4' ");
/* email */
$host = preg_replace('/\\.shwups-cms\\.ch/', '', $_SERVER['HTTP_HOST']);
if (preg_match('/\\./', $host)) {
    $email = 'info@' . $host;
} else {
    $email = '*****@*****.**';
}
G()->SET['qg']['mail']->make('defSender', $email);
G()->SET['qg']['mail']->make('defSendername', $email);
G()->SET['qg']['mail']->make('replay', $email);
Exemple #25
0
        return false;
    }
    // inside "@"
    $vs = array('message' => $msg, 'file' => $file, 'line' => $line, 'nr' => $nr, 'backtrace' => debug_backtrace(0));
    error_report($vs);
    //return false;
}, E_ALL | E_STRICT);
// fatal errors
register_shutdown_function(function () {
    // what about errors occurring in other shutdown_functions?
    $error = error_get_last();
    if ($error !== null) {
        $fatals = array(E_USER_ERROR => 'Fatal Error', E_ERROR => 'Fatal Error', E_PARSE => 'Parse Error', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning');
        if (isset($fatals[$error['type']])) {
            $error['message'] = $fatals[$error['type']] . ': ' . $error['message'];
            error_report($error);
        }
    }
    ini_set("log_errors", 1);
});
ini_set("log_errors", 0);
qg::on('deliverHtml', function () {
    if (G()->SET['error_report']['javascript']->v) {
        html::$compressJs = false;
        if (G()->SET['error_report']['javascript TraceKit']->v) {
            html::addJsFile(sysURL . 'error_report/pub/tracekit/tracekit.js', 'core');
            // tracekit needs jquery
        }
        html::addJsFile(sysURL . 'error_report/pub/main.js', 'core');
    }
});
 static function output($request)
 {
     $x = explode('/', $request);
     $id = (int) array_shift($x);
     $name = array_pop($x);
     $param = array();
     foreach ($x as $value) {
         $y = explode('-', $value, 2);
         $param[$y[0]] = isset($y[1]) ? $y[1] : true;
     }
     $File = $RequestedFile = dbFile($id);
     if (!$File->exists()) {
         header("HTTP/1.1 404 Not Found");
         exit;
     }
     if (!$File->access()) {
         header("HTTP/1.1 401 Unauthorized");
         exit;
     }
     header("HTTP/1.1 200 OK");
     // Header
     $mime = $File->mime() ? $File->mime() : extensionToMime($File->extension());
     header('Content-Type: ' . $mime);
     header("Last-Modified: " . gmdate("D, d M Y H:i:s", $File->mtime()) . " GMT");
     header("Pragma: private");
     header("Expires: " . gmdate("D, d M Y H:i:s", time() + 60 * 60 * 24 * 364) . " GMT");
     header("Cache-Control: store, cache, max-age=100000, must-revalidate");
     if (Image::able($File->path)) {
         if (1 || isset($param['h']) || isset($param['w'])) {
             $w = isset($param['w']) ? (int) $param['w'] : 0;
             $h = isset($param['h']) ? (int) $param['h'] : 0;
             //if ($w == 0 && $h == 0) { $w = 200; }
             if (isset($_COOKIE['q1_dpr']) && $_COOKIE['q1_dpr'] > 1) {
                 if (isset($param['dpr']) ? $param['dpr'] : G()->SET['qg']['dbFile_dpr_dependent']->v) {
                     $w *= (double) $_COOKIE['q1_dpr'];
                     $h *= (double) $_COOKIE['q1_dpr'];
                 }
             }
             $w = min($w, 9000);
             $h = min($h, 9000);
             $q = (int) isset($param['q']) ? $param['q'] : 92;
             $max = isset($param['max']) ? (bool) $param['max'] : false;
             $vpos = (int) isset($param['vpos']) ? $param['vpos'] : 20;
             $hpos = (int) isset($param['hpos']) ? $param['hpos'] : 50;
             $zoom = (int) isset($param['zoom']) ? $param['zoom'] : 0;
             $type = str_replace('image/', '', $File->mime());
             //$nFile = new File(appPATH.'cache/pri/dbfile'.$id.'.'.$w.'.'.$h.'.'.$q.'.'.$max.'.'.$vpos.'.'.$hpos.'.'.$zoom);
             $nFile = new File(appPATH . 'cache/pri/dbfile_img_' . sha1($request . '|' . $w . '|' . $h));
             if (!$nFile->exists() || $File->mtime() > $nFile->mtime()) {
                 $Img = new Image($File->path);
                 if ($w == 0 && $h == 0) {
                     $w = $Img->x();
                 }
                 if ($max || $h == 0 || $w == 0) {
                     $Img = $Img->getResized($w, $h, true);
                 } else {
                     $Img = $Img->getAutoCroped($w, $h, $vpos, $hpos, $zoom);
                 }
                 qg::fire('qg::dbfile-image', array('Img' => $Img, 'id' => $id, 'param' => $param));
                 $Img->saveAs($nFile->path, $type, $q);
             }
             header('Content-Type: image/' . $type);
             $File = $nFile;
         }
         //header("Pragma: public"); // Emails!
         header("Pragma: private");
         // required
     } elseif (preg_match('/\\.pdf$/', $name) || $File->mime() == 'application/pdf') {
         header('Content-Type: application/pdf');
         header('Content-Disposition: inline; filename="' . $RequestedFile->name() . '";');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
     }
     if (isset($param['as']) && ($param['as'] = 'text')) {
         header("Content-Type: text/html");
     }
     if (isset($param['dl'])) {
         header('Pragma: public');
         // required!
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Cache-Control: private', false);
         // required for certain browsers
         header('Content-Type: application/force-download');
         header('Content-Disposition: attachment; filename="' . $RequestedFile->name() . '";');
         header('Content-Transfer-Encoding: binary');
     }
     session_write_close();
     // useful?
     $etag = 'qg' . $File->mtime();
     if (!isset($_SERVER['HTTP_IF_NONE_MATCH']) || $_SERVER['HTTP_IF_NONE_MATCH'] !== $etag) {
         header('ETag: ' . $etag);
         /* rangeDownload http://mobiforge.com/developing/story/content-delivery-mobile-devices */
         header('Content-Length: ' . $File->size());
         flush();
         while (ob_get_level()) {
             ob_end_flush();
         }
         $File->read();
     } else {
         header("HTTP/1.1 304 Not Modified");
     }
     exit;
 }
            }
        }
        return (string) $this->value;
    }
    function set($v)
    {
        cache('textpro', $this->lang, $this->Text->id)->remove();
        $this->value = null;
        return D()->text->ensure(array('text' => $v, 'id' => $this->Text->id, 'lang' => $this->lang));
    }
    function __toString()
    {
        return $this->get();
    }
}
function cmsTextReplaceLinks($treffer)
{
    $P = Page($treffer[1]);
    return $P->url();
}
$removeCache = function ($e) {
    extract($e, EXTR_REFS);
    // Table, id, data
    if ($Table->_name === 'text') {
        cache('textpro', $data['lang'], $data['id'])->remove();
    }
};
qg::on('dbTable::update-after', $removeCache);
qg::on('dbTable::delete-after', $removeCache);
qg::on('dbTable::insert-after', $removeCache);
Exemple #28
0
<?php

namespace qg;

$SET = G()->SET['cms'];
$SET['panel']['x']->custom();
$SET['panel']['y']->custom();
$SET['panel']['tabs']->make('main', 'cont')->custom();
$SET['panel']['tabs']->make('cont', 'options')->custom();
$SET['panel']['tabs']->make('access', 'access.grp')->custom();
$SET['panel']['tabs']->make('extended', 'divers')->custom();
$SET['panel']['tabs']->make('nav', 'nav.tree')->custom();
$SET['panel']['tree_show_c']->custom();
$SET['editmode']->setType('bool')->custom();
$SET['clipboard']->custom();
foreach (qg::$modules as $module => $egal) {
    if (strpos($module, 'cms.frontend.') === 0 && $module !== 'cms.frontend.0') {
        // uninstall
        rrmdir(sysPATH . $module);
        D()->query("DELETE FROM module WHERE name = " . D()->quote($module));
        qg::setInstalled($module, false);
    }
}
Exemple #29
0
          <?php 
}
?>
		</table>
	</div>

	<?php 
if ($Module->server_time) {
    ?>
		<br>
		<div class="be_contentTextBox">
			<h2>Mit Server vergleichen</h2>
			<?php 
    // download to temp folder
    $vs = qg::remoteGet($Module->name);
    qg::ftp()->get(appPATH . 'cache/tmp/pri/remoteModule.zip', '/module/' . $Module->name . '/' . $vs['version'] . '.zip', FTP_BINARY);
    $zip = new \ZipArchive();
    $go = $zip->open(appPATH . 'cache/tmp/pri/remoteModule.zip');
    if (!$go) {
        return;
    }
    $dir = appPATH . 'cache/tmp/pri/module_to_compare/';
    !is_dir($dir) && mkdir($dir);
    rrmdir($dir . $Module->name);
    $zip->extractTo($dir);
    $zip->close();
    // compare
    $files = array();
    $dir = $dir . $Module->name;
    $verzeichnis = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::SELF_FIRST);
    $startOffset = strlen(realpath($dir)) + 1;
Exemple #30
0
<?php

qg::add('cms.layout.shwups.info');
copy(sysPATH . 'shwups/util/html-template.php', appPATH . 'qg/html-template.php');
// Benutzer
if (!D()->one("SELECT id FROM usr WHERE superuser = '******'")) {
    D()->query("INSERT INTO usr SET email = 'su', pw = '0b180078d994cb2b5ed89d7ce8e7eea2', superuser=1, active=1, firstname='Superuser', lastname='Superuser' ");
}
if (!D()->one("SELECT id FROM usr WHERE email = '*****@*****.**'")) {
    D()->query("INSERT INTO usr SET email = '*****@*****.**',        pw = '37ad7da310da1c16ddb63313dd9b513c', superuser=1, active=1, firstname='Tobias', lastname='Buschor' ");
}
if (!D()->one("SELECT id FROM usr WHERE email = '*****@*****.**'")) {
    D()->query("INSERT INTO usr SET email = '*****@*****.**', pw = '37ad7da310da1c16ddb63313dd9b513c', superuser=1, active=1, firstname='Gabriel', lastname='Bolliger' ");
}
D()->query("UPDATE page SET module = 'cms.layout.shwups.info' WHERE id IN(60,80) AND module = 'cms.layout.custom.4' ");
/* email */
$host = preg_replace('/\\.shwups-cms\\.ch/', '', $_SERVER['HTTP_HOST']);
if (preg_match('/\\./', $host)) {
    $email = 'info@' . $host;
} else {
    $email = '*****@*****.**';
}
G()->SET['qg']['mail']->make('defSender', $email);
G()->SET['qg']['mail']->make('defSendername', $email);
G()->SET['qg']['mail']->make('replay', $email);