if (!isset($_GET['id']) || !(isset($_GET['rank']) || $remove)) { echo '-1'; exit; } $id = (int) $_GET['id']; $rank = isset($_GET['rank']) ? (int) $_GET['rank'] : 0; if ($id <= 0 || $rank > 5 || $rank < -1 && !($remove && $rank == -5)) { echo '0'; exit; } // ライブラリ読み込み require_once P2EX_LIB_DIR . '/ic2/bootstrap.php'; // }}} // {{{ execute $finder = new IC2_DataObject_Images(); $finder->whereAdd(sprintf('id = %d', $id)); $code = -1; if ($finder->find(1)) { if ($rank != -5) { $setter = new IC2_DataObject_Images(); $setter->rank = $rank; $setter->whereAddQuoted('size', '=', $finder->size); $setter->whereAddQuoted('md5', '=', $finder->md5); $setter->whereAddQuoted('mime', '=', $finder->mime); if ($setter->update()) { $code = 1; } else { $code = 0; } } if ($remove) {
P2Util::header_nocache(); header('Content-Type: application/json; charset=UTF-8'); // }}} // {{{ 初期化 // パラメータを検証 if (!isset($_GET['id']) && !isset($_GET['url']) && !isset($_GET['md5'])) { echo 'null'; exit; } // ライブラリ読み込み require_once P2EX_LIB_DIR . '/ic2/bootstrap.php'; // }}} // {{{ execute $icdb = new IC2_DataObject_Images(); if (isset($_GET['id'])) { $icdb->whereAdd(sprintf('id=%d', (int) $_GET['id'])); } elseif (isset($_GET['url'])) { $icdb->whereAddQuoted('uri', '=', (string) $_GET['url']); } else { $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);
/** * メモを追加 */ public static function addMemo($target, $memo) { if (empty($target)) { return; } if (!is_array($target)) { if (is_integer($updated) || ctype_digit($updated)) { $id = (int) $updated; if ($id > 0) { $updated = array($id); } else { return; } } else { P2Util::pushInfoHtml('<p>WARNING! IC2_DatabaseManager::addMemo(): 不正な引数</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) { $find = new IC2_DataObject_Images(); $find->whereAdd("id = {$id}"); if ($find->find(true) && strpos($find->memo, $memo) === false) { $update = new IC2_DataObject_Images(); $update->whereAdd("id = {$id}"); if (strlen($find->memo) > 0) { $update->memo = $find->memo . ' ' . $memo; } else { $update->memo = $memo; } $update->update(); unset($update); } unset($find); } // トランザクションのコミット if ($db->phptype == 'pgsql') { $ta->query('COMMIT'); } elseif ($db->phptype == 'sqlite') { $db->query('COMMIT;'); } }
$operator = 'NOT ' . $operator; } $icdb->whereAddQuoted($field, $operator, $expr); } $qfe['key']->setValue($key); } // 重複画像をスキップするとき $_find_duplicated = 0; // 試験的パラメータ、登録レコード数がこれ以上の画像のみを抽出 if ($ini['Viewer']['unique'] || $_find_duplicated > 1) { $subq = 'SELECT ' . ($sort == 'ASC' ? 'MIN' : 'MAX') . '(id) FROM '; $subq .= $db->quoteIdentifier($ini['General']['table']); if (isset($keys)) { // サブクエリ内でフィルタリングするので親クエリのWHERE句をパクってきてリセット $subq .= $icdb->_query['condition']; $icdb->whereAdd(); } // md5だけでグループ化しても十分とは思うけど、一応。 $subq .= ' GROUP BY size, md5, mime'; if ($_find_duplicated > 1) { $subq .= sprintf(' HAVING COUNT(*) > %d', $_find_duplicated - 1); } // echo '<!--', mb_convert_encoding($subq, 'CP932', 'UTF-8'), '-->'; $icdb->whereAdd("id IN ({$subq})"); } // データベースを更新するとき if (isset($_POST['edit_submit']) && !empty($_POST['change'])) { $target = array_unique(array_map('intval', $_POST['change'])); switch ($mode) { // 一括でパラメータ変更 case 1: