Exemple #1
0
 public function __construct()
 {
     global $fb, $app;
     $this->user = array();
     $this->img = array();
     if (adminOrder('app_mode', 'default') == 'on') {
         save_image('https://graph.facebook.com/' . $fb->username . '/picture?width=165&height=165', '__photos/__downloaded/' . $fb->username . '.jpg');
         $this->user['name'] = $fb->name;
         $this->user['username'] = $fb->username;
         $this->user['gender'] = $fb->gender;
         $this->user['email'] = '*****@*****.**';
         // Saving email is against facebook policy
         $this->user['photo'] = '__photos/__downloaded/' . $fb->username . '.jpg';
         $this->img['font'] = '__stylesheet/__fonts/' . $app['fontName'];
         $this->img['size'] = $app['fontSize'];
         $this->img['final'] = '__photos/__tmp/' . $this->user['username'] . '.jpg';
     } else {
         $this->user['name'] = 'samundra kc ';
         $this->user['username'] = '******';
         $this->user['gender'] = 'male';
         $this->user['email'] = '*****@*****.**';
         $this->user['photo'] = '__photos/__downloaded/fadkit.jpg';
         $this->img['font'] = '__stylesheet/__fonts/' . adminOrder('fontName', 'config');
         $this->img['size'] = adminOrder('fontSize', 'config');
         $this->img['final'] = '__photos/__tmp/fadkit.jpg';
     }
 }
function returnPath($path)
{
    if (strpos($path, "http://") !== false || strpos($path, "https://") !== false) {
        $upload_path = getUploadDirPath(basename($path));
        save_image($path, UPLOAD_CAR_IMAGES . $upload_path);
        return $upload_path;
    }
}
function images($params)
{
    global $template_file;
    $template_file = '';
    $data = array();
    //
    $data['path'] = implode('/', $params);
    $files_path = STATIC_FILES_ROOT . $data['path'] . '/';
    if (!is_dir($files_path)) {
        mkdir($files_path, 0775, true);
    }
    //
    if (isset($_FILES['file']) && isset($_FILES['file']['tmp_name']) && $_FILES['file']['tmp_name'] != '') {
        include 'interfaces/image_magic.php';
        move_uploaded_file($_FILES['file']['tmp_name'], $files_path . $_FILES['file']['name']);
        $new_name = time() . '.jpg';
        $image = load_image($files_path . $_FILES['file']['name']);
        save_image($image, $files_path . $new_name, 'jpg');
        //
        $thumbnail = thumbnail($image, 160);
        save_image($thumbnail, $files_path . 'thumb_' . $new_name, 'jpg');
        //
        unlink($files_path . $_FILES['file']['name']);
        imagedestroy($image);
        imagedestroy($thumbnail);
    }
    //
    $data['files'] = array();
    if ($dh = opendir($files_path)) {
        while (($file = readdir($dh)) !== false) {
            if ($file == '.' || $file == '..' || is_dir($files_path . '/' . $file)) {
            } else {
                if (substr($file, 0, 6) == 'thumb_') {
                    $filemtime = filemtime($files_path . '/' . $file);
                    $type = strtolower(substr($file, strrpos($file, '.') + 1));
                    $file_size = filesize($files_path . '/' . $file);
                    $data['files'][] = array('type' => $type, 'file_size' => intval($file_size / 10.24) / 100, 'created_at' => $filemtime, 'thumb' => $file, 'name' => substr($file, 6));
                }
            }
        }
        closedir($dh);
    }
    return $data;
}
Exemple #4
0
 function crop_image_square($source, $destination, $image_type, $square_size, $image_width, $image_height, $quality)
 {
     if ($image_width <= 0 || $image_height <= 0) {
         return false;
     }
     //return false if nothing to resize
     if ($image_width > $image_height) {
         $y_offset = 0;
         $x_offset = ($image_width - $image_height) / 2;
         $s_size = $image_width - $x_offset * 2;
     } else {
         $x_offset = 0;
         $y_offset = ($image_height - $image_width) / 2;
         $s_size = $image_height - $y_offset * 2;
     }
     $new_canvas = imagecreatetruecolor($square_size, $square_size);
     //Create a new true color image
     //Copy and resize part of an image with resampling
     if (imagecopyresampled($new_canvas, $source, 0, 0, $x_offset, $y_offset, $square_size, $square_size, $s_size, $s_size)) {
         save_image($new_canvas, $destination, $image_type, $quality);
     }
     return true;
 }
