Esempio n. 1
0
    $result = $search->find(true);
    if (!$result) {
        ic2_error('404');
    }
    $force = false;
}
if ($result) {
    // ウィルススキャンにひっかかったファイルだったら終了。
    if (!$force && $search->mime == 'clamscan/infected') {
        ic2_error('x04', '', false);
    }
    // あぼーんフラグ(rankが負)が立っていたら終了。
    if (!$force && $search->rank < 0 && !isset($_REQUEST['rank'])) {
        ic2_error('x01', '', false);
    }
    $filepath = $thumbnailer->srcPath($search->size, $search->md5, $search->mime);
    $params = array('uri' => $search->uri, 'name' => $search->name, 'size' => $search->size, 'md5' => $search->md5, 'width' => $search->width, 'height' => $search->height, 'mime' => $search->mime, 'memo' => $search->memo, 'rank' => $search->rank);
    // 自動メモ機能が有効のとき
    if ($ini['General']['automemo'] && !is_null($memo) && strpos($search->memo, $memo) === false) {
        if (is_string($search->memo) && strlen($search->memo) > 0) {
            $memo .= ' ' . $search->memo;
        }
        $update = new IC2_DataObject_Images();
        $update->memo = $params['memo'] = $memo;
        $update->whereAddQuoted('uri', '=', $search->uri);
        $update->update();
        unset($update);
    }
    // ランク変更
    if (isset($_REQUEST['rank'])) {
        $update = new IC2_DataObject_Images();
Esempio n. 2
0
    $icdb->whereAddQuoted('md5', '=', (string) $_GET['md5']);
}
if (!$icdb->find(1)) {
    echo 'null';
    exit;
}
$thumb_type = isset($_GET['t']) ? $_GET['t'] : IC2_Thumbnailer::SIZE_DEFAULT;
switch ($thumb_type) {
    case IC2_Thumbnailer::SIZE_PC:
    case IC2_Thumbnailer::SIZE_MOBILE:
    case IC2_Thumbnailer::SIZE_INTERMD:
        $thumbnailer = new IC2_Thumbnailer($thumb_type);
        break;
    default:
        $thumbnailer = new IC2_Thumbnailer();
}
$src = $thumbnailer->srcPath($icdb->size, $icdb->md5, $icdb->mime);
$thumb = $thumbnailer->thumbPath($icdb->size, $icdb->md5, $icdb->mime);
echo json_encode(array('id' => (int) $icdb->id, 'uri' => $icdb->uri, 'host' => $icdb->host, 'name' => $icdb->name, 'size' => (int) $icdb->size, 'md5' => $icdb->md5, 'width' => (int) $icdb->width, 'height' => (int) $icdb->height, 'mime' => $icdb->mime, 'rank' => (int) $icdb->rank, 'time' => (int) $icdb->time, 'memo' => $icdb->memo, 'url' => $icdb->uri, 'src' => $src && file_exists($src) ? $src : null, 'thumb' => $thumb && file_exists($thumb) ? $thumb : null));
exit;
// }}}
/*
 * Local Variables:
 * mode: php
 * coding: cp932
 * tab-width: 4
 * c-basic-offset: 4
 * indent-tabs-mode: nil
 * End:
 */
// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker:
Esempio n. 3
0
 /**
  * 画像を削除
  */
 public static function remove($target, $to_blacklist = false)
 {
     $removed_files = array();
     if (empty($target)) {
         return $removed_files;
     }
     if (!is_array($target)) {
         if (is_integer($target) || ctype_digit($target)) {
             $id = (int) $target;
             if ($id > 0) {
                 $target = array($id);
             } else {
                 return $removed_files;
             }
         } else {
             P2Util::pushInfoHtml('<p>WARNING! IC2_DatabaseManager::remove(): 不正な引数</p>');
             return $removed_files;
         }
     }
     // トランザクションの開始
     $ta = new IC2_DataObject_Images();
     $db = $ta->getDatabaseConnection();
     if ($db->phptype == 'pgsql') {
         $ta->query('BEGIN');
     } elseif ($db->phptype == 'sqlite') {
         $db->query('BEGIN;');
     }
     // 画像を削除
     foreach ($target as $id) {
         $icdb = new IC2_DataObject_Images();
         $icdb->whereAdd("id = {$id}");
         if ($icdb->find(true)) {
             // キャッシュしているファイルを削除
             $t1 = new IC2_Thumbnailer(IC2_Thumbnailer::SIZE_PC);
             $t2 = new IC2_Thumbnailer(IC2_Thumbnailer::SIZE_MOBILE);
             $t3 = new IC2_Thumbnailer(IC2_Thumbnailer::SIZE_INTERMD);
             $srcPath = $t1->srcPath($icdb->size, $icdb->md5, $icdb->mime);
             $t1Path = $t1->thumbPath($icdb->size, $icdb->md5, $icdb->mime);
             $t2Path = $t2->thumbPath($icdb->size, $icdb->md5, $icdb->mime);
             $t3Path = $t3->thumbPath($icdb->size, $icdb->md5, $icdb->mime);
             if (file_exists($srcPath)) {
                 unlink($srcPath);
                 $removed_files[] = $srcPath;
             }
             if (file_exists($t1Path)) {
                 unlink($t1Path);
                 $removed_files[] = $t1Path;
             }
             if (file_exists($t2Path)) {
                 unlink($t2Path);
                 $removed_files[] = $t2Path;
             }
             if (file_exists($t3Path)) {
                 unlink($t3Path);
                 $removed_files[] = $t3Path;
             }
             // ブラックリスト送りの準備
             if ($to_blacklist) {
                 $_blacklist = new IC2_DataObject_BlackList();
                 $_blacklist->size = $icdb->size;
                 $_blacklist->md5 = $icdb->md5;
                 if ($icdb->mime == 'clamscan/infected' || $icdb->rank == -4) {
                     $_blacklist->type = 2;
                 } elseif ($icdb->rank < 0) {
                     $_blacklist->type = 1;
                 } else {
                     $_blacklist->type = 0;
                 }
             }
             // 同一画像を検索
             $remover = new IC2_DataObject_Images();
             $remover->whereAddQuoted('size', '=', $icdb->size);
             $remover->whereAddQuoted('md5', '=', $icdb->md5);
             //$remover->whereAddQuoted('mime', '=', $icdb->mime); // SizeとMD5で十分
             $remover->find();
             while ($remover->fetch()) {
                 // ブラックリスト送りにする
                 if ($to_blacklist) {
                     $blacklist = clone $_blacklist;
                     $blacklist->uri = $remover->uri;
                     $blacklist->insert();
                 }
                 // テーブルから抹消
                 $remover->delete();
             }
         }
     }
     // トランザクションのコミット
     if ($db->phptype == 'pgsql') {
         $ta->query('COMMIT');
     } elseif ($db->phptype == 'sqlite') {
         $db->query('COMMIT;');
     }
     return $removed_files;
 }
Esempio n. 4
0
switch ($type) {
    case 'id':
        $search->whereAddQuoted('id', '=', $uri);
        break;
    case 'file':
        preg_match('/^([1-9][0-9]*)_([0-9a-f]{32})(?:\\.(jpg|png|gif))?$/', $uri, $fdata);
        $search->whereAddQuoted('size', '=', $fdata[0]);
        $search->whereAddQuoted('md5', '=', $fdata[1]);
        break;
    default:
        $search->whereAddQuoted('uri', '=', $uri);
}
if ($search->find(true)) {
    if (!empty($_GET['o'])) {
        $thumb = new IC2_Thumbnailer(IC2_Thumbnailer::SIZE_DEFAULT);
        $src = $thumb->srcPath($search->size, $search->md5, $search->mime);
        if (!file_exists($src)) {
            ic2_mkthumb_error("&quot;{$uri}&quot;のローカルキャッシュがありません。");
        } else {
            ic2_mkthumb_success(basename($src), $search->mime, $src, true, $attachment);
        }
    } else {
        $thumb = new IC2_Thumbnailer($thumb, $options);
        $result = $thumb->convert($search->size, $search->md5, $search->mime, $search->width, $search->height);
        if (PEAR::isError($result)) {
            ic2_mkthumb_error($result->getMessage());
        } else {
            $mime = $thumb->type == '.png' ? 'image/png' : 'image/jpeg';
            ic2_mkthumb_success(basename($result), $mime, $thumb->buf, false, $attachment);
        }
    }