Jump to content

puritania

Members
  • Posts

    37
  • Joined

  • Last visited

    Never

Everything posted by puritania

  1. I didn't post any example of DI. I just made an example for a good and clean OOP. To understand why this is important, you should read the following article: PDF If you have any questions after reading it, i can show you an example with my classes in my post above.
  2. Is that the only problem? You have all the html output in your variable $result. So just have to add <base href="http://www.example.domain.com/"> in the head area of the output.
  3. The problem seems to be the page is still signup.php rather than the URL specified in $url That's right yes. I really don't know if this page on the other server is that strict that it doesn't work properly. The only other way you could do is an autosubmitting form with hiddenfields, only then changes the url and the method is POST. The problem is that you can't do a POST request with header("Location: ...
  4. I just said that you should never use a plain <?php echo $_SERVER['PHP_SELF']; ?> in a form action. That's all.
  5. Just have a quick look at the php frameworks with mvc support. (Zend, Flow3, etc.)
  6. You didn't say anything about writing into mysql. To write a string properly in a database you have to do the following: $str = 'This is " a test with \' Quotes'; mysql_query("INSERT INTO `table` SET `column` = '" . mysql_real_escape_string($str) . "'");
  7. Google for "function postToHost"
  8. Dependency Injection, i already said that in the post above.
  9. Static methods are here for processes that don't depend on the object, but still have to be in the class. Example: class TextWriter { private $text; public function __construct($text) { $this->text = (string) $text; } public function write() { file_put_contents('bla.txt', self::formatText($this->text)); } private static function formatText($str) { return trim($str); } }
  10. Is the link is in the flash movie (as html-text) ?
  11. The only way to solve this problem is to define a good interface for Databases. For example: interface DB { public function query($query); public function fetch($res); // ... } class IAmUsingADatabase { private $db; public function __construct(DB $db) { $this->db = $db; } } So your classes are only using the methods of the interface. Now, if you want to use another database class that goes like this: class 3rdPartyDBClass { public function execute($query) { // ... } public function fetchAssoc($res) { // ... } } Extend it like this: class MyDB extends 3rdPartyDBClass implements DB { public function query($query) { parent::execute($query); } public function fetch($res) { parent::fetchAssoc($res); } } I hope this helps. (And again: Registries are ugly, DI's are much better, see post above.)
  12. And for those who really want to make the components re-usable, use the dependency injenction pattern instead of the registry. global stuff like singletons and registries aren't really better than a simple function x() { global $x; } They just look better
  13. Why do you have these objects? It looks like a broken concept. You can only search in objects by foreach-ing them and compare their values.
  14. i don't know if you really know what xss (cross site scripting) is, but you should make everything to avoid it. You should !!!really!!! always use $_SERVER['SCRIPT_NAME'] instead of $_SERVER['PHP_SELF'] or write it as a plain text when using forms. Please... if you really need or want to clear the $_POST Variable you can use $_POST = array(); and that's it. Regarding the header-stuff: Why don't you do it like this: <?php ... if(!empty($_POST['paragraph'])) { $output = null; foreach($_POST['paragraph'] as $data) { $title = $data['title']; $content = $data['content']; $output .= "[$title]\n$content\n"; } file_put_contents('data.txt', $output); } ?> <form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post"> <table border="0" cellpadding="5" cellspacing="1"> <tr> <th colspan="2"><h1>Paragraph Editor</h1></th> </tr> <tr> <th width="150">Title</th> <th>Content</th> </tr> <?php $i = 0; foreach(get_paragraphs() as $key => $data) { echo " <tr valign=\"top\">\n <td><input type=\"text\" name=\"paragraph[$i][title]\" value=\"$key\"></td>\n ". "<td><textarea name=\"paragraph[$i][content]\" cols=\"60\" rows=\"6\">$data</textarea></td>\n </tr>\n"; $i++; } ?> <tr> <td colspan="2"><input type="submit" name="submit" value="Apply Changes" /></td> </tr> </table> </form> As you can see, the header location is totally useless. Note: a header location to the same domain is useless in 99.9%. 2 other things: Don't check the submit button, check the data. Some browsers don't submit the button's value. And to save the data in text file with your scheme [] isn't really elegant. you should use xml or a database or if you want to keep it simple a serialized array. by the way, i see that you're using the eregi functions, these are old... you should use preg_match and co. Sorry about the Objections, but i had to say it (although if you are a Genius Super Moderator )
  15. str_replace('\\', ' ', $yourStr);
  16. Yes. It automatically escapes it when saving content into variables.
  17. Why do you make a header Location? Very ugly! And the form action ... uuuhh, what about XSS? Uglier than ugly...
  18. you should really use arrays. But have a look at variable variables $variableName = 'test'; echo ${$variableName}; // ouputs the content of $test
  19. puritania

    Adobe AIR

    i'm working with the beta flex3 and air. it's really cool.
  20. Sorry, where is that? When a place my mouse over a video, nothing happens. Can you post a link?
  21. no it appends it at the ed of the file. if you don't want that, you have to read the file first with file_get_contents, add the new content at the position you want and overwrite the file.
  22. browsers are looking for a new version of the content by default, if there isn't set any expiring date. if they weren't modified, the server says HTTP/1.1 304 Not Modified. this request takes time, because they'll be executed after parsing the whole html stuff, cause they need to find all the images, css and stuff. So if you have a lot of images in your layout and they don't change recently, you can try the following .htaccess: ExpiresActive On <FilesMatch "\.(ico|gif|jpg|jpeg|png|flv|pdf|swf|mov|mp3|wmv|ppt)$"> ExpiresDefault A2592000 Header append Cache-Control "public" </FilesMatch> this makes the following: it saves all these files in your browser cache for 1 week (expiresdefault) and loads them before the browser makes a server request to check if they were modified or not. this can really speed up a site. You can compress your css and js scripts by removing all the whitespaces and stuff. I hope, this could help... PS: Google for Yslow
  23. That is not possible with HTML, JS and PHP.
×
×
  • 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.