function parser($url, $url_str, $site, $str_query)
{
    global $maxCountOfRequest, $countOfRequest, $count_tablename, $captcha_tablename, $activity_tablename, $time_start, $endUrl, $user_id, $delta, $countRequest, $seacher, $img_captcha;
    //-------------------проверяем чтобы количество обращений не превышало допустимое-----------------------------------------------
    if ($countOfRequest >= $maxCountOfRequest) {
        $query = "SELECT accessdate FROM {$count_tablename} WHERE user_id = '{$user_id}' AND seacher = '{$seacher}'";
        $result = mysql_query($query);
        if (!$result) {
            error_message(mysql_error());
        }
        $query_data = mysql_fetch_array($result);
        $accessdate = $query_data['accessdate'];
        //        $todayU = intval(date("U")) + (!date('I')) * 60 * 60;
        $todayU = intval(date("U"));
        $accessU = intval(strtotime($accessdate));
        // в россии нет зимнего времени
        //        if (!date('I'))
        //            $winter = 1;
        //        else
        //            $winter = 0;
        //        $todayDate = mktime(date("H") + $winter, date("i"), date("s"), date("m"), date("d"), date("Y"));
        $todayDate = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y"));
        $accessdate = date("Y-m-d H:i:s", $todayDate);
        $diff = $todayU - $accessU;
        /*
         * Если перерыв больше $delta сбрасываем счетчик и записываем новое время
         * при последующем обновлении count в $count_tablename время не обновляется до истечения времени $delta
         */
        if ($diff > $delta) {
            $countOfRequest = 0;
            $query = "UPDATE {$count_tablename} SET count = '0', accessdate = '{$accessdate}' WHERE user_id = '{$user_id}' AND seacher = '{$seacher}'";
            $result = mysql_query($query);
            if (!$result) {
                error_message(mysql_error());
            }
        } else {
            $query = "UPDATE {$count_tablename} SET count = '{$countOfRequest}' WHERE user_id = '{$user_id}' AND seacher = '{$seacher}'";
            $result = mysql_query($query);
            if (!$result) {
                error_message(mysql_error());
            }
            $diff = $delta - $diff;
            $houer = floor($diff / (60 * 60));
            $min = floor($diff / 60) - $houer * 60;
            $sec = $diff - $houer * 60 * 60 - $min * 60;
            $time = $houer . ":" . $min . ":" . $sec;
            echo $time;
            //---------------------Говорим что закончили парсинг---------------------
            //            $query = "UPDATE $activity_tablename SET bool = '0' WHERE seacher = '$seacher'";
            //            $result = mysql_query($query);
            //
            //            if (!$result) {
            //                error_message(mysql_error());
            //            }
            exit;
        }
    }
    //-------------------------------------------------------------------------------------------------------------------------
    $response = curl($url_str, $url);
    //подключаем регулярные выражения поиска сайтов и навигации
    require 'google_regexp.php';
    if (count($matches[0]) == 0) {
        //парсим страницу с капчей
        preg_match_all('/<img src="([^>"]+?)"[^>]+?>/i', $response, $matches);
        //URL of image with captcha
        $imgSrc = 'http://www.' . $url . $matches[1][0];
        preg_match_all('/<form action="([^>"]+?)"[^>]+?>/i', $response, $matches);
        //Value of Input.continue
        $action = $matches[1][0];
        preg_match_all('/<input type="hidden" name="continue" value="([^>]+?)">/i', $response, $matches);
        //Value of Input.continue
        $continue = urlencode($matches[1][0]);
        preg_match_all('/<input type="hidden" name="id" value="([^>]+?)">/i', $response, $matches);
        //Value of Input.id
        $id = $matches[1][0];
        preg_match_all('/<input type="submit" name="submit" value="([^>"]+?)"[^>]+?>/i', $response, $matches);
        //Value of Input.submit
        $submit = $matches[1][0];
        if ($id && $continue) {
            // т.е страница с капчей
            //сохраним $countOfRequest в базу
            $query = "UPDATE {$count_tablename} SET count = '{$countOfRequest}' WHERE user_id = '{$user_id}' AND seacher = '{$seacher}'";
            $result = mysql_query($query);
            if (!$result) {
                error_message(mysql_error());
            }
            //---------------------Говорим что закончили парсинг----------------
            //            $query = "UPDATE $activity_tablename SET bool = '0' WHERE seacher = '$seacher'";
            //            $result = mysql_query($query);
            //
            //            if (!$result) {
            //                error_message(mysql_error());
            //            }
            //            //---------------------Говорим что выдана страница скапчей----------
            //            // в россии нет зимнего времени
            //            if (!date('I'))
            //                $winter = 1;
            //            else
            //                $winter = 0;
            //            $todayDate = mktime(date("H") + $winter, date("i"), date("s"), date("m"), date("d"), date("Y"));
            //            $accessdate = date("Y-m-d H:i:s", $todayDate);
            //
            //            $query = "UPDATE $captcha_tablename SET bool = '1', accessdate = '$accessdate' WHERE seacher = '$seacher'";
            //            $result = mysql_query($query);
            //
            //            if (!$result) {
            //                error_message(mysql_error());
            //            }
            //
            //            echo 0;
            save_image($imgSrc, $url, $img_captcha);
            $img_captcha = dirname($_SERVER['PHP_SELF']) . '/' . $img_captcha;
            $todayU = intval(date("U"));
            $htmlCaptcha = "<form action='sendCaptcha.php' method='Get'>\n            <img src='{$img_captcha}" . "?date={$todayU}'" . "/>\n            <div id='reload' onClick='reloadGoogle(" . '"' . $url_str . '"' . ");'>reload</div><br/>\n            <input type = 'text' id = 'captcha' name = 'captcha' value = '' size = '12'/><br/>\n            <input type = 'hidden' id = 'action' name = 'action' value = '{$action}'/>\n            <input type = 'hidden' id = 'continue' name = 'continue' value = '{$continue}'/>\n            <input type = 'hidden' id = 'id' name = 'id' value = '{$id}'/>\n            <input type = 'hidden' id = 'user_id' name = 'user_id' value = '{$user_id}'/>\n            <input type = 'hidden' id = 'submitG' name = 'submitG' value = '{$submit}'/>\n            <input value = 'Отправить' id = 'submit2' type = 'submit' onClick = 'SubmitCaptchaGoogle(" . '"' . $url_str . '"' . ");return false;'/><br/>\n\n            </form>";
            print_r($htmlCaptcha);
            exit;
        } else {
            echo 'regexp error';
            return 0;
        }
    }
    $countOfRequest++;
    $countRequest++;
    foreach ($matches_nav[1] as $i => $v) {
        $href_nav[$page_nav[1][$i]] = "http://www." . $url . $v;
    }
    foreach ($matches[1] as $v) {
        $href[] = $v;
    }
    //$href - array of URL of site
    /* echo "url=".$url."</br>";
       echo "str_query=".$str_query."</br>";
       echo "url_str=".$url_str."</br></br>"; */
    //Поиск сайта
    foreach ($href as $i => $value) {
        preg_match('/^(www.)?([^\\/]+)/i', $value, $matchesSite);
        preg_match('/^(www.)?(.+)/i', $value, $matchesSiteFull);
        $i++;
        //Пуникод - рускоязычные домены в utf-8
        $punycode = $matchesSite[2];
        $punycodeFull = $matchesSiteFull[2];
        $idn = new idna_convert(array('idn_version' => 2008));
        $punycode = stripos($punycode, 'xn--') !== false ? $idn->decode($punycode) : $idn->encode($punycode);
        $punycodeFull = stripos($punycodeFull, 'xn--') !== false ? $idn->decode($punycodeFull) : $idn->encode($punycodeFull);
        $arrayHref = explode('/', $value);
        $value = '';
        foreach ($arrayHref as $val) {
            if ($val) {
                $val = stripos($val, 'xn--') !== false ? $idn->decode($val) : $idn->encode($val);
                $value .= $val . '/';
            }
        }
        $punycode = mb_strtolower($punycode, "UTF-8");
        $punycodeFull = mb_strtolower($punycodeFull, "UTF-8");
        $site = mb_strtolower($site, "UTF-8");
        //        echo"<br/>";
        //        echo $punycode;
        //        echo"<br/>";
        //        echo $site;
        //        echo"<br/>";
        if ($punycode == $site || $punycodeFull == $site) {
            $statistic = array("statistic", $i, $site, $value);
            return $statistic;
        }
    }
    if (is_array($href_nav)) {
        return $href_nav;
    } else {
        return 0;
    }
    //просмотр клиентских HTTP заголовков
    /* echo"<b>HTTP Headers:</b></br>";
       foreach (getallheaders() as $name => $value) {
       echo "$name: $value</br>";
       }
       echo"</br>"; */
    //Вывод URL найденых сайтов и следующих сраниц выдачи
    /* $i=1;
          foreach($href as $val){
          echo"<b>$i -- $val</b></br>";
          $i++;
          }
    
          foreach($href_nav as $key => $val){
          echo"<b>$key => $val</b></br>";
          } */
}
    preg_match_all('/<form action="([^>"]+?)"[^>]+?>/i', $response, $matches);
    //Value of Input.continue
    $action = $matches[1][0];
    preg_match_all('/<input type="hidden" name="continue" value="([^>]+?)">/i', $response, $matches);
    //Value of Input.continue
    $continue = urlencode($matches[1][0]);
    preg_match_all('/<input type="hidden" name="id" value="([^>]+?)">/i', $response, $matches);
    //Value of Input.id
    $id = $matches[1][0];
    preg_match_all('/<input type="submit" name="submit" value="([^>]+?)" [^>]+?>/i', $response, $matches);
    //Value of Input.submit
    $submit = $matches[1][0];
    //        echo $action;
    //        echo"<br/>";
    //        echo $endUrl;
    //        echo"<br/>";
    //        echo $imgSrc;
    $todayU = intval(date("U"));
    if ($id && $continue) {
        save_image($imgSrc, $url, $img_captcha);
        $img_captcha = dirname($_SERVER['PHP_SELF']) . '/' . $img_captcha;
        $htmlCaptcha = "<form action='sendCaptcha.php' method='Get'><img src='{$img_captcha}" . "?date={$todayU}'" . "/>\n            <div id='reload' onClick='reloadGoogle(" . '"' . $url_str2 . '"' . ");'>reload</div><br/>\n            <input type = 'text' id = 'captcha' name = 'captcha' value = '' size = '12'/><br/>\n            <input type = 'hidden' id = 'action' name = 'action' value = '{$action}'/>\n            <input type = 'hidden' id = 'continue' name = 'continue' value = '{$continue}'/>\n            <input type = 'hidden' id = 'id' name = 'id' value = '{$id}'/>\n            <input type = 'hidden' id = 'user_id' name = 'user_id' value = '{$user_id}'/>\n            <input type = 'hidden' id = 'submitG' name = 'submitG' value = '{$submit}'/>\n            <input value = 'Отправить' id = 'submit2' type = 'submit' onClick = 'SubmitCaptchaGoogle(" . '"' . $url_str2 . '"' . ");return false;'/><br/>\n\n            </form>";
        print_r($htmlCaptcha);
    } else {
        //        print($response);
        echo 'Капча отправлена';
    }
} else {
    //    print($response);
    echo 'Капча отправлена';
}
Exemple #7
0
function crop_image_square($source, $destination, $image_type, $square_size, $image_width, $image_height, $quality)
{
    if ($image_width <= 0 || $image_height <= 0) {
        return false;
    }
    if ($image_width > $image_height) {
        $y_offset = 0;
        $x_offset = ($image_width - $image_height) / 2;
        $s_size = $image_width - $x_offset * 2;
    } else {
        $x_offset = 0;
        $y_offset = ($image_height - $image_width) / 2;
        $s_size = $image_height - $y_offset * 2;
    }
    $new_canvas = imagecreatetruecolor($square_size, $square_size);
    if (imagecopyresampled($new_canvas, $source, 0, 0, $x_offset, $y_offset, $square_size, $square_size, $s_size, $s_size)) {
        return save_image($new_canvas, $destination, $image_type, $quality);
    }
    return false;
}
    // DB에 파일내용 저장 성공시
    if ($mysqli->affected_rows > 0) {
        // 9. 업로드 파일을 새로 만든 파일명으로 변경 및 이동
        if (move_uploaded_file($_FILES['image']['tmp_name'], $filePath . $fileName)) {
            // 10. 성공시 db저장 내용을 적용(커밋)
            $mysqli->commit();
        } else {
            // 실패시 db에 저장했던 내용 취소를 위한 롤백
            $mysqli->rollback();
            exit("업로드 실패");
        }
        // if
    }
    // if
    $image_saving_info = array("id" => $insert_id);
    $mysqli->close();
    return $image_saving_info;
}
$possible_url = array("save_image");
$value = "An error has occurred";
// echo 'request temp title : '.$_FILES['image']['tmp_name'].'<br>';
// echo 'request 11 title : '.$_POST["title"].'<br>';
if (isset($_POST["title"]) && $_FILES['image']['size'] > 0) {
    // echo 'temp filename : '.$_FILES['image']['tmp_name'].'<br>';
    // echo 'temp filesize : '.$_FILES['image']['size'].'<br>';
    $value = save_image();
} else {
    $value = "Missing argument";
}
// return JSON array
exit(json_encode($value));
 /**
  * Expand image to a square
  *
  * @param object File
  * @return boolean
  */
 function userimg_expand_to_square(&$File)
 {
     if (!$File->is_image()) {
         // This must be an image:
         return false;
     }
     $Filetype =& $File->get_Filetype();
     if (!$Filetype) {
         // File type must be, otherwise we cannot work with this file:
         return false;
     }
     // Get image size:
     $image_size = $File->get_image_size('widthheight_assoc');
     if ($image_size['width'] == $image_size['height']) {
         // We should not expand this image because it is already a square:
         return false;
     }
     load_funcs('files/model/_image.funcs.php');
     // Load image:
     list($err, $src_imh) = load_image($File->get_full_path(), $Filetype->mimetype);
     if (!empty($err)) {
         // Error on image loading:
         return false;
     }
     // Expand image to square ---- START:
     // Use max side as square size for width & height:
     $expanded_image_size = max($image_size);
     if ($image_size['width'] > $image_size['height']) {
         // If width is more than height then we should center image vertically:
         $dst_x = 0;
         $dst_y = ceil(($expanded_image_size - $image_size['height']) / 2);
     } else {
         // If width is less than height then we should center image horizonatally:
         $dst_x = ceil(($expanded_image_size - $image_size['width']) / 2);
         $dst_y = 0;
     }
     // Create canvas for new image with white background:
     $dst_imh = imagecreatetruecolor($expanded_image_size, $expanded_image_size);
     $white_color = imagecolorallocate($dst_imh, 255, 255, 255);
     imagefill($dst_imh, 0, 0, $white_color);
     if (!@imagecopyresampled($dst_imh, $src_imh, $dst_x, $dst_y, 0, 0, $image_size['width'], $image_size['height'], $image_size['width'], $image_size['height'])) {
         // If func imagecopyresampled is not defined for example:
         return false;
     }
     // Expand image to square ---- END.
     // Save image:
     save_image($dst_imh, $File->get_full_path(), $Filetype->mimetype);
     // Remove the old thumbnails:
     $File->rm_cache();
     return true;
 }
Exemple #10
0
/**
 * @param $file (string)      - путь к большой картинке
 * @param $watermark (string) - путь к водяному знаку
 * @param $coords (array)     - массив координат
 * @param $opacity (double)   - значение прозрачности
 * @param $dist (string)      - путь к сгенерированной картинке
 * @param $flag (string)    - флаг - одна картинка накладывается или растрируется
 *
 *
 */
function merge_watermark($file, $watermark, $coords, $opacity, $dist, $flag)
{
    $data = array();
    if (!file_exists($file) || !file_exists($watermark)) {
        $data['status'] = "NO";
        $data['message'] = "Большая картинка или водяной знак не загружены";
        $data['url'] = '';
    } else {
        // Проверяем, есть ли такая папка
        if (!file_exists($dist)) {
            mkdir($dist, 777);
        }
        // считываем сигнатуру изображения
        $file_sign = exif_imagetype($file);
        $watermark_sing = exif_imagetype($watermark);
        // Если были переданы не верные картинки
        if (!$file_sign || !$watermark_sing) {
            $data['status'] = "NO";
            $data['message'] = "Были загружены некорректные изображения";
            $data['url'] = '';
        } else {
            // Объекты
            $file_img_object = create_image_object($file_sign, $file);
            $watermark_img_object = create_image_object($watermark_sing, $watermark);
            // если не удалось создать один из объектов
            if (!$file_img_object['object'] || !$watermark_img_object['object']) {
                $data['status'] = "NO";
                $data['message'] = "Возникла ошибка при генерации изображения";
                $data['url'] = '';
            } else {
                // уменьшаем изображение
                $file_img_object['object'] = resize_img($file, $file_img_object, 648, 536);
                // упрощаем массив координат
                $simple_coords = simpled_coords($coords, $flag);
                // не верно переданны координаты
                if (!$simple_coords) {
                    $data['status'] = "NO";
                    $data['message'] = "Не верное переданны координаты";
                    $data['url'] = '';
                } else {
                    // накладываем изображения по координатам
                    foreach ($simple_coords as $item_coord) {
                        imagecopymerge($file_img_object['object'], $watermark_img_object['object'], $item_coord['left'], $item_coord['top'], 0, 0, $watermark_img_object['size']['width'], $watermark_img_object['size']['height'], $opacity);
                    }
                    // получаем результат
                    $result = save_image($file_img_object, $dist);
                    // Если не получилось сгенерировать изображение
                    if (!$result['flag']) {
                        $data['status'] = "NO";
                        $data['message'] = "Ошибка сохранения изображения";
                        $data['url'] = '';
                    } else {
                        $data['status'] = "OK";
                        $data['message'] = "Изображение успешно сгенерированно";
                        $data['url'] = $result['src'];
                    }
                }
            }
        }
    }
    echo json_encode($data);
    exit;
}
Exemple #11
0
         $_SESSION['firephp']->log('longer than 60 minutes');
         $these_hours = floor($_POST['media_item_length_minutes_input'] / 60);
         $these_minutes = $_POST['media_item_length_minutes_input'] - $these_hours * 60;
     } else {
         $these_minutes = $_POST['media_item_length_minutes_input'];
     }
     //in case there were any hours input
     $these_hours += $_POST['media_item_length_hours_input'];
     $query .= "\n\t\t\t,'{$these_hours}:{$these_minutes}:00'\n\t  \t\t";
     $_SESSION['firephp']->log("'{$these_hours}:{$these_minutes}:00'");
 } else {
     $query .= ",null";
 }
 if (preg_match('@^http://.*@', $_POST['media_item_image_location_input'])) {
     //TODO:watch for images like this [http://imagelocation/something.php?image.jpg&h=200&w=100]
     $filename = save_image($_POST['media_item_image_location_input'], 'images/media_items/');
     if (!$filename) {
         $_SESSION['firephp']->error("there was a problem saving {$_POST['media_item_image_location_input']}");
     } else {
         $query .= ",'{$filename}'";
     }
 } else {
     $query .= ",'{$_POST['media_item_image_location_input']}'";
 }
 $query .= "\n\t  \t\t,'{$_POST['media_item_rating_input']}'\n\t  \t\t,'{$_POST['media_item_notes_input']}'\n\t  \t\t,'{$_POST['media_item_medium_input']}'\n\t  \t\t,'{$_POST['media_item_barcode_input']}'\n\t  \t\t,'{$_POST['media_item_isbn_input']}'\n\t  \t\t,'{$_POST['storage_slot_id_input']}'\n\t  \t)\n\t  \t";
 //insert record
 mysql_query($query) or $_SESSION['firephp']->error(mysql_error());
 $query = "select media_items.id from media_items where media_items.id = LAST_INSERT_ID()";
 $query_result = mysql_query($query) or $_SESSION['firephp']->error(mysql_error());
 $result_array = mysql2array($query_result);
 $media_id = $result_array[0]['id'];
Exemple #12
0
<?php

// echo '<pre>';
// var_dump($_FILES);
if (isset($_FILES['image']) && $_FILES['image']['error'] == '') {
    $tmp_name = save_image($_FILES['image']);
    insert_path_image($tmp_name);
}
$content_template_name = 'add_picture.php';
include 'view/base.php';
function capture()
{
    if (date("H") > 18 && date("H") < 00) {
        //is between 6pm and 8am dont capture images
        return;
    }
    echo 'starting</br>';
    $imgdata = get_image();
    if ($imgdata) {
        $saved = save_image($imgdata);
        if ($saved) {
            echo 'saved </br>';
        }
    } else {
        echo 'image not saved </br>';
    }
    $cameraposition = get_position();
    echo $cameraposition;
    next_position($cameraposition);
    move_cam($cameraposition);
}
Exemple #14
0
/**
 * Rotate the JPEG image if EXIF Orientation tag is defined
 *
 * @param string File name (with full path)
 * @param resource Image resource ( result of the function imagecreatefromjpeg() ) (by reference)
 * @param boolean TRUE - to save the rotated image in the end of this function
 */
function exif_orientation($file_name, &$imh, $save_image = false)
{
    global $Settings;
    if (!$Settings->get('exif_orientation')) {
        // Autorotate is disabled
        return;
    }
    if (!function_exists('exif_read_data')) {
        // EXIF extension is not loaded
        return;
    }
    $EXIF = exif_read_data($file_name);
    if (!(isset($EXIF['Orientation']) && in_array($EXIF['Orientation'], array(3, 6, 8)))) {
        // EXIF Orientation tag is not defined OR we don't interested in current value
        return;
    }
    load_funcs('files/model/_image.funcs.php');
    if (is_null($imh)) {
        // Create image resource from file name
        $imh = imagecreatefromjpeg($file_name);
    }
    if (!$imh) {
        // Image resource is incorrect
        return;
    }
    switch ($EXIF['Orientation']) {
        case 3:
            // Rotate for 180 degrees
            $imh = @imagerotate($imh, 180, 0);
            break;
        case 6:
            // Rotate for 90 degrees to the right
            $imh = @imagerotate($imh, 270, 0);
            break;
        case 8:
            // Rotate for 90 degrees to the left
            $imh = @imagerotate($imh, 90, 0);
            break;
    }
    if (!$imh) {
        // Image resource is incorrect
        return;
    }
    if ($save_image) {
        // Save rotated image
        save_image($imh, $file_name, 'image/jpeg');
    }
}
Exemple #15
0
function scale_image($source, $destination, $type, $width, $height, $quality, $method)
{
    global $twidth;
    global $theight;
    global $fwidth;
    global $fheight;
    if ($method === 'thumb') {
        $max_width = 240;
        $max_height = 240;
    } else {
        $max_width = 1200;
        $max_height = 800;
    }
    $scale = min($max_width / $width, $max_height / $height);
    $new_width = ceil($scale * $width);
    $new_height = ceil($scale * $height);
    if ($method === 'thumb') {
        $twidth = $new_width;
        $theight = $new_height;
    } else {
        $fwidth = $new_width;
        $fheight = $new_height;
    }
    $new_canvas = imagecreatetruecolor($new_width, $new_height);
    if (imagecopyresampled($new_canvas, $source, 0, 0, 0, 0, $new_width, $new_height, $width, $height)) {
        save_image($new_canvas, $destination, $type, $quality);
    }
    return true;
}
Exemple #16
0
/**
 * Rotate the JPEG image if EXIF Orientation tag is defined
 *
 * @param string File name (with full path)
 * @param resource Image resource ( result of the function imagecreatefromjpeg() ) (by reference)
 * @param boolean TRUE - to save the rotated image in the end of this function
 */
