示例#1
0
 function RunModule()
 {
     if (!isset($_REQUEST['module']) || !class_exists($_REQUEST['module']) || !isset($_REQUEST['pk']) || !isset($_REQUEST['field'])) {
         utopia::PageNotFound();
     }
     $obj = utopia::GetInstance($_REQUEST['module']);
     try {
         $rec = $obj->LookupRecord($_REQUEST['pk'], true);
     } catch (Exception $e) {
         utopia::PageNotFound();
     }
     if (!$rec || !isset($rec[$_REQUEST['field']])) {
         utopia::PageNotFound();
     }
     utopia::CancelTemplate();
     $data = $rec[$_REQUEST['field']];
     $table = $obj->fields[$_REQUEST['field']]['vtable']['tModule'];
     $tableField = $obj->fields[$_REQUEST['field']]['field'];
     $fieldType = $obj->GetFieldType($_REQUEST['field']);
     $filename = isset($_REQUEST['filename']) ? $_REQUEST['filename'] : $rec[$_REQUEST['field'] . '_filename'];
     $filetype = $rec[$_REQUEST['field'] . '_filetype'];
     $width = isset($_GET['w']) ? $_GET['w'] : NULL;
     $height = isset($_GET['h']) ? $_GET['h'] : NULL;
     $isImg = preg_match('/^image\\//', $filetype);
     if ($isImg && ($width || $height)) {
         $filetype = 'image/png';
     }
     $idents = array($table, $tableField, strlen($data), $width, $height, $isImg);
     $etag = utopia::checksum($idents);
     $attach = 'inline';
     if (isset($_REQUEST['attach'])) {
         $attach = $_REQUEST['attach'];
     }
     utopia::Cache_Check($etag, $filetype, $filename, 0, 2592000, $attach);
     $cacheFile = uCache::retrieve($idents);
     if ($cacheFile) {
         $data = file_get_contents($cacheFile);
     }
     if ($isImg && ($width || $height) && $cacheFile === FALSE) {
         $src = imagecreatefromstring($data);
         $img = utopia::constrainImage($src, $width, $height);
         //    Image output
         ob_start();
         imagepng($img);
         imagedestroy($img);
         $data = ob_get_clean();
         // only need to cache the resized versions
         uCache::store($idents, $data);
     }
     utopia::Cache_Output($data, $etag, $filetype, $filename, 0, 2592000, $attach);
 }
示例#2
0
 public function RunModule()
 {
     uEvents::TriggerEvent('InitSitemap');
     $grp = isset($_GET['group']) ? $_GET['group'] : '';
     if (!isset(self::$items[$grp])) {
         utopia::PageNotFound();
     }
     utopia::CancelTemplate();
     header('Content-Type: application/xml', true);
     echo '<?xml version="1.0" encoding="UTF-8"?>';
     echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
     foreach (self::$items[$grp] as $entry) {
         echo '<url>';
         foreach ($entry as $k => $v) {
             echo "\t<{$k}>{$v}</{$k}>";
         }
         echo '</url>';
     }
     echo '</urlset>';
     die;
 }
示例#3
0
function ProtectedScript()
{
    if ($_SERVER['SCRIPT_NAME'] == $_SERVER['REQUEST_URI']) {
        utopia::CancelTemplate();
        die("Protected Script\nCannot access directly");
    }
}
示例#4
0
 static function ajax()
 {
     header("X-Robots-Tag: noindex", true);
     utopia::CancelTemplate();
     if (isset($_GET['upload'])) {
         return jqFileManager::ProcessUpload(jqFileManager::GetPath(PATH_UPLOADS));
     }
     jqFileManager::ProcessAjax(PATH_UPLOADS, null, 'uUploads::OnRename', 'uUploads::GetIcon');
 }
