} } } } if (!empty($_REQUEST['youtube_url'])) { require_once 'db/db.class.php'; checkForSpam(); // Open the DB connection $db = new db_class(); if (!$db->connect($GLOBALS['db_hostname'], $GLOBALS['db_username'], $GLOBALS['db_password'], $GLOBALS['db_name'], true)) { $db->print_last_error(false); } // Get the user info into the DB $user_data = $stuffer->getUserData(); $sql = "SELECT id from users where username = '******'username']) . "';"; $user_id = $db->select_one($sql); if (!$user_id) { $user_id = $db->insert_array('users', $user_data); } // cram the video into the db $youtube_url = mysql_real_escape_string($_REQUEST['youtube_url']); $create_time = empty($create_time) ? time() : $create_time; $video_data = array('youtube_url' => $youtube_url, 'type' => 'video', 'user_id' => $user_id, 'create_time' => time()); $video_id = $db->insert_array('images', $video_data); if (is_numeric($video_id)) { header('Location: http://www.braincrave.org/?id=' . $video_id . "&success=1"); } else { $stuffer->error("Really? You screwed this up? All you had to do was paste in ONE THING. Maybe you should try again."); } } else { $image_id = $stuffer->stuff();
<?php require_once 'config.php'; require_once 'db/db.class.php'; require_once 'ImageStuffer.php'; $user_id = 1; $db = new db_class(); if (!$db->connect($GLOBALS['db_hostname'], $GLOBALS['db_username'], $GLOBALS['db_password'], $GLOBALS['db_name'], true)) { $db->print_last_error(false); die; } $stuffer = new ImageStuffer(); // open the current directory by opendir $handle = opendir("bimages"); echo 'svn delete '; while (($file = readdir($handle)) !== false) { $filename = 'bimages/' . $file; $extension = substr(strrchr($filename, '.'), 1); $md5 = md5_file($filename); $sql = "SELECT create_time FROM images WHERE md5 = '{$md5}'"; $create_time = $db->select_one($sql); if (!$create_time) { $create_time = filemtime($filename); $stuffer->saveImageToDB($md5, $extension, $user_id, $create_time); rename($filename, 'bimages/' . $md5 . '.' . $extension); echo " {$filename}"; } } closedir($handle);
</head> <body> <div align="center"> <?php if (!empty($_REQUEST['id']) && is_numeric($_REQUEST['id'])) { $image_id = $_REQUEST['id']; $row = $db->select("SELECT * FROM images WHERE id = {$image_id} LIMIT 1"); } else { $row = $db->select("SELECT * FROM images ORDER BY RAND() LIMIT 1"); } $media = $db->get_row($row, 'MYSQL_ASSOC'); // we've got an image $md5 = $media['md5']; $sql = "SELECT username FROM users u WHERE id = {$media['user_id']};"; $poster = $db->select_one($sql); $image_id = $media['id']; $image_type = $media['type']; $image_url = "bimages/{$md5}.{$image_type}"; $r = $db->select("SELECT id, md5, youtube_url, type FROM images WHERE id < {$image_id} ORDER BY id DESC LIMIT 1 "); $row = $db->get_row($r, 'MYSQL_ASSOC'); $prev_img = $row['md5'] . '.' . $row['type']; $prev_img_id = $db->select_one("SELECT id FROM images WHERE id < {$image_id} ORDER BY id DESC LIMIT 1"); $next_img_id = $db->select_one("SELECT id FROM images WHERE id > {$image_id} ORDER BY id ASC LIMIT 1"); $most_recent_upload = $db->select_one("SELECT id FROM images ORDER BY id DESC LIMIT 1"); $r = $db->select("SELECT id, md5, youtube_url, type FROM images WHERE id > {$image_id} ORDER BY id ASC LIMIT 1 "); $row = $db->get_row($r, 'MYSQL_ASSOC'); $next_img = 'bimages/' . $row['md5'] . '.' . $row['type']; ?> <div class="braincrave_title"> <a href="http://www.braincrave.org?id=<?php