Jump to content

MadTechie

Staff Alumni
  • Posts

    9,409
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by MadTechie

  1. Which is easier than using a substr also sasa code should be $x = explode('/', $url); not $x = ekplode('/', $url);
  2. basically you use strrpos and substr ie <?php $path = "../../images/aprilfoolcards/lovefoolsday.gif"; $cat = substr($path, 13, strrpos($path,"/", 13)-13); echo $cat; ?> untested EDIT updated: made a pigs ear of that!
  3. no, I just used the same code on post#2 as you posted. where do i need to update this code? $Page = (int)(!empty($_GET['page']))?$_GET['page']:1; ? Replace the first $Page with the code above No worries your doing great, is it correct? Yep very correct.. i missed that (was untested),
  4. Okay, the script is creating the png file (in its raw format) and what your doing is the same as opening the png file in a text editor and dumping it contents in a HTML page, this fails (as your seeing) To solved this you need to make the php appear as a png file.. to do this you use header() which you seam to be doing.. BUT what you need to do is call that php script as it is was a image So if my php script is called "createPNG.php" you put this in your HTML output like this <img src="createPNG.php"> So simply put create a file that is only used outputting the PNG raw data with the header set and then call that VIA the html file.. if thats confused you then please post what you have
  5. No.. it will not "cause" it, clicking the submit button does! 1. display form 2. submit form (file get uploaded here) 3. the form tiggers the (php) script in actions. So by the time the php has started the file is already in temp!
  6. No its not the same problem he has "Connection refused" this means the script found the server but was denied access (port blocked or something along those lines) you problem is your php took too long to connect this is why i got you to increase timeout to 15.. Lets create a smaller script and try to get it to connect.. at let try to find out why theirs a problem! First turn off any firewall you may have a test, (remember to turn the firewall on after the tests) if you old script still fails then try this. (this script is only for getting exta info) <?php error_reporting(E_ALL); // Use cURL to get the RSS feed into a PHP string variable. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,'http://www.dpreview.com/feeds/news.xml'); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 20); $xml = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); echo "<br>------------------------------<br>"; echo "<pre>";var_dump($info);echo "</pre>"; echo "<br>------------------------------<br>"; die($xml); try that script in a new file and pass back the output!
  7. when you upload a file, if it fits in the limts set in php.ini (ie max_filesize etc) then the file goes to tmp,, this happens before your script starts ie 1. Form is submitted 2. files are uploaded 3. action script is tiggered 4. action script does the move from $_FILES['var']['tmp_name'] to path you choose So before you make the move you check to see if the uploaded file has a tmp name ($_FILES['var']['tmp_name']), if not then the file wasn't uploaded, of couse you can also check the error ie if($_FILES['var']['error'] == 0) { # upload is fine } i hope that helps!
  8. did you update the code for the page ? ie $Page = (int)(!empty($_GET['page']))?$_GET['page']:1;
  9. I was asking if you had them on.. try turning them off..
  10. if your using $_GET then just do a help like for "?Page=".($Page-1) and "?Page=".($Page+1) for previous and next if you want a full page number list then just create loop from 1 to $totalPages with a simple echo "<a href='?page=".$n."' >$n</a>";
  11. Could be a firewall, do you have safe mode enabled , or open_basedir applied ? to be truth this isn't really a coding question anymore!
  12. your do it something like this <?php $Page = 1; $Entries = 30; // Open log file $logfile = "log.db"; if (file_exists($logfile)) { #$handle = fopen($logfile, "r"); #$log = fread($handle, filesize($logfile)); #fclose($handle); $fulllog = file($logfile); } else { die ("The log file doesn't exist!"); } // Seperate each logline #$log = explode("\n", trim($log)); // After that it may be useful to get each part of each logline in a separate variable. // This can be done by looping through each logline, and using explode again: $totalPages = ceil(count($log)/$Entries); $end = $Entries*$Page; $start = $end-$Entries; // Seperate each part in each logline $log = array(); for ($i = $start; $i < ($end); $i++) { $log[$i] = trim($fulllog[$i]); $log[$i] = explode('|', $fulllog[$i]); } echo "<p>Total Entries : " . count($fulllog) . "</p>"; // Show a table of the logfile //rest of your code
  13. use the function file_exists() <?php $file = '../images/image_1.jpg'; if(file_exists($file)) { echo "<img src='$file'>"; }else{ echo "<img src='no_image.jpg'>"; } ?>
  14. echo "from PHP $Monkeh said"; so your code should look something like this <?php $query = "SELECT * FROM `cards`"; $result = mysql_query($query) or die (mysql_error()); if (mysql_num_rows($result)>0) { echo'<select name = "cards">'; while ($row = mysql_fetch_array($result)) { $cid=$row[0]; $hid=$row[1]; $cards=$row[2]; echo "<option value=\"$cid\">$cards</option>\n"; } echo'</select>'; } ?>
  15. Code is fine the problem is with your Server and/or Configuration i tested it on my local PC, I assume you rebooted..and i assume the code your testing is the same as you posted! (except moving the last preg_replace into the make_safe function)
  16. why? uploads what?
  17. Okay well $xml is empty.. try these inorder (test after each one) #1 reboot apache and retest #2 increase the timeout Add curl_setopt($ch, CURLOPT_TIMEOUT, 15); after curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); #3 Add error reporting Add error_reporting(E_ALL); , to the start of the page (after the <?php)
  18. Please read this thread again! i have no idea why you added "file_get_contents" back in!
  19. by the sounds of thing you just want to check its valid!.. but also you want to extract details! telling me its changes and need to be a wildcard (i know what wildcard is thus if it changes i know its going to be a wildcard) With all that in-mind i'll have to assume you want parent:' to ' sprintf(LANG.lvnote_createafilter, ' to ') data: to ; i'll also assume the order is the seam each time! in that case try <?php preg_match('/parent:\s*\'([^\']*)\'.*?sprintf\(LANG.lvnote_createafilter, \'([^\']*)\'\).*?data: ([^;]*);/si', $Contents, $Matches) $parent= $Matches[1]; $createafilter= $Matches[2]; $data= $Matches[3]; } ?>
  20. Nope infact as 'element_set' isn't a php function i googled 'xml_regex.php' and found the site http://www.bobulous.org.uk/coding/php-xml-feeds.html this stats this means use one or the other! the reason for that use due to this line // Create an array of item elements from the XML feed. $news_items = element_set('item', $xml); its not creating an array try changing $xml = curl_exec($ch); curl_close($ch); to $xml = curl_exec($ch); curl_close($ch); die($xml);//added for debugging and see if your getting the sites RSS details!
  21. Your need to give an example as i'm not sure what you mean!
  22. that suggests that imagecreatefromXXX isn't working.. thus checking to see if the file exists would be my first step.. do you have error_reporting on ?
  23. Sorry i'm a little confused.. what are you trying to check for ? maybe a few examples and bolding the thing you need to check for.. are you trying to get the data between "data: " and the ";" ? if so try this preg_match_all('/data: ([^;]*);/s', $Contents, $Matches, PREG_PATTERN_ORDER); $Matches= $Matches[1]; echo "<pre>"; var_dump($Matches);
  24. As a guess.. (as it looks okay try this) <?php //add at the start. $uploadedPictExt = strtolower($uploadedPictExt); if(!file_exists("../photos/" . $_POST["photo_name"] . $uploadedPictExt)) { die("Error: file not found"); } ?>
  25. Well that RegEx isn't even valid! "http/i" should atleast be "/http/i" it doesn nothing to protect against bcc's it check to see if http exists in the $variable, as which stripos would be quicker!.. heres a quick version that will probably work. basically it check for newlines content-type:, to:, cc:, bcc in the body and just newlines in the email and to fields <?php //check valid email if(!validemail($email)) { die("invalid email"); } //check name + email if(!(has_no_newlines($name) && has_no_newlines($email) && (has_no_emailheaders($body))) { die("Inject detected"); } function has_no_newlines($text) { return preg_match("/(%0A|%0D|\n+|\r+)/i", $text); } function has_no_emailheaders($text) { return preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i", $text); } function validemail($email) { return (preg_match("/^[A-Z0-9._%-]+@[A-Z0-9.-]+.[A-Z]{2,4}$/i",$email)) } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.