<?php

ini_set('max_execution_time', 300);
$t = 0;
$i = 0;
$j = 0;
$array = array();
for ($j = 1; $j < 9; $j++) {
    for ($i = 0; $i < 50; $i++) {
        $source_photo = 'images/' . $j . '_' . $i . '.jpg';
        $dest_photo = 'resizeImages/' . $j . '_' . $i . '.jpg';
        if (!file_exists($dest_photo)) {
            $t++;
            $result = compress_image($source_photo, $dest_photo, 70);
        }
    }
}
if ($t == 400) {
    echo $j . "_" . $i;
} else {
    echo "skip";
}
function compress_image($source_url, $destination_url, $quality)
{
    $info = getimagesize($source_url);
    if ($info['mime'] == 'image/jpeg') {
        $image = imagecreatefromjpeg($source_url);
    } elseif ($info['mime'] == 'image/gif') {
        $image = imagecreatefromgif($source_url);
    } elseif ($info['mime'] == 'image/png') {
        $image = imagecreatefrompng($source_url);
}
$target_dir_abs = "/etc/domoleaf/www/templates/default/custom/room/";
$target_dir = "/templates/default/custom/room/";
$target_file = $target_dir_abs . basename($_FILES["fileToUpload"]["name"]);
$imageFileType = "jpg";
$uploadOk = 0;
if (!empty($_POST['id_elem']) && !empty($rooms->{$_POST['id_elem']}) && !empty($iduser)) {
    $filename = $iduser . '_' . $_POST['id_elem'] . '_' . $_SERVER['REQUEST_TIME'] . '.' . $imageFileType;
    $target_file = $target_dir_abs . $filename;
    if (empty($_FILES["fileToUpload"]["tmp_name"]) || empty($target_file)) {
        echo 0;
    }
    if (!move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        echo 0;
    }
    $compressed = compress_image($target_file, $target_file, 90);
    if (!rename($compressed, $target_file)) {
        echo 0;
    }
    $current_room = $rooms->{$_POST['id_elem']};
    if (!empty($current_room->room_bgimg)) {
        unlink($target_dir_abs . $current_room->room_bgimg);
    }
    $request = new Api();
    $request->add_request('confUserRoomBgimg', array($_POST['id_elem'], $filename, $iduser));
    $result = $request->send_request();
    $uploadOk = $target_dir . $filename;
}
echo $uploadOk;
?>
 
Example #3
0
         if ($Media["type"] == "video/mpeg" or $Media["type"] == "video/mp4" or $Media["type"] == "video/quicktime" or $Media["type"] == "video/x-ms-wmv" or $Media["type"] == "video/wmv" or $Media["type"] == "video/avi" or $Media["type"] == "video/m4v" or $Media["type"] == "video/mpv" or $Media["type"] == "video/flv" or $Media["type"] == "video/mkv") {
             include "video.php";
             #echo "3";
         }
     }
 }
 if ($Type != "") {
     #echo "4";
     if ($Media['name'] != "") {
         $Gallery_Img = "../../../uploads/{$Folder}/{$RanD}" . $Media['name'];
         $Images = $SiteInfo['domain'] . "/uploads/{$Folder}/{$RanD}" . $Media['name'];
         $Name = explode(".", $Media['name']);
         $Name = $Name['0'];
         #echo $Images;
         if ($Type == "image") {
             $filename = compress_image($Media['tmp_name'], $Gallery_Img, 90);
             $resizedFile = $Gallery_Img;
             $siz = getimagesize($resizedFile);
             list($width, $height) = getimagesize($resizedFile);
             if ($width > $height) {
                 $filename = $resizedFile;
                 $width = "1275";
                 $height = "825";
                 list($width_orig, $height_orig) = getimagesize($filename);
                 $ratio_orig = $width_orig / $height_orig;
                 if ($width / $height > $ratio_orig) {
                     $width = $height * $ratio_orig;
                 } else {
                     $height = $width / $ratio_orig;
                 }
                 $image_p = imagecreatetruecolor($width, $height);
Example #4
0
                 } else {
                     // Invalid type
                     @unlink($avatar_path . $id . '.tmp');
                     message($lang_profile['Bad type']);
                 }
             }
         }
         // Now check the width/height
         if (empty($width) || empty($height) || $width > $panther_config['o_avatars_width'] || $height > $panther_config['o_avatars_height']) {
             @unlink($avatar_path . $id . '.tmp');
             message($lang_profile['Too wide or high'] . ' ' . $panther_config['o_avatars_width'] . 'x' . $panther_config['o_avatars_height'] . ' ' . $lang_profile['pixels'] . '.');
         }
         // Delete any old avatars and put the new one in place
         delete_avatar($id);
         @rename($avatar_path . $id . '.tmp', $avatar_path . $id . $extension);
         compress_image($avatar_path . $id . $extension);
         @chmod($avatar_path . $id . $extension, 0644);
         // Disable Gravatar
         $update = array('use_gravatar' => 0);
         $data = array(':id' => $id);
         $db->update('users', $update, 'id=:id', $data);
     } else {
         message($lang_profile['Unknown failure']);
     }
     redirect(panther_link($panther_url['profile_personality'], array($id)), $lang_profile['Avatar upload redirect']);
 }
 $page_title = array($panther_config['o_board_title'], $lang_common['Profile'], $lang_profile['Upload avatar']);
 $required_fields = array('req_file' => $lang_profile['File']);
 $focus_element = array('upload_avatar', 'req_file');
 define('PANTHER_ACTIVE_PAGE', 'profile');
 require PANTHER_ROOT . 'header.php';
