Jump to content

oni-kun

Members
  • Posts

    1,984
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by oni-kun

  1. It's a good idea to place that header at first where needed, but usually servers will default to it. The <head>'s meta tag will be most important in the roll of encoding, since your browser will read that , and essentially apply that or default encoding to everything on the web page. JS headers and encoding is not needed.
  2. It's a good general idea to keep everything encoded in the same encoding such as UTF-8. Your PHP may automatically use UTF-8 but your AJAX chat may use ISO-8859-1, and so when UTF ->ISO-8859-1 = mojimbake, aka those weird symbols. Your chat will recieve UTF-8 from the server, send UTF-8 in a UTF environment, as you can see all the bases are set and it should be correct, as long as the file is encoded with UTF, it should not need to be parsed afterwards.
  3. You may want to set the server encoding: header('Content-Type:text/html; charset=UTF-8'); Make sure in your <head> you define the page as UTF-8. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> In your PHP code when you get and set text, make sure you use things such as iconv or utf8_encode() to make sure they're all the same encoding. This should fix 99% of your problems.
  4. Well, that seems a bit excessive. Note you can use 'eval()' to parse PHP from a string or text or file. $message = 'Hey!'; //Dynamic element $template = 'require("header.php"); echo '.$message.'; require("footer.php");'; eval($template); $template = '<?php'.$template.'?>'; //write new template.. $fp = fopen('newtemplate.php', 'w'); fwrite($fp, $template); fclose($fp);
  5. Some multi-line tags may accidentally pass through, may be a bug.. you should do something such as this. $htmlstring = preg_replace("'<embed[^>]*>.*</embed>'siU",'',$htmlstring); All in all that suggestion to 'brute-force' alike characters is all you can do, you may want to use a match multiple characters such as 'daaaamn' etc: $content = "grrrrrrrrrrr arggggg loooool shiiiiiit"; $pattern = '{([a-zA-Z])\1+}'; $replacement = '$1$1'; $filtered = preg_replace($pattern, $replacement, $content); Another suggestion is to use 'iconv' to strip out characters such as 'ú' to be filtered into 'u' beforehand, so 'fú*k' can't pass through unfiltered.
  6. No problem! Remember to mark this topic as solved.
  7. It seems he has it linked, but yes it is wise to do it directly for debugging such as this. target="_self" Could that be the problem? It might be submitting the second time, into the wrong place, I can't see anything that would otherwise muck up subsequent submits..
  8. Please, explain your application and what you want to do with it, I'm profoundly unaware of what you exactly want. If you're wanting to submit the url that is in $_GET['urls'], then DONT use the form. Use PHP to submit it. if (isset($_GET['urls'])) { // Check if 'urls' exists in address $url = htmlspecialchars(escape($_GET['urls'])); //urls=http://www.example.com/ mysql_query(UPDATE Tables bla bla $url); //Use the $_GET['urls'] and ignore form echo 'Thank you for updating!'; // Result, no need for an 'auto-submit' } else { $url = htmlspecialchars(escape($_POST['urls'])); //If there is no GET, This is what the user submits from the form. mysql_query(UPDATE Tables bla bla $url); //Use the $_POST['urls'] and use form echo "Your submit was complete. Thank you for updating!"; } I don't get why you want it to 'auto-submit'.. submitting is for the user to enter something into the box and send to the php form..if you're wanting to submit what the GET url is, then the form isn't needed. You can skip the form, and update it directly like the code I just showed..
  9. You need to add the code for the GET to do anything.. <?php //If FORM was sent if (!isset($_GET['urls']) && isset($_POST['urls'])) { //DoSomething with $_POST[]'s variable here } elseif (isset($_GET['urls'])) { $urls = $_GET['urls']; echo $urls; //use the same code you use for $_POST['urls'].. } else { //Nothing submitted. } ?> <form action='<?php echo $_SERVER['PHP_SELF']; ?>' method="post"> <p align="center">[b]<textarea rows="10" cols="50" name="urls"></textarea>[/b]<br /></p> <p align="center">Display: <input type="checkbox" value="d" name="d" /> Mask: <input type ="checkbox" value ="1" name="go" /><br /></p> <p align="center"><input type="submit" name="submit" /> </p> </form> Submitting it is the equivilent of a GET, just not visible in the url. It works.
  10. <?php //If FORM was sent if (!isset($_GET['urls']) && isset($_POST['urls'])) { //DoSomething with $_POST[]'s variable here } elseif (isset($_GET['urls'])) { //DoSomething with $_GET[]'s variable here } else { //Nothing submitted. } ?> <form action='<?php echo $_SERVER['PHP_SELF']; ?>' method="post"> <p align="center">[b]<textarea rows="10" cols="50" name="urls"></textarea>[/b]<br /></p> <p align="center">Display: <input type="checkbox" value="d" name="d" /> Mask: <input type ="checkbox" value ="1" name="go" /><br /></p> <p align="center"><input type="submit" name="submit" /> </p> </form> Works fine.
  11. oni-kun

    md5

    Messy code.. $query="UPDATE ".TBL_USERS." SET userlevel = 1 WHERE username = '$user'"; if (md5($user) == $_GET['act']){ mysql_query($query); }
  12. Yes, then my code is what you should use. It checks to make sure.. if the '?urls=' isn't used, then the form must be. Or if the '?urls=http://www.site.com' then it bypasses the form and does whatever you wish it to.
  13. I'm really not sure what you're trying to do. But lets break it down to what I know.. <?php //If FORM was sent if (!isset($_GET['urls']) && isset($_POST['urls'])) { echo "URLS is $_POST['urls']" ; } else { echo "URLS is set through GET: $_GET['urls']"; } What is important about it being passed through the form? The above code will get it if the user .. A) Uses the form, or B) Arrives through a $_GET[] url.. everything can be handled through php.
  14. I'm not sure your code is right... 'But I tested this code and it works flawlessly, try to create your function again out of this code.. <?php // File and new size $filename = 'test.jpg'; $percent = 0.5; // Content type header('Content-type: image/jpeg'); // Get new sizes list($width, $height) = getimagesize($filename); $newwidth = $width * $percent; $newheight = $height * $percent; // Load $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($filename); // Resize imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // Output imagejpeg($thumb); ?>
  15. You mean like this? <textarea rows="10" cols="50" name="urls"><?php echo $_GET['urls']; ?></textarea> I don't believe you can fill it in and submit it, atleast not with PHP. You'll need JS to submit the form onLoad().. Why do you need that form to be filled and sent with $_GET[]? You can just handle whatever the form does directly via PHP.
  16. Seems you have a simple solution to this. <?php $str = "A 'quote' is <b>bold</b>"; // Outputs: A 'quote' is <b>bold</b> echo htmlentities($str); // Outputs: A &#039;quote&#039; is <b>bold</b> echo htmlentities($str, ENT_QUOTES); ?> Htmlentities can also support encoding.. ($str, ENT_QUOTES, 'UTF-8').. More here: http://us2.php.net/manual/en/function.htmlentities.php htmlspecialchars is more simple but doesn't HTML encode everything, which in your case may not be as wise.
  17. If you use the GET, it wouldn't submit the form but go straight to the PHP code.. Something like this.. if (isset($_GET['urls'])) { //Redirect to URLS header('Location: '. $_GET['urls']); //Or do anything else.. display result etc. //echo 'URLS = ' . $_GET['urls']; } That means, if the url=http://www.site.com is filled, then it'll go to site.com or whichever function you wished for it to do..
  18. There is no way to do this without Flash or AJAX. Note AJAX works well with PHP, and for example if you use JS to hand the .. onChange on those value boxes, it'll call the GD library and update the page without refreshing it. It shouldn't be too hard to implement, more work than difficult for this step.
  19. Use something such as this instead to ensure the user is prompted with a download on a file.. <?php header('Content-type: application/zip'); // It will be called downloaded.zip.. if needed. header('Content-Disposition: attachment; filename="downloaded.zip"'); // Source of original file.. readfile('./files/user/original324_3423.zip'); ?>
  20. $d_uk = (isset($_POST['uk'])) ? 'uk' : ''; Nothing says you need to have co.uk variable.. Then you gotta add the .co.uk whois server.. find it online. if (($d_uk != '') || ($d_all != '') ) showDomainResult($domainbase.'.co.uk','whois.something.tld','NOT FOUND');
  21. Make sure it's 'co.uk' not "co.uk", Note you will also have to define the WHOIS server for the .co.uk domain.. around here: if (($d_com != '') || ($d_all != '') ) showDomainResult($domainbase.".com",'whois.crsnic.net','No match for'); if (($d_net != '') || ($d_all != '') ) showDomainResult($domainbase.".net",'whois.crsnic.net','No match for'); if (($d_org != '') || ($d_all != '') ) showDomainResult($domainbase.".org",'whois.publicinterestregistry.net','NOT FOUND'); if (($d_info != '') || ($d_all != '') ) showDomainResult($domainbase.".info",'whois.afilias.net','NOT FOUND'); // Create entry for '.co.uk', in single quotes, and define the whois.{whoisserver}.com
  22. Well, what you should do is this. If your PHP is within the same page.. <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> Or.. <form name="form" method="post" action="process.php"> This makes it so the FORM's Submit button actually sends a POST to.. process.php or $_POST['form']; variable in your PHP code..
  23. It seems you want the form to retrieve data from config.inc.php and display it on the forms to edit? <input type="text" name="site_title" size="25" value="<?=$title;?>"> $title will be whatever was the variable in config.inc.php.. So it'd show.. Form: [My site!], instead of blank.
  24. Something like this you can do.. function objectArray( $object ) { if ( is_array( $object )) return $object ; if ( !is_object( $object )) return false ; $serial = serialize( $object ) ; $serial = preg_replace( '/O:\d+:".+?"/' ,'a' , $serial ) ; if( preg_match_all( '/s:\d+:"\\0.+?\\0(.+?)"/' , $serial, $ms, PREG_SET_ORDER )) { foreach( $ms as $m ) { $serial = str_replace( $m[0], 's:'. strlen( $m[1] ) . ':"'.$m[1] . '"', $serial ) ; } } return @unserialize( $serial ) ; } class SampleObject{ public $var1; private $var2; protected $var3; static $var4; public function __construct(){ $this->var1 = "Value One"; $this->var2 = "Value Two"; $this->var3 = "Value Three"; SampleObject::$var4 = "Value Four"; } } $so = new SampleObject(); file_put_contents("wordtocount.txt",$so); echo "<pre>"; print_r( objectArray( $so )) ; echo "<br/>"; print_r(json_encode(objectArray($so))); And those will output.. Array: Array ( [var1] => Value One [var2] => Value Two [var3] => Value Three ) JSON (Compact): {"var1":"Value One","var2":"Value Two","var3":"Value Three"}
  25. If you don't need to put it into a database, I'd recommend you use json_encode() for it is much more what you'd use without needing to set it into a special array, json_decode would place the file contents into an array after. http://ca.php.net/json_encode
×
×
  • 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.