PHP Chart Director Howto

From Zoelife4U Wiki
Jump to: navigation, search

Synopsis

Chart Director For PHP is a professional chart component for PHP powered web applications. Not many requests come in for this, but it's good to know how to make it work. Unlike Ioncube, Source Guardian, or even PHP Shield, it requires more tweaking to get it to work. It took me about a week to figure this out, so I'll share the gory details.

Let's get it on!!!!!

I recommend using SSH, ask around for the c script, if you don't already have it, once logged in to the account, type the following:

mkdir phpchart && cd $_ 
wget http://download.advsofteng.com/chartdir_php_linux_64.tar.gz 
tar -zvxf chartdir_php_linux_64.tar.gz 
cd ChartDirector/

OK, so we have our Chart Director files on the account and ready to use, right? Not quite, Chart Directory for PHP requires the ability to use dl() to load itself, on typical environments, however, we use Thready Safety, which disables the dl() function. So, we must fool PHP into loading the Chart Director libraries. To make this happen, we should consider the customer may also require PDOs and PECLs so, first thing first is to install a fresh php.ini file by going to PHP Config in cPanel, and Installing an Ioncube enabled ini file, and while your there, set PHP to Single INI. Now back to our shell prompt:

 cd ~/public_html/
 mv php.ini.default php.ini
 vim ~/public_html/php.ini

Next around line 428 of php.ini, change the extension_dir directory to the php directory in the user's home, for example, the user's home directory is /home4/username the extension_dir must look like:

extension_dir = "/home4/username/php"

Be sure to get the correct home directory, you can get this by typing:

echo $HOME;

on the command line. Next, back in PHP.ini, around like 1126 add:

extension=phpchartdir520mt.dll

No, you're not seeing things, and no, I'm not smoking crack, the DLL is actually a Cross Platform library that works on Linux as well as Windows. Chart Director uses some resources, so up to lines 230-232 change the values to:

max_execution_time = 120     ; Maximum execution time of each script, in seconds
max_input_time = 180 ; Maximum amount of time each script may spend parsing request data 
memory_limit = 128M      ; Maximum amount of memory a script may consume (10MB)

And then save and close php.ini:

:wq

Next comes the part that gave me all the grief, if you look at the contents of the ChartDirector/lib directory, you'll see a buttload of dll files, an .so file and then a fonts/ directory, as well as a testing php file. copy the php file to public_html/ and move the other files in place...

cd ~/ChartDirector
cp lib/FinanceChart.php public_html/
cp -r ./lib/* ~/php # We need that fonts/ directory too!!

and last but not least, we need the system libraries, PDOs, etc in ~/php too.

cp /usr/lib/php/extensions/no-debug-zts-20060613/* ~/php

And that's that, PHP Chart is all set, the customer will have to purchase their license to actually use these libraries. But this is how it's done. One thing to note, the test files have to be modified to point to the phpchartdir.php file, which is the 'workhorse' of the whole thing. So if the customer insists on seeing the tests work, create a lib/ directory in public_html/ and copy phpchartdir.php in there, and move the phpdemo/ into public_html, then navigate to http://domainname.com/phpdemo/ to test it's working. Note, they have to purchase a license to use the product, so until they install the license file, they will see odd errors.

Personal tools
Online Users
Zoelife4U: