コード例 #1
0
ファイル: DefaultController.php プロジェクト: AxelPanda/ibos
 public function actionGetApp()
 {
     $catId = intval(EnvUtil::getRequest("catid"));
     $category = AppCategory::model()->fetch("catid = {$catId}");
     $page = intval(EnvUtil::getRequest("page"));
     $limit = ($page - 1) * 18;
     $pageNum = 18;
     if ($catId == 0) {
         $appCount = App::model()->count("appid");
     } else {
         $appCount = App::model()->count("catid = {$catId}");
     }
     $pages = $appCount % $pageNum == 0 ? intval($appCount / $pageNum) : intval($appCount / $pageNum) + 1;
     $condition = $catId == 0 ? "appid LIMIT {$limit},{$pageNum}" : "catid = {$category["catid"]} and appid LIMIT {$limit},{$pageNum}";
     $appList = App::model()->fetchAll($condition);
     $this->ajaxReturn(array("isSuccess" => true, "data" => $appList, "pages" => $pages));
 }
コード例 #2
0
ファイル: category.php プロジェクト: alencarmo/OCF
 function calculateItemNums($diff = 0)
 {
     if ($diff) {
         if (!isset($this->itemNum)) {
             load($this);
         }
         // $diff-nek megfeleloen modositjuk az itemNumot es taroljuk:
         $this->itemNum += $diff;
         executeQuery("UPDATE @category SET itemNum=#this->itemNum# WHERE id=#this->id#", $this->itemNum, $this->id);
         // ha van apja, akkor rekurzivan meghivjuk ra a fg-t u.a. a $diff-fel:
         if ($this->up) {
             $father = new AppCategory();
             $father->id = $this->up;
             $father->calculateItemNums($diff);
         }
     } else {
         // megszamlaljuk az osszes aktiv kozvetlen itemet:
         getDbCount($count, array("SELECT COUNT(*) FROM #item WHERE cid=#this->id# AND status=1", $this->id));
         // ha esetleg meg nincs betoltve a kategoria, akkor betoltjuk:
         if (!isset($this->directItemNum)) {
             load($this);
         }
         $diff = $count - $this->directItemNum;
         // ha kulonbseg van a tarolt es a tenyleges kozott:
         if ($diff) {
             // eltaroljuk az uj directItemNum-ot:
             executeQuery("UPDATE @category SET directItemNum=#count# WHERE id=#this->id#", $count, $this->id);
             // Ujrahivjuk a fg-t nem nulla $diff-fel, hogy az itemNum is
             // megfeleloen modosuljon:
             $this->calculateItemNums($diff);
         }
     }
 }
コード例 #3
0
ファイル: item.php プロジェクト: alencarmo/OCF
 function showAppCName()
 {
     $c = new AppCategory();
     $c->id = $this->getCid();
     $c->name = $this->getCatName();
     $c->permaLink = $this->getCatPermaLink();
     return $c->showListVal("name");
 }
