コード例 #1
0
ファイル: lookups.php プロジェクト: taqsuqs/drydock
 $db = new ThornModDBI();
 // Image lookup!
 if (isset($_GET['action']) && $_GET['action'] == "imglookup") {
     $url = trim($_GET['url']);
     // Generate a regex pattern that'll capture the image index
     // from the directory name
     $pattern = "/^" . preg_quote(THurl, '/') . "images\\/(\\d+)\\/.*\$/i";
     $matches = array();
     // use this as a preg_match param
     echo $pattern;
     // Die if we can't parse this properly
     if (preg_match($pattern, $url, $matches) == 0) {
         THdie("Invalid image URL '" . $url . "' specified.");
     }
     // $matches[1] should have the captured imgidx
     $post_location = $db->getpostfromimgidx($matches[1]);
     if ($post_location == null) {
         THdie("Post with imgidx " . $matches[1] . " not found.");
     }
     // If we got this far, then we have a valid result.
     $board_folder = $db->getboardname($post_location['board']);
     // get the board folder name
     // And now we redirect.
     if (THuserewrite) {
         header("Location: " . THurl . $board_folder . "/thread/" . $post_location['thread_loc'] . "#" . $post_location['post_loc']);
     } else {
         header("Location: " . THurl . "drydock.php?b=" . $board_folder . "&i=" . $post_location['thread_loc'] . "#" . $post_location['post_loc']);
     }
     die;
 } else {
     // Imglookup is the only one that actually uses a redirect, the rest uses the adminlookup template