$_SERVER['SCRIPT_FILENAME'] = forward_slash($_SERVER['SCRIPT_FILENAME']); $_SERVER['SCRIPT_NAME'] = forward_slash($_SERVER['SCRIPT_NAME']); // Inherit application definitions if (file_exists(G_APP_PATH . 'app.php')) { require_once G_APP_PATH . 'app.php'; } // Set the DB constants foreach (['host', 'port', 'name', 'user', 'pass', 'driver'] as $k) { if ($settings['db_' . $k]) { define('G_APP_DB_' . strtoupper($k), $settings['db_' . $k]); } } // Include app functions file_exists(G_APP_FILE_FUNCTIONS) ? require_once G_APP_FILE_FUNCTIONS : die("G\\: Can't find <strong>" . G_APP_FILE_FUNCTIONS . '</strong>. Make sure that this file exists.'); if (file_exists(G_APP_FILE_FUNCTIONS_RENDER)) { require_once G_APP_FILE_FUNCTIONS_RENDER; } // Set the URLs define("G_ROOT_URL", G_HTTP_PROTOCOL . "://" . G_HTTP_HOST . G_ROOT_PATH_RELATIVE); // http(s)://www.mysite.com/chevereto/ define("G_ROOT_LIB_URL", absolute_to_url(G_ROOT_LIB_PATH)); define("G_APP_LIB_URL", absolute_to_url(G_APP_PATH_LIB)); // Define the app theme define('G_APP_PATH_THEMES', G_APP_PATH . 'themes/'); if (!file_exists(G_APP_PATH_THEMES)) { die("G\\: Theme path doesn't exists!"); } if (isset($settings['theme']) and file_exists(G_APP_PATH_THEMES . $settings['theme'])) { define('G_APP_PATH_THEME', G_APP_PATH_THEMES . $settings['theme'] . '/'); define('BASE_URL_THEME', absolute_to_url(G_APP_PATH_THEME)); }
/*** Include the user definitions ***/ file_exists(__CHV_FILE_DEFINITIONS__) ? require_once __CHV_FILE_DEFINITIONS__ : die('Can\'t find ' . __CHV_FILE_DEFINITIONS__); if (headers_sent()) { die(str_replace('%%FILE%%', __CHV_FILE_DEFINITIONS__, __CHV_CONFIGURABLE_FILE_ERROR__)); } /*** Workaround the admin request ***/ if (preg_match('/\\/admin\\//', $_SERVER['REQUEST_URI'])) { define('access', 'admin'); define('SKIP_MAINTENANCE', true); } /*** Include the core functions ***/ file_exists(__CHV_FILE_FUNCTIONS__) ? require_once __CHV_FILE_FUNCTIONS__ : die('Can\'t find <strong>' . __CHV_FILE_FUNCTIONS__ . '</strong>. Make sure you have uploaded this file.'); require_once __CHV_PATH_INCLUDES__ . 'template.functions.php'; /*** Set some url paths ***/ define('__CHV_URL_SYSTEM_JS__', absolute_to_url(__CHV_PATH_SYSTEM_JS__)); define('__CHV_URL_THEME__', absolute_to_url(__CHV_PATH_THEME__)); define('__CHV_URL_UPDATE_SCRIPT__', __CHV_BASE_URL__ . 'update.php'); // Virtual paths define('__CHV_VIRTUALFOLDER_IMAGE__', sanitize_path($config['virtual_folder_image'])); define('__CHV_VIRTUALFOLDER_UPLOADED__', sanitize_path($config['virtual_folder_uploaded'])); /*** Call the dB class ***/ require_once __CHV_PATH_CLASSES__ . 'class.db.php'; $dB = new dB(); /*** Call the Login class ***/ require_once __CHV_PATH_CLASSES__ . 'class.login.php'; $Login = new Login(); /*** Call the ShortURL class ***/ require_once __CHV_PATH_CLASSES__ . 'class.shorturl.php'; $ShortURL = new ShortURL(); /*** Flood protection ***/ if (preg_match('/upload/', access)) {
/** * getlist * get the filelist according to the params * * @param string * @return mixed */ private function getlist($type, $order_sort, $limit, $keyword) { // Defaults if (!preg_match('/jpg|png|gif|all/', $type)) { $type = 'all'; } if (!check_value($order_sort)) { $order_sort = 'date_desc'; } if (!check_value($limit)) { $limit = 50; } // Type cleaning if ($type == 'all') { $type_qry = ''; } else { $types = explode(',', $type); $types_qry = array(); foreach ($types as $type_qry) { if (!in_array($type_qry, array('jpg', 'png', 'gif', 'all'))) { continue; // Continue (and warn)... } $types_qry[] = "'" . $type_qry . "'"; } $sql_types = implode(',', $types_qry); $type_qry = "WHERE image_type IN ({$sql_types})"; } // Order sort $ordersort = explode("_", $order_sort); $order = strtolower($ordersort[0]); $sort = strtolower($ordersort[1]); // Order clean if (!in_array($order, array('date', 'size'))) { $order = "date"; } $order = 'image_' . $order; // Sort clean if (!in_array($sort, array('asc', 'desc'))) { $sort = "desc"; } // Limits clean $limits = explode(',', $limit); $limits_qry = array(); if (count($limits) > 1) { for ($i = 0; $i <= 1; ++$i) { // Allow only two limits $limits_qry[] = intval($limits[$i]); } $sql_limits = implode(',', $limits_qry); } else { $sql_limits = intval($limit); } $base_qry = "SELECT * FROM chv_images LEFT JOIN chv_storages ON chv_images.storage_id = chv_storages.storage_id {$type_qry}"; $prepare = array(); if (check_value($keyword)) { $prepare[':keyword'] = "%{$keyword}%"; $keyword_qry = check_value($type_qry) ? "AND" : "WHERE" . " chv_images.image_name LIKE :keyword"; } $results = $this->dB->query_fetch("SELECT * FROM chv_images LEFT JOIN chv_storages ON chv_images.storage_id = chv_storages.storage_id {$type_qry} {$keyword_qry} ORDER BY {$order} {$sort} LIMIT {$sql_limits}", $prepare); if (is_array($results)) { // Now we got the results: Fix the result array in something actually usable $output = array(); foreach ($results as $result) { foreach ($result as $filevalues) { $file_array = $result; $image_target = get_image_target($file_array); // if the image doesn't exits remove it from the dB if ($this->dB->must_delete_image_record($file_array['image_id'], $image_target)) { unset($output['"' . $file_array['image_id'] . '"']); continue 2; } // Recreate the thumb recreate_thumb($image_target); $filename = $file_array['image_name'] . '.' . $file_array['image_type']; $file_array['image_viewer'] = __CHV_BASE_URL__ . __CHV_VIRTUALFOLDER_IMAGE__ . '/' . encodeID($file_array['image_id']); $file_array['image_size'] = format_bytes($result['image_size'], 0); $file_array['image_url'] = absolute_to_url($image_target['image_path']); $file_array['image_thumb_url'] = absolute_to_url($image_target['image_thumb_path']); $file_array['image_shorturl'] = __CHV_BASE_URL__ . encodeID($file_array['image_id']); $file_array['timestamp'] = strtotime($file_array['image_date']); $file_array['image_date'] = date('Y-m-d', $file_array['timestamp']); } $output['"' . $file_array['image_id'] . '"'] = $file_array; // Defined as "1" instead of 1 to don't rely on browser json sort (Chrome) } return $output; } else { return $this->dB->error; } }
/** * proccess_request * Process the request for the public area */ private function proccess_request() { global $lang; $this->template = 404; // Default template $this->pages = $this->get_pages(); // get theme pages // Prepare te request array to use the legacy request (?v=file.ext) if (check_value($_GET['v']) && preg_match("/^\\w*\\.jpg|png|gif\$/", $_GET['v'])) { $this->base_request = '?' . $this->request_array[1]; unset($this->request_array[1]); } @session_start(); if (count($_SESSION['ImagesUp']) > 0) { $_SESSION['ImagesUp'] = array_values($_SESSION['ImagesUp']); self::$uploaded = true; } if (chevereto_config('maintenance')) { $this->base_request = 'maintenance'; } // Switch according the request switch ($this->base_request) { case '': case 'index.php': @session_start(); $_SESSION['last_upload_request'] = time(); $this->template = 'index'; break; case 'json': json_prepare(); // Do a special trick for the json action=login if ($_REQUEST['action'] == 'login') { // Check for user match... $login_user = login_user($_REQUEST['password'], $_REQUEST['keep']); if ($login_user !== false) { $json_array = array('status_code' => 200, 'status_txt' => 'logged in'); } else { $json_array = array('status_code' => 403, 'status_txt' => 'invalid login'); } } elseif ($_REQUEST['action'] == 'logout') { do_logout(); $json_array = array('status_code' => 200, 'status_txt' => 'logged out'); } $json_array = check_value($json_array) ? $json_array : array('status' => 403, 'status_txt' => 'unauthorized'); session_write_close(); die(json_output($json_array)); break; case __CHV_VIRTUALFOLDER_IMAGE__: // View request $id_public = $this->request_array[1]; $this->template = !is_upload_result() ? 'view' : 'uploaded'; self::$is_viewer = true; break; case __CHV_VIRTUALFOLDER_UPLOADED__: @session_start(); if (count($_SESSION['ImagesUp']) > 0) { $this->template = 'uploaded'; self::$doctitle = $lang['doctitle_upload_complete']; } else { $this->redirect(__CHV_BASE_URL__, 400); } break; case 'error-javascript': chevereto_die(array(get_lang_txt('critical_js_step_1'), get_lang_txt('critical_js_step_2')), 'JavaScript', array(get_lang_txt('critical_js'))); break; case '?chevereto': $this->template = 'bool'; break; // Legacy viewer // Legacy viewer case '?v=' . $_GET['v']: // View request $id_public = $_GET['v']; $this->legacy_redirect = true; break; case 'delete': case 'delete-confirm': //$delete_what = $this->request_array[1]; $id_public = $this->request_array[2]; $deleteHash = $this->request_array[3]; $this->template = $this->base_request; self::$is_viewer = true; break; case 'maintenance': $this->template = 'maintenance'; self::$doctitle = chevereto_config('doctitle'); break; default: // Pages request require_once $this->path_theme . 'pages/pages_config.php'; // We load the special pages config if (in_array($this->base_request . '.php', $this->pages) and $this->request_array[1] == '' and $pages_config[$this->base_request]['live']) { $this->template = 'pages/' . $this->base_request; self::$doctitle = $pages_config[$this->base_request]['title']; } else { $this->template = 'shorturl'; $id_public = $this->base_request; self::$is_viewer = true; } break; } // Ask for the login on index and pages if ($this->template == 'index' || $this->template == 'pages/' . $this->base_request) { if (conditional_config('private_mode')) { if (!is_logged_user()) { $doctitle = get_lang_txt('txt_enter_password') . ' - ' . chevereto_config('doctitle'); include __CHV_PATH_SYSTEM__ . 'login.php'; die; } } } if ($this->template == 'uploaded') { self::$doctitle = get_lang_txt('doctitle_upload_complete'); self::$image_info = $_SESSION['ImagesUp'][0]; self::$uploaded_images = $_SESSION['ImagesUp']; $_SESSION['ImagesUp'] = NULL; unset($_SESSION['ImagesUp']); } if (preg_match('/view|shorturl|delete/', $this->template) || $this->legacy_redirect) { // Test connection if ($this->dB->dead) { self::$doctitle = 'dB connection error'; $this->template = 404; } else { // get image info $imageID = $this->legacy_redirect ? $id_public : decodeID($id_public); self::$image_info = $this->dB->image_info($imageID); self::$id_public = $id_public; if (!is_array(self::$image_info)) { // Record? if ($this->template == 'delete-confirm') { json_output(array('status_code' => 403, 'status_txt' => 'target image doesn\'t exists')); } else { $this->template = 404; } } else { if ($this->legacy_redirect) { $this->redirect(__CHV_BASE_URL__ . __CHV_VIRTUALFOLDER_IMAGE__ . '/' . encodeID(self::$image_info['image_id']), 301); } $target = get_image_target(self::$image_info); self::$image_target = $target['image_path']; self::$image_thumb_target = $target['image_thumb_path']; self::$image_url = absolute_to_url($target['image_path']); self::$image_thumb_url = absolute_to_url($target['image_thumb_path']); self::$image_filename = self::$image_info['image_filename']; self::$image_viewer = __CHV_BASE_URL__ . __CHV_VIRTUALFOLDER_IMAGE__ . '/' . $id_public; self::$delete_image_url = __CHV_BASE_URL__ . 'delete/image/' . self::$id_public . '/' . self::$image_info['image_delete_hash']; $image_delete_proceed = !empty(self::$image_info['image_delete_hash']) && $deleteHash === self::$image_info['image_delete_hash'] ? true : false; switch ($this->template) { case 'delete': if (!$image_delete_proceed) { $this->redirect(__CHV_BASE_URL__ . __CHV_VIRTUALFOLDER_IMAGE__ . '/' . self::$id_public, 301); } self::$delete_image_confirm_url = __CHV_BASE_URL__ . 'delete-confirm/image/' . self::$id_public . '/' . self::$image_info['image_delete_hash']; self::$doctitle = get_lang_txt('doctitle_delete_confirm') . ' ' . self::$image_info['image_filename']; break; case 'delete-confirm': if (!$image_delete_proceed) { json_output(array('status_code' => 403, 'status_txt' => 'invalid delete hash')); } else { require_once __CHV_PATH_ADMIN_CLASSES__ . 'class.manage.php'; $manage = new Manage(array('id' => self::$image_info['image_id'], 'action' => 'delete')); if ($manage->dead) { $json_array = array('status_code' => 403, 'status_txt' => $manage->error); } else { $json_array = $manage->process(); } } // Make the status_txt more readable... switch ($json_array['status_code']) { case 200: $json_array['status_txt'] = get_lang_txt('txt_image_deleted'); break; default: case 403: $json_array['status_txt'] = get_lang_txt('txt_error_deleting_image'); break; } json_output($json_array); break; default: self::$doctitle = get_lang_txt('doctitle_viewing_image') . ' ' . self::$image_info['image_filename']; break; } } } } if ($this->template == 404) { status_header(404); self::$doctitle = check_value(self::$doctitle) ? self::$doctitle : get_lang_txt('txt_404_title'); } else { status_header(200); } // We load the template if ($this->template == 'bool') { exit(json_encode(true)); } else { $this->load_template(); } }
/** * image_info * get the image info from the dB * * @access public * @param string * @return array */ public function image_info($id) { $query = 'SELECT * FROM chv_images LEFT JOIN chv_storages ON chv_images.storage_id = chv_storages.storage_id WHERE '; // Legacy request (file.ext) if (preg_match("/(\\w*\\.)(jpg|png|gif)\$/", $id)) { $target = explode(".", $id); $query .= 'chv_images.storage_id=1 AND chv_images.image_name=? AND chv_images.image_type=?'; $query_array = array($target[0], $target[1]); } else { $query .= 'chv_images.image_id=?'; $query_array = array($id); } $imageDB = $this->query_fetch_single($query, $query_array); if (is_array($imageDB)) { $id = $imageDB['image_id']; $id_public = encodeID($id); $image_target = get_image_target($imageDB); // if the image doesn't exits remove it from the dB if ($this->must_delete_image_record($id, $image_target)) { $this->dead = true; $this->error = "file doesn't exists"; return false; } else { // Recreate the thumb recreate_thumb($image_target); // Fix the dB values just in case... $imageDB['image_width'] = intval($imageDB['image_width']); $imageDB['image_height'] = intval($imageDB['image_height']); $imageDB['image_size'] = intval($imageDB['image_size']); // Populate the array $populate = array('image_filename' => $imageDB['image_name'] . '.' . $imageDB['image_type'], 'image_id_public' => $id_public, 'image_path' => $image_target['image_path'], 'image_url' => absolute_to_url($image_target['image_path']), 'image_attr' => 'width="' . $imageDB['image_width'] . '" height="' . $imageDB['image_height'] . '"', 'image_bytes' => intval($imageDB['image_size']), 'image_size' => format_bytes($imageDB['image_size']), 'image_thumb_url' => absolute_to_url($image_target['image_thumb_path']), 'image_thumb_path' => $image_target['image_thumb_path'], 'image_thumb_width' => chevereto_config('thumb_width'), 'image_thumb_height' => chevereto_config('thumb_height'), 'image_viewer' => __CHV_BASE_URL__ . __CHV_VIRTUALFOLDER_IMAGE__ . '/' . $id_public, 'image_shorturl' => __CHV_BASE_URL__ . $id_public, 'image_delete_url' => __CHV_BASE_URL__ . 'delete/image/' . $id_public . '/' . $imageDB['image_delete_hash'], 'image_delete_confirm_url' => __CHV_BASE_URL__ . 'delete-confirm/image/' . $id_public . '/' . $imageDB['image_delete_hash']); return array_merge($imageDB, $populate); } } else { $this->error = 'invalid id record (' . $id . ')'; return false; } }
/** * process * Does the thing * * @param string * @return mixed */ public function process() { if ($this->valid_data()) { $this->extension = $this->get_true_extension($this->mime); if ($this->extension == 'bmp') { require_once 'class.imageconvert.php'; $this->ImageConvert = new ImageConvert($this->working, $this->extension, $this->img_upload_path . 'temp_' . generateRandomString(256)); unset($this->working); unset($this->extension); $this->working = $this->ImageConvert->out; $this->extension = 'png'; } switch ($this->storage) { case 'direct': $this->img_upload_path = __CHV_PATH_IMAGES__; break; case 'datefolder': case 'datefolders': default: // Sets the date folder YYYY/MM/DD $datefolder = $this->img_upload_path . date('Y/m/d/'); $old_umask = umask(0); if (!file_exists($datefolder) && !@mkdir($datefolder, 0755, true)) { $this->error = "Unable to create upload folder"; return false; } umask($old_umask); $this->img_upload_path = $datefolder; break; } $image_filename = $this->nameFile($this->img_upload_path, $this->extension, chevereto_config('file_naming'), $this->original_file_name); // Prepare and formats the temp image $formated_temp = $this->working . '.' . $this->extension; rename($this->working, $formated_temp); unset($this->working); $this->working = $formated_temp; // Call the resize class require_once 'class.imageresize.php'; // Thumb $thumb_filename = str_replace($this->extension, 'th.' . $this->extension, $image_filename); $this->ThumbResize = new ImageResize($this->working, $thumb_filename, $this->thumb_width, $this->thumb_height, true); // Fixed width but fluid height? Replace the line above with this: // $this->ThumbResize = new ImageResize($this->working, $thumb_filename, $this->thumb_width); if (check_value($this->ThumbResize->error)) { $this->error = $this->ThumbResize->error . " (thumb)"; return false; } // Resize? if (check_value($this->resize_width)) { $this->ImageResize = new ImageResize($this->working, $this->working, $this->resize_width); if (check_value($this->ImageResize->error)) { $this->error = $this->ImageResize->error; return false; } } if (!check_value($this->error)) { // Apply the watermark ? if (!is_animated_image($this->working) && conditional_config('watermark_enable') and chevereto_config('watermark_opacity') > 0) { switch ($this->extension) { case 'gif': $src = imagecreatefromgif($this->working); break; case 'png': $src = imagecreatefrompng($this->working); break; case 'jpg': $src = imagecreatefromjpeg($this->working); break; } $src_width = imagesx($src); $src_height = imagesy($src); $watermark_src = imagecreatefrompng(__CHV_WATERMARK_FILE__); $watermark_width = imagesx($watermark_src); $watermark_height = imagesy($watermark_src); // Calculate the position switch (chevereto_config('watermark_x_position')) { case 'left': $watermark_x = chevereto_config('watermark_margin'); break; case 'center': $watermark_x = $src_width / 2 - $watermark_width / 2; break; case 'right': $watermark_x = $src_width - $watermark_width - chevereto_config('watermark_margin'); break; } switch (chevereto_config('watermark_y_position')) { case 'top': $watermark_y = chevereto_config('watermark_margin'); break; case 'center': $watermark_y = $src_height / 2 - $watermark_height / 2; break; case 'bottom': $watermark_y = $src_height - $watermark_height - chevereto_config('watermark_margin'); break; } // Watermark has the same or greater size of the image ? // --> Center the watermark if ($watermark_width == $src_width && $watermark_height == $src_height) { $watermark_x = $src_width / 2 - $watermark_width / 2; $watermark_y = $src_height / 2 - $watermark_height / 2; } // Watermark is too big ? // --> Fit the watermark on the image if ($watermark_width > $src_width || $watermark_height > $src_height) { // Watermark is wider than the image if ($watermark_width > $src_width) { $watermark_new_width = $src_width; $watermark_new_height = $src_width * $watermark_height / $watermark_width; if ($watermark_new_height > $src_height) { $watermark_new_width = $src_height * $watermark_width / $watermark_height; $watermark_new_height = $src_height; } } else { $watermark_new_width = $src_height * $watermark_width / $watermark_height; $watermark_new_height = $src_height; } $watermark_temp = $this->img_upload_path . 'temp_watermark_' . generateRandomString(64) . '.png'; $WatermarkResize = new ImageResize(__CHV_WATERMARK_FILE__, $watermark_temp, $watermark_new_width); if (!check_value($WatermarkResize->error)) { $watermark_width = $watermark_new_width; $watermark_height = $watermark_new_height; $watermark_src = imagecreatefrompng($watermark_temp); $watermark_x = $src_width / 2 - $watermark_width / 2; $watermark_y = $src_height / 2 - $watermark_height / 2; } } // Apply and save the watermark imagecopymerge_alpha($src, $watermark_src, $watermark_x, $watermark_y, 0, 0, $watermark_width, $watermark_height, chevereto_config('watermark_opacity'), $this->extension); switch ($this->extension) { case 'gif': imagegif($src, $this->working); break; case 'png': imagepng($src, $this->working); break; case 'jpg': imagejpeg($src, $this->working, 96); break; } imagedestroy($src); @unlink($watermark_temp); } // Move the temp to the final path... $uploaded = rename($this->working, $image_filename); // Change the CHMOD of the file (for some php enviroments) @chmod($image_filename, 0644); @chmod($thumb_filename, 0644); if ($uploaded) { $info = get_info($image_filename); $file_path = absolute_to_relative($image_filename); $thumb_path = absolute_to_relative($thumb_filename); $image_url = absolute_to_url($image_filename); $name = str_replace('.' . $this->extension, '', str_replace($this->img_upload_path, '', $image_filename)); $this->image_info = array('image_name' => $name, 'image_filename' => $name . "." . $this->extension, 'image_type' => $this->extension, 'image_path' => $file_path, 'image_url' => $image_url, 'image_width' => $info['width'], 'image_height' => $info['height'], 'image_attr' => 'width="' . $info['width'] . '" height="' . $info['height'] . '"', 'image_bytes' => $info['bytes'], 'image_size' => $info['size'], 'image_thumb_url' => absolute_to_url($thumb_filename), 'image_thumb_path' => $thumb_path, 'image_thumb_width' => $this->thumb_width, 'image_thumb_height' => $this->thumb_height); switch ($this->storage) { case 'direct': $this->image_info['storage_id'] = 2; break; case 'datefolder': case 'datefolders': $this->image_info['storage_id'] = NULL; break; } // Shorthand the dB object $dB = $this->dB; if ($dB->dead) { $this->error = $dB->error; return false; } if ($dB->insert_file($this->image_info)) { $image_delete_hash = $dB->image_delete_hash; $this->image_info['image_id'] = $dB->last_insert_id(); $this->image_info['image_id_public'] = encodeID($this->image_info['image_id']); $this->image_info['image_viewer'] = __CHV_BASE_URL__ . __CHV_VIRTUALFOLDER_IMAGE__ . '/' . $this->image_info['image_id_public']; $this->image_info['image_shorturl'] = __CHV_BASE_URL__ . $this->image_info['image_id_public']; $this->image_info['image_delete_hash'] = $image_delete_hash; $this->image_info['image_delete_url'] = __CHV_BASE_URL__ . 'delete/image/' . $this->image_info['image_id_public'] . '/' . $image_delete_hash; $this->image_info['image_delete_confirm_url'] = __CHV_BASE_URL__ . 'delete-confirm/image/' . $this->image_info['image_id_public'] . '/' . $image_delete_hash; $this->image_info['image_date'] = date('Y-m-d H:i:s', time()); return true; } else { unlink($image_filename); unlink($thumb_filename); $this->error = $dB->error; return false; } } else { unlink($this->working); $this->error = 'error uploading'; return false; } } else { unlink($this->working); return false; } } else { // Invalid data return false; } }
function get_image_fileinfo($file) { $info = getimagesize($file); $filesize = @filesize($file); if (!$info and !$filesize) { return false; } $mime = strtolower($info['mime']); return array('filename' => basename($file), 'name' => basename($file, '.' . get_file_extension($file)), 'width' => intval($info[0]), 'height' => intval($info[1]), 'ratio' => $info[0] / $info[1], 'size' => intval($filesize), 'size_formatted' => format_bytes($filesize), 'mime' => $mime, 'extension' => mime_to_extension($mime), 'bits' => $info['bits'], 'channels' => $info['channels'], 'url' => absolute_to_url($file), 'md5' => md5_file($file)); }
} }); } ajax_update(); }) </script> <?php } ?> </head> <body> <div id="main"> <div id="top"><a href="<?php echo absolute_to_url(__FILE__); ?> "><img src="<?php echo absolute_to_relative(__CHV_PATH_SYSTEM__); ?> img/logo.png" id="logo" alt="Chevereto"/></a> <span id="update_tool">Update 2.0.X to 2.5</span></div> <div id="update_content"><?php echo $content; ?> </div> </div> </body> </html>
/** * rename_image * Rename the target image * * @access private * @return string */ private function rename_image() { $this->image_rename = str_replace($this->image_name, $this->rename_name, $this->image_target); $this->image_thumb_rename = str_replace($this->image_name, $this->rename_name, $this->image_thumb_target); if (file_exists($this->image_rename)) { $this->error = 'ERR_RN:E1'; // target filename already exists $this->extra_info = array('image_filename' => $this->image_name . "." . $this->image_type); return false; } // Avoid Windows OS multibyte error on rename if (is_windows() && strlen($this->rename_name) !== strlen(urlencode($this->rename_name))) { $this->error = 'ERR_RN:E4'; // can't rename the image (multi-byte in Windows OS) return false; } rename($this->image_target, $this->image_rename); rename($this->image_thumb_target, $this->image_thumb_rename); if (file_exists($this->image_rename)) { if ($this->dB->rename_file($this->id, $this->rename_name)) { $this->ok = "image renamed"; $this->extra_info = array('image_url' => absolute_to_url($this->image_rename), 'image_thumb_url' => absolute_to_url($this->image_thumb_rename), 'image_name' => $this->rename_name, 'image_type' => $this->image_type); } else { @rename($this->image_rename, $this->image_target); @rename($this->image_thumb_rename, $this->image_thumb_target); $this->error = 'ERR_RN:E3'; //can't rename the image (DB)" } } else { $this->error = 'ERR_RN:E2'; // can't rename the image (FS) $this->extra_info = array('image_filename' => $this->image_name . "." . $this->image_type); } }