/** * Writes a line in the log file * * @param string $line */ public function write($line) { File::append($this->filepath, date($this->date_format) . ' - ' . $line . "\n"); // If the max size is exceeded if (File::getSize($this->filepath) >= $this->max_size) { File::delete($this->filepath . '.' . $this->nb_old_logs); for ($i = $this->nb_old_logs; $i >= 1; $i--) { if (File::exists($this->filepath . ($i == 1 ? '' : '.' . ($i - 1)))) { File::rename($this->filepath . ($i == 1 ? '' : '.' . ($i - 1)), $this->filepath . '.' . $i); } } } }
public function rename() { $path = $_POST['path']; $tree = $_POST['folder']; $check = strripos($path, '/'); $ds = '/'; if ($check === false) { $check = strripos($path, '\\'); $ds = '\\'; } if ($check === false) { echo lang('media_folder_found'); exit; } $folders = explode($ds, $path); if ($folders > 1) { $src = ''; $n = count($folders) - 1; for ($i = 0; $i < $n; $i++) { if ($i == 0) { $src = $folders[$i]; } else { $src .= $ds . $folders[$i]; } } $src .= $ds . $tree; } include_once ROOT . DS . 'includes' . DS . 'file.php'; $file = new File(); $this->root = dirname(ROOT); $dis = $this->root . DS . $path; $dis = str_replace('/', DS, $dis); $src = $this->root . DS . $src; $src = str_replace('/', DS, $src); echo $file->rename($dis, $src); exit; }
public function rename($path, $new_path) { return \File::rename($path, $new_path, $this); }
/** * Attach a file to a post * * @param int $post_id Post's id * @param string $filepath Path of the tmp file * @param string $thumbpath Path of the thumb (optional) */ public function attachFile($post_id, $filepath, $name, $thumbpath = null, $mobilepath = null) { $ext = strtolower(File::getExtension($filepath)); // In the DB $file_id = DB::createQuery('attachments')->set(array('post_id' => $post_id, 'name' => $name, 'ext' => $ext))->insert(); // File, and optionally thumb $newfilepath = self::getAttachedFilePath($file_id, $ext); if (!File::exists(File::getPath($newfilepath))) { File::makeDir(File::getPath($newfilepath), 0777, true); } File::rename($filepath, $newfilepath); if (isset($thumbpath)) { File::rename($thumbpath, self::getAttachedFilePath($file_id, 'jpg', 'thumb')); } if (isset($mobilepath)) { File::rename($mobilepath, self::getAttachedFilePath($file_id, 'jpg', 'mobile')); } }
$new_file = $content_root . "/" . dirname($path) . "/" . $status_prefix . $new_slug . "." . $content_type; } } // ensure that both variables are coming from the same place $file = Path::addStartingSlash($file); $new_file = Path::addStartingSlash($new_file); if ($file !== $new_file) { if ($index_file) { // If the page is an index file but not in a directory we want to rename the file not the parent directory. if (dirname($file) != dirname($new_file)) { File::rename(dirname($file), dirname($new_file)); } else { File::rename($file, $new_file); } } else { File::rename($file, $new_file); } } } /* |-------------------------------------------------------------------------- | Done. Let's redirect! |-------------------------------------------------------------------------- | | Pages go back to the tree, entries to their respective Entry Listing | Or, if a custom return was specified, we'll go there. | */ if ($form_data['type'] == 'none') { $app->flash('success', Localization::fetch('page_saved')); } else {
if (Token::check($token)) { // directory $filename = base64_decode($file); // error $error = ''; // submit function if (Request::post('rename')) { // check token if (Token::check(Request::post('token'))) { // if empty if (Request::post('rename_file_name') !== '') { $to = str_replace(File::name($filename) . '.' . File::ext($filename), '', $filename); // if exists if (!File::exists($to . Request::post('rename_file_name') . '.' . File::ext($filename))) { // rename file File::rename($filename, $to . '/' . $p->SeoLink(Request::post('rename_file_name')) . '.' . File::ext($filename)); // set notification $p->setMsg($p::$lang['Success_rename']); // redirect to edit index request::redirect($p->url() . '/backups'); } else { // if exists $error = '<span class="well red">' . Panel::$lang['File_Name_Exists'] . '</span>'; } } else { // if empty input value $error = '<span class="well red">' . Panel::$lang['File_Name_Required'] . '</span>'; } } else { die('crsf detect'); }
/** * Implements the a move_uploaded_file that handles multiple partitions. * * @return a boolean that indicates if the file was successfully moved. This will * return false if the file is not an uploaded file. */ function my_move_uploaded_file($filename, $destination) { // first check to make sure that this file is an uploaded file if (!is_uploaded_file($filename)) { // This file was not an uploaded file, return false return FALSE; } return File::rename($filename, $destination); }
/** * Create a group * * @param array $data Group's data * @return string URL name */ public function create($data) { $group_data = array(); // Name $change_name = false; if (!isset($data['name'])) { throw new FormException('invalid_name'); } $name = trim($data['name']); $group_data['name'] = $name; // URL name $url_name = Text::forURL($name); if ($url_name == '') { throw new FormException('invalid_name'); } $i = ''; while (self::urlExists($url_name . $i)) { $i = $i == '' ? 1 : $i + 1; } $url_name .= $i; $group_data['url_name'] = $url_name; // Creation date if (!isset($data['creation_date']) || !($creation_date = strptime($data['creation_date'], __('GROUP_EDIT_FORM_CREATION_DATE_FORMAT_PARSE')))) { throw new FormException('invalid_creation_date'); } $group_data['creation_date'] = $creation_date['tm_year'] + 1900 . '-' . ($creation_date['tm_mon'] + 1) . '-' . $creation_date['tm_mday']; // Email if (isset($data['mail'])) { if ($data['mail'] != '' && !Validation::isEmail($data['mail'])) { throw new FormException('invalid_mail'); } $group_data['mail'] = $data['mail']; } // Description if (isset($data['description'])) { $group_data['description'] = $data['description']; } // Avatar if (!isset($data['avatar_path']) || !File::exists($data['avatar_path']) || !isset($data['avatar_big_path']) && !File::exists($data['avatar_big_path'])) { throw new FormException('avatar'); } // Insertion in the DB $id = $this->createQuery()->set($group_data)->insert(); // Avatar $avatar_path = self::getAvatarPath($id, true); $avatar_dir = File::getPath($avatar_path); if (!is_dir($avatar_dir)) { File::makeDir($avatar_dir, 0777, true); } File::rename($data['avatar_path'], $avatar_path); $avatar_path = self::getAvatarPath($id, false); $avatar_dir = File::getPath($avatar_path); if (!is_dir($avatar_dir)) { File::makeDir($avatar_dir, 0777, true); } File::rename($data['avatar_big_path'], $avatar_path); // Members if (isset($data['members']) && is_array($data['members'])) { $i = 0; foreach ($data['members'] as &$member) { $member['order'] = $i++; } if (count($data['members']) != 0) { $users = DB::createQuery('users')->fields('id')->where('id IN (' . implode(',', array_keys($data['members'])) . ')')->select(); foreach ($users as $user) { DB::createQuery('groups_users')->set(array('group_id' => $id, 'user_id' => $user['id'], 'title' => $data['members'][(int) $user['id']]['title'], 'admin' => $data['members'][(int) $user['id']]['admin'] ? '1' : '0', 'order' => $data['members'][(int) $user['id']]['order']))->insert(); } } } // Add to the search index $search_model = new Search_Model(); $search_model->index(array('name' => Search_Model::sanitize($group_data['name']), 'url_name' => $group_data['url_name'], 'description' => Search_Model::sanitize($group_data['description'])), 'group', $id); self::clearCache(); return $url_name; }
public function rename($newName) { try { $result = parent::rename($newName); } catch (Exception $e) { Red::errorD($e->getMessage()); } if ($result === false) { $r = basename($this->getID()); } else { $r = basename($result); } $ext = Util::ext($r); echo str_replace(".{$ext}", "<span style=\"color:grey;\">.{$ext}</span>", $r); }
/** * the method above works only with files that have been uploaded while * this one works with files that are anywhere. It will take care of copying * the file to the right destination folder and so on * * @param ownerId The id of the owner of this file * @param albumId The album id to which the * @param fileName full path and name to the file that we're trying to store */ function storeFile($resourceId, $ownerId, $fileName, $mode = RESOURCE_STORAGE_STORE_COPY) { // check that the folders exist if (!$this->_checkBaseStorageFolder()) { return false; } if (!$this->_checkUserStorageFolder($ownerId)) { return false; } // new name for the file $fileParts = explode(".", $fileName); $fileExt = $fileParts[count($fileParts) - 1]; $destFile = "{$ownerId}-{$resourceId}.{$fileExt}"; $destPath = $this->getUserFolder($ownerId); // first of all, check if the file is readable and if not, quit if (!File::isReadable($fileName)) { return false; } $destFile = $destPath . $destFile; if ($mode == RESOURCE_STORAGE_STORE_COPY) { $res = File::copy($fileName, $destFile); } else { $res = File::rename($fileName, $destFile); } if (!$res) { return false; } // check that the permissions are correct File::chMod($destFile, 0755); return $destFile; }
AdminServLogs::add('action', 'Rename map (auto): ' . $_POST['map'][$i] . ' to ' . $newMapName); } $i++; } Utils::redirection(false, '?p=' . USER_PAGE . $hasDirectory); } else { if (isset($_POST['moveMapValid']) && isset($_POST['moveDirectoryList']) && isset($_POST['map']) && count($_POST['map']) > 0) { // Chemin if ($_POST['moveDirectoryList'] == '.') { $newPath = $data['mapsDirectoryPath']; } else { $newPath = $_POST['moveDirectoryList']; } // Déplacement foreach ($_POST['map'] as $map) { $result = File::rename($data['mapsDirectoryPath'] . $map, $newPath . basename($map)); if ($result !== true) { AdminServ::error(Utils::t('Unable to move the map') . ' : ' . $map . ' (' . $result . ')'); break; } else { AdminServLogs::add('action', 'Move map: ' . $map . ' to ' . $newPath . basename($map)); } } Utils::redirection(false, '?p=' . USER_PAGE . $hasDirectory); } else { if (isset($_POST['deleteMap']) && isset($_POST['map']) && count($_POST['map']) > 0) { foreach ($_POST['map'] as $map) { $result = File::delete($data['mapsDirectoryPath'] . $map); if ($result !== true) { AdminServ::error(Utils::t('Unable to delete the map') . ' : ' . $map . ' (' . $result . ')'); break;
/** * Save the data of a student * * @param string $username student's username * @param array $data student's data */ public function save($username, $data) { $student_data = array(); $old_data = DB::createQuery('students')->fields('firstname', 'lastname', 'student_number')->where(array('username' => $username))->select(); if (!$old_data[0]) { throw new Exception('Student not found'); } $old_data = $old_data[0]; $change_name = false; // Firstname if (isset($data['firstname']) && $old_data['firstname'] != trim($data['firstname'])) { if (trim($data['firstname']) == '') { throw new FormException('firstname'); } $student_data['firstname'] = trim($data['firstname']); $change_name = true; } // Lastname if (isset($data['lastname']) && $old_data['lastname'] != trim($data['lastname'])) { if (trim($data['lastname']) == '') { throw new FormException('lastname'); } $student_data['lastname'] = trim($data['lastname']); $change_name = true; } // Student number if (isset($data['student_number'])) { if (!ctype_digit(trim($data['student_number']))) { throw new FormException('student_number'); } $student_data['student_number'] = (int) trim($data['student_number']); // Moving the avatar if ($student_data['student_number'] != $old_data['student_number']) { // Thumb $avatar_path = self::getAvatarPath($student_data['student_number'], true); $avatar_dir = File::getPath($avatar_path); if (!is_dir($avatar_dir)) { File::makeDir($avatar_dir, 0777, true); } File::rename(self::getAvatarPath($old_data['student_number'], true), $avatar_path); // Big $avatar_path = self::getAvatarPath($student_data['student_number'], false); $avatar_dir = File::getPath($avatar_path); if (!is_dir($avatar_dir)) { File::makeDir($avatar_dir, 0777, true); } File::rename(self::getAvatarPath($old_data['student_number'], false), $avatar_path); } } // Promo if (isset($data['promo'])) { if (!ctype_digit(trim($data['promo'])) || (int) $data['promo'] < 2000) { throw new FormException('promo'); } $student_data['promo'] = (int) trim($data['promo']); } // Cesure if (isset($data['cesure'])) { $student_data['cesure'] = $data['cesure'] ? 1 : 0; } // Avatar if (isset($data['avatar_path']) && isset($data['student_number']) && File::exists($data['avatar_path'])) { $avatar_path = self::getAvatarPath((int) $data['student_number'], true); $avatar_dir = File::getPath($avatar_path); if (!is_dir($avatar_dir)) { File::makeDir($avatar_dir, 0777, true); } File::rename($data['avatar_path'], $avatar_path); } if (isset($data['avatar_big_path']) && isset($data['student_number']) && File::exists($data['avatar_big_path'])) { $avatar_path = self::getAvatarPath((int) $data['student_number'], false); $avatar_dir = File::getPath($avatar_path); if (!is_dir($avatar_dir)) { File::makeDir($avatar_dir, 0777, true); } File::rename($data['avatar_big_path'], $avatar_path); } // Update the DB $this->createQuery()->set($student_data)->where(array('username' => $username))->update(); if ($change_name) { Post_Model::clearCache(); // Update the search index $search_model = new Search_Model(); $search_model->index(array('username' => $username, 'firstname' => Search_Model::sanitize(isset($student_data['firstname']) ? $student_data['firstname'] : $old_data['firstname']), 'lastname' => Search_Model::sanitize(isset($student_data['lastname']) ? $student_data['lastname'] : $old_data['lastname'])), 'student', $username); } }
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"))); } }
// Check for co-authors. foreach ($history as $stamp => $info) { if ($info['author'] == $GLOBALS['pie']['user']) { continue; } // We are trying to affect an other author's work // ... which is only suitable for admins. if (!pieIsSuperuser($GLOBALS['pie']['user'])) { pieError("AuthorDiffers", array('action' => "{$context}history")); } } // Ask user for acknowledgement to rename the resource. pieError("AskApproval"); } // Rename the resource: if (!$object->rename($source, $destination)) { pieError("RenameError"); } if ($context == "page") { // Do what is to be done with pages. if ($object->meta['type'] != "alias") { // Delete the cache, if available. $cache = new Cache(); $cid = $cache->key('page', array('page' => $source)); if ($cache->exists($cid)) { if (!$cache->delete($cid)) { pieError('CacheWriteError'); } } if ($cache->exists($cache->key('latest', array()))) { $cache->delete($cache->key('latest', array()));
/** * Renames this member * * @param string $username username to rename this Member to * @return boolean * @throws Exception */ public function rename($username) { // the files in question $current_file = Config::getConfigPath() . '/users/' . $this->get('username') . '.yaml'; $new_file = Config::getConfigPath() . '/users/' . $username . '.yaml'; // is this the same that it already is? if ($username === $this->get('username')) { return true; } // is this a valid username? if (!self::isValidusername($username)) { throw new Exception(Localization::fetch('invalid_username')); } // does this filename already exist? if (File::exists($new_file)) { throw new Exception(Localization::fetch('username_already_exists')); } // everything checks out, rename the file and return true File::rename($current_file, $new_file); return true; }
/** * アップロードファイルを指定のフォルダに移動する * * @access private * @param array $files アップロードファイル情報 * @param string $src_path コピー元パス * @param string $dest_path コピー先パス * @return void * @author kobayashi * @author ida */ public static function storeUploadFile($files, $src_path, $dest_path) { if (!$files) { return false; } if (!(self::checkPath($src_path, true) && self::checkPath($dest_path, true))) { return false; } foreach ($files as $file) { $file_name = $file['saved_as']; \File::rename($src_path . $file_name, $dest_path . $file_name); self::makeThumbnail($dest_path, $file['saved_as']); } return $files; }
function testRenameFiles() { $f1 = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/rename_test/a/my_file.txt"); $this->assertFalse($f1->exists(), "Il file f1 esiste!!"); $f1->setContent("Ciao!!"); $this->assertTrue($f1->exists(), "Il file f1 non esiste!!"); $f3 = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/rename_test/a/another_name_again.txt"); $this->assertFalse($f3->exists(), "Il file f3 esiste gia'!!"); $f1->rename("another_name_again.txt"); $this->assertFalse($f1->exists(), "Il file f1 esiste ancora!!"); $this->assertTrue($f3->exists(), "Il rename non e' andato a buon fine!!"); $f3->delete(); }