Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. FTP: https://github.com/rjkip/ftp-php Imagine: https://github.com/avalanche123/Imagine Database: https://github.com/zendframework/zf2/tree/master/library/Zend/Db Which covers: - Upload images to a folder. Login required (FTP) - Resize and create thumbnails (Imagine) - Allowing to change the image title (Database?) - Allowing to delete the image (Database?) - Create/Edit/Delete albums (Database?) - Ability to set a cover photo (Database?) Highly advisable to install this through Composer. Packages can be found @ Packagist.
  2. You need to use XPath $cams = new SimpleXMLElement('http://chaturbate.com/affiliates/api/onlinerooms/?format=xml&wm=N6TZA', null, true); foreach ($cams->xpath('//username') as $username) { echo $username, '<br>', PHP_EOL; }
  3. Please keep it to one topic: http://forums.phpfreaks.com/topic/265698-gann-square-of-nine/
  4. Not just for children of a young age also adults like myself like to toy with it. Linux Format dedicated a few issues to it showing me the ins and outs.
  5. Try this: var_dump(ini_get('allow_url_fopen')); // string(1) "1" @CF I presume Google asked you for your permission to scrape your website? All jokes aside I scrape quite a few websites for my own personal use (Belgium job sites, even steampoweredgames.com), and I make sure none of them generates any serious load (sleep). I use a customized UA string that has a unique name and also clearly communicates that it honors the robots.txt. User-Agent: ItsieBitsieSpider (honors robots.txt) So if some websites wants my crawler to stop crawling them it's easy for them to do so. So far, there is no-one that is blocking the crawler. -- @OP Follow the leader (=Google). Do as they do: 1. Search for a robots.txt file (@ http://domain.top/robots.txt) read it and act accordingly 2. Search for a Robots header, act accordingly 3. Search for a Robots meta header (@ <meta name="robots" ..), act accordingly ALWAYS clearly communicate who you are: Do NOT open many simultaneous threads.. You may get the info faster but you are then "DDoS attacking" their server which is a crime. Do NOT sell the info, or make the visitors pay for the info.. obviously. -- If someone would sue you for crawling them then you have sufficient proof that your intentions were honest. For example I crawl steampoweredgames.com because their search sux*! And I am not the only one who thinks so. The only thing that does work in a usable matter is their checkout.. * I regularly want to browse for a yet unknown game that satisfies certain criteria (A simple search on release date is impossible, combining game modes, or genres also impossible.. ugh) but Steam does not give you enough tools to do so.
  6. I tried with file_get_contents and that worked fine! Can you verify that it still doesn't work?
  7. http://be2.php.net/manual/en/apc.installation.php What about it is unclear?
  8. Practice, practice, practice. Here you can find a list of possible practice ideas: http://forums.phpfreaks.com/topic/262327-bored-looking-for-ideas-heres-a-list/
  9. Simply use both. ZF2 for MVC and all, and any missing features you fill in from ZF1. It's perfectly possible.
  10. I personally never used the ZF1 MVC in a professional setting for the same reasons you mentioned, specifically the "module" setup felt weird and I couldn't get it to work properly. Many of these issues have been resolved in ZF2, though I haven't tried the Zf2 Mvc component either. That said with the release of ZF2 I suggest you invest time in that instead of ZF1.
  11. 1. It loads a Quote from a database, which it probably also retrieves through a Singleton. 2. Quote IS the model, and it loads not only the name but the entire quote from the DB though you can easily modify what it loads by default, but will have to put things in place to load extra stuff when needed.
  12. @Dex No, that's totally wrong and I am guessing that is due to you staring at the Desktop version of MVC instead of the Web version of it. In the Web version the View does not directly update the Model, it just can't it needs the help of the Controller to do so via a GET or POST request. Thus when you submit the page the Controller passes the View data ($_POST) to the Model which validates the data and through the Controller it is passed back to the View for display. // Controller: contact.php $di = StaticDIContainer::getInstance(); $req = $di->get('Request'); $model = $di->get('ContactModel'); $service = $di->get('ContactService'); if ($req->isPost()) { try { // a object can never be in an invalid state $model->populate($req->getPostData()); $service->send($model); // success! $di->get('Response')->sendHeader('Location', '/'); } catch (MultipleErrorException $e) { $errors = $e->getErrors(); $di->get('View') ->set('errors', $errors) ->set('input', $req->getPostData()); } } $di->get('View')->render('contact/form'); It's as simple as @requinix showed you though you can do it in pure procedural too.
  13. 1) Why is that bad? 2) Why not simply send Connection: close upon each request instead of telling it to persist? 3) Would nginx be an option? It uses FastCGI?
  14. System.out.TheStuffIMentionedAndJustDoIT('/path/to/directory/read/', 'outputfile.txt'); Also I dig some digging and I found ALL your answers here.
  15. I just want to add that these teachers were hired to teach the beginnings, yes, even the advanced classes, as advanced in this sense means the advanced introduction to Dreamweaver. Many colleges are sponsored by Microsoft and Adobe so naturally all software related classes are taught in their software packages and the alternatives become not an option. Other technologies are "forbidden"/not taught. For example one of the college's I have attended did not teach Java at all as they were heavily sponsored by Microsoft and they required you to purchase the student license of Adobe for the entire Adobe Suite although we only used like 2 or 3 products of the entire suite. Since these classes are too easy for you, you should re-evaluate your choice and join a University instead?
  16. https://github.com/teqneers/PHP-Stream-Wrapper-for-Git https://github.com/klaussilveira/gitter https://github.com/gitonomy/gitlib Aside from these I think it's pretty limited and not entirely side-effect free eg chdir(dirname(__FILE__));
  17. spl_autoload(function($className) { $className = ltrim($className, '\\'); $fileName = ''; $namespace = ''; if ($lastNsPos = strripos($className, '\\')) { $namespace = substr($className, 0, $lastNsPos); $className = substr($className, $lastNsPos + 1); $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; } $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; require $fileName; }); This is what I would use in small scripts. Any other I use Composer and it solves the autoloading for me. "autoload":{ "psr-0":{ "mylib": "src/" } } require 'vendor/autoload.php';
  18. So you were surprised no-one mentioned it, and THEN read the replies?
  19. That's because you don't read the replies. ManiacDan has mentioned it. Do a page search it will show 2 results.
  20. Which means that using a simple LIMIT binds you to mysql and PDO becomes nothing more than a condom around mysql.
  21. The first warning means there not enough arguments which is when $_GET['id'] is missing which is why you need modify the code so that it encloses the querying part: (The second is due to the first warning) if (isset($_GET['id'])) { // get the specified post $sql = " SELECT *, (SELECT max(id) FROM `%1$s` WHERE id < %2$d AND status = 'published') AS prev_id, (SELECT min(id) FROM `%1$s` WHERE id > %2$d AND status = 'published') AS next_id FROM `%1$s` WHERE id = %2$d AND status = 'published' "; $dbname = mysqli_connect('host', 'user', 'pass', 'dbname'); if (mysqli_connect_error()) { // todo add proper error handling here echo mysqli_error($dbname); exit; } $stmt = sprintf($sql, mysqli_real_escape_string($dbname, $table_name), mysqli_real_escape_string($dbname, $_GET['id'])); } else { // get the latest post $sql = " SELECT *, (SELECT max(id) FROM `%1$s` T2 WHERE T2.id < T1.id AND status = 'published') AS prev_id FROM `%1$s` T1 ORDER BY id DESC LIMIT 1 "; $stmt = sprintf($sql, mysqli_real_escape_string($dbname, $table_name)); }
  22. I stand corrected. I really thought it would yield the same error, I even checked it on sqlfiddle to make sure.. selective blindness
  23. Not when the value is a number and you use it in combination with sprintf and %d (look that up in the manual by clicking on the previous link), what CF was trying to point out. Maybe until you fully grasp PHP and how everything works it's best if you use mysqli_real_escape_string on everything before inserting it into an SQL string.
  24. It's easy enough to modify my code without having to resort to "sql inject" yourself... The OP just needs to enclose the query part with an if/else.
×
×
  • 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.