示例#1
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:
示例#2
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;
 }
示例#3
0
         $add += $chk;
     } elseif ($mode == 2) {
         $mng = IC2_EditForm::imgManager($img, $status);
         $add += $mng;
     }
 }
 // オリジナル画像が存在しないレコードを自動で削除
 if ($ini['Viewer']['delete_src_not_exists'] && !file_exists($add['src'])) {
     $add['thumb_k'] = $add['thumb'] = 'img/ic_removed.png';
     $add['t_width'] = $add['t_height'] = 32;
     $to_blacklist = false;
     $removed_files = array_merge($removed_files, IC2_DatabaseManager::remove(array($img['id'], $to_blacklist)));
     $flexy->setData('toBlackList', $to_blacklist);
 } else {
     // サムネイルのパスのみdevicePixelRatioが影響するので再取得
     $add['thumb'] = $thumb->thumbPath($icdb->size, $icdb->md5, $icdb->mime);
     if (!file_exists($add['thumb'])) {
         // レンダリング時に自動でhtmlspecialchars()されるので&amp;にしない
         $add['thumb'] = 'ic2.php?r=' . $r_type . '&t=1';
         if (file_exists($add['src'])) {
             $add['thumb'] .= '&id=' . $img['id'];
         } else {
             $add['thumb'] .= '&uri=' . rawurlencode($img['uri']);
         }
         if ($dpr === 1.5 || $dpr === 2.0) {
             $add['thumb'] .= '&d=' . $dpr;
         }
     }
     if ($_conf['ktai']) {
         $add['thumb_k'] = 'ic2.php?r=0&t=2';
         if (file_exists($add['src'])) {