コード例 #1
0
ファイル: dataonly.php プロジェクト: OptimalInternet/uCore
 public static function process()
 {
     $type = isset($_GET['dataonly-type']) ? $_GET['dataonly-type'] : NULL;
     if (!$type || !isset(self::$types[$type])) {
         utopia::UseTemplate();
         utopia::PageNotFound();
         return;
     }
     $qs = $_GET;
     unset($qs['__ajax']);
     unset($qs['dataonly-type']);
     $cm = utopia::GetCurrentModule();
     if (!self::IsAllowed($cm)) {
         // redirect to module
         $obj = utopia::GetInstance($cm);
         header('Location: ' . $obj->GetURL($qs));
         return;
     }
     try {
         // try to access it dataonly, if it fails for any reason, break out of , redirect
         call_user_func(self::$types[$type]);
     } catch (Exception $e) {
         $obj = utopia::GetInstance($cm);
         header('Location: ' . $obj->GetURL($qs));
         return;
     }
 }
コード例 #2
0
ファイル: uploads.php プロジェクト: OptimalInternet/uCore
 function RunModule()
 {
     $uuid = $this->GetUUID();
     if (is_array($uuid)) {
         $uuid = reset($uuid);
     }
     $sections = utopia::GetRewriteURL();
     $sections = preg_replace('/^' . preg_quote($uuid, '/') . '\\/?/', '', $sections);
     // shift uuid off the start
     if (!$sections) {
         utopia::PageNotFound();
     }
     $path = urldecode(PATH_UPLOADS . '/' . $sections);
     $path = parse_url($path, PHP_URL_PATH);
     $path = realpath($path);
     if (stripos($path, PATH_UPLOADS) === FALSE || !file_exists($path)) {
         utopia::PageNotFound();
     }
     utopia::CancelTemplate();
     $cType = utopia::GetMimeType($path);
     $fileName = pathinfo($path, PATHINFO_BASENAME);
     $fileMod = filemtime($path);
     $fileSize = filesize($path);
     $w = isset($_GET['w']) ? $_GET['w'] : NULL;
     $h = isset($_GET['h']) ? $_GET['h'] : NULL;
     if (stripos($cType, 'image/') !== FALSE && ($w || $h)) {
         $idents = array($_SERVER['REQUEST_URI'], $fileMod, $fileSize, $w, $h);
         $etag = utopia::checksum($idents);
         utopia::Cache_Check($etag, $cType, $fileName);
         $cacheFile = uCache::retrieve($idents);
         if ($cacheFile) {
             $output = file_get_contents($cacheFile);
         } else {
             $output = file_get_contents($path);
         }
         // check w and h
         $img = imagecreatefromstring($output);
         $img = utopia::constrainImage($img, $w, $h);
         $ext = pathinfo($path, PATHINFO_EXTENSION);
         ob_start();
         if (function_exists(strtolower("image{$ext}"))) {
             call_user_func("image{$ext}", $img);
         } else {
             imagepng($img);
             $cType = 'image/png';
             $fileName = str_replace(".{$ext}", '.png', $fileName);
         }
         $output = ob_get_clean();
         imagedestroy($img);
         // only need to cache the resized versions
         uCache::store($idents, $output);
         utopia::Cache_Output($output, $etag, $cType, $fileName);
     } else {
         header('Content-Type: ' . $cType);
         self::resumableOutput($path);
     }
 }
コード例 #3
0
ファイル: blob.php プロジェクト: OptimalInternet/uCore
 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);
 }
コード例 #4
0
ファイル: sitemap.php プロジェクト: OptimalInternet/uCore
 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;
 }
コード例 #5
0
 static function Launcher($module = NULL)
 {
     if ($module == NULL) {
         $module = self::GetCurrentModule();
     }
     if (!utopia::ModuleExists($module)) {
         utopia::PageNotFound();
     }
     utopia::SetVar('current_module', $module);
     self::QueueLauncher($module);
     $currentModule = reset(self::$launchers);
     do {
         $obj = utopia::GetInstance($currentModule);
         utopia::SetVar('title', $obj->GetTitle());
         // run module
         timer_start('Run Module: ' . $currentModule);
         $obj->_RunModule();
         timer_end('Run Module: ' . $currentModule);
     } while ($currentModule = next(self::$launchers));
 }
コード例 #6
0
ファイル: news.php プロジェクト: OptimalInternet/uCore
 public function RunModule()
 {
     uEvents::AddCallback('ProcessDomDocument', array($this, 'ProcessDomDocument'));
     if (isset($_GET['news_id'])) {
         $rec = $this->LookupRecord($_GET['news_id']);
         if (!$rec) {
             utopia::PageNotFound();
         }
         utopia::SetTitle($rec['heading']);
         utopia::SetDescription($rec['description']);
         $n = array();
         if ($rec['noindex']) {
             $n[] = 'noindex';
         }
         if ($rec['nofollow']) {
             $n[] = 'nofollow';
         }
         if ($n) {
             utopia::AddMetaTag('robots', implode(',', $n));
         }
         echo '{widget.' . modOpts::GetOption('news_widget_article') . '}';
         return;
     }
     if (isset($_GET['tags'])) {
         utopia::SetTitle('Latest ' . ucwords($_GET['tags']) . ' News');
     }
     echo '{widget.' . modOpts::GetOption('news_widget_archive') . '}';
 }
コード例 #7
0
ファイル: cms.php プロジェクト: OptimalInternet/uCore
 public static function assertContent()
 {
     $o = utopia::GetInstance(__CLASS__);
     if (self::$asserted) {
         return;
     }
     self::$asserted = true;
     $rec = self::findPage();
     if (!$rec) {
         if (utopia::GetCurrentModule() == __CLASS__) {
             utopia::PageNotFound();
         }
         return;
     }
     $canEdit = uEvents::TriggerEvent('CanAccessModule', 'uCMS_Edit') !== FALSE;
     if (!$canEdit && !$rec['is_published']) {
         utopia::PageNotFound();
     }
     if (!isset($_GET['preview']) && !isset($_GET['edit']) && !$rec['is_published']) {
         utopia::PageNotFound();
     }
     echo '<div class="cms-' . $rec['cms_id'] . '">{content}</div>';
     utopia::SetVar('cms_id', $rec['cms_id']);
     utopia::SetVar('cms_parent_id', $rec['parent']);
     $path = $o->GetCmsParents($rec['cms_id']);
     utopia::SetVar('cms_parents', $path);
     utopia::SetVar('cms_root_id', reset($path));
     utopia::SetDescription($rec['description']);
     if (!utopia::UsingTemplate() || utopia::UsingTemplate(TEMPLATE_BLANK)) {
         return;
     }
     utopia::UseTemplate(self::GetTemplate($rec['cms_id']));
 }