Category Archives: php

php related posts

pChart php class to build charts

pChart Logo

pChart Logo

Hi,

today i wanted to talk about a class that i have been using a lot lately and  i have worked with it for the past months, called pChart. this class let you create charts from stream data. the class let you create line, curve, cake/basic pie, bar,stacked,radar, 3d pie,radar, and scatter charts, and in this list i’m sure i’m forgetting some of them. the process to create the chart is very simple

pChart Creation Process

pChart Creation Process

as you see in the graph, the process consist in get the data from some stream, something that there is not mentioning is that the data retrieved, if is not a csv that the class have inbuilt functions to parse it, you need to prepare it, ordering in a specific way depending the type of chart you are using (if is a line bar, you need to define the serie name’s for each axis and the values for it). after you have the data, set the style, as the background, the font type and size (it support ttf fonts) and the scale. and then you are ready to draw the chart, that the returned data can be printed to the user directly, of course first setting a image type stream with the header() function or write it in a file.

below, you can see some example code:

// Standard inclusions
include(“pChart/pData.class”);
include(“pChart/pChart.class”);
// Dataset definition
$DataSet = new pData; // initialize the data parser object
$DataSet->ImportFromCSV(“Sample/bulkdata.csv”,”,”,array(1,2,3),FALSE,0); //get the data input from a csv file
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie();
$DataSet->SetSerieName(“January”,”Serie1″);
$DataSet->SetSerieName(“February”,”Serie2″);
$DataSet->SetSerieName(“March”,”Serie3″);
$DataSet->SetYAxisName(“Average age”);
$DataSet->SetYAxisUnit(“µs”);
// Initialise the graph
$Test = new pChart(700,230); //setting the widht and height of the chart
$Test->setFontProperties(“Fonts/tahoma.ttf”,8);  //the font used for the chart and the font size
$Test->setGraphArea(70,30,680,200);  //the width, height, x and y position of the area where the graph will be drawn
$Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);
$Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);
$Test->drawGraphArea(255,255,255,TRUE);
$Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2);
$Test->drawGrid(4,TRUE,230,230,230,50);
// Draw the 0 line
$Test->setFontProperties(“Fonts/tahoma.ttf”,6);
$Test->drawTreshold(0,143,55,72,TRUE,TRUE);
// Draw the line graph
$Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription());
$Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255);
// Finish the graph
$Test->setFontProperties(“Fonts/tahoma.ttf”,8);
$Test->drawLegend(75,35,$DataSet->GetDataDescription(),255,255,255);
$Test->setFontProperties(“Fonts/tahoma.ttf”,10);
$Test->drawTitle(60,22,”example 1″,50,50,50,585);
$Test->Render(“example1.png”);

and this is the result

pChart Example

pChart Example

you can download the class from here, you can find documentation and the classes definition at here, and here several examples of how to create different types of graphs

i hope this help you in some way :D .

Regards,

Shadow.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Related Post

Postfix queue bottleneck

Hi,

today a quick post, basically only to share this link that has been a great help to solve the bottleneck problem that could happen on postfix.

the bottleneck happen when the queue are stuck’s with too many request for some particular reason (like dictionary attacks or spam’s that make the active queue too busy) or something failed at processing the emails that put the request on incorrect queue.

as example, yesterday, for some reason clamav failed for lack of memory, something weird as the box have enough for everything (something that i need to look about) so, as result, the postfix failed at connect amavis, so the mail system but all the emails into deferred queue. after the restore of clamav, amavis and postifx, y run a postfix reload, that will run the cleanup daemon, to process all the emails that was on deferred and put them on the active queue.

you can diagnose this with the qshape tool, all explained  on the link above, is a but difficult to understand at the beginning, but is really useful :)

i hope it help you in some way :D

Regards.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Related Post

Open Source Web E-learning & Conference Platform: Big Blue Button

Hi,

some months ago, working over a project and designing the architecture and technical spects, we got a moment where we needed to get or build a streaming platform.  the problem was, that the streaming platform will needed to have a Q&A module, a way to share the desktop or ppt and other features. then searching in the web, i found Big Blue Button.

this open source project aims to build a free E-learning and Conference platform, from their web can be read as:

Our vision is that starting a web conference should be as easy as clicking a single metaphorical big blue button. As an open source project, we believe it should be easy for others to embrace and extend. And while web conferencing means many things to many people — our focus is to make the best web conferencing system for distance education.

the software is a conjunction of different technologies as java, flash, red5 etc.. to provide the streaming of the content to the users, is a big project, stable for now that really make the work. the only problem is that is not as-easy to install and configure than use it. for use it you just need a flash-compatible browser, but at the installation part, you need a dedicated server, linux-based, and follow a lot of configurations and installation process. i think is not for all the people but is a perfect project to customize /integrate in your own web application. also, the license of BBB is LGPL so can be integrated in any closed source project.

if you want, can try a live demo here

i hope it help you in some way :D

Regards,

Shadow.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Related Post

one file DB manager for mysql & postgreSQL: DBKiss

Hi,

2 days ago my boss was talking with a developer, and he recommended to change our phpmyadmin and use a one file DB manager called DBKiss

so, i installed it (what only take to extract from the compressed file) and tried it. the interface of course is not “nice” as the phpmyadmin but is functional, you have almost all the same functions except  the one of privileges as phpmyadmin, but you can execute sql queries, so if you know what you are doing, can be done manually.

the advantages of use DBKiss from phpmyadmin is the speed, is a lot more faster, even can make dumps of big SQL databases, something that phpmyadmin sometimes fails. also i think is more secure against attacks, like is less used and depends only from 1 file (anyway, if you have a DB manager that can be accessed from the web, always need to be in a protected directory)

the only thing i feel a little annoying is that force you to write the DB that you want to access to login. i usually login as root in the DB as i need to manage several of them, so i going to need to have the name of some at hand for the first login :)

i’d recommend you give it a try :) you can download it from here: http://www.gosu.pl/dbkiss/

Regards,

Shadow.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Related Post

BAD HEADER in amavis

Hi,

today seeing the logs of one of the servers i see that all the emails sent by one of the scripts was flagged as BAD HEADER and put it on quarantine. was something weird why i constructed the header variable in the correct way, so i tried to search for a solution. first of all i set the directive @bypass_header_checks_maps

@bypass_header_checks_maps = (
read_hash(“/var/amavis/badheader_bypass”),
);

there you can set 1 per line, all the email that you want to avoid the email header check. even that i do it, it didn’t worked for me, so i looked at the quarantine email and i look something like this:

X-Amavis-Alert: BAD HEADER SECTION Improper use of control character (char 0D
hex): Content-type: text/html; charset=iso-8859-1\r

so, i erased all the /r from the emails headers and all worked :D

i hope this help you in some way :D

Regards,

Shadow.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Related Post

GlotPress: collaborative translation

Hi,

for a tweet of one of the person i follow, i noticed the existence of this project.

basically GlotPress provide a web end and administration for translation of phrases for development projects.

is a nice platform, easy to use and the well implemented usability make the translations something fun and not something boring as always :P . i have contributed with some translations from english to spanish for the gravatar project.

the project is still under development, you can see more info here.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Related Post

Foreach objects in smarty

Hi,

recently i changed how a REST API sent the info from xml to JSON, that mean that now the arrays was converted into objects after the json_decode(). don’t was too much problem till i see that my smarty templates don’t worked anymore :(

the change of each file don’t was an option and the convert from objects to arrays is wasting resources in nothing, so i made a hack in the smarty main class :D

basically in the file Smarty_Compiler.php at line numero 1203 i added this if():

if(is_object($from)){
$output .= “\$_from = $from;”;
$output .= “foreach(\$_from as $key_part=>$item){“;
}else{

and in the else, you wrap all the other code to parse arrays :D

now the foreach will parse objects and arrays :D

i hope it helps.

Regards,

Shadow.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Related Post

Weird php bug? : “” == 0

Hi,

just happened something weird, i have a sentence like this:

if($var!=”"){

}

the thing is that the var sometimes get the value of 0, and for some reason it returned false (something that never happened to me before in 3 years programming in php). anyway i understand that can be considered as normal, but i wondering if is a bug :s (why it don’t happened before )

the solution?

if($var!==”"){

}

i hope has been useful :D

Regards,

Shadow.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Related Post