<?php
session_start();
$y = session_id();
echo $y;
/*
$page_access_levels = ':20:30:40:';
include('initialize_pointer.php');
include($include_root.'authenticate.inc');
include($include_root.'reports_class.inc');
pull_other_organization_report_permissions ( 4, 4, 5 );
/*
$password = 'tt';
//Check for numbers
if ( !ereg ( "[0-9]", $password ) ) {
$this->password_error .= 'Need at least one number in password. ';
}
else {
$this->password_error .= 'PASS OK. ';
}
echo $this->password_error
/*
$color_dec_code_a = 7;
$color_dec_code_b = 265;
$color_dec_code_c = 265;
$color = array ( 'F79949', '6D87D4', 'FED105', 'FE6205', 'FE0561', '840561', '055BFF', '05D1FE', '05FE78', '7000FF'
);
//Cycle through the clients with client id as key
echo '<table>';
for ( $i = 0; $i < 11; $i++ ) {
//echo "Profile is: ".$key. "=> ".$current_client."<br/>";
/*
$color_dec_code_a = rand ( 17, 255 );
$color_dec_code_b = rand ( 17, 255 );
$color_dec_code_a = $color_dec_code_a + 20;
$color_dec_code_b = $color_dec_code_b - 20;
$color_dec_code_c = $color_dec_code_c - 10;
$color_hex_code_a = dechex ( $color_dec_code_a );
$color_hex_code_b = dechex ( $color_dec_code_b );
$color_hex_code_c = dechex ( $color_dec_code_c );
*/
// echo '<tr><td style=\'background-color:
// #'.$color[$i].'\'>Hello</td></tr>';
//}
//echo '</table>';
//include('initialize_pointer.php');
//include($include_root."authenticate_public.inc");
//include($include_root."encryption_class.inc");
//include($include_root.'date_encrypted_functions.inc');
//$index = date_encrypted_find_index_unix_time ( time() );
//echo $index;
/*
$en = new Encryption();
$x = time();
//Loop through the years we want to create
for ( $y = 1900; $y < 1901; $y++ ) {
//Loop through the months in a year
for ( $m = 1; $m < 13; $m++ ) {
if ( $m < 10 ) {
$m = '0'.$m;
}
//Loop through the days in a month
for ( $d = 1; $d < 31; $d++ ) {
if ( $d > 28 && !checkdate ( $m, $d, $y ) ) {
break 1;
}
if ( $d < 10 ) {
$d = '0'.$d;
}
echo "Year: ".$y.", Month: ".$m.", Day: ".$d."<br/>";
//Create 1000 records with that equal the day, with a usless four digit extension to make the records encrypt to
//different values
//Determine how many fake records for this day
$num_fake_records_between_days = rand ( 0, 10 );
for ( $jr = 0; $jr < $num_fake_records_between_days; $jr++ ) {
$date_index++;
$junk_record_index = rand ( 5001, 9999 );
$date_val = $y.$m.$d.$junk_record_index;
$date_index_encrypted = $en->encrypt_data ( $date_index );
$date_val_encrypted = $en->encrypt_data ( $date_val );
echo $date_val.' Between day fake records<br/>';
//echo $date_index_encrypted;
}
$num_fake_records_within_day = rand ( 0, 2 );
for ( $i = 1000; $i < 1001; $i++ ) {
$date_index++;
$date_val = $y.$m.$d.$i;
$date_index_encrypted = $en->encrypt_data ( $date_index );
$date_val_encrypted = $en->encrypt_data ( $date_val );
echo $date_index.' - '.$date_val.' REAL<br/>';
//Insert val into table
//Generate a random number of intervening records, that are useless filler to foil simple runumbers attempts to
//decode the date index
$junk_records_count = rand ( 0, $num_fake_records_within_day );
for ( $jr = 0; $jr < $junk_records_count; $jr++ ) {
$date_index++;
$junk_record_index = rand ( 1301, 5000 );
$date_val = $y.$m.$d.$junk_record_index;
$date_index_encrypted = $en->encrypt_data ( $date_index );
$date_val_encrypted = $en->encrypt_data ( $date_val );
echo $date_index.' - '.$date_val.' Within day fake records<br/>';
}
}
}
}
}
$xx = time();
echo $x."<p>";
echo $xx."<p>";
$elapsed = $xx-$x;
echo "Time: ".$elapsed."<p>";
$minutes = $elapsed/60;
echo "Time minutes: ".$minutes."<p>";
$total_minutes = (150/1) * $minutes;
echo "Predicted total Time minutes: ".$total_minutes."<p>";
/*
$x = microtime();
for ($i=0; $i < 100000; $i++ ) {
$a["aworymy"][$i] = $i;
}
$xx = microtime();
echo $x."<p>";
echo $xx."<p>";
$elapsed = $xx-$x;
echo "Time with double quotes: ".$elapsed."<p>";
unset ($a);
$x = microtime();
for ($i=0; $i < 100000; $i++ ) {
$b['bworymy'][$i] = $i;
}
$xx = microtime();
echo $x."<p>";
echo $xx."<p>";
$elapsed = $xx-$x;
echo "Time no double quotes: ".$elapsed."<p>";
phpinfo();
include('initialize_pointer.php');
include($include_root.'encryption_class.inc');
//mcrypt_encrypt();
//echo secret_word | mcrypt -F -q -a rijndael-128 -k abc
//echo encrypted_word | mcrypt -k abc -d --force --bare
//$secret_sentence = shell_exec ( 'echo secret_wordf | /usr/local/bin/mcrypt -F -q -a rijndael-128 -k abc --bare' );
//$secret_sentence = shell_exec ( 'echo secret_wordf | /usr/local/bin/mcrypt -F -q -a rijndael-128 -k abc --bare | od -h' );
//$secret_sentence = shell_exec ( " mcrypt -F -q -a rijndael-128 -k abc" );
//$secret_sentence = shell_exec ( " echo whaaa" );
/*
$x = microtime();
for ($i=0; $i < 10; $i++ ) {
$fp = fopen ("/tmp/temp_secret.txt", "w+");
fputs ( $fp, "Words are secrets");
fclose($fp);
$secret_sentence = shell_exec ( '/usr/local/bin/mcrypt -q -a rijndael-128 -k abc -u --bare /tmp/temp_secret.txt' );
//echo "herer ".$secret_sentence."<p>";
//unlink ('/tmp/temp_secret.txt');
$fpb = fopen('/tmp/temp_secret.txt.nc', 'r');
$encrypted = fread ($fpb, filesize('/tmp/temp_secret.txt.nc'));
fclose($fpb);
echo 'Encrypted: '.$encrypted.'<p>';
}
$xx = microtime();
echo $x."<p>";
echo $xx."<p>";
$elapsed = $xx-$x;
echo "Time: ".$elapsed."<p>";
$x = microtime();
for ($i=0; $i < 10; $i++ ) {
$fp = fopen ("/tmp/temp_secret.txt.nc", "w+");
fputs ( $fp, $encrypted);
fclose($fp);
//$decryted = shell_exec ( 'echo '.base64_decode($secret_sentence).' | /usr/local/bin/mcrypt -k abc -d --force' );
//$decryted = shell_exec ( 'echo '.$secret_sentence.' | /usr/local/bin/mcrypt -k abc -d --force -a rijndael-128 --bare' );
$decryted = shell_exec ( '/usr/local/bin/mcrypt -k abc -d -a rijndael-128 --bare /tmp/temp_secret.txt.nc' );
//$decryted = shell_exec ( 'echo '.$secret_sentence );
$fd = fopen('/tmp/temp_secret.txt', 'r');
$decryted = fread ($fd, filesize('/tmp/temp_secret.txt'));
echo "Here Decrypted: ".$decryted;
}
$xx = microtime();
echo $x."<p>";
echo $xx."<p>";
$elapsed = $xx-$x;
echo "Time: ".$elapsed."<p>";
*/
/*
$x = time();
$en = new Encryption ();
for ($i=0; $i < 10000; $i++ ) {
$encrypt_me = "My secret client data";
//$encrypted = $en->encrypt_data ( $encrypt_me );
//echo "The encrypted data is: ".$encrypted."<p>";
//unset ($en);
//$ev = new Encryption ();
$decrypted = $en->decrypt_data ( $encrypted );
//echo "The decrypted data is: ".$decrypted."<p>";
}
$xx = time();
echo $x."<p>";
echo $xx."<p>";
$elapsed = $xx-$x;
echo "Time: ".$elapsed."<p>";
//$ee = aspell_check($g, "tom");
/*
$test_this_password = "rockhead";
$vetted_password = escapeshellcmd($test_this_password);
$s = popen("/home/teddk/cracktest ".$vetted_password, "r");
//var_dump($s);
//echo fgets($s);
while (!feof ($s) ) {
$z = fgets($s);
$z = escapeshellcmd($z);
print $z."<p/>";
}
pclose ($s);
$test_this_password = "washington";
$vetted_password = escapeshellcmd($test_this_password);
$s = popen("echo ".$vetted_password." | aspell -a --ignore-case", "r");
//var_dump($s);
//echo fgets($s);
while (!feof ($s) ) {
$z = fgets($s);
//$z = escapeshellcmd($z);
print $z."<p/>";
}
pclose ($s);
phpinfo();
/*
include("initialize_pointer.php");
include($include_root."authenticate_public.inc");
include($include_root."reports_class.inc");
echo "<link rel=\"shortcut icon\" href=\"http://localhost/favicon.ico\">";
db_generic_connect ();
$perms = report_permissions_household ( 5, 3, 7 );
var_dump ( $perms );
/*
<<<<<<< test.php
<<<<<<< test.php
<<<<<<< test.php
//echo "<img src=\"".test2.php."\">";
echo "Yes";
echo "<a href=\"test36666666666.php\">UUUUUUUUUUUUUUUUULINNKK</a>";
=======
=======
=======
include('include/email_class.inc');
$test = new Email();
$test->email_message ( "hide@address.com", "Tedd's name", "hide@address.com",
"Tedd Origin", "my message", "my thing to talk about" );
>>>>>>> 1.6
phpinfo()
/*
>>>>>>> 1.5
$page_access_levels = ":10:20:30:";
>>>>>>> 1.4
<<<<<<< test.php
echo "I am different, arn I not?";
=======
include("initialize_pointer.php");
if(!include($include_root."authenticate.inc")){echo "No Authentication"; exit; };
include($include_root."questions_display.inc");
include($include_root."Questions_answers_validation_class.inc");
$polly = "AbCd";
for ($d=0; $d < strlen($polly); $d++) {
echo $polly[$d]."<br>";
}
$t_question = array ("question_id" => "t_question", "question_title" => "Test_date", "question_type" => "date", "question_owner_group_id" => "1", "question_owner_org_id" => "1",
"question_field_size" => "0", "question_range_bottom" => "0", "question_range_top" => "0",
"question_display_order" => "1019", "question_required" => "yes", "question_default_value" => time(), "question_visible" => "yes",
"question_ecma" => "", "question_special_attribute" => "FjY");
echo question_display ($t_question, "", "");
$sql = "SELECT question_id FROM questions ORDER BY question_id DESC";
$result = run_query($sql, "ggg");
$value = pg_fetch_array ($result, "0");
echo "second try ".$value[0];
//echo strtotime("9/27/01 00:00:00");
<<<<<<< test.php
>>>>>>> 1.4
$x = getenv("SCRIPT_NAME");
=======
*/
/*
>>>>>>> 1.5
echo $x;
phpinfo();
*/
/*
//echo strtotime("9/27/01 00:00:00");
//phpinfo();
//session_start();
//if (!$_SESSION["xxx"]) {
// session_register('xxx');
//}
//echo "TEST is: ".$_SESSION['test']."<p>";
//$_SESSION['test'] = "why me<p>";
//echo "Session var xxx =: ".$_SESSION["xxx"];
//$_SESSION["xxx"] = "turnipprrreeeeeeeeeeeeeeppp";
//$xxx = "tywwwwytt";
SELECT DISTINCT (clientsa.client_id) FROM
((clients AS clientsa INNER JOIN client_rpt_profile AS client_rpt_profile1 ON (clientsa.client_id = client_rpt_profile1.client_id))
INNER JOIN client_rpt_profile AS client_rpt_profile2 ON
(clientsa.client_id = client_rpt_profile2.client_id))
SELECT clientsa.*, client_rpt_profile1.*, client_rpt_profile2.* FROM
((clients AS clientsa INNER JOIN client_rpt_profile AS client_rpt_profile1 ON (clientsa.client_id = client_rpt_profile1.client_id))
INNER JOIN client_rpt_profile AS client_rpt_profile2 ON
(clientsa.client_id = client_rpt_profile2.client_id))
SELECT clients.* FROM
((clients INNER JOIN client_rpt_profile AS client_rpt_profile1 ON (clients.client_id = client_rpt_profile1.client_id))
INNER JOIN client_rpt_profile AS client_rpt_profile2 ON
(client_rpt_profile1.client_id = client_rpt_profile2.client_id))
SELECT clients.* FROM
((clients LEFT OUTER JOIN client_rpt_profile AS client_rpt_profile1 ON (clients.client_id = client_rpt_profile1.client_id))
LEFT OUTER JOIN client_rpt_profile AS client_rpt_profile2 ON
(clients.client_id = client_rpt_profile2.client_id))
SELECT clients.*
FROM clients
WHERE clients.client_id IN
(SELECT client_rpt_profile.client_id FROM client_rpt_profile WHERE client_rpt_profile.client_id = clients.client_id)
AS clientsa INNER JOIN client_rpt_profile AS client_rpt_profile1 ON (clientsa.client_id = client_rpt_profile1.client_id))
INNER JOIN client_rpt_profile AS client_rpt_profile2 ON
(clients.client_id = client_rpt_profile2.client_id))
SELECT DISTINCT(clients.client_id) FROM clients
INNER JOIN client_rpt_profile AS client_rpt_profile1 ON (clients.client_id = client_rpt_profile1.client_id)
INNER JOIN client_rpt_answers AS client_rpt_answers1 ON (client_rpt_profile1.client_rpt_id = client_rpt_answers1.client_rpt_id)
INNER JOIN client_rpt_answers AS client_rpt_answers2 ON (client_rpt_profile1.client_rpt_id = client_rpt_answers2.client_rpt_id)
INNER JOIN client_rpt_profile AS client_rpt_profile2 ON (clients.client_id = client_rpt_profile2.client_id)
INNER JOIN client_rpt_answers AS client_rpt_answers3 ON (client_rpt_profile2.client_rpt_id = client_rpt_answers3.client_rpt_id)
INNER JOIN client_rpt_answers AS client_rpt_answers4 ON (client_rpt_profile2.client_rpt_id = client_rpt_answers4.client_rpt_id)
INNER JOIN report_relationship AS report_relationship1 ON (clients.client_id = report_relationship1.report_relationship_client_id)
INNER JOIN report_profile AS report_profile1 ON (report_relationship1.hh_report_id =
report_profile1.hh_report_id)
INNER JOIN report_answers AS report_answers1 ON (report_profile1.hh_report_id =
report_answers1.hh_report_id)
INNER JOIN report_answers AS report_answers2 ON (report_profile1.hh_report_id =
report_answers2.hh_report_id)
WHERE
client_rpt_profile1.report_type LIKE 'client_intake' AND
client_rpt_answers1.client_rpt_question_id = '101' AND client_rpt_answers1.client_rpt_answer LIKE 'male' AND
client_rpt_answers2.client_rpt_question_id = '102' AND client_rpt_answers2.client_rpt_answer LIKE 'white' AND
client_rpt_profile2.report_type LIKE 'client_discharge' AND
client_rpt_answers3.client_rpt_question_id = '106' AND client_rpt_answers3.client_rpt_answer LIKE '12' AND
client_rpt_answers4.client_rpt_question_id = '107' AND client_rpt_answers4.client_rpt_answer LIKE 'english' AND
report_profile1.report_type LIKE 'hh_intake' AND
report_answers1.report_question_id = '56' AND report_answers1.report_answer LIKE 'emergency_shelter' AND
report_answers2.report_question_id = '72' AND report_answers2.report_answer LIKE 'income'
INNER JOIN report_relationship AS report_relationship2 ON (clients.client_id = report_relationship2.report_relationship_client_id)
INNER JOIN report_profile AS report_profile2 ON (report_relationship1.hh_report_id = report_profile1.hh_report_id
report_profile2.report_type LIKE 'hh_discharge' AND
SELECT DISTINCT(clients.client_id)
FROM clients
INNER JOIN report_relationship AS report_relationship1 ON (clients.client_id = report_relationship1.report_relationship_client_id)
INNER JOIN report_profile AS report_profile1 ON (report_relationship1.hh_report_id = report_profile1.hh_report_id)
INNER JOIN report_answers AS report_answers1 ON (report_profile1.hh_report_id = report_answers1.hh_report_id)
INNER JOIN report_answers AS report_answers2 ON (report_profile1.hh_report_id = report_answers2.hh_report_id)
WHERE report_profile1.report_type LIKE 'household_intake' AND report_profile1.report_date_begin > '985766400' AND report_profile1.report_date_begin < '1017388800'
AND report_answers1.report_question_id = '133' AND report_answers1.axis_x = '24' AND report_answers1.axis_y = '25'
AND report_answers2.report_question_id = '133' AND report_answers2.axis_x = '24' AND report_answers2.axis_y = '26'
AND report_relationship1.client_relationship_to_lead LIKE 'head'
AND
( report_answers1.report_answer_int + report_answers2.report_answer_int) > 5 )
SELECT DISTINCT(clients.client_id)
FROM clients
INNER JOIN report_relationship AS report_relationship1 ON (clients.client_id = report_relationship1.report_relationship_client_id)
INNER JOIN report_profile AS report_profile1 ON (report_relationship1.hh_report_id = report_profile1.hh_report_id)
INNER JOIN report_answers AS report_answers1 ON (report_profile1.hh_report_id = report_answers1.hh_report_id)
WHERE report_profile1.report_type LIKE 'household_intake' AND report_profile1.report_date_begin > '985766400' AND report_profile1.report_date_begin < '1017388800'
AND report_relationship1.client_relationship_to_lead LIKE 'head'
AND
(
SELECT SUM(report_answers.report_answer_int) FROM report_answers
WHERE report_answers.report_question_id = '133'
AND report_answers.axis_x = '24'
AND report_answers.hh_report_id = report_profile1.hh_report_id
) > 20
function DrawBullet($image, $x, $y, $type, $color) {
switch ($type) {
case 0:
case 5:
for ($i=0; $i<8; $i++)
ImageArc($image, $x, $y, $i, $i, 0, 359, $color);
break;
case 1:
case 6:
ImageFilledRectangle($image, $x-3, $y-3, $x+3, $y+3, $color);
break;
case 2:
case 7:
ImageFilledRectangle($image, $x-1, $y-4, $x+1, $y+4, $color);
ImageFilledRectangle($image, $x-4, $y-1, $x+4, $y+1, $color);
break;
case 3:
case 8:
$points[0]=$x;
$points[1]=$y-4;
$points[2]=$x+4;
$points[3]=$y;
$points[4]=$x;
$points[5]=$y+4;
$points[6]=$x-4;
$points[7]=$y;
ImageFilledPolygon($image, $points, 4, $color);
break;
case 4:
case 9:
$points[0]=$x;
$points[1]=$y-4;
$points[2]=$x+4;
$points[3]=$y+4;
$points[4]=$x-4;
$points[5]=$y+4;
ImageFilledPolygon($image, $points, 3, $color);
break;
default: ;
}
return;
}
function MakeLinePointChart($imagedata) {
$id = uniqid("");
$width = $imagedata["width"];
if (!$width) $width=1;
$height = $imagedata["height"];
if (!$height) $height=1;
$chartx = 5;
$charty = 5;
$chartw = $width-10;
$charth = $height-10;
$scaleyx = 0;
$im = imagecreate($width, $height);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
$colors[0] = ImageColorAllocate($im, 240, 128, 128);
$colors[1] = ImageColorAllocate($im, 100, 149, 237);
$colors[2] = ImageColorAllocate($im, 50, 205, 50);
$colors[3] = ImageColorAllocate($im, 255, 215, 0);
$colors[4] = ImageColorAllocate($im, 131, 111, 255);
$colors[5] = ImageColorAllocate($im, 144, 238, 144);
$colors[6] = ImageColorAllocate($im, 70, 130, 180);
$colors[7] = ImageColorAllocate($im, 244, 164, 96);
$colors[8] = ImageColorAllocate($im, 139, 121, 94);
$colors[9] = ImageColorAllocate($im, 190, 190, 190);
ImageFill($im,0,0,$white);
$caption = $imagedata["caption"];
if ($caption) {
$font1 = 5;
$ifh1 = ImageFontHeight($font1);
$ifw1 = ImageFontWidth($font1);
$captionw = strlen($caption)*$ifw1;
ImageString($im, $font1, ($width - $captionw)/2, 0, $caption, $black);
ImageLine($im, ($width - $captionw)/2, $ifh1, ($width+$captionw)/2, $ifh1, $black);
$charth -= $ifh1;
}
$xcaption = $imagedata["xCaption"];
if ($xcaption) {
$font2 = 4;
$ifh2 = ImageFontHeight($font2);
$ifw2 = ImageFontWidth($font2);
$xcaptionw = strlen($xcaption)*$ifw2;
ImageString($im, $font2, ($width - $xcaptionw)/2, $height-$ifh2, $xcaption, $black);
$charty += $ifh2;
$charth -= $ifh2;
}
$xscale = $imagedata["xScale"];
if ($xscale) {
$font4 = 3;
$ifh4 = ImageFontHeight($font4);
$ifw4 = ImageFontWidth($font4);
$charty += $ifh4;
$charth -= $ifh4;
}
$ycaption = $imagedata["yCaption"];
if ($ycaption) {
$font3 = 4;
$ifh3 = ImageFontHeight($font3);
$ifw3 = ImageFontWidth($font3);
$ycaptionh = strlen($ycaption)*$ifw3;
ImageStringUp($im, $font3, $ifw3, ($height + $ycaptionh)/2, $ycaption, $black);
$chartx += $ifh3+5;
$chartw -= $ifh3+5;
$scaleyx += $ifh3+7;
}
// echo $chartw." ".$chartx." ".$chartw+$chartx."<br>";
$yscale = $imagedata["yScale"];
if ($yscale) {
$font6 = 3;
$ifh6 = ImageFontHeight($font6);
$ifw6 = ImageFontWidth($font6);
if ($imagedata["numberFormat"]) {
$longestyscale=strlen(sprintf($imagedata["numberFormat"],$imagedata["yMax"]));
$tmp = strlen(sprintf($imagedata["numberFormat"],$imagedata["yMin"]));
} else {
$longestyscale=strlen($imagedata["yMax"]);
$tmp = strlen($imagedata["yMin"]);
}
$longestyscale=max($longestyscale, $tmp);
$chartx += $longestyscale*$ifw6;
$chartw -= $longestyscale*$ifw6;
}
$ycount = $imagedata["yCount"];
$format = $imagedata["numberFormat"];
if ($ycount) {
$yinc = $charth/$ycount;
$yscaleinc = (-$imagedata["yMin"]+$imagedata["yMax"])/$ycount;
$y=$charty;
$yscaleval = $imagedata["yMin"];
for ($i=0; $i<=$ycount;$i++) {
ImageDashedLine($im, $chartx-2, $height-$y,$chartx+$chartw, $height-$y, $black);
if ($yscaleval==0) {
ImageLIne($im, $chartx-2, $height-$y,$chartx+$chartw, $height-$y, $black);
}
if ($yscale) {
if ($format) {
$yscaleval = sprintf($imagedata["numberFormat"],$yscaleval);
}
ImageString($im, $font6, $scaleyx, $height-$y-$ifh6/2,$yscaleval,$black);
}
$yscaleval += $yscaleinc;
$y += $yinc;
}
}
$xval = $imagedata["xValues"];
if ($xscale) {
$font5 = 3;
$ifh5 = ImageFontHeight($font5);
$ifw5 = ImageFontWidth($font5);
}
ImageLine($im, $chartx-2, $height-$charty,$chartx+$chartw, $height-$charty, $black);
ImageLine($im, $chartx, $height-$charty+2,$chartx, $height-$charty-$charth-2, $black);
$valuecount = $imagedata["valueCount"];
if ($valuecount && ($xscale || $xval)) {
$xdelta=$chartw/($valuecount*4);
for ($i=0; $i<$valuecount;$i++) {
$xoff= $chartx+($i*4+1)*$xdelta;
$ymax = $height-$charty-$charth*$imagedata["value".$i]/$imagedata["yMax"];
if ($xscale) {
ImageString($im, $font4, $xoff+$xdelta-(strlen($imagedata["scale".$i])*$ifw4)/2,$height-$charty,$imagedata["scale".$i],$black);
}
if ($xval) {
ImageString($im, $font5, $xoff+$xdelta-(strlen($imagedata["value".$i])*$ifw5)/2,$ymax-$ifh5,$imagedata["value".$i],$black);
}
}
}
$linecount = $imagedata["lineCount"];
for ($j=0;$j<$linecount;$j++) {
$valuecount = $imagedata["valueCount"];
$xold=$yold=-1;
if ($valuecount) {
$xdelta=$chartw/($valuecount*2);
for ($i=0; $i<$valuecount;$i++) {
$xoff= $chartx+($i*2+$imagedata["lineOffset"])*$xdelta;
$ymax = $height-$charty-$charth*($imagedata["value".$i."_".$j]-$imagedata["yMin"])/($imagedata["yMax"]-$imagedata["yMin"]);
if ($xold!=-1) {
// echo " $xold, $yold, $xoff, $ymax\n<br>";
ImageLine($im, $xold, $yold, $xoff, $ymax,$colors[$j]);
}
if ($imagedata["bullets"]==1) {
DrawBullet($im, $xoff, $ymax, $j, $colors[$j]);
}
if ($xscale) {
ImageString($im, $font4, $xoff+5,$ymax-$ifh4,$imagedata["value".$i."_".$j],$colors[$j]);
}
$xold=$xoff; $yold=$ymax;
// ImageFilledRectangle($im, $xoff, $ymax, $xoff+2*$xdelta, $height-$charty, $blue);
}
}
}
ImagePNG($im);
ImageDestroy($im);
}
function MakeBarChart($imagedata) {
$id = uniqid("");
$width = $imagedata["width"];
if (!$width) $width=1;
$height = $imagedata["height"];
if (!$height) $height=1;
$chartx = 5;
$charty = 5;
$chartw = $width-10;
$charth = $height-10;
$scaleyx = 0;
$im = imagecreate($width, $height);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
$blue = ImageColorAllocate($im, 0,0,255);
ImageFill($im,0,0,$white);
$caption = $imagedata["caption"];
if ($caption) {
$font1 = 5;
$ifh1 = ImageFontHeight($font1);
$ifw1 = ImageFontWidth($font1);
$captionw = strlen($caption)*$ifw1;
ImageString($im, $font1, ($width - $captionw)/2, 0, $caption, $black);
ImageLine($im, ($width - $captionw)/2, $ifh1, ($width+$captionw)/2, $ifh1, $black);
$charth -= $ifh1;
}
$xcaption = $imagedata["xCaption"];
if ($xcaption) {
$font2 = 4;
$ifh2 = ImageFontHeight($font2);
$ifw2 = ImageFontWidth($font2);
$xcaptionw = strlen($xcaption)*$ifw2;
ImageString($im, $font2, ($width - $xcaptionw)/2, $height-$ifh2, $xcaption, $black);
$charty += $ifh2;
$charth -= $ifh2;
}
$xscale = $imagedata["xScale"];
if ($xscale) {
$font4 = 3;
$ifh4 = ImageFontHeight($font4);
$ifw4 = ImageFontWidth($font4);
$charty += $ifh4;
$charth -= $ifh4;
}
$ycaption = $imagedata["yCaption"];
if ($ycaption) {
$font3 = 4;
$ifh3 = ImageFontHeight($font3);
$ifw3 = ImageFontWidth($font3);
$ycaptionh = strlen($ycaption)*$ifw3;
ImageStringUp($im, $font3, $ifw3, ($height + $ycaptionh)/2, $ycaption, $black);
$chartx += $ifh3+5;
$chartw -= $ifh3+5;
$scaleyx += $ifh3+7;
}
// echo $chartw." ".$chartx." ".$chartw+$chartx."<br>";
$yscale = $imagedata["yScale"];
if ($yscale) {
$font6 = 3;
$ifh6 = ImageFontHeight($font6);
$ifw6 = ImageFontWidth($font6);
if ($imagedata["numberFormat"]) {
$chartx += strlen(sprintf($imagedata["numberFormat"],$imagedata["yMax"]))*$ifw6;
$chartw -= strlen(sprintf($imagedata["numberFormat"],$imagedata["yMax"]))*$ifw6;
} else {
$chartx += strlen($imagedata["yMax"])*$ifw6;
$chartw -= strlen($imagedata["yMax"])*$ifw6;
}
}
$ycount = $imagedata["yCount"];
$format=$imagedata["numberFormat"];
if ($ycount) {
$yinc = $charth/$ycount;
$yscaleinc = $imagedata["yMax"]/$ycount;
$y=$charty;
$yscaleval = 0;
for ($i=0; $i<=$ycount;$i++) {
ImageDashedLine($im, $chartx-2, $height-$y,$chartx+$chartw, $height-$y, $black);
if ($yscale) {
if ($format) {
$yscaleval = sprintf($imagedata["numberFormat"],$yscaleval);
}
ImageString($im, $font6, $scaleyx, $height-$y-$ifh6/2,$yscaleval,$black);
$yscaleval += $yscaleinc;
}
$y += $yinc;
}
}
$xval = $imagedata["xValues"];
if ($xscale) {
$font5 = 3;
$ifh5 = ImageFontHeight($font5);
$ifw5 = ImageFontWidth($font5);
}
ImageLine($im, $chartx-2, $height-$charty,$chartx+$chartw, $height-$charty, $black);
ImageLine($im, $chartx, $height-$charty+2,$chartx, $height-$charty-$charth-2, $black);
$valuecount = $imagedata["valueCount"];
if ($valuecount) {
$xdelta=$chartw/($valuecount*4);
for ($i=0; $i<$valuecount;$i++) {
$xoff= $chartx+($i*4+1)*$xdelta;
$ymax = $height-$charty-$charth*$imagedata["value".$i]/$imagedata["yMax"];
ImageFilledRectangle($im, $xoff, $ymax, $xoff+2*$xdelta, $height-$charty, $blue);
if ($xscale) {
ImageString($im, $font4, $xoff+$xdelta-(strlen($imagedata["scale".$i])*$ifw4)/2,$height-$charty,$imagedata["scale".$i],$black);
}
if ($xval) {
ImageString($im, $font5, $xoff+$xdelta-(strlen($imagedata["value".$i])*$ifw5)/2,$ymax-$ifh5,$imagedata["value".$i],$black);
}
}
}
ImagePNG($im);
ImageDestroy($im);
}
$imagedata["width"] = 400;
$imagedata["height"] = 300;
$imagedata["caption"] = "Test Bar Chart";
$imagedata["xCaption"] = "X-Axis";
$imagedata["xScale"] = 1;
$imagedata["yScale"] = 1;
$imagedata["xValues"] = 1;
$imagedata["yCaption"] = "Y-Axis";
$imagedata["yCount"] = 4;
$imagedata["yMax"] = 400; //required
$imagedata["valueCount"] = 4;
$imagedata["value0"] = 100;
$imagedata["scale0"] = "1/99";
$imagedata["value1"] = 300;
$imagedata["scale1"] = "2/99";
$imagedata["value2"] = 150;
$imagedata["scale2"] = "3/99";
$imagedata["value3"] = 200;
$imagedata["scale3"] = "4/99";
//echo "<img src=\"".MakeBarChart($imagedata)."\">";
*/
?>