/** * Copy a no-product image * * @param string $language Language iso_code for no-picture image filename */ public function copyNoPictureImage($language) { if (isset($_FILES['no-picture']) and $_FILES['no-picture']['error'] === 0) { if ($error = checkImage($_FILES['no-picture'], $this->maxImageSize)) { $this->_errors[] = $error; } else { if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['no-picture']['tmp_name'], $tmpName)) { return false; } if (!imageResize($tmpName, _PS_IMG_DIR_ . 'p/' . $language . '.jpg')) { $this->_errors[] = Tools::displayError('An error occurred while copying no-picture image to your product folder.'); } if (!imageResize($tmpName, _PS_IMG_DIR_ . 'c/' . $language . '.jpg')) { $this->_errors[] = Tools::displayError('An error occurred while copying no-picture image to your category folder.'); } if (!imageResize($tmpName, _PS_IMG_DIR_ . 'm/' . $language . '.jpg')) { $this->_errors[] = Tools::displayError('An error occurred while copying no-picture image to your manufacturer folder'); } else { $imagesTypes = ImageType::getImagesTypes('products'); foreach ($imagesTypes as $k => $imageType) { if (!imageResize($tmpName, _PS_IMG_DIR_ . 'p/' . $language . '-default-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height'])) { $this->_errors[] = Tools::displayError('An error occurred while resizing no-picture image to your product directory.'); } if (!imageResize($tmpName, _PS_IMG_DIR_ . 'c/' . $language . '-default-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height'])) { $this->_errors[] = Tools::displayError('An error occurred while resizing no-picture image to your category directory.'); } if (!imageResize($tmpName, _PS_IMG_DIR_ . 'm/' . $language . '-default-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height'])) { $this->_errors[] = Tools::displayError('An error occurred while resizing no-picture image to your manufacturer directory.'); } } } unlink($tmpName); } } }
function cacheImage($image, $cacheImage, $size, $imageType = 'jpg', $disableCache = false) { if (file_exists($image)) { if (!file_exists(_PS_TMP_IMG_DIR_ . $cacheImage)) { $infos = getimagesize($image); $memory_limit = Tools::getMemoryLimit(); // memory_limit == -1 => unlimited memory if (function_exists('memory_get_usage') && (int) $memory_limit != -1) { $current_memory = memory_get_usage(); // Evaluate the memory required to resize the image: if it's too much, you can't resize it. if (($infos[0] * $infos[1] * $infos['bits'] * (isset($infos['channels']) ? $infos['channels'] / 8 : 1) + pow(2, 16)) * 1.8 + $current_memory > $memory_limit - 1024 * 1024) { return false; } } $x = $infos[0]; $y = $infos[1]; $max_x = (int) $size * 3; /* Size is already ok */ if ($y < $size && $x <= $max_x) { copy($image, _PS_TMP_IMG_DIR_ . $cacheImage); } else { $ratioX = $x / ($y / $size); if ($ratioX > $max_x) { $ratioX = $max_x; $size = $y / ($x / $max_x); } imageResize($image, _PS_TMP_IMG_DIR_ . $cacheImage, $ratioX, $size, 'jpg'); } } return '<img src="' . _PS_TMP_IMG_ . $cacheImage . ($disableCache ? '?time=' . time() : '') . '" alt="" class="imgm" />'; } return ''; }
function download_files() { @mkdir('bigFoto', 0777); @mkdir('smallFoto', 0777); $file = $_FILES['filename']; $tmp = $file['tmp_name']; if (file_exists($tmp)) { $info = getimagesize($tmp); //ัะฐััะธัะตะฝะธะต ะฟะพะปััะตะฝะฝะพะน ะบะฐััะธะฝะบะธ $expBigPic = substr($info['mime'], 6); //ะฐ ะบะฐััะธะฝะบะฐ ะปะธ ััะพ if (preg_match('(image/(.*))is', $info['mime'], $p)) { //ะฐะดัะตัั ั ัะฐะฝะตะฝะธั ะธ ะฝะฐะทะฒะฐะฝะธะต ะบะฐััะธะฝะพะบ $imgOrig = "bigFoto/" . time() . "." . $ั[1] . "{$expBigPic}"; $imgPrev = "smallFoto/" . time() . "." . $ั[1] . "png"; //ะทะฐะณััะทะบะฐ ะบะฐััะธะฝะพะบ move_uploaded_file($tmp, $imgOrig); $query = "INSERT INTO bigPic VALUES (NULL, '{$imgPrev}', '{$imgOrig}', '{$expBigPic}', 0)"; mysql_query($query); //ะดะตะปะฐะตะผ ะฟัะตะฒัั imageResize($imgOrig, $info, $imgPrev); } else { echo '<p class="attention">Wrong format</p>'; } } else { echo '<p class="attention">Test version (only for study)</p>'; } }
function pictureUpload(Product $product, Cart $cart) { global $errors; if (!($fieldIds = $product->getCustomizationFieldIds())) { return false; } $authorizedFileFields = array(); foreach ($fieldIds as $fieldId) { if ($fieldId['type'] == _CUSTOMIZE_FILE_) { $authorizedFileFields[intval($fieldId['id_customization_field'])] = 'file' . intval($fieldId['id_customization_field']); } } $indexes = array_flip($authorizedFileFields); foreach ($_FILES as $fieldName => $file) { if (in_array($fieldName, $authorizedFileFields) and isset($file['tmp_name']) and !empty($file['tmp_name'])) { $fileName = md5(uniqid(rand(), true)); if ($error = checkImage($file, intval(Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE')))) { $errors[] = $error; } if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($file['tmp_name'], $tmpName)) { return false; } elseif (!imageResize($tmpName, _PS_PROD_PIC_DIR_ . $fileName)) { $errors[] = Tools::displayError('An error occurred during the image upload.'); } elseif (!imageResize($tmpName, _PS_PROD_PIC_DIR_ . $fileName . '_small', intval(Configuration::get('PS_PRODUCT_PICTURE_WIDTH')), intval(Configuration::get('PS_PRODUCT_PICTURE_HEIGHT')))) { $errors[] = Tools::displayError('An error occurred during the image upload.'); } elseif (!chmod(_PS_PROD_PIC_DIR_ . $fileName, 0777) or !chmod(_PS_PROD_PIC_DIR_ . $fileName . '_small', 0777)) { $errors[] = Tools::displayError('An error occurred during the image upload.'); } else { $cart->addPictureToProduct(intval($product->id), $indexes[$fieldName], $fileName); } unlink($tmpName); } } return true; }
function getContent() { global $cookie; /* Languages preliminaries */ $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT')); $languages = Language::getLanguages(); $iso = Language::getIsoById($defaultLanguage); $isoUser = Language::getIsoById(intval($cookie->id_lang)); /* display the module name */ $this->_html = '<h2>' . $this->displayName . ' ' . $this->version . '</h2>'; /* update the editorial xml */ if (isset($_POST['submitUpdate'])) { // Generate new XML data $newXml = '<?xml version=\'1.0\' encoding=\'utf-8\' ?>' . "\n"; $newXml .= '<links>' . "\n"; $i = 0; foreach ($_POST['link'] as $link) { $newXml .= ' <link>'; foreach ($link as $key => $field) { if ($line = $this->putContent($newXml, $key, $field)) { $newXml .= $line; } } /* upload the image */ if (isset($_FILES['link_' . $i . '_img']) and isset($_FILES['link_' . $i . '_img']['tmp_name']) and !empty($_FILES['link_' . $i . '_img']['tmp_name'])) { Configuration::set('PS_IMAGE_GENERATION_METHOD', 1); if ($error = checkImage($_FILES['link_' . $i . '_img'], $this->maxImageSize)) { $this->_html .= $error; } elseif (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['link_' . $i . '_img']['tmp_name'], $tmpName)) { return false; } elseif (!imageResize($tmpName, dirname(__FILE__) . '/' . $isoUser . $i . '.jpg')) { $this->_html .= $this->displayError($this->l('An error occurred during the image upload.')); } unlink($tmpName); } if ($line = $this->putContent($newXml, 'img', $isoUser . $i . '.jpg')) { $newXml .= $line; } $newXml .= "\n" . ' </link>' . "\n"; $i++; } $newXml .= '</links>' . "\n"; /* write it into the editorial xml file */ if ($fd = @fopen(dirname(__FILE__) . '/' . $isoUser . 'links.xml', 'w')) { if (!@fwrite($fd, $newXml)) { $this->_html .= $this->displayError($this->l('Unable to write to the editor file.')); } if (!@fclose($fd)) { $this->_html .= $this->displayError($this->l('Can\'t close the editor file.')); } } else { $this->_html .= $this->displayError($this->l('Unable to update the editor file.<br />Please check the editor file\'s writing permissions.')); } } /* display the editorial's form */ $this->_displayForm(); return $this->_html; }
public function afterImageUpload() { /* Generate image with differents size */ if ($id_manufacturer = intval(Tools::getValue('id_manufacturer')) and isset($_FILES) and count($_FILES) and file_exists(_PS_MANU_IMG_DIR_ . $id_manufacturer . '.jpg')) { $imagesTypes = ImageType::getImagesTypes('manufacturers'); foreach ($imagesTypes as $k => $imageType) { imageResize(_PS_MANU_IMG_DIR_ . $id_manufacturer . '.jpg', _PS_MANU_IMG_DIR_ . $id_manufacturer . '-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height'])); } } }
public function addProd($post) { $lid = inserting('proizvodi', array('pro_sifra' => $post['sifra'], 'pro_naziv' => $post['naziv'], 'pro_slug' => slugging($post['naziv']), 'pro_cena' => $post['cena'], 'pro_grupa_id' => $post['grupa'], 'pro_kat_id' => $post['kategorija'], 'pro_potkat_id' => $post['potkategorija'], 'pro_marka_id' => $post['marka'], 'pro_model_id' => $post['model'], 'pro_opis' => $post['opis'], 'pro_metakeys' => $post['metakeys'], 'pro_metadesc' => $post['metadesc'])); for ($i = 0; $i < count($_FILES["slike"]["name"]); $i++) { $file = date('dmY') . rand(1111, 9999) . $_FILES["slike"]["name"][$i]; move_uploaded_file($_FILES["slike"]["tmp_name"][$i], 'assets/images/products/' . $file); $slid = inserting('slike', array('sli_proizvod_id' => $lid, 'sli_url' => $file)); $tgfile = 'assets/images/products/' . $file; imageResize($tgfile, '800', '600', $tgfile, 'crop', '100'); } }
protected function postImage($id) { $ret = parent::postImage($id); if ($id_store = (int) Tools::getValue('id_store') and isset($_FILES) and sizeof($_FILES) and file_exists(_PS_STORE_IMG_DIR_ . $id_store . '.jpg')) { $imagesTypes = ImageType::getImagesTypes('stores'); foreach ($imagesTypes as $k => $imageType) { imageResize(_PS_STORE_IMG_DIR_ . $id_store . '.jpg', _PS_STORE_IMG_DIR_ . $id_store . '-' . stripslashes($imageType['name']) . '.jpg', (int) $imageType['width'], (int) $imageType['height']); } } return $ret; }
function PageCompPageMainCode() { $iLimit = 30; $aNewSizes = array('_t.jpg' => array('w' => 240, 'h' => 240, 'square' => true), '_t_2x.jpg' => array('w' => 480, 'h' => 480, 'square' => true, 'new_file' => true)); $sNewFile = false; foreach ($aNewSizes as $sKey => $r) { if (isset($r['new_file'])) { $sNewFile = $sKey; break; } } $sPathPhotos = BX_DIRECTORY_PATH_MODULES . 'boonex/photos/data/files/'; if ($GLOBALS['MySQL']->getOne("SELECT COUNT(*) FROM `sys_modules` WHERE `uri` IN('photos')")) { $aRow = $GLOBALS['MySQL']->getFirstRow("SELECT `ID`, `Ext` FROM `bx_photos_main` ORDER BY `ID` ASC"); $iCounter = 0; while (!empty($aRow)) { $sFileOrig = $sPathPhotos . $aRow['ID'] . '.' . $aRow['Ext']; $sFileNew = $sNewFile ? $sPathPhotos . $aRow['ID'] . $sNewFile : false; if ((!$sFileNew || !file_exists($sFileNew)) && file_exists($sFileOrig)) { // file isn't already processed and original exists // resize foreach ($aNewSizes as $sKey => $r) { $sFileDest = $sPathPhotos . $aRow['ID'] . $sKey; imageResize($sFileOrig, $sFileDest, $r['w'], $r['h'], true, $r['square']); } ++$iCounter; } if ($iCounter >= $iLimit) { break; } $aRow = $GLOBALS['MySQL']->getNextRow(); } if (empty($aRow)) { $s = "All photos has been resized to the new dimentions."; } else { $s = "Page is reloading to resize next bunch of images...\n <script>\n setTimeout(function () {\n document.location = '" . BX_DOL_URL_ROOT . "upgrade/files/7.1.6-7.2.0/photos_resize.php?_t=" . time() . "';\n }, 1000);\n </script>"; } } else { $s = "Module 'Photos' isn't installed"; } return DesignBoxContent($GLOBALS['_page']['header'], $s, $GLOBALS['oTemplConfig']->PageCompThird_db_num); }
function afterImageUpload() { /* Generate image with differents size */ $obj = $this->loadObject(true); if ($obj->id and (isset($_FILES['image']) or isset($_FILES['thumb']))) { $imagesTypes = ImageType::getImagesTypes('scenes'); foreach ($imagesTypes as $k => $imageType) { if ($imageType['name'] == 'large_scene' and isset($_FILES['image'])) { imageResize($_FILES['image']['tmp_name'], _PS_SCENE_IMG_DIR_ . $obj->id . '-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height'])); } elseif ($imageType['name'] == 'thumb_scene') { if (isset($_FILES['thumb']) and !$_FILES['thumb']['error']) { $tmpName = $_FILES['thumb']['tmp_name']; } else { $tmpName = $_FILES['image']['tmp_name']; } imageResize($tmpName, _PS_SCENE_THUMB_IMG_DIR_ . $obj->id . '-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height'])); } } } return true; }
/** * Generate Form for NewPost/EditPost * * @param $iPostID - Post ID * @return HTML presentation of data */ function AddNewPostForm($iPostID = 0, $bBox = true) { $this->CheckLogged(); if ($iPostID == 0) { if (!$this->isAllowedPostAdd()) { return $this->_oTemplate->displayAccessDenied(); } } else { $iOwnerID = (int) $this->_oDb->getPostOwnerByID($iPostID); if (!$this->isAllowedPostEdit($iOwnerID)) { return $this->_oTemplate->displayAccessDenied(); } } $sPostCaptionC = _t('_Title'); $sPostTextC = _t('_Text'); $sAssociatedImageC = _t('_associated_image'); $sAddBlogC = $iPostID ? _t('_Submit') : _t('_Add Post'); $sTagsC = _t('_Tags'); $sNewPostC = _t('_New Post'); $sEditPostC = _t('_bx_blog_Edit_post'); $sDelImgC = _t('_Delete image'); $sErrorC = _t('_Error Occured'); $sCaptionErrorC = _t('_bx_blog_Caption_error'); $sTextErrorC = _t('_bx_blog_Text_error'); $sTagsInfoC = _t('_sys_tags_note'); $sLink = $this->genBlogFormUrl(); $sAddingForm = ''; $oCategories = new BxDolCategories(); $oCategories->getTagObjectConfig(); $aAllowView = $this->oPrivacy->getGroupChooser($this->_iVisitorID, 'blogs', 'view', array(), _t('_bx_blog_privacy_view')); $aAllowRate = $this->oPrivacy->getGroupChooser($this->_iVisitorID, 'blogs', 'rate', array(), _t('_bx_blog_privacy_rate')); $aAllowComment = $this->oPrivacy->getGroupChooser($this->_iVisitorID, 'blogs', 'comment', array(), _t('_bx_blog_privacy_comment')); $sAction = $iPostID == 0 ? 'new_post' : 'edit_post'; //adding form $aForm = array('form_attrs' => array('name' => 'CreateBlogPostForm', 'action' => $sLink, 'method' => 'post', 'enctype' => 'multipart/form-data'), 'params' => array('db' => array('table' => $this->_oConfig->sSQLPostsTable, 'key' => 'PostID', 'submit_name' => 'add_button')), 'inputs' => array('PostCaption' => array('type' => 'text', 'name' => 'PostCaption', 'caption' => $sPostCaptionC, 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 255), 'error' => $sCaptionErrorC), 'db' => array('pass' => 'Xss')), 'Tags' => array('type' => 'text', 'name' => 'Tags', 'caption' => $sTagsC, 'info' => $sTagsInfoC, 'required' => false, 'db' => array('pass' => 'Xss')), 'PostText' => array('type' => 'textarea', 'html' => 2, 'name' => 'PostText', 'caption' => $sPostTextC, 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 65535), 'error' => $sTextErrorC), 'db' => array('pass' => 'XssHtml')), 'Categories' => $oCategories->getGroupChooser('bx_blogs', $this->_iVisitorID, true), 'File' => array('type' => 'file', 'name' => 'BlogPic[]', 'caption' => $sAssociatedImageC), 'AssociatedImage' => array('type' => 'hidden'), 'allowView' => $aAllowView, 'allowRate' => $aAllowRate, 'allowComment' => $aAllowComment, 'hidden_action' => array('type' => 'hidden', 'name' => 'action', 'value' => $sAction), 'add_button' => array('type' => 'submit', 'name' => 'add_button', 'value' => $sAddBlogC))); if ($iPostID > 0) { $aBlogPost = $this->_oDb->getJustPostInfo($iPostID); $sPostCaption = $aBlogPost['PostCaption']; $sPostText = $aBlogPost['PostText']; $sPostTags = $aBlogPost['Tags']; $sPostPicture = $aBlogPost['PostPhoto']; if ($sPostPicture != '') { $sBlogsImagesUrl = BX_BLOGS_IMAGES_URL; $sPostPictureTag = <<<EOF <div class="blog_edit_image" id="edit_post_image_{$iPostID}"> <img class="bx-def-shadow bx-def-round-corners bx-def-margin-sec-right" style="max-width:{$this->iThumbSize}px; max-height:{$this->iThumbSize}px;" src="{$sBlogsImagesUrl}big_{$sPostPicture}" /> <a href="{$sLink}?action=del_img&post_id={$iPostID}" onclick="BlogpostImageDelete('{$sLink}?action=del_img&post_id={$iPostID}&mode=ajax', 'edit_post_image_{$iPostID}');return false;" >{$sDelImgC}</a> </div> EOF; $aForm['inputs']['AssociatedImage']['type'] = 'custom'; $aForm['inputs']['AssociatedImage']['content'] = $sPostPictureTag; $aForm['inputs']['AssociatedImage']['caption'] = $sAssociatedImageC; } $aCategories = explode(';', $aBlogPost['Categories']); $aForm['inputs']['PostCaption']['value'] = $sPostCaption; $aForm['inputs']['PostText']['value'] = $sPostText; $aForm['inputs']['Tags']['value'] = $sPostTags; $aForm['inputs']['Categories']['value'] = $aCategories; $aForm['inputs']['allowView']['value'] = $aBlogPost['allowView']; $aForm['inputs']['allowRate']['value'] = $aBlogPost['allowRate']; $aForm['inputs']['allowComment']['value'] = $aBlogPost['allowComment']; $aForm['inputs']['hidden_postid'] = array('type' => 'hidden', 'name' => 'EditPostID', 'value' => $iPostID); if ($aBlogPost['PostPhoto'] != '' && file_exists(BX_BLOGS_IMAGES_PATH . 'small_' . $aBlogPost['PostPhoto'])) { $GLOBALS['oTopMenu']->setCustomSubIconUrl(BX_BLOGS_IMAGES_URL . 'small_' . $aBlogPost['PostPhoto']); } else { $GLOBALS['oTopMenu']->setCustomSubIconUrl('book'); } $GLOBALS['oTopMenu']->setCustomSubHeader($sPostCaption); } if (empty($aForm['inputs']['allowView']['value']) || !$aForm['inputs']['allowView']['value']) { $aForm['inputs']['allowView']['value'] = BX_DOL_PG_ALL; } if (empty($aForm['inputs']['allowRate']['value']) || !$aForm['inputs']['allowRate']['value']) { $aForm['inputs']['allowRate']['value'] = BX_DOL_PG_ALL; } if (empty($aForm['inputs']['allowComment']['value']) || !$aForm['inputs']['allowComment']['value']) { $aForm['inputs']['allowComment']['value'] = BX_DOL_PG_ALL; } $oForm = new BxTemplFormView($aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { $this->CheckLogged(); $iOwnID = $this->_iVisitorID; $sCurTime = time(); $sPostUri = uriGenerate(bx_get('PostCaption'), $this->_oConfig->sSQLPostsTable, 'PostUri'); $sAutoApprovalVal = getParam('blogAutoApproval') == 'on' ? "approval" : "disapproval"; $aValsAdd = array('PostDate' => $sCurTime, 'PostStatus' => $sAutoApprovalVal); if ($iPostID == 0) { $aValsAdd['OwnerID'] = $iOwnID; $aValsAdd['PostUri'] = $sPostUri; } $iBlogPostID = -1; if ($iPostID > 0) { unset($aValsAdd['PostDate']); $oForm->update($iPostID, $aValsAdd); $this->isAllowedPostEdit($iOwnerID, true); $iBlogPostID = $iPostID; } else { $iBlogPostID = $oForm->insert($aValsAdd); $this->isAllowedPostAdd(true); } if ($iBlogPostID) { $this->iLastPostedPostID = $iBlogPostID; if ($_FILES) { for ($i = 0; $i < count($_FILES['BlogPic']['tmp_name']); $i++) { if ($_FILES['BlogPic']['error'][$i]) { continue; } if (0 < $_FILES['BlogPic']['size'][$i] && 0 < strlen($_FILES['BlogPic']['name'][$i]) && 0 < $iBlogPostID) { $sTmpFile = $_FILES['BlogPic']['tmp_name'][$i]; if (file_exists($sTmpFile) == false) { break; } $aSize = getimagesize($sTmpFile); if (!$aSize) { @unlink($sTmpFile); break; } switch ($aSize[2]) { case IMAGETYPE_JPEG: case IMAGETYPE_GIF: case IMAGETYPE_PNG: $sOriginalFilename = $_FILES['BlogPic']['name'][$i]; $sExt = strrchr($sOriginalFilename, '.'); $sFileName = 'blog_' . $iBlogPostID . '_' . $i; @unlink($sFileName); move_uploaded_file($sTmpFile, BX_BLOGS_IMAGES_PATH . $sFileName . $sExt); @unlink($sTmpFile); if (strlen($sExt)) { $sPathSrc = BX_BLOGS_IMAGES_PATH . $sFileName . $sExt; $sPathDst = BX_BLOGS_IMAGES_PATH . '%s_' . $sFileName . $sExt; imageResize($sPathSrc, sprintf($sPathDst, 'small'), $this->iIconSize / 1, $this->iIconSize / 1); imageResize($sPathSrc, sprintf($sPathDst, 'big'), $this->iThumbSize, $this->iThumbSize); imageResize($sPathSrc, sprintf($sPathDst, 'browse'), $this->iBigThumbSize, null); imageResize($sPathSrc, sprintf($sPathDst, 'orig'), $this->iImgSize, $this->iImgSize); chmod(sprintf($sPathDst, 'small'), 0644); chmod(sprintf($sPathDst, 'big'), 0644); chmod(sprintf($sPathDst, 'browse'), 0644); chmod(sprintf($sPathDst, 'orig'), 0644); $this->_oDb->performUpdatePostWithPhoto($iBlogPostID, $sFileName . $sExt); @unlink($sPathSrc); } break; default: @unlink($sTempFileName); return false; } } } } //reparse tags bx_import('BxDolTags'); $oTags = new BxDolTags(); $oTags->reparseObjTags('blog', $iBlogPostID); //reparse categories $oCategories = new BxDolCategories(); $oCategories->reparseObjTags('bx_blogs', $iBlogPostID); $sAlertAction = $iPostID == 0 ? 'create' : 'edit_post'; bx_import('BxDolAlerts'); $oZ = new BxDolAlerts('bx_blogs', $sAlertAction, $iBlogPostID, $this->_iVisitorID); $oZ->alert(); header("X-XSS-Protection: 0"); // to prevent browser's security audit to block youtube embeds(and others), just after post creation return $this->GenPostPage($iBlogPostID); } else { return MsgBox($sErrorC); } } else { $sAddingForm = $oForm->getCode(); } $sCaption = $iPostID ? $sEditPostC : $sNewPostC; $sAddingFormVal = '<div class="blogs-view bx-def-bc-padding">' . $sAddingForm . '</div>'; return $bBox ? DesignBoxContent($sCaption, '<div class="blogs-view bx-def-bc-padding">' . $sAddingForm . '</div>', 1) : $sAddingFormVal; }
/** * copyImg copy an image located in $url and save it in a path * according to $entity->$id_entity . * $id_image is used if we need to add a watermark * * @param int $id_entity id of product or category (set in entity) * @param int $id_image (default null) id of the image if watermark enabled. * @param string $url path or url to use * @param string entity 'products' or 'categories' * @return void */ private static function copyImg($id_entity, $id_image = NULL, $url, $entity = 'products') { $tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'ps_import'); $watermark_types = explode(',', Configuration::get('WATERMARK_TYPES')); switch ($entity) { default: case 'products': $imageObj = new Image($id_image); $path = $imageObj->getPathForCreation(); break; case 'categories': $path = _PS_CAT_IMG_DIR_ . (int) $id_entity; break; } $url_source_file = str_replace(' ', '%20', trim($url)); if (@copy($url_source_file, $tmpfile)) { imageResize($tmpfile, $path . '.jpg'); $imagesTypes = ImageType::getImagesTypes($entity); foreach ($imagesTypes as $k => $imageType) { imageResize($tmpfile, $path . '-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height']); } if (in_array($imageType['id_image_type'], $watermark_types)) { Module::hookExec('watermark', array('id_image' => $id_image, 'id_product' => $id_entity)); } } else { unlink($tmpfile); return false; } unlink($tmpfile); return true; }
<div id="fanartRibbon" style="position: absolute; width: 125px; height: 125px; background: url(<?php echo $baseurl; ?> /images/game-view/ribbon-fanart.png) no-repeat; z-index: 10"></div> <?php if ($fanartResult = mysql_query(" SELECT b.id, b.filename FROM banners as b WHERE b.keyvalue = '{$platform->id}' AND b.keytype = 'platform-fanart' ")) { $fanSlideCount = 0; if (mysql_num_rows($fanartResult) > 0) { ?> <div id="fanartSlider" class="nivoSlider"> <?php while ($fanart = mysql_fetch_object($fanartResult)) { // $dims = getimagesize("$baseurl/banners/$fanart->filename"); echo "$dims[0] x $dims[1]"; ?> <img class="fanartSlide imgShadow" <?php echo imageResize("{$baseurl}/banners/{$fanart->filename}", "banners/_platformviewcache/{$fanart->filename}", 470, "width"); ?> alt="<?php echo $game->GameTitle; ?> Fanart" title="<?php echo imageUsername($fanart->id); ?> <br /><a href='<?php echo "{$baseurl}/banners/{$fanart->filename}"; ?> ' target='_blank'>View Full-Size</a> | <?php if ($adminuserlevel == 'ADMINISTRATOR') { echo "<a href='{$baseurl}/platform-edit/{$platform->id}/?function=Delete+Banner&bannerid={$fanart->id}'>Delete This Art</a>"; } ?>
function _makeAvatarFromSharedPhoto($iSharedPhotoId) { $aImageFile = BxDolService::call('photos', 'get_photo_array', array((int) $iSharedPhotoId, 'file'), 'Search'); if (!$aImageFile) { return false; } $sImagePath = BX_AVA_DIR_TMP . $this->_iProfileId . BX_AVA_EXT; if (!@copy($aImageFile['path'], $sImagePath)) { return false; } return IMAGE_ERROR_SUCCESS == imageResize($sImagePath, '', BX_AVA_PRE_RESIZE_W, BX_AVA_PRE_RESIZE_H, true) ? true : false; }
function getContent() { /* display the module name */ $this->_html = '<h2>' . $this->displayName . '</h2>'; $errors = ''; /* update the editorial xml */ if (isset($_POST['submitUpdate'])) { // Forbidden key $forbidden = array('submitUpdate'); foreach ($_POST as $key => $value) { if (!Validate::isString($_POST[$key])) { $this->_html .= $this->displayError($this->l('Invalid html field, javascript is forbidden')); $this->_displayForm(); return $this->_html; } } // Generate new XML data $newXml = '<?xml version=\'1.0\' encoding=\'utf-8\' ?>' . "\n"; $newXml .= '<editorial>' . "\n"; $newXml .= ' <header>'; // Making header data foreach ($_POST as $key => $field) { if ($line = $this->putContent($newXml, $key, $field, $forbidden, 'header')) { $newXml .= $line; } } $newXml .= "\n" . ' </header>' . "\n"; $newXml .= ' <body>'; // Making body data foreach ($_POST as $key => $field) { if ($line = $this->putContent($newXml, $key, $field, $forbidden, 'body')) { $newXml .= $line; } } $newXml .= "\n" . ' </body>' . "\n"; $newXml .= '</editorial>' . "\n"; /* write it into the editorial xml file */ if ($fd = @fopen(dirname(__FILE__) . '/editorial.xml', 'w')) { if (!@fwrite($fd, $newXml)) { $errors .= $this->displayError($this->l('Unable to write to the editor file.')); } if (!@fclose($fd)) { $errors .= $this->displayError($this->l('Can\'t close the editor file.')); } } else { $errors .= $this->displayError($this->l('Unable to update the editor file.<br />Please check the editor file\'s writing permissions.')); } /* upload the image */ if (isset($_FILES['body_homepage_logo']) and isset($_FILES['body_homepage_logo']['tmp_name']) and !empty($_FILES['body_homepage_logo']['tmp_name'])) { Configuration::set('PS_IMAGE_GENERATION_METHOD', 1); if ($error = checkImage($_FILES['body_homepage_logo'], $this->maxImageSize)) { $errors .= $error; } elseif (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['body_homepage_logo']['tmp_name'], $tmpName)) { return false; } elseif (!imageResize($tmpName, dirname(__FILE__) . '/homepage_logo.jpg')) { $errors .= $this->displayError($this->l('An error occurred during the image upload.')); } unlink($tmpName); } $this->_html .= $errors == '' ? $this->displayConfirmation('Settings updated successfully') : $errors; } /* display the editorial's form */ $this->_displayForm(); return $this->_html; }
/** * Copy a product image * * @param integer $id_product Product Id for product image filename * @param integer $id_image Image Id for product image filename */ public function copyImage($id_product, $id_image, $method = 'auto') { if (!isset($_FILES['image_product']['tmp_name']) or !file_exists($_FILES['image_product']['tmp_name'])) { return false; } if ($error = checkImage($_FILES['image_product'], $this->maxImageSize)) { $this->_errors[] = $error; } else { if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['image_product']['tmp_name'], $tmpName)) { $this->_errors[] = Tools::displayError('An error occured during the image upload'); } elseif (!imageResize($tmpName, _PS_IMG_DIR_ . 'p/' . $id_product . '-' . $id_image . '.jpg')) { $this->_errors[] = Tools::displayError('an error occurred while copying image'); } elseif ($method == 'auto') { $imagesTypes = ImageType::getImagesTypes('products'); foreach ($imagesTypes as $k => $imageType) { if (!imageResize($tmpName, _PS_IMG_DIR_ . 'p/' . $id_product . '-' . $id_image . '-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height'])) { $this->_errors[] = Tools::displayError('an error occurred while copying image') . ' ' . stripslashes($imageType['name']); } } } @unlink($tmpName); Module::hookExec('watermark', array('id_image' => $id_image, 'id_product' => $id_product)); } }
/** * Moves and resize uploaded file * * @param array $_FILES - system array of uploaded files * @param string $fname - name of "file" form * @param string $path_and_name - path and name of new file to create * @param string $maxsize - max available size (optional) * @param boolean $imResize - call imageResize function immediately (optional) * * @return int in case of error and extention of new file * in case of success * * NOTE: Source image should be in GIF, JPEG, PNG or BMP format */ function moveUploadedImage($_FILES, $fname, $path_and_name, $maxsize = '', $imResize = 'true') { global $max_photo_height; global $max_photo_width; $height = $max_photo_height; if (!$height) { $height = 400; } $width = $max_photo_width; if (!$width) { $width = 400; } if ($maxsize && ($_FILES[$fname]['size'] > $maxsize || $_FILES[$fname]['size'] == 0)) { if (file_exists($_FILES[$fname]['tmp_name'])) { unlink($_FILES[$fname]['tmp_name']); } return false; } else { $scan = getimagesize($_FILES[$fname]['tmp_name']); if ($scan['mime'] == 'image/jpeg' && ($ext = '.jpg') || $scan['mime'] == 'image/gif' && ($ext = '.gif') || $scan['mime'] == 'image/png' && ($ext = '.png')) { $path_and_name .= $ext; move_uploaded_file($_FILES[$fname]['tmp_name'], $path_and_name); if ($imResize) { imageResize($path_and_name, $path_and_name, $width, $height); } } else { return IMAGE_ERROR_WRONG_TYPE; } } return $ext; }
$select ); while ($item = $rsItems->GetNext()) { $arButtons = CIBlock::GetPanelButtons( $item["IBLOCK_ID"], $item["ID"], 0, array("SECTION_BUTTONS"=>false, "SESSID"=>false) ); $item["EDIT_LINK"] = $arButtons["edit"]["edit_element"]["ACTION_URL"]; $item["DELETE_LINK"] = $arButtons["edit"]["delete_element"]["ACTION_URL"]; if ($item["PREVIEW_PICTURE"]) { if ($arParams["RESIZE_PREVIEW_PICTURE"] === "Y") { $item["PREVIEW_PICTURE"] = \imageResize(array("WIDTH" => $arParams["RESIZE_WIDTH"], "HEIGHT" => $arParams["RESIZE_HEIGHT"], "MODE" => "cut"), \CFile::GetPath($item["PREVIEW_PICTURE"])); } else { $item["PREVIEW_PICTURE"] = \CFile::GetPath($item["PREVIEW_PICTURE"]); } } if ($arParams["SHOW_DATE"] === "Y") { $item["DATE"]["DAY"] = FormatDate('d', MakeTimeStamp($item["DATE_ACTIVE_FROM"])); $item["DATE"]["MONTH"] = FormatDate('F', MakeTimeStamp($item["DATE_ACTIVE_FROM"])); } if (!$item["PREVIEW_TEXT"]) { if ($arParams["CUT_TEXT_VALUE"]) { $item["PREVIEW_TEXT"] = \Ns\Bitrix\Helper::Create('iblock')->useVariant('text')->cut($item["PREVIEW_TEXT"], ($arParams["CUT_TEXT_VALUE"]) ? $arParams["CUT_TEXT_VALUE"] : false); } } $arResult["ITEMS"][$item["ID"]] = $item; }
/** * @return void * @param int $key Thumbnail type (1, 2, 3 etc.) * @desc Create specified thumbnail for image. */ function createThumbnail($key) { $params = $this->image['images'][$key]; $original_file = $this->path.$this->id.'_0'; if ($key==0) { // create image default thumbnail list($original_thumb_w,$original_thumb_h) = split('x',ORIGINAL_THUMBNAIL_SIZE); $thumbnail_file = $this->path.$this->id.'_t'; if (file_exists($original_file)) { imageResize($original_file, $thumbnail_file, $original_thumb_w, $original_thumb_h); } } else { // create image thumbnails $thumbnail_file = $this->path.$this->id.'_'.$key; if (file_exists($original_file)) { imageResize($original_file, $thumbnail_file, $params['width'], $params['height']); } } }
/** * Update settings in database and configuration files * * @params array $fields Fields settings * * @global string $currentIndex Current URL in order to keep current Tab */ protected function _postConfig($fields) { global $currentIndex, $smarty; $languages = Language::getLanguages(false); if (!Configuration::get('PS_FORCE_SMARTY_2')) { $files = scandir(_PS_THEME_DIR_); foreach ($files as $file) { if (!preg_match('/^\\..*/', $file)) { $smarty->clearCache($file); } } } else { $smarty->clear_all_cache(); } /* Check required fields */ foreach ($fields as $field => $values) { if (isset($values['required']) and $values['required']) { if (isset($values['type']) and $values['type'] == 'textLang') { foreach ($languages as $language) { if (($value = Tools::getValue($field . '_' . $language['id_lang'])) == false and (string) $value != '0') { $this->_errors[] = Tools::displayError('field') . ' <b>' . $values['title'] . '</b> ' . Tools::displayError('is required.'); } } } elseif (($value = Tools::getValue($field)) == false and (string) $value != '0') { $this->_errors[] = Tools::displayError('field') . ' <b>' . $values['title'] . '</b> ' . Tools::displayError('is required.'); } } } /* Check fields validity */ foreach ($fields as $field => $values) { if (isset($values['type']) and $values['type'] == 'textLang') { foreach ($languages as $language) { if (Tools::getValue($field . '_' . $language['id_lang']) and isset($values['validation'])) { if (!Validate::$values['validation'](Tools::getValue($field . '_' . $language['id_lang']))) { $this->_errors[] = Tools::displayError('field') . ' <b>' . $values['title'] . '</b> ' . Tools::displayError('is invalid.'); } } } } elseif (Tools::getValue($field) and isset($values['validation'])) { if (!Validate::$values['validation'](Tools::getValue($field))) { $this->_errors[] = Tools::displayError('field') . ' <b>' . $values['title'] . '</b> ' . Tools::displayError('is invalid.'); } } } /* Default value if null */ foreach ($fields as $field => $values) { if (!Tools::getValue($field) and isset($values['default'])) { $_POST[$field] = $values['default']; } } /* Save process */ if (!sizeof($this->_errors)) { if (Tools::isSubmit('submitAppearanceconfiguration')) { if (isset($_FILES['PS_LOGO']['tmp_name']) and $_FILES['PS_LOGO']['tmp_name']) { if ($error = checkImage($_FILES['PS_LOGO'], 300000)) { $this->_errors[] = $error; } if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['PS_LOGO']['tmp_name'], $tmpName)) { return false; } elseif (!@imageResize($tmpName, _PS_IMG_DIR_ . 'logo.jpg')) { $this->_errors[] = 'an error occurred during logo copy'; } unlink($tmpName); } if (isset($_FILES['PS_LOGO_MAIL']['tmp_name']) and $_FILES['PS_LOGO_MAIL']['tmp_name']) { if ($error = checkImage($_FILES['PS_LOGO_MAIL'], 300000)) { $this->_errors[] = $error; } if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS_MAIL')) or !move_uploaded_file($_FILES['PS_LOGO_MAIL']['tmp_name'], $tmpName)) { return false; } elseif (!@imageResize($tmpName, _PS_IMG_DIR_ . 'logo_mail.jpg')) { $this->_errors[] = 'an error occurred during logo copy'; } unlink($tmpName); } if (isset($_FILES['PS_LOGO_INVOICE']['tmp_name']) and $_FILES['PS_LOGO_INVOICE']['tmp_name']) { if ($error = checkImage($_FILES['PS_LOGO_INVOICE'], 300000)) { $this->_errors[] = $error; } if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS_INVOICE')) or !move_uploaded_file($_FILES['PS_LOGO_INVOICE']['tmp_name'], $tmpName)) { return false; } elseif (!@imageResize($tmpName, _PS_IMG_DIR_ . 'logo_invoice.jpg')) { $this->_errors[] = 'an error occurred during logo copy'; } unlink($tmpName); } if (isset($_FILES['PS_STORES_ICON']['tmp_name']) and $_FILES['PS_STORES_ICON']['tmp_name']) { if ($error = checkImage($_FILES['PS_STORES_ICON'], 300000)) { $this->_errors[] = $error; } if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS_STORES_ICON')) or !move_uploaded_file($_FILES['PS_STORES_ICON']['tmp_name'], $tmpName)) { return false; } elseif (!@imageResize($tmpName, _PS_IMG_DIR_ . 'logo_stores.gif')) { $this->_errors[] = 'an error occurred during logo copy'; } unlink($tmpName); } $this->uploadIco('PS_FAVICON', _PS_IMG_DIR_ . 'favicon.ico'); } /* Update settings in database */ if (!sizeof($this->_errors)) { foreach ($fields as $field => $values) { unset($val); if (isset($values['type']) and $values['type'] == 'textLang') { foreach ($languages as $language) { $val[$language['id_lang']] = isset($values['cast']) ? $values['cast'](Tools::getValue($field . '_' . $language['id_lang'])) : Tools::getValue($field . '_' . $language['id_lang']); } } else { $val = isset($values['cast']) ? $values['cast'](Tools::getValue($field)) : Tools::getValue($field); } Configuration::updateValue($field, $val); } Tools::redirectAdmin($currentIndex . '&conf=6' . '&token=' . $this->token); } } }
/** * Delete resized image then regenerate new one with updated settings */ private function _regenerateThumbnails() { @ini_set('max_execution_time', 3600); $productsTypes = ImageType::getImagesTypes('products'); $categoriesTypes = ImageType::getImagesTypes('categories'); $languages = Language::getLanguages(); $productsImages = Image::getAllImages(); /* Delete categories images */ $toDel = scandir(_PS_CAT_IMG_DIR_); foreach ($toDel as $d) { if (preg_match('/^[0-9]+\\-(.*)\\.jpg$/', $d) or preg_match('/^([[:lower:]]{2})\\-default\\-(.*)\\.jpg$/', $d)) { unlink(_PS_CAT_IMG_DIR_ . $d); } } /* Regenerate categories images */ $errors = false; $categoriesImages = scandir(_PS_CAT_IMG_DIR_); foreach ($categoriesImages as $image) { if (preg_match('/^[0-9]*\\.jpg$/', $image)) { foreach ($categoriesTypes as $k => $imageType) { if (!imageResize(_PS_CAT_IMG_DIR_ . $image, _PS_CAT_IMG_DIR_ . substr($image, 0, -4) . '-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write category image. Please check the folder\'s writing permissions.'); } /* Regenerate No-picture images */ $errors = false; foreach ($categoriesTypes as $k => $imageType) { foreach ($languages as $language) { $file = _PS_CAT_IMG_DIR_ . $language['iso_code'] . '.jpg'; if (!file_exists($file)) { $file = _PS_PROD_IMG_DIR_ . Language::getIsoById(intval(Configuration::get('PS_LANG_DEFAULT'))) . '.jpg'; } if (!imageResize($file, _PS_CAT_IMG_DIR_ . $language['iso_code'] . '-default-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write no-picture image to the category images folder. Please check the folder\'s writing permissions.'); } /* Delete manufacturers images */ $toDel = scandir(_PS_MANU_IMG_DIR_); foreach ($toDel as $d) { if (preg_match('/^[0-9]+\\-(.*)\\.jpg$/', $d) or preg_match('/^([[:lower:]]{2})\\-default\\-(.*)\\.jpg$/', $d)) { unlink(_PS_MANU_IMG_DIR_ . $d); } } /* Regenerate manufacturers images */ $manufacturersTypes = ImageType::getImagesTypes('manufacturers'); $manufacturersImages = scandir(_PS_MANU_IMG_DIR_); $errors = false; foreach ($manufacturersImages as $image) { if (preg_match('/^[0-9]*\\.jpg$/', $image)) { foreach ($manufacturersTypes as $k => $imageType) { if (!imageResize(_PS_MANU_IMG_DIR_ . $image, _PS_MANU_IMG_DIR_ . substr($image, 0, -4) . '-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write manufacturer images. Please check the folder\'s writing permissions.'); } /* Regenerate No-picture images */ $errors = false; foreach ($manufacturersTypes as $k => $imageType) { foreach ($languages as $language) { $file = _PS_MANU_IMG_DIR_ . $language['iso_code'] . '.jpg'; if (!file_exists($file)) { $file = _PS_PROD_IMG_DIR_ . Language::getIsoById(intval(Configuration::get('PS_LANG_DEFAULT'))) . '.jpg'; } if (!imageResize($file, _PS_MANU_IMG_DIR_ . $language['iso_code'] . '-default-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write no-picture image to the manufacturer images folder. Please check the folder\'s writing permissions.'); } /* Delete suppliers images */ $toDel = scandir(_PS_SUPP_IMG_DIR_); foreach ($toDel as $d) { if (preg_match('/^[0-9]+\\-(.*)\\.jpg$/', $d) or preg_match('/^([[:lower:]]{2})\\-default\\-(.*)\\.jpg$/', $d)) { unlink(_PS_SUPP_IMG_DIR_ . $d); } } /* Regenerate suppliers images */ $suppliersTypes = ImageType::getImagesTypes('suppliers'); $suppliersImages = scandir(_PS_SUPP_IMG_DIR_); $errors = false; foreach ($suppliersImages as $image) { if (preg_match('/^[0-9]*\\.jpg$/', $image)) { foreach ($suppliersTypes as $k => $imageType) { if (!imageResize(_PS_SUPP_IMG_DIR_ . $image, _PS_SUPP_IMG_DIR_ . substr($image, 0, -4) . '-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write supplier images into the supplier images folder. Please check the folder\'s writing permissions.'); } /* Regenerate No-picture images */ $errors = false; foreach ($suppliersTypes as $k => $imageType) { foreach ($languages as $language) { $file = _PS_SUPP_IMG_DIR_ . $language['iso_code'] . '.jpg'; if (!file_exists($file)) { $file = _PS_PROD_IMG_DIR_ . Language::getIsoById(intval(Configuration::get('PS_LANG_DEFAULT'))) . '.jpg'; } if (!imageResize($file, _PS_SUPP_IMG_DIR_ . $language['iso_code'] . '-default-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write no-picture image into the suppliers images folder.<br />Please check its writing permissions.'); } /* Delete scenes images */ $toDel = scandir(_PS_SCENE_IMG_DIR_); foreach ($toDel as $d) { if (preg_match('/^[0-9]+\\-(.*)\\.jpg$/', $d) or preg_match('/^([[:lower:]]{2})\\-default\\-(.*)\\.jpg$/', $d)) { unlink(_PS_SCENE_IMG_DIR_ . $d); } } /* Regenerate scenes images */ $scenesTypes = ImageType::getImagesTypes('scenes'); $scenesImages = scandir(_PS_SCENE_IMG_DIR_); $errors = false; foreach ($scenesImages as $image) { if (preg_match('/^[0-9]*\\.jpg$/', $image)) { foreach ($scenesTypes as $k => $imageType) { if (!imageResize(_PS_SCENE_IMG_DIR_ . $image, _PS_SCENE_IMG_DIR_ . substr($image, 0, -4) . '-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write scene images into the scene images folder. Please check the folder\'s writing permissions.'); } /* Regenerate No-picture images */ $errors = false; foreach ($scenesTypes as $k => $imageType) { foreach ($languages as $language) { $file = _PS_SCENE_IMG_DIR_ . $language['iso_code'] . '.jpg'; if (!file_exists($file)) { $file = _PS_PROD_IMG_DIR_ . Language::getIsoById(intval(Configuration::get('PS_LANG_DEFAULT'))) . '.jpg'; } if (!imageResize($file, _PS_SCENE_IMG_DIR_ . $language['iso_code'] . '-default-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write no-picture image into the scenes images folder.<br />Please check its writing permissions.'); } /* Delete products images */ $toDel = scandir(_PS_PROD_IMG_DIR_); foreach ($toDel as $d) { if (preg_match('/^[0-9]+\\-[0-9]+\\-(.*)\\.jpg$/', $d) or preg_match('/^([[:lower:]]{2})\\-default\\-(.*)\\.jpg$/', $d)) { unlink(_PS_PROD_IMG_DIR_ . $d); } } /* Regenerate No-picture images */ $errors = false; foreach ($productsTypes as $k => $imageType) { foreach ($languages as $language) { $file = _PS_PROD_IMG_DIR_ . $language['iso_code'] . '.jpg'; if (!file_exists($file)) { $file = _PS_PROD_IMG_DIR_ . Language::getIsoById(intval(Configuration::get('PS_LANG_DEFAULT'))) . '.jpg'; } $newFile = _PS_PROD_IMG_DIR_ . $language['iso_code'] . '-default-' . stripslashes($imageType['name']) . '.jpg'; if (!imageResize($file, $newFile, intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write no-picture image to the product images folder. Please check the folder\'s writing permissions.'); } /* Regenerate products images */ $errors = false; foreach ($productsImages as $k => $image) { if (file_exists(_PS_PROD_IMG_DIR_ . $image['id_product'] . '-' . $image['id_image'] . '.jpg')) { foreach ($productsTypes as $k => $imageType) { $newFile = _PS_PROD_IMG_DIR_ . $image['id_product'] . '-' . $image['id_image'] . '-' . stripslashes($imageType['name']) . '.jpg'; if (!imageResize(_PS_PROD_IMG_DIR_ . $image['id_product'] . '-' . $image['id_image'] . '.jpg', $newFile, intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } } // Hook watermark optimization $result = Db::getInstance()->ExecuteS(' SELECT m.`name` FROM `' . _DB_PREFIX_ . 'module` m LEFT JOIN `' . _DB_PREFIX_ . 'hook_module` hm ON hm.`id_module` = m.`id_module` LEFT JOIN `' . _DB_PREFIX_ . 'hook` h ON hm.`id_hook` = h.`id_hook` WHERE h.`name` = \'watermark\' AND m.`active` = 1'); if ($result and sizeof($result)) { foreach ($productsImages as $k => $image) { if (file_exists(_PS_PROD_IMG_DIR_ . $image['id_product'] . '-' . $image['id_image'] . '.jpg')) { foreach ($result as $k => $module) { if ($moduleInstance = Module::getInstanceByName($module['name']) and is_callable(array($moduleInstance, 'hookwatermark'))) { call_user_func(array($moduleInstance, 'hookwatermark'), array('id_image' => $image['id_image'], 'id_product' => $image['id_product'])); } } } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write product image. Please check the folder\'s writing permissions.'); } return sizeof($this->_errors) > 0 ? false : true; }
</div> <?php $count++; ## Tile Items Display while ($recent = mysql_fetch_object($recentResult)) { if ($boxartResult = mysql_query(" SELECT b.filename FROM banners as b WHERE b.keyvalue = '{$recent->id}' AND b.filename LIKE '%boxart%front%' LIMIT 1 ")) { $boxart = mysql_fetch_object($boxartResult); } ?> <div style="width: 440px; min-height: 150px; float: left; padding: 6px; margin: 10px 13px; border-radius: 4px; border: 1px solid #4f4f4f; background-color: #333;"> <div style="height: 102px; width: 106px; text-align: center; float:left"> <?php if ($boxart->filename != "") { ?> <img <?php echo imageResize("{$baseurl}/banners/{$boxart->filename}", "banners/_favcache/_tile-view/{$boxart->filename}", 100); ?> alt="<?php echo $recent->GameTitle; ?> Boxart" style="border: 1px solid #666;"/> <?php } else { ?> <img src="<?php echo $baseurl; ?> /images/common/placeholders/boxart_blank.png" alt="<?php echo $recent->GameTitle; ?> Boxart" style="width:70px; height: 100px; border: 1px solid #666;"/>
protected function uploadImage($id, $name, $dir, $ext = false) { if (isset($_FILES[$name]['tmp_name']) and !empty($_FILES[$name]['tmp_name'])) { // Delete old image if (Validate::isLoadedObject($object = $this->loadObject())) { $object->deleteImage(); } else { return false; } // Check image validity if ($error = checkImage($_FILES[$name], $this->maxImageSize)) { $this->_errors[] = $error; } elseif (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES[$name]['tmp_name'], $tmpName)) { return false; } else { $_FILES[$name]['tmp_name'] = $tmpName; // Copy new image if (!imageResize($tmpName, _PS_IMG_DIR_ . $dir . $id . '.' . $this->imageType, NULL, NULL, $ext ? $ext : $this->imageType)) { $this->_errors[] = Tools::displayError('An error occurred while uploading image.'); } if (sizeof($this->_errors)) { return false; } if ($this->afterImageUpload()) { unlink($tmpName); return true; } return false; } } return true; }
/** * Parsing uploaded files, store its with temp names, fill data into SQL tables * * @param $iMemberID current member ID * @return Text presentation of data (enum ID`s) */ function parseUploadedFiles() { $sCurrentTime = time(); if ($_FILES) { $aIDs = array(); for ($i = 0; $i < count($_FILES['userfile']['tmp_name']); $i++) { if ($_FILES['userfile']['error'][$i]) { continue; } if ($_FILES['userfile']['size'][$i] > $this->iMaxUplFileSize) { echo _t_err('_bx_ads_Warn_max_file_size', $_FILES['userfile']['name'][$i]); continue; } list($width, $height, $type, $attr) = getimagesize($_FILES['userfile']['tmp_name'][$i]); if ($type != 1 && $type != 2 && $type != 3) { continue; } $sBaseName = $this->_iVisitorID . '_' . $sCurrentTime . '_' . ($i + 1); $sExt = strrchr($_FILES['userfile']['name'][$i], '.'); $sExt = strtolower(trim($sExt)); $sImg = BX_DIRECTORY_PATH_ROOT . "{$this->sUploadDir}img_{$sBaseName}{$sExt}"; $sImgThumb = BX_DIRECTORY_PATH_ROOT . "{$this->sUploadDir}thumb_{$sBaseName}{$sExt}"; $sImgThumbBig = BX_DIRECTORY_PATH_ROOT . "{$this->sUploadDir}big_thumb_{$sBaseName}{$sExt}"; $sImgIcon = BX_DIRECTORY_PATH_ROOT . "{$this->sUploadDir}icon_{$sBaseName}{$sExt}"; $vResizeRes = imageResize($_FILES['userfile']['tmp_name'][$i], $sImg, $this->iImgSize, $this->iImgSize); $vThumbResizeRes = imageResize($_FILES['userfile']['tmp_name'][$i], $sImgThumb, $this->iThumbSize, $this->iThumbSize); $vBigThumbResizeRes = imageResize($_FILES['userfile']['tmp_name'][$i], $sImgThumbBig, $this->iBigThumbSize, $this->iBigThumbSize); $vIconResizeRes = imageResize($_FILES['userfile']['tmp_name'][$i], $sImgIcon, $this->iIconSize, $this->iIconSize); if ($vResizeRes || $vThumbResizeRes || $vBigThumbResizeRes || $vIconResizeRes) { echo _t_err("_ERROR_WHILE_PROCESSING"); continue; } $iImgId = $this->_oDb->insertMedia($this->_iVisitorID, $sBaseName, $sExt); if (!$iImgId) { @unlink($sImg); @unlink($sImgThumb); @unlink($sImgThumbBig); @unlink($sImgIcon); continue; } $aIDs[] = $iImgId; } return implode(',', $aIDs); } }
/** * Update settings in database and configuration files * * @params array $fields Fields settings * * @global string $currentIndex Current URL in order to keep current Tab */ protected function _postConfig($fields) { global $currentIndex, $smarty; $languages = Language::getLanguages(false); Tools::clearCache($smarty); /* Check required fields */ foreach ($fields as $field => $values) { if (isset($values['required']) and $values['required']) { if (isset($values['type']) and $values['type'] == 'textLang') { foreach ($languages as $language) { if (($value = Tools::getValue($field . '_' . $language['id_lang'])) == false and (string) $value != '0') { $this->_errors[] = Tools::displayError('field') . ' <b>' . $values['title'] . '</b> ' . Tools::displayError('is required.'); } } } elseif (($value = Tools::getValue($field)) == false and (string) $value != '0') { $this->_errors[] = Tools::displayError('field') . ' <b>' . $values['title'] . '</b> ' . Tools::displayError('is required.'); } } } /* Check fields validity */ foreach ($fields as $field => $values) { if (isset($values['type']) and $values['type'] == 'textLang') { foreach ($languages as $language) { if (Tools::getValue($field . '_' . $language['id_lang']) and isset($values['validation'])) { if (!Validate::$values['validation'](Tools::getValue($field . '_' . $language['id_lang']))) { $this->_errors[] = Tools::displayError('field') . ' <b>' . $values['title'] . '</b> ' . Tools::displayError('is invalid.'); } } } } elseif (Tools::getValue($field) and isset($values['validation'])) { if (!Validate::$values['validation'](Tools::getValue($field))) { $this->_errors[] = Tools::displayError('field') . ' <b>' . $values['title'] . '</b> ' . Tools::displayError('is invalid.'); } } } /* Default value if null */ foreach ($fields as $field => $values) { if (!Tools::getValue($field) and isset($values['default'])) { $_POST[$field] = $values['default']; } } /* Save process */ if (!sizeof($this->_errors)) { if (Tools::isSubmit('submitAppearanceconfiguration')) { if (isset($_FILES['PS_LOGO']['error']) && $_FILES['PS_LOGO']['error'] == 1 || isset($_FILES['PS_LOGO_MAIL']['error']) && $_FILES['PS_LOGO_MAIL']['error'] == 1 || isset($_FILES['PS_LOGO_INVOICE']['error']) && $_FILES['PS_LOGO_INVOICE']['error'] == 1 || isset($_FILES['PS_FAVICON']['error']) && $_FILES['PS_FAVICON']['error'] == 1 || isset($_FILES['PS_STORES_ICON']['error']) && $_FILES['PS_STORES_ICON']['error'] == 1) { $uploadMaxSize = (int) str_replace('M', '', ini_get('upload_max_filesize')); $postMaxSize = (int) str_replace('M', '', ini_get('post_max_size')); $maxSize = $uploadMaxSize < $postMaxSize ? $uploadMaxSize : $postMaxSize; $this->_errors[] = Tools::displayError('An error occurred during logo copy. Image size must be below') . ' ' . $maxSize . 'M.'; } if (isset($_FILES['PS_LOGO']['tmp_name']) and $_FILES['PS_LOGO']['tmp_name']) { if ($error = checkImage($_FILES['PS_LOGO'], 300000)) { $this->_errors[] = $error; } if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['PS_LOGO']['tmp_name'], $tmpName)) { return false; } elseif (!@imageResize($tmpName, _PS_IMG_DIR_ . 'logo.jpg')) { $this->_errors[] = Tools::displayError('an error occurred during logo copy'); } unlink($tmpName); } if (isset($_FILES['PS_LOGO_MAIL']['tmp_name']) and $_FILES['PS_LOGO_MAIL']['tmp_name']) { if ($error = checkImage($_FILES['PS_LOGO_MAIL'], 300000)) { $this->_errors[] = $error; } if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS_MAIL')) or !move_uploaded_file($_FILES['PS_LOGO_MAIL']['tmp_name'], $tmpName)) { return false; } elseif (!@imageResize($tmpName, _PS_IMG_DIR_ . 'logo_mail.jpg')) { $this->_errors[] = Tools::displayError('an error occurred during logo copy'); } unlink($tmpName); } if (isset($_FILES['PS_LOGO_INVOICE']['tmp_name']) and $_FILES['PS_LOGO_INVOICE']['tmp_name']) { if ($error = checkImage($_FILES['PS_LOGO_INVOICE'], 300000)) { $this->_errors[] = $error; } if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS_INVOICE')) or !move_uploaded_file($_FILES['PS_LOGO_INVOICE']['tmp_name'], $tmpName)) { return false; } elseif (!@imageResize($tmpName, _PS_IMG_DIR_ . 'logo_invoice.jpg')) { $this->_errors[] = Tools::displayError('an error occurred during logo copy'); } unlink($tmpName); } if (isset($_FILES['PS_STORES_ICON']['tmp_name']) and $_FILES['PS_STORES_ICON']['tmp_name']) { if ($error = checkImage($_FILES['PS_STORES_ICON'], 300000)) { $this->_errors[] = $error; } if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS_STORES_ICON')) or !move_uploaded_file($_FILES['PS_STORES_ICON']['tmp_name'], $tmpName)) { return false; } elseif (!@imageResize($tmpName, _PS_IMG_DIR_ . 'logo_stores.gif')) { $this->_errors[] = Tools::displayError('an error occurred during logo copy'); } unlink($tmpName); } $this->uploadIco('PS_FAVICON', _PS_IMG_DIR_ . 'favicon.ico'); } /* Update settings in database */ if (!sizeof($this->_errors)) { foreach ($fields as $field => $values) { unset($val); if (isset($values['type']) and $values['type'] == 'textLang') { foreach ($languages as $language) { $val[$language['id_lang']] = isset($values['cast']) ? $values['cast'](Tools::getValue($field . '_' . $language['id_lang'])) : Tools::getValue($field . '_' . $language['id_lang']); } } else { $val = isset($values['cast']) ? $values['cast'](Tools::getValue($field)) : Tools::getValue($field); } Configuration::updateValue($field, $val); } Tools::redirectAdmin($currentIndex . '&conf=6' . '&token=' . $this->token); } } }
private function copyImg($item, $className) { require_once '../../images.inc.php'; $identifier = $this->supportedImports[strtolower($className)]['identifier']; $matchId = $this->getMatchId(strtolower($className)); $matchIdLang = $this->getMatchIdLang(); switch ($className) { default: case 'Product': $path = _PS_PROD_IMG_DIR_; $type = 'products'; break; case 'Category': $path = _PS_CAT_IMG_DIR_; $type = 'categories'; break; case 'Manufacturer': $path = _PS_MANU_IMG_DIR_; $type = 'manufacturers'; break; case 'Supplier': $path = _PS_SUPP_IMG_DIR_; $type = 'suppliers'; break; } $cover = 1; if (array_key_exists($item[$identifier], $matchId)) { if (array_key_exists('images', $item) && !is_null($item['images'])) { foreach ($item['images'] as $key => $image) { $tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'import'); if (@copy(str_replace(' ', '%20', $image), $tmpfile)) { $imagesTypes = ImageType::getImagesTypes($type); imageResize($tmpfile, $path . (int) $matchId[$item[$identifier]] . '.jpg'); if ($className == 'Product') { $image = new Image(); $image->id_product = (int) $matchId[$item[$identifier]]; $image->cover = $cover; $image->position = Image::getHighestPosition((int) $matchId[$item[$identifier]]) + 1; $legend = array(); foreach ($item['name'] as $key => $val) { if (array_key_exists($key, $matchIdLang)) { $legend[$matchIdLang[$key]] = Tools::link_rewrite($val); } else { $legend[Configuration::get('PS_LANG_DEFAULT')] = Tools::link_rewrite($val); } } $image->legend = $legend; $image->add(); imageResize($tmpfile, $path . (int) $matchId[$item[$identifier]] . '-' . (int) $image->id . '.jpg'); foreach ($imagesTypes as $k => $imageType) { imageResize($tmpfile, $path . (int) $matchId[$item[$identifier]] . '-' . (int) $image->id . '-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height']); } } else { foreach ($imagesTypes as $k => $imageType) { imageResize($tmpfile, $path . (int) $matchId[$item[$identifier]] . '-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height']); } } } else { @unlink($tmpfile); } @unlink($tmpfile); $cover = 0; } } } }
$even = true; // List files foreach ($files as $file) { if ($file->isDirectory()) { continue; } $fileItem = array(); $imageSize = array(); $filepath = $file->getAbsolutePath(); $fileItem['margin'] = 0; $imageSize = getimagesize($file->getAbsolutePath()); $fileItem['real_width'] = $imageSize[0] ? $imageSize[0] : 0; $fileItem['real_height'] = $imageSize[1] ? $imageSize[1] : 0; // calculate percentage width and height if ($config['thumbnail.scale_mode'] == "percentage") { $imageSize = imageResize($imageSize[0], $imageSize[1], $config['thumbnail.width'], $config['thumbnail.height']); $fileItem['width'] = $imageSize['width']; $fileItem['height'] = $imageSize['height']; // Calculate margin if ($config['thumbnail.height'] - $imageSize['height'] > 0) { $fileItem['margin'] = ($config['thumbnail.height'] - $imageSize['height']) / 2; } } else { $fileItem['width'] = $config['thumbnail.width']; $fileItem['height'] = $config['thumbnail.height']; } $fileItem['name'] = basename($file->getAbsolutePath()); $fileItem['path'] = $file->getAbsolutePath(); $fileItem['modificationdate'] = date($config['filesystem.datefmt'], $file->lastModified()); $fileItem['even'] = $even; $fileItem['hasReadAccess'] = $file->canRead() && checkBool($config["filesystem.readable"]) ? "true" : "false";
function uploadMedia() { global $dir; $sMediaDir = $this->getProfileMediaDir(); if (!$sMediaDir) { return false; } $sFileName = time(); $ext = moveUploadedImage($_FILES, 'photo', $sMediaDir . $sFileName, $this->aMediaConfig['max']['photoFile'], false); if (0 == $_FILES[$this->sMediaType]['error']) { if (getParam('enable_watermark') == 'on') { $iTransparent = getParam('transparent1'); $sWaterMark = $dir['profileImage'] . getParam('Water_Mark'); if (strlen(getParam('Water_Mark')) && file_exists($sWaterMark)) { $sFile = $sMediaDir . $sFileName . $ext; applyWatermark($sFile, $sFile, $sWaterMark, $iTransparent); } } if (strlen($ext) && !(int) $ext) { imageResize($sMediaDir . $sFileName . $ext, $sMediaDir . 'icon_' . $sFileName . $ext, $this->aMediaConfig['size']['iconWidth'], $this->aMediaConfig['size']['iconHeight'], true); imageResize($sMediaDir . $sFileName . $ext, $sMediaDir . 'thumb_' . $sFileName . $ext, $this->aMediaConfig['size']['thumbWidth'], $this->aMediaConfig['size']['thumbHeight'], true); imageResize($sMediaDir . $sFileName . $ext, $sMediaDir . 'photo_' . $sFileName . $ext, $this->aMediaConfig['size']['photoWidth'], $this->aMediaConfig['size']['photoHeight'], true); $this->insertMediaToDb($sFileName . $ext); if (0 == $this->iMediaCount || $this->aMedia['0']['PrimPhoto'] == 0) { $iLastID = mysql_insert_id(); $this->oMediaQuery->setPrimaryPhoto($this->iProfileID, $iLastID); } @unlink($sMediaDir . $sFileName . $ext); } } }
function performPhotoUpload($sTmpFile, $aFileInfo, $bAutoAssign2Profile = false, $isMoveUploadedFile = true, $iChangingPhotoID = 0, $iAuthorId = 0) { global $dir; $iLastID = -1; if (!$iAuthorId) { $iAuthorId = $this->_iOwnerId; } $this->oModule = BxDolModule::getInstance('BxPhotosModule'); // checker for flash uploader if (!$this->oModule->_iProfileId) { $this->oModule->_iProfileId = $this->_iOwnerId; } if (!$iAuthorId || file_exists($sTmpFile) == false || !$this->oModule->isAllowedAdd(FALSE, FALSE, FALSE)) { return false; } $sMediaDir = $this->oModule->_oConfig->getFilesPath(); if (!$sMediaDir) { @unlink($sTmpFile); return false; } $sTempFileName = $sMediaDir . $iAuthorId . '_temp'; @unlink($sTempFileName); if ($isMoveUploadedFile && is_uploaded_file($sTmpFile) || !$isMoveUploadedFile) { if ($isMoveUploadedFile) { move_uploaded_file($sTmpFile, $sTempFileName); @unlink($sTmpFile); } else { $sTempFileName = $sTmpFile; } @chmod($sTempFileName, 0644); if (file_exists($sTempFileName) && filesize($sTempFileName) > 0) { $aSize = getimagesize($sTempFileName); if (!$aSize) { @unlink($sTempFileName); return false; } switch ($aSize[2]) { case IMAGETYPE_JPEG: $sExtension = '.jpg'; break; case IMAGETYPE_GIF: $sExtension = '.gif'; break; case IMAGETYPE_PNG: $sExtension = '.png'; break; default: @unlink($sTempFileName); return false; } $sStatus = 'processing'; $iImgWidth = (int) $aSize[0]; $iImgHeight = (int) $aSize[1]; $sDimension = $iImgWidth . 'x' . $iImgHeight; $sFileSize = sprintf("%u", filesize($sTempFileName) / 1024); if ($iChangingPhotoID == 0) { if (is_array($aFileInfo) && count($aFileInfo) > 0) { $aFileInfo['dimension'] = $sDimension; $iLastID = $this->insertSharedMediaToDb($sExtension, $aFileInfo, $iAuthorId); } else { $sExtDb = trim($sExtension, '.'); $sMedUri = $sCurTime = time(); $sTitleDescTemp = $this->sTempFilename != '' ? $this->sTempFilename : $iAuthorId . '_temp'; if (getParam('bx_photos_activation') == 'on') { $bAutoActivate = true; $sStatus = 'approved'; } else { $bAutoActivate = false; $sStatus = 'pending'; } $sAlbum = $_POST['extra_param_album']; $aAlbumParams = isset($_POST['extra_param_albumPrivacy']) ? array('privacy' => (int) $_POST['extra_param_albumPrivacy']) : array(); $iLastID = $this->oModule->_oDb->insertData(array('medProfId' => $iAuthorId, 'medExt' => $sExtDb, 'medTitle' => $sTitleDescTemp, 'medUri' => $sMedUri, 'medDesc' => $sTitleDescTemp, 'medTags' => '', 'Categories' => PROFILE_PHOTO_CATEGORY, 'medSize' => $sDimension, 'Approved' => $sStatus, 'medDate' => $sCurTime)); $this->addObjectToAlbum($this->oModule->oAlbums, $sAlbum, $iLastID, $bAutoActivate, $iAuthorId, $aAlbumParams); $this->oModule->isAllowedAdd(true, true); } } else { $iLastID = $iChangingPhotoID; $this->updateMediaShared($iLastID, $aFileInfo); } $sFunc = $isMoveUploadedFile ? 'rename' : 'copy'; if (!$sFunc($sTempFileName, $sMediaDir . $iLastID . $sExtension)) { @unlink($sTempFileName); return false; } $this->sSendFileInfoFormCaption = $iLastID . $sExtension . " ({$sDimension}) ({$sFileSize}kb)"; $sFile = $sMediaDir . $iLastID . $sExtension; // watermark postprocessing if (getParam('enable_watermark') == 'on') { $iTransparent = getParam('transparent1'); $sWaterMark = $dir['profileImage'] . getParam('Water_Mark'); if (strlen(getParam('Water_Mark')) && file_exists($sWaterMark)) { applyWatermark($sFile, $sFile, $sWaterMark, $iTransparent); } } // generate present pics foreach ($this->oModule->_oConfig->aFilesConfig as $sKey => $aValue) { if (!isset($aValue['size_def'])) { continue; } $iWidth = (int) $this->oModule->_oConfig->getGlParam($sKey . '_width'); $iHeight = (int) $this->oModule->_oConfig->getGlParam($sKey . '_height'); if ($iWidth == 0) { $iWidth = $aValue['size_def']; } if ($iHeight == 0) { $iHeight = $aValue['size_def']; } $sNewFilePath = $sMediaDir . $iLastID . $aValue['postfix']; $iRes = imageResize($sFile, $sNewFilePath, $iWidth, $iHeight, true, isset($aValue['square']) && $aValue['square']); if ($iRes != 0) { return false; } //resizing was failed @chmod($sNewFilePath, 0644); } $aOwnerInfo = getProfileInfo($iAuthorId); $bAutoAssign2Profile = $aOwnerInfo['Avatar'] == 0 ? true : $bAutoAssign2Profile; if ($bAutoAssign2Profile && $iLastID > 0) { $this->setPrimarySharedPhoto($iLastID, $iAuthorId); createUserDataFile($iAuthorId); } if (is_array($aFileInfo) && count($aFileInfo) > 0) { $this->alertAdd($iLastID, true); } } } return $iLastID; }
<?php } else { $counter++; } } elseif ($favoritesview == "banner") { if ($bannerResult = mysql_query(" SELECT b.filename FROM banners as b WHERE b.keyvalue = '{$favoriteID}' AND b.keytype = 'series' LIMIT 1 ")) { $banner = mysql_fetch_object($bannerResult); } ?> <div style="width: 222px; min-height: 80px; float: left; padding: 10px; margin: 10px; border-radius: 16px; border: 2px solid #333; background-color: #fff;"> <div style="height: 47px;"> <?php if ($banner->filename != "") { ?> <img <?php echo imageResize("{$baseurl}/banners/{$banner->filename}", "banners/_favcache/_banner-view/{$banner->filename}", 200); ?> alt="<?php echo $game->GameTitle; ?> Boxart" style="border: 1px solid #666;"/> <?php } else { ?> <img src="<?php echo $baseurl; ?> /images/common/placeholders/banner_blank.png" alt="<?php echo $game->GameTitle; ?> Boxart" style="width:200px; height: 47px; border: 1px solid #666;"/>