DatetimeWrapper::setTimezone(DatetimeWrapper::getTimezone()); $deal = $this->deal; $merchant = $deal->merchant; //------- to set the meta data and page title for SEO $document = JFactory::getDocument(); $document->setMetadata('Keywords', $deal->name); $version = new JVersion(); $joomla = $version->getShortVersion(); if (substr($joomla, 0, 3) >= 1.6) { $document = JFactory::getDocument(); $document->setTitle($deal->name); } else { $mainframe->setPageTitle($deal->name); } // load the deal image size $dealImageSize = EnmasseHelper::getDealImageSize(); if (!empty($dealImageSize)) { $image_height = $dealImageSize->image_height; $image_width = $dealImageSize->image_width; } else { $image_height = 252; $image_width = 400; } //contruct deal image url $imageUrlArr = array(); if (EnmasseHelper::is_urlEncoded($deal->pic_dir)) { $imageUrlArr = unserialize(urldecode($deal->pic_dir)); } else { $imageUrlArr[0] = $deal->pic_dir; } //contruct data for social network sharing
function upload() { global $mainframe; $version = new JVersion(); $joomla = $version->getShortVersion(); if (substr($joomla, 0, 3) >= '1.6') { $mainframe = JFactory::getApplication(); } $fileArr = JRequest::getVar('Filedata', '', 'files', 'array'); $folder = JRequest::getVar('folder', '', '', 'path'); $format = JRequest::getVar('format', 'html', '', 'cmd'); $return = JRequest::getVar('return-url', null, 'post', 'base64'); $parentId = JRequest::getVar('parentId'); $err = null; //------------------------------ // to get the image size from seeting table $dealImageSize = EnmasseHelper::getDealImageSize(); if (!empty($dealImageSize)) { $image_height = $dealImageSize->image_height; $image_width = $dealImageSize->image_width; } else { $image_height = 252; $image_width = 400; } for ($i = 0; $i < count($fileArr['name']); $i++) { $file[$i]['name'] = $fileArr['name'][$i]; $file[$i]['type'] = $fileArr['type'][$i]; $file[$i]['tmp_name'] = $fileArr['tmp_name'][$i]; $file[$i]['error'] = $fileArr['error'][$i]; $file[$i]['size'] = $fileArr['size'][$i]; } // Set FTP credentials, if given jimport('joomla.client.helper'); JClientHelper::setCredentialsFromRequest('ftp'); // Make the filename safe jimport('joomla.filesystem.file'); $random = rand(); for ($count = 0; $count < count($file); $count++) { $file[$count]['name'] = JFile::makeSafe($file[$count]['name']); if (isset($file[$count]['name'])) { $filepath = JPath::clean(JPATH_SITE . DS . 'components' . DS . 'com_enmasse' . DS . 'upload' . DS . strtolower($random . '-' . $count . '-' . $file[$count]['name'])); $imagepath = JPath::clean('components' . DS . 'com_enmasse' . DS . 'upload' . DS . strtolower($random . '-' . $count . '-' . $file[$count]['name'])); $imagePathArr[$count] = $imagepath; if (!MediaHelper::canUpload($file[$count], $err)) { if ($format == 'json') { jimport('joomla.error.log'); $log =& JLog::getInstance('upload.error.php'); $log->addEntry(array('comment' => 'Invalid: ' . $filepath . ': ' . $err)); header('HTTP/1.0 415 Unsupported Media Type'); jexit('Error. Unsupported Media Type!'); } else { JError::raiseNotice(100, JText::_($err)); // REDIRECT if ($return) { $mainframe->redirect(base64_decode($return) . '&folder=' . $folder . '&parentId=' . $parentId); } return; } } $image = $file[$count]["name"]; $uploadedfile = $file[$count]['tmp_name']; $filename = stripslashes($file[$count]['name']); $extension = $this->getExtension($filename); $extension = strtolower($extension); $size = filesize($file[$count]['tmp_name']); if ($extension == "jpg" || $extension == "jpeg") { $uploadedfile = $file[$count]['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); } else { if ($extension == "png") { $uploadedfile = $file[$count]['tmp_name']; $src = imagecreatefrompng($uploadedfile); } } list($width, $height) = getimagesize($uploadedfile); $newwidth = 60; $newheight = $height / $width * $newwidth; $tmp = imagecreatetruecolor($newwidth, $newheight); $newwidth1 = $image_width; $newheight1 = $image_height; $tmp1 = imagecreatetruecolor($newwidth1, $newheight1); imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagecopyresampled($tmp1, $src, 0, 0, 0, 0, $newwidth1, $newheight1, $width, $height); $filename = $filepath; $filename1 = $filepath; imagejpeg($tmp, $filename, 100); imagejpeg($tmp1, $filename1, 100); imagedestroy($src); imagedestroy($tmp); imagedestroy($tmp1); if ($count == count($file) - 1) { $mainframe->redirect(base64_decode($return) . '&folder=' . urlencode(serialize($imagePathArr)) . '&parentId=' . $parentId); } } else { $mainframe->redirect('index.php', 'Invalid Request', 'error'); } } //$mainframe->redirect(base64_decode($return).'&folder='.$imagepath.'&parentId='.$parentId); }