function exif_orientation($file_name, &$imh, $save_image = false)
{
    global $Settings;
    if (!$Settings->get('exif_orientation')) {
        // Autorotate is disabled
        return;
    }
    if (!function_exists('exif_read_data')) {
        // Exif extension is not loaded
        return;
    }
    $image_info = array();
    getimagesize($file_name, $image_info);
    if (!isset($image_info['APP1']) || strpos($image_info['APP1'], 'Exif') !== 0) {
        // This file format is not an 'Exchangeable image file format' so there are no Exif data to read
        return;
    }
    if (($exif_data = exif_read_data($file_name)) === false) {
        // Could not read Exif data
        return;
    }
    if (!(isset($exif_data['Orientation']) && in_array($exif_data['Orientation'], array(3, 6, 8)))) {
        // Exif Orientation tag is not defined OR we don't interested in current value
        return;
    }
    load_funcs('files/model/_image.funcs.php');
    if (is_null($imh)) {
        // Create image resource from file name
        $imh = imagecreatefromjpeg($file_name);
    }
    if (!$imh) {
        // Image resource is incorrect
        return;
    }
    switch ($exif_data['Orientation']) {
        case 3:
            // Rotate for 180 degrees
            $imh = @imagerotate($imh, 180, 0);
            break;
        case 6:
            // Rotate for 90 degrees to the right
            $imh = @imagerotate($imh, 270, 0);
            break;
        case 8:
            // Rotate for 90 degrees to the left
            $imh = @imagerotate($imh, 90, 0);
            break;
    }
    if (!$imh) {
        // Image resource is incorrect
        return;
    }
    if ($save_image) {
        // Save rotated image
        save_image($imh, $file_name, 'image/jpeg');
    }
}
function parser($url, $url_str, $site, $str_query)
{
    global $countOfRequest, $endUrl, $img_captcha;
    $response = curl($url_str, $url);
    //подключаем регулярные выражения поиска сайтов и навигации
    require 'google_regexp.php';
    if (count($matches[0]) == 0) {
        //парсим страницу с капчей
        preg_match_all('/<img src="([^>"]+?)"[^>]+?>/i', $response, $matches);
        //URL of image with captcha
        $imgSrc = 'http://www.' . $url . $matches[1][0];
        preg_match_all('/<form action="([^>"]+?)"[^>]+?>/i', $response, $matches);
        //Value of Input.continue
        $action = $matches[1][0];
        preg_match_all('/<input type="hidden" name="continue" value="([^>]+?)">/i', $response, $matches);
        //Value of Input.continue
        $continue = urlencode($matches[1][0]);
        preg_match_all('/<input type="hidden" name="id" value="([^>]+?)">/i', $response, $matches);
        //Value of Input.id
        $id = $matches[1][0];
        preg_match_all('/<input type="submit" name="submit" value="([^>"]+?)"[^>]+?>/i', $response, $matches);
        //Value of Input.submit
        $submit = $matches[1][0];
        save_image($imgSrc, $url, $img_captcha);
        //        echo $action;
        //        echo"<br/>";
        /*
         * При попытке обновить капчу function reload по урл $endUrl говорит что такой страницы не существует
         * обновляется при повторении запроса по $url_str
         */
        //        echo"<br/>";
        //        echo $imgSrc;
        if ($id && $continue) {
            $htmlCaptcha = "<form action='sendCaptcha.php' method='Get'>\n            <img src='{$img_captcha}'/>\n            <div id='reload' onClick='reload(" . '"' . $url_str . '"' . ");'>reload</div><br/>\n            <input type = 'text' id = 'captcha' name = 'captcha' value = '' size = '12'/><br/>\n            <input type = 'hidden' id = 'action' name = 'action' value = '{$action}'/>\n            <input type = 'hidden' id = 'continue' name = 'continue' value = '{$continue}'/>\n            <input type = 'hidden' id = 'id' name = 'id' value = '{$id}'/>\n            <input type = 'hidden' id = 'submitG' name = 'submitG' value = '{$submit}'/>\n            <input value = 'Отправить' id = 'submit2' type = 'submit' onClick = 'SubmitCaptcha(" . '"' . $url_str . '"' . ");return false;'/><br/>\n\n            </form>";
            print_r($htmlCaptcha);
            //            print($response);
            exit;
        } else {
            return 0;
        }
    }
    $countOfRequest++;
    foreach ($matches_nav[1] as $i => $v) {
        $href_nav[$page_nav[1][$i]] = "http://www." . $url . $v;
    }
    foreach ($matches[1] as $v) {
        $href[] = $v;
    }
    //$href - array of URL of site
    /* echo "url=".$url."</br>";
       echo "str_query=".$str_query."</br>";
       echo "url_str=".$url_str."</br></br>"; */
    //Поиск сайта
    foreach ($href as $i => $value) {
        preg_match('/^(www.)?([^\\/]+)/i', $value, $matchesSite);
        $i++;
        if ($matchesSite[2] == $site) {
            $statistic = array("statistic", $i, $site, $value);
            return $statistic;
        }
    }
    return $href_nav;
    //просмотр клиентских HTTP заголовков
    /* echo"<b>HTTP Headers:</b></br>";
       foreach (getallheaders() as $name => $value) {
       echo "$name: $value</br>";
       }
       echo"</br>"; */
    //Вывод URL найденых сайтов и следующих сраниц выдачи
    /* $i=1;
          foreach($href as $val){
          echo"<b>$i -- $val</b></br>";
          $i++;
          }
    
          foreach($href_nav as $key => $val){
          echo"<b>$key => $val</b></br>";
          } */
}
Exemple #18
0
/**
 * Crop image
 *
 * @param object File
 * @param integer X coordinate (in percents)
 * @param integer Y coordinate (in percents)
 * @param integer Width (in percents)
 * @param integer Height (in percents)
 * @param integer Min size of width or height (in pixels), 0 - to don't limit
 * @param integer Max size of width or height (in pixels), 0 - to don't limit
 * @return boolean TRUE if cropping is successful
 */
