function tranformEnumValues($file = 0, $line = 0) { CustomField::addCustomColumns("item"); CustomField::addCustomColumns("user"); CustomField::addCustomColumns("search"); G::load($fields, "SELECT cid, columnIndex, `values`, `type` \n FROM @customfield \n WHERE cid=0 AND isCommon=0 AND columnIndex LIKE 'col_%' AND (type=4 OR type=6 OR type=7)"); foreach ($fields as $field) { CustomField::tranformEnumValuesForClass($field, "user", $file, $line); } $query = "SELECT cid, columnIndex, `values`, `type` \n FROM @customfield \n WHERE cid!=0 AND columnIndex LIKE 'col_%' AND (type=4 OR type=6 OR type=7)"; iterateLargeDatabaseTable($query, array("CustomField", "tranformEnumValuesInner")); }
function deletePictureOrMedia($isPicture = TRUE) { global $gorumrecognised, $gorumuser, $gorumroll; hasAdminRights($isAdm); $parts = explode("_", $gorumroll->rollid); $this->id = $parts[0]; $className = $this->get_class(); $attr = quoteSQL("{$parts['1']}_{$parts['2']}"); CustomField::addCustomColumns($className); load($this); if ($isAdm || $className == "item" && $gorumrecognised && $gorumuser->id == $this->ownerId) { executeQuery("UPDATE @{$className} SET `attr`='' WHERE id=#id#", $attr, $this->id); } else { die; } return $isPicture ? "{$this->id}_{$parts['2']}." . $this->{$attr} : "{$this->id}_" . $this->{$attr}; }
function move() { global $gorumroll; // csak admin move-olhat: hasAdminRights($isAdm); if (!$isAdm) { return; } $oldCid = G::getAttr($this->id, "item", "cid"); // ha nincs move-olas: if ($oldCid == $this->cid) { return; } G::load($newCategory, array("SELECT * FROM @category WHERE id=#cid#", $this->cid)); // Ellenorzes: ItemField::filterCompatibleCategories($oldCid, $newCategory); if (!count($newCategory)) { return; } // trukkozes $newCategory = $newCategory[0]; CustomField::addCustomColumns("item"); G::load($oldFields, array("SELECT columnIndex FROM @customfield WHERE cid=#cid# ORDER BY sortId ASC", $oldCid)); G::load($newFields, array("SELECT columnIndex FROM @customfield WHERE cid=#cid# ORDER BY sortId ASC", $this->cid)); load($this); $newObj = gclone($this); $newObj->cid = $newCategory->id; if ($newCategory->immediateAppear) { $newObj->status = TRUE; } for ($i = 0; $i < count($oldFields); $i++) { if (isset($this->{$oldFields[$i]->columnIndex})) { $newObj->{$newFields[$i]->columnIndex} = $this->{$oldFields[$i]->columnIndex}; } } modify($newObj); // itemnumok beallitasa if ($newObj->status) { $newCategory->increaseDirectItemNum(); } G::load($oldCategory, $oldCid, "appcategory"); if ($this->status) { $oldCategory->decreaseDirectItemNum(); } Roll::setInfoText("adMoved"); CacheManager::resetCache($this->cid); CacheManager::resetCache($oldCid); }
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); }
function getListSelect() { global $lll, $gorumroll, $gorumuser; if ($gorumroll->list == "user" || $gorumroll->list == "user_inactive") { $select = "SELECT n.* " . $this->getSpecialSortAttrs() . " FROM @user AS n WHERE id!=name && isAdm=0 AND active="; $select .= $gorumroll->list == "user" ? "1" : "0"; } elseif ($gorumroll->list == "user_search") { loadSQL($search = new Search(), array("SELECT query FROM @search WHERE uid=#uid# AND name=''", $gorumuser->id)); $select = $search->query; } CustomField::addCustomColumns("user"); //echo("$select<br><br>"); return $select; }
function setupCustomListAppearance($elementName) { global $lll, $item_typ, $jQueryLib, $curvyCorners, $gorumroll; // ha tobb item list is van egy oldalon, mindegyiknek teljesen kulonbozo typeinfo-ja lehet: include "item_typ.php"; // resetting $item_typ CustomField::addCustomColumns("item"); $lll["item_search_ttitle"] = htmlspecialchars($this->listTitle); $columns = $gorumroll->list == "export" ? $this->exportFields : $this->columns; G::load($columns, "SELECT * FROM @itemfield WHERE FIND_IN_SET(id, '{$columns}')!=0"); $item = new Item(); $item_typ["listOrder"] = array(); foreach (explode(",", $this->columns) as $id) { for ($i = 0; $i < count($columns); $i++) { if ($columns[$i]->id == $id) { $columns[$i]->showInList = 1; if (!$columns[$i]->customListPlacement) { $item_typ["listOrder"][] = $columns[$i]->columnIndex; } $item_typ["attributes"][$columns[$i]->columnIndex][] = "list"; if ($columns[$i]->customListPlacement) { $item_typ["attributes"][$columns[$i]->columnIndex][] = "customListPlacement"; } break; } } } $item->fields =& $columns; $item->cid = $this->cid; $item->activateVariableFields(); $item->fields = 0; CustomList::getSortingSql($this->primarySort, $this->primaryDir, $this->primaryPersistent, $this->secondarySort, $this->secondaryDir, $this->secondaryPersistent); if ($specialSortAttrs = $item->getSpecialSortAttrs($this->cid ? 0 : 1, $this->cid)) { $this->query = str_replace("n.*", "n.* {$specialSortAttrs}", $this->query); } if ($this->limit) { $item_typ["limit"] = $this->limit; } if ($this->listStyle != customlist_scrollable && $gorumroll->list != "export") { $_S =& new AppSettings(); if ($this->customAdListTemplate) { $item_typ["listTemplate"] = $this->customAdListTemplate; } elseif ($_S->customAdListTemplate) { $item_typ["listTemplate"] = $_S->customAdListTemplate; } } //var_dump($item_typ); if ($this->listStyle == customlist_scrollable && $gorumroll->list != "export") { // Neheny szajton, az orientattiont egyszeruen nem tudtam a typeInfoban atvinni a // item_scrollablepresentationbe - kenytelen voltan globalba tenni: global $scrollablePlacement, $orientation; if (!isset($item_typ["listTemplate"])) { $item_typ["listTemplate"] = "scrollable_widget.tpl.php"; } $item_typ["listPresentationClassName"] = "ItemScrollablePresentation"; $params = ""; $scrollablePlacement = $elementName; if ($elementName == "customListLeft" || $elementName == "customListRight") { $item_typ["scrollableOrientation"] = $orientation = "vertical"; $scrollableParams = "vertical: true"; } else { $scrollableParams = "vertical: false"; $item_typ["scrollableOrientation"] = $orientation = "horizontal"; } if ($this->loop) { $scrollableParams .= ", loop: true"; } include_once NOAH_APP . "/item_scrollablepresentation.php"; JavaScript::addInclude(GORUM_JS_DIR . $jQueryLib); JavaScript::addInclude(GORUM_JS_DIR . "/jquery/jquery.dimensions.js"); JavaScript::addInclude(GORUM_JS_DIR . "/jquery/jquery.center.js"); JavaScript::addInclude(GORUM_JS_DIR . "/jquery/jquery.scrollable.js"); JavaScript::addInclude(GORUM_JS_DIR . "/jquery/jquery.em.js"); JavaScript::addInclude(GORUM_JS_DIR . "/jquery/jquery.jscrollpane.js"); JavaScript::addInclude(JS_DIR . "/scrollable.js"); JavaScript::addCss(CSS_DIR . "/scrollable.css"); JavaScript::addCss(GORUM_JS_DIR . "/jquery/jscrollpane.css"); JavaScript::addOnload("\$.noah.globalScrollableOnLoad();", "scrollable"); JavaScript::addOnload("\$.noah.scrollableOnLoad(" . G::js($this->id, $elementName, $scrollableParams) . ");"); if ($this->autoScroll) { JavaScript::addOnload("\$.noah.autoscrollOnLoad(" . G::js($this->id, $elementName, $this->autoScroll) . ");"); } } }