Jessica
Staff Alumni-
Posts
8,968 -
Joined
-
Last visited
-
Days Won
41
Everything posted by Jessica
-
How to check to see if a file exists on a SERVER
Jessica replied to mazman13's topic in PHP Coding Help
A server is a computer. What is the problem? Post your code and any errors, etc. It's likely you have the path wrong or something. -
that means you have a missing } somewhere. Line up your brackets.
-
<th> is a table header. HTML is a vast language, I'm sure there are many things you might not recognize - like fieldset and legend.
-
echo date("M d, Y", time()-(60*60*6));
-
Set the upload_max_filesize to something higher.
-
the line before it needs a ; to end it.
-
Are you sure it's the file type, and not size that is the problem? Perhaps the files are too big.
-
Or: echo '<table border='5'> <tr> <th>Picture</th> <th><a href="results.php?sort=1">Price</a></th> <th><a href="results.php?sort=2">Baths</a></th> <th><a href="results.php?sort=3">Bedrooms</a></th> <th>State</th> <th>City</th> <th><a href="results.php?sort=4">Square Feet</a></th> </tr>'; If you want to use a " inside of a string, you need to either mark the string with ' or escape them like Fert said. Same for ' and \'.
-
$string = substr($str, 0, strpos($str, $chr));
-
Seconding wordpress - I use it for my blog and other things. If you use MediaTemple it's a one click install - otherwise you install it yourself, but it's very easy.
-
"Are you sure there's no simple way to redirect www.mysite.com/username to www.mysite.com/userpage.php?id=$userid" mod_rewrite IS the simple way. That's exactly what it's for!
-
i thought everything was done in the httpd.conf file??? No, it's done in the htaccess file.
-
Did you try using mod_rewrite? It might already be enabled...move on to the next step in the article, or call your host.
-
Put each story in an array, and use array_unique
-
[SOLVED] echo problem with double quotes " "
Jessica replied to sebastiaandraaisma's topic in PHP Coding Help
echo '<tr> <td><span class="style3"> Local time in '.$time.'</span> </td> </tr>' or echo "<tr> <td><span class=\"style3\"> Local time in $time</span> </td> </tr>" -
You never define $file.
-
Finish it? I don't count enough closing } for the opening {. If that was all the code you got, I guess I counted wrong. The code is very inconsistently written.
-
I think you're missing some of it. I changed what was applicable, but like I said, I think the end is missing some code. Try this, and add what was missing if it was, etc. <? include "config.php"; if (!isset($_FILES['userfile'])) exit; if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { if ($_FILES['userfile']['size']>$max_size) { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">File is too big !</font><br>\n"; exit; } if(($_FILES['userfile']['type']=="image/gif") || ($_FILES['userfile']['type']=="image/pjpeg") || ($_FILES['userfile']['type']=="image/jpeg") || ($_FILES['userfile']['type']=="image/png") || ($_FILES['userfile']['type'] == 'image/x-photoshop') || ($_FILES['userfile']['type'] == 'application/photoshop')){ if (file_exists("./".$path . $_FILES['userfile']['name'])) { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">There already exists a file with this name, please rename your file and try again</font><br>\n"; exit; } //generate random number $zufall = rand(1,9999); $fupl = "$zufall"; $res = copy($_FILES['userfile']['tmp_name'], "./".$path .$fupl .$_FILES['userfile']['name']); if (!$res) { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">Didn't work, please try again</font><br>\n"; exit; } else { ?> <br> <? //set url variable $domst = ""; $drecks = "/"; $imgf = $fupl.$_FILES['userfile']['name']; $thbf = $tpath.$imgf; $urlf = $domst .$domain .$drecks .$path .$imgf; //create thumbnails function createthumb($name,$filename,$new_w,$new_h){ $system=explode('.',$name); if (preg_match('/jpg|jpeg|JPG/',$system[1])){ $src_img=imagecreatefromjpeg($name); } if (preg_match('/png|PNG/',$system[1])){ $src_img=imagecreatefrompng($name); } if (preg_match('/gif|GIF/',$system[1])){ $src_img=imagecreatefromgif($name); } $old_x=imageSX($src_img); $old_y=imageSY($src_img); if ($old_x > $old_y) { $thumb_w=$new_w; $thumb_h=$old_y*($new_h/$old_x); } if ($old_x < $old_y) { $thumb_w=$old_x*($new_w/$old_y); $thumb_h=$new_h; } if ($old_x == $old_y) { $thumb_w=$new_w; $thumb_h=$new_h; } $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); if (preg_match("/png/",$system[1])){ imagepng($dst_img,$filename); } if (preg_match("/gif/",$system[1])){ imagegif($dst_img,$filename); }else { imagejpeg($dst_img,$filename); } imagedestroy($dst_img); imagedestroy($src_img); } if(($_FILES['userfile']['type'] == 'image/x-photoshop') || ($_FILES['userfile']['type'] == 'application/photoshop')){ //No thumbnail }else{ createthumb($path.$imgf,$tpath.$imgf,$tsize,$tsize); } ?> <body bgcolor="#ffffff"> <center> <div class="support" id="agreement"> <table border='0' > <link rel="STYLESHEET" type="text/css" href="style.css"> <FORM action="nowhere" method="post"><title>iMage-Net</title> <center><? include "ads.php"; ?> <tr><td>URL:</td><td><input type="text" name="thetext" size="60" value='<? echo $domst .$domain .$drecks ?>viewer.php?id=<? echo $imgf; ?>'></td></tr> <tr><td>DIRECT URL:</td><td><input type="text" name="thetext" size="60" value="<? echo $urlf; ?>"></td></tr> <tr><td>HTML:</td><td><input type="text" name="thetext" size="60" value="<a href='<? echo $domst .$domain .$drecks; ?>viewer.php?id=<? echo $imgf; ?>'><img src='<? echo $domst.$domain.$drecks.$tpath.$imgf; ?>'></a>"></td></tr> <tr><td>BBCode:</td><td><input type="text" name="thetext" size="60" value="[url=<? echo $domst .$domain .$drecks; ?>viewer.php?id=<? echo $imgf; ?>][img=<? echo $domst.$domain.$drecks.$tpath.$imgf; ?>][/url]"></td></tr> <tr><td>IMAGE:</td><td> <img src='<? echo $thbf ?>'> </td></br><a href="javascript:history.go(-1);" title="go back to previous page">Back</a> </div></tr></td></tr> <? } } else { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\"><link rel='stylesheet' href='style.css' type='text/css'><div class='support' id='agreement'><p><center>You selected a wrong filetype!</font></center></div><br>\n"; exit; } } ?> </table> <br><br> </body>
-
Change HTTP_POST_FILES to just FILES, for one. Secondly, a psd is not an image, so PHP won't be able to create a thumbnail of it. It's a very complex file, not an image. On Preview: The GD Library is how PHP manipulates Images. The script could be modified to allow people to upload and host psd files, but not to create image previews (AFAIK.)
-
Google for Cross site scripting and XSS. You'll need to use things like strip_tags(), htmlentities(), etc. There are some good articles on how to stop it. Basically, sanitize ALL user input ALWAYS.
-
mod_rewrite is really the best solution for what you want to do. Here is a great article: http://www.sitepoint.com/article/guide-url-rewriting
-
Are you sure? It's in the users table? Are you connecting to the right database, etc?
-
You could write a game in PHP, I've done it a few times. You could use any web language, other good ones might be RoR or Java. If you want to make desktop software rather than a browser-based game, you'll want to use a language such as Java, C++