function crop_image($File, $x, $y, $width, $height, $min_size = 0, $max_size = 0)
{
    $Filetype =& $File->get_Filetype();
    if (!$Filetype) {
        // Error
        return false;
    }
    // Load image
    list($err, $src_imh) = load_image($File->get_full_path(), $Filetype->mimetype);
    if (!empty($err)) {
        // Error
        return false;
    }
    $src_width = imagesx($src_imh);
    $src_height = imagesy($src_imh);
    $x = $src_width * ($x / 100);
    $y = $src_height * ($y / 100);
    $width = $src_width * ($width / 100);
    $height = $src_height * ($height / 100);
    $dest_width = $width;
    $dest_height = $height;
    if ($max_size > 0) {
        // Check if we should limit by max size
        $dest_width = $dest_width > $max_size ? $max_size : $dest_width;
        $dest_height = $dest_height > $max_size ? $max_size : $dest_height;
    }
    if ($min_size > 0) {
        // Check if we should limit by min size
        $width = $width < $min_size ? $min_size : $width;
        $height = $height < $min_size ? $min_size : $height;
    }
    if ($x + $width > $src_width) {
        // Shift a crop X position to the left if the crop width is over image width
        $x = $src_width - $width;
    }
    if ($y + $height > $src_height) {
        // Shift a crop Y position to the top if the crop height is over image height
        $y = $src_height - $height;
    }
    $dst_imh = imagecreatetruecolor($dest_width, $dest_height);
    // Crop image
    if (!@imagecopyresampled($dst_imh, $src_imh, 0, 0, $x, $y, $dest_width, $dest_height, $width, $height)) {
        // If func imagecopyresampled is not defined for example:
        return false;
    }
    // Save image
    save_image($dst_imh, $File->get_full_path(), $Filetype->mimetype);
    // Remove the old thumbnails
    $File->rm_cache();
    return true;
}
Exemple #19
0
/**
 * Rotate image
 *
 * @param object File
 * @param integer # degrees to rotate
 * @return boolean TRUE if rotating is successful
 */
function rotate_image($File, $degrees)
{
    $Filetype =& $File->get_Filetype();
    if (!$Filetype) {
        // Error
        return false;
    }
    // Load image
    list($err, $imh) = load_image($File->get_full_path(), $Filetype->mimetype);
    if (!empty($err)) {
        // Error
        return false;
    }
    // Rotate image
    if (!($imh = @imagerotate($imh, (int) $degrees, 0))) {
        // If func imagerorate is not defined for example:
        return false;
    }
    // Save image
    save_image($imh, $File->get_full_path(), $Filetype->mimetype);
    // Remove the old thumbnails
    $File->rm_cache();
    return true;
}
Exemple #20
0
            $thumb_h = $img_h;
            // name of the thumbnail will, however, contain the original width and height of src (to match the name given by core 'thumbnail' editable region)
            $thumb_name = $path_parts['filename'] . '-' . round(imagesx($image)) . 'x' . round(imagesy($image)) . '.' . $path_parts['extension'];
        } else {
            $thumb_name = $path_parts['filename'] . '-' . round($thumb_w) . 'x' . round($thumb_h) . '.' . $path_parts['extension'];
        }
        $thumbnail = $path_parts['dirname'] . '/' . $thumb_name;
        $thumbnail_url = $Config['k_append_url'] . $Config['UserFilesPath'] . 'image/' . pathinfo($img, PATHINFO_DIRNAME) . '/' . $thumb_name;
        // create a new true color image
        $canvas = imagecreatetruecolor($thumb_w, $thumb_h);
        imagealphablending($canvas, false);
        // Create a new transparent color for image
        $color = imagecolorallocatealpha($canvas, 0, 0, 0, 127);
        // Completely fill the background of the new image with allocated color.
        imagefill($canvas, 0, 0, $color);
        // Restore transparency blending
        imagesavealpha($canvas, true);
        // copy from src into the thumbnail
        imagecopyresampled($canvas, $image, 0, 0, $img_x, $img_y, $thumb_w, $thumb_h, $img_w, $img_h);
        // save to disk
        save_image($mime_type, $canvas, $thumbnail, $t_quality);
        // remove image from memory
        imagedestroy($canvas);
        // Job done. Exit.
        die('OK:' . $thumbnail_url);
    } else {
        die('Image not found');
    }
} else {
    die('No GD image library installed');
}
<?php

