Jump to content

salathe

Staff Alumni
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by salathe

  1. Get in contact with Google and request a partnership. That would be the only offical way of getting all of the results for a search. Other options include using their APIs (which provide limited results) or literally scraping the results from the Google web interface (which probably is not allowed programatically).
  2. Kudos to Facebook for open sourcing the tool and it obviously suits their needs very well. As for whether this will become widely used outside Facebook, that's really not the point. Chances are, most of PHPFreaks' membership won't be needing a PHP to C++ compiler anytime soon (for anything other than educational value).
  3. The answer depends on your proficiencies and the tools available to you. For example, regex might be easier for you to pick up and write a quick script doing what you want (get those tags' contents). For me, it might be easier to use a document parser and access the structure (e.g using Tidy, DOM and friends) to get at the tags' contents. For someone else, get_meta_tags() might work fine (assuming they were not wanting the title!). If you're not comfortable with one method over another (or not aware of others to compare against) then that's also going to come into play with regards to the "easiest" way to do something.
  4. It's better than nothing. Another, preferable, technique in the code that you just posted would be to explicitly look for digit-only input since it is really an ID number being used in the query. Also, none of this has any bearing on whether the input will be safe for display, which is an entirely separate concern.
  5. Is there any particular reason why the default is 0000-00-00? If you allow the column to have NULL values in the table, you won't have to use PHP to look for the special zero date.
  6. In your code you have $database_login = Registry::get("database_login"); $databse_password = Registry::get("database_password"); Note that later you use the variables $database_user and $database_password
  7. function Testing($value) { echo $this->Settings->{'page_' . $value}; exit; } Testing('hello');
  8. A quick (in terms of lines of code at least) would be: file_put_contents('logs.txt', implode(PHP_EOL, file('logs.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES))); If the file is particularly large (i.e. if loading it into memory isn't trivial) then it would be better to go through the file in pieces (like, line-by-line), writing non-empty lines to a temporary file then moving said temporary file to the original location once the process is complete.
  9. Is the purpose of this thread to discuss remote-rending-services or to show that you've found a way of crashing a really crappy browser?
  10. It's note quite the same algorithm but you could use str_rot13 (to get Uryyb Jbeyq).
  11. It probably makes more sense to use m/d/y
  12. You only open the file for reading, not reading and writing (see the 2nd line of your code posted above). That's quite apart from your code being malformed (see where the syntax highlighting breaks in your post).
  13. Given your posted XML, shouldn't $xml->items->item instead be $xml->item ?
  14. zohab, please ask a question or at least suggest a topic of discussion. Otherwise, we've no idea what you want to know.
  15. Any, so long as it is clear (like camelCase and under_scored), descriptive and consistent throughout your code.
  16. Ah now the story unfolds. How happy would you be starting from scratch with a completely new approach? Unless there is any real reason for doing so, it would be much preferable to work only one remote file if possible (ideally, 300 different scripts all running at once): some form of task/queue framework would be good. If that sounds like too much hard work, you could also use cURL to fetch the files in batches (or say 50, 100, or even 300) in parallel and you can then be working some files while the rest are still being fetched: for this, look to using the curl_multi_* functions.
  17. Move the underscore (_) one character to the left and put a plus symbol (+) where it was. Then tell my why that would work.
  18. What are the major factors in the performance of your script, what is making it particularly slow: large files, lots of files, remote files (all of the above)?
  19. Yes it's possible, in a variety of ways. You could use/learn JavaScript (maybe made easier with jQuery or some other helper framework) only, or you could use JS and PHP or some other scripting language to "interpret" the XML and sort into different divisions as you like.
  20. What does your string look like (e.g. is it an HTML page, random text file, etc.)?
  21. In the first line, the $month and $day variables are in the wrong places (switch them around) since obviously there is no month 25! (Sorry) This was a very simple mis-type and something you really should have been able to figure out yourself, considering you knew the input given was in ddmmyy format. As for it "no matter what" outputting Wednesday, I've no idea how you got it to do that.
  22. Where did you get the idea to use $query->recordcount() from? It looks like $query should either by a resource or boolean (true/false), not an object. Try $db->numRows($query) instead.
  23. On (or near) line 30, you'll have code that looks like ->recordcount( which is causing an issue. Diagnosing the precise cause (other than the variable to which it is attached not being an object) needs us to see a sample of the code. If the script isn't too long (nor contains sensitive information) please post it here, or at least a portion of the script surrounding line 30. Edit: typos
  24. Unless I'm missing some finer point, your code could alternately be: $data = explode(',', $r); foreach ($data as $key => $value) { $data[$key] = explode('~', $value); } print_r($data);
  25. The two lines below extract the day, month and year from your example date using sscanf and gets the day of the week using those values and strtotime/date. It's just one example of getting what you wanted. sscanf('012510', '%02d%02d%02d', $day, $month, $year); $dayoftheweek = date('l', strtotime("20$year-$month-$day")); var_dump($month, $day, $dayoftheweek);
×
×
  • 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.