Create New Album:


EOT; } //-----------------------------------------------------------------------------// function show_album_delete() { echo <<

Delete Album:


EOT; } //---------------------------------------------------------------------------// //---------------------------------------------------------------------------// // Create random alphanumber string 8 lebgth minimum //---------------------------------------------------------------------------// function RandomString($length = 8) { $string = ""; //character that can be used $possible = "0123456789bcdfghjkmnpqrstvwxyz"; for($i=0;$i < $length;$i++) { $char = substr($possible, rand(0, strlen($possible)-1), 1); if (!strstr($string, $char)) { $string .= $char; } } return $string; } //---------------------------------------------------------------------------// function check_file($filename) { $exists = file_exists($filename); if ($exists) { echo "file exist ...\n"; } else { echo "file does not exist ..\n"; } } //---------------------------------------------------------------------------// function find_directories() { #$command = "ls -d */"; $command = "find * -prune -type d -exec ls -d {} \;"; system($command, $rval); } //---------------------------------------------------------------------------// // List user's directories ommiting parent directory //---------------------------------------------------------------------------// function load_albums($username) { if(isset($_GET['album'])) { $album = $_GET['album']; } else { $album = "album"; } $username = strtolower($username); $dir = $this->root . "/" . substr($username, 0,1) . "/" . $username; //echo $dir . "\n"; if(is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if(($file != '.') && ($file != '..')) { $fullpath = $dir . "/" . $file; if(is_dir($fullpath)) { if($file == $album) { echo "url?album=$file\">" . "" . ucfirst($file) . ", \n"; } else { echo "url?album=$file\">" . "" . ucfirst($file) . ", \n"; } } } } closedir($dh); } } echo "

"; } //---------------------------------------------------------------------------// // List user's directories ommiting parent directory //---------------------------------------------------------------------------// function dropdown_albums($username) { if(isset($_GET['album'])) { $album = $_GET['album']; } else { $album = "album"; } $username = strtolower($username); $dir = $this->root . "/" . substr($username, 0,1) . "/" . $username; echo "\n"; } //---------------------------------------------------------------------------// function album_links() { foreach ($this->stack as $key=>$value) { echo "url . "/" . $this->stack[$key] . "\">$this->stack[$key]\n"; } } //---------------------------------------------------------------------------// // Create directory for Album based on root, user name and album name //---------------------------------------------------------------------------// function create_album($username, $album = "album") { $username = strtolower($username); $album = strtolower(str_replace(" ","_", trim($album))); $album = preg_replace("/[^a-zA-Z0-9_\s]/", "", $album); if((strlen($album) < 4) || (strlen($album) > 16 )) $album = RandomString(); $dir = $this->root . "/" . substr($username, 0,1) . "/" . $username . "/" . $album; #debug echo "1. mkdir" . $dir . "

\n"; if(!is_dir($dir)) { #debug echo "2. mkdir" . $dir . "

\n"; mkdir($dir, 0777, true); chmod($dir, 0777); } } //---------------------------------------------------------------------------// // Delete directory for Album based on root, user name and album name //---------------------------------------------------------------------------// function delete_album($username, $album) { $username = strtolower($username); $album = strtolower(str_replace(" ","_", trim($album))); $album = preg_replace("/[^a-zA-Z0-9_\s]/", "", $album); if(strlen($album) < 2) { echo "No Album Deleted\n"; } else { $dir = $this->root . "/" . substr($username, 0,1) . "/" . $username . "/" . $album; if(is_dir($dir)) { $cmd = "rm -fR " . $dir; #debig echo $cmd . "
"; system($cmd, $rval); } } } //---------------------------------------------------------------------------// #create_album("kevin101"); #delete_album("kevin300", "8z7km6"); #list_album("kevin101"); #album_list(); //---------------------------------------------------------------------------// } real_escape_string($url); $name = $mysqli->real_escape_string($name); $album = $mysqli->real_escape_string($album); /*--- this query with escaped $city will work ---*/ if ($mysqli->query("INSERT INTO wbs.images ( url, user, album, dt ) VALUES ( '$url', '$name', '$album', NOW() )")) { printf("%d row inserted.\n", $mysqli->affected_rows); } /*--- this query with escaped $city will work ---*/ if ($mysqli->query("UPDATE wbs.users SET sec = sec + 1, logdate = now(), picture = '$url' WHERE username LIKE '$name';")) { printf("%d row updated.\n", $mysqli->affected_rows); } $mysqli->close(); } //-----------------------------------------------------------------------------// function deleteImage($url) { $mysqli = new mysqli("localhost", "root", "xapian64", "wbs"); #$url = $mysqli->real_escape_string($url); /*--- this query with escaped $city will work ---*/ if ($mysqli->query("DELETE FROM wbs.images WHERE url LIKE '$url';")) { printf("%d row deleted.\n", $mysqli->affected_rows); } $mysqli->close(); } //-----------------------------------------------------------------------------// } ?>