Feed on Posts or Comments

Category ArchivePHP




PHP & Programming Daantje on 15 Feb 2010

Bug in EZPDF using sessions.

Found bug in ezpdf (009) when using sessions and an older php 5.2.0 version. Loose the session and pdf file will parse correctly. Strange that this bug is not appearing with php 5.2.6

jQuery & PHP & Programming Daantje on 10 Jun 2009

Filter webpages server side with rhino and jquery…

I’m now busy with writing a filter, to grep data out of an large based HTML website, build back in the old days. Luckily they’ve used class names to point out the right table cells. I thought it would be a great job for jquery… But server-side… Could it be possible?
After some googling I found this very interesting blog post: “Bringing the Browser to the Server“. A real great way to use a javascript lib like jquery or prototype server side!
I use PHP to grep the HTML and transfer it to valid XHTML so I can use it in rhino.

./html2xml.php [path/to/file.html]

#!/usr/bin/php -q
<?php
        $doc = new DOMDocument();
        $doc->loadHTMLFile($argv[1]);
        $html = $doc->saveXML();

        $html = str_replace('<script','<noscript',$html);
        $html = str_replace('</script','</noscript',$html);

        echo $html;
?>

Than I use jquery to grep all data and do an ajax request to a PHP file to insert the data into a database.

After some testing, my scripts only work wit an older version of jquery. I use 1.2.6, the later ones all give errors…

I’ll try to post more info and code later ;) Check my tweets for info too!

PHP Daantje on 26 Oct 2005

mobileBrowserRedirect

I wrote this little PHP script for a friend of mine. He needed to redirect to a xhtml page when a user with a mobile device (internet capable PDA or phone) connected to his homepage. This script is very easy to implement… Just put it at the top of your first index.php file. When a user connects, this script will check the user agent (browser) and when a trigger is present, it will redirect. Hope it helps someone… Have fun.

$redirect = "/2005/xhtml/index.html";
$agents = array(
     'Zaurus',
     'PDA',
     'PalmOS',
     'Xda',
     'LG',
     'MOT-',
     'SAMSUNG-SGH-',
     'SIE-',
     'SonyEricsson',
     'SHARP',
     'NEC-',
     'Panasonic',
     'Nokia',
     'MDA'
);
foreach($agents as $i){
     if(strstr($_SERVER['HTTP_USER_AGENT'],$i)){
         header("Location: ".$redirect);
         exit;
     }
}

MacOS & PHP Daantje on 27 Feb 2005

PHP-GTK on MacOS X

1st try:
I’m building a project timer app in PHP with the php_gtk.so module. But I can’t compile it for my Mac… I have it running on my linux based machine, but not on my mac yet… I’ve found these pre-compiled libs, but it still doesn’t work…

I’m now checking the Fink stuff… I think I miss some GTK lib…

2nd try:
Found the gtk lib, but still no luck… If someone has an idea, please post!. I always get this error when I fire up a php-gtk script:

PHP Warning: Unknown(): Unable to load dynamic library ‘/usr/lib/php/extensions/no-debug-non-zts-20020429/php_gtk.so’ - dlcompat: dyld: php Undefined symbols

3th try “EUREKA! It works!”:

I have it working! This is what I did… I’ve downloaded the latest source from php.net. Unpaked it and compiled it with this configuration:

./configure 
--prefix=/usr 
--mandir=/usr/share/man 
--infodir=/usr/share/info 
--with-apxs2 
--with-ldap=/usr 
--with-kerberos=/usr 
--enable-cli 
--with-zlib-dir=/usr 
--enable-trans-sid 
--with-xml 
--enable-exif 
--enable-ftp 
--enable-mbstring 
--enable-mbregex 
--enable-dbx 
--enable-sockets 
--with-iodbc=/usr 
--with-curl=/usr 
--with-config-file-path=/etc 
--sysconfdir=/private/etc

Do a make and make install command to update the existing php binary.

Now download the latest php-gtk source and compile it.

./buildconf
./configure
make
make install

Now you should have this file: /usr/lib/php/extensions/no-debug-non-zts-20020429/php_gtk

rename the php_gtk to php_gtk.so

mv /usr/lib/php/extensions/no-debug-non-zts-20020429/php_gtk /usr/lib/php/extensions/no-debug-non-zts-20020429/php_gtk.so

Make sure that the file is executable;

chmod +x /usr/lib/php/extensions/no-debug-non-zts-20020429/php_gtk.so

Okay now your done… Don’t edit the php.ini to use the php_gtk.so at startup, or else you can’t use php in your Apache webserver! Use the php_gtk.so with this line in your source: dl(’php_gtk.so’);

To get it to work,

start up X11 (This is very important! php-gtk needs X11 or Xdarwin to run or else you get this error:

Fatal error: php-gtk: Could not open display in php-gtk-1.0.1/test/hello.php on line 4)

Xdarwin comes with Fink, a package management system for MacOS X based on the Debian apt tools.

Start your file in the terminal of X11 or Xdarwin and open a bottle of beer!


MacOS & PHP Daantje on 27 Feb 2005

PHP-GTK on MacOS X how to

Yes it works! Read my howto on how to make it work. Now I can build my project timer ;) I will make it GPL when I’m done…

Projects & MySQL & PHP Daantje on 26 Oct 2002

Uploaded Daantje’s Guestbook Project

Finaly, becouse my brothers site ‘oorsmeer.com‘ needed a new guestbook, I’ve recoded my guestbook code. It’s downloadable and usable under GPL license. Check it out…

Projects & PHP Daantje on 26 Oct 2002

BUG IN WhoisDomainCheckup 3.1.x

We’re building the website for be-HOSTING now, and I’m inplementing the WhoisDomainCheckup script. And found a bug. The .info domains are always registered. This is not true! This is because my HTTP/1.1 header is wrong, change in the include the ‘fsockopen()’ string HTTP/1.1 in HTTP/1.0 and the bug is gone… I’m checking out how to send in 1.1 the IPnumber of the server… New version is on it’s way now…


Projects & PHP Daantje on 20 Oct 2002

I’m Making Classes!

I’m going to make classes of all my scripts, for better implementation! I have something to do this weekend! ;-)