Example #5
0
 function kind_small()
 {
     $ext_arr = array('image' => array('gif', 'jpg', 'jpeg', 'png', 'bmp'));
     $save_path = FCPATH . '/data/';
     $save_url = 'data/';
     if (empty($_FILES) === false) {
         //原文件名
         $file_name = $_FILES['imgFile']['name'];
         //服务器上临时文件名
         $tmp_name = $_FILES['imgFile']['tmp_name'];
         //文件大小
         $file_size = $_FILES['imgFile']['size'];
         //检查文件名
         if (!$file_name) {
             $this->alert("请选择文件。");
         }
         //检查目录
         if (@is_dir($save_path) === false) {
             $this->alert("上传目录不存在。");
         }
         //检查目录写权限
         if (@is_writable($save_path) === false) {
             $this->alert("上传目录没有写权限。");
         }
         //检查是否已上传
         if (@is_uploaded_file($tmp_name) === false) {
             $this->alert("上传失败。");
         }
         /*  //检查文件大小
             if ($file_size > $max_size) {
                 $this->alert("上传文件大小超过限制。");
             }*/
         //检查目录名
         $dir_name = empty($_GET['dir']) ? 'image' : trim($_GET['dir']);
         if (empty($ext_arr[$dir_name])) {
             $this->alert("目录名不正确。");
         }
         //获得文件扩展名
         $temp_arr = explode(".", $file_name);
         $file_ext = array_pop($temp_arr);
         $file_ext = trim($file_ext);
         $file_ext = strtolower($file_ext);
         //检查扩展名
         if (in_array($file_ext, $ext_arr[$dir_name]) === false) {
             alert("上传文件扩展名是不允许的扩展名。\n只允许" . implode(",", $ext_arr[$dir_name]) . "格式。");
         }
         //创建文件夹
         if ($dir_name !== '') {
             $save_path .= $dir_name . "/";
             $save_url .= $dir_name . "/";
             if (!file_exists($save_path)) {
                 mkdir($save_path);
             }
         }
         $ymd = date("Ymd");
         $save_path .= $ymd . "/";
         $save_url .= $ymd . "/";
         if (!file_exists($save_path)) {
             mkdir($save_path);
         }
         //新文件名
         $new_file_name = date("YmdHis") . '_' . rand(10000, 99999) . '.' . $file_ext;
         //移动文件
         $file_path = $save_path . $new_file_name;
         if (move_uploaded_file($tmp_name, $file_path) === false) {
             $this->alert("上传文件失败。");
         }
         $this->load->helper('image');
         $middle_file = $save_path . $new_file_name . '263x388.png';
         $middle_file_204 = $save_path . $new_file_name . '204x204.png';
         $big_file = $save_path . $new_file_name . '458x480.png';
         $small_file = $save_path . $new_file_name . '78x78.png';
         compress_image($file_path, 263, 388, $middle_file);
         compress_image($file_path, 458, 480, $big_file);
         compress_image($file_path, 78, 78, $small_file);
         compress_image($file_path, 204, 204, $middle_file_204);
         @chmod($middle_file, 0644);
         @chmod($middle_file_204, 0644);
         @chmod($big_file, 0644);
         @chmod($small_file, 0644);
         @chmod($file_path, 0644);
         $file_url = $save_url . $new_file_name;
         $save_name = $save_url . $new_file_name;
         header('Content-type: text/html; charset=UTF-8');
         echo json_encode(array('error' => 0, 'url' => $file_url, 'align' => $save_name));
         exit;
     }
 }
