$file_name = zip_entry_name($entry); $file_name = mb_convert_encoding($file_name, "UTF-8", $enc); // もう走査しなくていい if ($count > FORCOVER) { break; } // 画像か否か if (!is_image($file_name, $image_ext)) { continue; } // サムネイルを作るべき画像か if ($count == FORCOVER) { $data = zip_entry_read($entry, zip_entry_filesize($entry)); $ext = get_ext($file_name); $thumb = array("id" => $i + 1, "zip" => $zip_file, "filepath" => CACHE . "/thumb." . $ext, "ext" => $ext); file_put_contents($thumb["filepath"], $data); $r = make_thumbnail($thumb); if ($r) { save_thumbnail($thumb); } } $count++; } } else { //die("[ERR]ZIP_OPEN : ".$zip_file); // ここに代替画像 } zip_close($comic); } echo 'ok'; //header('Location: index.php');
function rest_put($post_id, $keys, $values, $images_name, $thumbnail_img_url) { $mysqli = new mysqli("localhost", "root", "111111", 'db_chat_member_test'); if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; } // delete old html file $sql_query = "SELECT db_filename FROM posts WHERE id = '{$post_id}'"; if ($result = $mysqli->query($sql_query)) { $row = $result->fetch_array(); if (isset($row['db_filename'])) { delete_html_file($row['db_filename']); } else { echo 'fail to select old html file from db'; } } if (isset($images_name)) { // delete old image file and add new image file $img_name_arr = explode(':', $images_name); $img_to_delete = array(); $img_to_update = array(); $query = "SELECT image_filename FROM post_images WHERE post_id = '{$post_id}'"; if ($result = $mysqli->query($query)) { if ($result->num_rows > 0) { $db_result = array(); while ($row = $result->fetch_assoc()) { array_push($db_result, $row['image_filename']); } $img_to_delete = array_diff($db_result, $img_name_arr); $img_to_update = array_diff($img_name_arr, $db_result); delete_images_by_name($img_to_delete); } else { // echo 'delete post images no select result'; $img_to_update = $img_name_arr; } } if (count($img_to_delete) > 0) { foreach ($img_to_delete as $imgname) { $sql_query = "DELETE FROM post_images WHERE post_id = '{$post_id}' \n\t\t\t\t\t\t\t\t\tAND image_filename = '{$imgname}'"; $mysqli->query($sql_query); if ($mysqli->error) { echo "Failed to delete post images : (" . $mysqli->error . ") "; } } } if (count($img_to_update) > 0) { foreach ($img_to_update as $imgname) { $query = sprintf("INSERT INTO post_images\n\t\t\t\t\t\t\t\t\t\t\t\t(post_id, image_filename)\n\t\t\t\t\t\t\t\t\t\t\t\tVALUES ('%s', '%s')", $post_id, $imgname); $mysqli->query($query); if ($mysqli->error) { echo "Failed to insert post_images db: (" . $mysqli->error . ") "; } } } } save_thumbnail($thumbnail_img_url); $thumbUserPath = 'http://localhost:8080/web_test/image_test/thumbnails/'; // update post $sql_query = "UPDATE posts SET "; $arr_size = count($keys); for ($count = 0; $count < $arr_size; $count++) { if (strcmp($keys[$count], "thumb_img_path")) { // not equal $sql_query .= " {$keys[$count]} = '{$values[$count]}'"; } else { // equal. add thumbnail server path to thumb_img_path $thumb_path = $thumbUserPath . $values[$count]; $sql_query .= " {$keys[$count]} = '{$thumb_path}'"; } if ($count != $arr_size - 1) { $sql_query .= ", "; } } $sql_query .= " WHERE id = '{$post_id}'"; $mysqli->query($sql_query); if ($mysqli->error) { echo "Failed to update posts db: (" . $mysqli->error . ") "; } $ret = array(); if ($mysqli->affected_rows == 0) { $ret['ret_val'] = "fail"; } else { $ret['ret_val'] = "success"; } $mysqli->close(); return $ret; }
mt_srand(make_seed()); if (!empty($input['file6'])) { if (!empty($config['min_size']) && filesize(_BASEPATH_ . '/tmp/' . $input['file6']) < $config['min_size']) { $input['file6'] = ''; $error = true; $topass['message']['type'] = MESSAGE_ERROR; $topass['message']['text'][] = sprintf($GLOBALS['_lang'][94], 6, $config['min_size']); } elseif (!empty($config['max_size']) && filesize(_BASEPATH_ . '/tmp/' . $input['file6']) > $config['max_size']) { $input['file6'] = ''; $error = true; $topass['message']['type'] = MESSAGE_ERROR; $topass['message']['text'][] = sprintf($GLOBALS['_lang'][95], 6, $config['max_size']); } else { mt_srand(make_seed()); $rand = mt_rand(0, 9); if (save_thumbnail(_BASEPATH_ . '/tmp/' . $input['file6'], $config['t1_width'], _BASEPATH_ . '/tmp', $filename . '_1', $config_t1) && save_thumbnail(_BASEPATH_ . '/tmp/' . $input['file6'], $config['t2_width'], _BASEPATH_ . '/tmp', $filename . '_2', $config_t2) && save_thumbnail(_BASEPATH_ . '/tmp/' . $input['file6'], $config['pic_width'], _BASEPATH_ . '/tmp', $filename . '_3', $config)) { @unlink(_BASEPATH_ . '/tmp/' . $input['file6']); $input['file6'] = $rand . '/' . $filename . '.jpg'; if (!$fileop->rename(_BASEPATH_ . '/tmp/' . $filename . '_1.jpg', _PHOTOPATH_ . '/t1/' . $input['file6']) || !$fileop->rename(_BASEPATH_ . '/tmp/' . $filename . '_2.jpg', _PHOTOPATH_ . '/t2/' . $input['file6']) || !$fileop->rename(_BASEPATH_ . '/tmp/' . $filename . '_3.jpg', _PHOTOPATH_ . '/' . $input['file6'])) { $error = true; } if ($photos_remaining > 0) { --$photos_remaining; } } else { $error = true; } } } elseif ($input['file6'] === false) { $error = true; // we should have $topass['message'] set from within upload_file();