-
Posts
1,469 -
Joined
-
Last visited
-
Days Won
12
Everything posted by CroNiX
-
PHP & MySQL - Not Inserting Rows when within Foreach loop
CroNiX replied to johnslater's topic in PHP Coding Help
That can also be adjusted in your mysql server settings. -
Zend Studio
-
Simple PHP question -- unsure of the exact name
CroNiX replied to careym1989's topic in PHP Coding Help
So some hacker fool can't get on your page and start entering in their own stuff into your url variables. Like 'http://www.yoursite.com?page=http://hackersite.com/evilscript.txt', which could execute the contents of evilscript.txt on your server doing whatever the script says. Since your script is telling PHP to open whatever file is in the url variable, thats what it will do. Thats just one example. Always screen/validate any input that the user can access, that mainly being your URL variables passed via POST/GET/COOKIE. -
There are also ajax history managers that allow you to use the browser back button properly and bookmark pages properly. http://digitarald.de/projects/history-manager/
-
Not too hard with google. Search "web+bot+list". Anyway, the above post is correct. There is no law that a bot has to report itself as a bot and if there was it would be ignored. This seems like a waste of your time to try to implement what you are trying to do. Actually, I have read that having a robots.txt is a bad idea because it shows some of your directory structure to unscrupulous people who look for exploits.
-
There are javascript solutions for this. They check the browser/version and if its an unsupported version of png w/alpha (like IE6) then it fixes them for that image. Search for 'PNGFIX'.
-
$login = isset($_POST['login') ? $_POST['login'] : ""; This code is how I set variables sent via url. First it checks if 'login' exists in the POST array, if it does it uses that value, if it doesn't it sets it to an empty string. Of course you should also ALWAYS sanitize variables that are sent through a URL as they can be manipulated by the sender and used for an injection attack.
-
AJAX. You could also try to refresh the iframe.
-
yes, its in my above post. Look at the very end of the code line. You need the </a>
-
The [/url] showed up because I didn't enclose it in code tags. Please note that it should have been an end to the anchor tag as seen below. To get rid of the underline for the link: <a href="bar1.jpg" style="text-decoration:none"><img src="bar1.jpg" /></a> or it would be much better to use it in a css using a class. The style info needs to be in the <head> of your document. <style="text/css"> .nolink { text-decoration:none; } </style> <a href="bar1.jpg" class="nolink"><img src="bar1.jpg" /></a> Yes you can change the color if you wanted. You can also do this using a style sheet. Please see http://www.w3schools.com/css/css_intro.asp for more info
-
<a href="largeimage.jpg"><img src="thumbnail.jpg" /></a>
-
Couldn't you also get the size of the original array, run an array_unique and compare the sizes? They should be the same if there are no duplicates. $a = array(1,2,2,3,4); $b = array_unique($a); if(sizeof($a) == sizeof($b)) { echo 'All values are unique'; } else { echo 'There are duplicate value(s)'; } I didn't try this, but I would think it would work.
-
Im a big fan of the mootools javascript framework. It would be overkill to only use it for image reflection ... but http://www.digitalia.be/software/reflectionjs-for-mootools
-
[SOLVED] Help with OOP and callback functions using xml_parse()
CroNiX replied to CroNiX's topic in PHP Coding Help
Done. Now, any critique on my newbie class code? -
[SOLVED] Help with OOP and callback functions using xml_parse()
CroNiX replied to CroNiX's topic in PHP Coding Help
yep man o man all the hours pouring over this and to fall for such a noobish error. Thanks DarkWater. -
Hello, I just joined because I am stuck. I have been programming in procedural php for several years and am attempting to learn oop. I have successfully converted several pieces of code to classes, but am really stuck on this one. I keep getting this error: First I will post the working procedural code followed by the problematic class. The methods within the class that the problem occurs are: readXML, startElement, endElement, and characterData. There could be other things wrong with how I am coding this and I appreciate any criticism as I want/need to learn this, but the main goal is to get the problematic methods working. Thanks in advance, -CroNiX working procedural code: <?php $x = parseme("test.xml"); function parseme($filename){ $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); $fp = fopen($filename,"r") or die("Error reading RSS data."); while ($data = fread($fp, 4096)) xml_parse($xml_parser, $data, feof($fp)) or die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); fclose($fp); xml_parser_free($xml_parser); } function startElement($parser, $tagName, $attrs) { global $insideitem, $tag; if ($insideitem) { $tag = $tagName; } elseif ($tagName == "ITEM") { $insideitem = true; } } function characterData($parser, $data) { global $insideitem, $tag, $title, $description, $link; if ($insideitem) { switch ($tag) { case "TITLE": $title .= $data; break; case "DESCRIPTION": $description .= $data; break; case "LINK": $link .= $data; break; } } } function endElement($parser, $tagName) { global $insideitem, $tag, $title, $description, $link; if ($tagName == "ITEM") { htmlspecialchars(printf("<p>%s</p>",trim($description)),ENT_COMPAT); $title = ""; $description = ""; $link = ""; $insideitem = false; } } ?> Problematic Class code: <?php class GalleryXML { public $xml_file = "gallery.xml"; //xml file name public $image_folder = "."; //image folder public $th_prefix = "th_"; //thumbnail prefix (to avoid trying to get exif from them) public $insideitem; public $tag; public $title; public $description; public $link; public $xml_parser; function __construct() { if(!function_exists('exif_read_data')) die('PHP is missing the EXIF extension.'); } function generateXML(){ if(file_exists($this->xml_file)) unlink($this->xml_file); $f = fopen($this->xml_file, "a"); if($f){ fputs($f,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<rss version=\"2.0\">"); fputs($f,"<gallerydata>"); $handle = opendir($this->image_folder); while (($file = readdir($handle)) !== false) { //filter out thumbnails and everything but jpegs if((preg_match("/jpg|jpeg/i", $file)) && (!preg_match("/^" . $this->th_prefix . "/i", $file))){ $exif_array = @exif_read_data($file); $title = isset($exif_array['Title']) ? $exif_array['Title'] : "" ; $im_dir = $this->image_folder == "." ? "" : $this->image_folder . "/"; fputs($f,"<ITEM><DESCRIPTION>"); fputs($f,htmlentities("<a href=\"" . $im_dir . $file . "\" rel=\"lightbox\" title=\"$title\"><div class=\"horizontal\"><img src=\"" . $im_dir . $this->th_prefix . "$file\" alt=\"$title\" border=\"0\" /></div></a><div class=\"lightboxDesc\">$title</div>",ENT_COMPAT)); fputs($f,"</DESCRIPTION></ITEM>"); } } } fputs($f,"</gallerydata></rss>"); closedir($handle); fclose($f); } function readXML(){ $this->xml_parser = xml_parser_create(); xml_set_object($this->xml_parser, $this); xml_set_element_handler($this->xml_parser, "startElemnet", "endElement"); xml_set_character_data_handler($this->xml_parser, "characterData"); $fp = fopen($this->xml_file,"r") or die("Error reading RSS data."); while ($data = fread($fp, 4096)) xml_parse($this->xml_parser, $data, feof($fp)) // Handle errors in parsing or die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->xml_parser)), xml_get_current_line_number($this->xml_parser))); fclose($fp); xml_parser_free($this->xml_parser); } function startElement($parser, $tagName, $attrs) { if ($this->insideitem) { $this->tag = $tagName; } elseif ($tagName == "ITEM") { $this->insideitem = true; } } function endElement($parser, $tagName) { if ($tagName == "ITEM") { htmlspecialchars(printf("<p>%s</p>",trim($this->description)),ENT_COMPAT); $this->title = ""; $this->description = ""; $this->link = ""; $this->insideitem = false; } } function characterData($parser, $data) { if ($this->insideitem) { switch ($this->tag) { case "TITLE": $this->title .= $data; break; case "DESCRIPTION": $this->description .= $data; break; case "LINK": $this->link .= $data; break; } } } /** * @return string */ public function getImage_folder() { return $this->image_folder; } /** * @return string */ public function getTh_prefix() { return $this->th_prefix; } /** * @return string */ public function getXml_file() { return $this->xml_file; } /** * @param string $image_folder */ public function setImage_folder($image_folder) { $this->image_folder = $image_folder; } /** * @param string $th_prefix */ public function setTh_prefix($th_prefix) { $this->th_prefix = $th_prefix; } /** * @param string $xml_file */ public function setXml_file($xml_file) { $this->xml_file = $xml_file; } } $im= new GalleryXML(); $im->setXml_file("test.xml"); //$im->generateXML(); $im->readXML(); ?>