require __DIR__ . '/../src/bootstrap_admin.php';
if (has_post()) {
    if (array_key_exists('image', $_FILES)) {
        $image = $_FILES['image'];
        if (!is_file_type_allowed($image['type'])) {
            header('Location: /admin/index.php');
            die;
        }
        $moved = move_uploaded_file($image['tmp_name'], __DIR__ . '/../img/products/' . $image['name']);
        $image_data = ['product_id' => $_POST['product_id'], 'src' => $image['name'], 'description' => ''];
        save_image($image_data);
    }
    header('Location: /admin/index.php');
    die;
}
if (!array_key_exists('product_id', $_GET)) {
    header('Location: /admin/index.php');
    die;
}
echo render_admin_template('add_image_to_product', ['product_id' => $_GET['product_id'], 'user' => get_current_admin_user()]);
Exemple #22
0
function k_resize_image($src, $dest = 0, $new_width = 0, $new_height = 0, $zoom_crop = 1, $enforce_max = 0, $quality = 80, $crop_position = 'middle', $check_thumb_exists = 0)
{
    global $FUNCS;
    // check to see if GD function exist
    if (!function_exists('imagecreatetruecolor')) {
        return displayError('GD Library Error: imagecreatetruecolor does not exist - please contact your webhost and ask them to install the GD library');
    }
    if (trim($src) == '') {
        return displayError('Source image not set');
    }
    // get mime type of src
    $mime_type = mime_type($src);
    ini_set('memory_limit', "50M");
    // make sure that the src is gif/jpg/png
    if (!valid_src_mime_type($mime_type)) {
        return displayError("Invalid src mime type: " . $mime_type);
    }
    if (strlen($src) && file_exists($src)) {
        // open the existing image
        $image = open_image($mime_type, $src);
        if ($image === false) {
            return displayError('Unable to open image : ' . $src);
        }
        // Get original width and height
        $width = imagesx($image);
        $height = imagesy($image);
        // generate new w/h if not provided
        if ($new_width && !$new_height) {
            $new_height = $height * ($new_width / $width);
        } elseif ($new_height && !$new_width) {
            $new_width = $width * ($new_height / $height);
        } elseif (!$new_width && !$new_height) {
            $new_width = $width;
            $new_height = $height;
        }
        // If new dimensions cannot exceed certain values
        if ($enforce_max) {
            // the supplied width and height were actually the max permissible values.
            $max_width = $new_width;
            $max_height = $new_height;
            // make the new values the same as that of the source image
            $new_width = $width;
            $new_height = $height;
            // if new dimensions already within bounds (and this not a thumbnail that we are creating), return.
            if ($dest && $new_width <= $max_width && $new_height <= $max_height) {
                return;
            }
            if ($new_width > $max_width) {
                if (!$zoom_crop) {
                    $ratio = (double) ($max_width / $new_width);
                    $new_width = (int) ($new_width * $ratio);
                    $new_height = (int) ($new_height * $ratio);
                } else {
                    $new_width = $max_width;
                }
            }
            // if new height still overshoots maximum value
            if ($new_height > $max_height) {
                if (!$zoom_crop) {
                    $ratio = (double) ($max_height / $new_height);
                    $new_width = (int) ($new_width * $ratio);
                    $new_height = (int) ($new_height * $ratio);
                } else {
                    $new_height = $max_height;
                }
            }
        }
        // Create filename if not provided one (happens only for thumbnails)
        if (!$dest) {
            $path_parts = $FUNCS->pathinfo($src);
            $thumb_name = $path_parts['filename'] . '-' . round($new_width) . 'x' . round($new_height) . '.' . $path_parts['extension'];
            $thumbnail = $path_parts['dirname'] . '/' . $thumb_name;
            if ($check_thumb_exists && file_exists($thumbnail)) {
                return $thumb_name;
            }
        }
        // create a new true color image
        $canvas = imagecreatetruecolor($new_width, $new_height);
        imagealphablending($canvas, false);
        // Create a new transparent color for image
        $color = imagecolorallocatealpha($canvas, 0, 0, 0, 127);
        // Completely fill the background of the new image with allocated color.
        imagefill($canvas, 0, 0, $color);
        // Restore transparency blending
        imagesavealpha($canvas, true);
        if ($zoom_crop) {
            $src_x = $src_y = 0;
            $src_w = $width;
            $src_h = $height;
            $cmp_x = $width / $new_width;
            $cmp_y = $height / $new_height;
            // if new dimensions equal to the original (and this not a thumbnail that we are creating), return.
            if ($dest && $cmp_x == 1 && $cmp_y == 1) {
                return;
            }
            // calculate x or y coordinate and width or height of source
            if ($cmp_x > $cmp_y) {
                $src_w = round($width / $cmp_x * $cmp_y);
                $src_x = round(($width - $width / $cmp_x * $cmp_y) / 2);
            } elseif ($cmp_y > $cmp_x) {
                $src_h = round($height / $cmp_y * $cmp_x);
                $src_y = round(($height - $height / $cmp_y * $cmp_x) / 2);
            }
            switch ($crop_position) {
                case 'top_left':
                    $src_x = 0;
                    $src_y = 0;
                    break;
                case 'top_center':
                    $src_y = 0;
                    break;
                case 'top_right':
                    $src_x *= 2;
                    $src_y = 0;
                    break;
                case 'middle_left':
                    $src_x = 0;
                    break;
                case 'middle':
                    break;
                case 'middle_right':
                    $src_x *= 2;
                    break;
                case 'bottom_left':
                    $src_x = 0;
                    $src_y *= 2;
                    break;
                case 'bottom_center':
                    $src_y *= 2;
                    break;
                case 'bottom_right':
                    $src_x *= 2;
                    $src_y *= 2;
                    break;
            }
            imagecopyresampled($canvas, $image, 0, 0, $src_x, $src_y, $new_width, $new_height, $src_w, $src_h);
        } else {
            // copy and resize part of an image with resampling
            imagecopyresampled($canvas, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
        }
        if (!$dest) {
            $dest = $thumbnail;
        }
        // output image to browser based on mime type
        save_image($mime_type, $canvas, $dest, $quality);
        // remove image from memory
        imagedestroy($canvas);
        return $thumb_name;
    } else {
        if (strlen($src)) {
            return displayError("image " . $src . " not found");
        } else {
            return displayError("no source specified");
        }
    }
    return;
}
<?php

require "config.php";
require "libs.php";
header("Content-Type: application/json; charset=utf-8");
set_params(array("user_id", "center_x", "center_y", "image"));
$image_path = save_image($image, $user_id);
$command = $python . " " . $inserter . " " . $user_id . " " . $image_path . " " . $center_x . " " . $center_y . " 2>&1";
//echo $command."\n";
// $command = "cat ".dirname(__FILE__)."\sample.dat";
exec($command, $stdout, $exit_code);
if ($exit_code) {
    var_dump($stdout);
    echo json_encode(array("error" => "registeration engine error"));
    exit;
} else {
    echo json_encode(array("success" => "awesome!"));
    exit;
}
Exemple #24
0
 /**
  * Save thumbnail for file
  *
  * @param resource
  * @param string size name
  * @param string mimetype of thumbnail
  * @param string short error code
  */
 function save_thumb_to_cache($thumb_imh, $size_name, $thumb_mimetype, $thumb_quality = 90)
 {
     $af_thumb_path = $this->get_af_thumb_path($size_name, $thumb_mimetype, true);
     if ($af_thumb_path[0] != '!') {
         // We obtained a path for the thumbnail to be saved:
         return save_image($thumb_imh, $af_thumb_path, $thumb_mimetype, $thumb_quality);
     }
     return $af_thumb_path;
     // !Error code
 }
            save_yt_order($connection);
            break;
        case 5:
            save_image_order($connection);
            break;
        case 6:
            save_section_order($connection);
            break;
        case 7:
            save_section($connection);
            break;
        case 8:
            save_youtube($connection);
            break;
        case 9:
            save_image($connection);
            break;
        case 10:
            add_section($connection);
            break;
        case 11:
            add_youtube($connection);
            break;
        case 12:
            add_image($connection);
            break;
        default:
            print '[["ERROR"]["Save had an invalid ID"]]';
    }
}
/* Navigation items */
/**
 * Stretch image
 *
 * @param mixed $input
 * @param string $dest_file
 * @param integer $new_width
 * @param integer $new_height
 * @param mixed $output_type
 * @param integer $quality
 * @return null
 */
