Exemplo n.º 1
0
 /**
  * login_user
  * Checks for the admin/user password
  *
  * @return	mixed
  */
 public static function login_user($password = '', $keep = '')
 {
     // Always clean the cookie and session on new login request
     if (check_value($password)) {
         unset($_SESSION["login_password"]);
         setcookie('login_password', '', time() - 3600, __CHV_RELATIVE_ROOT__, $_SERVER['SERVER_NAME']);
     }
     if (isset($_COOKIE['login_password'])) {
         $_SESSION['login_password'] = $_COOKIE['login_password'];
     }
     $admin_password = md5(chevereto_config('admin_password'));
     $user_password = md5(chevereto_config('user_password'));
     $permission = NULL;
     if ($password == $admin_password || isset($_SESSION['login_password']) && $_SESSION['login_password'] == $admin_password) {
         $permission = 'admin';
     } elseif (check_value(chevereto_config('user_password')) && ($password == $user_password || $_SESSION['login_password'] == $user_password)) {
         $permission = 'user';
     }
     if (!is_null($permission) && check_value($password) && $keep == 1) {
         setcookie('login_password', $password, time() + 60 * 60 * 24 * 30, __CHV_RELATIVE_ROOT__, $_SERVER['SERVER_NAME']);
     }
     if (!is_null($permission) && check_value($password)) {
         $_SESSION['login_password'] = $password;
     }
     if (is_null($permission)) {
         self::do_logout();
     } else {
         self::$user = $permission;
     }
     return !is_null($permission) ? $permission : false;
 }
Exemplo n.º 2
0
        }
    }
}
// No errors, attemp to do the upload process
if (!$error) {
    require_once __CHV_PATH_CLASSES__ . 'class.upload.php';
    $api_upload = new Upload($to_upload);
    if ($api_remote_upload) {
        $api_upload->is_remote = true;
    }
    $api_upload->img_upload_path = __CHV_PATH_IMAGES__;
    $api_upload->storage = chevereto_config('storage');
    $api_upload->resize_width = $to_resize;
    $api_upload->thumb_width = chevereto_config('thumb_width');
    $api_upload->thumb_height = chevereto_config('thumb_height');
    $api_upload->max_size = return_bytes(chevereto_config('max_filesize'));
    /*** Do the thing? ***/
    if ($api_upload->process()) {
        $api_status_code = 200;
        $api_status_txt = 'OK';
        // Build the data array
        $api_data_array = $api_upload->image_info;
        if ($api_upload->is_remote) {
            $api_data_array['source'] = $to_upload;
        } else {
            $api_data_array['source'] = 'base64 image string';
        }
        $api_data_array['resized'] = check_value($to_resize) ? '1' : '0';
        $api_txt_output = $api_upload->image_info['image_url'];
        // Short URL generation
        if (is_config_short_url()) {
Exemplo n.º 3
0
/**
 * api_mode
 * Returns the boolean according to the $ask_mode and API mode setted in config.php
 */
function api_mode($ask_mode)
{
    if (trim(strtolower(chevereto_config('api_mode'))) == $ask_mode) {
        return true;
    }
}
Exemplo n.º 4
0
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)) {
    $flood = is_upload_flood();
}
/*** maintenance ***/
if (preg_match('/upload|API|pref/', access) && chevereto_config('maintenance')) {
    status_header(400);
    die('maintenance');
}
/*** Call the handler ***/
if (check_value(access) && !preg_match("/API|update|pref/", access)) {
    require_once __CHV_PATH_CLASSES__ . 'class.handler.php';
    $handler = new Handler();
}
Exemplo n.º 5
0
<?php 
}
?>

</head>

<body>

<div id="wrap">
    <div id="top">
    	<a href="<?php 
show_base_url();
?>
"><img src="<?php 
show_theme_imgdir();
?>
logo.png" alt="<?php 
echo chevereto_config('site_name');
?>
" /></a>
    	<?php 
if (is_logged_user()) {
    ?>
<div id="logged">You are logged in <span class="sep">&middot;</span> <a rel="logout"><?php 
    show_lang_txt('txt_logout');
    ?>
</a></div><?php 
}
?>
    </div>
    
