| Define (' Max ', 2);
MySQL tutorial _connect (' localhost ', ' your MySQL username ', ' your MySQL password '); mysql_select_db (' Your MySQL database ');
Switch ($_post[' action ']) { Case ' upload ':
$file = $_files[' file ' [' Tmp_name ']; $filename = $_files[' file ' [' Name '];
if ($file) {
$max = max * 1024 * 1024; $q = mysql_query ("select * from ' uploads ' order by ' batch ' desc limit 1"); $r = Mysql_fetch_assoc ($q); $batch = $r [' Batch '];
if ($filename = = ' Upload.zip ') {
$zip = Zip_open ($file); if ($zip) {
while ($zip _entry = Zip_read ($zip)) {
$size = zip_entry_filesize ($zip _entry);
$name = Zip_entry_name ($zip _entry);
$type = substr (STRRCHR ($name, '. '), 1);
if (Zip_entry_open ($zip, $zip _entry, "R")) {
$content = Zip_entry_read ($zip _entry, zip_entry_filesize ($zip _entry));
Zip_entry_close ($zip _entry);
}
if ($size > $max) {
Header (' Location:./?error=4 ');
Exit
}
$error = true;
if ($type = = ' gif ' && $error) {
$error = false;
}
if ($type = = ' png ' && $error) {
$error = false;
}
if ($type = = ' jpg ' && $error) {
$error = false;
}
if ($type = = ' jpeg ' && $error) {
$error = false;
}
if ($error) {
Header (' Location:./?error=2 ');
} else {
$id = 1;
$batch 2 = $batch + 1;
while (File_exists ("uploads/$id/$name")) {
$id + +;
}
@mkdir ("uploads/$id");
$fp = @fopen ("uploads/$id/$name", "w");
if (@fwrite ($FP, $content)) {
$q = mysql_query ("INSERT INTO ' uploads ' (' file ', ' batch ') VALUES (' uploads/$id/$name ', ' $batch 2 ')");
$id = mysql_insert_id ();
} else {
Header (' Location:./?error=3 ');
}
Fclose ($FP);
}
}
Header (' Location:./?batch= '. $batch 2);
Zip_close ($zip);
}
} else {
if (filesize ($file) > $max) {
Header (' Location:./?error=4 ');
Exit
}
$error = true;
if (@imagecreatefromjpeg ($file) && $error) {
$error = false;
}
if (@imagecreatefromgif ($file) && $error) {
$error = false;
}
if (@imagecreatefrompng ($file) && $error) {
$error = false;
}
if ($error) {
Header (' Location:./?error=2 ');
} else {
$id = 1;
$batch = $batch + 1;
while (File_exists ("uploads/$id/$filename")) {
$id + +;
}
@mkdir ("uploads/$id");
if (@move_uploaded_file ($file, "uploads/$id/$filename")) {
$q = mysql_query ("INSERT INTO ' uploads ' (' file ', ' batch ') VALUES (' uploads/$id/$filename ', ' $batch ')");
$id = mysql_insert_id ();
Header (' Location:./?image= '. $id);
} else {
Header (' Location:./?error=3 ');
}
}
}
} else {
Header (' Location:./?error=1 ');
}
Exit
Break
}
Header (' content-type:text/html; charset=iso-8859-1 ');
Ob_start (' rewrite ');
function Rewrite ($buffer) {
$host = $_server[' http_host '];
$path = dirname ($_server[' php_self '));
$absolute = "http://$host $path/";
return Preg_replace (' # (href|src|action) = "/# '," \1= "$absolute", $buffer);
}
?>
<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml" >
<head>
<title>jpegr-share Photos instantly</title>
<meta name= "description" content= "Upload and share photos and images instantly, on jpegr.com"/>
<meta name= "keywords" content= "upload, upload images, share photos, photo sharing, Image uploader"/>
<link href= "/css tutorial/main.css" rel= "stylesheet"/>
<script src= "/mint/?js" type= "text/Web Effects" ></script>
<script src= "/js/nb-object.js" type= "Text/javascript" ></script>
</head>
<body>
<h1><a href= "http://jpeg.sn8.us/" title= "Goto Jpegr Home" ><img src= "/img/logo.gif" alt= "Jpegr"/> </a></h1>
<div id= "Menu" >
<form method= "POST" action= "/" enctype= "Multipart/form-data" class= "right" >
<input type= "hidden" name= "action" value= "upload"/>
<label for= "Quick" >quick upload</label>
<input type= "File" name= "file" size= "ten" id= "Quick"/>
<input type= "Submit" value= "Upload" class= "button"/>
</form>
<a href= "/" >upload</a>
<a href= "/help/" >help</a>
<a href= "/terms-of-service/" >terms of service</a>
</div>
<?php Recently uploaded query $q = mysql_query (' select * from ' uploads ' ID ' desc limit 15 '); $q = mysql_query (' Select count (' ID ') as ' count ' from ' uploads '); $r = Mysql_fetch_assoc ($q);
?> <div id= "Main" > <H2 class= "Right" ><?php echo number_format ($r [' count ']);?> <strong>images <?php if ($_get[' p '] = = ' help ') {
?>
<h2>help</h2>
<div>
<ul>
<li>
<strong>how do I upload a image?</strong><br/>
Just use the Quick Upload form on the top, or goto the <a href= "/" >home page</a> to <a href= "/" >upload A n Image</a>
</li>
<li>
<strong>what does "You must select a file to upload!" mean?</strong><br/>
This means is clicked <strong>upload</strong> without selecting an image file.
</li>
<li>
<strong>what does "that are a not a valid JPEG, GIF, or PNG image." Mean?</strong><br/>
This means so you uploaded a file, but it is not a JPEG, GIF, or PNG image.
</li>
<li>
<strong>what does "there is a problem with the server, and we were unable to upload image." Your T;<br/>
This means your file is accepted, but it did not get saved, your would need to <a href= "/" >try again</a>, or &L T;a href= "/" >upload another image</a>.
</li>
<li>
<strong>what does "The file you selected were too big, <em><?php echo Max;?>mb</em> is the maximum . "Mean?</strong><br/>
This means is tried to upload a file of that is too big.
</li>
</ul>
</div>
<?php } elseif ($_get[' p '] = = ' Terms-of-service ') {
?> <div> <strong>when you upload to Jpegr your agree to the following</strong>; <ul> <li>you won't use Jpegr to upload pornographic the content, any violation the this agreement may result in ban, and IM Mediate removal of content.</li> <li>you won't abuse Jpegr ' s upload form.</li> <li>any violation may, permanent ban.</li> </ul> </div> <?php } else {
if (Is_numeric ($_get[' image ')) {
$q = mysql_query ("select * from ' uploads ' where ' id ' = ' $_get[image] '");
$r = Mysql_fetch_assoc ($q);
$root _ = ' http://'. $_server[' Http_host ']. DirName ($_server[' php_self ')). '/';
?>
<h2>here is your image</h2>
<div>
<a href= "/<?php echo $r [' file '];?>" >click here to view your image</a><br/><br
<label for= "Direct" >direct link to your image</label><br/>
<input type= "text" id= "direct" value= "<?php echo $root _. $r [' file '];?> "onfocus=" This.select (); "/><br/>
<label for= "Share" style= "font-weight:bold;" >share with your friends</label><br/>
<input type= "text" id= "Share" value= "<?php Echo htmlspecialchars (" $root _?image= $r [id] ");?>" Onfocus= " This.select (); "/><br/>
<label for= "HTML" >post link to MySpace or website</label><br/>
<input type= "text" id= "html" value= "<?php Echo htmlspecialchars (" <a href= "$root _" ><img src= "$root _$r[ File] "alt=" visit Jpegr "/></a>")?> "onfocus=" This.select (); "/><br/>
<label for= "Forum" >post to a forum</label><br/>
<input type= "text" id= "forum" value= "<?php Echo htmlspecialchars (" [Url= $root _][img] $root _$r[file][/img][/url] ");?>" onfocus= "This.select ();"/><br/>
If you are want to <a href= '/' >upload another image</a>, can go back or use the form below!<br/><br />
</div>
<?php }
if (Is_numeric ($_get[' batch ')) {
$q = mysql_query ("select * from ' uploads ' where ' batch ' = ' $_get[batch]");
?> <div> To view a image in full size, just click it.<br/><br/>
<?php while ($r = Mysql_fetch_assoc ($q)) { ?> <a href= "<?php echo $r [' file '];?>" > "border=" 0 "style=" max-width:75px; "/></a> <?php }
?>
<br/><br/>
<div id= "Slider" >
<h3>beta Image slideshow</h3>
<noscript>please turn on JavaScript to view our slideshows.</noscript>
<div id= "Slide" ></div>
</div>
<script type= "Text/javascript" >
<?php
$QQ = mysql_query ("select * from ' uploads ' where ' batch ' = ' $_get[batch]");
while ($RR = Mysql_fetch_assoc ($qq)) {
?>
Nb.slideshow.addimage (' <?php echo $rr [' file '];?> ');
<?php
}
?>
Nb.slideshow.start ();
</script>
</div>
<h2>share This batch with your friends</h2>
<div>
<label for= "Share" style= "font-weight:bold;" >batch viewer</label><br/>
<input type= "text" id= "Share" value= "http://jpeg.sn8.us/?batch=<?php Echo ($_get[' batch ')"? $_get[' Batch ']: 0;?> "onfocus=" This.select (); "/><br/>
If you are want to <a href= '/' >upload another batch</a>, can go back or use the form below!<br/><br />
</div>
<?php }
?> <form method= "POST" action= "/" enctype= "Multipart/form-data" > <input type= "hidden" name= "action" value= "upload"/> <?php Switch ($_get[' ERROR ']) {
Case 1:
$error = ' must select a file to Upload!<br/> ';
Break
Case 2:
$error = ' is a not a valid JPEG, GIF, or PNG image.<br/> ';
Break
Case 3:
$error = ' There is a problem with the server, and we were unable to upload your ' image.<br ';
Break
Case 4:
$error = ' The file you selected is too big, <strong> '. Max. ' Mb</strong> is the maximum.<br/> ';
Break
}
?>
<font color= "#ff0004" ><?php echo $error;?></font>
You can upload a <strong>jpeg</strong>, <strong>gif</strong>, or <strong>png</strong > Image. (Max <strong><?php echo max;?>mb</strong>) <br/><br/>
You can also upload a <strong>zip</strong> named <strong>upload.zip</strong> containing Multiple images.<br/><br/>
<label for= "File" >choose your file</label><br/>
<input type= "File" name= "file" size= "id=" "File"/><br/>
<input type= "Submit" value= "Upload" class= "button"/>
</form>
<?php }
?> </div>
</div> </body>
??????
<?php
mysql_connect (' localhost ', ' your MySQL username ', ' your MySQL password ');
mysql_select_db (' Your MySQL database ');
if ($_get[' delete ']) {
$sql = "Select * from ' uploads ' where ' id ' = ' $_get[delete] '";
$q = mysql_query ($sql);
$r = Mysql_fetch_assoc ($q);
Unlink ($_server[' document_root '). '/' . $r [' file ']];
$sql = "Delete from ' uploads ' where ' id ' = ' $_get[delete] '";
$q = mysql_query ($sql);
Header (' Location: '. $_server[' Http_referer '));
Exit
}
?>
<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>jpegr administration</title>
<style type= "Text/css" >
Body {
Font-family:sans-serif;
font-size:12px;
width:800px;
margin:40px Auto;
}
A
Color: #105cb6;
Text-decoration:none;
}
a:hover {
Text-decoration:underline;
}
TD {
padding:4px;
}
. head {
Font-weight:bold;
Color: #ffffff;
Background-color: #222222;
}
. Item {
Background-color: #f2f2f2;
}
. One {
width:60px;
Text-align:center;
}
. Three {
width:80px;
Text-align:center;
}
. page,. Current {
Display:block;
Float:left;
PADDING:2PX 4px;
margin:0px 4px 8px 0px;
}
. page {
Color: #000000;
Background-color: #eeeeee;
}
. Current {
Font-weight:bold;
Color: #ffffff;
Background-color: #222222;
}
</style>
</head>
<body>
<?php
$sql = ' Select Ceil (count (' id ')/' as ' count ' from ' uploads ';
$q = mysql_query ($sql);
$r = Mysql_fetch_assoc ($q);
$pages = $r [' count '];
$offset = ($_get[' page '] > 0 && $_get[' page '] <= $pages)? ($_get[' page ']-1) * 20:0;
for ($i = 1; $i <= $pages; $i + +) {
$class = ($_get[' page '] = = $i | | $i = = 1 &&!$_get[' page '])? ' class= ': ' class= ' "page";
?>
<a href= "page=<?php echo $i;?>" <?php echo $class; >><?php echo $i;?></a>
<?php
}
?>
<BR clear= "All"/>
<table width= "100%" >
<tr class= "Head" >
<TD class= "One" >id</td>
<TD class= "Two" >filename</td>
<TD class= "three" >action</td>
</tr>
<?php
$sql = "Select * from ' uploads ' ORDER by ' ID ' desc limit $offset, 20";
$q = mysql_query ($sql);
while ($r = Mysql_fetch_assoc ($q)) {
?>
<TR class= "Item" >
<TD class= "One" ><?php Echo number_format ($r [' id ']);?></td>
<TD class= "Two" ><?php echo $r [' file '];?></td>
<TD class= "three" ><a href= "/<?php echo $r [' file '];?>" target= "_blank" ">view</a>, <a href="? delete=<?php echo $r [' id '];?> "onclick=" return confirm (' Are your sure you want to delete &quot;<?php echo $r [ ' file ']; >&quot;? '); >delete</a></td>
</tr>
<?php
}
?>
</table>
</body>
</html> Css??
HTML, Body {
Font-family:sans-serif;
font-size:12px;
width:800px;
margin:40px Auto;
}
A
Color: #105cb6;
Text-decoration:none;
}
H1 {
margin:0px 0px 10px 0px;
}
H1 a {
-moz-outline-width:0px;
}
H1 a img {
border:0px;
}
h3 {
margin:4px;
}
a:hover {
Text-decoration:underline;
}
#menu {
Background-color: #e5f5ff;
padding:8px;
border:1px solid #0099ff;
position:relative;
}
#menu a {
Font-weight:bold;
margin:0px 8px 0px 0px;
}
#menu A:hover {
Text-decoration:underline;
}
#menu. Right {
margin:0px;
padding:0px;
Position:absolute;
top:4px;
right:4px;
}
#menu. Input {
Background-color: #ffffff;
padding:2px;
border:1px solid #0066ff;
}
#menu. button {
Font-family:sans-serif;
padding:2px;
Cursor:pointer;
}
#menu Label {
Cursor:pointer;
}
#ads {
Background-color: #fde5f3;
MARGIN:8PX 0px;
border:1px solid #ec008c;
}
#recent {
Background-color: #e6fec9;
MARGIN:8PX 0px;
padding:2px;
border:1px solid #9dca68;
}
#main {
Background-color: #fffee5;
padding:8px;
border:1px solid #fff200;
}
#main H2 {
font-size:16px;
Color: #222222;
margin:0px;
}
#main Form {
MARGIN:4PX 8px;
}
#main Label {
Cursor:pointer;
}
#main. button {
Font-family:sans-serif;
margin:2px 0px 0px 0px;
padding:2px;
Cursor:pointer;
}
#main. Right {
font-size:14px;
Float:right;
padding:0px 0px 2px 0px;
border-bottom:1px solid #444444;
}
#main Div {
MARGIN:4PX 8px;
}
#main Div Label {
Font-weight:bold;
}
#main Div Input {
Font-family:sans-serif;
font-size:12px;
width:680px;
padding:2px;
margin:2px 0px 4px 4px;
}
#main Div Li {
margin-bottom:8px;
}
#links {
Background-color: #e9e8e8;
margin:8px 0px 0px 0px;
PADDING:4PX 0px;
border:1px solid #231f20;
}
. spacer {
height:4px;
Overflow:hidden;
} #slider { Color: #ffffff; Background-color: #232323; height:400px; margin:10px; padding:5px; border:1px solid #121212; } #slider H3 { Color: #ffffff; font-size:14px; line-height:20px; Background-color: #343434; height:20px; margin: -5px-5px 15px-5px; padding:5px; } #slider #slide #image { max-height:350px; } |