Example #6
0
 public function comprimir()
 {
     if ($_POST) {
         if ($data["file"]["error"] > 0) {
             $error = $data["file"]["error"];
         } else {
             if ($data["file"]["type"] == "image/gif" || $data["file"]["type"] == "image/jpeg" || $data["file"]["type"] == "image/png" || $data["file"]["type"] == "image/pjpeg") {
                 $url = 'destination1.jpg';
                 $filename = compress_image($data["file"]["tmp_name"], $url, 80);
                 $buffer = file_get_contents($url);
                 /* Force download dialog... */
                 header("Content-Type: application/force-download");
                 header("Content-Type: application/octet-stream");
                 header("Content-Type: application/download");
                 /* Don't allow caching... */
                 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                 /* Set data type, size and filename */
                 header("Content-Type: application/octet-stream");
                 header("Content-Transfer-Encoding: binary");
                 header("Content-Length: " . strlen($buffer));
                 header("Content-Disposition: attachment; filename={$url}");
                 /* Send our file... */
                 echo $buffer;
             } else {
                 $error = "Uploaded image should be jpg or gif or png";
             }
         }
     }
 }
                $sql1 = mysql_query("Select * from USERS where UserId='{$p}'", $con);
                $row = mysql_fetch_array($sql1, MYSQL_ASSOC);
                $email = $row['EmailId'];
                $sql = mysql_query("Insert into CONTACTS(Contacts_UserId,Contacts_FromUserId,Contacts_UserName,Contacts_EmailId,Contacts_Status,IsAContact) values('{$p}','{$fromuserid}','{$email}','{$email}',0,0)", $con);
            }
        }
    } else {
        $response = array("Result" => 1);
    }
} else {
    if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
        $dest = $_FILES['userfile']['name'];
        $store_dir = $upload_dir_db . $fromuserid . $chatroomid . time() . $dest;
        $moveBool = false;
        $upload = '/afs/cad/u/h/h/hhm4/public_html/';
        $filename = compress_image($_FILES["userfile"]["tmp_name"], $upload, 80);
        $moveBool1 = move_uploaded_file(filename, "{$upload}");
        echo $moveBool1;
        $moveBool = move_uploaded_file($_FILES['userfile']['tmp_name'], "{$store_dir}");
        if ($moveBool == 1) {
            $query = mysql_query("Insert into CHATMESSAGES(ChatRoomId,FromUserId,MessageLink) values('{$chatroomid}','{$fromuserid}','{$store_dir}')", $con);
            if (mysql_affected_rows() == 1) {
                $response = array("Result" => 0);
                $update = mysql_query("select UserIds from CHATROOM_USERS where ChatRoomId='{$chatroomid}'", $con);
                $row = mysql_fetch_array($update, MYSQL_ASSOC);
                $userids = $row['UserIds'];
                $userids = explode(";", $userids);
                foreach ($userids as $p) {
                    $chk = mysql_query("Select * from CONTACTS where Contacts_FromUserId='{$fromuserid}' AND Contacts_UserId='{$p}'", $con);
                    $count = mysql_num_rows($chk);
                    if ($count == 0 && $fromuserid != $p) {
if (isset($_POST['counterserv'])) {
    $DB = new connectionDB();
    $DB->connecttoDB();
    $sqls = "DELETE FROM tblprofileservices where id ='{$memberid}'";
    $DB->runquery($sqls);
    $DB->closeDB();
    unset($DB);
    $ctrserv = mysql_real_escape_string($_POST['counterserv']);
    for ($bilanger = 0; $ctrserv > $bilanger; $bilanger++) {
        if ($_POST['service' . ($bilanger + 1)] != "" || $_POST['descser' . ($bilanger + 1)] != "") {
            if ($_FILES["fileserv" . ($bilanger + 1)]["error"] > 0) {
                $error = $_FILES["fileserv" . ($bilanger + 1)]["error"];
            } else {
                if ($_FILES["fileserv" . ($bilanger + 1)]["type"] == "image/gif" || $_FILES["fileserv" . ($bilanger + 1)]["type"] == "image/jpeg" || $_FILES["fileserv" . ($bilanger + 1)]["type"] == "image/png" || $_FILES["fileserv" . ($bilanger + 1)]["type"] == "image/pjpeg") {
                    $url = '../profilefiles/' . $foldernames . '/serv' . ($bilanger + 1) . '.jpg';
                    $filename = compress_image($_FILES["fileserv" . ($bilanger + 1)]["tmp_name"], $url, 80);
                    $buffer = file_get_contents($url);
                } else {
                    $error = "Uploaded image should be jpg or gif or png";
                }
            }
            $se = mysql_real_escape_string($_POST['service' . ($bilanger + 1)]);
            $de = mysql_real_escape_string($_POST['descser' . ($bilanger + 1)]);
            $nas = 0;
            $nas = $bilanger + 1;
            $DB = new connectionDB();
            $DB->connecttoDB();
            $sqls = "INSERT INTO tblprofileservices VALUES('{$memberid}', '{$se}' , '{$de}' , '/pccibatangas/profilefiles/{$foldernames}/serv{$nas}.jpg')";
            $DB->runquery($sqls);
            $DB->closeDB();
            unset($DB);
Example #9
0
                        list($width, $height, $type, ) = getimagesize($smiley_path . '/' . $filename . '.tmp');
                        if (empty($width) || empty($height) || $width > $panther_config['o_smilies_width'] || $height > $panther_config['o_smilies_height']) {
                            @unlink($smiley_path . '/' . $filename . '.tmp');
                            message($lang_admin_smilies['Too wide or high'] . ' ' . $panther_config['o_smilies_width'] . 'x' . $panther_config['o_smilies_height'] . ' ' . $lang_admin_smilies['pixels'] . '.');
                        } else {
                            if ($type == 1 && $uploaded_file['type'] != 'image/gif') {
                                @unlink($smiley_path . '/' . $filename . '.tmp');
                                message($lang_admin_smilies['Bad type']);
                            }
                        }
                        // Delete any old images and put the new one in place
                        @unlink($smiley_path . '/' . $filename . $extensions[0]);
                        @unlink($smiley_path . '/' . $filename . $extensions[1]);
                        @unlink($smiley_path . '/' . $filename . $extensions[2]);
                        @rename($smiley_path . '/' . $filename . '.tmp', $smiley_path . '/' . $filename . $extensions[0]);
                        compress_image($smiley_path . '/' . $filename . $extensions[0]);
                        @chmod($smiley_path . '/' . $filename . $extensions[0], 0644);
                    } else {
                        message($lang_admin_smilies['Unknown failure']);
                    }
                    redirect(panther_link($panther_url['admin_smilies']), $lang_admin_smilies['Successful Upload']);
                }
            }
        }
    }
}
$page_title = array($panther_config['o_board_title'], $lang_admin_common['Admin'], $lang_admin_common['Smilies']);
define('PANTHER_ACTIVE_PAGE', 'admin');
require PANTHER_ROOT . 'header.php';
generate_admin_menu('smilies');
$emoticons = $options = array();
Example #10
0
         list($width, $height, $file_type, ) = getimagesize($image_path . $id . '.tmp');
         if (empty($width) || empty($height) || $width > $panther_config['o_image_group_width'] || $height > $panther_config['o_image_group_height']) {
             @unlink($image_path . $id . '.tmp');
             message(sprintf($lang_admin_groups['Too wide or high'], $panther_config['o_image_group_width'], $panther_config['o_image_group_height']));
         } else {
             if ($file_type == 1 && $uploaded_file['type'] != 'image/gif') {
                 @unlink($image_path . $id . '.tmp');
                 message($lang_admin_groups['Bad type']);
             }
         }
         // Delete the old image (if it exists) and put the new one in place
         if ($panther_groups[$id]['g_image'] != '') {
             @unlink($image_path . $id . '.' . $panther_groups[$id]['g_image']);
         }
         @rename($image_path . $id . '.tmp', $image_path . $id . '.' . $type);
         compress_image($image_path . $id . '.' . $type);
         @chmod($image_path . $id . '.' . $type, 0644);
         $update = array('g_image' => $type);
         $data = array(':id' => $id);
         $db->update('groups', $update, 'g_id=:id', $data);
     } else {
         message($lang_admin_image_group['Unknown failure']);
     }
     if (!defined('FORUM_CACHE_FUNCITONS_LOADED')) {
         require PANTHER_ROOT . 'include/cache.php';
     }
     generate_groups_cache();
     redirect(panther_link($panther_url['admin_groups']), $lang_admin_groups['Image upload redirect']);
 }
 $page_title = array($panther_config['o_board_title'], $lang_admin_common['Admin'], $lang_admin_common['User groups']);
 $required_fields = array('req_file' => $lang_admin_groups['File']);