function stretch_image($input, $dest_file, $new_width, $new_height, $output_type = null, $quality = 80)
{
    if (!extension_loaded('gd')) {
        return false;
    }
    // if
    if (is_array($input) && array_key_exists('type', $input) && array_key_exists('resource', $input)) {
        $open_image = $input;
        $close_resource = false;
    } else {
        $open_image = open_image($input);
        $close_resource = true;
        if (!is_array($open_image)) {
            throw new Error(lang('Could not parse image: ' . $input));
            return false;
        }
        // if
    }
    // if
    $image_type = $open_image['type'];
    $image = $open_image['resource'];
    if ($output_type === null) {
        $output_type = $image_type;
    }
    // if
    $width = imagesx($image);
    $height = imagesy($image);
    $resulting_image = imagecreatetruecolor($new_width, $new_height);
    if (can_use_image_alpha($output_type)) {
        imagealphablending($resulting_image, false);
        imagesavealpha($resulting_image, true);
        $alpha = imagecolorallocatealpha($resulting_image, 255, 255, 255, 127);
        imagefilledrectangle($resulting_image, 0, 0, $new_width, $new_height, $alpha);
    } else {
        $white_color = imagecolorallocate($resulting_image, 255, 255, 255);
        imagefill($resulting_image, 0, 0, $white_color);
    }
    // if
    imagecopyresampled($resulting_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
    if ($close_resource) {
        imagedestroy($image);
    }
    // if
    $result = save_image($image, $dest_file, $output_type, $quality);
    return $result;
}
Exemple #27
0
function SaveRemoteImage($html)
{
    import('Common.Org.phpQuery.phpQuery', '', '.php');
    $obj = phpQuery::newDocumentHTML($html);
    $images = pq($hobj)->find('img');
    foreach ($images as $item) {
        $src = save_image(pq($item)->attr('src'));
        if ($src) {
            pq($item)->attr('src', $src);
        }
    }
    return html_encode(pq($obj)->html());
}
<?php

function save_image($inPath, $outPath)
{
    //Download images from remote server
    $in = fopen($inPath, "rb");
    $out = fopen($outPath, "wb");
    while ($chunk = fread($in, 8192)) {
        fwrite($out, $chunk, 8192);
    }
    fclose($in);
    fclose($out);
}
save_image('http://graph.facebook.com/100000881073253/picture', 'facebook.jpg');
save_image('http://a0.twimg.com/profile_images/457031171/favicoblogfreakz_bigger.png', 'twitter.jpg');
//link tham khao http://blogfreakz.com/php/how-to-save-image-from-url-using-php/
Exemple #29
0
        fatal('Invalid width');
    } else {
        if ($height <= 0 || $height > MAX_IM_SIZE) {
            fatal('Invalid height');
        }
    }
    $im = imagecreatetruecolor($width, $height);
    if (!$im) {
        fatal('Failed to create image.');
    }
    $bgcolor = imagecolorallocate($im, 255, 255, 255);
    imagefill($im, 0, 0, $bgcolor);
    imagetruecolortopalette($im, false, 256);
    imagesavealpha($im, false);
    $imagekey = create_image_key();
    save_image($im, $imagekey);
    imagedestroy($im);
    header("Location: ?op=edit&imagekey={$imagekey}");
} else {
    ?>
<div class="article">
    <h2>Create your new pixel art!</h2>
    <form action="?op=new" method="POST">
        <label for="width">Image width (max <?php 
    echo MAX_IM_SIZE;
    ?>
):</label>
        <input type="number" id="width" name="width" value="<?php 
    echo MAX_IM_SIZE;
    ?>
" min="1" max="<?php 
Exemple #30
0
    $cliparts_path = $_GET['cliparts'];
    if ($type == 'send' || $type == 'snap') {
        $data = $_POST['img'];
        list($format, $data) = explode(';', $data, 2);
        list(, $data) = explode(',', $data, 2);
        $data = str_replace(' ', '+', $data);
        $data = base64_decode($data);
        /*
        $path = $_FILES["image"]["tmp_name"];
        $img = imagecreatefrompng($path);
        imagepng($img, "out.png");
        */
        global $IMAGES_PATH;
        $id = $user->getId();
        $path = $IMAGES_PATH . "/" . $id . ".png";
        if ($type == 'snap') {
            file_put_contents($path, $data);
        } else {
            $path = save_image($id, $user->getName(), $data);
        }
        imagefusion($path, $cliparts_path, $path);
        echo $path;
    } else {
        echo "Invalide type";
    }
} else {
    require_once "view/montage.view.php";
}
?>