http://opensource.org/licenses/MIT --------------------------------------------------------------------- */ if (!defined('access') or !access) { die('This file cannot be directly accessed.'); } ?> <body id="filemanager"> <div id="top"> <a href="<?php echo __CHV_ADMIN_URL__; ?> " id="logo"><img src="<?php echo absolute_to_relative(__CHV_PATH_ADMIN_SYSTEM_IMG__); ?> chevereto.png" alt="" /></a> <div id="tagline-total"> <div id="tagline">File Manager</div> <div id="total-files"></div> </div> <div id="top-links"> <a href="<?php echo __CHV_BASE_URL__; ?> " target="_blank"><?php show_lang_txt('txt_homepage'); ?> </a> <a id="logout"><?php
/** * check_theme * This cheks the consistency of the current theme... First the folder and then the files. */ function check_theme() { global $config, $install_errors; $theme_files = array('index.php', 'header.php', 'footer.php', 'uploaded.php', 'view.php', '404.php', 'delete.php'); $theme_files_minify = array('theme.js', 'style.css', 'uploadify.css'); $theme_files = array_merge_minified($theme_files, $theme_files_minify); foreach ($theme_files as $key => $value) { $theme_files[$key] = __CHV_PATH_THEME__ . $value; } if (!file_exists(__CHV_PATH_THEME__)) { $install_errors[] = 'Theme directory <code>' . absolute_to_relative(__CHV_PATH_THEME__) . '</code> doesn\'t exists.'; } else { check_files_folders($theme_files, 'File'); } if (count($install_errors) == 0) { return true; } }
function get_img_relative_url() { return absolute_to_relative(Handler::$image_target); //wea }
function show_chevereto_header() { $doctitle = check_value(get_doctitle()) ? get_doctitle() . ' - ' : ''; $html = '<script type="text/javascript" src="' . __CHV_URL_SYSTEM_JS__ . conditional_minify('jquery.js') . '"></script> <script type="text/javascript" src="' . __CHV_URL_SYSTEM_JS__ . conditional_minify('jquery.uploadify-3.1_chevereto.js') . '"></script> <script type="text/javascript" src="' . __CHV_URL_SYSTEM_JS__ . conditional_minify('functions.js') . '"></script> <script type="text/javascript" src="' . __CHV_URL_SYSTEM_JS__ . conditional_minify('chevereto.js') . '"></script> <script type="text/javascript" src="' . __CHV_URL_THEME__ . conditional_minify('theme.js') . '"></script> <link type="text/css" href="' . __CHV_URL_THEME__ . conditional_minify('style.css') . '" rel="stylesheet" /> <link type="text/css" href="' . __CHV_URL_THEME__ . conditional_minify('uploadify.css') . '" rel="stylesheet" /> <link type="image/x-icon" href="' . __CHV_URL_THEME__ . 'favicon.ico" rel="shortcut icon" /> <meta name="generator" content="Chevereto ' . get_chevereto_version() . '" /> <meta name="description" content="' . chevereto_config('meta_description') . '" /> <meta name="keywords" content="' . chevereto_config('meta_keywords') . '" /> <title>' . $doctitle . chevereto_config('doctitle') . '</title> <script type="text/javascript"> var base_url = "' . __CHV_BASE_URL__ . '"; var base_url_js = "' . __CHV_URL_SYSTEM_JS__ . '"; var uploadify_swf = "' . absolute_to_relative(__CHV_PATH_SYSTEM_JS__) . 'uploadify.swf"; var uploader_file = "' . __CHV_RELATIVE_ROOT__ . 'upload.php"; var zeroclip_swf = "' . __CHV_URL_SYSTEM_JS__ . 'ZeroClipboard.swf"; var session_id = "' . session_id() . '"; var virtual_url_image = "' . __CHV_BASE_URL__ . __CHV_VIRTUALFOLDER_IMAGE__ . '/"; var virtual_url_uploaded = "' . __CHV_BASE_URL__ . __CHV_VIRTUALFOLDER_UPLOADED__ . '/"; var config = { doctitle : "' . chevereto_config('doctitle') . '", virtual_folder_image : "' . chevereto_config('virtual_folder_image') . '", virtual_folder_uploaded : "' . chevereto_config('virtual_folder_uploaded') . '", max_filesize : "' . chevereto_config('max_filesize') . '", min_resize_size : ' . chevereto_config('min_resize_size') . ', max_resize_size : ' . chevereto_config('max_resize_size') . ', multiupload : ' . (chevereto_config('multiupload') ? "true" : "false") . ', multiupload_limit : ' . chevereto_config('multiupload_limit') . ', error_reporting : ' . (chevereto_config('error_reporting') ? "true" : "false") . ' } var ImagesUp = ' . json_encode(get_uploaded_images()) . '; var lang = ' . json_encode(get_chevereto_safe_lang()) . '; </script>'; if (check_value(chevereto_config('facebook_app_id'))) { $html .= "\n\n"; $html .= '<meta property="fb:app_id" content="' . chevereto_config('facebook_app_id') . '" />' . "\n"; $html .= '<script type="text/javascript"> (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/' . get_lang_locale() . '/all.js#xfbml=1&appId=' . chevereto_config('facebook_app_id') . '"; fjs.parentNode.insertBefore(js, fjs); }(document, "script", "facebook-jssdk"));' . "\n"; $html .= '</script>' . "\n"; } $ga = get_google_analytics(); $html .= $ga ? "\n" . $ga . "\n" : ''; $html .= "\n" . '<noscript><meta http-equiv="refresh" content="0;url=' . __CHV_BASE_URL__ . 'error-javascript" /></noscript>' . "\n"; echo $html; }
/** * 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 exception_to_error($e, $die = TRUE) { $internal_code = 500; $internal_error = '<b>' . G_APP_NAME . ' error:</b> ' . get_set_status_header_desc($internal_code); set_status_header($internal_code); // Debug levels // 0:NONE 1:ERROR_LOG 2:PRINT(NO ERROR_LOG) 3:PRINT+ERROR_LOG $debug_level = get_app_setting('debug_level'); if (!in_array($debug_level, [0, 1, 2, 3])) { $debug_level = 1; } if (in_array($debug_level, [1, 3])) { error_log($e); } if (!in_array($debug_level, [2, 3])) { // No print here die($internal_error); } $message = []; $message[] = '<b>Fatal error [' . $e->getCode() . ']:</b> ' . safe_html($e->getMessage()); $message[] = 'Triggered in ' . absolute_to_relative($e->getFile()) . ' at line ' . $e->getLine() . "\n"; $message[] = '<b>Stack trace:</b>'; $rtn = ''; $count = 0; foreach ($e->getTrace() as $frame) { $args = ''; if (isset($frame['args'])) { $args = array(); foreach ($frame['args'] as $arg) { switch (true) { case is_string($arg): if (file_exists($arg)) { $arg = absolute_to_relative($arg); } $args[] = "'" . $arg . "'"; break; case is_array($arg): $args[] = 'Array'; break; case is_null($arg): $args[] = 'NULL'; break; case is_bool($arg): $args[] = $arg ? 'true' : 'false'; break; case is_object($arg): $args[] = get_class($arg); break; case is_resource($arg): $args[] = get_resource_type($arg); break; default: $args[] = $arg; break; } } $args = join(', ', $args); } $rtn .= sprintf("#%s %s(%s): %s(%s)\n", $count, isset($frame['file']) ? absolute_to_relative($frame['file']) : 'unknown file', isset($frame['line']) ? $frame['line'] : 'unknown line', isset($frame['class']) ? $frame['class'] . $frame['type'] . $frame['function'] : $frame['function'], $args); $count++; } $message[] = $rtn; $message = implode("\n", $message); if ($die) { echo nl2br($message); die; } else { return $message; } }
echo __CHV_BASE_URL__; ?> ";</script><?php } ?> </head> <body> <div id="main"> <div id="top"><a href="http://chevereto.com/" title="Chevereto image hosting script"><img src="<?php echo absolute_to_relative(__CHV_PATH_SYSTEM__); ?> img/logo.png" id="logo" alt="Chevereto" /></a> <img src="<?php echo absolute_to_relative(__CHV_PATH_SYSTEM__); ?> img/ico-warn.png" id="icon" alt="" /></div> <p><?php echo $what_happend; ?> </p> <?php if (is_array($error_msg)) { ?> <ul> <?php foreach ($error_msg as $error) { echo '<li>' . $error . '</li>' . "\n"; } ?>