public function placeOver(Image $background, $posX, $posY) { $background->open(); $this->open(); imagecopy($background->getResource(), $this->getResource(), $posX, $posY, 0, 0, $this->getWidth(), $this->getHeight()); $filepath = $background->getFilepath(); return $this->_writeImageToDisk($filepath, $background->getResource(), $background->getType()); }
/** * file agregator * * adds a file to an ad * * @param mixed $file * @param mixed $target a blank parameter in which the * target file witll be written * @access public * @return Boolean */ public function add($file, &$target) { $target = $this->_generateFilename($file); $up_pic = self::target($target); $up_thm = self::target($target, true); $stored = $this->uploaded_and_stored($file, $up_pic); // do not create thumbnails if file is not supported (pdf) if (Image::isValidType(Image::getType($up_pic))) { Image::thumbnail($up_pic, $up_thm, 333); } return !Image::isError() && $stored; }
/** * Upload Image from POST * * @param array $file - Part of $_FILES like $_FILES['photo'] * @param string $fileName - Put image with this filename * @param Config $imageUploaderConfig * @throws RuntimeException * @throws InvalidArgumentException * @throws ImageException * @throws ImageUploaderException * @return Image */ public static function upload($file, $fileName = null, Config $imageUploaderConfig = null) { $imageUploaderConfig = ConfigManager::mergeConfigs($imageUploaderConfig, ConfigManager::getConfig("Image", "ImageUploader")->AuxConfig); $uploadDir = $imageUploaderConfig->uploadDir; if (empty($uploadDir)) { throw new RuntimeException("Unable to get any appropriate uploadDir!"); } if (!file_exists($uploadDir)) { throw new InvalidArgumentException("Upload directory {$uploadDir} doesn't exists."); } ensurePathLastSlash($uploadDir); if (!in_array($file["type"], $imageUploaderConfig->acceptedMimeTypes->toArray())) { throw new ImageException("Unsupported file uploaded!"); } // Check if we have enough memory to open this file as image $info = getimagesize($file['tmp_name']); if ($info != false && !Image::checkMemAvailbleForResize($info[0], $info[1])) { throw new ImageUploaderException("Not enough memory to open image", static::EXCEPTION_IMAGE_IS_BIG); } // Check if we are able to create image resource from this file. $image = new Image($file['tmp_name']); $format = null; if (isset($imageUploaderConfig->saveFormat) and $imageUploaderConfig->saveFormat != null) { $format = $imageUploaderConfig->saveFormat; } else { $format = $image->getType(); } if ($fileName === null) { $fileName = static::findNewFileName($uploadDir, $format); } $savePath = $uploadDir . $fileName; if (isset($imageUploaderConfig->minimumSize)) { $checkResult = $image->isSizeMeetRequirements($imageUploaderConfig->minimumSize->largeSideMinSize, $imageUploaderConfig->minimumSize->smallSideMinSize); if (!$checkResult) { throw new ImageUploaderException("Given image is smaller than specified minimum size.", static::EXCEPTION_IMAGE_IS_SMALL); } } switch ($format) { case Image::IMAGE_TYPE_JPEG: $image->writeJpeg($savePath); break; case Image::IMAGE_TYPE_PNG: $image->writePng($savePath); break; case Image::IMAGE_TYPE_GIF: $image->writeGif($savePath); break; } return $image; }
/** * Generate image cache and return resulting path * * @param string $folderName * @param Image $image * @param boolean $forceGenerate * @throws InvalidArgumentException * @throws RuntimeException * @return string */ public function generateImageCache($folderName, Image $image, $forceGenerate = false) { if (!in_array($folderName, $this->config->folders->toArray())) { throw new InvalidArgumentException("There is no such folder defined with name {$folderName}!"); } if (!file_exists($this->config->cacheDir . $folderName)) { throw new RuntimeException("There is no such folder {$folderName} in cache directory!"); } $resultingFilePath = $this->config->cacheDir . $folderName . "/" . $image->fileName; if ($forceGenerate or !file_exists($resultingFilePath)) { switch ($image->getType()) { case Image::IMAGE_TYPE_JPEG: $image->writeJpeg($resultingFilePath); break; case Image::IMAGE_TYPE_GIF: $image->writeGif($resultingFilePath); break; case Image::IMAGE_TYPE_PNG: $image->writePng($resultingFilePath); break; } } return $resultingFilePath; }
/** * Add a group */ public function add($params) { $this->setView('add.php'); $this->setTitle(__('GROUP_ADD_TITLE')); $is_logged = isset(User_Model::$auth_data); $is_admin = $is_logged && User_Model::$auth_data['admin'] == '1'; // Authorization if (!$is_admin) { throw new ActionException('Page', 'error404'); } $group = array(); // Saving data if (isset($_POST['name']) && isset($_POST['creation_date']) && isset($_POST['mail']) && isset($_POST['description'])) { $uploaded_files = array(); try { // Members $members = array(); if (isset($_POST['members_ids']) && is_array($_POST['members_ids'])) { foreach ($_POST['members_ids'] as $id) { if (ctype_digit($id)) { $id = (int) $id; $members[$id] = array('title' => isset($_POST['member_title_' . $id]) ? $_POST['member_title_' . $id] : '', 'admin' => isset($_POST['member_admin_' . $id])); } } } // Other info $data = array('name' => $_POST['name'], 'creation_date' => $_POST['creation_date'], 'mail' => $_POST['mail'], 'description' => $_POST['description'], 'members' => $members); // Avatar if (isset($_FILES['avatar']) && !is_array($_FILES['avatar']['name'])) { if ($_FILES['avatar']['size'] > Config::UPLOAD_MAX_SIZE_PHOTO) { throw new FormException('avatar'); } if ($avatarpath = File::upload('avatar')) { $uploaded_files[] = $avatarpath; try { $img = new Image(); $img->load($avatarpath); $type = $img->getType(); if ($type == IMAGETYPE_JPEG) { $ext = 'jpg'; } else { if ($type == IMAGETYPE_GIF) { $ext = 'gif'; } else { if ($type == IMAGETYPE_PNG) { $ext = 'png'; } else { throw new Exception(); } } } if ($img->getWidth() > 800) { $img->setWidth(800, true); } $img->setType(IMAGETYPE_JPEG); $img->save($avatarpath); // Thumb $avatarthumbpath = $avatarpath . '.thumb'; $img->thumb(Config::$AVATARS_THUMBS_SIZES[0], Config::$AVATARS_THUMBS_SIZES[1]); $img->setType(IMAGETYPE_JPEG); $img->save($avatarthumbpath); unset($img); $uploaded_files[] = $avatarthumbpath; $data['avatar_path'] = $avatarthumbpath; $data['avatar_big_path'] = $avatarpath; } catch (Exception $e) { throw new FormException('avatar'); } } } $url_name = $this->model->create($data); Routes::redirect('group', array('group' => $url_name)); } catch (FormException $e) { foreach ($uploaded_files as $uploaded_file) { File::delete($uploaded_file); } foreach ($data as $key => $value) { $group[$key] = $value; } $group['members'] = Student_Model::getInfoByUsersIds(array_keys($members)); foreach ($group['members'] as &$member) { if (isset($members[(int) $member['user_id']])) { $member['title'] = $members[(int) $member['user_id']]['title']; $member['admin'] = $members[(int) $member['user_id']]['admin'] ? '1' : '0'; } } $this->set('form_error', $e->getError()); } } $this->set('group', $group); $this->addJSCode('Group.initEdit();'); }
/** * Add a post */ public function iframe_add() { $this->setView('iframe_add.php'); @set_time_limit(0); $uploaded_files = array(); try { if (!isset(User_Model::$auth_data)) { throw new Exception(__('POST_ADD_ERROR_SESSION_EXPIRED')); } $is_student = isset(User_Model::$auth_data['student_number']); // Message $message = isset($_POST['message']) ? trim($_POST['message']) : ''; if ($message == '' || $message == __('PUBLISH_DEFAULT_MESSAGE')) { throw new Exception(__('POST_ADD_ERROR_NO_MESSAGE')); } $message = preg_replace('#\\n{2,}#', "\n\n", $message); // Category if (!isset($_POST['category']) || !ctype_digit($_POST['category'])) { throw new Exception(__('POST_ADD_ERROR_NO_CATEGORY')); } $category = (int) $_POST['category']; // Official post (in a group) $official = isset($_POST['official']); // Group $group = isset($_POST['group']) && ctype_digit($_POST['group']) ? (int) $_POST['group'] : 0; if ($group == 0) { $group = null; $official = false; } else { $groups_auth = Group_Model::getAuth(); if (isset($groups_auth[$group])) { if ($official && !$groups_auth[$group]['admin']) { throw new Exception(__('POST_ADD_ERROR_OFFICIAL')); } } else { throw new Exception(__('POST_ADD_ERROR_GROUP_NOT_FOUND')); } } // Private message $private = isset($_POST['private']); if ($private && !$is_student) { throw new Exception(__('POST_ADD_ERROR_PRIVATE')); } $attachments = array(); // Photos if (isset($_FILES['attachment_photo']) && is_array($_FILES['attachment_photo']['name'])) { foreach ($_FILES['attachment_photo']['size'] as $size) { if ($size > Config::UPLOAD_MAX_SIZE_PHOTO) { throw new Exception(__('POST_ADD_ERROR_PHOTO_SIZE', array('size' => File::humanReadableSize(Config::UPLOAD_MAX_SIZE_PHOTO)))); } } if ($filepaths = File::upload('attachment_photo')) { foreach ($filepaths as $filepath) { $uploaded_files[] = $filepath; } foreach ($filepaths as $i => $filepath) { $name = isset($_FILES['attachment_photo']['name'][$i]) ? $_FILES['attachment_photo']['name'][$i] : ''; try { $img = new Image(); $img->load($filepath); $type = $img->getType(); if ($type == IMAGETYPE_JPEG) { $ext = 'jpg'; } else { if ($type == IMAGETYPE_GIF) { $ext = 'gif'; } else { if ($type == IMAGETYPE_PNG) { $ext = 'png'; } else { throw new Exception(); } } } if ($img->getWidth() > 800) { $img->setWidth(800, true); } $img->save($filepath); // Thumb $thumbpath = $filepath . '.thumb'; $img->thumb(Config::$THUMBS_SIZES[0], Config::$THUMBS_SIZES[1]); $img->setType(IMAGETYPE_JPEG); $img->save($thumbpath); unset($img); $attachments[] = array($filepath, $name, $thumbpath); $uploaded_files[] = $thumbpath; } catch (Exception $e) { throw new Exception(__('POST_ADD_ERROR_PHOTO_FORMAT')); } } } } // Vidéos /* @uses PHPVideoToolkit : http://code.google.com/p/phpvideotoolkit/ * @requires ffmpeg, php5-ffmpeg */ if (isset($_FILES['attachment_video']) && is_array($_FILES['attachment_video']['name'])) { foreach ($_FILES['attachment_video']['size'] as $size) { if ($size > Config::UPLOAD_MAX_SIZE_VIDEO) { throw new Exception(__('POST_ADD_ERROR_VIDEO_SIZE', array('size' => File::humanReadableSize(Config::UPLOAD_MAX_SIZE_VIDEO)))); } } if ($filepaths = File::upload('attachment_video')) { foreach ($filepaths as $filepath) { $uploaded_files[] = $filepath; } foreach ($filepaths as $i => $filepath) { $name = isset($_FILES['attachment_video']['name'][$i]) ? $_FILES['attachment_video']['name'][$i] : ''; try { $video = new ffmpeg_movie($filepath, false); if (!$video->hasVideo()) { throw new Exception('No video stream found in the file'); } if (!$video->hasAudio()) { throw new Exception('No audio stream found in the file'); } } catch (Exception $e) { throw new Exception(__('POST_ADD_ERROR_VIDEO_FORMAT')); } // Video conversion try { $video_current_width = $video->getFrameWidth(); $video_width = min($video_current_width, Config::VIDEO_MAX_WIDTH); if ($video_width % 2 == 1) { // Even number required $video_width--; } $video_height = $video_width * $video->getFrameHeight() / $video_current_width; if ($video_height % 2 == 1) { // Even number required $video_height--; } // Extract thumb $video_thumb = $video->getFrame(round($video->getFrameCount() * 0.2)); unset($video); $video_thumb = $video_thumb->toGDImage(); $thumbpath = DATA_DIR . Config::DIR_DATA_TMP . File::getName($filepath) . '.thumb'; imagejpeg($video_thumb, $thumbpath, 95); unset($video_thumb); $img = new Image(); $img->load($thumbpath); $img->setWidth($video_width, true); $img->setType(IMAGETYPE_JPEG); $img->save($thumbpath); $uploaded_files[] = $thumbpath; unset($img); // Convert to FLV if (!preg_match('#\\.flv$#i', $filepath)) { $toolkit = new PHPVideoToolkit(); $toolkit->on_error_die = true; // Will throw exception on error $toolkit->setInputFile($filepath); $toolkit->setVideoOutputDimensions($video_width, $video_height); $toolkit->setFormatToFLV(Config::VIDEO_SAMPLING_RATE, Config::VIDEO_AUDIO_BIT_RATE); $toolkit->setOutput(DATA_DIR . Config::DIR_DATA_TMP, File::getName($filepath) . '.flv', PHPVideoToolkit::OVERWRITE_EXISTING); $toolkit->execute(false, false); // Multipass: false, Log: false File::delete($filepath); $filepath = $toolkit->getLastOutput(); $filepath = $filepath[0]; unset($toolkit); } $attachments[] = array($filepath, $name, $thumbpath); $uploaded_files[] = $filepath; } catch (Exception $e) { throw new Exception(__('POST_ADD_ERROR_VIDEO_CONVERT') . $e->getMessage()); } } } } // Audios if (isset($_FILES['attachment_audio']) && is_array($_FILES['attachment_audio']['name'])) { foreach ($_FILES['attachment_audio']['size'] as $size) { if ($size > Config::UPLOAD_MAX_SIZE_AUDIO) { throw new Exception(__('POST_ADD_ERROR_AUDIO_SIZE', array('size' => File::humanReadableSize(Config::UPLOAD_MAX_SIZE_AUDIO)))); } } if ($filepaths = File::upload('attachment_audio')) { foreach ($filepaths as $filepath) { $uploaded_files[] = $filepath; } foreach ($filepaths as $i => $filepath) { if (!preg_match('#\\.mp3$#', $filepath)) { throw new Exception(__('POST_ADD_ERROR_AUDIO_FORMAT')); } $name = isset($_FILES['attachment_audio']['name'][$i]) ? $_FILES['attachment_audio']['name'][$i] : ''; $attachments[] = array($filepath, $name); } } } // Files if (isset($_FILES['attachment_file']) && is_array($_FILES['attachment_file']['name'])) { foreach ($_FILES['attachment_file']['size'] as $size) { if ($size > Config::UPLOAD_MAX_SIZE_FILE) { throw new Exception(__('POST_ADD_ERROR_FILE_SIZE', array('size' => File::humanReadableSize(Config::UPLOAD_MAX_SIZE_FILE)))); } } if ($filepaths = File::upload('attachment_file')) { foreach ($filepaths as $filepath) { $uploaded_files[] = $filepath; } foreach ($filepaths as $i => $filepath) { if (!preg_match('#\\.[a-z0-9]{2,4}$#i', $filepath)) { throw new Exception(__('POST_ADD_ERROR_FILE_FORMAT')); } if (preg_match('#\\.(jpg|png|gif|mp3|flv)$#i', $filepath)) { throw new Exception(__('POST_ADD_ERROR_FILE_FORMAT2')); } $name = isset($_FILES['attachment_file']['name'][$i]) ? $_FILES['attachment_file']['name'][$i] : ''; $attachments[] = array($filepath, $name); } } } // Event if (isset($_POST['event_title']) && isset($_POST['event_start']) && isset($_POST['event_end'])) { // Title $event_title = trim($_POST['event_title']); if ($event_title == '') { throw new Exception(__('POST_ADD_ERROR_EVENT_NO_TITLE')); } // Dates if (!($event_start = strptime($_POST['event_start'], __('PUBLISH_EVENT_DATE_FORMAT')))) { throw new Exception(__('POST_ADD_ERROR_EVENT_DATE')); } if (!($event_end = strptime($_POST['event_end'], __('PUBLISH_EVENT_DATE_FORMAT')))) { throw new Exception(__('POST_ADD_ERROR_EVENT_DATE')); } $event_start = mktime($event_start['tm_hour'], $event_start['tm_min'], 0, $event_start['tm_mon'] + 1, $event_start['tm_mday'], $event_start['tm_year'] + 1900); $event_end = mktime($event_end['tm_hour'], $event_end['tm_min'], 0, $event_end['tm_mon'] + 1, $event_end['tm_mday'], $event_end['tm_year'] + 1900); if ($event_start > $event_end) { throw new Exception(__('POST_ADD_ERROR_EVENT_DATE_ORDER')); } $event = array($event_title, $event_start, $event_end); } else { $event = null; } // Survey if (isset($_POST['survey_question']) && isset($_POST['survey_end']) && isset($_POST['survey_answer']) && is_array($_POST['survey_answer'])) { // Question $survey_question = trim($_POST['survey_question']); if ($survey_question == '') { throw new Exception(__('POST_ADD_ERROR_SURVEY_NO_QUESTION')); } // Date if (!($survey_end = strptime($_POST['survey_end'], __('PUBLISH_EVENT_DATE_FORMAT')))) { throw new Exception(__('POST_ADD_ERROR_SURVEY_DATE')); } $survey_end = mktime($survey_end['tm_hour'], $survey_end['tm_min'], 0, $survey_end['tm_mon'] + 1, $survey_end['tm_mday'], $survey_end['tm_year'] + 1900); // Multiple answers $survey_multiple = isset($_POST['survey_multiple']); // Answers $survey_answers = array(); foreach ($_POST['survey_answer'] as $survey_answer) { $survey_answer = trim($survey_answer); if ($survey_answer != '') { $survey_answers[] = $survey_answer; } } if (count($survey_answers) < 2) { throw new Exception(__('POST_ADD_ERROR_SURVEY_ANSWERS')); } $survey = array($survey_question, $survey_end, $survey_multiple, $survey_answers); } else { $survey = null; } // Creation of the post $id = $this->model->addPost((int) User_Model::$auth_data['id'], $message, $category, $group, $official, $private); // Attach files foreach ($attachments as $attachment) { $this->model->attachFile($id, $attachment[0], $attachment[1], isset($attachment[2]) ? $attachment[2] : null); } // Event if (isset($event)) { $this->model->attachEvent($id, $event[0], $event[1], $event[2]); } // Survey if (isset($survey)) { $this->model->attachSurvey($id, $survey[0], $survey[1], $survey[2], $survey[3]); } $this->addJSCode(' parent.location = "' . Config::URL_ROOT . Routes::getPage('home') . '"; '); } catch (Exception $e) { // Delete all uploading files in tmp foreach ($uploaded_files as $uploaded_file) { File::delete($uploaded_file); } $this->addJSCode(' with(parent){ Post.errorForm(' . json_encode($e->getMessage()) . '); } '); } }
private function createAndUploadImageDimensionMap(Image $image, $dimensionsKeyname) { $imd = $this->getDimensionByKeyname($dimensionsKeyname); $srcPth = $this->imagesRoot . $image->FilePath; if (file_exists($srcPth)) { $tempPath = tempnam(sys_get_temp_dir(), 'img_'); if ($dimensionsKeyname == 'original') { $s3Path = $srcPth; $pts = getimagesize($s3Path); $width = $pts[0]; $height = $pts[1]; $newDims = array('x' => $width, 'y' => $height); $s3Path = $srcPth; } else { //need to redimension this image, using MagickWand $magick_wand = NewMagickWand(); MagickReadImage($magick_wand, $srcPth); $width = MagickGetImageWidth($magick_wand); $height = MagickGetImageHeight($magick_wand); $newDims = $this->getNewDimensionsPreservingAspectRatio($width, $height, $imd->Width, $imd->Height); MagickScaleImage($magick_wand, $newDims['x'], $newDims['y']); MagickWriteImage($magick_wand, $tempPath); $s3Path = $tempPath; } $headers = array(); //This holds the http headers for our S3 object. switch ($image->ImageType) { case 'GIF': $headers['Content-Type'] = 'image/gif'; break; case 'JPG': $headers['Content-Type'] = 'image/jpeg'; break; case 'PNG': $headers['Content-Type'] = 'image/png'; break; default: throw new Exception("Unrecognized type {$image->getType()}"); break; } //A "Far Future" expiration - maximizing the chance that the user's web browser will use //a cached version rather than requesting the file from Cloudfront. //Also set to public (as recommended by Google Speed Tracer), so that caching will work when //using SSL as well. Even though Cloudfont doesn't support ssl today, someday it will //and we will be prepared! $headers['Cache-Control'] = 'public, max-age=315360000'; //10 years $imDimMap = new ImageDimensionsMap(); $imDimMap->ImageId = $image->Id; $imDimMap->ImageDimensionsId = $imd->Id; $imDimMap->Width = $newDims['x']; $imDimMap->Height = $newDims['y']; $imDimMap->Version = $image->Version; $imDimMap->save(); //upload the new file to S3 try { $acl = S3Service::ACL_PUBLIC_READ; if (!file_exists($tempPath)) { throw new Exception("{$tempPath} dosn't exist"); } $res = $this->s3->putObject(S3Service::inputFile($s3Path, true), $this->bucket, $this->getPath($image, $imDimMap, $imd), $acl, array(), $headers); if ($res) { unlink($tempPath); } else { //something's wrong. Fail silently and just leave the old version if it exists. //Don't throw an exception or raise a failure, because there's a user on the other side //of this request waiting to see this image. $imDimMap->Version = $imDimMap->Version - 1; $imDimMap->save(); } } catch (Exception $e) { //something's wrong. Fail silently and just leave the old version if it exist. //Don't throw an exception or raise a failure, because there's a user on the other side //of this request waiting to see this image. $imDimMap->Version = $imDimMap->Version - 1; $imDimMap->save(); } } return $imDimMap; }
/** * Edit a user */ public function edit($params) { $this->setView('edit.php'); $is_logged = isset(User_Model::$auth_data); $is_admin = $is_logged && User_Model::$auth_data['admin'] == '1'; // Authorization if (!$is_admin) { throw new ActionException('Page', 'error404'); } try { $student = $this->model->getInfo($params['username']); } catch (Exception $e) { throw new ActionException('Page', 'error404'); } $this->setTitle(__('STUDENT_EDIT_TITLE', array('username' => $student['username']))); // Birthday $student['birthday'] = date(__('USER_EDIT_FORM_BIRTHDAY_FORMAT'), strtotime($student['birthday'])); // Saving data if (isset($_POST['mail']) && isset($_POST['msn']) && isset($_POST['jabber']) && isset($_POST['address']) && isset($_POST['zipcode']) && isset($_POST['city']) && isset($_POST['cellphone']) && isset($_POST['phone']) && isset($_POST['birthday']) && isset($_POST['firstname']) && isset($_POST['lastname']) && isset($_POST['student_number']) && isset($_POST['promo'])) { $uploaded_files = array(); try { // Other info $user_data = array('mail' => $_POST['mail'], 'msn' => $_POST['msn'], 'jabber' => $_POST['jabber'], 'address' => $_POST['address'], 'zipcode' => $_POST['zipcode'], 'city' => $_POST['city'], 'cellphone' => $_POST['cellphone'], 'phone' => $_POST['phone'], 'birthday' => $_POST['birthday']); $student_data = array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'student_number' => $_POST['student_number'], 'promo' => $_POST['promo'], 'cesure' => isset($_POST['cesure'])); // Avatar if (isset($_FILES['avatar']) && !is_array($_FILES['avatar']['name'])) { if ($_FILES['avatar']['size'] > Config::UPLOAD_MAX_SIZE_PHOTO) { throw new FormException('avatar'); } if ($avatarpath = File::upload('avatar')) { $uploaded_files[] = $avatarpath; try { $img = new Image(); $img->load($avatarpath); $type = $img->getType(); if ($type == IMAGETYPE_JPEG) { $ext = 'jpg'; } else { if ($type == IMAGETYPE_GIF) { $ext = 'gif'; } else { if ($type == IMAGETYPE_PNG) { $ext = 'png'; } else { throw new Exception(); } } } if ($img->getWidth() > 800) { $img->setWidth(800, true); } $img->setType(IMAGETYPE_JPEG); $img->save($avatarpath); // Thumb $avatarthumbpath = $avatarpath . '.thumb'; $img->thumb(Config::$AVATARS_THUMBS_SIZES[0], Config::$AVATARS_THUMBS_SIZES[1]); $img->setType(IMAGETYPE_JPEG); $img->save($avatarthumbpath); unset($img); $uploaded_files[] = $avatarthumbpath; $student_data['avatar_path'] = $avatarthumbpath; $student_data['avatar_big_path'] = $avatarpath; } catch (Exception $e) { throw new FormException('avatar'); } } } $user_model = new User_Model(); $user_model->save((int) $student['id'], $user_data); $this->model->save($student['username'], $student_data); Routes::redirect('student', array('username' => $params['username'])); } catch (FormException $e) { foreach ($uploaded_files as $uploaded_file) { File::delete($uploaded_file); } foreach ($student_data as $key => $value) { $student[$key] = $value; } foreach ($user_data as $key => $value) { $student[$key] = $value; } $this->set('form_error', $e->getError()); } } $this->set('student', $student); $this->addJSCode('User.initEdit();'); }
<?php include '../class.Images.php'; //There’s so much to know about an image. Go get some information! $image = new Image('../test/image3.jpg'); print 'Width: ' . $image->getWidth() . '<br />'; print 'Height: ' . $image->getHeight() . '<br />'; print 'Extension: ' . $image->getExtension() . '<br />'; print 'Mime: ' . $image->getMimeType() . '<br />'; print 'Type: ' . $image->getType() . '<br />'; print 'Filesize in Bytes: ' . $image->getFileSizeInBytes() . '<br />'; print 'Filesize in kBytes: ' . $image->getFileSizeInKiloBytes() . '<br />'; print 'Filesize readable: ' . $image->getFileSize() . '<br />'; print 'Ratio Width:Height: ' . $image->getRatioWidthToHeight() . '<br />'; print 'Ratio Height:Width: ' . $image->getRatioHeightToWidth() . '<br />'; print 'Is it RGB?: ' . $image->isRGB();
public function index() { $this->setView('index.php'); $is_logged = isset(User_Model::$auth_data); $is_student = $is_logged && isset(User_Model::$auth_data['student_number']); $is_admin = $is_logged && User_Model::$auth_data['admin'] == '1'; $this->set(array('username' => User_Model::$auth_data['username'], 'is_logged' => $is_logged, 'is_student' => $is_student, 'is_admin' => $is_admin)); //Fonction qui met à jour l'annuaire dans mysql et ajoute les avatars //$uploaded_files=array(); if (isset($_FILES['uploadzip'])) { if ($_FILES['uploadzip']['size'] > Config::UPLOAD_MAX_SIZE_FILE) { throw new Exception(__('POST_ADD_ERROR_FILE_SIZE', array('size' => File::humanReadableSize(Config::UPLOAD_MAX_SIZE_FILE)))); } //On déplace le fichier zipper vers le serveur if ($filepaths = File::upload('uploadzip')) { // foreach($filepaths as $filepath) // $uploaded_files[] = $filepath; //foreach($filepaths as $i => $filepath){ if (!preg_match('#\\.zip$#', $filepaths)) { throw new Exception(__('POST_ADD_ERROR_FILE_FORMAT')); } $name = $filepaths; //} } $path = DATA_DIR . Config::DIR_DATA_TMP . 'annuaire/'; // On dézip celui-ci if (FILE::exists($path)) { FILE::delete($path); } File::makeDir($path); $zip = new ZipArchive(); $res = $zip->open($name); if ($res === TRUE) { $zip->extractTo($path); $zip->close(); unlink($name); } else { throw new Exception(__('ADMIN_POST_ZIPERROR')); } if (File::delete(DATA_DIR . Config::DIR_DATA_TMP . $name)) { // On aplique le chmod a tous les dossiers et fichiers du zip FILE::chmodDirectory($path, 0); // on traite les fichiers students.csv et users.csv if (file_exists($path . 'users.csv')) { $fp = fopen($path . 'users.csv', "r"); } else { throw new Exception(__('ADMIN_POST_CSVERROR1')); } $i = 0; while (!feof($fp)) { $i = $i + 1; // Tant qu'on n'atteint pas la fin du fichier $ligne = fgets($fp, 4096); /* On lit une ligne */ // On récupère les champs séparés par ; dans liste $liste = explode(";", $ligne); // On assigne les variables if (strlen($liste[0]) > 1) { if (isset($liste[0])) { $username = $liste[0]; } if (isset($liste[1])) { $admin = $liste[1]; } if (isset($liste[2])) { $mail = $liste[2]; } if (isset($liste[3])) { $msn = $liste[3]; } if (isset($liste[4])) { $jabber = $liste[4]; } if (isset($liste[5])) { $address = $liste[5]; } if (isset($liste[6])) { $zipcode = $liste[6]; } if (isset($liste[7])) { $city = $liste[7]; } if (isset($liste[8])) { $cellphone = $liste[8]; } if (isset($liste[9])) { $phone = $liste[9]; } if (isset($liste[10])) { $birthday = $liste[10]; } if (!$this->model->checkuser($username, 1)) { $this->model->insertUsers(trim($username), trim($admin), trim($mail), trim($msn), trim($jabber), trim($address), trim($zipcode), trim($city), trim($cellphone), trim($phone), trim($birthday)); } } } fclose($fp); if (file_exists($path . 'students.csv')) { $fp = fopen($path . 'students.csv', "r"); } else { throw new Exception(__('ADMIN_POST_CSVERROR2')); } $i = 0; while (!feof($fp)) { $i = $i + 1; // Tant qu'on n'atteint pas la fin du fichier $ligne = fgets($fp, 4096); /* On lit une ligne */ // On récupère les champs séparés par ; dans liste $liste = explode(";", $ligne); // On assigne les variables if (strlen($liste[0]) > 1) { if (isset($liste[0])) { $username = $liste[0]; } if (isset($liste[1])) { $lastname = $liste[1]; } if (isset($liste[2])) { $firstname = $liste[2]; } if (isset($liste[3])) { $student_number = $liste[3]; } if (isset($liste[4])) { $promo = $liste[4]; } if (isset($liste[5])) { $cesure = $liste[5]; } if (!$this->model->checkuser($username, 2)) { $this->model->insertStudents(trim($username), trim($lastname), trim($firstname), trim($student_number), trim($promo), trim($cesure)); } // On déplace et formate les photos dans le dossier avatars $avatarpath = $path . 'photos_students/' . $student_number . '.jpg'; $img = new Image(); $img->load($avatarpath); $type = $img->getType(); if ($type == IMAGETYPE_JPEG) { $ext = 'jpg'; } else { if ($type == IMAGETYPE_GIF) { $ext = 'gif'; } else { if ($type == IMAGETYPE_PNG) { $ext = 'png'; } else { throw new Exception(); } } } if ($img->getWidth() > 800) { $img->setWidth(800, true); } $img->setType(IMAGETYPE_JPEG); $img->save($avatarpath); // Thumb $avatarthumbpath = $path . 'photos_students/' . $student_number . '_thumb.jpg'; $img->thumb(Config::$AVATARS_THUMBS_SIZES[0], Config::$AVATARS_THUMBS_SIZES[1]); $img->setType(IMAGETYPE_JPEG); $img->save($avatarthumbpath); if (FILE::exists(DATA_DIR . Config::DIR_DATA_STORAGE . 'avatars/' . substr($student_number, 0, -2) . '/')) { FILE::move($avatarthumbpath, DATA_DIR . Config::DIR_DATA_STORAGE . 'avatars/' . substr($student_number, 0, -2) . '/'); FILE::move($avatarpath, DATA_DIR . Config::DIR_DATA_STORAGE . 'avatars/' . substr($student_number, 0, -2) . '/'); } else { FILE::makeDir(DATA_DIR . Config::DIR_DATA_STORAGE . 'avatars/' . substr($student_number, 0, -2) . '/'); FILE::move($avatarthumbpath, DATA_DIR . Config::DIR_DATA_STORAGE . 'avatars/' . substr($student_number, 0, -2) . '/'); FILE::move($avatarpath, DATA_DIR . Config::DIR_DATA_STORAGE . 'avatars/' . substr($student_number, 0, -2) . '/'); } unset($img); } } fclose($fp); // On supprime le tout du dossier temp FILE::delete($path); } } }
public function addAttachment($param) { $this->setView('iframe_add.php'); $is_logged = isset(User_Model::$auth_data); $is_admin = $is_logged && User_Model::$auth_data['admin'] == '1'; @set_time_limit(0); $uploaded_files = array(); $attachments = array(); try { if ($is_admin && isset($param['id']) && isset($_FILES['attachment_photo']) && is_array($_FILES['attachment_photo']['name'])) { foreach ($_FILES['attachment_photo']['size'] as $size) { if ($size > Config::UPLOAD_MAX_SIZE_PHOTO) { throw new Exception(__('POST_ADD_ERROR_PHOTO_SIZE', array('size' => File::humanReadableSize(Config::UPLOAD_MAX_SIZE_PHOTO)))); } } if ($filepaths = File::upload('attachment_photo')) { foreach ($filepaths as $filepath) { $uploaded_files[] = $filepath; } foreach ($filepaths as $i => $filepath) { $name = isset($_FILES['attachment_photo']['name'][$i]) ? $_FILES['attachment_photo']['name'][$i] : ''; try { $img = new Image(); $img->load($filepath); $type = $img->getType(); if ($type == IMAGETYPE_JPEG) { $ext = 'jpg'; } else { if ($type == IMAGETYPE_GIF) { $ext = 'gif'; } else { if ($type == IMAGETYPE_PNG) { $ext = 'png'; } else { throw new Exception(); } } } if ($img->getWidth() > 800) { $img->setWidth(800, true); } $img->save($filepath); // Thumb $thumbpath = $filepath . '.thumb'; $img->thumb(Config::$THUMBS_SIZES[0], Config::$THUMBS_SIZES[1]); $img->setType(IMAGETYPE_JPEG); $img->save($thumbpath); unset($img); $attachments[] = array($filepath, $name, $thumbpath); $uploaded_files[] = $thumbpath; } catch (Exception $e) { throw new Exception(__('POST_ADD_ERROR_PHOTO_FORMAT')); } } } // Attach files foreach ($attachments as $attachment) { $this->model->attachFile($param['id'], $attachment[0], $attachment[1], isset($attachment[2]) ? $attachment[2] : null); } $this->addJSCode(' parent.location = "' . Config::URL_ROOT . Routes::getPage('post', array('id' => $param['id'])) . '"; '); } Post_Model::clearCache(); } catch (Exception $e) { // Delete all uploading files in tmp foreach ($uploaded_files as $uploaded_file) { File::delete($uploaded_file); } $this->addJSCode(' with(parent){ Post.errorForm(' . json_encode($e->getMessage()) . '); } '); } }
public function isepdorPage($param) { $this->setView('isepdor.php'); $questions = $this->model->getquestions(); for ($i = 0; $i < count($questions); $i++) { $type = explode(',', $questions[$i]["type"]); $tab = array("students", "associations", "employees", "events"); $result = array_intersect($type, $tab); if (in_array("students", $result)) { $questions[$i]["students"] = 1; } else { $questions[$i]["students"] = 0; } if (in_array("events", $result)) { $questions[$i]["events"] = 1; } else { $questions[$i]["events"] = 0; } if (in_array("associations", $result)) { $questions[$i]["associations"] = 1; } else { $questions[$i]["associations"] = 0; } if (in_array("employees", $result)) { $questions[$i]["employees"] = 1; } else { $questions[$i]["employees"] = 0; } if ($questions[$i]["extra"] == null) { $questions[$i]["extra"] = " "; } } $events = $this->model->getevents(); for ($i = 0; $i < count($events); $i++) { if ($events[$i]['extra'] == "soiree") { $events[$i]['extra'] = 1; } else { $events[$i]['extra'] = 0; } } $myFile = DATA_DIR . Config::DIR_DATA_STORAGE . Config::DIR_DATA_ADMIN . "/diplome.json"; $file = fopen($myFile, 'r'); $positions = fread($file, filesize($myFile)); fclose($file); $this->addJSCode(' Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxcore.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxdata.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxbuttons.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxscrollbar.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxmenu.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxgrid.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxgrid.edit.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxgrid.selection.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxgrid.sort.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxgrid.filter.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxgrid.columnsresize.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxlistbox.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxdropdownlist.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxcheckbox.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxcombobox.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxgrid.pager.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxdragdrop.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxcalendar.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxtooltip.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxdatetimeinput.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jquery.global.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jquery.glob.fr-FR.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/jqx/jqxtabs.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/crop/jquery.Jcrop.min.js","js"); Admin.loadjscssfile("' . Config::URL_STATIC . 'js/crop/jquery.color.js","js"); jQuery(document).ready(function () { diplomeData=new Array(); Admin.loadTab(); Admin.loadCrop(); Admin.loadCatGrid(' . json_encode($questions) . '); Admin.loadEventGrid(' . json_encode($events) . '); Admin.loadEmployGrid(' . json_encode($this->model->getemployees()) . '); Admin.loadDate(' . json_encode($this->model->getDate()) . '); jQuery(".jcrop-holder").ready(function () { Admin.loadDiplome(' . $positions . '); }); jQuery("#adminIsepdorTab").removeClass("hidden"); }); '); /* Code qui met à jour le questionnaire pour les ISEP D'or * */ if (isset($_POST['categories'])) { $id = array(); $post = json_decode($_POST['categories'], true); for ($i = 0; $i < count($post); $i++) { if (is_numeric($post[$i]['id'])) { array_push($id, $post[$i]['id']); } } $toDelete = $this->model->checkIsepdorQuestions($id); if (count($toDelete) > 0) { for ($i = 0; $i < count($toDelete); $i++) { $this->model->deleteQuestions($toDelete[$i]); } } for ($i = 0; $i < count($post); $i++) { if ($post[$i]['extra'] == "") { $post[$i]['extra'] = NULL; } if ($post[$i]['id'] != "") { $this->model->updateisepdor($post[$i]['type'], $post[$i]['extra'], $post[$i]['questions'], $post[$i]['id'], $post[$i]['position']); } elseif ($post[$i]['id'] == "") { $this->model->insertisepdor($post[$i]['type'], $post[$i]['extra'], $post[$i]['questions'], $post[$i]['position']); } } } /*Code qui met à jour la table isepdor_employees * */ if (isset($_POST['employees'])) { $id = array(); $post = json_decode($_POST['employees'], true); for ($i = 0; $i < count($post); $i++) { if (is_numeric($post[$i]['id'])) { array_push($id, $post[$i]['id']); } } $toDelete = $this->model->checkIsepdorEmployees($id); if (count($toDelete) > 0) { for ($i = 0; $i < count($toDelete); $i++) { $this->model->deleteEmployees($toDelete[$i]); } } for ($i = 0; $i < count($post); $i++) { $username = $this->makeusername($post[$i]['lastname'], $post[$i]['firstname']); if ($post[$i]['id'] != "") { $this->model->updateEmployees($post[$i]['lastname'], $post[$i]['firstname'], $post[$i]['id'], $username); } elseif ($post[$i]['id'] == "") { $this->model->insertemployees($post[$i]['lastname'], $post[$i]['firstname'], $username); } } } /*Code qui met à jour la table isepdor_event * */ if (isset($_POST['events'])) { $id = array(); $post = json_decode($_POST['events'], true); for ($i = 0; $i < count($post); $i++) { if (is_numeric($post[$i]['id'])) { array_push($id, $post[$i]['id']); } } $toDelete = $this->model->checkIsepdorEvents($id); if (count($toDelete) > 0) { for ($i = 0; $i < count($toDelete); $i++) { $this->model->deleteEvents($toDelete[$i]); } } for ($i = 0; $i < count($post); $i++) { if ($post[$i]['extra'] == 1) { $post[$i]['extra'] = "soiree"; } else { $post[$i]['extra'] = NULL; } if ($post[$i]['id'] != "") { $this->model->updateEvent($post[$i]['name'], $post[$i]['id'], $post[$i]['extra']); } elseif ($post[$i]['id'] == "") { $this->model->insertEvent($post[$i]['name'], $post[$i]['extra']); } } } /*Code qui met à jour les date de vote des isep d'or * */ if (isset($_POST['dates'])) { $post = json_decode($_POST['dates'], true); $this->model->insertDate($post[0][0], $post[0][1], $post[1][0], $post[1][1], $post[2][0], $post[2][1]); } /* * Change l'image diplome */ if (isset($_FILES['diplome']) && !is_array($_FILES['diplome']['name'])) { if ($_FILES['diplome']['size'] > Config::UPLOAD_MAX_SIZE_PHOTO) { throw new FormException('size'); } if ($avatarpath = File::upload('diplome')) { $uploaded_files[] = $avatarpath; try { $img = new Image(); $img->load($avatarpath); $type = $img->getType(); if ($type == IMAGETYPE_JPEG) { $ext = 'jpg'; } else { if ($type == IMAGETYPE_GIF) { $ext = 'gif'; } else { if ($type == IMAGETYPE_PNG) { $ext = 'png'; } else { throw new Exception(); } } } if ($img->getHeight() != 794 || $img->getWidth() != 1122) { throw new FormException('width'); } $img->setType($type); $img->save($avatarpath); unset($img); if (isset($avatarpath) && File::exists($avatarpath)) { $avatar_path = DATA_DIR . Config::DIR_DATA_STORAGE . Config::DIR_DATA_ADMIN . "diplomeIsepDOr9652.png"; $avatar_dir = File::getPath($avatar_path) . "/diplomeIsepDOr9652.png"; File::rename($avatarpath, $avatar_dir); } } catch (FormException $e) { $this->set('form_error', $e->getError()); } foreach ($uploaded_files as $uploaded_file) { File::delete($uploaded_file); } } Post_Model::clearCache(); } /* * Enregistre les coordonnées */ if (isset($_POST['diplomeData'])) { $post = $_POST['diplomeData']; $file = fopen($myFile, 'w'); fwrite($file, $post); fclose($file); } /* * Envoie les diplomes */ if (isset($_GET['getDiplome'])) { $template = DATA_DIR . Config::DIR_DATA_STORAGE . Config::DIR_DATA_ADMIN . "diplomeIsepDOr9652.png"; $font = DATA_DIR . Config::DIR_DATA_STORAGE . Config::DIR_DATA_ADMIN . "font2354.ttf"; $files = array(); $positions = json_decode($positions, true); //récupere les coordonnées précédament demandées for ($i = 0; $i < count($positions); $i++) { $coord[$positions[$i]['index']] = $positions[$i]; } $questions = IsepOr_Model::fetchQuestions(); foreach ($questions as $value) { if (strpos($value['type'], ',')) { $data = array(); foreach (explode(',', $value['type']) as $type) { $data = IsepOr_Controller::__array_rePad($data, IsepOr_Model::fetchFinals($value['id'], $type, 2)); } $finalList[$value['id']] = array_slice(IsepOr_Controller::__array_orderby($data, 'cmpt', SORT_DESC), 0, 3); } else { $finalList[$value['id']] = IsepOr_Model::fetchFinals($value['id'], $value['type'], 2); } } for ($i = 0; $i < count($questions); $i++) { for ($j = 0; $j < count($finalList[$questions[$i]['id']]); $j++) { File::copy($template, DATA_DIR . Config::DIR_DATA_TMP . "diplome" . $i . $j . ".png"); array_push($files, DATA_DIR . Config::DIR_DATA_TMP . "diplome" . $i . $j . ".png"); $im = ImageCreateFromPng(DATA_DIR . Config::DIR_DATA_TMP . "diplome" . $i . $j . ".png"); // Path Images $color = ImageColorAllocate($im, 0, 0, 0); // Text Color $champs[0] = $questions[$i]['questions']; $champs[1] = $finalList[$questions[$i]['id']][$j]["name"]; $champs[2] = ""; if (!is_numeric($finalList[$questions[$i]['id']][$j]["valid"])) { $champs[2] = $this->model->getBirthDay($finalList[$questions[$i]['id']][$j]["valid"]); } for ($a = 0; $a < 3; $a++) { $pxX = round($coord[$a]['x1']); // X $pxY = round($coord[$a]['y2']); // Y ImagettfText($im, round($coord[$a]['h']), 0, $pxX, $pxY, $color, $font, $champs[$a]); } imagePng($im, DATA_DIR . Config::DIR_DATA_TMP . "diplome" . $i . $j . ".png", 9); ImageDestroy($im); if ($finalList[$questions[$i]['id']][$j]['cmpt'] != $finalList[$questions[$i]['id']][$j + 1]['cmpt']) { break; } } } if (self::create_zip($files, DATA_DIR . Config::DIR_DATA_TMP . "diplomesIsepDor.zip", true)) { foreach ($files as $file) { File::delete($file); } header($_SERVER["SERVER_PROTOCOL"] . " 200 OK"); header("Cache-Control: public"); // needed for i.e. header("Content-Type: application/zip"); header("Content-Transfer-Encoding: Binary"); header("Content-Length:" . filesize(DATA_DIR . Config::DIR_DATA_TMP . "diplomesIsepDor.zip")); header("Content-Disposition: attachment; filename=diplomesIsepDor.zip"); readfile(DATA_DIR . Config::DIR_DATA_TMP . "diplomesIsepDor.zip"); File::delete(DATA_DIR . Config::DIR_DATA_TMP . "diplomesIsepDor.zip"); die; } foreach ($files as $file) { File::delete($file); } } /*Code qui export les résultats des isep d'or * */ if (isset($_GET['export'])) { $db = $this->model->getResult(); header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: filename=' . 'Résultats_Isepdor' . '.xls'); header('Pragma: no-cache'); header('Expires: 0'); print '<table border=1 > <!-- impression des titres de colonnes --> <TR> <TD bgcolor="#3366CC">Tour</TD> <TD bgcolor="#3366CC">Nom du votant</TD> <TD bgcolor="#3366CC">Catégorie</TD> <TD bgcolor="#3366CC">Réponse(student)</TD> <TD bgcolor="#3366CC">Réponse(admin)</TD> <TD bgcolor="#3366CC">Réponse(assoce)</TD> <TD bgcolor="#3366CC">Réponse(event)</TD> </TR> '; foreach ($db as $champs) { print '<TR>'; print '<TD>' . $champs['round'] . '</TD>'; print '<TD>' . $champs['username'] . '</TD>'; print '<TD>' . utf8_decode($champs['questions']) . '</TD>'; print '<TD>' . $champs['student_username'] . '</TD>'; print '<TD>' . utf8_decode($champs['admin']) . '</TD>'; print '<TD>' . utf8_decode($champs['assoce']) . '</TD>'; print '<TD>' . utf8_decode($champs['name']) . '</TD>'; print '</TR>'; } print '</table>'; exit; } /* * Ajout de la police */ if (isset($_FILES['font']) && $_FILES['font']['name'] != null) { if ($_FILES['font']['size'] > Config::UPLOAD_MAX_SIZE_FILE) { throw new Exception(__('POST_ADD_ERROR_FILE_SIZE', array('size' => File::humanReadableSize(Config::UPLOAD_MAX_SIZE_FILE)))); } if ($filepaths = File::upload('font')) { if (!preg_match('#\\.ttf$#i', $filepaths)) { throw new Exception(__('POST_ADD_ERROR_FILE_FORMAT')); } $avatar_path = DATA_DIR . Config::DIR_DATA_STORAGE . Config::DIR_DATA_ADMIN . "font2354.ttf"; $avatar_dir = File::getPath($avatar_path) . "/font2354.ttf"; File::rename($filepaths, $avatar_dir); } else { throw new Exception(__('ADMIN_UPLOAD_ERROR')); } } /*Code qui met supprime les champs de la table résultat des isep d'or * */ if (isset($_GET['delete_result'])) { $this->model->deleteresult(); header("Location: " . Config::URL_ROOT . Routes::getPage('admin', array("nav" => "isepdor"))); } }