示例#5
0
 public function RunModule()
 {
     utopia::CancelTemplate();
     $siteName = modOpts::GetOption('site_name');
     $schema = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http';
     $dom = $schema . '://' . utopia::GetDomainName();
     $xml = new DOMDocument('1.0');
     $xml->encoding = 'UTF-8';
     $xml->formatOutput = true;
     $feed = $xml->createElement('feed');
     //$feed->setAttribute('version','2.0');
     $feed->setAttribute('xmlns', 'http://www.w3.org/2005/Atom');
     $feed->setAttribute('xmlns:media', 'http://search.yahoo.com/mrss/');
     $xml->appendChild($feed);
     $self = str_replace(' ', '%20', htmlspecialchars($dom . $_SERVER['REQUEST_URI']));
     $node = $xml->createElement('title', $siteName . ' - Atom Feed');
     $feed->appendChild($node);
     $node = $xml->createElement('subtitle', $siteName . ' - Atom Feed');
     $feed->appendChild($node);
     $node = $xml->createElement('id', $self);
     $feed->appendChild($node);
     $node = $xml->createElement('link');
     $node->setAttribute('href', $self);
     $node->setAttribute('rel', 'self');
     $feed->appendChild($node);
     $node = $xml->createElement('link');
     $node->setAttribute('href', $dom . PATH_REL_ROOT);
     $feed->appendChild($node);
     $updated = $xml->createElement('updated');
     $updated->nodeValue = date(DATE_ATOM);
     $feed->appendChild($updated);
     $obj = utopia::GetInstance('module_NewsDisplay');
     $dataset = $obj->GetDataset();
     while ($row = $dataset->fetch()) {
         $summary = trim($obj->PreProcess('description', $row['description'], $row));
         if (!$summary) {
             continue;
         }
         $url = $dom . $obj->GetURL(array('news_id' => $row['news_id']), true);
         $entry = $xml->createElement('entry');
         $feed->appendChild($entry);
         self::appendData($xml, $entry, $row['heading'], 'title');
         self::appendData($xml, $entry, $url, 'id');
         $node = $xml->createElement('link');
         $node->setAttribute('href', $url);
         $entry->appendChild($node);
         self::appendData($xml, $entry, date(DATE_ATOM, strtotime($row['time'])), 'updated');
         self::appendData($xml, $entry, $summary, 'summary');
         if ($row['image']) {
             $node = $xml->createElement('media:thumbnail');
             $node->setAttribute('width', '150');
             $node->setAttribute('height', '150');
             $node->setAttribute('url', $dom . uBlob::GetLink(get_class($this), 'image', $row['news_id']) . '?w=150&h=150');
             $entry->appendChild($node);
         }
         $author = $xml->createElement('author');
         $entry->appendChild($author);
         $authorname = $row['author_name'] ? $row['author_name'] : 'Unknown';
         self::appendData($xml, $author, $authorname, 'name');
         if ($row['author_email']) {
             self::appendData($xml, $author, $row['author_email'], 'email');
         }
     }
     header('Access-Control-Allow-Origin: *');
     header('Content-Type: application/atom+xml', true);
     echo $xml->saveXML();
 }
示例#6
0
 public function RunModule()
 {
     utopia::CancelTemplate();
     clearstatcache();
     $uStr = '';
     self::$includeFiles = array_unique(self::$includeFiles);
     foreach (self::$includeFiles as $filename) {
         //does it exist?
         if (!file_exists($filename)) {
             continue;
         }
         $uStr .= $filename . filemtime($filename) . '-' . filesize($filename);
     }
     $identifiers = array($_SERVER['REQUEST_URI'], $uStr, count(self::$includeFiles), PATH_REL_CORE);
     $etag = utopia::checksum($identifiers);
     utopia::Cache_Check($etag, 'text/css', $this->GetUUID());
     $out = uCache::retrieve($identifiers);
     if ($out) {
         $out = file_get_contents($out);
     } else {
         $out = self::BuildCSS(true);
         uCache::store($identifiers, $out);
     }
     utopia::Cache_Output($out, $etag, 'text/css', $this->GetUUID());
 }
示例#7
0
 public function RunModule()
 {
     utopia::CancelTemplate();
     clearstatcache();
     $uStr = '';
     foreach (self::$includeFiles as $info) {
         if (!file_exists($info['path'])) {
             continue;
         }
         $uStr .= $info['path'] . filemtime($info['path']) . '-' . filesize($info['path']);
     }
     $identifiers = array($_SERVER['REQUEST_URI'], $uStr, self::$includeFiles, self::GetJavascriptConstants(), self::$includeText, PATH_REL_CORE);
     $etag = utopia::checksum($identifiers);
     utopia::Cache_Check($etag, 'text/javascript', $this->GetUUID());
     $out = uCache::retrieve($identifiers);
     if ($out) {
         $out = file_get_contents($out);
     } else {
         $out = self::BuildJavascript(true);
         uCache::store($identifiers, $out);
     }
     utopia::Cache_Output($out, $etag, 'text/javascript', $this->GetUUID());
 }