From 9bbf3caafb4ca434dfb295452fed951d7a19f727 Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Sat, 19 Sep 2009 19:53:15 -0700 Subject: [PATCH] first commit --- .htaccess | 11 + .svn/all-wcprops | 23 + .svn/entries | 145 ++++ .svn/prop-base/favicon.ico.svn-base | 5 + .svn/text-base/.htaccess.svn-base | 11 + .svn/text-base/favicon.ico.svn-base | Bin 0 -> 1150 bytes .svn/text-base/imgboard.php.svn-base | 348 ++++++++ css/.svn/all-wcprops | 23 + css/.svn/entries | 137 +++ css/.svn/text-base/burichan.css.svn-base | 181 ++++ css/.svn/text-base/futaba.css.svn-base | 150 ++++ css/.svn/text-base/global.css.svn-base | 83 ++ css/burichan.css | 181 ++++ css/futaba.css | 150 ++++ css/global.css | 83 ++ favicon.ico | Bin 0 -> 1150 bytes imgboard.php | 348 ++++++++ inc/.svn/all-wcprops | 29 + inc/.svn/entries | 167 ++++ .../text-base/database_flatfile.php.svn-base | 254 ++++++ .../text-base/database_mysql.php.svn-base | 195 +++++ inc/.svn/text-base/functions.php.svn-base | 262 ++++++ inc/.svn/text-base/html.php.svn-base | 461 ++++++++++ inc/database_flatfile.php | 254 ++++++ inc/database_mysql.php | 195 +++++ inc/flatfile/.svn/all-wcprops | 17 + inc/flatfile/.svn/entries | 96 +++ .../.svn/text-base/flatfile.php.svn-base | 807 ++++++++++++++++++ .../text-base/flatfile_utils.php.svn-base | 112 +++ inc/flatfile/flatfile.php | 807 ++++++++++++++++++ inc/flatfile/flatfile_utils.php | 112 +++ inc/functions.php | 262 ++++++ inc/html.php | 461 ++++++++++ res/.svn/all-wcprops | 5 + res/.svn/entries | 35 + src/.svn/all-wcprops | 5 + src/.svn/entries | 35 + thumb/.svn/all-wcprops | 5 + thumb/.svn/entries | 35 + 39 files changed, 6490 insertions(+) create mode 100644 .htaccess create mode 100644 .svn/all-wcprops create mode 100644 .svn/entries create mode 100644 .svn/prop-base/favicon.ico.svn-base create mode 100644 .svn/text-base/.htaccess.svn-base create mode 100644 .svn/text-base/favicon.ico.svn-base create mode 100644 .svn/text-base/imgboard.php.svn-base create mode 100644 css/.svn/all-wcprops create mode 100644 css/.svn/entries create mode 100644 css/.svn/text-base/burichan.css.svn-base create mode 100644 css/.svn/text-base/futaba.css.svn-base create mode 100644 css/.svn/text-base/global.css.svn-base create mode 100644 css/burichan.css create mode 100644 css/futaba.css create mode 100644 css/global.css create mode 100644 favicon.ico create mode 100644 imgboard.php create mode 100644 inc/.svn/all-wcprops create mode 100644 inc/.svn/entries create mode 100644 inc/.svn/text-base/database_flatfile.php.svn-base create mode 100644 inc/.svn/text-base/database_mysql.php.svn-base create mode 100644 inc/.svn/text-base/functions.php.svn-base create mode 100644 inc/.svn/text-base/html.php.svn-base create mode 100644 inc/database_flatfile.php create mode 100644 inc/database_mysql.php create mode 100644 inc/flatfile/.svn/all-wcprops create mode 100644 inc/flatfile/.svn/entries create mode 100644 inc/flatfile/.svn/text-base/flatfile.php.svn-base create mode 100644 inc/flatfile/.svn/text-base/flatfile_utils.php.svn-base create mode 100644 inc/flatfile/flatfile.php create mode 100644 inc/flatfile/flatfile_utils.php create mode 100644 inc/functions.php create mode 100644 inc/html.php create mode 100644 res/.svn/all-wcprops create mode 100644 res/.svn/entries create mode 100644 src/.svn/all-wcprops create mode 100644 src/.svn/entries create mode 100644 thumb/.svn/all-wcprops create mode 100644 thumb/.svn/entries diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..e6daf3a --- /dev/null +++ b/.htaccess @@ -0,0 +1,11 @@ +DirectoryIndex index.html +AddCharset UTF-8 .html +AddCharset UTF-8 .php + + + +Header add Pragma "no-cache" +Header add Cache-Control "no-cache" +Header unset Vary + + \ No newline at end of file diff --git a/.svn/all-wcprops b/.svn/all-wcprops new file mode 100644 index 0000000..1f3bc6a --- /dev/null +++ b/.svn/all-wcprops @@ -0,0 +1,23 @@ +K 25 +svn:wc:ra_dav:version-url +V 21 +/svn/!svn/ver/1/trunk +END +imgboard.php +K 25 +svn:wc:ra_dav:version-url +V 35 +/svn/!svn/ver/10/trunk/imgboard.php +END +.htaccess +K 25 +svn:wc:ra_dav:version-url +V 31 +/svn/!svn/ver/4/trunk/.htaccess +END +favicon.ico +K 25 +svn:wc:ra_dav:version-url +V 33 +/svn/!svn/ver/7/trunk/favicon.ico +END diff --git a/.svn/entries b/.svn/entries new file mode 100644 index 0000000..86160e7 --- /dev/null +++ b/.svn/entries @@ -0,0 +1,145 @@ +10 + +dir +1 +https://tinyib.googlecode.com/svn/trunk +https://tinyib.googlecode.com/svn + + + +2009-04-28T06:13:22.144594Z +1 + + + + + + + + + + + + + + + +ac9068a4-33bb-11de-8a2e-13aa1706fec1 + +thumb +dir + +src +dir + +css +dir + +res +dir + +inc +dir + +imgboard.php +file +10 + + + +2009-09-19T21:46:36.687500Z +cbd0009edf136e903db25ef38fe53ae1 +2009-09-19T21:48:28.690807Z +10 +tslocum + + + + + + + + + + + + + + + + + + + + + +11975 + +.htaccess +file +4 + + + +2009-08-10T14:35:37.140625Z +39d69df67a127e3914df8916452324c4 +2009-09-04T03:12:19.723445Z +4 +tslocum + + + + + + + + + + + + + + + + + + + + + +225 + +favicon.ico +file +7 + + + +2009-08-15T04:35:52.000000Z +c07f4742f5123d08c9b3f379042c9658 +2009-09-16T19:10:07.306932Z +7 +tslocum +has-props + + + + + + + + + + + + + + + + + + + + +1150 + diff --git a/.svn/prop-base/favicon.ico.svn-base b/.svn/prop-base/favicon.ico.svn-base new file mode 100644 index 0000000..5e9587e --- /dev/null +++ b/.svn/prop-base/favicon.ico.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff --git a/.svn/text-base/.htaccess.svn-base b/.svn/text-base/.htaccess.svn-base new file mode 100644 index 0000000..e6daf3a --- /dev/null +++ b/.svn/text-base/.htaccess.svn-base @@ -0,0 +1,11 @@ +DirectoryIndex index.html +AddCharset UTF-8 .html +AddCharset UTF-8 .php + + + +Header add Pragma "no-cache" +Header add Cache-Control "no-cache" +Header unset Vary + + \ No newline at end of file diff --git a/.svn/text-base/favicon.ico.svn-base b/.svn/text-base/favicon.ico.svn-base new file mode 100644 index 0000000000000000000000000000000000000000..fcff32f061c39da6cb6433e4ba409416109dfc87 GIT binary patch literal 1150 zcmeH@u?~YU3`DPjjRgsb6-GX-f8VVm;S7rOWI;D38g$9|{LEnK<*)DMd)B*^MoEk1 z$jOoW+0W2Pq5rvU0|kE$PoZ^b^E^TJnA4M?4<^@~tDa1FsxrUcJWrNA=2t%RxjvgC g6P`NbADxxb=#UrXO@+Rb^$9ihmi-#F^UBn@4Y%(&JOBUy literal 0 HcmV?d00001 diff --git a/.svn/text-base/imgboard.php.svn-base b/.svn/text-base/imgboard.php.svn-base new file mode 100644 index 0000000..e3413f3 --- /dev/null +++ b/.svn/text-base/imgboard.php.svn-base @@ -0,0 +1,348 @@ + $val) { $_GET[$key] = stripslashes($val); } + foreach ($_POST as $key => $val) { $_POST[$key] = stripslashes($val); } +} +if (get_magic_quotes_runtime()) { set_magic_quotes_runtime(0); } + +$tinyib = array(); +$tinyib['board'] = "b"; // Identifier for this board using only letters and numbers +$tinyib['boarddescription'] = "TinyIB"; // Displayed in the logo area +$tinyib['maxthreads'] = 100; // Set this to limit the number of threads allowed before discarding older threads. 0 to disable +$tinyib['logo'] = ""; // Logo HTML +$tinyib['tripseed'] = ""; // Text to use when generating secure tripcodes +$tinyib['adminpassword'] = ""; // Text entered at the manage prompt to gain administrator access +$tinyib['modpassword'] = ""; // Same as above, but only has access to delete posts. Blank ("") to disable +$tinyib['databasemode'] = "flatfile"; // flatfile or mysql + +// mysql settings +$mysql_host = "localhost"; +$mysql_username = ""; +$mysql_password = ""; +$mysql_database = ""; +$mysql_posts_table = $tinyib['board'] . "_posts"; +$mysql_bans_table = "bans"; + +function fancyDie($message) { + die('' . $message . ''); +} + +// Check directories are writable by the script +$writedirs = array("res", "src", "thumb"); +if ($tinyib['databasemode'] == 'flatfile') { $writedirs[] = "inc/flatfile"; } +foreach ($writedirs as $dir) { + if (!is_writable($dir)) { + fancyDie("Directory '" . $dir . "' can not be written to! Please modify its permissions."); + } +} + +$includes = array("inc/functions.php", "inc/html.php"); +if ($tinyib['databasemode'] == 'flatfile') { + $includes[] = 'inc/database_flatfile.php'; +} elseif ($tinyib['databasemode'] == 'mysql') { + $includes[] = 'inc/database_mysql.php'; +} else { + fancyDie("Unknown database mode specificed"); +} + +foreach ($includes as $include) { + include $include; +} + +if ($tinyib['tripseed'] == '' || $tinyib['adminpassword'] == '') { + fancyDie('$tinyib[\'tripseed\'] and $tinyib[\'adminpassword\'] still need to be configured!'); +} + +$redirect = true; +// Check if the request is to make a post +if (isset($_POST["message"]) || isset($_POST["file"])) { + $ban = banByIP($_SERVER['REMOTE_ADDR']); + if ($ban) { + if ($ban['expire'] == 0 || $ban['expire'] > time()) { + $expire = ($ban['expire'] > 0) ? ('Your ban will expire ' . date('y/m/d(D)H:i:s', $ban['expire'])) : 'The ban on your IP address is permanent and will not expire.'; + $reason = ($ban['reason'] == '') ? '' : ('
The reason provided was: ' . $ban['reason']); + fancyDie('Sorry, it appears that you have been banned from posting on this image board. ' . $expire . $reason); + } else { + clearExpiredBans(); + } + } + + $parent = "0"; + if (isset($_POST["parent"])) { + if ($_POST["parent"] != "0") { + if (!threadExistsByID($_POST['parent'])) { + fancyDie("Invalid parent thread ID supplied, unable to create post."); + } + + $parent = $_POST["parent"]; + } + } + + $lastpost = lastPostByIP(); + if ($lastpost) { + if ((time() - $lastpost['timestamp']) < 30) { + fancyDie("Please wait a moment before posting again. You will be able to make another post in " . (30 - (time() - $lastpost['timestamp'])) . " seconds."); + } + } + + if (strlen($_POST["message"]) > 8000) { + fancyDie("Please shorten your message, or post it in multiple parts. Your message is " . strlen($_POST["message"]) . " characters long, and the maximum allowed is 8000."); + } + + $post = newPost(); + $post['parent'] = $parent; + $post['ip'] = $_SERVER['REMOTE_ADDR']; + + $nt = nameAndTripcode($_POST["name"]); + $post['name'] = $nt[0]; + $post['tripcode'] = $nt[1]; + + $post['name'] = cleanString(substr($post['name'], 0, 75)); + $post['email'] = cleanString(str_replace('"', '"', substr($_POST["email"], 0, 75))); + $post['subject'] = cleanString(substr($_POST["subject"], 0, 75)); + $post['message'] = str_replace("\n", "
", colorQuote(cleanString(rtrim($_POST["message"])))); + if ($_POST['password'] != '') { $post['password'] = md5(md5($_POST['password'])); } else { $post['password'] = ''; } + $post['nameblock'] = nameBlock($post['name'], $post['tripcode'], $post['email'], time()); + + if (isset($_FILES['file'])) { + if ($_FILES['file']['name'] != "") { + switch ($_FILES['file']['error']) { + case UPLOAD_ERR_OK: + break; + case UPLOAD_ERR_FORM_SIZE: + fancyDie("That file is larger than 2 MB."); + break; + case UPLOAD_ERR_INI_SIZE: + fancyDie("The uploaded file exceeds the upload_max_filesize directive (" . ini_get('upload_max_filesize') . ") in php.ini."); + break; + case UPLOAD_ERR_PARTIAL: + fancyDie("The uploaded file was only partially uploaded."); + break; + case UPLOAD_ERR_NO_FILE: + fancyDie("No file was uploaded."); + break; + case UPLOAD_ERR_NO_TMP_DIR: + fancyDie("Missing a temporary folder."); + break; + case UPLOAD_ERR_CANT_WRITE: + fancyDie("Failed to write file to disk"); + break; + default: + fancyDie("Unable to save the uploaded file."); + } + + if (!is_file($_FILES['file']['tmp_name']) || !is_readable($_FILES['file']['tmp_name'])) { + fancyDie("File transfer failure. Please retry the submission."); + } + + $post['file_original'] = substr(htmlentities($_FILES['file']['name'], ENT_QUOTES), 0, 50); + $post['file_hex'] = md5_file($_FILES['file']['tmp_name']); + $post['file_size'] = $_FILES['file']['size']; + $post['file_size_formatted'] = convertBytes($post['file_size']); + $file_type = strtolower(preg_replace('/.*(\..+)/', '\1', $_FILES['file']['name'])); if ($file_type == '.jpeg') { $file_type = '.jpg'; } + $file_name = time() . mt_rand(1, 99); + $post['thumb'] = $file_name . "s" . $file_type; + $post['file'] = $file_name . $file_type; + $thumb_location = "thumb/" . $post['thumb']; + $file_location = "src/" . $post['file']; + + if(function_exists("mime_content_type")) { + $file_mime = mime_content_type($_FILES['file']['tmp_name']); + } else { + $file_mime = "image/jpeg"; // It is highly recommended you use PHP 4.3.0 or later! + } + + if (($file_type == '.jpg' || $file_type == '.gif' || $file_type == '.png') && ($file_mime == "image/jpeg" || $file_mime == "image/gif" || $file_mime == "image/png")) { + if (!@getimagesize($_FILES['file']['tmp_name'])) { + fancyDie("Failed to read the size of the uploaded file. Please retry the submission."); + } + } else { + fancyDie("Only GIF, JPG, and PNG files are allowed."); + } + + + $hexmatches = postsByHex($post['file_hex']); + if (count($hexmatches) > 0) { + foreach ($hexmatches as $hexmatch) { + if ($hexmatch["parent"] == "0") { + $goto = $hexmatch["id"]; + } else { + $goto = $hexmatch["parent"]; + } + fancyDie("Duplicate file uploaded. That file has already been posted here."); + } + } + + if (!move_uploaded_file($_FILES['file']['tmp_name'], $file_location)) { + fancyDie("Could not copy uploaded file."); + } + + if ($_FILES['file']['size'] != filesize($file_location)) { + fancyDie("File transfer failure. Please go back and try again."); + } + + $file_imagesize = getimagesize($file_location); + $post['image_width'] = $file_imagesize[0]; + $post['image_height'] = $file_imagesize[1]; + + if ($post['image_width'] > 250 || $post['image_height'] > 250) { + $width = 250; + $height = 250; + } else { + $width = $post['image_width']; + $height = $post['image_height']; + } + if (!createThumbnail($file_location, $thumb_location, $width, $height)) { + fancyDie("Could not create thumbnail."); + } + + $thumbsize = getimagesize($thumb_location); + $post['thumb_width'] = $thumbsize[0]; + $post['thumb_height'] = $thumbsize[1]; + } + } + + if ($post['file'] == '') { // No file uploaded + if ($post['parent'] == '0') { + fancyDie("An image is required to start a thread."); + } + if (str_replace('
', '', $post['message']) == "") { + fancyDie("Please enter a message and/or upload an image to make a reply."); + } + } + + $post['id'] = insertPost($post); + trimThreads(); + echo 'Updating thread page...
'; + if ($post['parent'] != '0') { + rebuildThread($post['parent']); + + if (strtolower($post['email']) != "sage") { + bumpThreadByID($post['parent']); + } + } else { + rebuildThread($post['id']); + } + + echo 'Updating thread index...
'; + rebuildIndexes(); +// Check if the request is to delete a post and/or its associated image +} elseif (isset($_GET['delete']) && !isset($_GET['manage'])) { + if (isset($_POST['delete'])) { + $post = postByID($_POST['delete']); + if ($post) { + if ($post['password'] != '' && md5(md5($_POST['password'])) == $post['password']) { + deletePostByID($post['id']); + if ($post['parent'] == 0) { threadUpdated($post['id']); } else { threadUpdated($post['parent']); } + echo 'Post successfully deleted.'; + } else { + fancyDie('Invalid password.'); + } + } else { + fancyDie('Sorry, an invalid post identifier was sent. Please go back, refresh the page, and try again.'); + } + } else { + fancyDie('Tick the box next to a post and click "Delete" to delete it.'); + } + $redirect = false; +// Check if the request is to access the management area +} elseif (isset($_GET["manage"])) { + $text = ""; $onload = ""; $navbar = " "; + $redirect = false; $loggedin = false; $isadmin = false; + $returnlink = basename($_SERVER['PHP_SELF']); + + list($loggedin, $isadmin) = manageCheckLogIn(); + + if ($loggedin) { + if ($isadmin) { + if (isset($_GET["rebuildall"])) { + $allthreads = allThreads(); + foreach ($allthreads as $thread) { + rebuildThread($thread["id"]); + } + rebuildIndexes(); + $text .= "Rebuilt board."; + } elseif (isset($_GET["bans"])) { + clearExpiredBans(); + + if (isset($_POST['ip'])) { + if ($_POST['ip'] != '') { + $banexists = banByIP($_POST['ip']); + if ($banexists) { + fancyDie('Sorry, there is already a ban on record for that IP address.'); + } + + $ban = array(); + $ban['ip'] = $_POST['ip']; + $ban['expire'] = ($_POST['expire'] > 0) ? (time() + $_POST['expire']) : 0; + $ban['reason'] = $_POST['reason']; + + insertBan($ban); + $text .= 'Successfully added a ban record for ' . $ban['ip'] . '
'; + } + } elseif (isset($_GET['lift'])) { + $ban = banByID($_GET['lift']); + if ($ban) { + deleteBanByID($_GET['lift']); + $text .= 'Successfully lifted ban on ' . $ban['ip'] . '
'; + } + } + + $onload = manageOnLoad('bans'); + $text .= manageBanForm(); + $text .= manageBansTable(); + } + } + + if (isset($_GET["delete"])) { + $post = postByID($_GET['delete']); + if ($post) { + deletePostByID($post['id']); + rebuildIndexes(); + if ($post['parent'] > 0) { + rebuildThread($post['parent']); + } + $text .= 'Post No.' . $post['id'] . ' successfully deleted.'; + } else { + fancyDie("Sorry, there doesn't appear to be a post with that ID."); + } + } elseif (isset($_GET["moderate"])) { + if ($_GET['moderate'] > 0) { + $post = postByID($_GET['moderate']); + if ($post) { + $text .= manageModeratePost($post); + } else { + fancyDie("Sorry, there doesn't appear to be a post with that ID."); + } + } else { + $onload = manageOnLoad('moderate'); + $text .= manageModeratePostForm(); + } + } elseif (isset($_GET["logout"])) { + $_SESSION['tinyib'] = ''; + session_destroy(); + die('--> --> -->'); + } + } else { + $onload = manageOnLoad('login'); + $text .= manageLogInForm(); + } + + echo managePage($text, $onload); +} elseif (!file_exists('index.html') || count(allThreads()) == 0) { + rebuildIndexes(); +} + +if ($redirect) { + echo '--> --> -->'; +} + +?> \ No newline at end of file diff --git a/css/.svn/all-wcprops b/css/.svn/all-wcprops new file mode 100644 index 0000000..74ad4c9 --- /dev/null +++ b/css/.svn/all-wcprops @@ -0,0 +1,23 @@ +K 25 +svn:wc:ra_dav:version-url +V 25 +/svn/!svn/ver/2/trunk/css +END +burichan.css +K 25 +svn:wc:ra_dav:version-url +V 38 +/svn/!svn/ver/2/trunk/css/burichan.css +END +global.css +K 25 +svn:wc:ra_dav:version-url +V 36 +/svn/!svn/ver/8/trunk/css/global.css +END +futaba.css +K 25 +svn:wc:ra_dav:version-url +V 36 +/svn/!svn/ver/2/trunk/css/futaba.css +END diff --git a/css/.svn/entries b/css/.svn/entries new file mode 100644 index 0000000..4cc20cb --- /dev/null +++ b/css/.svn/entries @@ -0,0 +1,137 @@ +10 + +dir +2 +https://tinyib.googlecode.com/svn/trunk/css +https://tinyib.googlecode.com/svn + + + +2009-04-29T14:47:23.189190Z +2 +tslocum + + + + + + + + + + + + + + + + + + + + + +0 + +burichan.css +file + + + + +2009-09-05T06:40:39.781250Z +7cd5a3a7d6fe2481ff27bb4acf7faee6 +2009-04-29T14:47:23.189190Z +2 +tslocum + + + + + + + + + + + + + + + + + + + + + +2669 + +global.css +file +8 + + + +2009-09-18T00:14:15.812500Z +87a4674b421f90774b19e2cea188b4ef +2009-09-18T00:25:02.232167Z +8 +tslocum + + + + + + + + + + + + + + + + + + + + + +1108 + +futaba.css +file + + + + +2009-03-01T11:57:17.593750Z +833be8071c404d80a6887e82e82e3cb2 +2009-04-29T14:47:23.189190Z +2 +tslocum + + + + + + + + + + + + + + + + + + + + + +1942 + diff --git a/css/.svn/text-base/burichan.css.svn-base b/css/.svn/text-base/burichan.css.svn-base new file mode 100644 index 0000000..0e163af --- /dev/null +++ b/css/.svn/text-base/burichan.css.svn-base @@ -0,0 +1,181 @@ +html, body { + font-size:12pt; + background:#EEF2FF; + color:#000000; +} +a { + background:inherit; + color:#34345C; + text-decoration:none; + font-family:sans-serif; +} +a:visited { + background:inherit; + color:#34345C; + text-decoration:none; + font-family:sans-serif; +} +a:hover { + color:#DD0000; + background:inherit; + font-family:sans-serif; +} +.filesize a { + text-decoration:underline; +} +.filesize a:visited { + text-decoration:underline; +} +.adminbar { + text-align:right; + background:inherit; + clear:both; + float:right; +} +.logo { + clear:both; + text-align:center; + background:inherit; + font-size:24pt; + color:#AF0A0F; + width:100%; +} +.replymode { + background:#0010E0; + color:#FFFFFF; + width:100%; +} +.catalogmode { + background:#0040E0; + color:#FFFFFF; + width:100%; +} +.postarea { + background:inherit; +} +.rules { + /*font-size:0.7em;*/ + width: 468px; + font-size: 10px; + font-family: sans-serif; +} +.rules li { + margin-left: 1em; + /*text-indent: 0em;*/ +} +.postblock { + background:#9988EE; + color:#000000; + font-weight:800; +} +.footer { + text-align:center; + font-size:10px; + font-family:sans-serif; +} +.passvalid { + background:#9988EE; + text-align:center; + width:100%; + color:#ffffff; +} +.dellist { + background:inherit; + text-align:center; +} +.delbuttons { + background:inherit; + text-align:center; + padding-bottom:4px; +} +.managehead { + background:#0F8FE1; + color:#000000; + font-family:sans-serif; + font-size:14px; + padding:0px; +} +.postlists { + background:#FFFFFF; + width:100%; + padding:0px; + color:#000000; +} +.row1 { + background:#9AD2F6; + font-family:sans-serif; + font-size:12px; + color:#000000; +} +.row2 { + background:#FFFFFF; + font-family:sans-serif; + font-size:12px; + color:#000000; +} +.unkfunc { + color:#789922; +} +.filesize { + font-size:12px; + font-family:sans-serif; + text-decoration:underline; + /*padding-left:3em;*/ +} +.filetitle { + background:inherit; + font-size:18px; + font-family:serif; + color:#0F0C5D; + font-weight:800; +} +.postername { + background:inherit; + font-size:12px; + font-family:serif; + color:#117743; + font-weight:800; +} +.oldpost { + background:inherit; + font-size:18px; + font-family:serif; + color:#0F0C5D; + font-weight:800; +} +.omittedposts { + background:inherit; + font-size:18px; + font-family:serif; + color:#070707; + font-weight:800; +} +.reply { + background:#D6DAF0; + color:#000000; + font-family:serif; +} +.replyhl { + background: #D6BAD0; + color: #000000; +} +.replytitle { + background:inherit; + font-size:18px; + font-family:serif; + color:#0F0C5D; + font-weight:800; +} +.commentpostername { + background:inherit; + font-size:12px; + font-family:serif; + color:#117743; + font-weight:800; +} +.thumbnailmsg { + background:inherit; + font-size:9px; + font-family:sans-serif; + color:#000000; +} \ No newline at end of file diff --git a/css/.svn/text-base/futaba.css.svn-base b/css/.svn/text-base/futaba.css.svn-base new file mode 100644 index 0000000..e0c7e36 --- /dev/null +++ b/css/.svn/text-base/futaba.css.svn-base @@ -0,0 +1,150 @@ +html, body { + background:#FFFFEE; + color:#800000; +} +a { + color:#0000EE; +} +a:hover { + color:#DD0000; +} +.reflink a:hover{ + font-weight: bold; +} +.adminbar { + text-align:right; + clear:both; + float:right; +} +.logo { + clear:both; + text-align:center; + font-size:2em; + color:#800000; + width:100%; +} +.replymode { + background:#E04000; + text-align:center; + padding:2px; + color:#FFFFFF; + width:100%; +} +.catalogmode { + background:#0040E0; + text-align:center; + padding:2px; + color:#FFFFFF; + width:100%; +} +.rules { + /*font-size:0.7em;*/ + width: 468px; + font-size: 10px; + font-family: sans-serif; +} +.rules li { + margin-left: 1em; + /*text-indent: 0em;*/ +} +.postblock { + background:#EEAA88; + color:#800000; + font-weight:800; +} +.footer { + text-align:center; + font-size:12px; + font-family:serif; +} +.passvalid { + background:#EEAA88; + text-align:center; + width:100%; + color:#ffffff; +} +.dellist { + font-weight: bold; + text-align:center; +} +.delbuttons { + text-align:center; + padding-bottom:4px; + +} +.managehead { + background:#AAAA66; + color:#400000; + padding:0px; +} +.postlists { + background:#FFFFFF; + width:100%; + padding:0px; + color:#800000; +} +.row1 { + background:#EEEECC; + color:#800000; +} +.row2 { + background:#DDDDAA; + color:#800000; +} +.unkfunc { + background:inherit; + color:#789922; +} +.filesize { + text-decoration:none; +} +.filetitle { + background:inherit; + font-size:1.2em; + color:#CC1105; + font-weight:800; +} +.postername { + color:#117743; + font-weight:bold; +} +.postertrip { + color:#228854; +} +.oldpost { + color:#CC1105; + font-weight:800; +} +.omittedposts { + color:#707070; +} +.reply { + background: #F0E0D6; + color: #800000; +} +.replyhl { + background: #F0C0B0; + color: #800000; +} +.replytitle { + font-size: 1.2em; + color:#CC1105; + font-weight:800; +} +.commentpostername { + color:#117743; + font-weight:800; +} +.thumbnailmsg { + font-size: small; + color:#800000; +} + +.abbrev { + color:#707070; +} +.highlight { + background:#F0E0D6; + color:#800000; + border: 2px dashed #EEAA88; +} \ No newline at end of file diff --git a/css/.svn/text-base/global.css.svn-base b/css/.svn/text-base/global.css.svn-base new file mode 100644 index 0000000..4fdd740 --- /dev/null +++ b/css/.svn/text-base/global.css.svn-base @@ -0,0 +1,83 @@ +body { + margin: 0; + padding: 8px; + margin-bottom: auto; +} + +blockquote blockquote { + margin-left: 0em; +} + +form { + margin-bottom: 0px; +} + +.postarea { + text-align: center; +} + +.postarea table { + margin: 0px auto; + text-align: left; +} + +.aa { + white-space: pre; + text-align: left; + font-family: IPAMonaPGothic, Mona, 'MS PGothic', YOzFontAA97 !important; +} + +.thumb { + border: none; + float: left; + margin: 2px 20px; +} + +.nothumb { + float: left; + background: #eee; + border: 2px dashed #aaa; + text-align: center; + margin: 2px 20px; + padding: 1em 0.5em 1em 0.5em; +} + +.reply blockquote, blockquote :last-child { + margin-bottom: 0em; +} + +.reflink a { + color: inherit; + text-decoration: none; +} + +.reflink a:hover{ + color: #800000; +} + +.reply .filesize { + margin-left: 20px; +} + +.userdelete { + float: right; + text-align: center; + white-space: nowrap; +} + +.doubledash { + vertical-align: top; + clear: both; + float: left; + font-size: 1.75em; +} + +.moderator { + color: #FF0000; +} + +.managebutton { + font-size: 15px; + height: 28px; + margin: 0.2em; +} \ No newline at end of file diff --git a/css/burichan.css b/css/burichan.css new file mode 100644 index 0000000..0e163af --- /dev/null +++ b/css/burichan.css @@ -0,0 +1,181 @@ +html, body { + font-size:12pt; + background:#EEF2FF; + color:#000000; +} +a { + background:inherit; + color:#34345C; + text-decoration:none; + font-family:sans-serif; +} +a:visited { + background:inherit; + color:#34345C; + text-decoration:none; + font-family:sans-serif; +} +a:hover { + color:#DD0000; + background:inherit; + font-family:sans-serif; +} +.filesize a { + text-decoration:underline; +} +.filesize a:visited { + text-decoration:underline; +} +.adminbar { + text-align:right; + background:inherit; + clear:both; + float:right; +} +.logo { + clear:both; + text-align:center; + background:inherit; + font-size:24pt; + color:#AF0A0F; + width:100%; +} +.replymode { + background:#0010E0; + color:#FFFFFF; + width:100%; +} +.catalogmode { + background:#0040E0; + color:#FFFFFF; + width:100%; +} +.postarea { + background:inherit; +} +.rules { + /*font-size:0.7em;*/ + width: 468px; + font-size: 10px; + font-family: sans-serif; +} +.rules li { + margin-left: 1em; + /*text-indent: 0em;*/ +} +.postblock { + background:#9988EE; + color:#000000; + font-weight:800; +} +.footer { + text-align:center; + font-size:10px; + font-family:sans-serif; +} +.passvalid { + background:#9988EE; + text-align:center; + width:100%; + color:#ffffff; +} +.dellist { + background:inherit; + text-align:center; +} +.delbuttons { + background:inherit; + text-align:center; + padding-bottom:4px; +} +.managehead { + background:#0F8FE1; + color:#000000; + font-family:sans-serif; + font-size:14px; + padding:0px; +} +.postlists { + background:#FFFFFF; + width:100%; + padding:0px; + color:#000000; +} +.row1 { + background:#9AD2F6; + font-family:sans-serif; + font-size:12px; + color:#000000; +} +.row2 { + background:#FFFFFF; + font-family:sans-serif; + font-size:12px; + color:#000000; +} +.unkfunc { + color:#789922; +} +.filesize { + font-size:12px; + font-family:sans-serif; + text-decoration:underline; + /*padding-left:3em;*/ +} +.filetitle { + background:inherit; + font-size:18px; + font-family:serif; + color:#0F0C5D; + font-weight:800; +} +.postername { + background:inherit; + font-size:12px; + font-family:serif; + color:#117743; + font-weight:800; +} +.oldpost { + background:inherit; + font-size:18px; + font-family:serif; + color:#0F0C5D; + font-weight:800; +} +.omittedposts { + background:inherit; + font-size:18px; + font-family:serif; + color:#070707; + font-weight:800; +} +.reply { + background:#D6DAF0; + color:#000000; + font-family:serif; +} +.replyhl { + background: #D6BAD0; + color: #000000; +} +.replytitle { + background:inherit; + font-size:18px; + font-family:serif; + color:#0F0C5D; + font-weight:800; +} +.commentpostername { + background:inherit; + font-size:12px; + font-family:serif; + color:#117743; + font-weight:800; +} +.thumbnailmsg { + background:inherit; + font-size:9px; + font-family:sans-serif; + color:#000000; +} \ No newline at end of file diff --git a/css/futaba.css b/css/futaba.css new file mode 100644 index 0000000..e0c7e36 --- /dev/null +++ b/css/futaba.css @@ -0,0 +1,150 @@ +html, body { + background:#FFFFEE; + color:#800000; +} +a { + color:#0000EE; +} +a:hover { + color:#DD0000; +} +.reflink a:hover{ + font-weight: bold; +} +.adminbar { + text-align:right; + clear:both; + float:right; +} +.logo { + clear:both; + text-align:center; + font-size:2em; + color:#800000; + width:100%; +} +.replymode { + background:#E04000; + text-align:center; + padding:2px; + color:#FFFFFF; + width:100%; +} +.catalogmode { + background:#0040E0; + text-align:center; + padding:2px; + color:#FFFFFF; + width:100%; +} +.rules { + /*font-size:0.7em;*/ + width: 468px; + font-size: 10px; + font-family: sans-serif; +} +.rules li { + margin-left: 1em; + /*text-indent: 0em;*/ +} +.postblock { + background:#EEAA88; + color:#800000; + font-weight:800; +} +.footer { + text-align:center; + font-size:12px; + font-family:serif; +} +.passvalid { + background:#EEAA88; + text-align:center; + width:100%; + color:#ffffff; +} +.dellist { + font-weight: bold; + text-align:center; +} +.delbuttons { + text-align:center; + padding-bottom:4px; + +} +.managehead { + background:#AAAA66; + color:#400000; + padding:0px; +} +.postlists { + background:#FFFFFF; + width:100%; + padding:0px; + color:#800000; +} +.row1 { + background:#EEEECC; + color:#800000; +} +.row2 { + background:#DDDDAA; + color:#800000; +} +.unkfunc { + background:inherit; + color:#789922; +} +.filesize { + text-decoration:none; +} +.filetitle { + background:inherit; + font-size:1.2em; + color:#CC1105; + font-weight:800; +} +.postername { + color:#117743; + font-weight:bold; +} +.postertrip { + color:#228854; +} +.oldpost { + color:#CC1105; + font-weight:800; +} +.omittedposts { + color:#707070; +} +.reply { + background: #F0E0D6; + color: #800000; +} +.replyhl { + background: #F0C0B0; + color: #800000; +} +.replytitle { + font-size: 1.2em; + color:#CC1105; + font-weight:800; +} +.commentpostername { + color:#117743; + font-weight:800; +} +.thumbnailmsg { + font-size: small; + color:#800000; +} + +.abbrev { + color:#707070; +} +.highlight { + background:#F0E0D6; + color:#800000; + border: 2px dashed #EEAA88; +} \ No newline at end of file diff --git a/css/global.css b/css/global.css new file mode 100644 index 0000000..4fdd740 --- /dev/null +++ b/css/global.css @@ -0,0 +1,83 @@ +body { + margin: 0; + padding: 8px; + margin-bottom: auto; +} + +blockquote blockquote { + margin-left: 0em; +} + +form { + margin-bottom: 0px; +} + +.postarea { + text-align: center; +} + +.postarea table { + margin: 0px auto; + text-align: left; +} + +.aa { + white-space: pre; + text-align: left; + font-family: IPAMonaPGothic, Mona, 'MS PGothic', YOzFontAA97 !important; +} + +.thumb { + border: none; + float: left; + margin: 2px 20px; +} + +.nothumb { + float: left; + background: #eee; + border: 2px dashed #aaa; + text-align: center; + margin: 2px 20px; + padding: 1em 0.5em 1em 0.5em; +} + +.reply blockquote, blockquote :last-child { + margin-bottom: 0em; +} + +.reflink a { + color: inherit; + text-decoration: none; +} + +.reflink a:hover{ + color: #800000; +} + +.reply .filesize { + margin-left: 20px; +} + +.userdelete { + float: right; + text-align: center; + white-space: nowrap; +} + +.doubledash { + vertical-align: top; + clear: both; + float: left; + font-size: 1.75em; +} + +.moderator { + color: #FF0000; +} + +.managebutton { + font-size: 15px; + height: 28px; + margin: 0.2em; +} \ No newline at end of file diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..fcff32f061c39da6cb6433e4ba409416109dfc87 GIT binary patch literal 1150 zcmeH@u?~YU3`DPjjRgsb6-GX-f8VVm;S7rOWI;D38g$9|{LEnK<*)DMd)B*^MoEk1 z$jOoW+0W2Pq5rvU0|kE$PoZ^b^E^TJnA4M?4<^@~tDa1FsxrUcJWrNA=2t%RxjvgC g6P`NbADxxb=#UrXO@+Rb^$9ihmi-#F^UBn@4Y%(&JOBUy literal 0 HcmV?d00001 diff --git a/imgboard.php b/imgboard.php new file mode 100644 index 0000000..e3413f3 --- /dev/null +++ b/imgboard.php @@ -0,0 +1,348 @@ + $val) { $_GET[$key] = stripslashes($val); } + foreach ($_POST as $key => $val) { $_POST[$key] = stripslashes($val); } +} +if (get_magic_quotes_runtime()) { set_magic_quotes_runtime(0); } + +$tinyib = array(); +$tinyib['board'] = "b"; // Identifier for this board using only letters and numbers +$tinyib['boarddescription'] = "TinyIB"; // Displayed in the logo area +$tinyib['maxthreads'] = 100; // Set this to limit the number of threads allowed before discarding older threads. 0 to disable +$tinyib['logo'] = ""; // Logo HTML +$tinyib['tripseed'] = ""; // Text to use when generating secure tripcodes +$tinyib['adminpassword'] = ""; // Text entered at the manage prompt to gain administrator access +$tinyib['modpassword'] = ""; // Same as above, but only has access to delete posts. Blank ("") to disable +$tinyib['databasemode'] = "flatfile"; // flatfile or mysql + +// mysql settings +$mysql_host = "localhost"; +$mysql_username = ""; +$mysql_password = ""; +$mysql_database = ""; +$mysql_posts_table = $tinyib['board'] . "_posts"; +$mysql_bans_table = "bans"; + +function fancyDie($message) { + die('' . $message . ''); +} + +// Check directories are writable by the script +$writedirs = array("res", "src", "thumb"); +if ($tinyib['databasemode'] == 'flatfile') { $writedirs[] = "inc/flatfile"; } +foreach ($writedirs as $dir) { + if (!is_writable($dir)) { + fancyDie("Directory '" . $dir . "' can not be written to! Please modify its permissions."); + } +} + +$includes = array("inc/functions.php", "inc/html.php"); +if ($tinyib['databasemode'] == 'flatfile') { + $includes[] = 'inc/database_flatfile.php'; +} elseif ($tinyib['databasemode'] == 'mysql') { + $includes[] = 'inc/database_mysql.php'; +} else { + fancyDie("Unknown database mode specificed"); +} + +foreach ($includes as $include) { + include $include; +} + +if ($tinyib['tripseed'] == '' || $tinyib['adminpassword'] == '') { + fancyDie('$tinyib[\'tripseed\'] and $tinyib[\'adminpassword\'] still need to be configured!'); +} + +$redirect = true; +// Check if the request is to make a post +if (isset($_POST["message"]) || isset($_POST["file"])) { + $ban = banByIP($_SERVER['REMOTE_ADDR']); + if ($ban) { + if ($ban['expire'] == 0 || $ban['expire'] > time()) { + $expire = ($ban['expire'] > 0) ? ('Your ban will expire ' . date('y/m/d(D)H:i:s', $ban['expire'])) : 'The ban on your IP address is permanent and will not expire.'; + $reason = ($ban['reason'] == '') ? '' : ('
The reason provided was: ' . $ban['reason']); + fancyDie('Sorry, it appears that you have been banned from posting on this image board. ' . $expire . $reason); + } else { + clearExpiredBans(); + } + } + + $parent = "0"; + if (isset($_POST["parent"])) { + if ($_POST["parent"] != "0") { + if (!threadExistsByID($_POST['parent'])) { + fancyDie("Invalid parent thread ID supplied, unable to create post."); + } + + $parent = $_POST["parent"]; + } + } + + $lastpost = lastPostByIP(); + if ($lastpost) { + if ((time() - $lastpost['timestamp']) < 30) { + fancyDie("Please wait a moment before posting again. You will be able to make another post in " . (30 - (time() - $lastpost['timestamp'])) . " seconds."); + } + } + + if (strlen($_POST["message"]) > 8000) { + fancyDie("Please shorten your message, or post it in multiple parts. Your message is " . strlen($_POST["message"]) . " characters long, and the maximum allowed is 8000."); + } + + $post = newPost(); + $post['parent'] = $parent; + $post['ip'] = $_SERVER['REMOTE_ADDR']; + + $nt = nameAndTripcode($_POST["name"]); + $post['name'] = $nt[0]; + $post['tripcode'] = $nt[1]; + + $post['name'] = cleanString(substr($post['name'], 0, 75)); + $post['email'] = cleanString(str_replace('"', '"', substr($_POST["email"], 0, 75))); + $post['subject'] = cleanString(substr($_POST["subject"], 0, 75)); + $post['message'] = str_replace("\n", "
", colorQuote(cleanString(rtrim($_POST["message"])))); + if ($_POST['password'] != '') { $post['password'] = md5(md5($_POST['password'])); } else { $post['password'] = ''; } + $post['nameblock'] = nameBlock($post['name'], $post['tripcode'], $post['email'], time()); + + if (isset($_FILES['file'])) { + if ($_FILES['file']['name'] != "") { + switch ($_FILES['file']['error']) { + case UPLOAD_ERR_OK: + break; + case UPLOAD_ERR_FORM_SIZE: + fancyDie("That file is larger than 2 MB."); + break; + case UPLOAD_ERR_INI_SIZE: + fancyDie("The uploaded file exceeds the upload_max_filesize directive (" . ini_get('upload_max_filesize') . ") in php.ini."); + break; + case UPLOAD_ERR_PARTIAL: + fancyDie("The uploaded file was only partially uploaded."); + break; + case UPLOAD_ERR_NO_FILE: + fancyDie("No file was uploaded."); + break; + case UPLOAD_ERR_NO_TMP_DIR: + fancyDie("Missing a temporary folder."); + break; + case UPLOAD_ERR_CANT_WRITE: + fancyDie("Failed to write file to disk"); + break; + default: + fancyDie("Unable to save the uploaded file."); + } + + if (!is_file($_FILES['file']['tmp_name']) || !is_readable($_FILES['file']['tmp_name'])) { + fancyDie("File transfer failure. Please retry the submission."); + } + + $post['file_original'] = substr(htmlentities($_FILES['file']['name'], ENT_QUOTES), 0, 50); + $post['file_hex'] = md5_file($_FILES['file']['tmp_name']); + $post['file_size'] = $_FILES['file']['size']; + $post['file_size_formatted'] = convertBytes($post['file_size']); + $file_type = strtolower(preg_replace('/.*(\..+)/', '\1', $_FILES['file']['name'])); if ($file_type == '.jpeg') { $file_type = '.jpg'; } + $file_name = time() . mt_rand(1, 99); + $post['thumb'] = $file_name . "s" . $file_type; + $post['file'] = $file_name . $file_type; + $thumb_location = "thumb/" . $post['thumb']; + $file_location = "src/" . $post['file']; + + if(function_exists("mime_content_type")) { + $file_mime = mime_content_type($_FILES['file']['tmp_name']); + } else { + $file_mime = "image/jpeg"; // It is highly recommended you use PHP 4.3.0 or later! + } + + if (($file_type == '.jpg' || $file_type == '.gif' || $file_type == '.png') && ($file_mime == "image/jpeg" || $file_mime == "image/gif" || $file_mime == "image/png")) { + if (!@getimagesize($_FILES['file']['tmp_name'])) { + fancyDie("Failed to read the size of the uploaded file. Please retry the submission."); + } + } else { + fancyDie("Only GIF, JPG, and PNG files are allowed."); + } + + + $hexmatches = postsByHex($post['file_hex']); + if (count($hexmatches) > 0) { + foreach ($hexmatches as $hexmatch) { + if ($hexmatch["parent"] == "0") { + $goto = $hexmatch["id"]; + } else { + $goto = $hexmatch["parent"]; + } + fancyDie("Duplicate file uploaded. That file has already been posted here."); + } + } + + if (!move_uploaded_file($_FILES['file']['tmp_name'], $file_location)) { + fancyDie("Could not copy uploaded file."); + } + + if ($_FILES['file']['size'] != filesize($file_location)) { + fancyDie("File transfer failure. Please go back and try again."); + } + + $file_imagesize = getimagesize($file_location); + $post['image_width'] = $file_imagesize[0]; + $post['image_height'] = $file_imagesize[1]; + + if ($post['image_width'] > 250 || $post['image_height'] > 250) { + $width = 250; + $height = 250; + } else { + $width = $post['image_width']; + $height = $post['image_height']; + } + if (!createThumbnail($file_location, $thumb_location, $width, $height)) { + fancyDie("Could not create thumbnail."); + } + + $thumbsize = getimagesize($thumb_location); + $post['thumb_width'] = $thumbsize[0]; + $post['thumb_height'] = $thumbsize[1]; + } + } + + if ($post['file'] == '') { // No file uploaded + if ($post['parent'] == '0') { + fancyDie("An image is required to start a thread."); + } + if (str_replace('
', '', $post['message']) == "") { + fancyDie("Please enter a message and/or upload an image to make a reply."); + } + } + + $post['id'] = insertPost($post); + trimThreads(); + echo 'Updating thread page...
'; + if ($post['parent'] != '0') { + rebuildThread($post['parent']); + + if (strtolower($post['email']) != "sage") { + bumpThreadByID($post['parent']); + } + } else { + rebuildThread($post['id']); + } + + echo 'Updating thread index...
'; + rebuildIndexes(); +// Check if the request is to delete a post and/or its associated image +} elseif (isset($_GET['delete']) && !isset($_GET['manage'])) { + if (isset($_POST['delete'])) { + $post = postByID($_POST['delete']); + if ($post) { + if ($post['password'] != '' && md5(md5($_POST['password'])) == $post['password']) { + deletePostByID($post['id']); + if ($post['parent'] == 0) { threadUpdated($post['id']); } else { threadUpdated($post['parent']); } + echo 'Post successfully deleted.'; + } else { + fancyDie('Invalid password.'); + } + } else { + fancyDie('Sorry, an invalid post identifier was sent. Please go back, refresh the page, and try again.'); + } + } else { + fancyDie('Tick the box next to a post and click "Delete" to delete it.'); + } + $redirect = false; +// Check if the request is to access the management area +} elseif (isset($_GET["manage"])) { + $text = ""; $onload = ""; $navbar = " "; + $redirect = false; $loggedin = false; $isadmin = false; + $returnlink = basename($_SERVER['PHP_SELF']); + + list($loggedin, $isadmin) = manageCheckLogIn(); + + if ($loggedin) { + if ($isadmin) { + if (isset($_GET["rebuildall"])) { + $allthreads = allThreads(); + foreach ($allthreads as $thread) { + rebuildThread($thread["id"]); + } + rebuildIndexes(); + $text .= "Rebuilt board."; + } elseif (isset($_GET["bans"])) { + clearExpiredBans(); + + if (isset($_POST['ip'])) { + if ($_POST['ip'] != '') { + $banexists = banByIP($_POST['ip']); + if ($banexists) { + fancyDie('Sorry, there is already a ban on record for that IP address.'); + } + + $ban = array(); + $ban['ip'] = $_POST['ip']; + $ban['expire'] = ($_POST['expire'] > 0) ? (time() + $_POST['expire']) : 0; + $ban['reason'] = $_POST['reason']; + + insertBan($ban); + $text .= 'Successfully added a ban record for ' . $ban['ip'] . '
'; + } + } elseif (isset($_GET['lift'])) { + $ban = banByID($_GET['lift']); + if ($ban) { + deleteBanByID($_GET['lift']); + $text .= 'Successfully lifted ban on ' . $ban['ip'] . '
'; + } + } + + $onload = manageOnLoad('bans'); + $text .= manageBanForm(); + $text .= manageBansTable(); + } + } + + if (isset($_GET["delete"])) { + $post = postByID($_GET['delete']); + if ($post) { + deletePostByID($post['id']); + rebuildIndexes(); + if ($post['parent'] > 0) { + rebuildThread($post['parent']); + } + $text .= 'Post No.' . $post['id'] . ' successfully deleted.'; + } else { + fancyDie("Sorry, there doesn't appear to be a post with that ID."); + } + } elseif (isset($_GET["moderate"])) { + if ($_GET['moderate'] > 0) { + $post = postByID($_GET['moderate']); + if ($post) { + $text .= manageModeratePost($post); + } else { + fancyDie("Sorry, there doesn't appear to be a post with that ID."); + } + } else { + $onload = manageOnLoad('moderate'); + $text .= manageModeratePostForm(); + } + } elseif (isset($_GET["logout"])) { + $_SESSION['tinyib'] = ''; + session_destroy(); + die('--> --> -->'); + } + } else { + $onload = manageOnLoad('login'); + $text .= manageLogInForm(); + } + + echo managePage($text, $onload); +} elseif (!file_exists('index.html') || count(allThreads()) == 0) { + rebuildIndexes(); +} + +if ($redirect) { + echo '--> --> -->'; +} + +?> \ No newline at end of file diff --git a/inc/.svn/all-wcprops b/inc/.svn/all-wcprops new file mode 100644 index 0000000..c4fbe05 --- /dev/null +++ b/inc/.svn/all-wcprops @@ -0,0 +1,29 @@ +K 25 +svn:wc:ra_dav:version-url +V 25 +/svn/!svn/ver/4/trunk/inc +END +database_mysql.php +K 25 +svn:wc:ra_dav:version-url +V 44 +/svn/!svn/ver/9/trunk/inc/database_mysql.php +END +database_flatfile.php +K 25 +svn:wc:ra_dav:version-url +V 47 +/svn/!svn/ver/9/trunk/inc/database_flatfile.php +END +html.php +K 25 +svn:wc:ra_dav:version-url +V 35 +/svn/!svn/ver/10/trunk/inc/html.php +END +functions.php +K 25 +svn:wc:ra_dav:version-url +V 40 +/svn/!svn/ver/10/trunk/inc/functions.php +END diff --git a/inc/.svn/entries b/inc/.svn/entries new file mode 100644 index 0000000..384e4c9 --- /dev/null +++ b/inc/.svn/entries @@ -0,0 +1,167 @@ +10 + +dir +4 +https://tinyib.googlecode.com/svn/trunk/inc +https://tinyib.googlecode.com/svn + + + +2009-09-04T03:12:19.723445Z +4 +tslocum + + + + + + + + + + + + + + +ac9068a4-33bb-11de-8a2e-13aa1706fec1 + +database_mysql.php +file +9 + + + +2009-09-18T00:50:30.703125Z +b5d356351b1fbdb2c5cbeda9241f8aa4 +2009-09-18T00:52:50.403559Z +9 +tslocum + + + + + + + + + + + + + + + + + + + + + +7779 + +database_flatfile.php +file +9 + + + +2009-09-18T00:50:36.359375Z +cb80ffc18b07448097139faedd300a3e +2009-09-18T00:52:50.403559Z +9 +tslocum + + + + + + + + + + + + + + + + + + + + + +8666 + +flatfile +dir + +html.php +file +10 + + + +2009-09-19T21:41:25.296875Z +b555bd0497f886c2d3fedeeb1ba99680 +2009-09-19T21:48:28.690807Z +10 +tslocum + + + + + + + + + + + + + + + + + + + + + +14016 + +functions.php +file +10 + + + +2009-09-19T21:44:49.156250Z +8fa43669064f3502daee0fed9cf209e6 +2009-09-19T21:48:28.690807Z +10 +tslocum + + + + + + + + + + + + + + + + + + + + + +7687 + diff --git a/inc/.svn/text-base/database_flatfile.php.svn-base b/inc/.svn/text-base/database_flatfile.php.svn-base new file mode 100644 index 0000000..b6ab2bd --- /dev/null +++ b/inc/.svn/text-base/database_flatfile.php.svn-base @@ -0,0 +1,254 @@ +datadir = 'inc/flatfile/'; + +# Post Functions +function uniquePosts() { + return 0; +} + +function postByID($id) { + return convertPostsToSQLStyle($GLOBALS['db']->selectWhere(POSTS_FILE, new SimpleWhereClause(POST_ID, '=', $id, INTEGER_COMPARISON), 1), true); +} + +function threadExistsByID($id) { + $compClause = new AndWhereClause(); + $compClause->add(new SimpleWhereClause(POST_ID, '=', $id, INTEGER_COMPARISON)); + $compClause->add(new SimpleWhereClause(POST_PARENT, '=', 0, INTEGER_COMPARISON)); + + return count($GLOBALS['db']->selectWhere(POSTS_FILE, $compClause, 1)) > 0; +} + +function insertPost($newpost) { + $post = array(); + $post[POST_ID] = '0'; + $post[POST_PARENT] = $newpost['parent']; + $post[POST_TIMESTAMP] = time(); + $post[POST_BUMPED] = time(); + $post[POST_IP] = $newpost['ip']; + $post[POST_NAME] = $newpost['name']; + $post[POST_TRIPCODE] = $newpost['tripcode']; + $post[POST_EMAIL] = $newpost['email']; + $post[POST_NAMEBLOCK] = $newpost['nameblock']; + $post[POST_SUBJECT] = $newpost['subject']; + $post[POST_MESSAGE] = $newpost['message']; + $post[POST_PASSWORD] = $newpost['password']; + $post[POST_FILE] = $newpost['file']; + $post[POST_FILE_HEX] = $newpost['file_hex']; + $post[POST_FILE_ORIGINAL] = $newpost['file_original']; + $post[POST_FILE_SIZE] = $newpost['file_size']; + $post[POST_FILE_SIZE_FORMATTED] = $newpost['file_size_formatted']; + $post[POST_IMAGE_WIDTH] = $newpost['image_width']; + $post[POST_IMAGE_HEIGHT] = $newpost['image_height']; + $post[POST_THUMB] = $newpost['thumb']; + $post[POST_THUMB_WIDTH] = $newpost['thumb_width']; + $post[POST_THUMB_HEIGHT] = $newpost['thumb_height']; + $post[POST_THUMB_HEIGHT] = $newpost['thumb_height']; + + return $GLOBALS['db']->insertWithAutoId(POSTS_FILE, POST_ID, $post); +} + +function bumpThreadByID($id) { + $rows = $GLOBALS['db']->selectWhere(POSTS_FILE, new SimpleWhereClause(POST_ID, '=', $id, INTEGER_COMPARISON), 1); + if (count($rows) > 0) { + foreach ($rows as $post) { + $post[POST_BUMPED] = time(); + $GLOBALS['db']->updateRowById(POSTS_FILE, POST_ID, $post); + } + } +} + +function countThreads() { + $rows = $GLOBALS['db']->selectWhere(POSTS_FILE, new SimpleWhereClause(POST_PARENT, '=', 0, INTEGER_COMPARISON)); + return count($rows); +} + +function convertPostsToSQLStyle($posts, $singlepost=false) { + $newposts = array(); + foreach ($posts as $oldpost) { + $post = newPost(); + $post['id'] = $oldpost[POST_ID]; + $post['parent'] = $oldpost[POST_PARENT]; + $post['timestamp'] = $oldpost[POST_TIMESTAMP]; + $post['bumped'] = $oldpost[POST_BUMPED]; + $post['ip'] = $oldpost[POST_IP]; + $post['name'] = $oldpost[POST_NAME]; + $post['tripcode'] = $oldpost[POST_TRIPCODE]; + $post['email'] = $oldpost[POST_EMAIL]; + $post['nameblock'] = $oldpost[POST_NAMEBLOCK]; + $post['subject'] = $oldpost[POST_SUBJECT]; + $post['message'] = $oldpost[POST_MESSAGE]; + $post['password'] = $oldpost[POST_PASSWORD]; + $post['file'] = $oldpost[POST_FILE]; + $post['file_hex'] = $oldpost[POST_FILE_HEX]; + $post['file_original'] = $oldpost[POST_FILE_ORIGINAL]; + $post['file_size'] = $oldpost[POST_FILE_SIZE]; + $post['file_size_formatted'] = $oldpost[POST_FILE_SIZE_FORMATTED]; + $post['image_width'] = $oldpost[POST_IMAGE_WIDTH]; + $post['image_height'] = $oldpost[POST_IMAGE_HEIGHT]; + $post['thumb'] = $oldpost[POST_THUMB]; + $post['thumb_width'] = $oldpost[POST_THUMB_WIDTH]; + $post['thumb_height'] = $oldpost[POST_THUMB_HEIGHT]; + + if ($post['parent'] == '') { + $post['parent'] = '0'; + } + + if ($singlepost) { return $post; } + $newposts[] = $post; + } + return $newposts; +} + +function allThreads() { + $rows = $GLOBALS['db']->selectWhere(POSTS_FILE, new SimpleWhereClause(POST_PARENT, '=', 0, INTEGER_COMPARISON), -1, new OrderBy(POST_BUMPED, DESCENDING, INTEGER_COMPARISON)); + return convertPostsToSQLStyle($rows); +} + +function postsInThreadByID($id) { + $compClause = new OrWhereClause(); + $compClause->add(new SimpleWhereClause(POST_ID, '=', $id, INTEGER_COMPARISON)); + $compClause->add(new SimpleWhereClause(POST_PARENT, '=', $id, INTEGER_COMPARISON)); + + $rows = $GLOBALS['db']->selectWhere(POSTS_FILE, $compClause, -1, new OrderBy(POST_ID, ASCENDING, INTEGER_COMPARISON)); + return convertPostsToSQLStyle($rows); +} + +function latestRepliesInThreadByID($id) { + $rows = $GLOBALS['db']->selectWhere(POSTS_FILE, new SimpleWhereClause(POST_PARENT, '=', $id, INTEGER_COMPARISON), 3, new OrderBy(POST_ID, DESCENDING, INTEGER_COMPARISON)); + return convertPostsToSQLStyle($rows); +} + +function postsByHex($hex) { + $rows = $GLOBALS['db']->selectWhere(POSTS_FILE, new SimpleWhereClause(POST_FILE_HEX, '=', $hex, STRING_COMPARISON), 1); + return convertPostsToSQLStyle($rows); +} + +function deletePostByID($id) { + $posts = postsInThreadByID($id); + foreach ($posts as $post) { + if ($post['id'] != $id) { + deletePostImages($post); + $GLOBALS['db']->deleteWhere(POSTS_FILE, new SimpleWhereClause(POST_ID, '=', $post['id'], INTEGER_COMPARISON)); + } else { + $thispost = $post; + } + } + + if (isset($thispost)) { + deletePostImages($thispost); + $GLOBALS['db']->deleteWhere(POSTS_FILE, new SimpleWhereClause(POST_ID, '=', $thispost['id'], INTEGER_COMPARISON)); + } +} + +function trimThreads() { + global $tinyib; + if ($tinyib['maxthreads'] > 0) { + $numthreads = countThreads(); + if ($numthreads > $tinyib['maxthreads']) { + $allthreads = allThreads(); + for ($i=$tinyib['maxthreads'];$i<$numthreads;$i++) { + deletePostByID($allthreads[$i]['id']); + } + } + } +} + +function lastPostByIP() { + $rows = $GLOBALS['db']->selectWhere(POSTS_FILE, new SimpleWhereClause(POST_IP, '=', $_SERVER['REMOTE_ADDR'], STRING_COMPARISON), 1, new OrderBy(POST_ID, DESCENDING, INTEGER_COMPARISON)); + return convertPostsToSQLStyle($rows, true); +} + +# Ban Functions +function banByID($id) { + return convertBansToSQLStyle($GLOBALS['db']->selectWhere(BANS_FILE, new SimpleWhereClause(BAN_ID, '=', $id, INTEGER_COMPARISON), 1), true); +} + +function banByIP($ip) { + return convertBansToSQLStyle($GLOBALS['db']->selectWhere(BANS_FILE, new SimpleWhereClause(BAN_IP, '=', $ip, STRING_COMPARISON), 1), true); +} + +function allBans() { + $rows = $GLOBALS['db']->selectWhere(BANS_FILE, NULL, -1, new OrderBy(BAN_TIMESTAMP, DESCENDING, INTEGER_COMPARISON)); + return convertBansToSQLStyle($rows); +} + +function convertBansToSQLStyle($bans, $singleban=false) { + $newbans = array(); + foreach ($bans as $oldban) { + $ban = array(); + $ban['id'] = $oldban[BAN_ID]; + $ban['ip'] = $oldban[BAN_IP]; + $ban['timestamp'] = $oldban[BAN_TIMESTAMP]; + $ban['expire'] = $oldban[BAN_EXPIRE]; + $ban['reason'] = $oldban[BAN_REASON]; + + if ($singleban) { return $ban; } + $newbans[] = $ban; + } + return $newbans; +} + +function insertBan($newban) { + $ban = array(); + $ban[BAN_ID] = '0'; + $ban[BAN_IP] = $newban['ip']; + $ban[BAN_TIMESTAMP] = time(); + $ban[BAN_EXPIRE] = $newban['expire']; + $ban[BAN_REASON] = $newban['reason']; + + return $GLOBALS['db']->insertWithAutoId(BANS_FILE, BAN_ID, $ban); +} + +function clearExpiredBans() { + $compClause = new AndWhereClause(); + $compClause->add(new SimpleWhereClause(BAN_EXPIRE, '>', 0, INTEGER_COMPARISON)); + $compClause->add(new SimpleWhereClause(BAN_EXPIRE, '<=', time(), INTEGER_COMPARISON)); + + $bans = $GLOBALS['db']->selectWhere(BANS_FILE, $compClause, -1); + foreach ($bans as $ban) { + deleteBanByID($ban[BAN_ID]); + } +} + +function deleteBanByID($id) { + $GLOBALS['db']->deleteWhere(BANS_FILE, new SimpleWhereClause(BAN_ID, '=', $id, INTEGER_COMPARISON)); +} + +?> \ No newline at end of file diff --git a/inc/.svn/text-base/database_mysql.php.svn-base b/inc/.svn/text-base/database_mysql.php.svn-base new file mode 100644 index 0000000..64ecb42 --- /dev/null +++ b/inc/.svn/text-base/database_mysql.php.svn-base @@ -0,0 +1,195 @@ + 0; +} + +function insertPost($post) { + mysql_query("INSERT INTO `" . $GLOBALS['mysql_posts_table'] . "` (`parent`, `timestamp`, `bumped`, `ip`, `name`, `tripcode`, `email`, `nameblock`, `subject`, `message`, `password`, `file`, `file_hex`, `file_original`, `file_size`, `file_size_formatted`, `image_width`, `image_height`, `thumb`, `thumb_width`, `thumb_height`) VALUES (" . $post['parent'] . ", " . time() . ", " . time() . ", '" . $_SERVER['REMOTE_ADDR'] . "', '" . mysql_real_escape_string($post['name']) . "', '" . mysql_real_escape_string($post['tripcode']) . "', '" . mysql_real_escape_string($post['email']) . "', '" . mysql_real_escape_string($post['nameblock']) . "', '" . mysql_real_escape_string($post['subject']) . "', '" . mysql_real_escape_string($post['message']) . "', '" . mysql_real_escape_string($post['password']) . "', '" . $post['file'] . "', '" . $post['file_hex'] . "', '" . mysql_real_escape_string($post['file_original']) . "', " . $post['file_size'] . ", '" . $post['file_size_formatted'] . "', " . $post['image_width'] . ", " . $post['image_height'] . ", '" . $post['thumb'] . "', " . $post['thumb_width'] . ", " . $post['thumb_height'] . ")"); + return mysql_insert_id(); +} + +function bumpThreadByID($id) { + mysql_query("UPDATE `" . $GLOBALS['mysql_posts_table'] . "` SET `bumped` = " . time() . " WHERE `id` = " . $id . " LIMIT 1"); +} + +function countThreads() { + return mysql_result(mysql_query("SELECT COUNT(*) FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `parent` = 0"), 0, 0); +} + +function allThreads() { + $threads = array(); + $result = mysql_query("SELECT * FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `parent` = 0 ORDER BY `bumped` DESC"); + while ($thread = mysql_fetch_assoc($result)) { + $threads[] = $thread; + } + return $threads; +} + +function postsInThreadByID($id) { + $posts = array(); + $result = mysql_query("SELECT * FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `id` = " . $id . " OR `parent` = " . $id . " ORDER BY `id` ASC"); + while ($post = mysql_fetch_assoc($result)) { + $posts[] = $post; + } + return $posts; +} + +function latestRepliesInThreadByID($id) { + $posts = array(); + $replies = mysql_query("SELECT * FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `parent` = " . $id . " ORDER BY `id` DESC LIMIT 3"); + while ($post = mysql_fetch_assoc($replies)) { + $posts[] = $post; + } + return $posts; +} + +function postsByHex($hex) { + $posts = array(); + $result = mysql_query("SELECT `id`, `parent` FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `file_hex` = '" . mysql_real_escape_string($hex) . "' LIMIT 1"); + while ($post = mysql_fetch_assoc($result)) { + $posts[] = $post; + } + return $posts; +} + +function deletePostByID($id) { + $posts = postsInThreadByID($id); + foreach ($posts as $post) { + if ($post['id'] != $id) { + deletePostImages($post); + mysql_query("DELETE FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `id` = " . $post['id'] . " LIMIT 1"); + } else { + $thispost = $post; + } + } if (isset($thispost)) { + deletePostImages($thispost); + mysql_query("DELETE FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `id` = " . $thispost['id'] . " LIMIT 1"); + } +} + +function trimThreads() { + global $tinyib; + if ($tinyib['maxthreads'] > 0) { + $result = mysql_query("SELECT `id` FROM `b_posts` WHERE `parent` = 0 ORDER BY `bumped` DESC LIMIT " . $tinyib['maxthreads']. ", 10"); + while ($post = mysql_fetch_assoc($result)) { + deletePostByID($post['id']); + } + } +} + +function lastPostByIP() { + $replies = mysql_query("SELECT * FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `ip` = '" . $_SERVER['REMOTE_ADDR'] . "' ORDER BY `id` DESC LIMIT 1"); + while ($post = mysql_fetch_assoc($replies)) { + return $post; + } +} + +# Ban Functions +function banByID($id) { + $result = mysql_query("SELECT * FROM `" . $GLOBALS['mysql_bans_table'] . "` WHERE `id` = '" . mysql_real_escape_string($id) . "' LIMIT 1"); + while ($ban = mysql_fetch_assoc($result)) { + return $ban; + } +} + +function banByIP($ip) { + $result = mysql_query("SELECT * FROM `" . $GLOBALS['mysql_bans_table'] . "` WHERE `ip` = '" . mysql_real_escape_string($ip) . "' LIMIT 1"); + while ($ban = mysql_fetch_assoc($result)) { + return $ban; + } +} + +function allBans() { + $bans = array(); + $result = mysql_query("SELECT * FROM `" . $GLOBALS['mysql_bans_table'] . "` ORDER BY `timestamp` DESC"); + while ($ban = mysql_fetch_assoc($result)) { + $bans[] = $ban; + } + return $bans; +} + +function insertBan($ban) { + mysql_query("INSERT INTO `" . $GLOBALS['mysql_bans_table'] . "` (`ip`, `timestamp`, `expire`, `reason`) VALUES ('" . mysql_real_escape_string($ban['ip']) . "', " . time() . ", '" . mysql_real_escape_string($ban['expire']) . "', '" . mysql_real_escape_string($ban['reason']) . "')"); + return mysql_insert_id(); +} + +function clearExpiredBans() { + $result = mysql_query("SELECT * FROM `" . $GLOBALS['mysql_bans_table'] . "` WHERE `expire` > 0 AND `expire` <= " . time()); + while ($ban = mysql_fetch_assoc($result)) { + mysql_query("DELETE FROM `" . $GLOBALS['mysql_bans_table'] . "` WHERE `id` = " . $ban['id'] . " LIMIT 1"); + } +} + +function deleteBanByID($id) { + mysql_query("DELETE FROM `" . $GLOBALS['mysql_bans_table'] . "` WHERE `id` = " . mysql_real_escape_string($id) . " LIMIT 1"); +} + +?> \ No newline at end of file diff --git a/inc/.svn/text-base/functions.php.svn-base b/inc/.svn/text-base/functions.php.svn-base new file mode 100644 index 0000000..42497f3 --- /dev/null +++ b/inc/.svn/text-base/functions.php.svn-base @@ -0,0 +1,262 @@ +"); + $replace = array("<", ">"); + + return str_replace($search, $replace, $string); +} + +function threadUpdated($id) { + rebuildThread($id); + rebuildIndexes(); +} + +function newPost() { + return array('parent' => '0', + 'timestamp' => '0', + 'bumped' => '0', + 'ip' => '', + 'name' => '', + 'tripcode' => '', + 'email' => '', + 'nameblock' => '', + 'subject' => '', + 'message' => '', + 'password' => '', + 'file' => '', + 'file_hex' => '', + 'file_original' => '', + 'file_size' => '0', + 'file_size_formatted' => '', + 'image_width' => '0', + 'image_height' => '0', + 'thumb' => '', + 'thumb_width' => '0', + 'thumb_height' => '0'); +} + +function convertBytes($number) { + $len = strlen($number); + if ($len < 4) { + return sprintf("%dB", $number); + } elseif ($len <= 6) { + return sprintf("%0.2fKB", $number/1024); + } elseif ($len <= 9) { + return sprintf("%0.2fMB", $number/1024/1024); + } + + return sprintf("%0.2fGB", $number/1024/1024/1024); +} + +function nameAndTripcode($name) { + global $tinyib; + + if (ereg("(#|!)(.*)", $name, $regs)) { + $cap = $regs[2]; + $cap_full = '#' . $regs[2]; + + if (function_exists('mb_convert_encoding')) { + $recoded_cap = mb_convert_encoding($cap, 'SJIS', 'UTF-8'); + if ($recoded_cap != '') { + $cap = $recoded_cap; + } + } + + if (strpos($name, '#') === false) { + $cap_delimiter = '!'; + } elseif (strpos($name, '!') === false) { + $cap_delimiter = '#'; + } else { + $cap_delimiter = (strpos($name, '#') < strpos($name, '!')) ? '#' : '!'; + } + + if (ereg("(.*)(" . $cap_delimiter . ")(.*)", $cap, $regs_secure)) { + $cap = $regs_secure[1]; + $cap_secure = $regs_secure[3]; + $is_secure_trip = true; + } else { + $is_secure_trip = false; + } + + $tripcode = ""; + if ($cap != "") { + /* From Futabally */ + $cap = strtr($cap, "&", "&"); + $cap = strtr($cap, ",", ", "); + $salt = substr($cap."H.", 1, 2); + $salt = ereg_replace("[^\.-z]", ".", $salt); + $salt = strtr($salt, ":;<=>?@[\\]^_`", "ABCDEFGabcdef"); + $tripcode = substr(crypt($cap, $salt), -10); + } + + if ($is_secure_trip) { + if ($cap != "") { + $tripcode .= "!"; + } + + $tripcode .= "!" . substr(md5($cap_secure . $tinyib['tripcodeseed']), 2, 10); + } + + return array(ereg_replace("(" . $cap_delimiter . ")(.*)", "", $name), $tripcode); + } + + return array($name, ""); +} + +function nameBlock($name, $tripcode, $email, $timestamp) { + $output = ""; + + if ($name == "" && $tripcode == "") { + $output .= "Anonymous"; + } else { + $output .= $name; + } + + if ($tripcode != "") { + $output .= '!' . $tripcode; + } + + if ($email != "") { + $output = '' . $output . ''; + } + + return '' . $output . ' ' . date('y/m/d(D)H:i:s', $timestamp); +} + +function writePage($filename, $contents) { + global $tinyib; + + $tempfile = tempnam('res/', $tinyib['board'] . 'tmp'); /* Create the temporary file */ + $fp = fopen($tempfile, 'w'); + fwrite($fp, $contents); + fclose($fp); + /* If we aren't able to use the rename function, try the alternate method */ + if (!@rename($tempfile, $filename)) { + copy($tempfile, $filename); + unlink($tempfile); + } + + chmod($filename, 0664); /* it was created 0600 */ +} + +function fixLinksInRes($html) { + $search = array(' href="css/', ' href="src/', ' href="thumb/', ' href="res/', ' href="imgboard.php', ' href="favicon.ico', 'src="thumb/', ' action="imgboard.php'); + $replace = array(' href="../css/', ' href="../src/', ' href="../thumb/', ' href="../res/', ' href="../imgboard.php', ' href="../favicon.ico', 'src="../thumb/', ' action="../imgboard.php'); + + return str_replace($search, $replace, $html); +} + +function colorQuote($message) { + if (substr($message, -1, 1) != "\n") { $message .= "\n"; } + return preg_replace('/^(>[^\>](.*))\n/m', '\\1' . "\n", $message); +} + +function deletePostImages($post) { + if ($post['file'] != '') { @unlink('src/' . $post['file']); } + if ($post['thumb'] != '') { @unlink('thumb/' . $post['thumb']); } +} + +function manageCheckLogIn() { + global $tinyib; + $loggedin = false; $isadmin = false; + if (isset($_POST['password'])) { + if ($_POST['password'] == $tinyib['adminpassword']) { + $_SESSION['tinyib'] = $tinyib['adminpassword']; + } elseif ($tinyib['modpassword'] != '' && $_POST['password'] == $tinyib['modpassword']) { + $_SESSION['tinyib'] = $tinyib['modpassword']; + } + } + + if (isset($_SESSION['tinyib'])) { + if ($_SESSION['tinyib'] == $tinyib['adminpassword']) { + $loggedin = true; + $isadmin = true; + } elseif ($tinyib['modpassword'] != '' && $_SESSION['tinyib'] == $tinyib['modpassword']) { + $loggedin = true; + } + } + + return array($loggedin, $isadmin); +} + +function createThumbnail($name, $filename, $new_w, $new_h) { + $system=explode(".", $filename); + $system = array_reverse($system); + if (preg_match("/jpg|jpeg/", $system[0])) { + $src_img=imagecreatefromjpeg($name); + } else if (preg_match("/png/", $system[0])) { + $src_img=imagecreatefrompng($name); + } else if (preg_match("/gif/", $system[0])) { + $src_img=imagecreatefromgif($name); + } else { + return false; + } + + if (!$src_img) { + fancyDie("Unable to read uploaded file during thumbnailing. A common cause for this is an incorrect extension when the file is actually of a different type."); + } + $old_x = imageSX($src_img); + $old_y = imageSY($src_img); + if ($old_x > $old_y) { + $percent = $new_w / $old_x; + } else { + $percent = $new_h / $old_y; + } + $thumb_w = round($old_x * $percent); + $thumb_h = round($old_y * $percent); + + $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h); + fastImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y); + + if (preg_match("/png/", $system[0])) { + if (!imagepng($dst_img, $filename)) { + return false; + } + } else if (preg_match("/jpg|jpeg/", $system[0])) { + if (!imagejpeg($dst_img, $filename, 70)) { + return false; + } + } else if (preg_match("/gif/", $system[0])) { + if (!imagegif($dst_img, $filename)) { + return false; + } + } + + imagedestroy($dst_img); + imagedestroy($src_img); + + return true; +} + +function fastImageCopyResampled(&$dst_image, &$src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h, $quality = 3) { + //Author: Tim Eckel - Date: 12/17/04 - Project: FreeRingers.net - Freely distributable. + if (empty($src_image) || empty($dst_image)) { return false; } + + if ($quality <= 1) { + $temp = imagecreatetruecolor ($dst_w + 1, $dst_h + 1); + imagecopyresized ($temp, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w + 1, $dst_h + 1, $src_w, $src_h); + imagecopyresized ($dst_image, $temp, 0, 0, 0, 0, $dst_w, $dst_h, $dst_w, $dst_h); + imagedestroy ($temp); + } elseif ($quality < 5 && (($dst_w * $quality) < $src_w || ($dst_h * $quality) < $src_h)) { + + $tmp_w = $dst_w * $quality; + $tmp_h = $dst_h * $quality; + $temp = imagecreatetruecolor ($tmp_w + 1, $tmp_h + 1); + + imagecopyresized ($temp, $src_image, $dst_x * $quality, $dst_y * $quality, $src_x, $src_y, $tmp_w + 1, $tmp_h + 1, $src_w, $src_h); + + imagecopyresampled ($dst_image, $temp, 0, 0, 0, 0, $dst_w, $dst_h, $tmp_w, $tmp_h); + + imagedestroy ($temp); + + } else { + imagecopyresampled ($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); + } + + + return true; +} + +?> \ No newline at end of file diff --git a/inc/.svn/text-base/html.php.svn-base b/inc/.svn/text-base/html.php.svn-base new file mode 100644 index 0000000..dc294ee --- /dev/null +++ b/inc/.svn/text-base/html.php.svn-base @@ -0,0 +1,461 @@ + + + + + ¨ + + +EOF; + } elseif ($post["file"] != "") { + $return .= <<File: ${post["file"]}–(${post["file_size_formatted"]}, ${post["image_width"]}x${post["image_height"]}, ${post["file_original"]}) +
+ +${post[ + +EOF; + } + + $return .= << +