function modifyForm() { global $lll, $gorumroll, $category_typ; $this->id = $gorumroll->rollid; load($this); if ($this->picture) { $picture = CAT_PIC_DIR . "/{$this->id}.{$this->picture}"; shrinkPicture($width, $height, 70, 70, $picture); $ctrl =& new AppController("cat/delete_picture/{$this->id}"); $deleteLink = $ctrl->generAnchor($lll["deletePicture"]); $lll["category_picture_embedfield"] = "\n <table id='deletePicture'>\n <tr>\n <td>%s</td>\n <td rowspan='2' class='deleteAfterSuccess'>\n <img src='{$picture}', width='{$width}' height='{$height}'>\n </td>\n </tr>\n <tr class='deleteAfterSuccess'>\n <td>{$deleteLink}</td>\n </tr>\n </table>"; JavaScript::addOnload("\n \$('#deletePicture a').click(function (){\n \$.get(this.href, function(){\n \$('#deletePicture .deleteAfterSuccess').remove();\n });\n return false;\n }); \n "); } // Propagation: JavaScript::addInclude(GORUM_JS_DIR . "/jquery/jquery.center.js"); // to center the loading animation image JavaScript::addInclude(GORUM_JS_DIR . "/jquery/field.js"); // to retrieve the form field values JavaScript::addInclude(JS_DIR . "/propagate.js"); // Propagate into all other categories: $propagatePostfix = OverlayController::addPropagateOverlay($this->id, "_cat"); // Propagate into the subcategories only: getDbCount($count, array("SELECT COUNT(*) FROM @category WHERE up=#id#", $this->id)); if ($count) { $propagatePostfix .= " " . OverlayController::addPropagateOverlay($this->id, "_cat", "_subcat"); } foreach (array_keys($category_typ["attributes"]) as $attr) { if (!in_array($attr, array("name", "notificationLinksProperties", "expirationAndModerationProperties", "seoProperties", "otherProperties")) && $this->getVisibility($category_typ["attributes"][$attr], $attr) == Form_visible) { if (isset($lll["category_{$attr}"])) { $lll["category_{$attr}"] .= $propagatePostfix; } elseif (isset($lll["appcategory_{$attr}"])) { $lll["appcategory_{$attr}"] .= $propagatePostfix; } elseif (isset($lll[$attr])) { $lll[$attr] .= $propagatePostfix; } } } parent::modifyForm(); }
function downsizeImage($width, $height, $info, $sourceFile, $destFile) { $create_fg = array("", "ImageCreateFromGIF", "ImageCreateFromJPEG", "ImageCreateFromPNG"); $save_fg = array("", "ImageGIF", "ImageJPEG", "ImagePNG"); shrinkPicture($newWidth, $newHeight, $width, $height, $sourceFile); $src_im = $create_fg[$info[2]]($sourceFile); $dst_im = ImageCreateTrueColor($newWidth, $newHeight); imagecopyresampled($dst_im, $src_im, 0, 0, 0, 0, $newWidth, $newHeight, $info[0], $info[1]); $th_foname = $this->getPicDir() . "/{$destFile}"; $save_fg[$info[2]]($dst_im, $th_foname); // attempt to chmod the file, so that an FTP user can have read and write access to it, too: chmod($th_foname, 0666); imagedestroy($src_im); }
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); }