示例#1
0
     // 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
     // Init some things that MIGHT get set later if we're doing an IP lookup
     $single_ip = "";
     $posthistory = array();
     $banhistory = array();
     $banselect = array();