Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. Hmm... providing all the links are formatted like you posted earlier, then you can do something like this: <?php $data = <<<EOF <br><a href="http://site.com/layouts1.php?layoutpreview=Layout"><img src="img url"></a><br><hr> <br><a href="http://site.com/layouts1.php?layoutpreview=Layout"><img src="img url"></a><br><hr> <br><a href="http://site.com/layouts1.php?layoutpreview=Layout"><img src="img url"></a><br><hr> <br><a href="http://site.com/layouts1.php?layoutpreview=Layout"><img src="img url"></a><br><hr> <br><a href="http://site.com/layouts1.php?layoutpreview=Layout"><img src="img url"></a><br><hr> EOF; preg_match_all('`<br><a href="[^"]+"><img src="[^"]+"></a><br><hr>`mi', $data, $matches); $items = $matches[0]; $numItems = count($matches); $itemsPerPage = 2; $numPages = ceil($numItems / $itemsPerPage); // etc... ?> Obviously you'll need to edit it to fit your needs.
  2. In PHP 5.1+ PDO is included by default and on my VPS (Debian Etch), PDO was installed by default when I installed the package using APT. Furthermore, all functions that deal with database connectivity are located in extensions.
  3. That would probably be a bit trickier. You don't necessarily need a database for creating pagination (our pagination inside the tutorials on the main site doesn't). You will have to extract each item and count how many there are. When you've done that then you can perform the steps outlined in my previous post. Here is how our tutorial pagination works: $pages = explode('[PAGEBREAK]', $content->body); $pages = array_map('trim', $pages); $numPages = count($pages); if ($page < 1 || $page > $numPages) { throw new PHPFreaks_Exception('Page out of range.'); } $this->view->currentPage = $page; $this->view->numPages = $numPages; $this->view->currentPageBody = $pages[$page-1]; Page breaks are simply made by placing [PAGEBREAK] inside the body text of the tutorial.
  4. Do you want to display X images per page? Where do you get the information for those images? Basically, to create pagination you'll need to know three things: 1) The total number of items (we'll call it numItems) 2) The items that should be on each page (we'll call it itemsPerPage) 3) The requested page (defaults to 1) Then can say: numPages = numItems / itemsPerPage Then you can check if the requested page is out of range. If it's a valid page then you can get the items within that range. E.g. if you have 10 items per page and you have 100 items then you'll have 10 pages. Then you just select the relevant items and display them to the user. I hope that makes sense.
  5. There are a number of different headers you could use. For instance, if you would like it cached for one month then you could do Expires: Tue, 22 Jul 2008 20:42:40 GMT and Cache-Control: max-age=2592000; must-revalidate (one month being 30 days here). Furthermore, keeping Last-Modified accurate and sending an ETag will also help. An ETag is simply, well... a tag. It changes each time the file changes and the client can then check by sending the ETag in a If-None-Match request header. If the ETag matches then the server will send an HTTP 304 Not Modified response header and the browser will then use the cached version instead. If I remember correctly, then ETags where introduced in HTTP 1.1. A combination of the above might be the ideal solution.
  6. Depends on your browser settings and the headers sent by the server.
  7. That's the point of this forum (partially). The "hacking" process is for finding security vulnerabilities.
  8. Hmm... perhaps. I suppose I can change it if it's widespread opinion that and [code] should be distinctive.
  9. Well, it was requested and it had long annoyed me that it didn't use a mono-spaced font. Also, some people used that instead of the ones with large amounts of code. That took up a lot of vertical space.
  10. You can always see your topics and posts from your profile and you can click the "Show new replies to your posts" to check if there are any new replies in topics you've posted in.
  11. It has been requested that your post be split from the topic you posted it in.
  12. What do you mean with "reprogramming the mouse cursor"?
  13. SMF does by default have the php tags. The only thing it does is add syntax highlighting to it. I just modified the CSS to match the same styles as the regular code box has (i.e. box that stands out from the rest of the content, monospaced font and overflowing content will be scrollable).
  14. I'd recommend that you escape HTML entities before you output them and not before you insert them into the database. They pose no security risk in the database. The benefit of doing it on each request is that former exploits will be fixed when you deploy a security fix if you do it when outputting it. Had you done it when inserting instead then all existing exploits will still exist and will therefore not be fixed by the new changes. You have far greater control over the content in that way. It also seems that you're parsing bbcodes and such upon insertion into the database. Again, I'd recommend against that. If you parse them when outputting you will instead be able to have greater control over the content - existing content in particular. In that way you can add changes to the bbcode parser and those changes will be immediately reflected on existing and future content.
  15. No offense, but if you hold a bachelor in computer science, shouldn't you then be able to do something as simple as describing how a web based forum system works?
  16. Could also be a simple shifting/rotation cipher. Chances are many. In what context did it appear?
  17. What's up with the third one? o_O I use number two. Generally I code after the ZF standard. By the way, this is kind of poll-ish, so I'll move it to the Polls forum.
  18. Be assured, everyone does. Even the best of the best.
  19. If you know regular expressions, then it's pretty trivial. First you start by enabling rewriting: RewriteEngine on Then to rewrite e.g. /profile/Daniel0 to index.php?act=profile&username=Daniel0 you can do this: RewriteRule ^/profile/([a-zA-Z0-9]+)$ index.php?act=profile&username=$1 See, it's separated by spaces. The second part is the regex, i.e. the URL from the user to match. In regular expressions, everything in parentheses are stored in backreferences. The third part is the URL to rewrite to and $1 will here be replaced by the username. After that you can optionally have some options (flags), such as redirection, stop looking for more entries, send a specific response code, etc. You can also set various conditions that should be met, e.g. that HTTPS must be on. You can read about it here and here. If you're starting from scratch, then this might be better: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f # condition: only if the requested URL isn't a file that exists RewriteRule .* index.php # forward everything to index.php Then you can get the requested URL from $_SERVER['REQUEST_URI'] and then you can split it up or you can use regex there to send the request data to whatever place that should take care of that specific request.
  20. Daniel0

    Joomla!

    As always, I'd recommend Zend Framework (which our site is also built with). Other popular ones are symfony, CodeIgniter and CakePHP.
  21. Daniel0

    Joomla!

    Exactly the reason why I won't use Joomla! (who puts punctuation in the name of their software anyways?) nor any other pre-made content management system for anything. I don't want to deal with other people's crap. You'll end up modifying a lot of things so I think you're better off just starting with one of the large frameworks and custom building it from the start.
  22. As ober said (more or less), modify the layout.
  23. http://arstechnica.com/news.ars/post/20080317-firefox-3-goes-on-a-diet-eats-less-memory-than-ie-and-opera.html That's for FF3b4 though. I suppose it hasn't become worse after the stable release.
  24. Actually it has more efficient memory handling than any other browser.
×
×
  • 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.