David Ansermot Web Developer / TYPO3 Integrator

27oct/100

Using XHR and PHP for files upload

The website ProDevTips propose a tutorial about multiple file upload with PHP and XHR.

First of all, we now use stream_copy_to_stream to upload the files, hence such things as max file upload size and so on will not be respected. Luckily Valums’ solution will do th [...]

Read the tutorial

25oct/100

PEAR releases – 2010/10/25

The Latest PEAR Releases are out :

22oct/100

Using the Tidy PHP extension

xml logoWhen you want to perform checks on the tags xHTML programming, there are various tools to generate the transaction or directly through the web.

The site shows PHPsnippets as a script, a way to complete the transaction from the Tidy extension and PHP

The operation is very easy to implement because you just need to specify the page to check to get the desired result and see if your page contains format errors

Read the article about Tidy

22oct/100

Using closures in PHP 5.3

php logoSince the release of PHP 5.3, the closures are often used. There are few descriptions around the web showing you all the power offered by the new closures.

Vance Lucas published an article on this subject with five examples to put theory into practice, which are:

  • Templating
  • Extending dynamic code
  • Completion Time
  • Caching
  • Convenience (as in their role in specific functions for callbacks)

These five examples show that it is possible to use the closures very easily with very few lines of code.

Read the article

22oct/100

PHP – Remote post on WordPress using cUrl

Here's a code snippet function for remote posting on WordPress blogs I've made for my usage. It use XML-RPC and cUrl to publish on your blog.
Hope it'll help you.

  1. < ?php
  2.  
  3. /**
  4. * Remote post on WordPress function
  5. *
  6. * @date 2010-10-22
  7. * @author David Ansermot
  8. * @url http://v2.ansermot.ch
  9. *
  10. * @param string $url: Your blog's url
  11. * @param string $login: Your blog's login
  12. * @param string $pass: Your blog's password
  13. * @param string $postTitle: The post's title
  14. * @param string $postCats: A comma separated list of categories's ids
  15. * @param string $postContent: The post's content
  16. * @return bool
  17. */
  18. function curlRemotePostToWordPress($url, $login, $pass, $postTitle, $postCats, $postContent) {
  19.  
  20. // Remote post url
  21. $rpcUrl = rtrim($url, '/').'/xmlrpc.php';
  22.  
  23. // Categories for the post
  24. $categories = explode(',', $postCats);
  25.  
  26. // Post xml
  27. $xml = ''.$postTitle.'
  28.  
  29. < ![CDATA[ '.$postContent.' ] ]>';
  30.  
  31. // Build request
  32. $params = array('', '', $login, $pass, $xml, 1);
  33. $request = xmlrpc_encode_request('blogger.newPost', $params);
  34.  
  35. // Send the request
  36. try {
  37.  
  38. $ch = curl_init();
  39.  
  40. // cUrl configuration
  41. curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
  42. curl_setopt($ch, CURLOPT_URL, $rpcUrl);
  43. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  44. curl_setopt($ch, CURLOPT_TIMEOUT, 1);
  45.  
  46. // Execution
  47. curl_exec($ch);
  48.  
  49. return true;
  50.  
  51. } catch (Exception $e) {
  52.  
  53. return false;
  54.  
  55. }
  56. }
  57.  
  58. ?>