コード例 #4
0
ファイル: init.php プロジェクト: alencarmo/OCF
 function showApp()
 {
     global $navBarText, $categoryColumnsNum, $language, $jQueryLib;
     JavaScript::addInclude(GORUM_JS_DIR . $jQueryLib);
     JavaScript::addCss(CSS_DIR . "/layout.css");
     JavaScript::addCss(CSS_DIR . "/pages.css");
     if (is_callable(array("ThemeConfig", "init"))) {
         ThemeConfig::init();
     }
     $this->makeLoginMenu();
     $this->makeAdminMenu();
     $this->applyDebugMode();
     if (class_exists('rss')) {
         Rss::makeRssFeed();
     } else {
         View::assign("mainClass", 'main_withoutSidebar');
         View::assign("outerMainClass", 'outerMain_withoutSidebar');
     }
     CustomList::getList(customlist_top);
     CustomList::getList(customlist_bottom);
     CustomList::getList(customlist_aboveContent);
     CustomList::getList(customlist_belowContent);
     CustomList::getList(customlist_right);
     CustomList::getList(customlist_left);
     $_S =& new AppSettings();
     View::assign("baseUrl", Controller::getBaseUrl());
     View::assign("userStatus", $this->showUserStatus());
     View::assign("themeSelector", $this->showSelector("Theme"));
     View::assign("languageSelector", $this->showSelector("Language"));
     View::assign("versionFooter", $_S->versionFooter);
     View::assign("infoText", $this->showInfoText());
     View::assign("jsIncludes", JavaScript::getIncludes());
     View::assign("javaScript", JavaScript::getScript());
     View::assign("titlePrefix", $_S->getAttr("titlePrefix"));
     View::assign("categoryColumnsNum", $categoryColumnsNum);
     View::assign("cssDir", CSS_DIR);
     View::assign("imagesDir", IMAGES_DIR);
     View::assign("language", $language);
     View::assign("langDir", $_S->langDir);
     View::assign("extraBody", $_S->getProAttr("extraBody"));
     View::assign("extraFooter", $_S->getProAttr("extraFooter"));
     View::assign("extraHead", $_S->getProAttr("extraHead"));
     View::assign("extraTopContent", $_S->getProAttr("extraTopContent"));
     View::assign("extraBottomContent", $_S->getProAttr("extraBottomContent"));
     AppCategory::assignCurrentCategoryFields();
     User::assignCurrentUserFields();
 }
コード例 #5
0
ファイル: subscription.php プロジェクト: alencarmo/OCF
 function showListVal($attr)
 {
     global $lll;
     if ($attr == "catName") {
         if (!$this->cid) {
             return $lll["allCategories"];
         }
         $c = new AppCategory();
         $c->id = $this->cid;
         $c->name = $this->catName;
         $c->permaLink = $this->catPermaLink;
         return $c->showListVal("name");
     } elseif (($s = parent::showListVal($attr)) !== FALSE) {
         return $s;
     } else {
         $s = parent::showListVal($attr, "safetext");
     }
     return $s;
 }