Example #11
0
                 } else {
                     // Invalid type
                     @unlink($avatar_dir . '1.tmp');
                     message($lang_admin_options['Bad type']);
                 }
             }
         }
         // Now check the width/height
         if (empty($width) || empty($height) || $width > $panther_config['o_avatars_width'] || $height > $panther_config['o_avatars_height']) {
             @unlink($avatar_dir . '1.tmp');
             message(sprintf($lang_admin_options['Too wide or high'], $panther_config['o_avatars_width'], $panther_config['o_avatars_height']));
         }
         // Delete the old default avatar
         @unlink($avatar_dir . '1.' . $panther_config['o_avatar']);
         @rename($avatar_dir . '1.tmp', $avatar_dir . '1.' . $extension);
         compress_image($avatar_dir . '1.' . $extension);
         @chmod($avatar_dir . '1.' . $extension, 0644);
         $form['avatar'] = $extension;
     }
 }
 // Convert IDN to Punycode if needed
 if (preg_match('/[^\\x00-\\x7F]/', $form['base_url'])) {
     if (!function_exists('idn_to_ascii')) {
         message($lang_admin_options['Base URL problem']);
     } else {
         $form['base_url'] = idn_to_ascii($form['base_url']);
     }
 }
 $max_file_size = return_bytes(@ini_get('upload_max_filesize'));
 $max_post_size = return_bytes(@ini_get('post_max_size'));
 $comparison = $max_file_size > $max_post_size ? $max_post_size : $max_file_size;
