private function _postProcess() { Configuration::updateValue('WATERMARK_TYPES', implode(',', Tools::getValue('image_types'))); Configuration::updateValue('WATERMARK_Y_ALIGN', Tools::getValue('yalign')); Configuration::updateValue('WATERMARK_X_ALIGN', Tools::getValue('xalign')); Configuration::updateValue('WATERMARK_TRANSPARENCY', Tools::getValue('transparency')); //submited watermark if (isset($_FILES['PS_WATERMARK']) and !empty($_FILES['PS_WATERMARK']['tmp_name'])) { /* Check watermark validity */ if ($error = checkImage($_FILES['PS_WATERMARK'], $this->maxImageSize)) { $this->_errors[] = $error; } elseif (!copy($_FILES['PS_WATERMARK']['tmp_name'], dirname(__FILE__) . '/watermark.gif')) { $this->_errors[] = Tools::displayError('an error occurred while uploading watermark: ' . $_FILES['PS_WATERMARK']['tmp_name'] . ' to ' . $dest); } } if ($this->_errors) { foreach ($this->_errors as $error) { $this->_html .= '<div class="module_error alert error"><img src="../img/admin/warning.gif" alt="' . $this->l('ok') . '" /> ' . $this->l($error) . '</div>'; } } else { $this->_html .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="' . $this->l('ok') . '" /> ' . $this->l('Settings updated') . '</div>'; } }
/** * 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 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; }
function checkUpload($upload_name) { if(is_uploaded_file($_FILES[$upload_name]['tmp_name'])) { if(checkImage($upload_name)) { return true; }else{ return false; } }else{ return true; } }
public function postProcess() { if (Tools::isSubmit('submitStoreConf')) { if (isset($_FILES['store_img']) and isset($_FILES['store_img']['tmp_name']) and !empty($_FILES['store_img']['tmp_name'])) { if ($error = checkImage($_FILES['store_img'], 4000000)) { return $this->displayError($this->l('invalid image')); } else { if (!move_uploaded_file($_FILES['store_img']['tmp_name'], dirname(__FILE__) . '/' . $_FILES['store_img']['name'])) { return $this->displayError($this->l('an error occurred on uploading file')); } else { if (Configuration::get('BLOCKSTORE_IMG') != $_FILES['store_img']['name']) { @unlink(dirname(__FILE__) . '/' . Configuration::get('BLOCKSTORE_IMG')); } Configuration::updateValue('BLOCKSTORE_IMG', $_FILES['store_img']['name']); return $this->displayConfirmation($this->l('Settings are updated')); } } } } return ''; }
public function postProcess() { global $currentIndex; $errors = false; if (Tools::isSubmit('submitAdvConf')) { $file = false; if (isset($_FILES['adv_img']) and isset($_FILES['adv_img']['tmp_name']) and !empty($_FILES['adv_img']['tmp_name'])) { if ($error = checkImage($_FILES['adv_img'], 4000000)) { $errors .= $error; } elseif (!move_uploaded_file($_FILES['adv_img']['tmp_name'], dirname(__FILE__) . '/' . $this->adv_imgname)) { $errors .= $this->l('Error move uploaded file'); } $this->adv_img = _MODULE_DIR_ . $this->name . '/' . $this->adv_imgname; } if ($link = Tools::getValue('adv_link')) { Configuration::updateValue('BLOCKADVERT_LINK', $link); $this->adv_link = htmlentities($link, ENT_QUOTES, 'UTF-8'); } } if ($errors) { echo $this->displayError($errors); } }
public function addImage() { if (isset($_FILES['body_homepage_logo']) and isset($_FILES['body_homepage_logo']['tmp_name']) and !empty($_FILES['body_homepage_logo']['tmp_name'])) { $name = "homepage_logo_" . $this->id . "." . $this->extension(basename($_FILES['body_homepage_logo']['name'])); $name1 = "homepage_logo_" . $this->id; $t = 1; foreach (glob(dirname(__FILE__) . '/img/' . $name1 . '.*') as $fn) { $t *= unlink($fn); } if (!$t) { $this->errors .= Tools::displayError('An error occurred during the image upload.'); return false; } if ($error = checkImage($_FILES['body_homepage_logo'], $this->maxImageSize)) { $this->errors .= $error; return false; } elseif (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['body_homepage_logo']['tmp_name'], $tmpName)) { $this->errors .= Tools::displayError('An error occurred during the image upload.'); return false; } else { list($width, $height, $t, $s) = getimagesize($tmpName); $q1 = $this->maxImageWidth / $width; $q2 = $this->maxImageHeight / $height; if ($q1 > $q2 && $q1 < 1) { $t = imageResize($tmpName, dirname(__FILE__) . '/img/' . $name, $this->maxImageWidth, null); } elseif ($q2 < 1) { $t = imageResize($tmpName, dirname(__FILE__) . '/img/' . $name, null, $this->maxImageHeight); } else { $t = imageResize($tmpName, dirname(__FILE__) . '/img/' . $name, $this->maxImageWidth, $this->maxImageHeight); } if (!$t) { $this->errors .= Tools::displayError('An error occurred during the image upload.'); return false; } } if (isset($tmpName)) { unlink($tmpName); } if (file_exists(dirname(__FILE__) . '/img/' . $name)) { Db::getInstance()->ExecuteS('UPDATE `' . _DB_PREFIX_ . $this->table . '` set `body_home_logo`="' . $name . '" where id_editorial="' . $this->id . '"'); } } else { $this->errors .= Tools::displayError('The image cannot be uploaded.'); } }
<?php if ($urls && checkImage()) { $urls = str_replace("\r\n", "\n", $urls); $urls = explode("\n", $urls); $results = array(); foreach ($urls as $link) { $link = preg_match("#\\w+://#", $link) ? $link : "http://" . $link; $start = microtime(true); $content = @file_get_contents($link); if ($content === FALSE) { continue; } $result['domain'] = $link; $result['time'] = sprintf("%01.3f", microtime(true) - $start); $result['size'] = sprintf("%01.2f", strlen($content) / 1000); $result['average'] = sprintf("%01.3f", $result['time'] / $result['size']); $results[] = $result; } if ($results) { echo "<table cellpadding=\"3\" cellspacing=\"3\"><tr bgcolor=\"#E6E6E6\"><td>Size</td><td>Load time (secs)</td><td>Average speed per KB</td></tr>"; foreach ($results as $k => $r) { echo "<tr bgcolor=\"#FFEAEA\"><td align=\"center\">{$r['size']} KB</td><td align=\"center\">{$r['time']}</td><td align=\"center\">{$r['average']}</td></tr>"; } echo "</table>"; } } ?> </td> </tr>
/** * Write the posted image on disk * * @param string $receptionPath * @param int $destWidth * @param int $destHeight * @param array $imageTypes * @param string $parentPath * @return boolean */ private function writePostedImageOnDisk($receptionPath, $destWidth = null, $destHeight = null, $imageTypes = null, $parentPath = null) { if ($this->wsObject->method == 'PUT') { if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name']) { $file = $_FILES['image']; if ($file['size'] > $this->imgMaxUploadSize) { throw new WebserviceException(sprintf('The image size is too large (maximum allowed is %d KB)', $this->imgMaxUploadSize / 1000), array(72, 400)); } // Get mime content type $mime_type = false; if (Tools::isCallable('finfo_open')) { $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME; $finfo = finfo_open($const); $mime_type = finfo_file($finfo, $file['tmp_name']); finfo_close($finfo); } elseif (Tools::isCallable('mime_content_type')) { $mime_type = mime_content_type($file['tmp_name']); } elseif (Tools::isCallable('exec')) { $mime_type = trim(exec('file -b --mime-type ' . escapeshellarg($file['tmp_name']))); } if (empty($mime_type) || $mime_type == 'regular file') { $mime_type = $file['type']; } if (($pos = strpos($mime_type, ';')) !== false) { $mime_type = substr($mime_type, 0, $pos); } // Check mime content type if (!$mime_type || !in_array($mime_type, $this->acceptedImgMimeTypes)) { throw new WebserviceException('This type of image format not recognized, allowed formats are: ' . implode('", "', $this->acceptedImgMimeTypes), array(73, 400)); } elseif ($file['error']) { throw new WebserviceException('Error while uploading image. Please change your server\'s settings', array(74, 400)); } // Try to copy image file to a temporary file if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['image']['tmp_name'], $tmpName)) { throw new WebserviceException('Error while copying image to the temporary directory', array(75, 400)); } else { $result = $this->writeImageOnDisk($tmpName, $receptionPath, $destWidth, $destHeight, $imageTypes, $parentPath); } @unlink($tmpName); return $result; } else { throw new WebserviceException('Please set an "image" parameter with image data for value', array(76, 400)); } } elseif ($this->wsObject->method == 'POST') { if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name']) { $file = $_FILES['image']; if ($file['size'] > $this->imgMaxUploadSize) { throw new WebserviceException(sprintf('The image size is too large (maximum allowed is %d KB)', $this->imgMaxUploadSize / 1000), array(72, 400)); } require_once _PS_ROOT_DIR_ . '/images.inc.php'; if ($error = checkImageUploadError($file)) { throw new WebserviceException('Image upload error : ' . $error, array(76, 400)); } if (isset($file['tmp_name']) && $file['tmp_name'] != null) { if ($this->imageType == 'products') { $product = new Product((int) $this->wsObject->urlSegment[2]); if (!Validate::isLoadedObject($product)) { throw new WebserviceException('Product ' . (int) $this->wsObject->urlSegment[2] . ' doesn\'t exists', array(76, 400)); } $image = new Image(); $image->id_product = (int) $product->id; $image->position = Image::getHighestPosition($product->id) + 1; if (!$image->add()) { throw new WebserviceException('Error while creating image', array(76, 400)); } if (!Validate::isLoadedObject($product)) { throw new WebserviceException('Product ' . (int) $this->wsObject->urlSegment[2] . ' doesn\'t exists', array(76, 400)); } } // copy image if (!isset($file['tmp_name'])) { return false; } if ($error = checkImage($file, $this->imgMaxUploadSize)) { throw new WebserviceException('Bad image : ' . $error, array(76, 400)); } if ($this->imageType == 'products') { $image = new Image($image->id); if (!(Configuration::get('PS_OLD_FILESYSTEM') && file_exists(_PS_PROD_IMG_DIR_ . $product->id . '-' . $image->id . '.jpg'))) { $image->createImgFolder(); } if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($file['tmp_name'], $tmpName)) { throw new WebserviceException('An error occurred during the image upload', array(76, 400)); } elseif (!imageResize($tmpName, _PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '.' . $image->image_format)) { throw new WebserviceException('An error occurred while copying image', array(76, 400)); } else { $imagesTypes = ImageType::getImagesTypes('products'); foreach ($imagesTypes as $imageType) { if (!imageResize($tmpName, _PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '-' . stripslashes($imageType['name']) . '.' . $image->image_format, $imageType['width'], $imageType['height'], $image->image_format)) { $this->_errors[] = Tools::displayError('An error occurred while copying image:') . ' ' . stripslashes($imageType['name']); } } } @unlink($tmpName); $this->imgToDisplay = _PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '.' . $image->image_format; if (!isset($this->_errors) || !count($this->_errors)) { header('Location: ' . $this->wsObject->wsUrl . $this->wsObject->urlSegment[0] . '/products/' . $product->id . '/' . $image->id); die; } } elseif (isset($this->wsObject->urlSegment[1]) && in_array($this->wsObject->urlSegment[1], array('categories', 'manufacturers', 'suppliers', 'stores')) && isset($this->wsObject->urlSegment[2])) { if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($file['tmp_name'], $tmpName)) { throw new WebserviceException('An error occurred during the image upload', array(76, 400)); } elseif (!imageResize($tmpName, $receptionPath)) { throw new WebserviceException('An error occurred while copying image', array(76, 400)); } else { $imagesTypes = ImageType::getImagesTypes('categories'); foreach ($imagesTypes as $imageType) { if (!imageResize($tmpName, _PS_CAT_IMG_DIR_ . (int) $this->wsObject->urlSegment[2] . '-' . stripslashes($imageType['name']) . '.jpg', (int) $imageType['width'], (int) $imageType['height'])) { $this->_errors[] = Tools::displayError('An error occurred while copying image:') . ' ' . stripslashes($imageType['name']); } } } @unlink(_PS_TMP_IMG_DIR_ . $tmpName); $this->imgToDisplay = $receptionPath; } return true; } } } else { throw new WebserviceException('Method ' . $this->wsObject->method . ' is not allowed for an image resource', array(77, 405)); } }
public function getContent() { if (Tools::isSubmit('addNewSlide')) { $this->_createNewSlide(); } foreach ($this->kinkyslider_output_images as $slideToUpdate) { if (Tools::isSubmit($this->name . '_deleteslide_' . $slideToUpdate['kinky_id'])) { $this->_deleteSlide($slideToUpdate['kinky_id']); } } if (Tools::isSubmit('updateSlides')) { foreach ($this->kinkyslider_output_images as $slideToUpdate) { $_thisID = $slideToUpdate['kinky_id']; $_thisLink = $slideToUpdate['kinky_link']; $_thisImageDir = $slideToUpdate['kinky_imagedir']; $_thisHeader = $slideToUpdate['kinky_header']; $_thisPrice = $slideToUpdate['kinky_price']; $_thisOrder = $slideToUpdate['kinky_order']; $_thisActive = $slideToUpdate['kinky_active']; $_thisSlideIsChanged = false; /* Let's see if the user wanted to upload an image for this slide ID * If so, we'll create a new directory on the server, move the uploaded image there, * Scale the image to the width & height given in the configuration and * Then save it as JPEG image. */ if (isset($_FILES[$this->name . '_image' . $_thisID]) and isset($_FILES[$this->name . '_image' . $_thisID]['tmp_name']) and !empty($_FILES[$this->name . '_image' . $_thisID]['tmp_name'])) { if ($error = @checkImage($_FILES[$this->name . '_image' . $_thisID], 4000000)) { $this->_postErrors[] = $error; } else { $_last_picture_dir = $this->bazinga_last_dir('images'); $_numeric_last_picture_dir = (int) $_last_picture_dir; $_new_picture_dir = $_numeric_last_picture_dir + 1; $_target_path = dirname(__FILE__) . '/uploads/images/' . $_new_picture_dir . '/'; mkdir(str_replace('//', '/', $_target_path), 0755, true); if (move_uploaded_file($_FILES[$this->name . '_image' . $_thisID]['tmp_name'], $_target_path . KINKYSLIDER_DEFAULT_FILE_NAME . '.png')) { // $this->bazinga_load($_target_path.$_FILES[$this->name.'_image'.$_thisID]['name']); // $this->bazinga_resizeZoomCrop($this->kinkyslider_calculated_image_width,$this->kinkyslider_calculated_image_height); //$this->bazinga_save($_target_path.KINKYSLIDER_DEFAULT_FILE_NAME.'.png'); $_thisImageDir = $_new_picture_dir; $_thisSlideIsChanged = true; } } } if ($_checkUpdate = Tools::getValue($this->name . '_link' . $_thisID)) { $this->_linkValidation($_checkUpdate); if (!sizeof($this->_postErrors)) { $_thisLink = $_checkUpdate; $_thisSlideIsChanged = true; } } if ($_checkUpdate = Tools::getValue($this->name . '_order' . $_thisID)) { $this->_numericValidation($_checkUpdate, 'order'); if (!sizeof($this->_postErrors)) { $_thisOrder = $_checkUpdate; $_thisSlideIsChanged = true; } } if ($_checkUpdate = Tools::getValue($this->name . '_header' . $_thisID)) { $_thisHeader = strip_tags(nl2br2($_checkUpdate)); $_thisSlideIsChanged = true; } if ($_checkUpdate = Tools::getValue($this->name . '_price' . $_thisID)) { $_thisPrice = strip_tags(nl2br2($_checkUpdate)); $_thisSlideIsChanged = true; } if ($_checkUpdate = (int) Tools::getValue($this->name . '_active' . $_thisID)) { if ($_checkUpdate == 1 && $_thisActive == 0) { $_thisActive = 1; $_thisSlideIsChanged = true; } } elseif ((int) Tools::getValue($this->name . '_active' . $_thisID) != 1 && $_thisActive == 1) { $_thisActive = 0; $_thisSlideIsChanged = true; } if ($_thisSlideIsChanged == true) { $this->_updataSlide($_thisID, $_thisLink, $_thisImageDir, $_thisHeader, $_thisPrice, $_thisOrder, $_thisActive); } } /* end foreach */ if (!sizeof($this->_postErrors)) { $this->_html .= '<div class="conf confirm">' . $this->l('Ustawienia zostały zaktualizowane') . '</div>'; } else { foreach ($this->_postErrors as $err) { $this->_html .= '<div class="alert error">' . $err . '</div>'; } } } /*end isSubmit('updateSlider'); */ if (Tools::isSubmit('updateSettings')) { foreach ($this->kinkyslider_config as $configRowToUpdate) { if ($_checkUpdate = Tools::getValue($this->name . '_config_' . $configRowToUpdate['kinky_key'])) { switch ($configRowToUpdate['kinky_validation']) { case KINKYSLIDER_VALIDATION_STANDARD: break; case KINKYSLIDER_VALIDATION_NUMERIC: $this->_numericValidation($_checkUpdate, $configRowToUpdate['sml_key']); break; case KINKYSLIDER_VALIDATION_NUMERIC_OR_NONE: $this->_numericOrNoneValidation($_checkUpdate, $configRowToUpdate['kinky_label']); break; case KINKYSLIDER_VALIDATION_NUMERIC_OR_AUTO: $this->_numericOrAutoValidation($_checkUpdate, $configRowToUpdate['kinky_label']); break; } if (!sizeof($this->_postErrors)) { $_thisNewValue = strip_tags(nl2br2($_checkUpdate)); $this->_setConfigValue($configRowToUpdate['kinky_id'], $_thisNewValue); } } elseif (Tools::getValue($this->name . '_config_' . $configRowToUpdate['kinky_key']) == 0) { $_thisNewValue = 0; $this->_setConfigValue($configRowToUpdate['kinky_id'], $_thisNewValue); } } if (!sizeof($this->_postErrors)) { $this->_html .= '<div class="conf confirm">Your settings have been saved.</div>'; } else { foreach ($this->_postErrors as $err) { $this->_html .= '<div class="alert error">' . $err . '</div>'; } } } $this->_getSettings(); $this->_getSlideList(); $this->_displayForm(); return $this->_html; }
echo "\n <li> <a href='cars.php?c=" . $car['c_id'] . "'>" . $car['yr'] . " " . $car['brd'] . " " . $car['mdl'] . "</a><br> </li>\n "; } ?> </ul> </div> </div> <div class='sub mid main'> <?php if (isset($carID) && $idCheck == 1) { echo "\n <div class='return-to-list mobile'>\n <div class='left-arrow'></div>\n <a href='suppliers.php' class='return'> Return to list.</a>\n </div>\n "; } ?> <?php if (isset($carID) && $idCheck == 1) { $img_url = checkImage($carID, "../"); echo "\n <div class='item-details'>\n <h2>" . $car_yr . " " . $car_brd . " " . $car_mdl . "</h2>\n <p class='sub-heading'>" . $car_tran . " " . $car_mke . "</p>\n <img src='../assets/img/cars/" . $img_url . "' alt='Image of car' class='car-image'>\n <p class='details-heading'>Car Details:<p>\n <p class='sub-info'>Price: \$" . $car_price . "</p>\n <p class='sub-info'>Date Listed: " . $car_date . "</p>\n <p class='sub-info'>VIN: " . $car_vin . "</p>\n <p class='sub-info'>Registraion: " . $car_rego . "</p>\n <p class='sub-info'>Condition: " . $car_cond . "</p>\n <p class='sub-info'>Description: " . $car_desr . "</p>\n <p class='sub-info'>No of Views: " . $car_view . "</p>\n <p class='sub-info'>Supplied by: <a href='suppliers.php?s=" . $car_sup_id . "' class='sub-info link'>" . $car_sup_name . "</a> </p>\n </div>\n "; } elseif (isset($detailErr)) { echo "{$detailErr}"; } else { echo "\n <h2 class='desktop no-select-tip'>Please select an item from the left.</h2>\n <h2 class='mobile no-select-tip'>Please select an item from above.</h2>\n "; } ?> </div> <div class='sub right column'> <div class='tools'> <ul> <li> <button class='button create'>Add Car</button> </li> <?php if (isset($carID) && $idCheck == 1) {
checkImage($pdf, '11', $this->view->disp[$i][4], 7.1, 11); $pdf->Cell(3, 0.4, ' Bicarakan dengan saya', 0, 0, 'L'); //$pdf->Image('public/images/check20.png', 10.1, 11, 0.2, 0.2, 'PNG'); checkImage($pdf, '15', $this->view->disp[$i][4], 10.1, 11); $pdf->Cell(4, 0.4, ' Disiapkan', 'R', 1, 'L'); $pdf->Image('public/images/check20.png', 1.1, 11.4, 0.2, 0.2, 'PNG'); checkImage($pdf, '4', $this->view->disp[$i][4], 1.1, 11.4); $pdf->Cell(3, 0.4, ' Untuk diketahui', 'L', 0, 'L'); //$pdf->Image('public/images/check20.png', 4.1, 11.4, 0.2, 0.2, 'PNG'); checkImage($pdf, '8', $this->view->disp[$i][4], 4.1, 11.4); $pdf->Cell(3, 0.4, ' Edarkan', 0, 0, 'L'); //$pdf->Image('public/images/check20.png', 7.1, 11.4, 0.2, 0.2, 'PNG'); checkImage($pdf, '12', $this->view->disp[$i][4], 7.1, 11.4); $pdf->Cell(3, 0.4, ' Bicarakan bersama', 0, 0, 'L'); //$pdf->Image('public/images/check20.png', 10.1, 11.4, 0.2, 0.2, 'PNG'); checkImage($pdf, '16', $this->view->disp[$i][4], 10.1, 11.4); $pdf->Cell(4, 0.4, ' Harap dihadiri/diwakili', 'R', 1, 'L'); $pdf->Cell(13, 0.7, 'CATATAN KEPALA KANTOR :', 'RL', 1, 'L'); //$pdf->MultiCell(13, 0.1, $test, 1, 'J'); @$pdf->Cell(13, 0.4, '' . $this->view->disp[$i][5], 'RL', 1, 'L'); $pdf->Cell(13, 0.4, '', 'RL', 1, 'L'); $pdf->Cell(13, 0.4, '', 'RL', 1, 'L'); $pdf->Cell(13, 0, '', 0, 1, 'L'); $pdf->Cell(6.5, 0.4, 'Tgl Penyelesaian :', 'TL', 0, 'L'); $pdf->Cell(6.5, 0.4, 'Diajukan kembali tgl :', 'RTL', 1, 'L'); $pdf->Cell(6.5, 0.4, 'Penerima :', 'BL', 0, 'L'); $pdf->Cell(6.5, 0.4, 'Penerima :', 'RBL', 1, 'L'); $pdf->Cell(13, 0.7, 'DISPOSISI Kasubbag / Kasi :', 'RL', 1, 'L'); $pdf->Cell(13, 0.4, 'Kepada :', 'RL', 1, 'L'); $pdf->Cell(13, 0.4, 'Petunjuk :', 'RL', 1, 'L'); $pdf->Cell(13, 0.4, '', 'RL', 1, 'L');
/** * _postProcess() * Called upon successful module configuration validation */ private function _postProcess() { $output = ""; if (Tools::isSubmit('updateSubmit')) { $banners = Tools::getValue('blockadvertmultiId'); if ($banners and is_array($banners) and count($banners)) { foreach ($banners as $row) { $bnr = array(); $bnr['id'] = $row; $bnr['description'] = Tools::getValue('desc_' . $row); $bnr['image_link'] = Tools::getValue('link_' . $row); /* Patch by Madman */ if (isset($_FILES['banner_image_' . $row]) and isset($_FILES['banner_image_' . $row]['tmp_name']) and !empty($_FILES['banner_image_' . $row]['tmp_name'])) { $bnr['image_name'] = $_FILES['banner_image_' . $row]['name']; } else { $bnr['image_name'] = Tools::getValue('image_name_' . $row); } /* Patch by Madman */ // $bnr['image_name'] = Tools::getValue('image_name_'.$row); $bnr['block_id'] = Tools::getValue('block_' . $row); $bnr['order'] = Tools::getValue('order_' . $row); $bnr['blank'] = Tools::getValue('blank_' . $row) ? '1' : '0'; $bnr['active'] = Tools::getValue('active_' . $row) ? '1' : '0'; $bnr['rotate'] = Tools::getValue('rotate_' . $row) ? '1' : '0'; $bnrs[] = $bnr; /* Patch by Madman */ if (isset($_FILES['banner_image_' . $row]) and isset($_FILES['banner_image_' . $row]['tmp_name']) and !empty($_FILES['banner_image_' . $row]['tmp_name'])) { Configuration::set('PS_IMAGE_GENERATION_METHOD', 1); $name = $_FILES['banner_image_' . $row]['name']; $ext = strtolower(substr($name, strrpos($name, ".") + 1)); $path = $this->img_fpath . basename($_FILES['banner_image_' . $row]['name']); if (stripos('/png/gif/jpg/jpeg/bmp/', $ext) === false) { $errors .= $this->displayError($this->l('Incorrect file type.')); } if (_PS_VERSION_ < "1.5.4") { /* If version is less then 1.5.4 */ if ($error = checkImage($_FILES['banner_image_' . $row], $this->maxImageSize)) { $errors .= $this->displayError($error); } elseif (!move_uploaded_file($_FILES['banner_image_' . $row]['tmp_name'], $path)) { $errors .= $this->displayError($this->l('An error occurred during the image upload.')); } } else { /* 1.5.4x */ if ($error = ImageManager::validateUpload($_FILES['banner_image_' . $row], $this->maxImageSize)) { $errors .= $this->displayError($error); } elseif (!move_uploaded_file($_FILES['banner_image_' . $row]['tmp_name'], $path)) { $errors .= $this->displayError($this->l('An error occurred during the image upload.')); } } if (isset($errors) && $errors) { $errors .= $this->displayError($this->l('Error creating banner.')); } elseif (!$this->updateBanner($bnr)) { $errors .= $this->displayError($this->l('Error creating banner on database.')); } } else { $errors .= $this->displayError($this->l('An error occurred during the banner image update.')); } /* Patch by Madman */ } if ($this->saveBanners($bnrs)) { $output .= $this->displayConfirmation($this->l('Banners updated successfully.')); } else { $output .= $this->displayError($this->l('There were problems updating banners.')); } } } elseif (Tools::isSubmit('addSubmit')) { $bnr['description'] = Tools::getValue('banner_description'); $bnr['image_link'] = Tools::getValue('banner_link'); $bnr['image_name'] = $_FILES['banner_image']['name']; $bnr['block_id'] = Tools::getValue('banner_block_id'); $bnr['order'] = Tools::getValue('banner_order'); $bnr['blank'] = Tools::getValue('banner_blank') ? '1' : '0'; $bnr['active'] = Tools::getValue('banner_active') ? '1' : '0'; $bnr['rotate'] = Tools::getValue('banner_rotate') ? '1' : '0'; /* upload the image */ if (isset($_FILES['banner_image']) and isset($_FILES['banner_image']['tmp_name']) and !empty($_FILES['banner_image']['tmp_name'])) { Configuration::set('PS_IMAGE_GENERATION_METHOD', 1); $name = $_FILES['banner_image']['name']; $ext = strtolower(substr($name, strrpos($name, ".") + 1)); $path = $this->img_fpath . basename($_FILES['banner_image']['name']); if (stripos('/png/gif/jpg/jpeg/bmp/', $ext) === false) { $errors .= $this->displayError($this->l('Incorrect file type.')); } if (_PS_VERSION_ < "1.5.4") { /* If version is less then 1.5.4 */ if ($error = checkImage($_FILES['banner_image'], $this->maxImageSize)) { $errors .= $this->displayError($error); } elseif (!move_uploaded_file($_FILES['banner_image']['tmp_name'], $path)) { $errors .= $this->displayError($this->l('An error occurred during the image upload.')); } } else { /* 1.5.4x */ if ($error = ImageManager::validateUpload($_FILES['banner_image'], $this->maxImageSize)) { $errors .= $this->displayError($error); } elseif (!move_uploaded_file($_FILES['banner_image']['tmp_name'], $path)) { $errors .= $this->displayError($this->l('An error occurred during the image upload.')); } } if (isset($errors) && $errors) { $errors .= $this->displayError($this->l('Error creating banner.')); } elseif (!$this->addBanner($bnr)) { $errors .= $this->displayError($this->l('Error creating banner on database.')); } } else { $errors .= $this->displayError($this->l('An error occurred during the banner creation.')); } $output .= isset($errors) && $errors != '' ? $errors : $this->displayConfirmation($this->l('Banner added successfully.')); } elseif (Tools::isSubmit('deleteSubmit')) { $bnr = Tools::getValue('bannerDelete'); if ($this->deleteBanner($bnr)) { $output .= $this->displayConfirmation($this->l('Banner succesfully deleted.')); } else { $output .= $this->displayError($this->l('Problems deleting the banner.')); } } return $output; }
protected function postProcess() { $languages = Language::getLanguages(false); $default_language = Configuration::get('PS_LANG_DEFAULT'); $max_image_size = 2 * 1024 * 1024; // 2 Mb $errors = array(); $res = 1; for ($i = 1; $i < 6; $i++) { $image_name = $_FILES['images']['name'][$i]; if ($image_name != null) { $new_image_name = md5($image_name) . '.jpg'; $file = array(); $file['name'] = $_FILES['images']['name'][$i]; $file['tmp_name'] = $_FILES['images']['tmp_name'][$i]; $file['type'] = $_FILES['images']['type'][$i]; $file['error'] = $_FILES['images']['error'][$i]; $file['size'] = $_FILES['images']['size'][$i]; if ($error = checkImage($file, $max_image_size)) { $errors[] = $error; } elseif (!move_uploaded_file($file['tmp_name'], dirname(__FILE__) . '/img/' . $new_image_name)) { $errors[] = $this->l('An error occurred during the image upload.'); } if (!sizeof($errors)) { // Clear old rows $res &= $this->cleanDb($i); // New rows $res &= Db::getInstance()->Execute(' INSERT INTO `' . _DB_PREFIX_ . 'reinsurance` (`id_reinsurance`, `filename`) VALUES (\'' . (int) $i . '\', \'' . (isset($new_image_name) ? pSQL($new_image_name) : '') . '\') '); } } } foreach ($_POST['texts'] as $key => $text) { $res &= $this->cleanTxt($key); if ($text[$default_language] != null && Validate::isCleanHtml($text[$default_language])) { if (!sizeof($errors)) { foreach ($languages as $lang) { if ($text[$lang['id_lang']] == '' || !Validate::isCleanHtml($text[$lang['id_lang']])) { $text[$lang['id_lang']] = $text[$default_language]; } $res &= Db::getInstance()->Execute(' INSERT INTO `' . _DB_PREFIX_ . 'reinsurance_lang` (`id_reinsurance`, `id_lang`, `text`) VALUES (\'' . (int) $key . '\', \'' . (int) $lang['id_lang'] . '\', \'' . pSQL($text[$lang['id_lang']]) . '\') '); } if (!$res) { $errors[] = $this->l('An error occured on save'); } } } else { if ($key == 1) { $errors[] = $this->l('The block 1 is required'); } else { // check if another language aren't empty foreach ($text as $id_lang => $val) { if ($id_lang != $default_language) { if ($val != null) { $errors[] = $this->l('The text for the block number') . ' ' . $key . ' ' . $this->l('is incorrect, the default language information is required '); } } } } } } if (!sizeof($errors)) { $this->_html .= $this->displayConfirmation($this->l('Configuration updated')); } else { $this->_html .= $this->displayError(implode('<br />', $errors)); } }
function create_new_album($album, $albumai, $albumuri, $image, $date, $searched, $imagekey, $mbid, $domain) { global $mysqlc, $album_created; $retval = null; // See if the image needs to be archived. // This archives stuff that is currently in prefs/imagecache - // these have come from coverscraper/getAlbumCover for albums that are in the search or playlist. // We can't use images from prefs/imagecache because they will eventually get removed. if (preg_match('#^prefs/imagecache/#', $image)) { $image = preg_replace('#_small\\.jpg|_asdownloaded\\.jpg#', '', $image); system('cp ' . $image . '_small.jpg albumart/small/' . $imagekey . '.jpg'); system('cp ' . $image . '_asdownloaded.jpg albumart/asdownloaded/' . $imagekey . '.jpg'); $image = 'albumart/small/' . $imagekey . '.jpg'; } $i = checkImage($imagekey); if ($stmt = sql_prepare_query("INSERT INTO Albumtable (Albumname, AlbumArtistindex, AlbumUri, Year, Searched, ImgKey, " . "mbid, Domain, Image) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", $album, $albumai, $albumuri, $date, $i, $imagekey, $mbid, $domain, $image)) { $retval = $mysqlc->lastInsertId(); debuglog("Created Album " . $album . " with Albumindex " . $retval, "MYSQL", 7); $album_created = $retval; } return $retval; }
/** * 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; $languages = Language::getLanguages(); /* Check required fields */ foreach ($fields as $field => $values) { if (isset($values['required']) and $values['required']) { if ($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 ($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 (isset($_POST['submitGeneral' . $this->table])) { rewriteSettingsFile(isset($_POST['PS_BASE_URI']) ? $_POST['PS_BASE_URI'] : '', NULL, NULL); unset($this->_fieldsGeneral['PS_BASE_URI']); } elseif (isset($_POST['submitAppearance' . $this->table])) { 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 occured 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 ($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); } } }
/** * postProcess update configuration * @TODO adding alt and title attributes for <img> and <a> * @var string * @return void */ public function postProcess() { global $currentIndex; $errors = ''; if (Tools::isSubmit('submitDeleteImgConf')) { $this->_deleteCurrentImg(); } if (Tools::isSubmit('submitAdvConf')) { $file = false; if (isset($_FILES['adv_img']) and isset($_FILES['adv_img']['tmp_name']) and !empty($_FILES['adv_img']['tmp_name'])) { if ($error = checkImage($_FILES['adv_img'], 4000000)) { $errors .= $error; } elseif ($dot_pos = strrpos($_FILES['adv_img']['name'], '.')) { // __DIR__ exists since php 5.3 $current_dir = defined(__DIR__) ? __DIR__ : dirname(__FILE__); // as checkImage tell us it's a good image, we'll just copy the extension $ext = substr($_FILES['adv_img']['name'], $dot_pos + 1); $newname = $this->adv_imgname . '.' . $ext; $this->_deleteCurrentImg(); if (!move_uploaded_file($_FILES['adv_img']['tmp_name'], $current_dir . '/' . $newname)) { $errors .= $this->l('Error move uploaded file'); } Configuration::updateValue('BLOCKADVERT_IMG_EXT', $ext); $this->adv_img = Tools::getMediaServer($this->name) . _MODULE_DIR_ . $this->name . '/' . $this->adv_imgname . '.' . Configuration::get('BLOCKADVERT_IMG_EXT'); } } if ($link = Tools::getValue('adv_link')) { Configuration::updateValue('BLOCKADVERT_LINK', $link); $this->adv_link = htmlentities($link, ENT_QUOTES, 'UTF-8'); } } if ($errors) { echo $this->displayError($errors); } }
protected function uploadImage($id, $name, $dir, $ext = false) { if (isset($_FILES[$name]) && (int) $_FILES[$name]['error'] === 1) { $max_upload = (int) ini_get('upload_max_filesize'); $max_post = (int) ini_get('post_max_size'); $upload_mb = min($max_upload, $max_post); $this->_errors[] = $this->l('The file') . ' <b>' . $_FILES[$name]['name'] . '</b> ' . $this->l('exceeds the size allowed by the server, this limit is set to') . ' <b>' . $upload_mb . $this->l('Mb') . '</b>'; } elseif (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; }
/** * 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'])) { return false; } if ($error = checkImage($_FILES['image_product'], $this->maxImageSize)) { $this->_errors[] = $error; } else { $image = new Image($id_image); if (!(Configuration::get('PS_LEGACY_IMAGES') && file_exists(_PS_PROD_IMG_DIR_ . $id_product . '-' . $id_image . '.jpg'))) { $image->createImgFolder(); } if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['image_product']['tmp_name'], $tmpName)) { $this->_errors[] = Tools::displayError('An error occurred during the image upload'); } elseif (!imageResize($tmpName, _PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '.' . $image->image_format)) { $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_PROD_IMG_DIR_ . $image->getExistingImgPath() . '-' . stripslashes($imageType['name']) . '.' . $image->image_format, $imageType['width'], $imageType['height'], $image->image_format)) { $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)); } }
public function getContent() { global $cookie; /* display the module name */ $this->_html = '<h2>' . $this->displayName . '</h2>'; $errors = ''; // Delete logo image if (Tools::isSubmit('deleteImage')) { if (!file_exists(dirname(__FILE__) . '/homepage_logo.jpg')) { $errors .= $this->displayError($this->l('This action cannot be taken.')); } else { unlink(dirname(__FILE__) . '/homepage_logo.jpg'); Configuration::updateValue('EDITORIAL_IMAGE_DISABLE', 1); Tools::redirectAdmin('index.php?tab=AdminModules&configure=' . $this->name . '&token=' . Tools::getAdminToken('AdminModules' . (int) Tab::getIdFromClassName('AdminModules') . (int) $cookie->id_employee)); } $this->_html .= $errors; } /* update the editorial xml */ if (Tools::isSubmit('submitUpdate')) { // Forbidden key $forbidden = array('submitUpdate'); $editorial = new EditorialClass(1); $editorial->copyFromPost(); $editorial->update(); /* 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 (file_exists(dirname(__FILE__) . '/homepage_logo.jpg')) { unlink(dirname(__FILE__) . '/homepage_logo.jpg'); } 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.')); } if (isset($tmpName)) { unlink($tmpName); } } $this->_html .= $errors == '' ? $this->displayConfirmation($this->l('Settings updated successfully')) : $errors; if (file_exists(dirname(__FILE__) . '/homepage_logo.jpg')) { list($width, $height, $type, $attr) = getimagesize(dirname(__FILE__) . '/homepage_logo.jpg'); Configuration::updateValue('EDITORIAL_IMAGE_WIDTH', (int) round($width)); Configuration::updateValue('EDITORIAL_IMAGE_HEIGHT', (int) round($height)); Configuration::updateValue('EDITORIAL_IMAGE_DISABLE', 0); } } /* display the editorial's form */ $this->_displayForm(); return $this->_html; }
/** * 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); } } }
if (empty($_POST['title'])) { $errors[] = "title"; } else { $title = mysqli_real_escape_string($dbc, strip_tags($_POST['title'])); } // validate type if (isset($_POST['type']) && filter_var($_POST['type'], FILTER_VALIDATE_INT, array('min_range' => 1))) { $type_id = $_POST['type']; } else { $errors[] = 'type'; } // validate Image if (empty($_FILES['myImage']['name'])) { $errors[] = "myImage"; } else { $check = checkImage($_FILES['myImage']['name']); if (mysqli_num_rows($check) > 0) { $errors[] = 'existIMG'; } else { $myImage = $_FILES['myImage']['name']; } } // validate status if (isset($_POST['status'])) { $status = $_POST['status']; } else { $errors[] = 'status'; } if (empty($errors)) { // upload img $targetimg = '../images/gallery/' . $myImage;
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; }
function createEvent($date, $description, $type, $creator, $image) { if (($pathToImage = checkImage($image)) != false) { global $db; $a = $db->prepare('INSERT INTO events VALUES(null, ?, ?, ?, ?, ?)'); $a->execute(array($date, $description, $type, $creator, $pathToImage)); return true; } return false; }
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; }
/** * 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)); } }
/** * 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); } } }
/** * postProcess update configuration * @TODO adding alt and title attributes for <img> and <a> * @var string * @return void */ public function postProcess() { global $currentIndex; $errors = ''; if (Tools::isSubmit('submitDeleteImgConf')) { $this->_deleteCurrentImg(); } if (Tools::isSubmit('submitAdvConf')) { $file = false; if (isset($_FILES['adv_img']) and isset($_FILES['adv_img']['tmp_name']) and !empty($_FILES['adv_img']['tmp_name'])) { if ($error = checkImage($_FILES['adv_img'], Tools::convertBytes(ini_get('upload_max_filesize')))) { $errors .= $error; } elseif ($dot_pos = strrpos($_FILES['adv_img']['name'], '.')) { // as checkImage tell us it's a good image, we'll just copy the extension $this->_deleteCurrentImg(); $this->adv_imgname = 'advertising'; $ext = substr($_FILES['adv_img']['name'], $dot_pos + 1); $newname = 'advertising_custom'; if (!move_uploaded_file($_FILES['adv_img']['tmp_name'], _PS_MODULE_DIR_ . $this->name . '/' . $newname . '.' . $ext)) { $errors .= $this->l('Error move uploaded file'); } else { $this->adv_imgname = $newname; } Configuration::updateValue('BLOCKADVERT_IMG_EXT', $ext); $this->adv_img = Tools::getMediaServer($this->name) . _MODULE_DIR_ . $this->name . '/' . $this->adv_imgname . '.' . Configuration::get('BLOCKADVERT_IMG_EXT'); } } if ($link = Tools::getValue('adv_link')) { Configuration::updateValue('BLOCKADVERT_LINK', $link); $this->adv_link = htmlentities($link, ENT_QUOTES, 'UTF-8'); } if ($title = Tools::getValue('adv_title')) { Configuration::updateValue('BLOCKADVERT_TITLE', $title); $this->adv_title = htmlentities($title, ENT_QUOTES, 'UTF-8'); } } if ($errors) { echo $this->displayError($errors); } }
</form></center>'; break; case 'sepia': $image = imagecreatefromgif($target_file); imagefilter($image, IMG_FILTER_GRAYSCALE); imagefilter($image, IMG_FILTER_COLORIZE, 100, 50, 0); imagegif($image, 'uploads/sepia_100_50_0_' . $filename); imagedestroy($image); checkImage('uploads/sepia_100_50_0_' . $filename); echo '<br><center><form action="upload.php" method="POST"> <input type="submit" name="try_another_filter" value="Try Another Filter" /> <input type="hidden" name="image_file" value=uploads/sepia_100_50_0_' . $filename . ' /> </form></center>'; break; default: checkImage($target_file); echo '<br><center><form action="upload.php" method="POST"> <input type="submit" name="try_another_filter" value="Try Another Filter" /> </form></center>'; break; } } } } list($width_original, $height_original) = getimagesize($target_file); // Prints out the correct size of the image function checkImage($target_file) { global $width_original, $height_original; if ($width_original > 1024 && $height_original > 768) { $width = 1024;