コード例 #6
0
ファイル: updatelib.php プロジェクト: alencarmo/OCF
function updateItemTable()
{
    global $thumbnailSizes;
    executeQueryForUpdate("\n        ALTER TABLE @item \n        DROP title, DROP picture, DROP keepPrivate,\n        CHANGE `active` `status` INT NOT NULL DEFAULT 1, \n        CHANGE `expirationTime` `expirationTime` DATETIME NOT NULL, \n        CHANGE `creationtime` `creationtime` DATETIME NOT NULL;", __FILE__, __LINE__);
    executeQueryForUpdate("UPDATE @item SET `expirationTime`=0, expEmailSent=0", __FILE__, __LINE__);
    G::load($cats, "SELECT * FROM @category WHERE expiration!=0");
    foreach ($cats as $cat) {
        executeQueryForUpdate("UPDATE @item SET `expirationTime`= NOW() + INTERVAL {$cat->expiration} DAY WHERE cid={$cat->id};", __FILE__, __LINE__);
    }
    CustomField::addCustomColumns("item");
    G::load($items, "SELECT * FROM @item WHERE col_1!=''");
    $create_fg = array("", "ImageCreateFromGIF", "ImageCreateFromJPEG", "ImageCreateFromPNG");
    $save_fg = array("", "ImageGIF", "ImageJPEG", "ImagePNG");
    $extensions = array("", "gif", "jpg", "png");
    $checkBits = array(0, IMG_GIF, IMG_JPG, IMG_PNG);
    $memoryLimit = byteStr2num(ini_get('memory_limit'));
    foreach ($items as $item) {
        $ext = strstr($item->col_1, "jpg") ? "jpg" : (strstr($item->col_1, "gif") ? "gif" : (strstr($item->col_1, "png") ? "png" : ""));
        if (!$ext) {
            continue;
        }
        executeQueryForUpdate("UPDATE @item SET col_1='{$ext}' WHERE id={$item->id}", __FILE__, __LINE__);
        $fname = AD_PIC_DIR . "/{$item->id}.{$ext}";
        if (file_exists($fname)) {
            @unlink(AD_PIC_DIR . "/th_{$item->id}.{$ext}");
            // a regi thumbnailt toroljuk
            copy($fname, AD_PIC_DIR . "/{$item->id}_1.{$ext}");
            // uj nev a full image-nek
            // mas fg-eket kell hivni az image tipusnak megfeleloen:
            $size = getimagesize($fname);
            $width = $size[0];
            $height = $size[1];
            $type = $size[2];
            // az image tipus, 1=>GIF, 2=>JPG, 3=>PNG
            $ext = $extensions[$type];
            $supported = FALSE;
            if (defined("IMG_GIF") && function_exists("ImageTypes")) {
                $supported = isset($checkBits[$type]) && ImageTypes() & $checkBits[$type];
            }
            // ha az adott image tipus supportalva van:
            if ($supported) {
                foreach ($thumbnailSizes as $thSize => $dimensions) {
                    if (function_exists('memory_get_usage') && $memoryLimit && $memoryLimit != -1) {
                        $channels = isset($size['channels']) ? $size['channels'] : 1;
                        // png has no channels
                        $memoryNeeded = Round(($size[0] * $size[1] * $size['bits'] * $channels / 8 + Pow(2, 16)) * 1.65);
                        $usage = memory_get_usage();
                        //FP::log("Current usage: $usage, limit: $memoryLimit, new to allocate: $memoryNeeded, rest after allocate: ". ($memoryLimit-$usage-$memoryNeeded));
                        // skipping if ImageCreate would exceed the memory limit:
                        if ($usage + $memoryNeeded > $memoryLimit) {
                            continue;
                        }
                    }
                    shrinkPicture($newWidth, $newHeight, $dimensions["width"], $dimensions["height"], $fname);
                    $src_im = $create_fg[$type]($fname);
                    $dst_im = ImageCreateTrueColor($newWidth, $newHeight);
                    imagecopyresampled($dst_im, $src_im, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
                    $th_foname = AD_PIC_DIR . "/th_{$thSize}_{$item->id}_1.{$ext}";
                    // pictures/ads/th_medium_2345_5.jpg
                    $save_fg[$type]($dst_im, $th_foname);
                    imagedestroy($src_im);
                }
            }
            @unlink($fname);
            // a full image-et a regi neven toroljuk
        }
    }
    global $gorumuser, $gorumrecognised;
    $gorumrecognised = TRUE;
    $gorumuser->isAdm = 1;
    $c = new AppCategory();
    $c->recalculateAllItemNums(TRUE);
}
コード例 #7
0
ファイル: category.php プロジェクト: alencarmo/OCF
 function populateFullCategoryTree()
 {
     global $categoryTreeFormat, $categoryTreeMainClass, $categoryTreeMainTag, $categoryTreeActiveNodeClass, $categoryTreeParentNodeClass, $categoryTreeLeafNodeClass, $categoryTreeWithLinks;
     $attrs = "id, name, up, sortId, wholeName, itemNum, permaLink, subCatNum";
     if ($categoryTreeFormat == "single_array") {
         $item = new Item();
         $categories = $item->getSelectFromTree(FALSE, TRUE, $attrs);
     } else {
         $query = "SELECT {$attrs} FROM @category WHERE up=0 ORDER BY sortId ASC";
         G::load($mainCats, $query);
         $cat = new AppCategory();
         $categories =& $cat->getCategoryTree($mainCats, $attrs, FALSE);
         if ($categoryTreeFormat == "html") {
             $categories = $cat->getHtmlTree($categories, $categoryTreeMainTag, $categoryTreeMainClass, $categoryTreeActiveNodeClass, $categoryTreeWithLinks);
         }
     }
     View::assign("fullCategoryTree", $categories);
 }