function __construct() { $this->dbLink = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!$this->dbLink) { awfuck('Can\'t reach database. MySQL says: ' . mysql_error()); } mysql_select_db(DB_NAME); }
$deboog = isset($_GET['deboog']) || $_SESSION['deboog']; foreach (array('section', 'category', 'month', 'year', 'post', 'offset', 'mode', 'status') as $crit) { if (isset($_GET[$crit])) { $req_posts[$crit] = $_GET[$crit]; } } $req_page = isset($_GET['page']) ? $_GET['page'] : "default"; // Some useful variables $pagetitle = ''; $headerisprinted = false; // Is set to true by do_header() $poststatus = array('1' => 'Draft', '2' => 'Published', '3' => 'Deleted'); // Connect to me database $db['link'] = mysql_connect($db['host'], $db['user'], $db['pass']); if (!$db['link']) { awfuck('Can\'t reach database. MySQL says: ' . mysql_error()); } mysql_select_db($db['name']); // Get list of sections $result = mysql_query('SELECT * FROM sections'); while ($section = mysql_fetch_assoc($result)) { $section_byname[$section['name']] = $section; $section_byid[$section['section_id']] = $section; $section_byplug[$section['plug']] = $section; } mysql_free_result($result); // Get list of categories $result = mysql_query('SELECT * FROM categories'); while ($category = mysql_fetch_assoc($result)) { $category_byname[$category['name']] = $category; $category_byid[$category['category_id']] = $category;
function __construct() { awfuck("You've asked for a specific page, which exists, but is missing the sacred class."); }
function do_page($reqPosts) { //global $selectedposts, $onepost; echo '<div class="container"><!-- Page -->'; // If, posting is required, then do it. if (isset($_POST['doit'])) { if (!$_POST['post_id']) { awfuck('Post submitted with no post_id!'); } switch ($_POST['doit']) { case "Submit Edit": $thequery = sprintf('UPDATE posts SET section_id = %s, category_id = %s, status = %s, title = "%s", content = "%s", date = "%s", time = "%s" WHERE post_id = %s', mysql_real_escape_string($_POST['section_id']), mysql_real_escape_string($_POST['category_id']), mysql_real_escape_string($_POST['status']), mysql_real_escape_string($_POST['title']), mysql_real_escape_string($_POST['content']), mysql_real_escape_string($_POST['sort_date']), mysql_real_escape_string($_POST['sort_time']), mysql_real_escape_string($_POST['post_id'])); shitbugs(sprintf('<b>Query is:</b><br />%s', $thequery)); if (mysql_query($thequery)) { happymsg('<h4>Post has been updated</h4>', $_POST['post_id']); } else { awfuck(mysql_error()); } display_posts(array('post' => $_POST['post_id']), "display"); break; case "Submit New": echo "- NEWPOST<br>"; $thequery = sprintf('INSERT INTO posts (section_id, category_id, status, title, content, date, time) VALUES (%s, %s, %s, "%s", "%s", "%s", "%s")', mysql_real_escape_string($_POST['section_id']), mysql_real_escape_string($_POST['category_id']), mysql_real_escape_string($_POST['status']), mysql_real_escape_string($_POST['title']), mysql_real_escape_string($_POST['content']), mysql_real_escape_string($_POST['sort_date']), mysql_real_escape_string($_POST['sort_time'])); if (mysql_query($thequery)) { printf('Post #%s has been created. <a href="phux0red.php?page=dostuff&edit&post=%s">Edit it again?</a>', mysql_insert_id(), mysql_insert_id()); } display_posts(array('post' => mysql_insert_id()), "display"); break; case "Attach Image": echo "- ATTACH IMAGE<br>"; foreach ($_FILES as $file) { print_r($file); echo '<br><br>'; if ($file['tmp_name'] > '') { list($filebase, $fileext) = explode(".", strtolower($file['name']), 2); $small_filename = sprintf('gallery/small/%s-s.%s', $filebase, $fileext); $medium_filename = sprintf('gallery/medium/%s-m.%s', $filebase, $fileext); switch ($fileext) { case "dll": echo "F**K YOU!"; break; case "jpg": echo "Type is JPEG<br>"; $imagetoprocess = imagecreatefromjpeg($file['tmp_name']); imagejpeg(process_image($imagetoprocess, 200, 200), $small_filename, 100); imagejpeg(process_image($imagetoprocess, 800, 600), $medium_filename, 100); $thequery = sprintf('INSERT INTO post_img (post_id, filename, caption, description) VALUES (%s, "%s", "%s", "%s")', mysql_real_escape_string($_POST['post_id']), mysql_real_escape_string($filebase), mysql_real_escape_string($_POST['caption']), mysql_real_escape_string($_POST['description'])); if (mysql_query($thequery)) { printf('Image has been uploaded. <a href="phux0red.php?post=%s">View post</a>', $_POST['post_id']); } break; } } } move_uploaded_file($_FILES['image_to_upload']['tmp_name'], "gallery/large/{$_FILES['image_to_upload']['name']}"); break; default: echo "- " . $_post['doit']; break; } } else { echo "NOT POSTING ANYTHING, SO...<br>"; } // End posting stuff. echo "FINISHED DECIDING WHAT TO DO<br>"; if (isset($_GET['edit'])) { if (isset($_GET['post'])) { edit_post($onepost['0']); } } elseif (isset($_GET['newpost'])) { edit_post(0); } elseif (isset($_GET['addimg'])) { if (isset($_GET['post'])) { edit_images($onepost['0']); } } else { echo "<h3>Drafts:</h3>"; display_posts(array('status' => '1'), "list"); echo "<h3>Published Posts:</h3>"; display_posts(array('status' => '2'), "list"); echo "<h3>Deleted Posts:</h3>"; display_posts(array('status' => '3'), "list"); } ?> </div><!-- Page --> <?php }
} // Init function do_page() { } $title['page'] = "Account Stuff"; if (!$_POST & !$_GET) { awshit('Yeah, that isn\'t gonna work.'); } if (isset($_GET['logout'])) { $isloggedin = false; unset($_SESSION); session_destroy(); awshit('You are logged out.'); } else { $result_login = mysql_query(sprintf('SELECT user_id, username, realname FROM users WHERE username="******" AND password="******"', $_POST['u'], sha1($_POST['p']))); if (!$result_login) { awfuck('Something f****d up: %s', mysql_error()); } if ($currentuser = mysql_fetch_array($result_login)) { $_SESSION = $currentuser; if ($_POST['deboog']) { $_SESSION['deboog'] = true; } $isloggedin = true; awshit(sprintf('Welcome, %s!', $currentuser['realname'])); } else { awshit('Die, muthafucka!'); } printf('Welcome, %s!', $currentuser['realname']); }