notfound.php
27 lines
| 1014 B
| text/x-php
|
PhpLexer
/ strips / notfound.php
| r10 | <?php | |||
| require_once('../frontend.inc.php'); | ||||
| require_once('../admin/include/admin.inc.php'); | ||||
| /* Provide clean data */ | ||||
| if( !preg_match('/(\d{4})\.(\w{3})$/', $_SERVER['REQUEST_URI'], $request) ) | ||||
| term('404 Not Found'); | ||||
| $stripnumber = (int) $strip[0]; | ||||
| $extention = mysql_real_escape_string($request[2]); | ||||
| /* Determine if the requested strip exists and is published */ | ||||
| $qr = mysqli_query($link, "SELECT strip.id AS id, media_t.extension AS ext | ||||
| FROM strip JOIN media_t ON strip.media = media_t.id | ||||
| WHERE strip.id = $stripnumber AND media_t.extension = '$extension' AND strip.published < NOW()"); | ||||
| if(!( $strip = mysqli_fetch_array($qr) )) | ||||
| term('404 Not Found'); | ||||
| if( @rename(sprintf('restricted/%04d.%s', $strip[0], $strip[1]), sprintf('%04d.%s', $strip[0], $strip[1])) ) { | ||||
| /* We are the first one to get here, post to Twitter */ | ||||
| twitterpost( urlencode("Comic ".$strip[0]." posted: ".SITE_HOST.SITE_PATH."/strip/".$strip[0]) ); | ||||
| } | ||||
| header("Location: $_SERVER[REQUEST_URI]"); | ||||
| ?> | ||||
