コード例 #1
0
ファイル: uploaded.php プロジェクト: golfcrseven/scsuper
<?php

// โหลดไฟล์ inint
include '../../../bin/inint.php';
// ค่าคงที่สำหรับป้องกันการเรียกหน้าเพจโดยตรง
DEFINE('MAIN_INIT', 'load');
if (defined('MAIN_INIT')) {
    require_once ADMIN_PATH . 'inc.login.php';
    if (cms::isReferer() && $isAdmin) {
        //ค่าที่ส่งมา
        $save['module'] = $_GET['write_module'];
        $id = $_GET['write_id'];
        $last_id = $db->getRec(DB_ARCHIVE, $id);
        $save['ip'] = cms::getip();
        $save['member_id'] = $login_result['id'];
        $save['sender'] = $login_result['name'];
        //upload thumb
        $path = DATA_PATH . $save['module'] . '/';
        $valid_formats = array("jpg", "png", "gif", "JPG", "PNG", "GIF");
        $verifyToken = md5('Love_Art' . $_GET['timestamp']);
        if (!empty($_FILES) && $_GET['token'] == $verifyToken) {
            //ลบรูปเก่า..ถ้ามี
            if ($last_id['id']) {
                if (is_file(ROOT_PATH . 'images/' . $save['module'] . '/' . $last_id['picture'])) {
                    $flgDelete = unlink(ROOT_PATH . 'images/' . $save['module'] . '/' . $last_id['picture']);
                }
                if (is_file(ROOT_PATH . 'images/' . $save['module'] . '/thumb_' . $last_id['picture'])) {
                    $flgDeleteThumb = unlink(ROOT_PATH . 'images/' . $save['module'] . '/thumb_' . $last_id['picture']);
                }
            }
            include 'class.resize.php';
コード例 #2
0
ファイル: ajaximage.php プロジェクト: golfcrseven/scsuper
<?php

// โหลดไฟล์ inint
include '../../config/inint.php';
// ค่าคงที่สำหรับป้องกันการเรียกหน้าเพจโดยตรง
DEFINE('MAIN_INIT', 'load');
if (defined('MAIN_INIT') && cms::isReferer()) {
    $module = $_POST['write_module'];
    $content_id = $_POST['write_id'];
    $path = ROOT_PATH . 'img/' . $module . '/gallery/' . $content_id . '/';
    $verifyToken = md5(md5('concept71') . $_GET['tstmp']);
    if ($_GET['token'] == $verifyToken) {
        $valid_formats = array("jpg", "png", "gif", "JPG", "PNG", "GIF");
        if (isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST") {
            include 'class.resize.php';
            $image = new SimpleImage();
            if (!$_FILES["write_image"]["name"]) {
                die('Empty Files...');
            }
            if (!file_exists($path)) {
                if (!mkdir($path, 0777, true)) {
                    die('Failed to create folders...');
                }
            }
            for ($i = 0; $i < count($_FILES["write_image"]["name"]); $i++) {
                if ($_FILES["write_image"]["name"][$i] != "") {
                    $name = $_FILES['write_image']['name'][$i];
                    $size = $_FILES['write_image']['size'][$i];
                    if (strlen($name)) {
                        list($txt, $ext) = explode(".", $name);
                        if (in_array($ext, $valid_formats)) {