Example #12
0
 // IMO using if isset is an identical test
 if (isset($_FILES['userfile']['tmp_name'])) {
     // In this line I'm examining the file size and the MIME type of the file
     // to verify that the file is in the acceptable size range and is a jpeg
     // image.  MIME type testing isn't foolproof, it is possible to spoof this.
     // The size testing, however, is not spoofable.
     //if (($_FILES['userfile']['size'] > 100000) && ($_FILES['userfile']['type'] == 'image/jpeg' || $_FILES['userfile']['type'] == 'image/pjpeg'))
     //{
     $new_file_name = time() . '.jpg';
     $file_path = 'img/car_img/' . $new_file_name;
     // Give the file a new name to prevent one user from overwriting files
     // uploaded by another. mktime(), which creates a UNIX timestamp in
     // addition to the user name is good for this.
     $source_photo = $_FILES['userfile']['tmp_name'];
     $dest_photo = 'img/car_img/' . $new_file_name;
     $compressed = compress_image($source_photo, $dest_photo, 30);
     //   if (move_uploaded_file($dest_photo ,$compressed))
     //{
     echo "Upload successful!<br /><br />\n";
     echo 'File: ' . $_FILES['userfile']['name'] . ' (' . $_FILES['userfile']['size'] . ") Bytes<br />\n";
     echo "Renamed: {$new_file_name}<br />\n";
     $dbcnx = @mysql_connect("localhost", "root");
     if (!$dbcnx) {
         echo "<p>Unable to connect to the " . "database server at this time.</p>";
         exit;
     }
     // Select the  database
     if (!@mysql_select_db("cars")) {
         echo "<p>Unable to locate the database at this time.</p>";
         exit;
     }