Exemplo n.º 6
0
			<*****@*****.**>

  Copyright (c) Rodolfo Berrios <*****@*****.**>
  
  Licensed under the MIT license
  http://opensource.org/licenses/MIT

  --------------------------------------------------------------------- */
if (!defined('access') or !access) {
    die('This file cannot be directly accessed.');
}
/**
 * This File declarates and proccess the Short URL
 */
require_once __CHV_PATH_CLASSES__ . 'class.shorturl.php';
$ShortURL = new ShortURL();
if (!check_value(chevereto_config('short_url_service'))) {
    $config['short_url_service'] = 'tinyurl';
}
$ShortURL->service = chevereto_config('short_url_service');
if (check_value(chevereto_config('short_url_user')) or check_value(chevereto_config('short_url_keypass'))) {
    $ShortURL->user = chevereto_config('short_url_user');
    $ShortURL->pass = chevereto_config('short_url_keypass');
}
if (chevereto_config('short_url_service') == "google" && !check_value(chevereto_config('short_url_keypass'))) {
    $ShortURL->pass = '******';
    // For demo / new installations only
}
if (chevereto_config('short_url_service') == 'custom' and check_value(chevereto_config('custom_short_url_api'))) {
    $ShortURL->custom_service_api = chevereto_config('custom_short_url_api');
}
Exemplo n.º 7
0
 /**
  * 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();
     }
 }
Exemplo n.º 8
0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html id="shortURL" xmlns="http://www.w3.org/1999/xhtml" <?php 
show_language_html_tags();
?>
 xmlns:fb="http://ogp.me/ns/fb#">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php 
show_image_filename();
?>
 (<?php 
show_image_dimentions();
?>
)</title>
<meta name="description" content="<?php 
echo chevereto_config('meta_description');
?>
" />
<meta name="generator" content="Chevereto <?php 
show_chevereto_version();
?>
" />
<meta content="width = device-width, initial-scale = 1.0, maximum-scale = 1.0, minimum-scale = 1.0, user-scalable = no" name="viewport">
<link href="<?php 
show_theme_url();
echo conditional_minify('style.css');
?>
" rel="stylesheet" type="text/css" />
<link href="<?php 
show_theme_url();
?>
Exemplo n.º 9
0
 /**
  * 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;
     }
 }
Exemplo n.º 10
0
function get_google_analytics()
{
    if (!check_value(chevereto_config('google_analytics_tracking_id'))) {
        return false;
    }
    return '<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(["_setAccount", "' . chevereto_config('google_analytics_tracking_id') . '"]);
  _gaq.push(["_trackPageview"]);
  (function() {
    var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;
    ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
    var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>';
}
Exemplo n.º 11
0
 /**
  * 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;
     }
 }
Exemplo n.º 12
0
	var admin_url = "<?php 
echo __CHV_ADMIN_URL__;
?>
";
	var admin_json = admin_url+"json";

	var config = {
		thumb_width : "<?php 
echo chevereto_config('thumb_width');
?>
",
		thumb_height : "<?php 
echo chevereto_config('thumb_height');
?>
",
		error_reporting : <?php 
echo chevereto_config('error_reporting') ? "true" : "false";
?>
,
		over_resize : <?php 
echo chevereto_config('over_resize') ? "true" : "false";
?>
	}
	
	var lang = <?php 
echo json_encode($lang);
?>
;
</script>

</head>
Exemplo n.º 13
0
            default:
            case 'shorturl':
                $short_url = 'image_shorturl';
                break;
            case 'direct':
                $short_url = 'image_url';
                break;
            case 'viewer':
                $short_url = 'image_viewer';
                break;
        }
        $short_url = $upload->image_info[$short_url];
        $imageInfo['image_shorturl_service'] = $ShortURL->get_ShortURL($short_url);
    }
    $_SESSION['ImagesUp'][$upload->image_info['image_id_public']] = $imageInfo;
    if (chevereto_config("error_reporting") == true) {
        $output = $upload->image_info;
    } else {
        $output = array("image_id_public" => $upload->image_info['image_id_public']);
    }
    json_output($output);
} else {
    // Translate the upload errors from the class to Chevereto's lang
    switch ($upload->error) {
        case 'error uploading':
            $error_msg = $lang['error_uploading'];
            break;
        case 'empty source':
            $error_msg = $lang['error_empty'];
            break;
        case 'invalid source':