initial import without history

This commit is contained in:
Steffen Vogel 2010-08-17 01:23:57 +02:00
commit afedeabeaf
2269 changed files with 157023 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
.settings
.cproject
.project
.classpath

18
.htaccess Normal file
View File

@ -0,0 +1,18 @@
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} (/(?:add|delete|update|ip))\.(xml|html|gif|txt|csv) [OR]
RewriteCond %{REQUEST_FILENAME} (/admin/(?:cleanup|sync|parse))\.(xml|html|gif|txt|csv) [OR]
RewriteCond %{REQUEST_FILENAME} (/admin/get)\.(xml|html|gif|txt|csv|png) [OR]
RewriteCond %{REQUEST_FILENAME} (/admin/stats/types)\.(xml|html|gif|txt|csv|png)
RewriteRule .* %1.php?format=%2 [QSA]
RewriteCond %{QUERY_STRING} !zone=(0l.de|d.eta.li)
RewriteCond %{HTTP_HOST} (0l.de|d.eta.li)$ [NC]
RewriteRule (.*)(\?)? $1?zone=%1 [QSA]
RewriteCond %{QUERY_STRING} !host=[a-z0-9.-]+
RewriteCond %{HTTP_HOST} !^(d|dns|sddns|u|url)\.(0l.de|d.eta.li)$ [NC]
RewriteCond %{HTTP_HOST} ([a-z0-9.-]+)\.(0l.de|d.eta.li)$ [NC]
RewriteRule (.*) $1?host=%1 [QSA]
ExpiresActive Off

69
add.php Executable file
View File

@ -0,0 +1,69 @@
<?php
require_once 'include/init.php';
if (array_key_exists($_REQUEST['zone'], $config['sddns']['zones'])) {
$zone = $config['sddns']['zones'][$_REQUEST['zone']];
$host = (empty($_REQUEST['host'])) ? Host::unique($zone, $db) : new Host($_REQUEST['host'], $zone);
$pw = (empty($_REQUEST['pw'])) ? randomString(8) : $_REQUEST['pw'];
if (empty($_REQUEST['lifetime']) || !is_int($_REQUEST['lifetime'])) {
$lifetime = $config['sddns']['std']['lifetime'];
}
else {
$lifetime = (int) $_REQUEST['lifetime'];
}
if (($lifetime > $config['sddns']['max_lifetime'] && !isAuthentificated()) || $lifetime < 0) {
$output->add('invalid lifetime', 'error', $lifetime);
}
if ($host->isRegistred($db)) {
$host = new DBHost($host->isRegistred($db), $db);
$output->add('found existing host' ,'notice', $host);
if (!$host->checkPassword($pw)) {
$output->add('not authentificated for host', 'error', $host);
die();
}
}
else {
$host = $host->add($pw, $db); // returns new DBHost
$output->add('host added to db' ,'notice', $host);
if (empty($_REQUEST['pw']))
$output->add('generated password' ,'notice', $pw);
}
$type = (empty($_REQUEST['type'])) ? $config['sddns']['std']['type'] : $_REQUEST['type'];
$rdata = (empty($_REQUEST['rdata']) && $type = 'A') ? $_SERVER['REMOTE_ADDR'] : $_REQUEST['rdata'];
if ($type != 'URL') { // pseudo type to create url redirection
$ttl = (empty($_REQUEST['ttl'])) ? $config['sddns']['std']['ttl'] : (int) $_REQUEST['ttl'];
$class = (empty($_REQUEST['class'])) ? $config['sddns']['std']['class'] : $_REQUEST['class'];
$record = new Record($host, $ttl, $class, $type, $rdata);
if (!$record->isRegistred($db)) {
$record = $record->add($db, $lifetime);
$output->add('record added to db', 'success', $record);
$zone->cleanup($db);
$zone->sync($db);
}
else {
$output->add('record already exists in db', 'error', $record);
die();
}
}
else {
$uri = new Uri($rdata, $host);
$uri = $uri->add($db, $lifetime);
$output->add('uri redirection added to db', 'success', $uri);
}
}
else {
$output->add('zone not found', 'error', $_REQUEST['zone']);
}
?>

6
admin/.htaccess Normal file
View File

@ -0,0 +1,6 @@
AuthType Basic
AuthName "Administration area"
AuthUserFile /var/www/nulll/.htpasswd
AuthGroupFile /var/www/nulll/.htgroups
Require group admins

21
admin/cleanup.php Executable file
View File

@ -0,0 +1,21 @@
<?php
require_once dirname(__FILE__) . '/../include/init.php';
if (empty($_REQUEST['zone']) || $_REQUEST['zone'] == 'all') {
$zones = $config['sddns']['zones'];
}
elseif (isset($config['sddns']['zones'][$_REQUEST['zone']])) {
$zones = array($config['sddns']['zones'][$_REQUEST['zone']]);
}
else {
$output->add('no such zone', 'error', $_REQUEST['zone']);
}
foreach ($zones as $zone) {
$output->add('cleaning zone', 'notice', $zone);
$zone->cleanup($db);
}
?>

203
admin/get.php Executable file
View File

@ -0,0 +1,203 @@
<?php
require_once '../include/init.php';
$dataTables = array(
'hosts' => null, // table name => date field
'records' => 'created',
'queries' => 'queried',
'logs' => 'logged',
'uris' => 'created'
);
$colors = array(
'records' => 'midnightblue',
'queries' => 'red',
'logs' => 'orange',
'uris' => 'black'
);
if (@!empty($_REQUEST['data'])) {
$tmps = explode(',', trim($_REQUEST['data'], ' ,'));
foreach ($tmps as $tmp) {
if (in_array(trim($tmp), array_keys($dataTables)) && !($output instanceof GraphOutput && !$dataTables[trim($tmp)]))
$get[] = trim($tmp);
}
}
else {
$get = array('queries');
}
if ($output instanceof GraphOutput) {
require_once $site['path']['server'] . '/include/jpgraph/jpgraph_line.php';
require_once $site['path']['server'] . '/include/jpgraph/jpgraph_date.php';
$perModes = array(
'hour' => false, // mySQL funtion => is timestamp
'day' => false,
'date' => true,
'week' => false,
'month' => false,
'weekday' => false
);
if (@isset($_REQUEST['per'])) {
if (in_array($_REQUEST['per'], array_keys($perModes)))
$per = $_REQUEST['per'];
}
else {
$per = 'date';
}
$graph = $output->getGraph(700, 300);
$graph->img->SetAntiAliasing();
if ($perModes[$per]) {
$graph->SetScale('datint');
$graph->xaxis->scale->SetTimeAlign(HOURADJ_1);
$graph->xaxis->scale->SetDateFormat( 'M y' );
$graph->xaxis->SetLabelAngle(45);
}
else {
$graph->SetScale('intint');
$graph->xaxis->SetLabelFormatCallback(function($label) {
global $per;
switch ($per) {
case 'month':
return date('M', mktime(0, 0, 0, $label));
break;
case 'weekday':
return date('l', mktime(0, 0, 0, 3, $label + 1, 2010));
break;
default:
return $label;
}
});
}
$graph->SetMargin(80,60,30,30);
$graph->title->Set(implode(', ', $get) . '/' . $per);
$graph->legend->SetAbsPos(10, 10, 'right', 'top');
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 14);
$graph->yaxis->SetFont(FF_VERDANA, FS_NORMAL, 10);
$graph->xaxis->SetFont(FF_VERDANA, FS_NORMAL, 10);
$graph->yaxis->title->SetFont(FF_VERDANA, FS_NORMAL, 12);
$graph->xaxis->title->SetFont(FF_VERDANA, FS_NORMAL, 12);
$graph->yaxis->title->SetOrientation(90);
$graph->SetBackgroundGradient('white', 'white');
$graph->xaxis->title->Set('date');
$graph->yaxis->title->Set(implode(',', $get) . '/' . $per);
$graph->yaxis->SetLabelFormatCallback(function($label) { return ($label > 1000) ? round($label / 1000) . 'k' : $label; });
$graph->yaxis->SetTitleMargin(50);
$graph->xaxis->SetTitleMargin(17);
// fetch data & create plot
foreach ($get as $table) {
unset($plotData);
$result = $db->query('SELECT ' . strtoupper($per) . '(' . $dataTables[$table] . ') AS day, COUNT(*) AS count FROM ' . $table . ' GROUP BY day');
foreach ($result as $date) {
$plotData['x'][] = $date['day'];
$plotData['y'][] = $date['count'];
}
if ($perModes[$per])
array_walk($plotData['x'], function(&$value) { $value = strtotime($value); });
$plot = new LinePlot($plotData['y'], $plotData['x']);
$plot->SetColor($colors[$table]);
$plot->SetLegend($table);
$plot->SetLineWeight(2);
$graph->Add($plot);
}
$output->showGraph();
}
else {
switch ($get[0]) {
case 'hosts':
$filter = array();
if (array_key_exists($_REQUEST['zone'], $config['sddns']['zones'])) {
$filter['zone'] = $config['sddns']['zones'][$_REQUEST['zone']];
if (!empty($_REQUEST['host'])) {
$filter['host'] = $_REQUEST['host'];
}
}
$data = DBHost::get($db, $filter);
$dateField = null;
break;
case 'logs':
$data = $db->query('SELECT logged, id, program, message FROM logs ORDER BY logged DESC', 1000);
$dateField = 'logged';
break;
case 'queries':
$data = $db->query('SELECT queried, id, ip, port, hostname, class, type, options FROM queries ORDER BY queried DESC', 1000);
$dateField = 'queried';
break;
case 'uris':
$filter = array();
if (array_key_exists($_REQUEST['zone'], $config['sddns']['zones'])) {
$filter['zone'] = $config['sddns']['zones'][$_REQUEST['zone']];
if (!empty($_REQUEST['host'])) {
$filter['host'] = $_REQUEST['host'];
}
}
$data = DBUri::get($db, $filter);
$dateField = 'created';
break;
case 'records':
default:
$filter = array();
if (array_key_exists($_REQUEST['zone'], $config['sddns']['zones'])) {
$filter['zone'] = $config['sddns']['zones'][$_REQUEST['zone']];
if (!empty($_REQUEST['host'])) {
$filter['host'] = $_REQUEST['host'];
}
}
if (!empty($_REQUEST['class']) && in_array($_REQUEST['class'], $config['sddns']['classes']))
$filter['class'] = $_REQUEST['class'];
if (!empty($_REQUEST['ttl']))
$filter['ttl'] = (int) $_REQUEST['ttl'];
if (!empty($_REQUEST['type']) && in_array($_REQUEST['type'], $config['sddns']['types'])) {
$filter['type'] = $_REQUEST['type'];
if (!empty($_REQUEST['rdata']) && Record::isRData($_REQUEST['rdata'], $filter['type']))
$filter['rdata'] = $_REQUEST['rdata'];
}
$data = DBRecord::get($db, $filter);
$dateField = 'created';
}
foreach ($data as $row) {
switch (@$_REQUEST['data']) {
case 'uris':
$output->add('', 'data', $row->host, $row);
break;
case 'hosts':
case 'logs':
case 'queries':
case 'records':
default:
$output->add('', 'data', $row);
}
}
}
?>

62
admin/parse.php Executable file
View File

@ -0,0 +1,62 @@
<?php
require_once dirname(__FILE__) . '/../include/init.php';
$sql = 'SELECT *
FROM logs
WHERE
program = \'named\'
LIMIT 10000';
$result = $db->query($sql);
$pattern = '/^named\[(\d+)\]: queries: info: client ([.\d]+)#(\d+): query: ([.-\w]+) ([A-Z]+) ([A-Z]+) (.*)$/';
$sqlDelete = 'DELETE FROM logs WHERE id IN (';
$queries = array();
$c = 0; $u = 0;
foreach ($result as $log) {
if (preg_match($pattern, $log['message'], $matches)) {
$query = array('ip' => new IpV4($matches[2]),
'port' => (int) $matches[3],
'hostname' => $matches[4],
'class' => $matches[5],
'type' => $matches[6],
'options' => $matches[7],
'log_id' => $log['id'],
'queried' => strtotime($log['logged']));
$db->execute('INSERT IGNORE INTO queries (ip, port, hostname, class, type, options, queried, log_id) VALUES (\'' . $query['ip'] . '\', ' . $query['port'] . ', \'' . $query['hostname'] . '\', \'' . $query['class'] . '\', \'' . $query['type'] . '\', \'' . $query['options'] . '\', \'' . date('Y-m-d H:i:s', $query['queried']) . '\', ' . $query['log_id'] . ')');
$c++;
$sqlDelete .= $query['log_id'] . ', ';
$output->add('query parsed', 'debug', 3, $query);
foreach ($config['sddns']['zones'] as $zone) {
if (substr($query['hostname'], -strlen($zone->name)) == $zone->name && strlen($query['hostname']) > strlen($zone->name)) {
$filter = array('class' => $query['class'],
'type' => $query['type'],
'host' => substr($query['hostname'], 0, -(strlen($zone->name) + 1)),
'zone' => $zone);
$records = DBRecord::get($db, $filter);
foreach ($records as $record) {
$record->lastAccessed = $query['queried'];
$record->update();
$output->add('record renewed', 'notice', 1,$record);
}
}
}
}
}
if ($c > 0) {
$db->execute(substr($sqlDelete, 0, -2) . ')');
$output->add('parsed queries', 'success', $c);
}
else {
$output->add('no queries to parse', 'warning');
}
?>

21
admin/query.php Executable file
View File

@ -0,0 +1,21 @@
<?php
require_once '../include/init.php';
$ns = new NameServer($config['sddns']['ns']['hostname'], $config['sddns']['ns']['port']);
if (empty($_REQUEST['query'])) {
//throw new UserException('missing query hostname!');
}
$type = (empty($_REQUEST['type'])) ? 'A' : $_REQUEST['type'];
$class = (empty($_REQUEST['class'])) ? 'IN' : $_REQUEST['class'];
//$results = $ns->query($_REQUEST['query'], $type, $class);
$zone = $config['sddns']['zones']['0l.de'];
$results = $zone->getRecordsFromNS();
foreach ($results as $result) {
$output->add('', 'data', $result);
}
?>

11
admin/stats/hosts.php Executable file
View File

@ -0,0 +1,11 @@
<?php
require_once '../../include/init.php';
$result = $db->query('SELECT DISTINCT hostname, COUNT(hostname) AS sum FROM queries GROUP BY hostname ORDER BY sum DESC', (empty($_GET['n'])) ? 1000 : (int) $_GET['n']);
foreach ($result as $row) {
$output->add($row['hostname'], 'data', $row['sum']);
}
?>

46
admin/stats/types.php Executable file
View File

@ -0,0 +1,46 @@
<?php
require_once '../../include/init.php';
$result = $db->query('SELECT COUNT(*) AS count FROM queries', 1)->first();
$count = $result['count'];
$result = $db->query('SELECT type, COUNT(id) AS sum FROM queries GROUP BY type ORDER BY sum DESC');
if ($output instanceof GraphOutput) {
require_once $site['path']['server'] . '/include/jpgraph/jpgraph_pie.php';
$data = array();
$graph = $output->getGraph(500, 400, 'pie');
foreach ($result as $type) {
$data[] = $type['sum'];
$legend[] = $type['type'];
}
$graph->title->Set('record types');
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 14);
$graph->legend->SetFont(FF_VERDANA, FS_NORMAL, 10);
$graph->SetAntiAliasing();
$pie = new PiePlot($data);
$pie->value->SetFont(FF_VERDANA, FS_NORMAL, 9);
$pie->value->SetColor('black');
$pie->SetLabelPos(0.7);
$pie->setLegends($legend);
$pie->setTheme('sand');
$pie->SetGuideLines(true, false);
$pie->SetGuideLinesAdjust(1.4);
$pie->setCenter(0.32, 0.5);
$graph->Add($pie);
$output->showGraph();
}
else {
foreach ($result as $row) {
$output->add($row['type'], 'data', round(($row['sum'] / $count) * 100, 5) . ' %', $row['sum']);
}
}
?>

18
admin/sync.php Executable file
View File

@ -0,0 +1,18 @@
<?php
require_once dirname(__FILE__) . '/../include/init.php';
if (empty($_REQUEST['zone']) || $_REQUEST['zone'] == 'all') {
$zones = $config['sddns']['zones'];
}
else {
$zones = array($config['sddns']['zones'][$_REQUEST['zone']]);
}
foreach ($zones as $zone) {
$output->add('syncing zone', 'notice', $zone);
$zone->sync($db);
}
?>

60
delete.php Executable file
View File

@ -0,0 +1,60 @@
<?php
require_once 'include/init.php';
$pw = @$_REQUEST['pw'];
if (array_key_exists($_REQUEST['zone'], $config['sddns']['zones'])) {
$zone = $config['sddns']['zones'][$_REQUEST['zone']];
if (!empty($_REQUEST['host'])) {
$host = reset(DBHost::get($db, array('host' => $_REQUEST['host'], 'zone' => $zone)));
if (!empty($host)) {
if ($host->checkPassword($pw) || isAuthentificated()) {
if (!empty($_REQUEST['class']) && in_array($_REQUEST['class'], $config['sddns']['classes']))
$class = $_REQUEST['class'];
if (!empty($_REQUEST['type']) && in_array($_REQUEST['type'], $config['sddns']['types'])) {
$type = $_REQUEST['type'];
if (!empty($_REQUEST['rdata']) && Record::isRData($_REQUEST['rdata'], $type))
$rdata = $_REQUEST['rdata'];
}
if (@$type == 'URL' || empty($type)) {
$uris = DBUri::get($db, array('zone' => $zone, 'host' => $host));
foreach ($uris as $uri) {
$uri->delete();
$output->add('uri deleted from db', 'success', $uri);
}
}
if (@$type != 'URL' || empty($type)) {
$records = DBRecord::get($db, array('zone' => $zone, 'host' => $host, 'type' => @$type, 'class' => @$class, 'rdata' => @$rdata));
foreach ($records as $record) {
$record->delete();
$output->add('record deleted from db', 'success', $record);
}
}
$zone->cleanup($db);
$zone->sync($db);
}
else {
$output->add('not authentificated for host', 'error', $host);
}
}
else {
$output->add('host not found', 'error', $_REQUEST['host']);
}
}
else {
$output->add('no host specified', 'error');
}
}
else {
$output->add('zone not found', 'error', $_REQUEST['zone']);
}
?>

102
expert.php Executable file
View File

@ -0,0 +1,102 @@
<?php
require_once 'include/init.php';
$output->add('hits since launch', 'notice', $site['hits']);
if (isAuthentificated()) {
$output->add('authetificated as', 'notice', $_SERVER['PHP_AUTH_USER']);
}
$ttl = (isset($_REQUEST['ttl'])) ? $_REQUEST['ttl'] : $config['sddns']['std']['ttl'];
$lifetime = (isset($_REQUEST['lifetime'])) ? $_REQUEST['lifetime'] : $config['sddns']['std']['lifetime'];
$checkedClass = (isset($_REQUEST['class'])) ? $_REQUEST['class'] : $config['sddns']['std']['class'];
$checkedType = (isset($_REQUEST['type'])) ? $_REQUEST['type'] : $config['sddns']['std']['type'];
?>
<div id="expert">
<div style="float: right;"><a href="images/0l.png"><img src="images/0l_small.png" alt="0l" /></a></div>
<h1>Tiny DNS & URL</h1>
<h3>aka SDDNS - <b>S</b>imple <b>D</b>ynamic <b>D</b>omain <b>N</b>ame <b>S</b>ervice</h3>
<p>by <a href="http://www.steffenvogel.de">Steffen Vogel</a></p>
<hr style="clear: both;" />
<form onsubmit="submit_expert(this);" method="post">
<table>
<tr>
<td><label for="command">operation</label></td>
<td><select name="command" size="1">
<?php
foreach ($config['sddns']['cmds'] as $cmd) {
echo '<option' . ((@$_REQUEST['command'] == $cmd) ? ' selected="selected"' : '') . ' value="' . $cmd . '">' . $cmd . '</option>';
}
?>
</select></td>
</tr>
<tr>
<td><label for="format">format</label></td>
<td><select name="format" size="1">
<?php
foreach ($config['sddns']['formats'] as $format) {
echo '<option value="' . $format . '">' . $format . '</option>';
}
?>
<option><i>none</i></option></select></td>
<td><input type="checkbox" name="debug" value="1" /> include debugging information</td>
</tr>
<tr><td><label for="host">hostname</label></td><td><input type="text" name="host" value="<?= @$_REQUEST['host'] ?>" />.<select name="zone" size="1">';
<?php
foreach ($config['sddns']['zones'] as $zone) {
echo '<option' . (($_REQUEST['zone'] == $zone->name) ? ' selected="selected"' : '') . ' value="' . $zone->name . '">' . $zone->name . '</option>';
}
?>
</select></td><td>optional; random or servername</td></tr>
<tr><td><label for="ttl">ttl</label></td><td><input type="text" name="ttl" value="<?= $ttl ?>" /> seconds</td><td>time to live in cache; max <?= $config['sddns']['max_ttl'] ?> seconds</td></tr>
<tr><td><label for="lifetime">lifetime</label></td><td><input type="text" name="lifetime" value="<?= $lifetime ?>" /> seconds</td><td>lifetime of a record/url without an update; max <?= $config['sddns']['max_lifetime'] ?></td></tr>
<tr>
<td><label for="class">class</label></td>
<td><select name="class" size="1">
<?php
foreach ($config['sddns']['classes'] as $class) {
echo '<option' . (($class == $checkedClass) ? ' selected="selected"' : '') . ' value="' . $class . '">' . $class . '</option>';
}
?>
<option><i>all</i></option></select></td>
</tr>
<tr>
<td><label for="type">type</label></td>
<td><select name="type" size="1">
<?php
foreach ($config['sddns']['types'] as $type) {
echo '<option' . (($type == $checkedType) ? ' selected="selected"' : '') . ' value="' . $type . '">' . $type . '</option>';
}
?>
<option><i>all</i></option></select></td>
</tr>
<tr><td><label for="rdata">rdata</label></td><td><input value="<?= (empty($_REQUEST['rdata']) && $checkedType == 'A') ? $_SERVER['REMOTE_ADDR'] : @$_REQUEST['rdata'] ?>" type="text" name="rdata" /></td><td></td></tr>
<?php
if (!isAuthentificated()) // admin needs no password
echo '<tr><td><label for="pw">password</label></td><td><input type="password" name="pw" /></td><td>optional; random generated</td></tr>';
?>
</table>
<input type="submit" />
<p>
<a href="simple">simple mode</a> -
<a href="http://0l.de/projects/sddns/usage">usage</a> -
<a href="http://0l.de/projects/sddns/">wiki</a> -
<a href="javascript:u='http://d.0l.de/add.html?type=URL&rdata='+encodeURIComponent(location.href);h=encodeURIComponent(window.getSelection().toString().replace(/[\s\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2E\x2F\x3A\x3B\x3C\x3D\x3F\x40\x5B\x5C\x5D\x5E\x5F\x60\x7B\x7C\x7C\x7D\x7E]+/gi,'-').replace(/^\-+/,'').replace(/\-+$/,''));if(!h){h=prompt('Subdomain','');}if(h){u+='&host='+h;}location.href=u">bookmarklet</a> -
<a href="javascript:installSearchEngine('<?= $site['url']?>/opensearch.xml');">search plugin</a>
</form>
<hr />
<address><?= $_SERVER['SERVER_SIGNATURE'] ?></address>
</div>

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 894 B

BIN
favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 B

BIN
images/0l.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

BIN
images/0l_small.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
images/bookmarklet.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
images/data.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

BIN
images/debug.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 774 B

BIN
images/error.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

BIN
images/exception.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 B

BIN
images/notice.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 778 B

BIN
images/success.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 781 B

BIN
images/warning.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 666 B

38
include/config.php Executable file
View File

@ -0,0 +1,38 @@
<?php
$config['path']['web'] = '';
$config['db']['host'] = 'localhost';
$config['db']['user'] = 'sddns';
$config['db']['pw'] = '29111954Af';
$config['db']['db'] = 'st_sddns';
$config['db']['tbl']['prefix'] = '';
$config['db']['tbl']['records'] = $config['db']['tbl']['prefix'] . 'records';
$config['db']['tbl']['hosts'] = $config['db']['tbl']['prefix'] . 'hosts';
$config['db']['tbl']['uris'] = $config['db']['tbl']['prefix'] . 'uris';
$config['sddns']['htpasswd'] = $site['path']['server'] . '/../.htpasswd';
$key = array('hmac' => 'gDlXSZtESw78I47O68UEigpPofn0XbpSpo5Vba+9IY38EYagPO/2C2Ch lZL+AvtN/ozRdra+p3+wLOKvVvqdrA==', 'name' => 'info.steffenvogel.de.');
$zones = array('0l.de', 'd.eta.li');
$config['sddns']['ns']['hostname'] = 'ns0.0l.de';
$config['sddns']['ns']['port'] = 53;
foreach ($zones as $zone) {
$config['sddns']['zones'][$zone] = new Zone($config['sddns']['ns']['hostname'], $zone, $key, $config['sddns']['ns']['port']);
}
$config['sddns']['max_lifetime'] = 6 * 30 * 24 * 60 * 60; // in seconds; 6 months
$config['sddns']['max_ttl'] = 60 * 60; // in seconds; 1 hour
$config['sddns']['classes'] = array('IN', 'CH', 'HS');
$config['sddns']['types'] = array('A', 'AAAA', 'NS', 'TXT', 'MX', 'SRV', 'CNAME', 'LOC', 'HINFO', 'URL' /* pseudo type for url redirection */);
$config['sddns']['std']['class'] = 'IN';
$config['sddns']['std']['type'] = 'A';
$config['sddns']['std']['ttl'] = 2 * 60; // in seconds; 2 minutes; < max_ttl!
$config['sddns']['std']['lifetime'] = 1 * 30 * 24 * 60 * 60; // in seconds; 1 month; < max_lifetime!
$config['sddns']['cmds'] = array('add', 'delete', 'update'); // available cmds
$config['sddns']['formats'] = array('html', 'xml', 'gif', 'txt', 'csv'); // available formats (keep in sync with .htaccess!)
?>

144
include/db.php Executable file
View File

@ -0,0 +1,144 @@
<?php
/**
* @brief base exception for database queries
*/
class DatabaseException extends CustomException {}
/**
* @brief abstract resultset definition
*/
abstract class DBResultSet implements Iterator {
/**
* @brief rowcount of the result
* @var int
*/
protected $_num_rows = 0;
/**
* @brief result
* @var array
*/
protected $_rows = array();
/**
* @param resource $resource database resource
*/
abstract function __construct($resource);
/**
* @brief current element (iterator)
* @return array
*/
public function current() {
return current($this->_rows);
}
/**
* @brief next element (iterator)
* @return array
*/
public function next() {
return next($this->_rows);
}
/**
* @brief index of current element (iterator)
* @return array
*/
public function key() {
return key($this->_rows);
}
/**
* @brief first element (pointer reset, iterator)
* @return array
*/
public function rewind() {
return reset($this->_rows);
}
/**
* @brief check current element (iterator)
* @return bool
*/
public function valid() {
return (bool) is_array($this->current());
}
public function first() {
return (isset($this->_rows[0])) ? $this->_rows[0] : null;
}
public function last() {
return $this->_rows[$this->_num_rows - 1];
}
public function count() {
return $this->_num_rows;
}
}
/**
* @brief interface database definition
*/
interface IDatabase {
/**
* @brief create database connection
* @param string $host IP or domain of the database host
* @param string $user user
* @param string $passwd password
*/
public function connect($host, $user, $pw);
/**
* @brief close database connection
*/
public function close();
/**
* @brief select database
* @param string $name name of database
*/
public function select($db);
/**
* @brief execute query
* @param string $sql query
* @return mixed
*/
public function execute($sql);
/**
* @brief query
* @param string $sql
* @param int $offset
* @param int $limit
* @return TDatabaseResultSet
*/
public function query($sql, $limit = -1, $offset = 0);
}
/**
* @brief abstract database layer definition
*/
abstract class Database implements IDatabase {
/**
* @brief current database
* @var string
*/
protected $database = '';
/**
* @brief database handle
* @var resource
*/
protected $resource = false;
/**
* @brief container with exectuted queries
* @var array
*/
protected $statements = array();
}
?>

123
include/dbhost.php Executable file
View File

@ -0,0 +1,123 @@
<?php
class DBHost extends Host implements DBObject {
public $id;
public $generated;
private $password;
private $db;
public function __construct($id, Database $db) {
$config = Registry::get('config');
$this->db = $db;
$sql = 'SELECT * FROM ' . $config['db']['tbl']['hosts'] . ' WHERE id = ' . (int) $id;
$result = $this->db->query($sql, 1);
if ($result->count() == 1) {
$host = $result->first();
$this->id = $host['id'];
parent::__construct($host['hostname'], $config['sddns']['zones'][$host['zone']], $host['generated']);
}
else {
throw new CustomException('Host with id ' . $id . ' not found!');
}
}
public function __destruct() {
//$this->update();
}
public function update() {
$config = Registry::get('config');
$sql = 'UPDATE ' . $config['db']['tbl']['hosts'] . '
SET
hostname = \'' . $this->db->escape($this->toPunycode()) . '\',
zone = \'' . $this->db->escape($this->zone->name) . '\',
password = \'' . $this->db->escape($this->password) . '\',
generated = \'' .$this->db->escape( $this->generated) . '\'
WHERE id = ' . (int) $this->id;
$this->db->execute($sql);
}
public function delete() {
$config = Registry::get('config');
if ($this->getRecordsFromDB() > 0) {
throw new UserException('Host has records!');
}
elseif ($this->getUrisFromDB() > 0) {
throw new UserException('Host has uris!');
}
else {
$sql = 'DELETE FROM ' . $config['db']['tbl']['hosts'] . '
WHERE id = ' . (int) $this->id;
$this->db->execute($sql);
}
}
public function checkPassword($pw) {
$config = Registry::get('config');
$sql = 'SELECT password
FROM ' . $config['db']['tbl']['hosts'] . '
WHERE hostname = \'' . $this->db->escape($this->toPunycode()) . '\' && zone = \'' . $this->db->escape($this->zone->name) . '\'';
$result = $this->db->query($sql, 1);
$entry = $result->first();
return ($entry['password'] === sha1($pw)) && !empty($pw);
}
public function getRecordsFromDB() {
return DBRecord::get($this->db, array('host' => $this));
}
public function getUrisFromDB() {
return DBRUri::get($this->db, array('host' => $this));
}
public static function get(Database $db, $filter = false) {
$config = Registry::get('config');
$sql = 'SELECT id
FROM ' . $config['db']['tbl']['hosts'] . '
WHERE true';
if (!empty($filter['id']))
$sql .= ' && id = ' . (int) $filter['id'];
if (!empty($filter['host']) && is_string($filter['host']))
$sql .= ' && hostname = \'' . $db->escape($filter['host']) . '\'';
if (!empty($filter['zone']) && $filter['zone'] instanceof Zone)
$sql .= ' && zone = \'' . $db->escape($filter['zone']->name) . '\'';
if (!empty($filter['zone']) && is_string($filter['zone']))
$sql .= ' && zone = \'' . $db->escape($filter['zone']->name) . '\'';
if (!empty($filter['generated']))
$sql .= ' && generated = ' . ($filter['generated']) ? '1' : '0';
$sql .= ' ORDER BY id ASC';
$result = $db->query($sql);
$hosts = array();
foreach ($result as $host) {
$hosts[] = new self($host['id'], $db);
}
return $hosts;
}
/*
* Output
*/
public function toXml(DOMDocument $doc) {
$xmlRecord = parent::toXml($doc);
$xmlRecord->setAttribute('id', $this->id);
return $xmlRecord;
}
}
?>

11
include/dbobject.php Executable file
View File

@ -0,0 +1,11 @@
<?php
interface DBObject extends Object {
public static function get(Database $db, $filter);
public function delete();
public function __destruct();
public function update();
}
?>

113
include/dbrecord.php Executable file
View File

@ -0,0 +1,113 @@
<?php
class DBRecord extends Record implements DBObject {
public $id;
public $lifetime;
public $lastAccessed;
private $db;
public function __construct($id, Database $db) {
$config = Registry::get('config');
$this->db = $db;
$sql = 'SELECT *
FROM ' . $config['db']['tbl']['records'] . '
WHERE id = ' . (int) $id;
$result = $this->db->query($sql, 1);
$record = $result->first();
$this->id = $record['id'];
$this->lastAccessed = strtotime($record['last_accessed']);
$this->lifetime = $record['lifetime'];
$this->host = new DBHost($record['host_id'], $this->db);
parent::__construct($this->host, (int) $record['ttl'], $record['class'], $record['type'], $record['rdata']);
}
public function __destruct() {
//$this->update();
}
public function update() {
$config = Registry::get('config');
$sql = 'UPDATE ' . $config['db']['tbl']['records'] . '
SET
lifetime = ' . (int) $this->lifetime . ',
last_accessed = \'' . date('Y-m-d H:i:s', $this->lastAccessed) . '\',
host_id = \'' . $this->db->escape($this->host->id) . '\',
ttl = ' . (int) $this->ttl . ',
class = \'' . $this->db->escape($this->class) . '\',
type = \'' . $this->db->escape($this->type) . '\',
rdata = \'' . $this->db->escape( $this->rdata) . '\'
WHERE id = ' . (int) $this->id;
$this->db->execute($sql);
}
public function toXml(DOMDocument $doc) {
$xmlRecord = parent::toXml($doc);
$xmlRecord->setAttribute('id', $this->id);
$xmlRecord->appendChild($doc->createElement('lifetime', $this->lifetime));
$xmlRecord->appendChild($doc->createElement('lastaccessed', $this->lastAccessed));
return $xmlRecord;
}
public function delete() {
$config = Registry::get('config');
$sql = 'DELETE FROM ' . $config['db']['tbl']['records'] . '
WHERE id = ' . (int) $this->id;
$this->db->execute($sql);
}
public static function get(Database $db, $filter = false) {
$config = Registry::get('config');
$sql = 'SELECT r.id
FROM ' . $config['db']['tbl']['records'] . ' AS r
LEFT JOIN ' . $config['db']['tbl']['hosts'] . ' AS h
ON h.id = r.host_id
WHERE true';
if (!empty($filter['id']))
$sql .= ' && id = ' . (int) $filter['id'];
if (!empty($filter['host']) && $filter['host'] instanceof Host)
$sql .= ' && host_id = ' . (int) $filter['host']->isRegistred($db);
if (!empty($filter['host']) && $filter['host'] instanceof DBHost)
$sql .= ' && host_id = ' . (int) $filter['host']->id;
if (!empty($filter['host']) && is_string($filter['host']))
$sql .= ' && hostname = \'' . $db->escape($filter['host']) . '\'';
if (!empty($filter['zone']) && $filter['zone'] instanceof Zone)
$sql .= ' && zone = \'' . $db->escape($filter['zone']->name) . '\'';
if (!empty($filter['zone']) && is_string($filter['zone']))
$sql .= ' && zone = \'' . $db->escape($filter['zone']->name) . '\'';
if (!empty($filter['type']))
$sql .= ' && type = \'' . $db->escape($filter['type']) . '\'';
if (!empty($filter['class']))
$sql .= ' && class = \'' . $db->escape($filter['class']) . '\'';
if (!empty($filter['rdata']))
$sql .= ' && rdata = \'' . $db->escape($filter['rdata']) . '\'';
if (!empty($filter['ttl']))
$sql .= ' && ttl = ' . (int) $filter['ttl'];
$sql .= ' ORDER BY r.id ASC';
$result = $db->query($sql);
$records = array();
foreach ($result as $record) {
$records[] = new self($record['id'], $db);
}
return $records;
}
}
?>

106
include/dburi.php Executable file
View File

@ -0,0 +1,106 @@
<?php
class DBUri extends Uri implements DBObject {
public $id;
public $lifetime;
public $lastAccessed;
public $accessed;
private $db;
public function __construct($id, Database $db) {
$config = Registry::get('config');
$this->db = $db;
$sql = 'SELECT *
FROM ' . $config['db']['tbl']['uris'] . '
WHERE id = ' . (int) $id;
$result = $this->db->query($sql, 1);
$uri = $result->first();
$this->id = $uri['id'];
$this->lastAccessed = strtotime($uri['last_accessed']);
$this->lifetime = $uri['lifetime'];
$this->accessed = $uri['accessed'];
$this->host = new DBHost($uri['host_id'], $this->db);
parent::__construct($uri['uri'], $this->host);
}
public function __destruct() {
//$this->update();
}
public function update() {
$config = Registry::get('config');
$sql = 'UPDATE ' . $config['db']['tbl']['uris'] . '
SET
host_id = ' . (int) $this->host->id . ',
uri = \'' . $this->db->escape($this->uri) . '\',
accessed = ' . (int) $this->accessed . ',
last_accessed = \'' . date('Y-m-d H:i:s', $this->lastAccessed) . '\',
lifetime = ' . (int) $this->lifetime . '
WHERE id = ' . (int) $this->id;
$this->db->execute($sql);
}
public function toXml(DOMDocument $doc) {
$xmlUri = parent::toXml($doc);
$xmlUri->setAttribute('id', $this->id);
$xmlUri->appendChild($doc->createElement('lifetime', $this->lifetime));
$xmlUri->appendChild($doc->createElement('lastaccessed', $this->lastAccessed));
return $xmlUri;
}
public function delete() {
$config = Registry::get('config');
$sql = 'DELETE FROM ' . $config['db']['tbl']['uris'] . '
WHERE id = ' . (int) $this->id;
$this->db->execute($sql);
}
public static function get(Database $db, $filter = false) {
$config = Registry::get('config');
$sql = 'SELECT u.id
FROM ' . $config['db']['tbl']['uris'] . ' AS u
LEFT JOIN ' . $config['db']['tbl']['hosts'] . ' AS h
ON h.id = u.host_id
WHERE true';
if (!empty($filter['id']))
$sql .= ' && id = ' . (int) $filter['id'];
if (!empty($filter['host']) && $filter['host'] instanceof Host)
$sql .= ' && host_id = ' . (int) $filter['host']->isRegistred($db);
if (!empty($filter['host']) && $filter['host'] instanceof DBHost)
$sql .= ' && host_id = ' . (int) $filter['host']->id;
if (!empty($filter['host']) && is_string($filter['host']))
$sql .= ' && hostname = \'' . $db->escape($filter['host']) . '\'';
if (!empty($filter['zone']) && $filter['zone'] instanceof Zone)
$sql .= ' && zone = \'' . $db->escape($filter['zone']->name) . '\'';
if (!empty($filter['zone']) && is_string($filter['zone']))
$sql .= ' && zone = \'' . $db->escape($filter['zone']) . '\'';
if (!empty($filter['uri']))
$sql .= ' && uri = \'' . $filter['uri'] . '\'';
$sql .= ' ORDER BY u.id ASC';
$result = $db->query($sql);
$uris = array();
foreach ($result as $uri) {
$uris[] = new self($uri['id'], $db);
}
return $uris;
}
}
?>

26
include/exceptions.php Executable file
View File

@ -0,0 +1,26 @@
<?php
class UserException extends CustomException {}
class ValidationException extends UserException {}
class NameServerException extends CustomException {}
class CustomException extends Exception {
public function toXml(DOMDocument $doc) {
$xmlRecord = $doc->createElement('exception');
$xmlRecord->setAttribute('code', $this->code);
$xmlRecord->appendChild($doc->createElement('message', $this->message));
$xmlRecord->appendChild($doc->createElement('line', $this->line));
$xmlRecord->appendChild($doc->createElement('file', $this->file));
$xmlRecord->appendChild(backtrace2xml($this->getTrace(), $doc));
return $xmlRecord;
}
public function toHtml() {
return $this->message . ' in ' . $this->file . ':' . $this->line;
}
}
?>

73
include/functions.php Executable file
View File

@ -0,0 +1,73 @@
<?php
function isAuthentificated() {
$config = Registry::get('config');
$combi = @$_SERVER['PHP_AUTH_USER'] . ':{SHA}' . base64_encode(sha1(@$_SERVER['PHP_AUTH_PW'], TRUE));
$htpasswd = file('/var/www/nulll/sddns/../.htpasswd');
foreach ($htpasswd as $user) {
if ($combi == trim($user)) {
return true;
}
}
return false;
}
function randomString($length, $characters='abcdefghijklmnopqrstuvwxyz0123456789') {
$random_string = '';
$characters_length = strlen($characters);
for($i = 0; $i<$length; $i++) {
$random_string .= $characters[mt_rand(0, $characters_length - 1)];
}
return $random_string;
}
function backtrace2xml($traces, DomDocument $doc) {
$xmlTraces = $doc->createElement('backtrace');
foreach ($traces as $step => $trace) {
$xmlTrace = $doc->createElement('trace');
$xmlTraces->appendChild($xmlTrace);
$xmlTrace->setAttribute('step', $step);
foreach ($trace as $key => $value) {
switch ($key) {
case 'function':
case 'line':
case 'file':
case 'class':
case 'type':
$xmlTrace->appendChild($doc->createElement($key, $value));
break;
case 'args':
$xmlArgs = $doc->createElement($key);
$xmlTrace->appendChild($xmlArgs);
foreach ($value as $arg) {
$xmlArgs->appendChild($doc->createElement('arg', $value));
}
break;
}
}
}
return $xmlTraces;
}
function backtrace2html($traces) {
$trace = '';
foreach(debug_backtrace() as $i=>$l){
$trace .= '[' . $i . '] in function <b>' . $l['class'] . $l['type'] . $l['function'] . '</b>';
if($l['file'])
$trace .= ' in <b>' . $l['file'] . '</b>';
if($l['line'])
$trace .= ' on line <b>' . $l['line'] . '</b>';
}
return $trace;
}
?>

1
include/hits.txt Normal file
View File

@ -0,0 +1 @@
20624

123
include/host.php Executable file
View File

@ -0,0 +1,123 @@
<?php
class Host implements Object {
private $punycode;
public $zone;
public $generated;
/*
* Constructor & Factory
*/
public function __construct($hostname, Zone $zone, $generated = false) {
$hostname = strtolower($hostname);
if (self::isValid(idn_to_ascii($hostname))) {
$this->punycode = idn_to_ascii($hostname);
$this->zone = $zone;
$this->generated = $generated;
}
else {
if (strlen($hostname) > 63)
throw new UserException('Invalid hostname: too long');
else
throw new UserException('Invalid hostname: ' . idn_to_ascii($hostname));
}
}
public static function unique(Zone $zone, Database $db) {
$config = Registry::get('config');
$sql = 'SELECT hostname
FROM ' . $config['db']['tbl']['hosts'] . '
WHERE
generated = TRUE &&
zone = \'' . $db->escape($zone->name) . '\'
ORDER BY id DESC';
$result = $db->query($sql, 1);
$first = $result->first();
$last_id = base_convert($first['hostname'], 36, 10);
while ($result->count() > 0 || !Host::isValid(base_convert($last_id, 10, 36))) {
$sql = 'SELECT hostname
FROM ' . $config['db']['tbl']['hosts'] . '
WHERE
hostname = \'' . base_convert(++$last_id, 10, 36) . '\' &&
zone = \'' . $db->escape($zone->name) . '\'';
$result = $db->query($sql, 1);
}
return new self(base_convert($last_id, 10, 36), $zone, true);
}
/*
* Checks
*/
public static function isValid($hostname) {
$hostExpr = '[a-z0-9](?:[a-z0-9\-]*[a-z0-9])?';
return preg_match('/^(?:\*|(\*\.)?(' . $hostExpr . '\.)*(' . $hostExpr . '))$/i', $hostname);
}
public function isRegistred(Database $db) {
$config = Registry::get('config');
$sql = 'SELECT *
FROM ' . $config['db']['tbl']['hosts'] . '
WHERE hostname = \'' . $db->escape($this->toPunycode()) . '\' && zone = \'' . $db->escape($this->zone->name) . '\'';
$result = $db->query($sql, 1);
$host = $result->first();
return ($result->count() > 0) ? $host['id'] : false;
}
/*
* Database
*/
public function add($pw, Database $db) {
$config = Registry::get('config');
$sql = 'INSERT INTO ' . $config['db']['tbl']['hosts'] . ' (hostname, zone, password, generated)
VALUES (
\'' . $db->escape($this->toPunycode()) . '\',
\'' . $db->escape($this->zone->name) . '\',
\'' . $db->escape(sha1($pw)) . '\',
' . (int) $this->generated . ')';
$db->execute($sql);
return new DBHost($db->lastId(), $db);
}
/*
* Output
*/
public function toUnicode() {
return idn_to_utf8($this->punycode);
}
public function toPunycode() {
return $this->punycode;
}
public function __toString() {
return $this->toPunycode() . '.' . $this->zone->name;
}
public function toXml(DOMDocument $doc) {
$xmlHost = $doc->createElement('host');
$xmlHost->appendChild($doc->createElement('hostname', $this->toPunycode()));
$xmlHost->appendChild($doc->createElement('idn', $this->toUnicode()));
$xmlHost->appendChild($this->zone->toXml($doc));
return $xmlHost;
}
public function toHtml() {
return '<a target="_blank" href="http://' . $this . '">' . $this->toUnicode() . '.' . $this->zone->name . '</a>';
}
}
?>

98
include/init.php Executable file
View File

@ -0,0 +1,98 @@
<?php
error_reporting(E_ALL);
$site['path']['server'] = dirname(dirname(__FILE__));
require_once $site['path']['server'] . '/include/functions.php';
require_once $site['path']['server'] . '/include/exceptions.php';
require_once $site['path']['server'] . '/include/registry.php';
require_once $site['path']['server'] . '/include/mysql.php';
require_once $site['path']['server'] . '/include/output.php';
require_once $site['path']['server'] . '/include/object.php';
require_once $site['path']['server'] . '/include/dbobject.php';
require_once $site['path']['server'] . '/include/host.php';
require_once $site['path']['server'] . '/include/record.php';
require_once $site['path']['server'] . '/include/uri.php';
require_once $site['path']['server'] . '/include/ip.php';
require_once $site['path']['server'] . '/include/dbhost.php';
require_once $site['path']['server'] . '/include/dbrecord.php';
require_once $site['path']['server'] . '/include/dburi.php';
require_once $site['path']['server'] . '/include/nameserver.php';
require_once $site['path']['server'] . '/include/zone.php';
require_once $site['path']['server'] . '/include/config.php';
Registry::set('config', $config);
// get relevant runtime information
$site['hostname'] = @$_SERVER[ 'SERVER_NAME'];
$site['path']['web'] = $config['path']['web'];
$site['url'] = 'http://' . $site['hostname'] . $site['path']['web'];
// debug mode
if (@isset($_REQUEST['debug'])) {
$debug = (int) $_REQUEST['debug'];
}
else {
if (isAuthentificated()) {
$debug = 1;
}
else {
$debug = 0;
}
}
// output
if (isset($argc))
$format = 'txt';
elseif ($_SERVER['SERVER_NAME'] === 'members.dyndns.org')
$format = 'dyndns';
elseif (empty($_REQUEST['format']) || @$_REQUEST['format'] == 'php')
$format = 'html';
else
$format = $_REQUEST['format'];
$output = Output::getInstance($format, $debug);
Registry::set('output', $output);
// errorhandling
set_exception_handler(array($output, 'exception_handler'));
set_error_handler(array($output, 'error_handler'), E_ALL);
$parameters = array();
foreach ($_REQUEST as $parName => $parValue) {
$parameters[] = $parName . ' => ' . $parValue;
}
$output->add('debug level', 'debug', 2, $output->debug);
$output->add('parameters', 'debug', 2, $parameters);
// simple hit counting
$file = $site['path']['server'] . '/include/hits.txt';
$handle = fopen($file, 'r+') ;
$data = fread($handle, 512) ;
$site['hits'] = $data + 1;
fseek($handle, 0);
fwrite($handle, $site['hits']) ;
fclose($handle);
Registry::set('site', $site);
// set locale
setlocale(LC_TIME, 'de_DE.UTF8');
// set runtime configuration
ini_set('idn.default_charset', 'UTF-8');
// set timezone
date_default_timezone_set('Europe/Berlin');
// database
$db = new MySql($config['db']['host'], $config['db']['user'], $config['db']['pw'], $config['db']['db']);
Registry::set('db', $db);
?>

67
include/ip.php Executable file
View File

@ -0,0 +1,67 @@
<?php
class IpV4 implements Object {
public $tuples = array();
public function __construct($ipString) {
if (self::isValid($ipString)) {
$this->tuples = explode('.', $ipString);
}
else {
throw new ValidationException('Invalid IP: ', $ipString);
}
}
static function isValid($ipString) {
return preg_match('/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/', $ipString);
}
public function __toString() {
return implode('.', $this->tuples);
}
public function toHtml() {
return '<a href="http://www.dnsstuff.com/tools/ipall/?tool_id=67&ip=' . $this . '">' . $this . '</a>';
}
public function toXml(DOMDocument $doc) {
$xmlIpV4 = $doc->createElement('ip', $this);
$xmlIpV4->setAttribute('version', 4);
return $xmlIpV4;
}
}
class IpV6 implements Object {
private $ip;
public function __construct($ipString) {
if (self::isValid($ipString)) {
$this->ip = $ipString;
}
else {
throw new ValidationException('Invalid IP: ', $ipString);
}
}
static function isIpV6($ipString) {
return preg_match('/^((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4})|:))|(([0-9A-Fa-f]{1,4}:){6}(:|((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})|(:[0-9A-Fa-f]{1,4})))|(([0-9A-Fa-f]{1,4}:){5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){0,1}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:)(:[0-9A-Fa-f]{1,4}){0,4}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(:(:[0-9A-Fa-f]{1,4}){0,5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})))(%.+)?$/', $ipString);
}
public function __toString() {
return $this->ip;
}
public function toHtml() {
return '<a href="http://www.dnsstuff.com/tools/ipall/?tool_id=67&ip=' . $this . '">' . $this . '</a>';
}
public function toXml(DOMDocument $doc) {
$xmlIpV6 = $doc->createElement('ip', $this);
$xmlIpV6->setAttribute('version', 6);
return $xmlIpV6;
}
}
?>

1
include/jpgraph Symbolic link
View File

@ -0,0 +1 @@
jpgraph-3.0.7/src/

View File

@ -0,0 +1,71 @@
README FOR JPGRAPH 3.0.x
========================
This package contains JpGraph, an Object Oriented PHP5 Graph Plotting library.
The library is Copyright (C) 2001-2009 Aditus Consulting and
released under dual license QPL 1.0 for open source and educational
use and JpGraph Professional License for commercial use.
Please see full license details at http://www.aditus.nu/jpgraph/
* --------------------------------------------------------------------
* PHP4 IS NOT SUPPORTED in the 2.x or 3.x series
* --------------------------------------------------------------------
Requirements:
-------------
Miminum:
* PHP 5.1.0 or higher
* GD 2.0.28 or higher
Note: Earlier versions might work but is unsupported.
Recommended:
* PHP >= 5.2.0
* PHP Built-in GD library
Installation
------------
0. Make sure that the PHP version is compatible with the stated requirements
and that the PHP installation has support for the GD library.
Please run phpinfo() to check if GD library
is supported in the installation.
If the GD library doesn't seem to be installed
please consult the PHP manual under section "Image" for
instructions on where to find this library. Please refer to
the manual section "Verifying your PHP installation"
1. Unzip and copy the files to a directory of your choice where Your
httpd sever can access them.
For a global site installation you should copy the files to
somewhere in the PHP search path.
2. Check that the default directory paths in jpg-config.inc
for cache directory and TTF directory suits your installation.
Note1: The default directories are different depending on if
the library is running on Windows or UNIX.
Note2: Apache/PHP must have write permission to your cache
directory if you enable the cache feature. By default the cache
is disabled.
3. Check that all rest of the DEFINE in jpg-config.inc
is setup to your preference. The default should be fine
for most users.
4. Read the chapters on installation in the manual.
Documentation
-------------
The installation includes HTML documentation and reference guide for the
library. The portal page for all the documentation is
<YOUR-INSTALLATION-DIRECTORY>/docs/index.html
Bug reports and suggestions
---------------------------
Should be reported using the the issue tracker at
http://www.aditus.nu/bugtraq
<EOF>

View File

@ -0,0 +1 @@
Version: v3.0.7, Build: r1928, Exported: Mon, 11 Jan 2010 at 23:34 (UTC+2), w1002.1

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -0,0 +1,76 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Appendix A. How this manual was produced</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="pt08.html" title="Part VIII. Appendices"><link rel="prev" href="pt08.html" title="Part VIII. Appendices"><link rel="next" href="apb.html" title="Appendix B. JpGraph Professional License"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Appendix A. How this manual was produced</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="pt08.html">Prev</a> </td><th width="60%" align="center">Part VIII. Appendices</th><td width="20%" align="right"> <a accesskey="n" href="apb.html">Next</a></td></tr></table><hr></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="app.how-was-this-manual-produced"></a>Appendix A. How this manual was produced</h2></div></div></div><p>Unfortunately we couldn't locate any off-the-shelf system for producing this fairly
large manual with some special requirements like automatic inclusion of PHP source that
should be highlighted and in addition rendered by running the scripts and automatically
include the resulting images in the resulting manual. To solve this we have based our
solution around a DocBook5 setup with some custom steps that are described below.</p><p><span class="bold"><strong>DocBook5</strong></span></p><p>The source for the manual is written as a number of split <code class="uri"><a class="uri" href="http://www.docbook.org/" target="_top">DocBook5</a></code> XML compliant documents using
<code class="uri"><a class="uri" href="http://www.w3.org/TR/xinclude/" target="_top">XInclude</a></code> to bring them
together into one master document. </p><p>The transformation of the XML source files was done by the means of a DocBook XSL
stylesheet using the <span class="command"><strong>xsltproc</strong></span> XSL processor. (see <code class="uri"><a class="uri" href="http://xmlsoft.org/XSLT/xsltproc2.html" target="_top">libxslt</a></code>) The DocBook5
style sheets can directly produce either single file HTML or chunked (many files) HTML
(or XHTML). </p><p>In addition there is a style sheet to produce FO (Formatted Objects) output which can
be further refined to PDF with the help of the <span class="command"><strong>fop</strong></span> processor (see
<code class="uri"><a class="uri" href="http://xmlgraphics.apache.org/fop/" target="_top">Apache FOP</a></code>).
Unfortunately some formatting instructions in the source are lost in the transformation
to PDF output. This means that some aspects of the manual doesn't come out perfect in
the PDF output. For this reason the PDF version of the documentation should only be seen
as a complementary documentation. The master output format is the chunked HTML.</p><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>In formatting the chunked output we have prioritized to keep down the number
of files to avoid many pages with only a small amount of text on them. Our view
is that documentation which breaks the pages down to very low levels are
extremely tiresome to read.</p></div><p>
</p><p><span class="bold"><strong>Phing based build system</strong></span></p><p>The overall build process is drive by a <span class="command"><strong>Phing</strong></span> XML build script.
<span class="command"><strong>Phing</strong></span> (See <code class="uri"><a class="uri" href="http://phing.info/trac/" target="_top">http://phing.info/trac/</a></code> ) is most easily described as a PHP version of the
Java build system <span class="command"><strong>Ant</strong></span>. It has several advantages compared with a more
traditional <span class="command"><strong>make</strong></span> setup, the build files are all written in clear XML
which makes them easy to read and maintain. In addition there are a number of built-in
commands that makes deploying and handling of files extremely easy compared with a
traditional make system which must rely on external tools to do everything. </p><p><span class="bold"><strong>Syntax highlighting of example code</strong></span></p><p>The syntax highlighting and handling of the numerous example images initially posed a
small problem since there are no off-the-shelf good support for handling this. As a
basic requirement we needed all PHP scripts to be runnable and kept in the normal
example directories and then automatically included when the DocBook source was
processed. </p><p>What was needed was some easy way by which we could just mark in the DocBook source
(and still maintain valid DocBook XML) that we wanted a particular named example
included and either show just the image, just the source or both. In addition we
required the source to be syntax highlighted. </p><p>To handle this we had to write some custom tasks to extend Phing. In principal our
build system works as follows.</p><div class="orderedlist"><ol type="1"><li><p>When a new example have been added or an old one removed a special target in
our build file are run which extracts all scripts from the example sections in
the *.XML files. The name of each found example script in the XML source
corresponds to an existing PHP script in the Example directory in the JpGraph
distribution. A batch file is then automatically created which is subsequently
run and all generated images stored on disk.</p></li><li><p>When the normal DocBook XSL processing is done all the special example markups
in the XML source is replaced with XML tags to include the image and make sure
that the referred script is a proper PHP file name.</p></li><li><p>After the XSL process has been run all programlisting tags will have a special
token, for example "<code class="code">\#\#example0.php\#\#</code>" this then instructs a
custom <span class="command"><strong>Phing</strong></span> task to replace the name in the double "#" tags
with the corresponding source (in the resulting HTML code). At the same time
this source is included it is also passed through the custom syntax highlight
filter so that it comes out as proper marked up source which is inserted
directly in the resulting HTML file.</p></li></ol></div><p>The overall build system is illustrated in <a class="xref" href="apa.html#fig.documentation-build-system" title="Figure A.1. The documentation build process">Figure A.1</a></p><div class="figure"><a name="fig.documentation-build-system"></a><p class="title"><b>Figure A.1. The documentation build process</b></p><div class="figure-contents"><div class="mediaobject"><img src="images/documentation_buildprocess.png" alt="The documentation build process"></div></div></div><br class="figure-break"><p>The way the special markup works is that whenever we want a full example (source and
image) we create a &lt;programlisting&gt; tag with the file name and title within (single)
"#" characters. For example to include the very first example in this manual we have the
following tags in the docbook XML source</p><p>
</p><pre class="screen">&lt;programlisting&gt;#example0|The very first example#&lt;/programlisting&gt;</pre><p>
</p><p>The first part (before the "|") is the file name without extension that we want to
include and the second part (after the "|") is the title we want to use. This markup
will include both the source as well as the generated graph/image directly in the
resulting HTML.</p><p>When new examples have been added the examples target in our build file is run and
that extracts all the example script used in the book (in the above example
"<code class="code">example0.php</code>") and creates a batch file which is then run to create
all the images used in the examples. </p><p>The syntax highlighting is handled by a custom written filter extensions to
<span class="command"><strong>Phing</strong></span> which internally uses the PEAR package
<code class="filename">Pear::Text_Highlight</code>.</p><p><span class="bold"><strong>Notes:</strong></span></p><p>
</p><div class="orderedlist"><ol type="1"><li><p>In the current setup a regular expression in the Phing build script is
responsible for replacing the markup in the programlisting with a
&lt;figure&gt; tag and a new &lt;programlisting&gt;. This should be done with a
custom XSL layer instead and we will update this for the next major
revision.</p></li><li><p>Since the syntax highlighting makes use of HTML markup code for the colors
the PDF output does not support syntax highlighting</p></li><li><p>For the reference manual we still use our old DB based documentation
system which stores all the methods and classes in a DB augmented with
source documentation. (We actually prefer this in front of adding a lot of
end user documentation with PHPDoc comment sin the source which have a
tendency of cluttering up the code as well as making it prone to error since
the source files have to be modified in order to update a simple typo in the
documentations. Our next step is therefor to update that old system to be
able to produce DocBook5 compliant XML for further formatting and
processing.</p></li></ol></div><p>
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="pt08.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="pt08.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apb.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part VIII. Appendices </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Appendix B. JpGraph Professional License</td></tr></table></div></body></html>

View File

@ -0,0 +1,34 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Appendix B. JpGraph Professional License</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="pt08.html" title="Part VIII. Appendices"><link rel="prev" href="apa.html" title="Appendix A. How this manual was produced"><link rel="next" href="apbs02.html" title="B.2. Bulk (Re-seller license)"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Appendix B. JpGraph Professional License</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apa.html">Prev</a> </td><th width="60%" align="center">Part VIII. Appendices</th><td width="20%" align="right"> <a accesskey="n" href="apbs02.html">Next</a></td></tr></table><hr></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="app.jpg-license"></a>Appendix B. JpGraph Professional License</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="apb.html#id2560436">B.1. Single License</a></span></dt><dt><span class="section"><a href="apbs02.html">B.2. Bulk (Re-seller license)</a></span></dt></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2560436"></a>B.1. Single License</h2></div></div></div><div class="orderedlist"><ol type="1"><li><p>The JpGraph Professional License will be referred to as "The license" in the
remainder of this text.</p></li><li><p>This irrevocable, perpetual license covers versions 1.x &amp; 2.x of
JpGraph</p></li><li><p>This license gives the holder right to install JpGraph libraries on One Server
which can run one or several virtual HTTP servers.</p></li><li><p>The license holder is allowed to make modifications to the JpGraph sources but
in no event will the original copyright holders of this library be held
responsible for action or actions resulting from any modifications of the
source.</p></li><li><p>The license holder is not required to publicize or otherwise make available
any software used in conjunction with JpGraph.</p></li><li><p>The license holder may not re-distribute the library on it's own or versions
thereof to third party without prior written permission of the copyright
holder.</p></li><li><p>JpGraph License does not allow the library to be redistributed as part of
another product.</p></li><li><p>In no event shall the copyright notice in any of the source files supplied in
JpGraph be removed or modified.</p></li><li><p>The names "JpGraph" or "Aditus" must not be used to endorse or promote
products derived from this software without prior written permission.</p></li><li><p>The license may be transferred to another server by removing all installed
files from the old server.</p></li><li><p>The wording of this license may change without notice for future versions of
JpGraph.</p></li><li><p>By acquiring a license the licensee agrees to all terms and conditions in this
license text.</p></li><li><p><span class="bold"><strong>Limitations of Liability</strong></span></p><p>In no event, except for intellectual property claim, shall the initial
developers or copyright holders be liable for any damages whatsoever, including
- but not restricted to - lost revenue or profits or other direct, indirect,
special, incidental or consequential damages, even if they have been advised of
the possibility of such damages, except to the extent invariable law, if any,
provides otherwise.</p><p>In addition, in no event does this license authorize you to use JpGraph in
applications or systems where JpGraphs failure to perform can reasonably be
expected to result in a physical injury, loss of life or any economical damage.
Any such use by the licensee is entirely at the licensees own risk, and the
licensee agrees to hold the original copyright holders of JpGraph harmless from
any claims or losses relating to any such unauthorized use.</p></li><li><p><span class="bold"><strong>Limited Warranty</strong></span></p><p>JpGraph warrants that licensor is owner of the software with authority to
license the software to licensee and that the software does not infringe third
party intellectual property rights. Licensor agrees to indemnify, defend and
hold harmless licensee from any claims either that licensor does not own the
software or that the software infringes a third party's intellectual
property.</p><p>THE SOFTWARE AND THIS LICENSE DOCUMENT ARE PROVIDED AS IS. THE FOREGOING
WARRANTY IS IN LIEU OF ALL OTHER WARRANTIES, EXPRESS OR IMPLIED, OF ANY KIND,
INCLUDING WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.</p></li></ol></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="apa.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="pt08.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apbs02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appendix A. How this manual was produced </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> B.2. Bulk (Re-seller license)</td></tr></table></div></body></html>

View File

@ -0,0 +1,35 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>B.2. Bulk (Re-seller license)</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="apb.html" title="Appendix B. JpGraph Professional License"><link rel="prev" href="apb.html" title="Appendix B. JpGraph Professional License"><link rel="next" href="apc.html" title="Appendix C. FAQ"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">B.2. Bulk (Re-seller license)</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apb.html">Prev</a> </td><th width="60%" align="center">Appendix B. JpGraph Professional License</th><td width="20%" align="right"> <a accesskey="n" href="apc.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2504900"></a>B.2. Bulk (Re-seller license)</h2></div></div></div><div class="orderedlist"><ol type="1"><li><p>The JpGraph Professional License will be referred to as "The license" in the
remainder of this text.</p></li><li><p>This irrevocable, perpetual license covers versions 1.x &amp; 2.x of
JpGraph</p></li><li><p>This license gives the licensee the right to distribute the JpGraph libraries,
as part of its product portfolio and to use the Jpgraph libraries with its
hosted service offerings. Specifically this license gives the licensee the right
to deploy an unlimited number of JpGraph installations as part of their product
portfolio and offer an unlimited number of hosted services that use the JpGraph
libraries to an unlimited number of users.</p></li><li><p>The license holder is allowed to make modifications to the JpGraph sources but
in no event will the original copyright holders of this library be held
responsible for action or actions resulting from any modifications of the
source.</p></li><li><p>JpGraph libraries is only licensed to be redistributed as a part of the
licensees products. Specifically it may not be sold or re-distributed on it's
own.</p></li><li><p>In no event shall the copyright notice in any of the source files supplied in
JpGraph be removed or modified.</p></li><li><p>The names "JpGraph" or "Aditus" must not be used to endorse or promote
products derived from this software without prior written permission.</p></li><li><p>The wording of this license may change without notice for future versions of
JpGraph.</p></li><li><p>By acquiring a license the licensee agrees to all terms and conditions in this
license text.</p></li><li><p><span class="bold"><strong>Limitations of Liability</strong></span></p><p>In no event, except for intellectual property claim, shall the initial
developers or copyright holders be liable for any damages whatsoever, including
- but not restricted to - lost revenue or profits or other direct, indirect,
special, incidental or consequential damages, even if they have been advised of
the possibility of such damages, except to the extent invariable law, if any,
provides otherwise.</p><p>In addition, in no event does this license authorize you to use JpGraph in
applications or systems where JpGraphs failure to perform can reasonably be
expected to result in a physical injury, loss of life or any economical damage.
Any such use by the licensee is entirely at the licensees own risk, and the
licensee agrees to hold the original copyright holders of JpGraph harmless from
any claims or losses relating to any such unauthorized use.</p></li><li><p><span class="bold"><strong>Limited Warranty</strong></span></p><p>JpGraph warrants that licensor is owner of the software with authority to
license the software to licensee and that the software does not infringe third
party intellectual property rights. Licensor agrees to indemnify, defend and
hold harmless licensee from any claims either that licensor does not own the
software or that the software infringes a third party's intellectual
property.</p><p>THE SOFTWARE AND THIS LICENSE DOCUMENT ARE PROVIDED AS IS. THE FOREGOING
WARRANTY IS IN LIEU OF ALL OTHER WARRANTIES, EXPRESS OR IMPLIED, OF ANY KIND,
INCLUDING WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.</p></li></ol></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="apb.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="apb.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apc.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appendix B. JpGraph Professional License </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Appendix C. FAQ</td></tr></table></div></body></html>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,64 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Appendix E. Available plot marks</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="pt08.html" title="Part VIII. Appendices"><link rel="prev" href="apd.html" title="Appendix D. Named color list"><link rel="next" href="apes02.html" title="E.2. Built in image plot marks"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Appendix E. Available plot marks</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apd.html">Prev</a> </td><th width="60%" align="center">Part VIII. Appendices</th><td width="20%" align="right"> <a accesskey="n" href="apes02.html">Next</a></td></tr></table><hr></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="app.plotmark-list"></a>Appendix E. Available plot marks</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ape.html#id2662723">E.1. Built in basic plot marks</a></span></dt><dt><span class="sect1"><a href="apes02.html">E.2. Built in image plot marks</a></span></dt><dd><dl><dt><span class="sect2"><a href="apes02.html#id2663187">E.2.1. Image plot mark: Balls</a></span></dt><dt><span class="sect2"><a href="apes02.html#id2663263">E.2.2. Image plot mark: Squares</a></span></dt><dt><span class="sect2"><a href="apes02.html#id2663294">E.2.3. Image plot mark: Diamonds</a></span></dt><dt><span class="sect2"><a href="apes02.html#id2663325">E.2.4. Image plot mark: Stars</a></span></dt><dt><span class="sect2"><a href="apes02.html#id2663356">E.2.5. Image plot mark: Bevels</a></span></dt><dt><span class="sect2"><a href="apes02.html#id2663386">E.2.6. Image plot mark: Pushpins</a></span></dt></dl></dd></dl></div><p> Plot marks can be added to almost all linear (cartesian) graph types. They are used to
emphasise the actual data points in the graph. The plot mark property is available as the
instance variable "<code class="code">$mark</code>" for the plot types that support plot marks. </p><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2662723"></a>E.1. Built in basic plot marks</h2></div></div></div><p>To embellishment a line plot with one of the built-in basic plot marks, say a a red
diamond mark, at each data point the following line has to be added to the graph
script</p><p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-var">$lineplot</span><span class="hl-code">-&gt;</span><span class="hl-identifier">mark</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetType</span><span class="hl-brackets">(</span><span class="hl-identifier">MARK_DIAMOND</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$lineplot</span><span class="hl-code">-&gt;</span><span class="hl-identifier">mark</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetFillColor</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">red</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
</p><p>The rest of the basic plot marks are handled analogues.</p><p>
</p><div class="table"><a name="tab.built-in-plotmarks"></a><p class="title"><b>Table E.1. Built in line based plot marks</b></p><div class="table-contents"><table summary="Built in line based plot marks" border="1"><colgroup><col align="center"><col align="center"></colgroup><thead><tr><th align="center">Displayed plot mark</th><th align="center">Symbolic name</th></tr></thead><tbody><tr><td align="center">
<p><span class="inlinemediaobject"><img src="images/img_marker_square.png"></span></p>
</td><td align="center">
<p><code class="code">MARK_SQUARE</code></p>
</td></tr><tr><td align="center">
<p><span class="inlinemediaobject"><img src="images/img_marker_utriangle.png"></span></p>
</td><td align="center">
<p><code class="code">MARK_UTRIANGLE</code></p>
</td></tr><tr><td align="center">
<p><span class="inlinemediaobject"><img src="images/img_marker_dtriangle.png"></span></p>
</td><td align="center">
<p><code class="code">MARK_DTRIANGLE</code></p>
</td></tr><tr><td align="center">
<p><span class="inlinemediaobject"><img src="images/img_marker_diamond.png"></span></p>
</td><td align="center">
<p><code class="code">MARK_DIAMOND</code></p>
</td></tr><tr><td align="center">
<p><span class="inlinemediaobject"><img src="images/img_marker_circle.png"></span></p>
</td><td align="center">
<p><code class="code">MARK_CIRCLE</code></p>
</td></tr><tr><td align="center">
<p><span class="inlinemediaobject"><img src="images/img_marker_filledcircle.png"></span></p>
</td><td align="center">
<p><code class="code">MARK_FILLEDCIRCLE</code></p>
</td></tr><tr><td align="center">
<p><span class="inlinemediaobject"><img src="images/img_marker_cross.png"></span></p>
</td><td align="center">
<p><code class="code">MARK_CROSS</code></p>
</td></tr><tr><td align="center">
<p><span class="inlinemediaobject"><img src="images/img_marker_star.png"></span></p>
</td><td align="center">
<p><code class="code">MARK_STAR</code></p>
</td></tr><tr><td align="center">
<p><span class="inlinemediaobject"><img src="images/img_marker_x.png"></span></p>
</td><td align="center">
<p><code class="code">MARK_X</code></p>
</td></tr><tr><td align="center">
<p><span class="inlinemediaobject"><img src="images/img_marker_lefttriangle.png"></span></p>
</td><td align="center">
<p><code class="code">MARK_LEFTTRIANGLE</code></p>
</td></tr><tr><td align="center">
<p><span class="inlinemediaobject"><img src="images/img_marker_righttriangle.png"></span></p>
</td><td align="center">
<p><code class="code">MARK_RIGHTTRIANGLE</code></p>
</td></tr><tr><td align="center">
<p><span class="inlinemediaobject"><img src="images/img_marker_flash.png"></span></p>
</td><td align="center">
<p><code class="code">MARK_FLASH</code></p>
</td></tr></tbody></table></div></div><p><br class="table-break">
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="apd.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="pt08.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apes02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appendix D. Named color list </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> E.2. Built in image plot marks</td></tr></table></div></body></html>

View File

@ -0,0 +1,32 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>E.2. Built in image plot marks</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ape.html" title="Appendix E. Available plot marks"><link rel="prev" href="ape.html" title="Appendix E. Available plot marks"><link rel="next" href="apf.html" title="Appendix F. List of all country flags"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">E.2. Built in image plot marks</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ape.html">Prev</a> </td><th width="60%" align="center">Appendix E. Available plot marks</th><td width="20%" align="right"> <a accesskey="n" href="apf.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2663144"></a>E.2. Built in image plot marks</h2></div></div></div><p>Since the image based plot marks only supports some colors (since there has to be a
unique image for each color) the following sections shows for each major image plot mark
what colors are available. The image shows the natural size of the plot mark, i.e. the
scale factor is =1. Only the round balls ar available natively in three different sizes.
Even though it is possible to scale up all the images arbitrarily it will cause the
images to become pixelated.</p><p>To use one of the built in image plot mark two parameters has to be given to the
<code class="code">SetType()</code> method. The basic class of plot mark and the wanted color.
For example to use a green square as plot marks the following line would have to be
added</p><p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-var">$lineplot</span><span class="hl-code">-&gt;</span><span class="hl-identifier">mark</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetType</span><span class="hl-brackets">(</span><span class="hl-identifier">MARK_IMG_SQUARE</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">green</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
</p><p>If a non-supported color is specified an error will be thrown.</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2663187"></a>E.2.1. Image plot mark: Balls</h3></div></div></div><p>
</p><div class="figure"><a name="id2663196"></a><p class="title"><b>Figure E.1. Small size</b></p><div class="figure-contents"><div class="mediaobject"><img src="images/plotmark_colors_img_sball.png" alt="Small size"></div></div></div><p><br class="figure-break">
</p><p>
</p><div class="figure"><a name="id2663219"></a><p class="title"><b>Figure E.2. Medium size</b></p><div class="figure-contents"><div class="mediaobject"><img src="images/plotmark_colors_img_mball.png" alt="Medium size"></div></div></div><p><br class="figure-break">
</p><p>
</p><div class="figure"><a name="id2663242"></a><p class="title"><b>Figure E.3. Large size</b></p><div class="figure-contents"><div class="mediaobject"><img src="images/plotmark_colors_img_lball.png" alt="Large size"></div></div></div><p><br class="figure-break">
</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2663263"></a>E.2.2. Image plot mark: Squares</h3></div></div></div><p>
</p><div class="figure"><a name="id2663273"></a><p class="title"><b>Figure E.4. Standard size</b></p><div class="figure-contents"><div class="mediaobject"><img src="images/plotmark_colors_img_square.png" alt="Standard size"></div></div></div><p><br class="figure-break">
</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2663294"></a>E.2.3. Image plot mark: Diamonds</h3></div></div></div><p>
</p><div class="figure"><a name="id2663303"></a><p class="title"><b>Figure E.5. Standard size</b></p><div class="figure-contents"><div class="mediaobject"><img src="images/plotmark_colors_img_diamond.png" alt="Standard size"></div></div></div><p><br class="figure-break">
</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2663325"></a>E.2.4. Image plot mark: Stars</h3></div></div></div><p>
</p><div class="figure"><a name="id2663334"></a><p class="title"><b>Figure E.6. Standard size</b></p><div class="figure-contents"><div class="mediaobject"><img src="images/plotmark_colors_img_star.png" alt="Standard size"></div></div></div><p><br class="figure-break">
</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2663356"></a>E.2.5. Image plot mark: Bevels</h3></div></div></div><p>
</p><div class="figure"><a name="id2663365"></a><p class="title"><b>Figure E.7. Standard size</b></p><div class="figure-contents"><div class="mediaobject"><img src="images/plotmark_colors_img_bevel.png" alt="Standard size"></div></div></div><p><br class="figure-break">
</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2663386"></a>E.2.6. Image plot mark: Pushpins</h3></div></div></div><p>
</p><div class="figure"><a name="id2663396"></a><p class="title"><b>Figure E.8. Standard size</b></p><div class="figure-contents"><div class="mediaobject"><img src="images/plotmark_colors_img_pushpin.png" alt="Standard size"></div></div></div><p><br class="figure-break">
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ape.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ape.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apf.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appendix E. Available plot marks </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Appendix F. List of all country flags</td></tr></table></div></body></html>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,183 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Appendix G. List of files included in the library</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="pt08.html" title="Part VIII. Appendices"><link rel="prev" href="apf.html" title="Appendix F. List of all country flags"><link rel="next" href="aph.html" title="Appendix H. Error messages"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Appendix G. List of files included in the library</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apf.html">Prev</a> </td><th width="60%" align="center">Part VIII. Appendices</th><td width="20%" align="right"> <a accesskey="n" href="aph.html">Next</a></td></tr></table><hr></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2671565"></a>Appendix G. List of files included in the library</h2></div></div></div><p>In the distribution these files are stored directly under the src directory in the
distribution. </p><p>In the pro-version of the library there are also two alternative directories which
contains variations of the core <code class="filename">src</code> directory. These additional
directories are:</p><p>
</p><div class="variablelist"><dl><dt><span class="term">stripped-src</span></dt><dd><p>These file are suitable to be deployed on a production server. No examples
or demo applications are included here and in addition all files have white
spaces and comments stripped which makes them significantly smaller and
hence reduce the load time of the files on a productions server.</p></dd><dt><span class="term">phpExpress-src</span></dt><dd><p>These files are intended to be used with the PHP Accelerator from
NuSpehere. This accelerometer can be downloaded free of charge from <code class="uri"><a class="uri" href="http://www.nusphere.com" target="_top">NuSphere corporation</a></code>. For a
production server this is the recommended installation since it
significantly reduces the load on the production server. See <a class="xref" href="ch11.html" title="Chapter 11. NuSphere PHP accelerator">Chapter 11</a> for information on how to install
the freely available PHP Accelerator.</p></dd></dl></div><p>
</p><div class="table"><a name="id2671657"></a><p class="title"><b>Table G.1. List of files included in the library</b></p><div class="table-contents"><table summary="List of files included in the library" border="0"><colgroup><col><col><col></colgroup><thead><tr><th>File name</th><th>Only Pro Version </th><th>Description</th></tr></thead><tbody><tr><td>
<code class="filename">flags.dat</code>
</td><td>
</td><td>Raw data for country flag in maximum size</td></tr><tr><td>
<code class="filename">flags_thumb100x100.dat</code>
</td><td>
</td><td>Raw data for country flag in size 100x100</td></tr><tr><td>
<code class="filename">flags_thumb35x35.dat</code>
</td><td>
</td><td>Raw data for country flag in size 35x35</td></tr><tr><td>
<code class="filename">flags_thumb60x60.dat</code>
</td><td>
</td><td>Raw data for country flag in size 60x60</td></tr><tr><td>
<code class="filename">gd_image.inc.php</code>
</td><td>
</td><td>Interface classes to the low level GD library</td></tr><tr><td>
<code class="filename">imgdata_balls.inc.php</code>
</td><td>
</td><td>Stored image data for marker images</td></tr><tr><td>
<code class="filename">imgdata_bevels.inc.php</code>
</td><td>
</td><td>Stored image data for marker images</td></tr><tr><td>
<code class="filename">imgdata_diamonds.inc.php</code>
</td><td>
</td><td>Stored image data for marker images</td></tr><tr><td>
<code class="filename">imgdata_pushpins.inc.php</code>
</td><td>
</td><td>Stored image data for marker images</td></tr><tr><td>
<code class="filename">imgdata_squares.inc.php</code>
</td><td>
</td><td>Stored image data for marker images</td></tr><tr><td>
<code class="filename">imgdata_stars.inc.php</code>
</td><td>
</td><td>Stored image data for marker images</td></tr><tr><td>
<code class="filename">jpg-config.inc.php</code>
</td><td>
</td><td>Configuration file for the library</td></tr><tr><td>
<code class="filename">jpgraph_antispam-digits.php</code>
</td><td>
</td><td>Image data for CAPTCHA digits</td></tr><tr><td>
<code class="filename">jpgraph_antispam.php</code>
</td><td>
</td><td>Extension module: CAPTCHA figures</td></tr><tr><td>
<code class="filename">jpgraph_bar.php</code>
</td><td>
</td><td>Extension module: Bargraphs</td></tr><tr><td>
<code class="filename">jpgraph_canvas.php</code>
</td><td>
</td><td>Extension module: Canvas graphs</td></tr><tr><td>
<code class="filename">jpgraph_canvtools.php</code>
</td><td>
</td><td>Extension module: Tools for canvas graphs</td></tr><tr><td>
<code class="filename">jpgraph_date.php</code>
</td><td>
</td><td>Extension module: Date scale handling</td></tr><tr><td>
<code class="filename">jpgraph_errhandler.inc.php</code>
</td><td>
</td><td>Core module: Error handler</td></tr><tr><td>
<code class="filename">jpgraph_error.php</code>
</td><td>
</td><td>Extension module: Error plots</td></tr><tr><td>
<code class="filename">jpgraph_flags.php</code>
</td><td>
</td><td>Extension module: Country flags</td></tr><tr><td>
<code class="filename">jpgraph_gantt.php</code>
</td><td>
</td><td>Extension module: Gantt chart</td></tr><tr><td>
<code class="filename">jpgraph_gb2312.php</code>
</td><td>
</td><td>Extension module: GB2312 (Chinese) encoding</td></tr><tr><td>
<code class="filename">jpgraph_gradient.php</code>
</td><td>
</td><td>Extension module: Gradient fill</td></tr><tr><td>
<code class="filename">jpgraph_iconplot.php</code>
</td><td>
</td><td>Extension module: Icon images in plots</td></tr><tr><td>
<code class="filename">jpgraph_imgtrans.php</code>
</td><td>
</td><td>Extension module: Image transformation</td></tr><tr><td>
<code class="filename">jpgraph_led.php</code>
</td><td>
</td><td>Extension module: LED digits/numbers</td></tr><tr><td>
<code class="filename">jpgraph_legend.inc.php</code>
</td><td>
</td><td>Core module: Legend handling</td></tr><tr><td>
<code class="filename">jpgraph_line.php</code>
</td><td>
</td><td>Extension module: Line plot</td></tr><tr><td>
<code class="filename">jpgraph_log.php</code>
</td><td>
</td><td>Extension module: Log scale</td></tr><tr><td>
<code class="filename">jpgraph_mgraph.php</code>
</td><td>
</td><td>Extension module: Multigraph canvas</td></tr><tr><td>
<code class="filename">jpgraph.php</code>
</td><td>
</td><td>Core module: JpGraph core module</td></tr><tr><td>
<code class="filename">jpgraph_pie3d.php</code>
</td><td>
</td><td>Extension module: 3D Pie plot</td></tr><tr><td>
<code class="filename">jpgraph_pie.php</code>
</td><td>
</td><td>Extension module: 2D Pie plot</td></tr><tr><td>
<code class="filename">jpgraph_plotband.php</code>
</td><td>
</td><td>Extension module: Plot bands (filled areas in graphs)</td></tr><tr><td>
<code class="filename">jpgraph_plotmark.inc.php</code>
</td><td>
</td><td>Extension module: Plotmark for line plots</td></tr><tr><td>
<code class="filename">jpgraph_polar.php</code>
</td><td>
</td><td>Extension module: Polar plots</td></tr><tr><td>
<code class="filename">jpgraph_radar.php</code>
</td><td>
</td><td>Extension module:: Radar plot</td></tr><tr><td>
<code class="filename">jpgraph_regstat.php</code>
</td><td>
</td><td>Extension module: Spline and Bezier curves</td></tr><tr><td>
<code class="filename">jpgraph_rgb.inc.php</code>
</td><td>
</td><td>Core module: Color handling</td></tr><tr><td>
<code class="filename">jpgraph_scatter.php</code>
</td><td>
</td><td>Extension module:: Scatter plot</td></tr><tr><td>
<code class="filename">jpgraph_stock.php</code>
</td><td>
</td><td>Extension module:: Stock charts</td></tr><tr><td>
<code class="filename">jpgraph_text.inc.php</code>
</td><td>
</td><td>Core module: Text handling</td></tr><tr><td>
<code class="filename">jpgraph_ttf.inc.php</code>
</td><td>
</td><td>Core module: TTF font handling</td></tr><tr><td>
<code class="filename">jpgraph_utils.inc.php</code>
</td><td>
</td><td>Extension module:: Various utility classes</td></tr><tr><td>
<code class="filename">jpgraph_layout_vh.inc.php</code>
</td><td>
</td><td>Extension utility: classes for automatic layout classes</td></tr><tr><td>
<code class="filename">jpgraph_odo.php</code>
</td><td align="center">*</td><td>Extension module: Odometer plot</td></tr><tr><td>
<code class="filename">jpgraph_windrose.php</code>
</td><td align="center">*</td><td>Extension module:: Windrose plots</td></tr><tr><td>
<code class="filename">jpgraph_table.php</code>
</td><td align="center">*</td><td>Extension module:: Graphic tables</td></tr><tr><td>
<code class="filename">jpgraph_barcode.php</code>
</td><td align="center">*</td><td>Extension module: 1D Barcodes</td></tr><tr><td>
<code class="filename">jpgraph_matrix.php</code>
</td><td align="center">*</td><td>Extension module: Matrix plots</td></tr></tbody></table></div></div><br class="table-break"><p>In addition to the files above the distribution contains the following directories</p><div class="table"><a name="id2672820"></a><p class="title"><b>Table G.2. List of subdirectories in main <code class="filename">src</code> directory</b></p><div class="table-contents"><table summary="List of subdirectories in main src directory" border="0"><colgroup><col><col><col></colgroup><thead><tr><th>Directory</th><th>Only Pro Version</th><th>Description</th></tr></thead><tbody><tr><td>
<code class="filename">Examples</code>
</td><td>
</td><td>JpGraph Example directory</td></tr><tr><td>
<code class="filename">lang</code>
</td><td>
</td><td>Localized error messages</td></tr><tr><td>
<code class="filename">barcode</code>
</td><td align="center">*</td><td>1D Barcodes</td></tr><tr><td>
<code class="filename">datamatrix</code>
</td><td align="center">*</td><td>2D Barcode Datamatrix directory</td></tr><tr><td>
<code class="filename">pdf417</code>
</td><td align="center">*</td><td>2D Barcode PDF417 directory</td></tr><tr><td>
<code class="filename">QR</code>
</td><td align="center">*</td><td>2D Barcode QR (Quick response) directory</td></tr><tr><td>
<code class="filename">table_examples</code>
</td><td align="center">*</td><td>Table examples</td></tr><tr><td>
<code class="filename">windrose_examples</code>
</td><td align="center">*</td><td>Windrose examples</td></tr><tr><td>
<code class="filename">odometer_examples</code>
</td><td align="center">*</td><td>Odometer examples</td></tr><tr><td>
<code class="filename">matrix_examples</code>
</td><td align="center">*</td><td>Matrix plot examples</td></tr></tbody></table></div></div><br class="table-break"></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="apf.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="pt08.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="aph.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appendix F. List of all country flags </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Appendix H. Error messages</td></tr></table></div></body></html>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,194 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>H.2. QR 2D Barcode error messages</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="aph.html" title="Appendix H. Error messages"><link rel="prev" href="aph.html" title="Appendix H. Error messages"><link rel="next" href="aphs03.html" title="H.3. Datamatrix 2D barcode error messages"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">H.2. QR 2D Barcode error messages</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="aph.html">Prev</a> </td><th width="60%" align="center">Appendix H. Error messages</th><td width="20%" align="right"> <a accesskey="n" href="aphs03.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2678603"></a>H.2. QR 2D Barcode error messages</h2></div></div></div><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>These error messages are not yet localized</p></div><p>
</p><p>
</p><div class="table"><a name="id2678624"></a><p class="title"><b>Table H.2. English error messages</b></p><div class="table-contents"><table summary="English error messages" border="0"><colgroup><col><col></colgroup><thead><tr><th> Error code </th><th> Error message </th></tr></thead><tbody><tr><td>
<code class="code">1000</code>
</td><td class="errmsg">Tilde processing is not yet supported for QR
Barcodes.</td></tr><tr><td>
<code class="code">1001</code>
</td><td class="errmsg">Inverting the bit pattern is not supported
for QR Barcodes.</td></tr><tr><td>
<code class="code">1002</code>
</td><td class="errmsg">Cannot read data from file %s</td></tr><tr><td>
<code class="code">1003</code>
</td><td class="errmsg">Cannot open file %s</td></tr><tr><td>
<code class="code">1004</code>
</td><td class="errmsg">Cannot write QR barcode to file %s</td></tr><tr><td>
<code class="code">1005</code>
</td><td class="errmsg">Unsupported image format selected. Check
your GD installation</td></tr><tr><td>
<code class="code">1006</code>
</td><td class="errmsg">Cannot set the selected barcode colors.
Check your GD installation and spelling of color
name</td></tr><tr><td>
<code class="code">1007</code>
</td><td class="errmsg">
<p>
<span class="bold"><strong>JpGraph Error: HTTP headers have
already been sent.</strong></span>
</p>
<p>Caused by output from file %s at line %d. </p>
<p>Explanation: HTTP headers have already been sent back
to the browser indicating the data as text before the
library got a chance to send it's image HTTP header to
this browser. </p>
<p>This makes it impossible for the library to send back
image data to the browser (since that would be
interpreted as text by the browser and show up as junk
text). Most likely you have some text in your script
before the call to Graph::Stroke(). If this texts gets
sent back to the browser the browser will assume that
all data is plain text. Look for any text, even spaces
and newlines, that might have been sent back to the
browser. For example it is a common mistake to leave a
blank line before the opening </p>
</td></tr><tr><td>
<code class="code">1008</code>
</td><td class="errmsg">Could not create the barcode image with
image format=%s. Check your GD/PHP installation.</td></tr><tr><td>
<code class="code">1009</code>
</td><td class="errmsg">Cannot open log file %s for writing.</td></tr><tr><td>
<code class="code">1010</code>
</td><td class="errmsg">Cannot write log info to log file
%s.</td></tr><tr><td>
<code class="code">1100</code>
</td><td class="errmsg">Internal error: Illegal mask pattern
selected</td></tr><tr><td>
<code class="code">1101</code>
</td><td class="errmsg">Internal error: Trying to apply masking to
functional pattern.</td></tr><tr><td>
<code class="code">1102</code>
</td><td class="errmsg">Internal error: applyMaskAndEval(): Found
uninitialized module in matrix when applying mask
pattern.</td></tr><tr><td>
<code class="code">1200</code>
</td><td class="errmsg">Internal error: Was expecting %d bits in
version %d to be placed in matrix but got %d bits</td></tr><tr><td>
<code class="code">1201</code>
</td><td class="errmsg">Internal error: Trying to position bit
outside the matrix x=%d, y=%d, size=%d, bIdx=%d</td></tr><tr><td>
<code class="code">1202</code>
</td><td class="errmsg">Internal error: Trying to put data in
initialized bit.</td></tr><tr><td>
<code class="code">1203</code>
</td><td class="errmsg">Internal error: Mask number for format bits
is invalid. (maskidx=%d)</td></tr><tr><td>
<code class="code">1204</code>
</td><td class="errmsg">Internal error: Found an uninitialized bit
[val=%d] at (%d,%d) when flattening matrix</td></tr><tr><td>
<code class="code">1300</code>
</td><td class="errmsg">Internal error: QRCapacity::getFormatBits()
Was expecting a format in range [0,31] got %d</td></tr><tr><td>
<code class="code">1301</code>
</td><td class="errmsg">Internal error: QRCapacity::getVersionBits()
Was expecting a version in range [7,40] got %d</td></tr><tr><td>
<code class="code">1302</code>
</td><td class="errmsg">Internal error: QRCapacity::_chkVerErr() Was
expecting version in range [1,40] and error level in range
[0,3] got (%d,%d)</td></tr><tr><td>
<code class="code">1303</code>
</td><td class="errmsg">Internal error:
QRCapacity::getAlignmentPositions() Expected %d patterns but
found %d patterns (len=%d).</td></tr><tr><td>
<code class="code">1304</code>
</td><td class="errmsg">Internal error: QRCapacity::%s Was expecting
a version in range [1,40] got %d</td></tr><tr><td>
<code class="code">1400</code>
</td><td class="errmsg">QR Version must be specified as a value in
the range [1,40] got %d</td></tr><tr><td>
<code class="code">1401</code>
</td><td class="errmsg">Input data to barcode can not be
empty.</td></tr><tr><td>
<code class="code">1402</code>
</td><td class="errmsg">Automatic encodation mode was specified but
input data looks like specification for manual
encodation.</td></tr><tr><td>
<code class="code">1403</code>
</td><td class="errmsg">Was expecting an array of arrays as input
data for manual encoding.</td></tr><tr><td>
<code class="code">1404</code>
</td><td class="errmsg">Each input data array element must consist
of two entries. Element $i has of $nn entries</td></tr><tr><td>
<code class="code">1405</code>
</td><td class="errmsg">Each input data array element must consist
of two entries with first entry being the encodation
constant and the second element the data string. Element %d
is incorrect in this respect.</td></tr><tr><td>
<code class="code">1406</code>
</td><td class="errmsg">Was expecting either a string or an array as
input data</td></tr><tr><td>
<code class="code">1407</code>
</td><td class="errmsg">Manual encodation mode was specified but
input data looks like specification for automatic
encodation.</td></tr><tr><td>
<code class="code">1408</code>
</td><td class="errmsg">Input data too large to fit into one QR
Symbol</td></tr><tr><td>
<code class="code">1409</code>
</td><td class="errmsg">The selected symbol version %d is too small
to fit the specified data and selected error correction
level.</td></tr><tr><td>
<code class="code">1410</code>
</td><td class="errmsg">Trying to read past the last available
codeword in block split.</td></tr><tr><td>
<code class="code">1411</code>
</td><td class="errmsg">Internal error: Expected 1 or 2 as the
number of block structures.</td></tr><tr><td>
<code class="code">1412</code>
</td><td class="errmsg">Internal error: Too many codewords for
chosen symbol version. (negative number of pad
codewords).</td></tr><tr><td>
<code class="code">1413</code>
</td><td class="errmsg">Internal error: splitInBytes: Expected an
even number of 8-bit blocks.</td></tr><tr><td>
<code class="code">1414</code>
</td><td class="errmsg">Internal error: getCountBits() illegal
version number (=%d).</td></tr><tr><td>
<code class="code">1415</code>
</td><td class="errmsg">Manually specified encodation schema
MODE_NUMERIC has no data that can be encoded using this
schema.</td></tr><tr><td>
<code class="code">1416</code>
</td><td class="errmsg">Manually specified encodation schema
MODE_ALPHANUM has no data that can be encoded using this
schema.</td></tr><tr><td>
<code class="code">1417</code>
</td><td class="errmsg">Manually specified encodation schema
MODE_BYTE has no data that can be encoded using this
schema.</td></tr><tr><td>
<code class="code">1418</code>
</td><td class="errmsg">Unsupported encodation schema specified
(%d)</td></tr><tr><td>
<code class="code">1419</code>
</td><td class="errmsg">Found character in data stream that cannot
be encoded with the selected manual encodation mode.</td></tr><tr><td>
<code class="code">1420</code>
</td><td class="errmsg">Encodation using KANJI mode not yet
supported.</td></tr><tr><td>
<code class="code">1421</code>
</td><td class="errmsg">Internal error: Unsupported encodation mode
doAuto().</td></tr><tr><td>
<code class="code">1422</code>
</td><td class="errmsg">Found unknown characters in the data stream
that can't be encoded with any available encodation
mode.</td></tr><tr><td>
<code class="code">1423</code>
</td><td class="errmsg">Kanji character set not yet
supported.</td></tr><tr><td>
<code class="code">1424</code>
</td><td class="errmsg">Internal error: DataStorage:: Unsupported
character mode (%d) DataStorage::Remaining()</td></tr><tr><td>
<code class="code">1425</code>
</td><td class="errmsg">Internal error: DataStorage:: Trying to
extract slice of len=%d (with type=%d) when there are only
%d elements left</td></tr><tr><td>
<code class="code">1426</code>
</td><td class="errmsg">Internal error: DataStorage:: Trying to read
past input data length.</td></tr><tr><td>
<code class="code">1427</code>
</td><td class="errmsg">Expected either DIGIT, ALNUM or BYTE but
found ASCII code=%d</td></tr><tr><td>
<code class="code">1428</code>
</td><td class="errmsg">Internal error: DataStorage::Peek() Trying
to peek past input data length.</td></tr></tbody></table></div></div><p><br class="table-break">
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="aph.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="aph.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="aphs03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appendix H. Error messages </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> H.3. Datamatrix 2D barcode error messages</td></tr></table></div></body></html>

View File

@ -0,0 +1,112 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>H.3. Datamatrix 2D barcode error messages</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="aph.html" title="Appendix H. Error messages"><link rel="prev" href="aphs02.html" title="H.2. QR 2D Barcode error messages"><link rel="next" href="api.html" title="Appendix I. Compiling PHP"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">H.3. Datamatrix 2D barcode error messages</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="aphs02.html">Prev</a> </td><th width="60%" align="center">Appendix H. Error messages</th><td width="20%" align="right"> <a accesskey="n" href="api.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2679880"></a>H.3. Datamatrix 2D barcode error messages</h2></div></div></div><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>These error messages are not yet localized</p></div><p>
</p><p>
</p><div class="table"><a name="id2679902"></a><p class="title"><b>Table H.3. English error messages</b></p><div class="table-contents"><table summary="English error messages" border="0"><colgroup><col><col></colgroup><thead><tr><th> Error code </th><th> Error message </th></tr></thead><tbody><tr><td>
<code class="code">1</code>
</td><td class="errmsg">Data is too long to fit specified symbol
size</td></tr><tr><td>
<code class="code">2</code>
</td><td class="errmsg">The BASE256 data is too long to fit
available symbol size</td></tr><tr><td>
<code class="code">3</code>
</td><td class="errmsg">Data must have at least three characters for
C40 encodation</td></tr><tr><td>
<code class="code">4</code>
</td><td class="errmsg">Data must have at least three characters for
TEXT encodation</td></tr><tr><td>
<code class="code">5</code>
</td><td class="errmsg">Internal error: (-5) Trying to read source
data past the end</td></tr><tr><td>
<code class="code">6</code>
</td><td class="errmsg">Internal error: (-6) Trying to look ahead in
data past the end</td></tr><tr><td>
<code class="code">7</code>
</td><td class="errmsg">Internal error: (-7) Logic error in TEXT/C40
encodation (impossible branch)</td></tr><tr><td>
<code class="code">8</code>
</td><td class="errmsg">The given data can not be encoded using X12
encodation.</td></tr><tr><td>
<code class="code">9</code>
</td><td class="errmsg">The "tilde" encoded data is not
valid.</td></tr><tr><td>
<code class="code">10</code>
</td><td class="errmsg">Data must have at least three characters for
X12 encodation</td></tr><tr><td>
<code class="code">11</code>
</td><td class="errmsg">Specified data can not be encoded with
datamatrix 000 140</td></tr><tr><td>
<code class="code">12</code>
</td><td class="errmsg">Can not create image</td></tr><tr><td>
<code class="code">13</code>
</td><td class="errmsg">Invalid color specification</td></tr><tr><td>
<code class="code">14</code>
</td><td class="errmsg">Internal error: (-14) Index for 140 bit
placement matrix out of bounds</td></tr><tr><td>
<code class="code">15</code>
</td><td class="errmsg">This PHP installation does not support the
chosen image encoding format</td></tr><tr><td>
<code class="code">16</code>
</td><td class="errmsg">Internal error: (-16) Cannot instantiate
ReedSolomon</td></tr><tr><td>
<code class="code">20</code>
</td><td class="errmsg">The specification for shape of matrix is out
of bounds (0,29)</td></tr><tr><td>
<code class="code">21</code>
</td><td class="errmsg">Cannot open the data file specifying bit
placement for Datamatrix 200</td></tr><tr><td>
<code class="code">22</code>
</td><td class="errmsg">Datafile for bit placement is corrupt, crc
checks fails.</td></tr><tr><td>
<code class="code">23</code>
</td><td class="errmsg">Internal error: (-23) Output matrice is not
big enough for mapping matrice</td></tr><tr><td>
<code class="code">24</code>
</td><td class="errmsg">Internal error: (-24) Bit sequence to be
placed is too short for the chosen output matrice</td></tr><tr><td>
<code class="code">25</code>
</td><td class="errmsg">Internal error: (-25) Shape index out of
bounds for bit placement</td></tr><tr><td>
<code class="code">26</code>
</td><td class="errmsg">Cannot open the data file specifying bit
placement for Datamatrix 140</td></tr><tr><td>
<code class="code">30</code>
</td><td class="errmsg">The symbol size specified for ECC140 type
Datamatrix is not valid</td></tr><tr><td>
<code class="code">31</code>
</td><td class="errmsg">Data is to long to fit into any available
matrice size for datamatrix 140</td></tr><tr><td>
<code class="code">32</code>
</td><td class="errmsg">Internal error: (-32) Cannot instantiate
MasterRandom</td></tr><tr><td>
<code class="code">33</code>
</td><td class="errmsg">Internal error: (-33) Failed to randomize
140 bit stream</td></tr><tr><td>
<code class="code">34</code>
</td><td class="errmsg">Cannot open file %s for writing</td></tr><tr><td>
<code class="code">35</code>
</td><td class="errmsg">Cannot write to file %s </td></tr><tr><td>
<code class="code">99</code>
</td><td class="errmsg">EDIFACT encodation not implemented</td></tr><tr><td>
<code class="code">100</code>
</td><td class="errmsg">
<p>
<span class="bold"><strong>JpGraph Error: HTTP headers have
already been sent.</strong></span>
</p>
<p>Caused by output from file %s at line %d. </p>
<p>Explanation: HTTP headers have already been sent back
to the browser indicating the data as text before the
library got a chance to send it's image HTTP header to
this browser. </p>
<p>This makes it impossible for the library to send back
image data to the browser (since that would be
interpreted as text by the browser and show up as junk
text). Most likely you have some text in your script
before the call to Graph::Stroke(). If this texts gets
sent back to the browser the browser will assume that
all data is plain text. Look for any text, even spaces
and newlines, that might have been sent back to the
browser. For example it is a common mistake to leave a
blank line before the opening </p>
</td></tr></tbody></table></div></div><p><br class="table-break">
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="aphs02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="aph.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="api.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">H.2. QR 2D Barcode error messages </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Appendix I. Compiling PHP</td></tr></table></div></body></html>

View File

@ -0,0 +1,90 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Appendix I. Compiling PHP</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="pt08.html" title="Part VIII. Appendices"><link rel="prev" href="aphs03.html" title="H.3. Datamatrix 2D barcode error messages"><link rel="next" href="apis02.html" title="I.2. Compiling PHP5"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Appendix I. Compiling PHP</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="aphs03.html">Prev</a> </td><th width="60%" align="center">Part VIII. Appendices</th><td width="20%" align="right"> <a accesskey="n" href="apis02.html">Next</a></td></tr></table><hr></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="app.compile-php"></a>Appendix I. Compiling PHP</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="api.html#id2680785">I.1. Compiling PHP4</a></span></dt><dd><dl><dt><span class="sect2"><a href="api.html#id2680792">I.1.1. Client version</a></span></dt><dt><span class="sect2"><a href="api.html#id2680803">I.1.2. Apache module</a></span></dt><dt><span class="sect2"><a href="api.html#id2680815">I.1.3. CGI extension</a></span></dt></dl></dd><dt><span class="sect1"><a href="apis02.html">I.2. Compiling PHP5</a></span></dt><dd><dl><dt><span class="sect2"><a href="apis02.html#id2680834">I.2.1. Client version</a></span></dt><dt><span class="sect2"><a href="apis02.html#id2680846">I.2.2. Apache module</a></span></dt><dt><span class="sect2"><a href="apis02.html#id2680858">I.2.3. CGI extension</a></span></dt></dl></dd></dl></div><p>Usually the included PHP version is adequate but if problems persists it is a good idea to
be able to compile PHP yourself. This way you will also be able to more quickly upgrade to
newer version of PHP which might have fix for a particular nasty bug that may have crept
in.</p><p> In the following sections we give examples of Unix shell scripts that will show typical
compile configuration for a downloaded PHP distribution. These compile configuration scripts
will make both the GD and FreeType libraries included in the executable. </p><p>In order to compile your downloaded PHP distribution first copy and save these scripts to
a local file and make that file runnable. Then run one of the selected configurations below
and do a normal "make". </p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3><p>When running <code class="code">make</code> you can speed up the compilation by telling make to use
a number of parallel compile processes. Since most modern system have at least two cores
a typical invocation of make would be to make use of three parallel compile time
processes. This is done by using the <code class="code">-j</code> argument. For example as
</p><pre class="screen">make -j3</pre></div><p>It is possible to compile PHP into (at least) three variants </p><div class="orderedlist"><ol type="1"><li><p>as a command line tool</p></li><li><p>as a Apache extension module (this is probably the most common variant)</p></li><li><p>as a CGI module to be used by a HTTP server (this is slower than running PHP
as a module since it needs to be read from disk and the process created every
time a PHP script needs to be executed.)</p></li></ol></div><p>There is one crucial difference of importance when using PHP to generate
images. Both the CGI module and the client variant are both standalone executables so what
is the difference? The crucial difference is that the CGI module will by default output a
MIME header before it outputs data while the client version will not. </p><p>The following sections have one compile script for each of the three major
versions.</p><div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3><p>You should make sure that the proposed directory paths in the scripts match your
particular server setup as this can vary from system to system. </p></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2680785"></a>I.1. Compiling PHP4</h2></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2680792"></a>I.1.1. Client version</h3></div></div></div><pre class="screen">#! /bin/sh
./configure --prefix=/usr/share --datadir=/usr/share/php \
--libdir=/usr/share/php --includedir=/usr/include \
--bindir=/usr/bin \
--with-config-file-path=/etc/php4/cli \
--with-config-file-scan-dir=/etc/php4/cli \
--enable-mbstring --enable-mbregex \
--with-mysql \
--with-gd --enable-gd-imgstrttf --enable-gd-native-ttf \
--with-zlib-dir=/usr/lib \
--with-png-dir=/usr/lib --with-jpeg-dir=/usr/lib --with-xpm-dir=/usr/X11R6 \
--with-tiff-dir=/usr/lib --with-ttf-dir=/usr/lib \
--with-freetype-dir=/usr/lib \
--enable-ftp \
--enable-memory-limit \
--enable-bcmath -enable-calendar \
--enable-ctype --with-ftp \
--enable-magic-quotes \
--enable-inline-optimization \
--with-bz2 \
--with-iconv
</pre></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2680803"></a>I.1.2. Apache module</h3></div></div></div><pre class="screen">#! /bin/sh
./configure --prefix=/usr/share --datadir=/usr/share/php --with-apxs2=/usr/sbin/apxs2 \
--libdir=/usr/share --includedir=/usr/include \
--bindir=/usr/bin \
--with-config-file-path=/etc/php4/apache2 \
--enable-mbstring --enable-mbregex \
--with-mysql \
--with-gd --enable-gd-imgstrttf --enable-gd-native-ttf \
--with-zlib-dir=/usr/lib \
--with-png-dir=/usr/lib --with-jpeg-dir=/usr/lib --with-xpm-dir=/usr/X11R6 \
--with-tiff-dir=/usr/lib --with-ttf-dir=/usr/lib \
--with-freetype-dir=/usr/lib \
--enable-ftp \
--enable-memory-limit \
--bindir=/usr/bin \
--enable-bcmath \
--enable-calendar \
--enable-ctype \
--with-ftp \
--enable-magic-quotes \
--enable-inline-optimization \
--with-bz2 \
--with-iconv
</pre></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2680815"></a>I.1.3. CGI extension</h3></div></div></div><pre class="screen">#! /bin/sh
./configure --prefix=/usr/share --datadir=/usr/share/php \
--libdir=/usr/share --includedir=/usr/include \
--bindir=/usr/bin \
--with-config-file-path=/etc/php4/apache2 \
--with-config-file-scan=/etc/php4/apache2 \
--enable-mbstring --enable-mbregex \
--with-mysql \
--with-gd --enable-gd-imgstrttf --enable-gd-native-ttf \
--with-zlib-dir=/usr/lib \
--with-png-dir=/usr/lib --with-jpeg-dir=/usr/lib --with-xpm-dir=/usr/X11R6 \
--with-tiff-dir=/usr/lib --with-ttf-dir=/usr/lib \
--with-freetype-dir=/usr/lib \
--enable-ftp \
--enable-memory-limit \
--bindir=/usr/bin \
--enable-bcmath \
--enable-calendar \
--enable-ctype \
--with-ftp \
--enable-magic-quotes \
--enable-inline-optimization \
--with-bz2 \
--with-iconv
</pre></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="aphs03.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="pt08.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apis02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">H.3. Datamatrix 2D barcode error messages </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> I.2. Compiling PHP5</td></tr></table></div></body></html>

View File

@ -0,0 +1,84 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>I.2. Compiling PHP5</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="api.html" title="Appendix I. Compiling PHP"><link rel="prev" href="api.html" title="Appendix I. Compiling PHP"><link rel="next" href="apj.html" title="Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">I.2. Compiling PHP5</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="api.html">Prev</a> </td><th width="60%" align="center">Appendix I. Compiling PHP</th><td width="20%" align="right"> <a accesskey="n" href="apj.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2680828"></a>I.2. Compiling PHP5</h2></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2680834"></a>I.2.1. Client version</h3></div></div></div><pre class="screen">#! /bin/sh
# mkphp5-cli
# Build a command line version of PHP5
./configure \
--prefix=/usr/share/php5 \
--datadir=/usr/share/php5 \
--libdir=/usr/share/php5 \
--includedir=/usr/include/php5 \
--enable-force-cgi-redirect \
--bindir=/usr/bin \
--with-config-file-path=/etc/php5/cli \
--with-config-file-scan-dir=/etc/php5/cli \
--enable-mbstring --enable-mbregex \
--with-mysql \
--with-gd --enable-gd-imgstrttf --enable-gd-native-ttf \
--with-zlib-dir=/usr/lib \
--with-png-dir=/usr/lib --with-jpeg-dir=/usr/lib --with-xpm-dir=/usr/X11R6 \
--with-tiff-dir=/usr/lib --with-ttf-dir=/usr/lib \
--with-freetype-dir=/usr/lib \
--enable-ftp \
--enable-memory-limit \
--enable-safe-mode \
--enable-bcmath -enable-calendar \
--enable-ctype \
--with-ftp \
--enable-magic-quotes \
--enable-inline-optimization \
--enable-tokenizer \
--with-bz2 \
--with-iconv \
--with-pear=/usr/share/php5
</pre></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2680846"></a>I.2.2. Apache module</h3></div></div></div><pre class="screen">#! /bin/sh
# mkphp5-sapi
# Build a SAPI (Apache module) version of PHP5
./configure --prefix=/usr/share \
--datadir=/usr/share/php --with-apxs2=/usr/sbin/apxs2 \
--libdir=/usr/share --includedir=/usr/include \
--bindir=/usr/bin \
--with-config-file-path=/etc/php5/apache2 \
--enable-mbstring --enable-mbregex \
--with-mysql \
--with-gd --enable-gd-imgstrttf --enable-gd-native-ttf \
--with-zlib-dir=/usr/lib \
--with-png-dir=/usr/lib --with-jpeg-dir=/usr/lib --with-xpm-dir=/usr/X11R6 \
--with-tiff-dir=/usr/lib --with-ttf-dir=/usr/lib \
--with-freetype-dir=/usr/lib \
--enable-ftp \
--enable-memory-limit --enable-safe-mode \
--bindir=/usr/bin \
--enable-bcmath -enable-calendar \
--enable-ctype --with-ftp \
--enable-magic-quotes \
--enable-inline-optimization \
--with-bz2 \
--with-iconv
!#</pre></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2680858"></a>I.2.3. CGI extension</h3></div></div></div><pre class="screen">#! /bin/sh
# mkphp5-cgi
# Build a CGI version of PHP5
./configure --prefix=/usr/share \
--datadir=/usr/share/php \
--libdir=/usr/share --includedir=/usr/include \
--enable-force-cgi-redirect \
--bindir=/usr/bin \
--with-config-file-path=/etc/php5/apache2 \
--enable-mbstring --enable-mbregex \
--with-mysql \
--with-gd --enable-gd-native-ttf \
--with-zlib-dir=/usr/lib \
--with-png-dir=/usr/lib --with-jpeg-dir=/usr/lib --with-xpm-dir=/usr/X11R6 \
--with-freetype-dir=/usr/lib \
--enable-ftp \
--enable-safe-mode \
--bindir=/usr/bin \
--enable-bcmath -enable-calendar \
--enable-ctype \
--enable-magic-quotes \
--enable-inline-optimization \
--enable-tokenizer \
--with-bz2 \
--with-iconv
</pre></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="api.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="api.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apj.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appendix I. Compiling PHP </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1</td></tr></table></div></body></html>

View File

@ -0,0 +1,54 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="pt08.html" title="Part VIII. Appendices"><link rel="prev" href="apis02.html" title="I.2. Compiling PHP5"><link rel="next" href="apjs02.html" title="J.2. Making sure you have the correct Apache2 setup"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apis02.html">Prev</a> </td><th width="60%" align="center">Part VIII. Appendices</th><td width="20%" align="right"> <a accesskey="n" href="apjs02.html">Next</a></td></tr></table><hr></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="app.setting-up-parallel-servers"></a>Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="apj.html#id2680924">J.1. Configuration files and directories for Apache2 in SuSE 10.1</a></span></dt><dt><span class="section"><a href="apjs02.html">J.2. Making sure you have the correct Apache2 setup</a></span></dt><dt><span class="section"><a href="apjs03.html">J.3. Approaches to running multiple PHP versions</a></span></dt><dt><span class="section"><a href="apjs04.html">J.4. Outline of the remainder of the chapter</a></span></dt><dt><span class="section"><a href="apjs05.html">J.5. Part I - Installing PHP4</a></span></dt><dd><dl><dt><span class="section"><a href="apjs05.html#id2681423">J.5.1. Step one; Compiling PHP4 as a module for Apache2</a></span></dt><dt><span class="section"><a href="apjs05.html#id2681721">J.5.2. Step two; Enable the PHP4 module in the Apache2 configuration</a></span></dt></dl></dd><dt><span class="section"><a href="apjs06.html">J.6. Part II - Creating a virtual host</a></span></dt><dd><dl><dt><span class="section"><a href="apjs06.html#id2681878">J.6.1. Step 1; Adding an alias IP-address to Your server</a></span></dt><dt><span class="section"><a href="apjs06.html#id2681896">J.6.2. Step 2; Creating different document and cgi roots</a></span></dt><dt><span class="section"><a href="apjs06.html#id2681914">J.6.3. Step 3; Configure Apache with a virtual host</a></span></dt></dl></dd><dt><span class="section"><a href="apjs07.html">J.7. Part III - Installing PHP5</a></span></dt><dt><span class="section"><a href="apjs08.html">J.8. Part IV - Verifying the setup</a></span></dt><dd><dl><dt><span class="section"><a href="apjs08.html#id2682186">J.8.1. Troubleshooting</a></span></dt></dl></dd></dl></div><p>Even though PHP4 is officially deprecated and is no longer actively maintained a large
number of existing installations are stiil (and will be) using PHP4. For this reason it can
be important to be able to test scripts running both PHP4 and PHP5. This section shows how
to do this on Linux SuSE 10.1 installation. Other Linux dialects can use similar but not
identical setups.</p><p>SuSE 10.1 ships with Apache2 and PHP5 as standard. In order to install PHP4 in parallel
some extra work is therefore required. This chapter explains how to setup both PHP4 and PHP5
on the same server by configuring Apache2 using virtual hosts. </p><p>We will show how to maintain a simultaneous installation of both PHP4 and PHP5 at the same
time without the need to run a switching script to select which PHP version to activate. In
this setup we have opted to configure Apache with two virtual hosts based on IP-address, one
host running PHP4 as a SAPI module and the other virtual host running PHP5 as a CGI
module.</p><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2680924"></a>J.1. Configuration files and directories for Apache2 in SuSE 10.1</h2></div></div></div><p>Before we start we give a short overview of where important configuration files and
directories for Apache2 are located in SuSE </p><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>The configuration files setup by SuSE is slightly different from the standard
one-single "/etc/httpd.conf" used by other systems. The way SuSE does it is to
create a hierarchy of setup files under "/etc/apache2/". While this might look
complicated at first sight it has several advantages specially when You consider
that some script have to modify and add configurations to Apache2. Doing
automatic (and safe) edits in a large config file that can also be manually
edited is almost impossible to guarantee. </p></div><p>
</p><p>
</p><div class="variablelist"><dl><dt><span class="term">Dir: /etc/apache2/</span></dt><dd><p>General configuration directory for Apache2, this is where the
"<code class="filename">httpd.conf</code>" lives. </p></dd><dt><span class="term">Dir: /etc/apache2/conf.d/</span></dt><dd><p>Module configuration files for loaded modules, for example php4.conf.
All the configuration files in this directory will be automatically read
by the main <code class="filename">httpd.conf</code> by means of an
"<code class="code">include conf.d/*.conf</code>" command so the exact name
doesn't really matter as long as the file ends in "<code class="code">*.conf</code>".
</p></dd><dt><span class="term">Dir: /etc/apache2/vhosts.d/</span></dt><dd><p>Virtual host configuration files. All files in this directory will be
automatically read by the main <code class="filename">httpd.conf</code> the exact
name doesn't really matter as long as the file ends in
"<code class="filename">*.conf</code>". Note: When yast2 is used to edit
virtual hosts it will add its "<code class="filename">yast2_*.conf</code>" in
this directory. Unfortunately the virtual host configuration in yast2 in
not without problem (bugs) for IP based virtual hosts so we prefer to
create the configuration files manually. This will be shown later on in
this article. </p></dd><dt><span class="term">File: /etc/sysconfig/apache2</span></dt><dd><p>This is the main Apache2 configuration file. This file is the one that
is really used to configure apache when it is started. This is also the
file that the "Yast2" HTTPD-module edits. </p><p>From our point of view the most important thing is that this is the
place where we tell Apache2 what external modules to load. </p><p>In the SuSE configuration this is done by listing all the modules in
the string variable <code class="code">APACHE_MODULES</code>. In the SuSE
configuration there are no static "AddModule" directives in any of the
configuration files for Apache. Instead this is dynamically generated
each time apache is started (for example by /etc/init.d/apache2 start) </p><p>The generation of the actual module file names is quite clever in that
the script looks at the core module name in the
<code class="code">APACHE_MODULE</code> variable and automatically determines the
name of the file name of the load modules. This means that for PHP we
only have to give the name "php4" or "php5" as the name of the module. </p><p>The script will then discover that the name of the file load module is
in fact "<code class="filename">libphp4.so</code>" or
"<code class="filename">libphp5.so</code>" automatically. The dynamically
created list of load modules will be written to
"<code class="filename">/etc/apache2/sysconfig/loadmodule.conf</code>" just
before the startup script activates apache2 daemon which will then read
the modules from this file which is included from the main
"<code class="filename">httpd.conf</code>" file. </p></dd></dl></div><p>
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="apis02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="pt08.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apjs02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">I.2. Compiling PHP5 </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> J.2. Making sure you have the correct Apache2 setup</td></tr></table></div></body></html>

View File

@ -0,0 +1,14 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>J.2. Making sure you have the correct Apache2 setup</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="apj.html" title="Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1"><link rel="prev" href="apj.html" title="Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1"><link rel="next" href="apjs03.html" title="J.3. Approaches to running multiple PHP versions"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">J.2. Making sure you have the correct Apache2 setup</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apj.html">Prev</a> </td><th width="60%" align="center">Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1</th><td width="20%" align="right"> <a accesskey="n" href="apjs03.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2681146"></a>J.2. Making sure you have the correct Apache2 setup</h2></div></div></div><p>PHP is only guaranteed to work with the Apache2 "Prefork MPM"
(Multi-Processing-Module) and you need to have apache2-prefork installed. This also
means that the APACHE_MPM in /etc/sysconfig/apache2 must NOT be set to "worker". You can
read more about the reasons for this issues in the <code class="uri"><a class="uri" href="http://httpd.apache.org/docs-2.0/developer/thread_safety.html" target="_top">Apache
Documentation : Thread Safety</a></code> For general information about MPMs please see
<code class="uri"><a class="uri" href="http://httpd.apache.org/docs-2.0/mpm.html" target="_top">Apache Documentation :
MPM</a></code>
</p><p>If you use Yast2 to install Apache2 and the prefork module then all this will be
automatically setup. Before continuing please make sure that You have successfully
installed Apache2 on your server. For example by directing your favorite browser to
"<code class="filename">http://localhost/</code>" </p><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>There is no need to install the default SuSE PHP5 module since we must replace
that anyway with our own CGI version of PHP5. </p></div><p>
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="apj.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="apj.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apjs03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1 </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> J.3. Approaches to running multiple PHP versions</td></tr></table></div></body></html>

View File

@ -0,0 +1,25 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>J.3. Approaches to running multiple PHP versions</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="apj.html" title="Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1"><link rel="prev" href="apjs02.html" title="J.2. Making sure you have the correct Apache2 setup"><link rel="next" href="apjs04.html" title="J.4. Outline of the remainder of the chapter"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">J.3. Approaches to running multiple PHP versions</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apjs02.html">Prev</a> </td><th width="60%" align="center">Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1</th><td width="20%" align="right"> <a accesskey="n" href="apjs04.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2681205"></a>J.3. Approaches to running multiple PHP versions</h2></div></div></div><p>There are two fundamental ways of running multiple versions of PHP on the same server. </p><p>
</p><div class="orderedlist"><ol type="1"><li><p>Running multiple instances of the HTTPD demon where each instance listens
on separate addresses and/or ports. </p><p><span class="bold"><strong>Advantage:</strong></span> This is the only way to run
multiple versions of PHP as (SAPI) modules in Apache2. In addition this has
some better security since potential crashes will be isolated and not effect
the other HTTPD demons. </p><p><span class="bold"><strong>Drawback:</strong></span> Running multiple HTTPD
instances will need more system resources in terms of memory and file
handlers. </p></li><li><p>Running one instance of the HTTPD demon which is configured to serve
multiple virtual hosts. This is the approach we have chosen. </p><p><span class="bold"><strong>Advantage:</strong></span> Minimum system overhead and
relatively easy to setup. </p><p><span class="bold"><strong>Drawback:</strong></span> Only one PHP version can be run
as a (SAPI) Apache module the other PHP versions must be
configured/installed as CGI modules. This has a slight performance impact
and might not be suitable for heavily loaded production sites. (Note: that
could be overcome with the use of fast-cgi which works by pre-loading an
instance of PHP in memory which will then be used by the Apache process. See
Apache2 documentation regarding fast-cgi for more details). </p><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>There are actually two versions of virtual hosts with apache. By
name pr by IP-address. In this example we have chosen to match the
virtual hosts by IP address since for a development server we want
to be able to use plain IP addresses and not have the added
complexity of setting up a full DNS server. For more details about
other differences please see the excellent Apache2 documentation.
</p></div><p>
</p></li></ol></div><p>
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="apjs02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="apj.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apjs04.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">J.2. Making sure you have the correct Apache2 setup </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> J.4. Outline of the remainder of the chapter</td></tr></table></div></body></html>

View File

@ -0,0 +1,18 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>J.4. Outline of the remainder of the chapter</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="apj.html" title="Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1"><link rel="prev" href="apjs03.html" title="J.3. Approaches to running multiple PHP versions"><link rel="next" href="apjs05.html" title="J.5. Part I - Installing PHP4"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">J.4. Outline of the remainder of the chapter</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apjs03.html">Prev</a> </td><th width="60%" align="center">Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1</th><td width="20%" align="right"> <a accesskey="n" href="apjs05.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2681321"></a>J.4. Outline of the remainder of the chapter</h2></div></div></div><p>The approach we will use is to setup PHP4 as a (SAPI) Apache module on the default
server address and setup PHP5 as a CGI module on a virtual host. </p><p>
</p><div class="variablelist"><dl><dt><span class="term">Part I - Installing PHP4 as a SAPI module in Apache.</span></dt><dd><p>Part 1 Installing PHP4 as a SAPI module in Apache. This sections
details how to configure and compile PHP4 as a SAPI module and then do
the necessary Apache configuration modifications to enable this new
module. By the end of this section we will have the ability to run PHP4
scripts on our server. </p></dd><dt><span class="term">Part II - Creating a virtual host</span></dt><dd><p>By assigning an alias IP-address on the server we can configure Apache
with a virtual server based on this address. This new virtual server
will have its own "cgi-bin/" as well as "htdocs/" directories. This part
shows how to enable this by adding suitable configurations in Apache. By
the end of this section our server will accept HTTP calls on a secondary
IP-Address and use the specified document root for this new IP-address.
</p></dd><dt><span class="term">Part III - Installing PHP5 as a CGI module on the virtual host.</span></dt><dd><p>This final part shows how to configure and compile PHP5 as a CGI
module that we then make available for the newly created virtual host in
part 2. By the end of this module we will have PHP4 running on the
default server address and PHP5 running on the secondary virtual host.
</p></dd></dl></div><p>
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="apjs03.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="apj.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apjs05.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">J.3. Approaches to running multiple PHP versions </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> J.5. Part I - Installing PHP4</td></tr></table></div></body></html>

View File

@ -0,0 +1,154 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>J.5. Part I - Installing PHP4</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="apj.html" title="Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1"><link rel="prev" href="apjs04.html" title="J.4. Outline of the remainder of the chapter"><link rel="next" href="apjs06.html" title="J.6. Part II - Creating a virtual host"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">J.5. Part I - Installing PHP4</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apjs04.html">Prev</a> </td><th width="60%" align="center">Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1</th><td width="20%" align="right"> <a accesskey="n" href="apjs06.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2681416"></a>J.5. Part I - Installing PHP4</h2></div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2681423"></a>J.5.1. Step one; Compiling PHP4 as a module for Apache2</h3></div></div></div><p>First download the latest PHP4 tar-ball from php.net or the closest mirror and
unpack it in a temporary directory. </p><p>Since we will compile PHP4 ourself we need first to make sure a number of
libraries and the corresponding header files are installed in the system in order to
be able to compile PHP4. This is done by installing a number of "*-devel.rpm" on
your server. Depending your wanted configuration different development libraries
must be made available. </p><p>At the very minimum you will need the "apache2-devel.rpm" which provides the
"/sbin/apxs2" (Apache eXtenSion 2) command used to build modules with Apache2. Other
modules you might need are </p><p>
</p><div class="itemizedlist"><ul type="disc"><li><p>jpeg-devel.rpm </p></li><li><p>png-devel.rpm </p></li><li><p>mm-devel.rpm </p></li><li><p>xml2-devel.rpm </p></li><li><p>mysql-devel.rpm </p></li><li><p>...</p></li></ul></div><p>
</p><p>Before you compile PHP4 you need to configure it by running the "./configure"
command with the options you want to be included in PHP4. </p><p>We use a small shell script called "mkphp4-sapi" to avoid having to re-type all
the options each time we compile a new version of PHP. The options we use for a
typical development server are (you might want to use other options) </p><p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">#! /bin/sh
./configure --prefix=/usr/share \
--datadir=/usr/share/php4 \
--with-apxs2=/usr/sbin/apxs2 \
--libdir=/usr/share \
--includedir=/usr/include \
--bindir=/usr/bin \
--with-config-file-path=/etc/php4/apache2 \
--enable-mbstring --enable-mbregex \
--with-mysql \
--with-gd --enable-gd-imgstrttf --enable-gd-native-ttf \
--with-zlib-dir=/usr/lib \
--with-png-dir=/usr/lib \
--with-jpeg-dir=/usr/lib --with-xpm-dir=/usr/X11R6 \
--with-tiff-dir=/usr/lib --with-ttf-dir=/usr/lib \
--with-freetype-dir=/usr/lib \
--enable-ftp \
--enable-memory-limit --enable-safe-mode \
--bindir=/usr/bin \
--enable-bcmath -enable-calendar \
--enable-ctype --with-ftp \
--enable-magic-quotes \
--enable-inline-optimization \
--with-bz2 \
--with-iconv</span></pre></td></tr></table></div><p>
</p><p>However there are one thing You should take notice of. We have specified the
config file path (where the php.ini resides) to "/etc/php4/apache2/" as You can
probably guess from this naming convention it will make it possible to have
different ini files for both PHP4 and PHP5. In fact we have four different ini files
according to </p><p>
</p><div class="orderedlist"><ol type="1"><li><p>"<code class="filename">/etc/php4/apache2/php.ini</code>" Used by the apache
SAPI module version of PHP4 </p></li><li><p>"<code class="filename">/etc/php4/cli/php.ini</code>" Used by the standalone
client version of PHP4 (/usr/bin/php4) </p></li><li><p>"<code class="filename">/etc/php5/apache2/php.ini</code>" Used by the apache
CGI version of PHP5 </p></li><li><p>"<code class="filename">/etc/php5/cli/php.ini</code>" Used by the standalone
client version of PHP5 (/usr/bin/php5) </p></li></ol></div><p>
</p><p>When you run this you might get some errors saying that the configuration file
cannot find some library. This is a sign that you might have the library installed
but not yet have the "*-devel" RPM version added to your system which is needed
since this is where all the usual header files needed for compilation would be. </p><p>So for example if you get an error like "Cannot find PNG libraries. Please check
your that the corresponding "png-devel" library is installed and if not go back to
Yast2 and install the needed "*-devel.rpm" versions of the libraries. </p><p>When You have been able to successfully run the ./configuration command it is time
to compile. Type "make" as usual but do not type "make install", now wait until the
compilation finishes. </p><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>If you are on a Pentium4 HT or on a real dual CPU machine you can speed up
the compilation by instead giving the "make -j3" command which will start up
3 concurrent compilation processes.</p></div><p>
</p><p>Again; Do not run "<code class="code">make install</code>" since this will try to modify the
configuration files in a way that isn't SuSE friendly. </p><p>The resulting PHP4 that you have built can be found in
"<code class="filename">.libs/libphp4.so</code>". Now we only want to copy this file to
the location of the other Apache2 modules. </p><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>Again, PHP is only guaranteed to work with the non-threaded version of
Apache2, which means that you should have installed the "apache2-prefork"
MPM and NOT the "apache2-worker" MPM. </p></div><p>
</p><p>If you have correctly installed the prefork MPM several existing modules should
now be installed in "<code class="filename">/usr/lib/apache2-prefork/</code>". </p><p>So the only thing that now remains is to copy
"<code class="filename">.libs/libphp4.so</code>" to
"<code class="filename">/usr/apache2-prefork/</code>" in order for Apache to find PHP4 as
a module. </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2681721"></a>J.5.2. Step two; Enable the PHP4 module in the Apache2 configuration</h3></div></div></div><p>There are three steps to needed to enable PHP4 in Apache. </p><p>
</p><div class="orderedlist"><ol type="1"><li><p>Add php4 to the APACHE_MODULE string in "/etc/sysconfig/apache2" in
order so that the startup script in SuSE will add the appropriate
LoadModule statement so that Apache will load PHP4 as a module. In our
case our module string will look like </p><p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">APACHE_MODULES=&quot;access actions alias auth auth_dbm autoindex cgi \
dir env expires include log_config mime negotiation setenvif ssl \
suexec userdir dav dav_svn php4 &quot;</span></pre></td></tr></table></div><p>
</p></li><li><p>Telling Apache to run files ending in *.php through the PHP4 module.
This is done by specifying the MIME type which the PHP4 module
registered itself with. In addition we also tell Apache to search for
the appropriate PHP index files in case a directory name is given as the
URL. We do this by creating a file "<code class="filename">php4.conf</code>" with
the following content </p><p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">&lt;IfModule sapi_apache2.c&gt;
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .php3s
AddType application/x-httpd-php-source .php4s
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php3
DirectoryIndex index.php4
DirectoryIndex index.php
&lt;/IfModule&gt;</span></pre></td></tr></table></div><p>
</p><p>and place it in the "<code class="filename">/etc/apache2/conf.d/</code>"
directory. This will guarantee that it will be read upon startup. The
"<code class="code">IfModule</code>" statement in the beginning is just to avoid
the statements to be executed in case the PHP4 module is not loaded (we
test this by checking if the "<code class="code">sapi_apache2.c</code>" has been
activated in Apache). </p></li><li><p>The final step now is to restart Apache by doing (as root) </p><p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">$&gt; /etc/init.d/apache2 restart</span></pre></td></tr></table></div><p>
</p></li></ol></div><p>
</p><p>In order to verify that PHP has been enabled run a standard PHP script; for
example by copying the following script to "<code class="filename">/srv/www/htdocs/</code>" </p><p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-identifier">phpinfo</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
</p><p>and name it as "<code class="filename">phpinfo.php</code>" . If you now go to your favorite
browser and run this script as "http://localhost/phpinfo.php" you should get the
standard PHP4 information presented as a quite big table. </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="apjs04.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="apj.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apjs06.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">J.4. Outline of the remainder of the chapter </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> J.6. Part II - Creating a virtual host</td></tr></table></div></body></html>

View File

@ -0,0 +1,89 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>J.6. Part II - Creating a virtual host</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="apj.html" title="Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1"><link rel="prev" href="apjs05.html" title="J.5. Part I - Installing PHP4"><link rel="next" href="apjs07.html" title="J.7. Part III - Installing PHP5"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">J.6. Part II - Creating a virtual host</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apjs05.html">Prev</a> </td><th width="60%" align="center">Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1</th><td width="20%" align="right"> <a accesskey="n" href="apjs07.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2681872"></a>J.6. Part II - Creating a virtual host</h2></div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2681878"></a>J.6.1. Step 1; Adding an alias IP-address to Your server</h3></div></div></div><p>In this example we will assume that the server is called "gamma" and have the
primary address "192.168.0.50". The virtual host will be called "gamma2" and will be
located at address "192.168.0.51". The easiest way to add another address alias is
to use yast2 and the network configuration module and simple add a new alias.
</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2681896"></a>J.6.2. Step 2; Creating different document and cgi roots</h3></div></div></div><p>In preparation of the new virtual host we want it to have a separate document and
cgi (where we will store the PHP5 binary) roots compared with the standard server.
For this purpose we add two new directories "/srv/www/gamm2-htdocs/" and
"/srv/www/gamma2-cgi-bin/" on the server. </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2681914"></a>J.6.3. Step 3; Configure Apache with a virtual host</h3></div></div></div><p>For his we add a new small config file named "gamma2_vhost.conf" (the exact name
is not important as long as it ends in *.conf) in the "/etc/apache2/vhosts.d/"
directory. The script we add is </p><p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code"># Setup gamma2 on secondary IP-address
&lt;VirtualHost 192.168.0.51&gt;
DocumentRoot /srv/www/gamma2-htdocs/
ServerName gamma2
ServerAdmin root@localhost
# We use a separate CGI directory
ScriptAlias /cgi-bin/ /srv/www/gamma2-cgi-bin/
# For good measure we also add recognition of PHP5 index
DirectoryIndex index.php5
# This is the two critical statement for this virtual
# host we activate PHP5 as a CGI module
Action php5-cgi /cgi-bin/php
AddHandler php5-cgi .php5 .php
&lt;Directory /srv/www/gamma2-cgi-bin/&gt;
AllowOverride None
Options +ExecCGI -Includes
Order allow,deny
Allow from all
&lt;/Directory&gt;
&lt;Directory &quot;/srv/www/gamma2-htdocs/&quot;&gt;
Options None
AllowOverride None
Order allow,deny
Allow from all
DirectoryIndex index.html index.php
&lt;/Directory&gt;
UserDir public_html
&lt;/VirtualHost&gt;</span></pre></td></tr></table></div><p>
</p><p>We do not go into any more detail of this configuration since it should be fairly
easy to understand. For details we refer to the Apache documentation. </p><p>What we have accomplished with this file is that when we call the server on the
second address any php file will be recognized by apache as a file to be handled by
the "php5-cgi" action. This in turn means that whenever Apache encounters a *.php5
(or *.php) file it will run the program "/cgi-bin/php". This path in turn will be
expanded to " /srv/www/gamma2-cgi-bin/php". </p><p>In the next section we will show how to compile PHP5 and put the executable CGI
version in this directory.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="apjs05.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="apj.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apjs07.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">J.5. Part I - Installing PHP4 </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> J.7. Part III - Installing PHP5</td></tr></table></div></body></html>

View File

@ -0,0 +1,59 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>J.7. Part III - Installing PHP5</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="apj.html" title="Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1"><link rel="prev" href="apjs06.html" title="J.6. Part II - Creating a virtual host"><link rel="next" href="apjs08.html" title="J.8. Part IV - Verifying the setup"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">J.7. Part III - Installing PHP5</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apjs06.html">Prev</a> </td><th width="60%" align="center">Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1</th><td width="20%" align="right"> <a accesskey="n" href="apjs08.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2681976"></a>J.7. Part III - Installing PHP5</h2></div></div></div><p>We are now ready for the last step which means compiling PHP5 as a CGI module for
Apache. This follows the same principle as the compilation for PHP4 as described above.
Again, we use a small configuration script "<code class="filename">mkphp5-cgi</code>" which is
shown below.</p><p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">#! /bin/sh
./configure --prefix=/usr/share \
--datadir=/usr/share/php \
--libdir=/usr/share --includedir=/usr/include \
--enable-force-cgi-redirect \
--bindir=/usr/bin \
--with-config-file-path=/etc/php5/apache2 \
--enable-mbstring --enable-mbregex \
--with-mysql \
--with-gd --enable-gd-imgstrttf --enable-gd-native-ttf \
--with-zlib-dir=/usr/lib \
--with-png-dir=/usr/lib --with-jpeg-dir=/usr/lib \
--with-xpm-dir=/usr/X11R6 \
--with-tiff-dir=/usr/lib --with-ttf-dir=/usr/lib \
--with-freetype-dir=/usr/lib \
--enable-ftp \
--enable-memory-limit --enable-safe-mode \
--bindir=/usr/bin \
--enable-bcmath -enable-calendar \
--enable-ctype --with-ftp \
--enable-magic-quotes \
--enable-inline-optimization \
--with-bz2 \
--with-iconv</span></pre></td></tr></table></div><p>
</p><p>Notice that as we said before we have a different configuration path for PHP5 compared
with PHP4 as shown above. Also note that in order to build the CGI module we do not
configure the "apxs2" option. After successful configuration type
"<span class="command"><strong>make</strong></span>" but do not type "<span class="command"><strong>make install</strong></span>" in order
to compile PHP5. </p><p>After the compilation have finished copy "<code class="filename">sapi/cgi/php</code>" to
"<code class="filename">/srv/www/gamma2-cgi-bin/php</code>" since this is the place where our
virtual host expects to find the PHP5 CGI module. </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="apjs06.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="apj.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apjs08.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">J.6. Part II - Creating a virtual host </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> J.8. Part IV - Verifying the setup</td></tr></table></div></body></html>

View File

@ -0,0 +1,36 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>J.8. Part IV - Verifying the setup</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="apj.html" title="Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1"><link rel="prev" href="apjs07.html" title="J.7. Part III - Installing PHP5"><link rel="next" href="apk.html" title="Appendix K. Why it is not possible to add a SVG backend to JpGraph"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">J.8. Part IV - Verifying the setup</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apjs07.html">Prev</a> </td><th width="60%" align="center">Appendix J. Setting up PHP5 in parallel with PHP4 in SuSE 10.1</th><td width="20%" align="right"> <a accesskey="n" href="apk.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2682045"></a>J.8. Part IV - Verifying the setup</h2></div></div></div><p>The only small thing remaining, in case You haven't done so already, is to create
suitable "<code class="filename">php.ini</code>" scripts that are copied to the previous
specified PHP4 and PHP5 config file directories,
"<code class="filename">/etc/php4/apache2/</code>" and
"<code class="filename">/etc/php5/apache2/</code>". </p><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>It is recommended to enable all warnings and errors in each php.ini file
unless You have very, very good reasons not to do this. Use the default php.ini
files in the PHP distribution as the initial template. For use with JpGraph it
is recommended to do the following modifications: </p><p>
</p><div class="orderedlist"><ol type="1"><li><p>Increase maximum allowed memory to 32MB </p></li><li><p>Increase maximum allowed script running time to 30s</p></li><li><p>Set full error reporting </p></li></ol></div><p>
</p></div><p>
</p><p>Assuming the IP-addresses shown in the configuration above we are now ready to test
out setup. In order to do this make sure that each document root have the "phpinfo.php"
test script (see above). </p><p>We can now test the different setups by using the URLs </p><p>
</p><div class="orderedlist"><ol type="1"><li><p><code class="filename">http://192.168.0.50/phpinfo.php</code>
</p><p>This URL would send back configuration showing that the server is running
PHP4. Verify that the config path used is set to
"<code class="filename">/etc/php4/apache2/</code>". </p></li><li><p><code class="filename">http://192.168.0.51/phpinfo.php</code>
</p><p>This URL would send back configuration showing that the server is running
PHP5 Verify that the config path used is set to
"<code class="filename">/etc/php5/apache2/</code>". </p></li></ol></div><p>
</p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2682186"></a>J.8.1. Troubleshooting</h3></div></div></div><p>
</p><div class="orderedlist"><ol type="1"><li><p>If your browser asks you to download content with mime-type
"<code class="code">mime/x-httpd-application</code>" when you try to visit the
PHP script it means that Apache does not yet run PHP as a module (now
module have accepted to handle the x-http-application mime type). Make
sure you have included the "php4" in the <code class="code">APACHE_MODULES</code>
string as described above and that you added the
"<code class="filename">php4.conf</code>" file in the
"<code class="filename">/etc/apache2/conf.d/</code>" directory. </p></li><li><p>We had some issues with FireFox insisting on downloading
"<code class="filename">phpinfo.php</code>" as a file even when other browser
showed the page properly, using "<span class="command"><strong>etherreal</strong></span>" we could
confirm that Firefox was using a previous cached version before we had
enabled PHP in the apache configuration. To solve this we had to clear
the Firefox cache. </p></li></ol></div><p>
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="apjs07.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="apj.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apk.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">J.7. Part III - Installing PHP5 </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Appendix K. Why it is not possible to add a SVG backend to JpGraph</td></tr></table></div></body></html>

View File

@ -0,0 +1,5 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Appendix K. Why it is not possible to add a SVG backend to JpGraph</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="pt08.html" title="Part VIII. Appendices"><link rel="prev" href="apjs08.html" title="J.8. Part IV - Verifying the setup"><link rel="next" href="apks02.html" title="K.2. Summary of findings"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Appendix K. Why it is not possible to add a SVG backend to JpGraph</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apjs08.html">Prev</a> </td><th width="60%" align="center">Part VIII. Appendices</th><td width="20%" align="right"> <a accesskey="n" href="apks02.html">Next</a></td></tr></table><hr></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="app.adding-svg"></a>Appendix K. Why it is not possible to add a SVG backend to JpGraph</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="apk.html#id2682272">K.1. Background</a></span></dt><dt><span class="sect1"><a href="apks02.html">K.2. Summary of findings</a></span></dt><dt><span class="sect1"><a href="apks03.html">K.3. Detailing the issue</a></span></dt><dd><dl><dt><span class="sect2"><a href="apks03.html#id2682329">K.3.1. The core problem</a></span></dt><dt><span class="sect2"><a href="apks03.html#id2682391">K.3.2. Why is this a problem ?</a></span></dt><dt><span class="sect2"><a href="apks03.html#id2682413">K.3.3. Possible workarounds</a></span></dt><dt><span class="sect2"><a href="apks03.html#id2682470">K.3.4. What would be required ?</a></span></dt><dt><span class="sect2"><a href="apks03.html#id2682512">K.3.5. DOM scripting and GetBBox()</a></span></dt><dt><span class="sect2"><a href="apks03.html#id2682556">K.3.6. A final comment</a></span></dt></dl></dd></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2682272"></a>K.1. Background</h2></div></div></div><p>We have received many suggestions to add SVG as output from the library to achieve
better quality in off-screen reproduction of graphs. Adding SVG output would
significantly enhance the print quality as well as adding the possibility of
seamless zooming in graphs. For this reason we have done a brief pre-study on the
feasibility of such a backend. This short note will describe our findings. </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="apjs08.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="pt08.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apks02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">J.8. Part IV - Verifying the setup </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> K.2. Summary of findings</td></tr></table></div></body></html>

View File

@ -0,0 +1,8 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>K.2. Summary of findings</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="apk.html" title="Appendix K. Why it is not possible to add a SVG backend to JpGraph"><link rel="prev" href="apk.html" title="Appendix K. Why it is not possible to add a SVG backend to JpGraph"><link rel="next" href="apks03.html" title="K.3. Detailing the issue"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">K.2. Summary of findings</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apk.html">Prev</a> </td><th width="60%" align="center">Appendix K. Why it is not possible to add a SVG backend to JpGraph</th><td width="20%" align="right"> <a accesskey="n" href="apks03.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2682291"></a>K.2. Summary of findings</h2></div></div></div><p>To our surprise we have to conclude that with the current SVG standard 1.1 as well
as with the upcoming 1.2 (based on SVG-T) it will not be possible to implement a
full backend in SVG. </p><p>The primary hinder is the lack of adequate text manipulation in the current SVG
standard. In addition the implementation of the text supporting feature in current
SVG viewers range from poor and erroneous to non-existing. </p><p>The only way to solve this would be to drastically reduce some functionality of
the library in regards to text handling and require the user of the library to
supply text sizes to be used in many places of the library where that is needed.
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="apk.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="apk.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apks03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appendix K. Why it is not possible to add a SVG backend to JpGraph </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> K.3. Detailing the issue</td></tr></table></div></body></html>

View File

@ -0,0 +1,80 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>K.3. Detailing the issue</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="apk.html" title="Appendix K. Why it is not possible to add a SVG backend to JpGraph"><link rel="prev" href="apks02.html" title="K.2. Summary of findings"><link rel="next" href="apl.html" title="Appendix L. The JpGraph configuration file"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">K.3. Detailing the issue</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apks02.html">Prev</a> </td><th width="60%" align="center">Appendix K. Why it is not possible to add a SVG backend to JpGraph</th><td width="20%" align="right"> <a accesskey="n" href="apl.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2682322"></a>K.3. Detailing the issue</h2></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2682329"></a>K.3.1. The core problem</h3></div></div></div><p>It all boils down to one critical issue: </p><p>With the current SVG 1.1 (and draft 1.2) standard there is no way to
statically find out the bounding box of an arbitrary text string for later usage
in the SVG script. </p><p>This very surprising omission in the SVG standard makes it in principal
impossible to even do such a simple thing as drawing a frame around a text
programatically since there is no easy way to find out the size, in the given
coordinate system, of the string. </p><p>Since the actual bounding box is dependent on both font, style, size, etc as
well as the actual SVG viewer text-layout engine implementation this calculation
cannot be done outside the viewer. It must be part of the SVG standard elements. </p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p> Now, anyone who are familiar with SVG would jump in here and point out
that this is not entirely correct. For the specific case of a frame around a
text it would be possible to use a filter function as specified by the
standard but that is a special case that just could be used to draw an
effect that looks like a frame around a text (using the objectBoundingBox
property). It is still not possible to find out the bounding box. </p><p>The second approach would be to to add some DOM Javascript code in the SVG
script which upon execution of the script could in theory find out the
bounding box and adjust suitable attributes in the script. </p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2682391"></a>K.3.2. Why is this a problem ?</h3></div></div></div><p>There are many places in the library where it is absolutely essential to find
out the bounding box of a text string to adjust the position of other object in
the graph. For example margins for titles, column width in gantt charts and
legends and so on. Without this functionality it will be impossible to add SVG
output without significantly reducing the functionality and in essence create a
new version of the library suitable for this reduced functionality that is
brought upon us by the use of SVG. </p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2682413"></a>K.3.3. Possible workarounds</h3></div></div></div><p>Looking at this from a more positive view instead of explaining why it cannot
be done there are in principal only two workarounds (neither which is a 100%
solution) </p><div class="orderedlist"><ol type="1"><li><p>Using a single fixed font. Restricting the library to one specific
fixed font would make it possible to calculate the bounding box for the
string. Due to differences in the existing viewers it would be necessary
to have some safety margins built in when doing this calculation.
However this would significantly impact the visual appearance of the
graphs. </p></li><li><p>Using heuristics By establishing some "good enough" heuristics for a
plain font we can try to find a guesstimate of the size of the string.
Unfortunately it is a big difference in length between "iiiii" and
"wwwww" even though they have the same number of characters. So without
fully implementing the same algorithm as some SVG viewer text-layout
engine uses this method cannot guarantee that the text will always fit
without making the box fit the worst case. In addition this method will
have some difficulty in handling rotated text strings. </p></li></ol></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2682470"></a>K.3.4. What would be required ?</h3></div></div></div><p>What would be required in the standard to solve this is a new basis element
which could be used to record the bounding box of a particular text string for
later reference. To just give some idea on what is needed some "pseudo-SVG" that
we would need is something along the lines of: </p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">&lt;def&gt;
&lt;boundingbox id=&quot;bb1&quot;
text=&quot;This is a text&quot; style=&quot; /&gt;
&lt;/def&gt;
&lt;rect x=&quot;50+#bb1.x1-10&quot; y=&quot;50+#bb1.y1-10&quot;
width=&quot;#bb1.width+20&quot;
height=&quot;#bb1.height+20&quot; /&gt;
&lt;text x=&quot;50&quot; y=&quot;50&quot; &gt;
&lt;tref xlink:href=&quot;#bb1&quot; /&gt;
&lt;/text&gt;</span></pre></td></tr></table></div><p>The basic idea is that in the def-section all text strings to later be used in
the script is defined together with the font (and any other formatting
applicable). These text strings are defined in the new SVG element "boundingbox"
which will calculate the bounding box of the given text. These text string is
later referenced in the actual text with a standard tref element. The bounding
box attributes can then be used in the positioning of the text with a "#"
reference based on the id of the new introduced element "boundingbox" The above
script would then draw a text string positioned at (50,50) with a frame around
it with a 10 units margin all around.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2682512"></a>K.3.5. DOM scripting and GetBBox()</h3></div></div></div><p>Since we make no claim to be experts in all aspects of the SVG standard (which
is fairly big) it might be possible that there is some way to still solve this
that has eluded us so we would be very interested in getting a second opinion of
these findings. We are aware of the SVG method GetBBox() but this would not work
in the library very well. The reason is that this is not a static function but
requires the context of a DOM script. This would require a substantially rewrite
of the library since there are graphs where every single coordinate would have
to be back-patched in the end (possible in multiple passes - since the
calculation of one bounding box would be needed to adjust another element). </p><p>This means that the script would no longer be static but would require the
library to generate "self-modifying" DOM script at the end. The logic of the
library assumes that the bounding box of text can be found out at the place of
creation and then this bounding box can be used to adjust subsequent
coordinates. </p><p>So to summarize this we do not feel that the potential back patching of every
single element in the SVG image at the end in a DOM script is a solution.
</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2682556"></a>K.3.6. A final comment</h3></div></div></div><p>Since we still find it very hard to believe this giant oversight in the
standard we would be happy to receive comments on these conclusions. </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="apks02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="apk.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apl.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">K.2. Summary of findings </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Appendix L. The JpGraph configuration file</td></tr></table></div></body></html>

View File

@ -0,0 +1,264 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Appendix L. The JpGraph configuration file</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="pt08.html" title="Part VIII. Appendices"><link rel="prev" href="apks03.html" title="K.3. Detailing the issue"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Appendix L. The JpGraph configuration file</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apks03.html">Prev</a> </td><th width="60%" align="center">Part VIII. Appendices</th><td width="20%" align="right"> </td></tr></table><hr></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="app.jpg-config"></a>Appendix L. The JpGraph configuration file</h2></div></div></div><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment">=======================================================================</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> File: JPG-CONFIG.INC</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Description: Configuration file for JpGraph library</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Created: 2004-03-27</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Ver: </span><span class="hl-inlinedoc">$Id: jpg-config.inc.php 1839 2009-09-25 12:36:15Z ljp $</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Copyright (c) Aditus Consulting. All rights reserved.</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment">========================================================================</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment">------------------------------------------------------------------------</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Directories for cache and font directory.</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> CACHE_DIR:</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> The full absolute name of the directory to be used to store the</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> cached image files. This directory will not be used if the USE_CACHE</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> define (further down) is false. If you enable the cache please note that</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> this directory MUST be readable and writable for the process running PHP.</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Must end with '/'</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> TTF_DIR:</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Directory where TTF fonts can be found. Must end with '/'</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> The default values used if these defines are left commented out are:</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> UNIX:</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> CACHE_DIR /tmp/jpgraph_cache/</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> TTF_DIR /usr/share/fonts/truetype/</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> MBTTF_DIR /usr/share/fonts/truetype/</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> WINDOWS:</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> CACHE_DIR $SERVER_TEMP/jpgraph_cache/</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> TTF_DIR $SERVER_SYSTEMROOT/fonts/</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> MBTTF_DIR $SERVER_SYSTEMROOT/fonts/</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment">------------------------------------------------------------------------</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> define('CACHE_DIR','/tmp/jpgraph_cache/');</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> define('TTF_DIR','/usr/share/fonts/truetype/');</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> define('MBTTF_DIR','/usr/share/fonts/truetype/');</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment">-------------------------------------------------------------------------</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Cache directory specification for use with CSIM graphs that are</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> using the cache.</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> The directory must be the filesysystem name as seen by PHP</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> and the 'http' version must be the same directory but as</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> seen by the HTTP server relative to the 'htdocs' ddirectory.</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> If a relative path is specified it is taken to be relative from where</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> the image script is executed.</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> </span><span class="hl-inlinedoc">Note:</span><span class="hl-comment"> The default setting is to create a subdirectory in the</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> directory from where the image script is executed and store all files</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> there. As ususal this directory must be writeable by the PHP process.</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">define</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">CSIMCACHE_DIR</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">csimcache/</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-reserved">define</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">CSIMCACHE_HTTP_DIR</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">csimcache/</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment">------------------------------------------------------------------------</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Various JpGraph Settings. Adjust accordingly to your</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> preferences. Note that cache functionality is turned off by</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> default (Enable by setting USE_CACHE to true)</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment">------------------------------------------------------------------------</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Deafult locale for error messages.</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> This defaults to English = 'en'</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">define</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">DEFAULT_ERR_LOCALE</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">en</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Deafult graphic format set to 'auto' which will automatically</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> choose the best available format in the order png,gif,jpeg</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> (The supported format depends on what your PHP installation supports)</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">define</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">DEFAULT_GFORMAT</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">auto</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Should the cache be used at all? By setting this to false no</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> files will be generated in the cache directory.</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> The difference from READ_CACHE being that setting READ_CACHE to</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> false will still create the image in the cache directory</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> just not use it. By setting USE_CACHE=false no files will even</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> be generated in the cache directory.</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">define</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">USE_CACHE</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-reserved">true</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Should we try to find an image in the cache before generating it?</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Set this define to false to bypass the reading of the cache and always</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> regenerate the image. Note that even if reading the cache is</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> disabled the cached will still be updated with the newly generated</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> image. Set also 'USE_CACHE' below.</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">define</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">READ_CACHE</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-reserved">true</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Determine if the error handler should be image based or purely</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> text based. Image based makes it easier since the script will</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> always return an image even in case of errors.</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">define</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">USE_IMAGE_ERROR_HANDLER</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-reserved">true</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Should the library examine the global php_errmsg string and convert</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> any error in it to a graphical representation. This is handy for the</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> occasions when, for example, header files cannot be found and this results</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> in the graph not being created and just a 'red-cross' image would be seen.</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> This should be turned off for a production site.</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">define</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">CATCH_PHPERRMSG</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-reserved">true</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Determine if the library should also setup the default PHP</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> error handler to generate a graphic error mesage. This is useful</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> during development to be able to see the error message as an image</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> instead as a 'red-cross' in a page where an image is expected.</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">define</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">INSTALL_PHP_ERR_HANDLER</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-reserved">false</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Should usage of deprecated functions and parameters give a fatal error?</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> (Useful to check if code is future proof.)</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">define</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">ERR_DEPRECATED</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-reserved">true</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> The builtin GD function imagettfbbox() fuction which calculates the bounding box for</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> text using TTF fonts is buggy. By setting this define to true the library</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> uses its own compensation for this bug. However this will give a</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> slightly different visual apparance than not using this compensation.</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Enabling this compensation will in general give text a bit more space to more</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> truly reflect the actual bounding box which is a bit larger than what the</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> GD function thinks.</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">define</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">USE_LIBRARY_IMAGETTFBBOX</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-reserved">true</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment">------------------------------------------------------------------------</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> The following constants should rarely have to be changed !</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment">------------------------------------------------------------------------</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> What group should the cached file belong to</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> (Set to '' will give the default group for the 'PHP-user')</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Please note that the Apache user must be a member of the</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> specified group since otherwise it is impossible for Apache</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> to set the specified group.</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">define</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">CACHE_FILE_GROUP</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">www</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> What permissions should the cached file have</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> (Set to '' will give the default persmissions for the 'PHP-user')</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">define</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">CACHE_FILE_MOD</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-number">0664</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="apks03.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="pt08.html">Up</a></td><td width="40%" align="right"> </td></tr><tr><td width="40%" align="left" valign="top">K.3. Detailing the issue </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html>

View File

@ -0,0 +1,10 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Chapter 1. About the library</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="pt01.html" title="Part I. Installing and verifying the configuring"><link rel="prev" href="pt01.html" title="Part I. Installing and verifying the configuring"><link rel="next" href="ch01s02.html" title="1.2. Software license"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 1. About the library</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="pt01.html">Prev</a> </td><th width="60%" align="center">Part I. Installing and verifying the configuring</th><td width="20%" align="right"> <a accesskey="n" href="ch01s02.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="chap_about"></a>Chapter 1. About the library</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ch01.html#id2495205">1.1. What is JpGraph?</a></span></dt><dt><span class="sect1"><a href="ch01s02.html">1.2. Software license</a></span></dt><dt><span class="sect1"><a href="ch01s03.html">1.3. Versions of the library covered</a></span></dt><dt><span class="sect1"><a href="ch01s04.html">1.4. Purpose and usage</a></span></dt><dt><span class="sect1"><a href="ch01s05.html">1.5. Prerequisites for running the library</a></span></dt><dt><span class="sect1"><a href="ch01s06.html">1.6. Who can use the library</a></span></dt><dt><span class="sect1"><a href="ch01s07.html">1.7. What you can do with the library</a></span></dt><dt><span class="sect1"><a href="ch01s08.html">1.8. What you shouldn't or cannot do with this library</a></span></dt><dt><span class="sect1"><a href="ch01s09.html">1.9. Feature-matrix for the library</a></span></dt><dt><span class="sect1"><a href="ch01s10.html">1.10. Where to find additional information</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch01s10.html#id2506358">1.10.1. Manuals and distributed documentation</a></span></dt><dt><span class="sect2"><a href="ch01s10.html#id2506446">1.10.2. On-line documentation and resources</a></span></dt><dt><span class="sect2"><a href="ch01s10.html#id2507130">1.10.3. Defect database</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch01s11.html">1.11. Known bugs and omissions</a></span></dt></dl></div><p><b>What you will learn in this chapter. </b>This chapter will go through what the library is, the licensing model, how it is
typically used and the detailed steps of installing it. This chapter will not
explain how to use the API in the library. It will help answering typical questions
such as "<span class="emphasis"><em>Should I use this library?</em></span>", <span class="emphasis"><em>"Is the library
suitable for use in my particular environment?</em></span>, <span class="emphasis"><em>"Do I have
enough knowledge to use this library?"</em></span></p><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2495205"></a>1.1. What is JpGraph?</h2></div></div></div><p>The JpGraph library is a 2D graph plotting library for PHP4 and PHP5. It is meant
to significantly simplify the creation of dynamic graphs using PHP scripting. The
libray can be used on its own or as an embedded part of a large WEB development
undertaking. In addition the library allows images to be created using the command
line version of PHP (the cli version).</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="pt01.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="pt01.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch01s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part I. Installing and verifying the configuring </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 1.2. Software license</td></tr></table></div></body></html>

View File

@ -0,0 +1,12 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>1.2. Software license</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch01.html" title="Chapter 1. About the library"><link rel="prev" href="ch01.html" title="Chapter 1. About the library"><link rel="next" href="ch01s03.html" title="1.3. Versions of the library covered"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">1.2. Software license</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch01.html">Prev</a> </td><th width="60%" align="center">Chapter 1. About the library</th><td width="20%" align="right"> <a accesskey="n" href="ch01s03.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2495223"></a>1.2. Software license</h2></div></div></div><p>JpGraph is released under a dual license. For non-commercial usage the library is
released under QPL 1.0 (Qt-License) and for professional use it is released under
the JpGraph Professional License. See <a class="xref" href="apb.html" title="Appendix B. JpGraph Professional License">Appendix B</a> for more details regarding the exact wording of
the license. The goal the license have is to be simple, fair and help recover some
of the development cost and hosting services that the library development brings
with it.</p><p>Broadly speaking commercial use is defined as</p><p>a) The library is included as an integral part of a product that is sold with a
cost that exceeds the cost of the distribution medium. </p><p>b) The library is offered as a WEB service for a fee </p><p>c) The library is used in an intranet in a company with more than 2
employees</p><p>One license entitles the user to install the library on one single physical
machine which may run one or several logical servers. In addition it also entitles
the license holder to install one version of the library on a separate development
server. The professional license is perpetual and is valid for one major
version.</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch01.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch01.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch01s03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 1. About the library </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 1.3. Versions of the library covered</td></tr></table></div></body></html>

View File

@ -0,0 +1,24 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>1.3. Versions of the library covered</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch01.html" title="Chapter 1. About the library"><link rel="prev" href="ch01s02.html" title="1.2. Software license"><link rel="next" href="ch01s04.html" title="1.4. Purpose and usage"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">1.3. Versions of the library covered</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch01s02.html">Prev</a> </td><th width="60%" align="center">Chapter 1. About the library</th><td width="20%" align="right"> <a accesskey="n" href="ch01s04.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2502156"></a>1.3. Versions of the library covered</h2></div></div></div><p>This manual covers versions up to v3.1 of JpGraph. There are three main branches
of the library: </p><div class="variablelist"><dl><dt><span class="term">The "1.x.y" branch</span></dt><dd><p>The 1.x.y series is only intended for PHP4 and is not compatible
with PHP5 running in strict mode. If you are running an older
installation with only PHP4 you must use this branch of the library.
In addition you must use this branch if for some obscure reason only
the very old GD 1.x library is available in the installation (teh GD
library is the low level graphic primitives library used by JpGraph
and available in PHP).</p><div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3><p>The 1.x.y series is since 31 Dec 2008 no longer maintained and
should be considered deprecated. There will be no more
maintenance releases made on this branch.</p></div></dd><dt><span class="term">The "3.x.y" branch</span></dt><dd><p>The "3.x.y" series is the current one and is only intended to run
on PHP5. This code is optimized for use both with PHP5 as well as
the new (and bundled version) of the GD 2.x library. Hence this will
not work if you only have the older GD 1.x graphic primitive library
installed. However, all modern PHP installations since 2006 have
shipped with GD 2.x so this should not in reality be any
problem.</p><div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3><p>Please note that it is not possible to run the "3.x.y" series
on PHP4. If you need to run on PHP4 then you <span class="bold"><strong>must</strong></span> use the 1.x version of the
library.</p></div></dd><dt><span class="term">The "3.x.y-p" branch (The pro-version)</span></dt><dd><p>This is in principle the same as the "3.x.y" branch with the
difference that the pro-version includes a number of additional
modules (see <a class="xref" href="pt05.html" title="Part V. Additional graph types available in the professional version">Part V</a>) not available in the free
version. This includes both some additional graph types as well as
1D and 2D barcodes. In addition the professional license gives three
months of email support for installing and configuring the
library.</p></dd></dl></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch01s02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch01.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch01s04.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">1.2. Software license </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 1.4. Purpose and usage</td></tr></table></div></body></html>

View File

@ -0,0 +1,73 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>1.4. Purpose and usage</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch01.html" title="Chapter 1. About the library"><link rel="prev" href="ch01s03.html" title="1.3. Versions of the library covered"><link rel="next" href="ch01s05.html" title="1.5. Prerequisites for running the library"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">1.4. Purpose and usage</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch01s03.html">Prev</a> </td><th width="60%" align="center">Chapter 1. About the library</th><td width="20%" align="right"> <a accesskey="n" href="ch01s05.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2502277"></a>1.4. Purpose and usage</h2></div></div></div><p>The purpose of the library is to make it possible to (very) easily create dynamic
images (a.k.a. graphs) using PHP scripting. The library hides as much as possible
all the details necessary to create dynamic images. Strictly speaking all the basic
low level functionality to draw images are already available in PHP since PHP comes
with the core GD library which is the very lowest layer to create images. The GD
library has graphic primitives to create lines, circles, points etc. but it has no
built-in intelligence to handle scales, labelling , colors etc. This logically makes
JpGraph library a higher type library more easily accessible than the raw GD
library. </p><div class="figure"><a name="id2502300"></a><p class="title"><b>Figure 1.1. JpGraph and PHP</b></p><div class="figure-contents"><div class="mediaobject"><img src="images/jpgraph-and-php.png" alt="JpGraph and PHP"></div></div></div><br class="figure-break"><p>There are several possible usage scenario for the library and it's different
parts. </p><p>The most common usage is most likely to visualize numeric data by creating basic
charts (for example line, bar or pie charts) that is included dynamically in a
WEB-page via a straight forward <code class="code">&lt;img&gt;</code> tag. The details on how to
create dynamic graphs will be fully covered in later sections of this manual The
library itself is agnostic to where the data comes from so it could for example be
retrieved from a database, from a plain text file or perhaps from some WEB-service.
In addition to this scenario the library could be used as a tool to create dynamic
charts that are stored as image files in a directory. This makes it possible to use
the library in an off-line batch mode from the command line (most likely using the
cli =command line version of PHP). For an example of using JpGraph in batch mode see <a class="xref" href="ch30.html" title="Chapter 30. Showing SPAM statistics">Chapter 30</a>.</p><p>In addition to these basic usage scenarios both the free and the slightly more
advanced pro-version of the library includes a multitude of additional functionality
which includes for example more advanced graph types (like spider graphs, polar
plots, contour plots etc.) and some non graph capabilities like the possibility to
create barcodes (only available in the pro-version) or to create Gantt-charts. The
usage of all of these types of graphs are explained in this manual.</p><p>
</p><div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3><p>In order to use JpGraph the PHP installation must have support for the GD
libraries enabled. See Chapter 2 and 3 for details on checking the
installation.</p></div><p>
</p><p>In order to get a quick feel for how the library can be used we have included in <a class="xref" href="ch01s04.html#example.example0" title="Example 1.1. This is the very first example (example0.php)">Example 1.1</a> a very basic type of line graph. Don't worry
right now about the details, the message here is that it only takes six lines of
real script code to create a basic graph. Have a look at the example and see just
how much of the script makes sense without us even having discussed any API
yet.</p><div class="example"><a name="example.example0"></a><p class="title"><b>Example 1.1. This is the very first example (<code class="filename">example0.php</code>) </b></p><div class="example-contents"><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code"> </span><span class="hl-comment">//</span><span class="hl-comment"> content=&quot;text/plain; charset=utf-8&quot;</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">require_once</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">jpgraph/jpgraph.php</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-reserved">require_once</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">jpgraph/jpgraph_line.php</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Some data</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$ydata</span><span class="hl-code"> = </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-number">11</span><span class="hl-code">,</span><span class="hl-number">3</span><span class="hl-code">,</span><span class="hl-number">8</span><span class="hl-code">,</span><span class="hl-number">12</span><span class="hl-code">,</span><span class="hl-number">5</span><span class="hl-code">,</span><span class="hl-number">1</span><span class="hl-code">,</span><span class="hl-number">9</span><span class="hl-code">,</span><span class="hl-number">13</span><span class="hl-code">,</span><span class="hl-number">5</span><span class="hl-code">,</span><span class="hl-number">7</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Create the graph. These two calls are always required</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">Graph</span><span class="hl-brackets">(</span><span class="hl-number">350</span><span class="hl-code">,</span><span class="hl-number">250</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetScale</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">textlin</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Create the linear plot</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$lineplot</span><span class="hl-code">=</span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">LinePlot</span><span class="hl-brackets">(</span><span class="hl-var">$ydata</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$lineplot</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetColor</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">blue</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Add the plot to the graph</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Add</span><span class="hl-brackets">(</span><span class="hl-var">$lineplot</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Display the graph</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div></div></div><br class="example-break"><div class="figure"><a name="fig.example0"></a><p class="title"><b>Figure 1.2. This is the very first example <code class="uri"><a class="uri" href="example_src/example0.html" target="_top">(<code class="filename">example0.php</code>)</a></code> </b></p><div class="figure-contents"><span class="inlinemediaobject"><img src="images/example0.png" alt="This is the very first example (example0.php)"></span></div></div><br class="figure-break"></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch01s03.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch01.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch01s05.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">1.3. Versions of the library covered </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 1.5. Prerequisites for running the library</td></tr></table></div></body></html>

View File

@ -0,0 +1,8 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>1.5. Prerequisites for running the library</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch01.html" title="Chapter 1. About the library"><link rel="prev" href="ch01s04.html" title="1.4. Purpose and usage"><link rel="next" href="ch01s06.html" title="1.6. Who can use the library"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">1.5. Prerequisites for running the library</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch01s04.html">Prev</a> </td><th width="60%" align="center">Chapter 1. About the library</th><td width="20%" align="right"> <a accesskey="n" href="ch01s06.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2502443"></a>1.5. Prerequisites for running the library</h2></div></div></div><p>
</p><div class="itemizedlist"><ul type="disc"><li><p>Any 32bit operating system capable of running PHP5</p></li><li><p>PHP5, requires version &gt;= 5.1.0 (it might work with earlier versions
but this is not officially supported)</p></li><li><p>Enabled GD 2.x library in PHP installation. This is normally bundled
with the PHP5 distribution. It is strongly recommended that you use the
included version of GD with PHP5 and not try to install it
separately.</p></li></ul></div><p>
</p><div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3><p>There are known issues so running the library under a 64 bit OS so the library
does not officially support any 64 bit OS:es</p></div><p>For more detailed information on PHP settings in <code class="filename">php.ini</code> see <a class="xref" href="ch03s02.html#sec.verifying-phpgd-inst" title="3.2.1. Verifying the PHP/GD installation">Section 3.2.1</a></p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch01s04.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch01.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch01s06.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">1.4. Purpose and usage </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 1.6. Who can use the library</td></tr></table></div></body></html>

View File

@ -0,0 +1,7 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>1.6. Who can use the library</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch01.html" title="Chapter 1. About the library"><link rel="prev" href="ch01s05.html" title="1.5. Prerequisites for running the library"><link rel="next" href="ch01s07.html" title="1.7. What you can do with the library"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">1.6. Who can use the library</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch01s05.html">Prev</a> </td><th width="60%" align="center">Chapter 1. About the library</th><td width="20%" align="right"> <a accesskey="n" href="ch01s07.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2502518"></a>1.6. Who can use the library</h2></div></div></div><p>Even though the library hides a lot of details it needs to be pointed out that
this is still a programmers library. It is assumed that the user of the library has
basic skills in programming PHP and is familiar, at least to a basic extent, with
the concept of objects and object oriented programming since the entire library is
built around this paradigm. Fully understanding basic concepts such as classes,
methods, class instances and class inheritage will substantially help in trying to
understand how to use the library.</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch01s05.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch01.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch01s07.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">1.5. Prerequisites for running the library </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 1.7. What you can do with the library</td></tr></table></div></body></html>

View File

@ -0,0 +1,22 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>1.7. What you can do with the library</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch01.html" title="Chapter 1. About the library"><link rel="prev" href="ch01s06.html" title="1.6. Who can use the library"><link rel="next" href="ch01s08.html" title="1.8. What you shouldn't or cannot do with this library"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">1.7. What you can do with the library</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch01s06.html">Prev</a> </td><th width="60%" align="center">Chapter 1. About the library</th><td width="20%" align="right"> <a accesskey="n" href="ch01s08.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2502539"></a>1.7. What you can do with the library</h2></div></div></div><p>One should probably differentiate between the two basic usage scenarios</p><p>
</p><div class="orderedlist"><ol type="1"><li><p><span class="bold"><strong>Online.</strong></span> That is, the image is dynamically
generated when a user is viewing a particular WEB-page. This means that
the time it takes to generate the image will add to the delay the user
is experiencing when trying to view the page. (The library supports a
caching mechanism to reduce the number of times an image has to
generated, see <a class="xref" href="ch05s06.html" title="5.6. Efficient graph generation using the built-in cache subsystem">Section 5.6</a> for a thorough
discussion). For this scenario one should probably keep the images as
basic as possible in order to have as small latency as possible. </p><p>In practice this means that the number of data points to visualize
should be kept in the order of hundreds and not thousands. In later
sections we will discuss in details what can be done to improve the
performance of the library.</p><p> </p></li><li><p><span class="bold"><strong>Offline</strong></span>. That is, the images are generated by
some "batch" processing (possible command line based). In this scenario
the delay is not an issue and one could create much more complicated
images and process many more data points. Even though the library in
itself does not impose any restriction of the number of data points to
process the memory and time limits set for PHP will. </p><p>In practice if you need to process images with sizes above 2000x2000
pixels resulting from processing 500,000 data points then it is probably
better to find a more suitable way to produce these graphs rather than a
PHP script (unless you are prepared to give PHP a couple of 100 MB of
allowed memory)</p></li></ol></div><p>
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch01s06.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch01.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch01s08.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">1.6. Who can use the library </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 1.8. What you shouldn't or cannot do with this library</td></tr></table></div></body></html>

View File

@ -0,0 +1,22 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>1.8. What you shouldn't or cannot do with this library</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch01.html" title="Chapter 1. About the library"><link rel="prev" href="ch01s07.html" title="1.7. What you can do with the library"><link rel="next" href="ch01s09.html" title="1.9. Feature-matrix for the library"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">1.8. What you shouldn't or cannot do with this library</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch01s07.html">Prev</a> </td><th width="60%" align="center">Chapter 1. About the library</th><td width="20%" align="right"> <a accesskey="n" href="ch01s09.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2502632"></a>1.8. What you shouldn't or cannot do with this library</h2></div></div></div><p>If the primary usage is heavy scientific processing where you need to visualize
complex 2D/3D scenarios then this library is not for you. In this case it is
probably better to use one of the scientific tools like Matlab or Maple.</p><p>In addition, if you for example intend to implement a large scale project planning
tool with several thousand activities that you want to manipulate and display using
the support Gantt charts in this library this is probably stretching it a bit too
far. Again, this is probably better done with more dedicated tools like MS Project. </p><p>In addition may we again point out that the library does not officially support
any 64bit OS due to issues with PHP/GD.</p><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>Some of the 2D barcodes will simply not work in a 64bit OS. This is
consequence of the computation of the error correcting codes which in some
instances assumes 32bit integers. For the basic graphs there is no known
issues but since the library is not verified on a 64bit OS we do not
officially support this.</p></div><p>
</p><p>There is also a question on sever load that should be taken into account. Due to
the CPU intensive nature of image processing the complexity of the generated images
needs to be kept as low as possible for any sites that would expect heavy load.
Since it is normally necessary to increase the allowed memory for PHP (see <a class="xref" href="ch03s03.html#sec3.setting-up-php-ini" title="Setting up your php.ini file">the section called “Setting up your php.ini file”</a>) when working with images this could
easily make the server hit it's physical memory limit if the load is very high. </p><p>For example, the practical lowest memory that should be set for PHP when working
with images is 32MB (recommended is at least 64MB), if your system must cope with 50
simultaneous users it means that the HTTP processes alone will need roughly 1.6GB
just to secure the basics. Handling 50 simultaneous executing image scripts will
also require some heavy processing and the server needs to have a CPU capacity to
handle this. Some discussions about dimensioning a server can be found in <a class="xref" href="ch05s06.html" title="5.6. Efficient graph generation using the built-in cache subsystem">Section 5.6</a>.</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch01s07.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch01.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch01s09.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">1.7. What you can do with the library </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 1.9. Feature-matrix for the library</td></tr></table></div></body></html>

View File

@ -0,0 +1,359 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>1.9. Feature-matrix for the library</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch01.html" title="Chapter 1. About the library"><link rel="prev" href="ch01s08.html" title="1.8. What you shouldn't or cannot do with this library"><link rel="next" href="ch01s10.html" title="1.10. Where to find additional information"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">1.9. Feature-matrix for the library</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch01s08.html">Prev</a> </td><th width="60%" align="center">Chapter 1. About the library</th><td width="20%" align="right"> <a accesskey="n" href="ch01s10.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2502724"></a>1.9. Feature-matrix for the library</h2></div></div></div><p>JpGraph library is an OO graph library which makes it easy to both draw a "quick and
dirty" graph with a minimum of code and quite complex graphs which requires a very fine
grain of control. The library tries to assign sensible default values for most parameters
hence making the learning curve quite flat since for most of the time very few commands are
required to draw graphs with a pleasing esthetic look.</p><p>The following list makes no claim to be complete but it will give a birds view of some of
the main (and in some cases unique) features of the library. The list will also illustrate
the difference between the free and the pro-version.</p><p>
</p><div class="table"><a name="id2502755"></a><p class="title"><b>Table 1.1. Feature matrix for JpGraph library</b></p><div class="table-contents"><table summary="Feature matrix for JpGraph library" border="0"><colgroup><col><col><col></colgroup><thead><tr><th>Feature</th><th>Free version</th><th>Pro-version</th></tr></thead><tbody><tr><td>Supports PNG, GIF, JPG image formats</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Flexible scales, supports text-lin, text-log, lin-lin, lin-log,
log-lin and log-log and integer scales </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Supports both PNG, GIF and JPG graphic formats. Note that the
available formats are dependent on the specific PHP installation where
the library is used.</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Supports caching of generated graphs to lessen burden of a HTTP
server. </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Supports batch mode to only generate images to a file</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Supports client side image maps which makes it easy to produce drill
down images. </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Intelligent auto-scaling which gravitates towards esthetic values,
i.e. multiples of 2:s and 5:s </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Fully supports manual scaling, with fine grain control of position of
ticks. </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Multiple Y-axes (and scales) and multiple data series in the same
graph</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Supports background images with different formatting options</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>User specified grace for auto-scaling</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Supports unlimited number of y-axes, </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Supports, line-plots, filled line-plots, accumulated line-plots, bar
plots, accumulated bar plots, grouped bar plots, error plots, line error
plots, scatter plots, gantt-charts, radar plots, 2D and 3D pie charts. </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Supports unlimited number of plots in each graph, makes it easy to
compose complex graph which consists of several plot types </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>User specified position of axis</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Designed as a flexible OO framework which makes it easy to add new
types of plots </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Supports automatic legend generation with custom formatting</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Supports both vertical and horizontal grids</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Supports anti-aliasing of lines</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Supports background images as well as unlimited number of icons in
the graph </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Supports rotation of linear graphs</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>More then 400 named colors</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Designed modularly - you don't have to include code which isn't used </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Supports user specified callback for fine tuning scale labels</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Support for text augmentation of graphs</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Support for PHP Accelerator</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Support for a large set of 1D barcodes (EAN-128, ...)</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Support for Windrose plots</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Support for discontinuities in graphs</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Enhanced anti-aliasing for PieCharts</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>More advanced formatting of graph titles including 3D Bevel effects. </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Additional 3D Bevel formatting feature for the entire Graph </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Footer text on all graph types </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Full support for color alpha blending </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Advanced interpolation with cubic splines to get smooth curves from
just a few data points. </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Several different fill styles for line plots</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Some image 3D effects built-in without external image manipulation
programs </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Additional built-in images for plot marks including 3D rendered
markers like diamonds, squares, bevels, balls, pins etc </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Support for calculation of linear regression</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Text strings can be added to the plot using scale coordinates </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Support for all primitive URL parameter types with CSIM graphs. </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Hare/Niemeyer Integer compensation for Pie Plots </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Possibility to use Vertical Gradient fill for line plots. </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Improved error handling. The visual appearance of the error handling
now tries to mimic any windows system window (in graphic) </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Builtin support to display over 200 country flag and the possibility
to use them as icons or markers in the graphs. All the flag images are
builtin with JpGraph in an efficient pre-compiled data format. </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Support for both Chinese and Japanese character sets </td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Support for custom TTF fonts</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Support for 2D contour plots of 3D functions</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Unlimited number of data points (up to memory and CPU limit of
server)</td><td align="center">
<p class="checkmark">
</p>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Windrose plots</td><td align="center">
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Odometer plots</td><td align="center">
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Graphic excel like tables</td><td align="center">
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>1D Linear barcodes (e.g. EAN8,13,128, Code39, 128, 2of5, Code-11,
Codabar etc)</td><td align="center">
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>2D-Barcode PDF417</td><td align="center">
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>2D-Barcode Datamatrix</td><td align="center">
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>2D-Barcode QR-code</td><td align="center">
</td><td align="center">
<p class="checkmark">
</p>
</td></tr><tr><td>Matrix visualization</td><td>
</td><td align="center">
<p class="checkmark">
</p>
</td></tr></tbody></table></div></div><p><br class="table-break">
</p><p>In addition to these high level features the library has been designed to be orthogonal
and consistent in its' naming convention. For example, to specify color each object (i.e.
axis, grids, texts, titles etc) within the graph implements the method
<code class="code">SetColor()</code> with the same signature. </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch01s08.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch01.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch01s10.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">1.8. What you shouldn't or cannot do with this library </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 1.10. Where to find additional information</td></tr></table></div></body></html>

View File

@ -0,0 +1,62 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>1.10. Where to find additional information</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch01.html" title="Chapter 1. About the library"><link rel="prev" href="ch01s09.html" title="1.9. Feature-matrix for the library"><link rel="next" href="ch01s11.html" title="1.11. Known bugs and omissions"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">1.10. Where to find additional information</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch01s09.html">Prev</a> </td><th width="60%" align="center">Chapter 1. About the library</th><td width="20%" align="right"> <a accesskey="n" href="ch01s11.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2506338"></a>1.10. Where to find additional information</h2></div></div></div><p>The primary source for information is this manual together with the<code class="uri"><a class="uri" href="http://www.aditus.nu/jpgraph/" target="_top">JpGraph web site</a></code> which also
contains further links to many external sources of information.</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2506358"></a>1.10.1. Manuals and distributed documentation</h3></div></div></div><p>
</p><div class="orderedlist"><ol type="1"><li><p>The JpGraph user manual (this document)</p></li><li><p>The JpGraph API reference manual. This reference contains details
about all public APIs available together with the classes.</p></li><li><p>JpGraph UML static class diagram. This is an experimental
documentation which shows the static class dependency between all
classes in the library.</p></li><li><p>The <code class="uri"><a class="uri" href="http://jpgraph.intellit.nl/index.php" target="_top">JpGraph
community forum</a></code>. This is a discussion board for users of
the JpGraph library where users both give examples on how they have
used the library as well as asking and answering generic and
specific questions.</p></li><li><p>The FAQ. This is available both <code class="uri"><a class="uri" href="http://www.aditus.nu/jpgraph/" target="_top">on-line</a></code> and in <a class="xref" href="apc.html" title="Appendix C. FAQ">Appendix C</a> to this manual. </p></li></ol></div><p>
</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2506446"></a>1.10.2. On-line documentation and resources</h3></div></div></div><p>The JpGraph document portal can be be found at <code class="uri"><a class="uri" href="http://www.aditus.nu/jpgraph/documentation.php" target="_top">http://www.aditus.nu/jpgraph/documentation.php</a></code>
in addition to the distributed documentation there are several "HowTo" sections
which explains with some larger examples how to accomplish some specific type of
graphs and solve common problems.</p><p>In addition to the <code class="uri"><a class="uri" href="http://www.aditus.nu/jpgraph/" target="_top">JpGraph Web site</a></code> there are
a number of external sites with tutorials and examples on how JpGraph has been
used. This is not a complete list (nor will it ever be) but it lists a few of
the tutorials/examples that we are aware of. The following is a partial list of
known external tutorial showing more or less advanced examples on how to use
specific features of the library. </p><p>
</p><div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3><p>Usual caveats apply in that we can take no responsibility for the
correctness of these tutorials since we have no influence over
them.</p></div><p>
</p><p>
</p><div class="table"><a name="id2506505"></a><p class="title"><b>Table 1.2. External JpGraph tutorial</b></p><div class="table-contents"><table summary="External JpGraph tutorial" border="0"><colgroup><col><col></colgroup><thead><tr><th>Name/Link</th><th>Description</th></tr></thead><tbody><tr><td><span class="bold"><strong>Chart Dog Application.</strong></span></td><td>Application example</td></tr><tr><td colspan="2">
<code class="uri"><a class="uri" href="http://www.jimwrightonline.com/php/chartdog_2_0/chartdog.php" target="_top">http://www.jimwrightonline.com/php/chartdog_2_0/chartdog.php</a></code></td></tr><tr><td><span class="bold"><strong>Découverte de la librairie Php
JpGraph</strong></span></td><td>French tutorial</td></tr><tr><td colspan="2">
<code class="uri"><a class="uri" href="http://eric-pommereau.developpez.com/tutoriels/decouverte-jpgraph/" target="_top">http://eric-pommereau.developpez.com/tutoriels/decouverte-jpgraph/</a></code></td></tr><tr><td><span class="bold"><strong>Einführung zu JPGraph</strong></span></td><td>German tutorial</td></tr><tr><td colspan="2">
<code class="uri"><a class="uri" href="http://www.binnendijk.net/jpgraph/index.php" target="_top">http://www.binnendijk.net/jpgraph/index.php</a></code></td></tr><tr><td><span class="bold"><strong>Des graphes en Php avec
JpGraph</strong></span></td><td>French tutorial</td></tr><tr><td colspan="2">
<code class="uri"><a class="uri" href="http://www.journaldunet.com/developpeur/tutoriel/php/011121php_jpgraph.shtml" target="_top">http://www.journaldunet.com/developpeur/tutoriel/php/011121php_jpgraph.shtml</a></code></td></tr><tr><td><span class="bold"><strong>Developing Professional Quality Graphs with
PHP</strong></span></td><td>English tutorial</td></tr><tr><td colspan="2">
<code class="uri"><a class="uri" href="http://devzone.zend.com/article/1260-Developing-Professional-Quality-Graphs-with-PHP" target="_top">http://devzone.zend.com/article/1260-Developing-Professional-Quality-Graphs-with-PHP</a></code></td></tr><tr><td><span class="bold"><strong>PHPHacks.com Posts Creating charts with
JPGraph</strong></span></td><td>English tutorial</td></tr><tr><td colspan="2">
<code class="uri"><a class="uri" href="http://devzone.zend.com/article/994-PHPHacks.com-Posts-Creating-charts-with-JPGraph" target="_top">http://devzone.zend.com/article/994-PHPHacks.com-Posts-Creating-charts-with-JPGraph</a></code></td></tr><tr><td><span class="bold"><strong>Simple linear regression with
PHP</strong></span></td><td>IBM developer works article</td></tr><tr><td colspan="2">
<code class="uri"><a class="uri" href="http://www.ibm.com/developerworks/web/library/wa-linphp2/" target="_top">http://www.ibm.com/developerworks/web/library/wa-linphp2/</a></code></td></tr><tr><td><span class="bold"><strong>Dreamweaver Article</strong></span></td><td>How to integrate with Dreamweaver</td></tr><tr><td colspan="2">
<code class="uri"><a class="uri" href="http://www.adobe.com/devnet/dreamweaver/articles/php_graphics_11.html" target="_top">http://www.adobe.com/devnet/dreamweaver/articles/php_graphics_11.html</a></code></td></tr><tr><td><span class="bold"><strong>JPGraph Library V2.2
Tutorial</strong></span></td><td>Typo3 integration</td></tr><tr><td colspan="2">
<code class="uri"><a class="uri" href="http://typo3.org/documentation/document-library/extension-manuals/rt_jpgraphtutor/current/" target="_top">http://typo3.org/documentation/document-library/extension-manuals/rt_jpgraphtutor/current/</a></code></td></tr><tr><td><span class="bold"><strong>Introduction to JPGraph (Part
I)</strong></span></td><td>Basic introduction</td></tr><tr><td colspan="2">
<code class="uri"><a class="uri" href="http://www.devtutorials.info/articles/1334_Introduction_to_JPGraph__Part_I_.asp" target="_top">http://www.devtutorials.info/articles/1334_Introduction_to_JPGraph__Part_I_.asp</a></code></td></tr><tr><td><span class="bold"><strong> PHP Graphics With JpGraph
</strong></span></td><td>Downloadable tutorials</td></tr><tr><td colspan="2">
<code class="uri"><a class="uri" href="http://rosihanari.net/web-tutorial/php-graphics/" target="_top">http://rosihanari.net/web-tutorial/php-graphics/</a></code></td></tr><tr><td><span class="bold"><strong>JpGraph: PHP Graphs &amp; Charts
On-The-Fly</strong></span></td><td>Basic introduction</td></tr><tr><td colspan="2">
<code class="uri"><a class="uri" href="http://www.communitymx.com/abstract.cfm?cid=2AB8E" target="_top">http://www.communitymx.com/abstract.cfm?cid=2AB8E</a></code></td></tr><tr><td><span class="bold"><strong>Using JpGraph</strong></span></td><td>JpGraph and Cake</td></tr><tr><td colspan="2">
<code class="uri"><a class="uri" href="http://bakery.cakephp.org/articles/view/using-jpgraph" target="_top">http://bakery.cakephp.org/articles/view/using-jpgraph</a></code></td></tr><tr><td><span class="bold"><strong>Create High Quality Graphs with
Jpgraph</strong></span></td><td>Basic introduction</td></tr><tr><td colspan="2">
<code class="uri"><a class="uri" href="http://phpkitchen.com/2002/05/create-high-quality-graphs-with-jpgraph/" target="_top">http://phpkitchen.com/2002/05/create-high-quality-graphs-with-jpgraph/</a></code></td></tr><tr><td><span class="bold"><strong>JpGraph tutorial </strong></span></td><td>Integration with Prado</td></tr><tr><td colspan="2">
<code class="uri"><a class="uri" href="http://www.pradosoft.com/wiki/index.php/JpGraph_tutorial" target="_top">http://www.pradosoft.com/wiki/index.php/JpGraph_tutorial</a></code></td></tr></tbody></table></div></div><p><br class="table-break">
</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2507130"></a>1.10.3. Defect database</h3></div></div></div><p>Unfortunately there will be defects (bugs) even in this library. If you
suspect that you have found a bug may we ask you to first check the existing bug
database if this problem has already been reported. If the problem you have
found has not been reported then we would appreciate hearing about your
issue.</p><p>You can find our defect database at <code class="uri"><a class="uri" href="http://www.aditus.nu/bugtraq/" target="_top">http://www.aditus.nu/bugtraq/</a></code></p><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>We have been forced to add some simple spam protection on the defect
reporting system to prevent a lot of phony robot signups </p><p>In order to sign-up for a new user account do the following </p><p>1. Goto the issue tracker at <code class="uri"><a class="uri" href="http://www.aditus.nu/bugtraq/?do=register" target="_top">http://www.aditus.nu/bugtraq/?do=register</a></code>
in order to signup for a new account </p><p>2. Select an arbitrary user name and prefix it with an "XY_", for
example, if your chosen user id would be "adam12" then signup as
"XY_adam12". </p><p>3. Fill in the rest of the values, your name, e-mail etc. </p><p>4, You will receive a confirmation mail in order to activate your
account. </p><p>5. In order to login you just need to use your chosen user name <span class="bold"><strong>BUT WITHOUT</strong></span> the "XY_" prefix. This is only
used when signing up for an account. </p></div><p>
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch01s09.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch01.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch01s11.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">1.9. Feature-matrix for the library </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 1.11. Known bugs and omissions</td></tr></table></div></body></html>

View File

@ -0,0 +1,17 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>1.11. Known bugs and omissions</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch01.html" title="Chapter 1. About the library"><link rel="prev" href="ch01s10.html" title="1.10. Where to find additional information"><link rel="next" href="ch02.html" title="Chapter 2. The Short Version: Installing the library (for PHP/Apache experts)"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">1.11. Known bugs and omissions</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch01s10.html">Prev</a> </td><th width="60%" align="center">Chapter 1. About the library</th><td width="20%" align="right"> <a accesskey="n" href="ch02.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2507221"></a>1.11. Known bugs and omissions</h2></div></div></div><p>In general a new version of the library is released twice a year. If you are in a
hurry to get a fix that may already be available in the development branch you can
always try the latest nightly build available from the JpGraph home page. However be
aware that a nightly build could be broken on rare occasions. However, our
development philosophy is to always have a releasable repository so for the most of
the time the snapshot will work fine. The snapshot is available from:</p><p><code class="uri"><a class="uri" href="http://www.aditus.nu/jpgraph/jpsnapshot.php" target="_top">http://www.aditus.nu/jpgraph/jpsnapshot.php</a></code></p><p>The following is a partial list of what we believe to be the most irritating known
bugs (and omissions). See the <code class="uri"><a class="uri" href="http://www.aditus.nu/bugtraq/index.php" target="_top">Bugtracker</a></code> for a more
current view on additional known minor issues with the library.</p><div class="orderedlist"><ol type="1"><li><p>For performance reasons background images are not rotated along with
graphs in rotated graphs. Images rotation must be made outside the
library with some image manipulation program. This will never be
included as a feature of the library since PHP is simply to slow for
this kind of pixel-by-pixel image manipulation.</p></li><li><p>The library does not work with a 64bit OS (This is partly due to PHP
and partly due to some calculation of Error codes that assumes 32 bit
integers)</p></li><li><p>Truetype fonts are aligned according to there bounding box. This means
that text line that contain characters below the baseline (e.g. "j")
will be aligned slightly different from texts that only contain
characters that are above the baseline (e.g. "a").</p></li></ol></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch01s10.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch01.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">1.10. Where to find additional information </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 2. The Short Version: Installing the library (for PHP/Apache experts)</td></tr></table></div></body></html>

View File

@ -0,0 +1,37 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Chapter 2. The Short Version: Installing the library (for PHP/Apache experts)</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="pt01.html" title="Part I. Installing and verifying the configuring"><link rel="prev" href="ch01s11.html" title="1.11. Known bugs and omissions"><link rel="next" href="ch02s02.html" title="2.2. Running the examples"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 2. The Short Version: Installing the library (for PHP/Apache experts)</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch01s11.html">Prev</a> </td><th width="60%" align="center">Part I. Installing and verifying the configuring</th><td width="20%" align="right"> <a accesskey="n" href="ch02s02.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2507309"></a>Chapter 2. The Short Version: Installing the library (for PHP/Apache experts)</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ch02.html#id2507336">2.1. Installing</a></span></dt><dt><span class="sect1"><a href="ch02s02.html">2.2. Running the examples</a></span></dt><dt><span class="sect1"><a href="ch02s03.html">2.3. Basic trouble shooting</a></span></dt></dl></div><p><b>What you will learn in this chapter. </b>This chapter will show you how to unpack the library and lists the minimum
prerequisites that is needed to get the library running. It is assumed that your are
familiar with adjusting the PHP configuration file <code class="filename">php.ini</code> and
that you already have a working PHP installation.</p><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2507336"></a>2.1. Installing</h2></div></div></div><p>Please follow the steps below:</p><p>
</p><div class="orderedlist"><ol type="1"><li><p>Either download the free library from <code class="uri"><a class="uri" href="http://www.aditus.nu/jpgraph/jpdownload.php" target="_top">http://www.aditus.nu/jpgraph/jpdownload.php</a></code>
or use your license information and download the pro-version from
<code class="uri">http://www.aditus.nu/jpgraph/pro_login.php</code>. The download
is just a packed zip (or tar.gz) of php files. There are no automatic
installation scripts.</p></li><li><p>Unpack the library where you normally store PHP libraries. This should
be in your PHP include path. When you unpack the library it will be
named "jpgraph-3.x" (where x corresponds to the version you have
downloaded).</p></li><li><p>Now either rename the unpacked the directory to just jpgraph or if the
system us Unix based create a soft symbolic link, for example</p><p><code class="prompt">ln -s jpgraph-2.x jpgraph</code></p><p>This will allow you to access the library files in your own program
for with a <code class="code">require_once('jpgraph/jpgraph.php')</code></p></li><li><p>Make sure that the GD extension is enabled in your
<code class="filename">php.ini</code> file (check the output from
<code class="code">phpinfo()</code> ) </p></li><li><p>[Optional] Verify that the paths defined in
<code class="filename">jpg-config.inc.php</code> corresponds to the server
setup. The path to your TTF fonts must be correct. If you get an error
saying that some TTF fonts cannot be found or read then the path needs
to be adjusted in this configuration file.</p></li><li><p>[Optional] Check that you have sufficient memory and execution time
set in your <code class="filename">php.ini</code> file. It is recommended to
allow at least 32Mb memory for PHP if you intend to run anything else
than very basic graph scripts.</p></li><li><p>[Optional] To allow for better debugging in conjunction with graph
scripts the output buffering should also be disabled in
<code class="filename">php.ini</code></p></li><li><p>[Optional] To avoid warning messages it might be necessary to set the
default timezone in <code class="filename">php.ini</code> if this has not already
been done. Starting with PHP 5.2 a warning is generated if the timezone
for PHP is not set.</p></li></ol></div><p>
</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3><p>When you install the library on a production server then you should not
install the library in the document root. Instead it should be installed so that
only the script can directly access the library files (somewhere in the PHP
path). </p><p>If you have the pro-version you really should install the pre-compiled version
of the library (available under directory <code class="filename">PhpExpress-src</code>.
This will significantly increase the performance of the library. The only
prerequisite is that you also need to install the (free) PhpExpress PHP
Accelerator from NuSphere Corporation. See <a class="xref" href="ch11.html" title="Chapter 11. NuSphere PHP accelerator">Chapter 11</a> for information on how to install the
freely available PHP Accelerator.</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch01s11.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="pt01.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch02s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">1.11. Known bugs and omissions </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 2.2. Running the examples</td></tr></table></div></body></html>

View File

@ -0,0 +1,8 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>2.2. Running the examples</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch02.html" title="Chapter 2. The Short Version: Installing the library (for PHP/Apache experts)"><link rel="prev" href="ch02.html" title="Chapter 2. The Short Version: Installing the library (for PHP/Apache experts)"><link rel="next" href="ch02s03.html" title="2.3. Basic trouble shooting"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">2.2. Running the examples</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch02.html">Prev</a> </td><th width="60%" align="center">Chapter 2. The Short Version: Installing the library (for PHP/Apache experts)</th><td width="20%" align="right"> <a accesskey="n" href="ch02s03.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2507535"></a>2.2. Running the examples</h2></div></div></div><p>The best way to verify that the installation is working is to run one of the
included example scripts. Assuming that the library is installed locally in the
document root on the HTTP server under <code class="filename">jpgraph/</code> pointing the
browser to <code class="filename">"http://llocalhost/jpgraph/Examples/example0.php"</code>
should show the same image as can be seen in <a class="xref" href="ch01s04.html#example.example0" title="Example 1.1. This is the very first example (example0.php)">Example 1.1</a>.</p><p>In order to generate all the examples available there is a "meta script" that will
just do this. Point the browser to </p><p><code class="filename">"http://llocalhost/jpgraph/Examples/testsuit.php"</code></p><p>just note that this will generate a page with more than 300 examples. Depending on
the capacity of the server it might take a few seconds before this script is
done.</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch02.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch02s03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 2. The Short Version: Installing the library (for PHP/Apache experts) </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 2.3. Basic trouble shooting</td></tr></table></div></body></html>

View File

@ -0,0 +1,12 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>2.3. Basic trouble shooting</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch02.html" title="Chapter 2. The Short Version: Installing the library (for PHP/Apache experts)"><link rel="prev" href="ch02s02.html" title="2.2. Running the examples"><link rel="next" href="ch03.html" title="Chapter 3. The Long Version: Installing the Library"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">2.3. Basic trouble shooting</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch02s02.html">Prev</a> </td><th width="60%" align="center">Chapter 2. The Short Version: Installing the library (for PHP/Apache experts)</th><td width="20%" align="right"> <a accesskey="n" href="ch03.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2507583"></a>2.3. Basic trouble shooting</h2></div></div></div><p>If none of the examples above to work there is a couple of things that needs to be
checked. If not any of these quick fixes solves the problem then it is best to read
the long version of the installation instructions before continuing the trouble shooting.</p><div class="orderedlist"><ol type="1"><li><p>Verify that the GD library is really working by running
<code class="code">phpinfo()</code> and check that your output includes a GD
section which should show similar information as the image below</p><p>
</p><div class="figure"><a name="id2507616"></a><p class="title"><b>Figure 2.1. <code class="code">phpinfo()</code> GD sections</b></p><div class="figure-contents"><div class="mediaobject"><img src="images/phpinfo-gd.png" alt="phpinfo() GD sections"></div></div></div><p><br class="figure-break">
</p></li><li><p>Make sure you have enabled strict error checking and disabled output
buffering in <code class="filename">php.ini</code>. This might not solve the
problem by itself but it will enable (better) error messages to trouble
shoot the installation.</p></li><li><p>Make sure that you are using a recent version of PHP (e.g. ≥
PHP 5.2.x)</p></li><li><p>Make sure that the path to the TTF directories are correctly specified
in <code class="filename">jpg-cnfig.inc.php</code></p></li></ol></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch02s02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch02.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">2.2. Running the examples </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 3. The Long Version: Installing the Library</td></tr></table></div></body></html>

View File

@ -0,0 +1,44 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Chapter 3. The Long Version: Installing the Library</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="pt01.html" title="Part I. Installing and verifying the configuring"><link rel="prev" href="ch02s03.html" title="2.3. Basic trouble shooting"><link rel="next" href="ch03s02.html" title="3.2. Necessary system requirements for the library"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 3. The Long Version: Installing the Library</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch02s03.html">Prev</a> </td><th width="60%" align="center">Part I. Installing and verifying the configuring</th><td width="20%" align="right"> <a accesskey="n" href="ch03s02.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2507690"></a>Chapter 3. The Long Version: Installing the Library</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ch03.html#id2507716">3.1. Downloading the library</a></span></dt><dt><span class="sect1"><a href="ch03s02.html">3.2. Necessary system requirements for the library</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch03s02.html#sec.verifying-phpgd-inst">3.2.1. Verifying the PHP/GD installation</a></span></dt><dt><span class="sect2"><a href="ch03s02.html#id2508312">3.2.2. Enabling GD library in php.ini for PH5</a></span></dt><dt><span class="sect2"><a href="ch03s02.html#id2508471">3.2.3. Verifying TTF fonts</a></span></dt><dt><span class="sect2"><a href="ch03s02.html#id2509526">3.2.4. Support for different image formats</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch03s03.html">3.3. Installing the library</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch03s03.html#sec2.config-dev-server">3.3.1. Configuring JpGraph/PHP on a development server</a></span></dt><dt><span class="sect2"><a href="ch03s03.html#sec2.config-prod-server">3.3.2. Configuring JpGraph/PHP on a production server</a></span></dt><dt><span class="sect2"><a href="ch03s03.html#sec2.adjusting-php-include-path">3.3.3. Adjusting PHP include path</a></span></dt><dt><span class="sect2"><a href="ch03s03.html#id2510786">3.3.4. Using Apache2 alias configuration during development</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch03s04.html">3.4. Installing and configuring Font support</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch03s04.html#sec1.getting_add_fonts">3.4.1. Configuring TTF fonts</a></span></dt><dt><span class="sect2"><a href="ch03s04.html#sec2.using-non-latin-fonts">3.4.2. Using non-latin based fonts with JpGraph</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch03s05.html">3.5. Adapting and customizing the installation</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch03s05.html#id2511664">3.5.1. Setting up necessary paths</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch03s06.html">3.6. Verifying the library installation</a></span></dt><dt><span class="sect1"><a href="ch03s07.html">3.7. Troubleshooting the installation</a></span></dt></dl></div><p><b>What you will learn in this chapter. </b>You will learn in detail how to configure and setup an environment to be able to
run the JpGraph library. The chapter will explain all configuration necessary in
great details and will also list some more extensive trouble shooting steps if you
encounter problems trying to get the library running. The only assumption is that
you have a working PHP installation together with your HTTP server.</p><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2507716"></a>3.1. Downloading the library</h2></div></div></div><p>
</p><div class="variablelist"><dl><dt><span class="term">Downloading the free version</span></dt><dd><p>Point the browser to
<code class="filename">"http://www.aditus.nu/jpgraph/jpdownload.php"</code>
and select the 3.x series if your are running PHP5 and the 1.x
series if you are still running a PHP4 installation. </p><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>The 1.x series of the library is no longer maintained so
in case you have not yet upgraded top PHP5 you should
strongly consider this.</p></div><p>
</p></dd><dt><span class="term">Downloading the pro version</span></dt><dd><p>
</p><div class="orderedlist"><ol type="1"><li><p>Locate your license file that was sent to you when you
purchased the library. You will need both the license
number as well as the registered license mail as stated
in the license. Your license information should look
similar to: </p><p>
</p><pre class="screen"><code class="computeroutput">----------------------------------------------------------
: Your license key : JPGP-0920-1234657
: Name on license : A. JpGraph User
: E-mail : jpgraph-user@example.com
----------------------------------------------------------
</code></pre><p>
</p></li><li><p>Point the browser to
<code class="filename">http://www.aditus.nu/jpgraph/pro_login.php</code>
and enter your licence email and key on the
website.</p><p>
</p><div class="figure"><a name="id2507833"></a><p class="title"><b>Figure 3.1. Pro-login dialogue on JpGraph Website</b></p><div class="figure-contents"><div class="mediaobject"><img src="images/pro-login.png" alt="Pro-login dialogue on JpGraph Website"></div></div></div><p><br class="figure-break">
</p></li><li><p>Depending on your system you should now download
either the 1.x or the (preferred) 3.x series. There is a
choice to either download the library as a "*.zip" file
or as a compressed "*.tar.gz" file (which is the
preferred format in a Unix environment). Save the
downloaded file to a temporary directory of your
choice.</p></li><li><p>[Optional] Verify your downloaded file against the
given MD5 sum on the website. On a Unix system this can
be done by running the <span class="command"><strong>md5</strong></span> program
and give the downloaded library as the argument.</p><p>For example: <code class="prompt">$&gt;</code>
<span class="command"><strong>md5</strong></span>
<code class="filename">jprgaph-3.0.0p.tar.gz</code></p></li><li><p>Unpack the library to a suitable directory that is in
your PHP include path as is described in <a class="xref" href="ch03s03.html" title="3.3. Installing the library">Section 3.3</a></p></li></ol></div><p>
</p></dd></dl></div><p>
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch02s03.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="pt01.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch03s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">2.3. Basic trouble shooting </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 3.2. Necessary system requirements for the library</td></tr></table></div></body></html>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,265 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>3.3. Installing the library</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch03.html" title="Chapter 3. The Long Version: Installing the Library"><link rel="prev" href="ch03s02.html" title="3.2. Necessary system requirements for the library"><link rel="next" href="ch03s04.html" title="3.4. Installing and configuring Font support"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">3.3. Installing the library</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch03s02.html">Prev</a> </td><th width="60%" align="center">Chapter 3. The Long Version: Installing the Library</th><td width="20%" align="right"> <a accesskey="n" href="ch03s04.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec1.installing-library"></a>3.3. Installing the library</h2></div></div></div><p>When you have verified the necessary preconditions as described in the previous
paragraphs it is time to install the library. The "installing" part is nothing more
than copying the files in the distribution to a place in the directory structure
where you script can find the library files. On a Unix system it is common to
install PHP libraries under "<code class="filename">/usr/share/php/</code>". On a windows
system there is really no standard path for installing PHP libraries so you have to
decide your self. </p><p>The important thing here is that the path to the library is included in the PHP
search path, i.e. it is in one of the paths that PHP searches when it tries to
resolve a "<code class="code">require_once</code>" or "<code class="code">include</code>" statements.
Furthermore, the included examples and demo applications (included in the pro
version) assumes that the library is installed under the directory
"<code class="filename">jpgraph/</code>".</p><p>As an example the following commands will install a specific version of the
library on a Unix server. If we assume that you have downloaded the library to the
"<code class="filename">/tmp/</code>" directory and are already standing in this
directory the following commands will setup the library to be used</p><p>
</p><pre class="screen">root:/tmp&gt; tar xzf jpgraph-2.5.tar.gz
root:/tmp&gt; cp -r jpgraph-2.5 /usr/shar/php/
root:/tmp&gt; ln -s /usr/shar/php/jpgraph-2.5 /usr/shar/php/jpgraph</pre><p>
</p><p>The last line makes a symbolic link from "jpgraph" to the actual version of the
library. This way you can try out different versions of the library without having
to make any changes in your scripts. You just point out a different version of the
library in the symbolic link.</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sec2.config-dev-server"></a>3.3.1. Configuring JpGraph/PHP on a development server</h3></div></div></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="sec3.setting-up-php-ini"></a>Setting up your php.ini file</h4></div></div></div><p>
</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3><p>To find the location of your <code class="filename">php.ini</code> file
create and run a script with the single line <code class="code">&lt;?php
phpinfo(); ?&gt;</code> . The look at the output for a line saying
"php.ini file used" and you will see which
<code class="filename">php.ini</code> file is used.</p></div><p>
</p><p><span class="bold"><strong>Setting the memory limits</strong></span></p><p>In many default configuration the allowed memory for PHP is not enough for
complex graph script since they (as many other image manipulation programs)
can require a lot of memory. On a development server there should be at
least 32MB memory allowed for the HTTP/PHP process. To verify this do the
following</p><p>
</p><div class="orderedlist"><ol type="1"><li><p>Open <code class="filename">php.ini</code> for editing.</p></li><li><p>Locate the line saying</p><p><code class="code">memory_limit = xx</code></p><p>where "xx" is some number. Now make sure that you have at
least 32MB allowed by making sure the line reads</p><p><code class="code">memory_limit = 32M</code></p><p>Note that fore very large images this might not be enough.
Consider the following example.</p><p>Assume you need to create an 1200x1024 image in true color.
Just the plain image in itself will require 1200x1020x4 bytes,
which is roughly 4.7MB RAM during internal processing the
library can need up to three times that amount of memory so this
means that just for the image the library needs around of ~15MB
of RAM. If we then take the memory needed to load PHP as well as
the entire JpGraph library and dynamically execute and parse the
library it can easily consume another ~15MB RAM. If the image is
very complex and requires a huge number of objects to be created
(a typical example is a large Gantt chart) it might be necessary
to double the allowed memory to 64MB RAM. </p></li></ol></div><p>
</p><p></p><p><span class="bold"><strong>Setting maximum allowed run time</strong></span></p><p>By default many installations have very short maximum run time for the PHP
scripts. Common figures are 10s. For normal interactive use involving plain
text processing this is usually adequate. However, producing large and
complex images might take considerable time (as do all images processing).
For this reason the maximum time limit for PHP should be increased to a
minimum of 20s (depending on the complexity of your images as well as any
associated data processing it might be necessary to allow up to
30-40s).</p><p>The allowed running time is controlled by the <code class="filename">php.ini</code>
setting</p><p><code class="code">max_execution_time = xx</code></p><p>where "xx" is some number. Recommended setting is therefore </p><p><code class="code">max_execution_time = 30</code></p><p></p><p><span class="bold"><strong>Disabling output buffer</strong></span></p><p>The next part of the <code class="filename">php.ini</code> file that might need
changing is the output buffer. In short this should be disabled and we will
shortly explain why. To check this do the following</p><div class="orderedlist"><ol type="1"><li><p>Open <code class="filename">php.ini</code> for editing</p></li><li><p>Locate the line saying </p><p><code class="code">output_buffering = xx</code></p><p>where "xx" is some number. Make sure that this line is
commented out, i.e. it reads</p><p><code class="code">; output_buffering = xx</code></p></li></ol></div><p>This reason we want this to be commented out is that during
development we want to be able to see the potential error messages produced
by the library and having the output buffering enabled will actually prevent
this. Fully understanding why this is the case is good first step into the
added complexity of producing images with PHP compared with just outputting
text. Understanding this requires us to understand a few basic principles
about the HTTP protocol. Especially how MIME encodings of data works.</p><p>The following explanation is slightly simplified since a full description
of the HTTP protocol would bring us a bit to far in this manual</p><div class="orderedlist"><ol type="1"><li><p>A client (e.g. browser) requests data from the server by
issuing a GET (or possible a POST) command to the server. This
is what happens when you enter a URI i the address bar in the
browser.</p></li><li><p>The server replies with a data stream (or an error if the
requested data wasn't available). This data stream is prepended
with header (MIME header) that tells the client (e.g. the
browser) how to interpret the data that follows. The most common
type (and the default type if no header is sent by a faulty
server) is "text/html" . This tells the client to interpret the
data as plain text with embedded HTML encoding. </p><p>When the data is to be interpreted as an image the header will
instead be one of the image headers, for example
<code class="code">"image/png"</code> or <code class="code">"image/jpeg"</code>. When
the client receives this header it will Interpret all the
following data as an image encoded in the indicated format. </p><p>The important thing to keep in mind here is that each server
reply can have one and only one MIME type. This is the key to
further understanding the specific issues with dynamic image
generation. This explains why if a PHP script running on the
server sends a header first indicating that the following data
it sends should be interpreted by the client as an image it
cannot send both image data and some text.</p></li></ol></div><p>We are now in a position to explain how output buffering would
make debugging more difficult.</p><p>Normally all output from a PHP script is sequentially, i.e. the header
must first be sent and then the data. If no header is sent or plain text is
sent without a header the client will interpret this as
<code class="code">"text/html"</code>. One purpose with "output_buffer" it to
circumvent this to allow a certain amount of output to be put in a buffer
for a while and later when some processing has determined what header should
be sent the data is prepended with the correct header and the rest of the
data is then sent. </p><p>What could now happen is the following (not unlikely scenario): </p><div class="orderedlist"><ol type="1"><li><p>The scripts starts executing and the image starts to be
build.</p></li><li><p>Your script has some minor issues which produces some warnings
from PHP. These warning does not get sent directly back to the
client (the browser) to allow you to act on these warnings
instead they will be put into the output buffer. When later the
scripts starts outputting the proper image header and the image
data it gets added to the output buffer where your previous
textual PHP warning already are stored. </p></li><li><p>Your client now receives the header that indicates that the
following data should be interpreted as an image but since that
image data is mixed with the textual warning messages it will
fail to decode the data (since it is not proper image data) and
will typical just show the image as a square with a red-cross
(FireFox) or some message along the lines of "<span class="italic">Cannot decode image</span>". This is all
depending on how a certain client handles a corrupt
image.</p></li></ol></div><p>The above scenario makes it impossible to debug your script
since it will give no clue to what caused or where in your script these
warnings were generated. The way to counteract this scenario is to disable
output buffering. In this way the warning will be sent back to the client as
soon as they are generated by PHP and will allow you to act on them. </p><p></p><p><span class="bold"><strong>Enabling adequate error checking</strong></span></p><p>The final part of the <code class="filename">php.ini</code> file that should be
adjusted (and this is not only for the JpGraph library) is the error level.
To ensure maximum interoperability of the developed scripts they should all
run completely silent no matter what error levels are set on the server.
This means that development of all scripts should always be done with
maximum error checking enabled. The JpGraph library can safely run
completely silent even when all error checking is enabled.</p><p>The error checking should therefore be specified as</p><p><code class="code">error_reporting = E_ALL | E_STRICT</code></p><p>to enable the highest degree of PHP error checking</p><p></p><p>
</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3><p>In addition to the above setting it is a good idea to also to
makes sure that the following options are set</p><p><code class="code">zend.ze1_compatibility_mode = Off</code></p><p>Zend engine 1 compatibility might cause problems with the
library</p><p><code class="code">implicit_flush = On</code></p><p>This can reduce the performance and shouldn't be used on a
production server but will make all outputs sent back to the client
as soon as possible and will aid in debugging.</p><p><code class="code">allow_call_time_pass_reference = Off</code></p><p>This is just a general good idea since call time pass references
is deprecated in PHP 5.0 and higher</p><p><code class="code">display_errors = On</code></p><p>This makes sure all error are displayed</p><p><code class="code">display_startup_errors = On</code></p><p>This makes sure that any initial errors thrown by PHP will be
reported</p></div><p>
</p><p><span class="bold"><strong>Setting default timezone</strong></span></p><p>Starting with PHP 5.2 a warning will now be generated unless a default
time zone is explicitly specified in <code class="filename">php.ini</code>. To set
this find the line <code class="code">date.timezone</code> in the
<code class="code">[Date]</code>section and set this to valid zone. For example to
specify GMT+1 one could specify</p><p><code class="code">date.timezone = Europe/Paris</code></p><p>Note: There should be no citation signs around the time zone.</p><p>
</p><div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3><p>In order to use the LED module (See <a class="xref" href="ch17.html#sec.led-graph-type" title="17.1. LED bill boards">Section 17.1</a>) the PHP installation must
have multi-byte strings enabled so that the function
<span class="command"><strong>mb_strlen()</strong></span> is available. This is normally
enabled at compile time for PHP by specifying the options
<code class="code">--enable-mbstring --enable-mbregex</code> when configuring
the compile options.</p></div><p>
</p><p>
</p><div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3><p>In order to use the PDF417 barcode module (See <a class="xref" href="ch25.html" title="Chapter 25. PDF417 (2D-Barcode)">Chapter 25</a>) it is necessary for the PHP
installation to support the function <span class="command"><strong>bcmod()</strong></span>.
This is enabled when compiling PHP by making sure that the option
<code class="code">--enable-bcmath</code> is given when configuring PHP at
compile time.</p></div><p>
</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2510338"></a>Setting up your jpg-config.inc.php</h4></div></div></div><p>Apart from the standard configuration described in <a class="xref" href="ch03s04.html" title="3.4. Installing and configuring Font support">Section 3.4</a> and <a class="xref" href="ch03s05.html" title="3.5. Adapting and customizing the installation">Section 3.5</a> there is only one important
configuration that is specific for a development server and that is the
localization setting for error messages. </p><p>As of version 3.0.0 there are three localization options</p><div class="orderedlist"><ol type="1"><li><p>English error messages ("en")</p></li><li><p>German error messages ("de")</p></li><li><p>Production error messages ("prod"). This is not really a
localization but a different set of error messages which does
not give detailed error messages but a generic message suitable
for a production server where the end user is not helped by
detailed graph script errors. Instead a generic message is shown
together with an error code that corresponds to the detailed
error. ("prod")</p></li></ol></div><p>In order to specify the error message localization the
following define in <code class="filename">jpg-config.inc.php</code> must be set the </p><p><code class="code">define('DEFAULT_ERR_LOCALE','en');</code></p><p>The possible options are</p><p>
</p><div class="orderedlist"><ol type="1"><li><p>"en", English locale</p></li><li><p>"de", German locale</p></li><li><p>"prod", The production version of the error messages.</p></li></ol></div><p>
</p><p>
</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3><p>In addition to specifying the locale in the
<code class="filename">jpg-config.inc.php</code> file it can also be
specified dynamically in each script by calling</p><p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">JpGraphError::SetErrLocale($aLocale);</span></pre></td></tr></table></div><p>
</p></div><p>
</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sec2.config-prod-server"></a>3.3.2. Configuring JpGraph/PHP on a production server</h3></div></div></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2510504"></a>Setting up your php.ini file</h4></div></div></div><p>Apart from what is applicable to a development server as described in <a class="xref" href="ch03s03.html#sec2.config-dev-server" title="3.3.1. Configuring JpGraph/PHP on a development server">Section 3.3.1</a> the following changes should be
considered in a production environment.</p><p>
<span class="bold"><strong>Setting the memory limits</strong></span>
</p><p>The one thing to keep in mind here is that each active connection will
spawn a unique PHP instance (HTTP process). This means that the memory limit
set per PHP process can cause a very high memory demand on a busy server
with many simultaneous connections. For this reason it is important that
during system test (before going into production) the actual needed memory
limit is determined. </p><p>For a busy server it is not uncommon to dimension it so it can handle 100
simultaneous connections. If the limit of r each PHP process is set to 32MB
this means that the server needs at least ~3.2GB memory just to handle the
PHP processes (if they are all using there maximum allowed memory).</p><p>
<span class="bold"><strong>Setting maximum allowed run time</strong></span>
</p><p>The same principle applies to a the allowed run time. For a production
server with high load and many simultaneous users it might be necessary to
increase the maximum allowed execution time just to be sure no process is
terminated due to it reaching its maximum allowed run time. When that
happens the PHP process will be killed an no output sent back to the client
(e.g. the browser).</p><p>
<span class="bold"><strong>Disabling output buffer</strong></span>
</p><p>The output buffer should be disabled on the production server as well
since enabling this will slow down the PHP and put a higher demand on the
memory requirements.</p><p>
<span class="bold"><strong>Enabling adequate error checking</strong></span>
</p><p>On a production server it is not a good idea to display all PHP error
messages to the end user so the display of error messages should be disabled
and the error messages should only be logged to a file.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3><p> On a production server it is also a good to idea to have the
following settings: </p><p>
<code class="code">display_errors = Off</code>
</p><p>This makes sure that now PHP errors are displayed</p><p>
<code class="code">display_startup_errors = Off</code>
</p><p>This makes sure that any initial errors thrown by PHP is not displayed
to the end user</p><p><code class="code">log_errors = On</code></p><p><code class="code">error_log = &lt;name-of-log-file&gt;</code></p><p>This makes sure all server PHP errors are logged to a specified
file</p></div></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2510671"></a>Setting up your <code class="filename">jpg-config.inc.php</code></h4></div></div></div><p>On a production server it is best not to show detailed error messages to
an end user. Instead it is better to have a generic error message that
indicates a server problem and give an error code which can be decoded by
looking it up in the table in <a class="xref" href="aph.html" title="Appendix H. Error messages">Appendix H</a> Using a generic error message is achieved by
setting the following define:</p><p><code class="code">define('DEFAULT_ERR_LOCALE','prod');</code></p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sec2.adjusting-php-include-path"></a>3.3.3. Adjusting PHP include path</h3></div></div></div><p>As was mentioned before the library should be installed somewhere in the PHP
include path. There are two ways of configuring the include path:</p><p>
</p><div class="orderedlist"><ol type="1"><li><p>setting the include path in <code class="filename">php.ini</code></p><p><code class="code">include_path = &lt;file-path&gt;</code></p></li><li><p>adjusting the include path directly in the code by using the PHP
command <code class="code">php_ini_set()</code> at the top of the script</p></li></ol></div><p>
</p><p>The library examples assume that the library is available under a directory
called "<code class="filename">jpgraph/</code>" . This will allow the scripts to include
the library files by, for example, writing "<code class="code">include</code>" or
"<code class="code">require_once</code>" statements such as </p><p><code class="code">require_once( 'jpgraph/jpgraph.php')</code></p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2510786"></a>3.3.4. Using Apache2 alias configuration during development</h3></div></div></div><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This section only discusses alias setting using the Apache HTTP server
so this section can be skipped at first time reading the manual without
loss of continuation.</p></div><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>More detailed information on the alias directive is also available in
the official Apache documentation at <code class="uri"><a class="uri" href="http://httpd.apache.org/docs/2.2/mod/mod_alias.html#alias" target="_top">http://httpd.apache.org/docs/2.2/mod/mod_alias.html</a></code></p></div><p>
</p><p>When accessing examples and test code through a regular bowser during
development the scripts must be available in document root (or somewhere beneath
that root) the root is traditionally named <code class="code">/htdocs</code>. Having a
development code/repository directly under this root directory is not a good
idea. For example, write access to a document root (even on a development
server) should be restricted, in addition the paths given to a test team should
be the same whatever version is currently under test so storing different
versions with different names under the root is also a poor setup.</p><p>A much better and easy, approach is to use the powerful concept of alias in
Apache. This is a way of mapping a URL to a specific directory on the server.
For example if <code class="uri"><a class="uri" href="http://www.eclipse.org/projects/project-plan.php?projectid=tools.pdt" target="_top">Eclipse-PDT</a></code>
is used as an IDE to develop PHP it is mandatory to have a workspace setup where
all the working files resides. Assuming that a local developer has his workspace
directly in his home directory, say <code class="filename">~joe/workspace</code>, we
could configure an alias so that the workspace is accessible by the alias
"<code class="filename">http://localhost/ws/</code>" by adding the following
configuration in the Apache setup file(s)</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">Alias /ws /home/joe/worksapce
&lt;Directory /home/joe/workspace&gt;
Order allow,deny
Allow from all
&lt;/Directory&gt;</span></pre></td></tr></table></div><p>In this particular setup we use very liberal settings, allowing basically
everyone with server access to access the directory. Using this approach makes
it very easy to use the same test setup but allow testing of different
branches/versions of the code.</p><p>Depending on the system these configurations can reside in different places.
However, a very common structure is to keep all these small configuration files
under <code class="filename">/etc/apache/conf.d/</code> The main Apache configuration
then reads all the files (regardless of there name) that are stored under this
directory. </p><p>As a final example we show a further slightly more complex example (which
actually shows how most of our developers have there systems setup for PHP5
development). This example adds options to do directory listing and allows the
server to follow symbolic links. More information on available argument for the
directive option is available in the official Apache documentation <code class="uri"><a class="uri" href="http://httpd.apache.org/docs/2.2/mod/core.html#options" target="_top">http://httpd.apache.org/docs/2.2/mod/core.html#options</a></code></p><p>
</p><div class="example"><a name="id2510923"></a><p class="title"><b>Example 3.5. Alias configuration for a development server running Apache with
Eclipse-PDT</b></p><div class="example-contents"><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code"># Configuration for Eclipse workspace
#
&lt;IfModule mod_php5.c&gt;
Alias /ws/ /home/joe/workspace/
&lt;Directory /home/joe/workspace/&gt;
Options +Indexes +Multiviews +FollowSymLinks
order allow,deny
allow from all
&lt;/Directory&gt;
&lt;/IfModule&gt;</span></pre></td></tr></table></div></div></div><p><br class="example-break">
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch03s02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch03s04.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">3.2. Necessary system requirements for the library </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 3.4. Installing and configuring Font support</td></tr></table></div></body></html>

View File

@ -0,0 +1,104 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>3.4. Installing and configuring Font support</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch03.html" title="Chapter 3. The Long Version: Installing the Library"><link rel="prev" href="ch03s03.html" title="3.3. Installing the library"><link rel="next" href="ch03s05.html" title="3.5. Adapting and customizing the installation"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">3.4. Installing and configuring Font support</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch03s03.html">Prev</a> </td><th width="60%" align="center">Chapter 3. The Long Version: Installing the Library</th><td width="20%" align="right"> <a accesskey="n" href="ch03s05.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec1.installing-fonts"></a>3.4. Installing and configuring Font support</h2></div></div></div><p>JpGraph supports two types of fonts, bitmap and TTF fonts. The advantage with
bitmap fonts are that they are supported from within the library without further
configuration. TTF fonts require some configuration and possible installation of the
actual TTF font specification file. (For more on installing TTF fonts see <a class="xref" href="ch03s04.html#sec1.getting_add_fonts" title="3.4.1. Configuring TTF fonts">Section 3.4.1</a>.) </p><p>The drawbacks, on the other hand, with bitmap fonts are quite a few</p><p>
</p><div class="itemizedlist"><ul type="disc"><li><p>they look quite crude and are only available in a few sizes</p></li><li><p>italic font style is not supported for bitmap fonts</p></li><li><p>they only support 7-bit ASCII characters</p></li><li><p>they only support 0 and 90 degree rotated text</p></li></ul></div><p>
</p><p>You can read more about how to use and select among the different fonts in <a class="xref" href="ch08.html" title="Chapter 8. Text and font handling">Chapter 8</a></p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sec1.getting_add_fonts"></a>3.4.1. Configuring TTF fonts</h3></div></div></div><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This could be considered an optional section since the library will
work even without TTF fonts. However, for th reasons listed previously
it is strongly recommended that TTF support is configured.</p></div><p>
</p><p>In the following we will assume that the FreeType library is enabled and
verified in the PHP installation (See <a class="xref" href="ch03s02.html#fig.phpinfo-gd" title="Figure 3.2. phphinfo() GD-Information">Figure 3.2</a>)</p><p>Due to various legal issues no TTF fonts are included in the distribution of
JpGraph since many commonly used TTF font files are copyrighted and there
distribution restricted. For the most commonly used WEB-fonts (the Microsoft
Core Fonts) the status is unclear. For many years Microsoft distributed them
freely but they are no longer available from Microsofts home page. Instead they
are available from <code class="uri"><a class="uri" href="http://corefonts.sourceforge.net/" target="_top">http://corefonts.sourceforge.net/</a></code>
</p><p>There are however a fair amount of freely available high quality TTF fonts
(see below). The first thing needed is to make sure that the path defines in the
file <code class="filename">jpg-config.inc.php</code> corresponds to the server setup (so
that the library can find the font files)</p><div class="orderedlist"><ol type="1"><li><p>Open <code class="filename">jpg-config.inc.php</code> for editing</p></li><li><p>Locate the define <code class="code">TTF_DIR</code> (this is the define that
possible needs updating depending on your system). By default this path
will have a sensible values depending on if the library is installed on
a Windows or a Unix system.</p></li><li><p>If you are on a Windows platform you can just point the TTF directory
path in JpGraph to use the standard Window font directory (e.g
<code class="filename">C:\windows\fonts\</code>)</p></li><li><p>If you are on a Unix platform, which may not have any TTF fonts
installed, you can download and install the core MS WEB-initiative fonts
from <code class="uri"><a class="uri" href="http://corefonts.sourceforge.net/" target="_top">http://corefonts.sourceforge.net/</a></code>
many Linux distributions also have automatic ways to install these
fonts. These fonts were put in the public domain by the Microsoft
Corporation but they are no longer available directly from
Microsoft.</p></li><li><p>You can also chose to install the freely available Vera Bitstream TTF
fonts available from <code class="uri"><a class="uri" href="http://www.gnome.org/fonts/" target="_top">http://www.gnome.org/fonts/</a></code></p></li><li><p>You can also chose to install the freely available DejaVu TTF fonts <code class="uri"><a class="uri" href="http://sourceforge.net/projects/dejavu/" target="_top">http://sourceforge.net/projects/dejavu</a></code></p></li></ol></div><p>JpGraph uses a standard naming convention for the TTF font files in order to
be able to find the correct font file that correspond to a particular font
family. This naming convention follows the standard naming of the available font
files from the distributions listed above. </p><p>If the installation of the library is made on a computer running MS Windows
then it is recommended to use the already available font files in Windows
(usually located in <code class="filename">C:\WINDOWS\FONTS</code>). </p><p>If the installation is made on a UNIX derivate running X11 then the font
location can differ between versions and UNIX brands. One commonly used path in
modern installations are "<code class="filename">/usr/share/fonts/truetype/</code>" (In
older installations it was common to put the truetype fonts under
"<code class="filename">/usr/X11R6/lib/X11/fonts/truetype/</code>".)</p><p>Finally we note that it is possible to install additional fonts not natively
supported by the library by using the <code class="code">SetUserFont()</code> family of
methods. (In theory it is also possible to patch the jpgraph source files to
include support for other font files natively but since this requires code
modifications of the library we do not discuss this further here in the
introduction.)</p><p>Freely available TTF fonts can be found, for example, from</p><p>
</p><div class="itemizedlist"><ul type="disc"><li><p><code class="uri"><a class="uri" href="http://www.webfontlist.com" target="_top">http://www.webfontlist.com</a></code></p></li><li><p><code class="uri"><a class="uri" href="http://www.webpagepublicity.com/free-fonts.html" target="_top">http://www.webpagepublicity.com/free-fonts.html</a></code></p></li><li><p><code class="uri"><a class="uri" href="http://www.fontonic.com/fonts.asp?width=do&amp;offset=120" target="_top">http://www.fontonic.com/fonts.asp?width=do&amp;offset=120</a></code></p></li><li><p><code class="uri"><a class="uri" href="http://www.fontspace.com/category/famous" target="_top">http://www.fontspace.com/category/famous</a></code></p></li></ul></div><p>
</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sec2.using-non-latin-fonts"></a>3.4.2. Using non-latin based fonts with JpGraph</h3></div></div></div><p>In addition to European fonts it is also possible to use non-latin based fonts
such as Cyrillic, Japanese, Chinese, Hebrew and Greek. For any of these
languages a suitable TTF font that supports the non-latin based language must be
made available to the library. Some specific rules also applies to each of the
supported languages due to the necessary character encoding needed due to
different convention when writing the character for some languages. </p><p>
</p><div class="itemizedlist"><ul type="disc"><li><p>For Cyrillic support the define <code class="code">LANGUAGE_CYRILLIC</code> in
<code class="filename">jpg-config.php</code> must be set to
<code class="code">true</code>. It is then possible to use a suitable
Cyrillic font as replacement of the ordinary font. This setting
combined with the <code class="code">CYRILLIC_FROM_WINDOWS</code> and
<code class="code">LANGUAGE_CHARSET</code> is used to fine tune the handling
cyrillic input. The rules are as follows:</p><p>
</p><div class="orderedlist"><ol type="1"><li><p>If <code class="code">LANGUAGE_CYRILLIC</code> is <span class="bold"><strong>false</strong></span> no specific handling of
Cyrillic characters at all will be done.</p></li><li><p>If <code class="code">CYRILLIC_FROM_WINDOWS</code> is <span class="bold"><strong>true</strong></span> then it will be assumed
the input coding by default is encoded using <span class="bold"><strong>WINDOWS-1251</strong></span>. </p><p>The conversion is then done via a call to
<code class="code">convert_cyr_string($aTxt, 'w', 'k')</code>
where <code class="code">$aTxt</code> is replaced with the input
string to be encoded.</p></li><li><p>If <code class="code">CYRILLIC_FROM_WINDOWS</code> is <span class="bold"><strong>false</strong></span> then it will be assumed
the input coding by default is encoded using <span class="bold"><strong>KOI8-R</strong></span>.</p><p>The conversion is then done via the sequence of
callls</p><p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-var">$isostring</span><span class="hl-code"> = </span><span class="hl-identifier">convert_cyr_string</span><span class="hl-brackets">(</span><span class="hl-var">$aTxt</span><span class="hl-code">, </span><span class="hl-quotes">&quot;</span><span class="hl-string">k</span><span class="hl-quotes">&quot;</span><span class="hl-code">, </span><span class="hl-quotes">&quot;</span><span class="hl-string">i</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$unistring</span><span class="hl-code"> = </span><span class="hl-identifier">LanguageConv</span><span class="hl-code">::</span><span class="hl-identifier">iso2uni</span><span class="hl-brackets">(</span><span class="hl-var">$isostring</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
</p><p>in oder to get a proper utf-8 internal encoding
(internally the library only uses utf-8 encoding)</p></li><li><p><code class="code">LANGUAGE_CHARSET</code> can be used to
dynamically adjust the conversion of the input character
set when using cyrillic characters. This constant is
used to auto-detect whether cyrillic conversion is
really necessary if enabled (via the If
<code class="code">LANGUAGE_CYRILLIC</code>=true) . This constant
can be set to a variable containing the currently used
character input set .A typical such string would be
'UTF-8' or 'utf-8' (the comparison is case-insensitive).
If this charset is not 'koi8-r' nor 'windows-1251'
derivate then no conversion is done. </p></li></ol></div><p>
</p><p></p></li><li><p>For Chinese character set JpGraph supports both BIG5 and GB2312
encoding. For BIG5 encoding the PHP installation must have support
for the "<code class="code">iconv()</code>" function. Furthermore the define
<code class="code">CHINESE_TTF_FONT</code> must be set to the name of the
Chinese BIG5 font that is to be used. By default this is set to
"<code class="filename">bkai00mp.ttf</code>". To use the Chinese BIG5
font in the scripts one must then specify the font family as
<code class="code">FF_CHINESE</code>.</p><p>To use the alternative font files
"<code class="filename">simsun.ttc</code>" and
"<code class="filename">simhei.ttf</code>" (which uses the GB2312
encoding) the only step needed is to install those fonts in the
normal TTF font directory and then specify the font family as
<code class="code">FF_SIMSUN</code>, the "<code class="filename">simhei.ttf</code>" is
used when the font style is specified as
<code class="code">FS_BOLD</code>.</p></li></ul></div><p>
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch03s03.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch03s05.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">3.3. Installing the library </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 3.5. Adapting and customizing the installation</td></tr></table></div></body></html>

View File

@ -0,0 +1,23 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>3.5. Adapting and customizing the installation</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch03.html" title="Chapter 3. The Long Version: Installing the Library"><link rel="prev" href="ch03s04.html" title="3.4. Installing and configuring Font support"><link rel="next" href="ch03s06.html" title="3.6. Verifying the library installation"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">3.5. Adapting and customizing the installation</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch03s04.html">Prev</a> </td><th width="60%" align="center">Chapter 3. The Long Version: Installing the Library</th><td width="20%" align="right"> <a accesskey="n" href="ch03s06.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec1.adapting-installation"></a>3.5. Adapting and customizing the installation</h2></div></div></div><p>All configuration of the library is done in the file
<code class="filename">jpg-config.inc.php</code>. Each option in the file is extensively
documented in <a class="xref" href="apl.html" title="Appendix L. The JpGraph configuration file">Appendix L</a> Here we will only cover the most important
configuration that it likely to have to be customized in order to successfully run
the library.</p><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>All configuration settings comes with default values that should in normal
cases be enough for a "standard" system. However for a production system you
might want to fine tune this according to your specific system setup.</p></div><p>
</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3><p>During development (and to some extent even on a production server) it
might be necessary to adjust some parameters in your
<code class="filename">php.ini</code> file. For more on this see <a class="xref" href="ch03s03.html" title="3.3. Installing the library">Section 3.3</a></p></div><p>
</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2511664"></a>3.5.1. Setting up necessary paths</h3></div></div></div><p>There are three categories of directory paths that can be specified. The
categories are:</p><p>
</p><div class="orderedlist"><ol type="1"><li><p>Font directories, this we already touched upon in <a class="xref" href="ch03s04.html#sec1.getting_add_fonts" title="3.4.1. Configuring TTF fonts">Section 3.4.1</a>. </p></li><li><p>Cache directory, the cache feature of the library is extensively
discussed in <a class="xref" href="ch09.html" title="Chapter 9. Using the JpGraph cache system">Chapter 9</a>. The important thing to notice
here is that whatever directory you chose to use as a cache
directory it must be a directory that is writable for the process
running PHP (normally the HTTP server process, e.g. Apache)</p></li><li><p>CSIM Cache directory (if CSIM cache feature is used). CSIM stands
for Client Side Image Maps and is a way to construct client side
drill down charts. (Today this is the only inpractice used image
mapping method but it is also possible to have Server Side Image
Maps).</p></li></ol></div><p>
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch03s04.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch03s06.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">3.4. Installing and configuring Font support </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 3.6. Verifying the library installation</td></tr></table></div></body></html>

View File

@ -0,0 +1,19 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>3.6. Verifying the library installation</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch03.html" title="Chapter 3. The Long Version: Installing the Library"><link rel="prev" href="ch03s05.html" title="3.5. Adapting and customizing the installation"><link rel="next" href="ch03s07.html" title="3.7. Troubleshooting the installation"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">3.6. Verifying the library installation</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch03s05.html">Prev</a> </td><th width="60%" align="center">Chapter 3. The Long Version: Installing the Library</th><td width="20%" align="right"> <a accesskey="n" href="ch03s07.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2511736"></a>3.6. Verifying the library installation</h2></div></div></div><p>After installing the library a good check that everything works is to run the
included example scripts. Worth noting is that some of the examples uses TTF fonts.
This means that if you try to run those examples on an installation that does not
have any TTF fonts configured an error message will be displayed.</p><p><span class="bold"><strong>Running your first example</strong></span></p><p>If we assume that you have installed the library directly under the document root
on the HTTP server in a directory named "<code class="code">jpgraph/</code>" you can access the
examples in the "<code class="filename">jpgraph/Examples/</code>" directory by pointing your
browser for example to "<code class="filename">jpgraph/Examples/example0.php</code>" . This
should then show the same image as is displayed in <a class="xref" href="ch01s04.html#fig.example0" title="Figure 1.2. This is the very first example (example0.php)">Figure 1.2</a></p><p>If the above example works correctly you can run all the included examples by
pointing the browser to the script
"<code class="filename">jpgraph/Examples/testsuit.php</code>". This will automatically
generate all non-CSIM examples (for an explanation of CSIM graphs see ??) and show
them in one long list. Note that since this has more than 300 images it can take
some time to generate all example images.</p><p>
</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3><p>In order to generate all CSIM examples you can run the testsuit with the
URL argument <code class="code">?type=2</code></p><p><code class="code">jpgraph/Examples/testsuit.php?type=2</code></p><p>You will then get a number of examples of so called drill-down charts
where a number of areas of the graphs a re hotspots which can be clicked to
open a specified URL. However, in these examples all the click-URL have just
dummy values which points back to the same file.</p></div><p>
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch03s05.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch03s07.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">3.5. Adapting and customizing the installation </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 3.7. Troubleshooting the installation</td></tr></table></div></body></html>

View File

@ -0,0 +1,88 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>3.7. Troubleshooting the installation</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch03.html" title="Chapter 3. The Long Version: Installing the Library"><link rel="prev" href="ch03s06.html" title="3.6. Verifying the library installation"><link rel="next" href="pt02.html" title="Part II. Basic graph creation"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">3.7. Troubleshooting the installation</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch03s06.html">Prev</a> </td><th width="60%" align="center">Chapter 3. The Long Version: Installing the Library</th><td width="20%" align="right"> <a accesskey="n" href="pt02.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2511832"></a>3.7. Troubleshooting the installation</h2></div></div></div><p>Unfortunately there are many parameters in a server installation that may affect
the execution of PHP so the steps below can only give some indications of how to
further investigate some potential problems.</p><p>Experience shows that most of the trouble are caused by either an old buggy
version of the free-type TTF library or using an old antiquated version of the GD
library. So before starting trouble shooting the scripts please make sure that you
have an up to date PHP installation with the bundled version of the GD library (as
describe in the previous sections) and a working FreeType library installed.</p><div class="orderedlist"><ol type="1"><li><p><span class="bold"><strong>No image is displayed.</strong></span></p><p>The first thing you should do is to isolate the problem by calling
your graph script directly in the browser. There are then two variants
of this problem. </p><p>
</p><div class="orderedlist"><ol type="a"><li><p>No data is sent back from the server.</p><p>You can verify this by calling your graph script directly
in the browser and then check the source (click "view
source" menu item in the browser). If this is a truly blank
image then no data was sent back from the browser.</p><p>This means that the PHP process has been terminated
prematurely before it could send any data back. This could
be caused by either the PHP process crashing (due to a bug
in either PHP or your HTTP server) or the HTTP server
crashed. This is often due to a broken PHP installation and
more than often a problem with the True Type libraries. </p><p>It could also be caused by the PHP script running longer
than the maximum allowed execution time (as specified in
<code class="filename">php.ini</code>). The first thing you
should do is to increase the maximum allowed execution time.
If this does not solve the problem you should look in the
log files for both your HTTP server and PHP to try to find
clues to if the PHP process really crashed. Another
possibility is that the PHP process uses more than the
maximum allowed memory (as set in
<code class="filename">php.ini</code>) and then it is terminated.
So a good first step is to put some really high values for
memory and time just to take away these parameters.</p></li><li><p>The data sent back is corrupt.</p><p>Depending on your browser this can show up differently but
a common symptom is a "red X" in the browser. In order to
debug this you should make sure that you have followed the
steps in <a class="xref" href="ch03s03.html#sec2.config-dev-server" title="3.3.1. Configuring JpGraph/PHP on a development server">Section 3.3.1</a> to make sure you
have output buffering disabled and have maximum error
checking enabled in PHP. The most common cases for this type
of problem is having enabled output buffering and some minor
errors in the script which causes PHP to emit warnings which
gets included in the image data. </p><p>A very common mistake is to have some white spaces in the
script before the opening "<code class="code">&lt;?php</code>". This
white space will be added to the output buffer and then get
mixed up with the image data causing the image data to be
corrupt. A similar problem can occur if multiple newlines
are added after the final <code class="code">"?&gt;"</code>
</p></li></ol></div><p>
</p></li><li><p><span class="bold"><strong>An error message saying "Fonts are not available or not
readable" </strong></span></p><p>When an image contains TTF fonts you might get an error message saying
that the fonts are not available or not readable. If this is the case it
is first necessary to check that the font files really exist in the
directory that is specified in <code class="filename">jpg-config.inc.php</code>
and that they are also readable by the HTTP/PHP process. If this is the
case then it is necessary to check that the names of the font files are
the one that JpGraph assumes, see <a class="xref" href="ch03s02.html#sec3.name-of-ttf-files" title="Name of TTF font files">the section called “Name of TTF font files”</a>. Another problem can be if
the PHP installation is running in "safe mode" (See <code class="uri"><a class="uri" href="http://se.php.net/manual/en/ini.sect.safe-mode.php" target="_top">PHP
Manual: Security and safe mode</a></code>) and has enabled strict
directory policy via an "<code class="code">open_basedir</code>" restriction. This
will prevent the PHP process from reading any files outside the
specified base directory. If this is enabled there is no way around for
PHP to read any files outside this restriction and any TTF files
necessary must be moved so that they can be accessed within the realms
of the specified basedirectory.</p><p>If you are running IIS and Win2k and get the error "Can't find font"
when trying to use TTF fonts then try to change the paths to UNIX style,
i.e. "<code class="filename">/usr/local/fonts/ttf/</code>". Remember that the
path is absolute and not relative to the <code class="filename">htdocs</code>
catalogue.</p><p>If you are running on Unix server please keep in mind that file names
are case sensitive.</p></li><li><p><span class="bold"><strong>An error message saying "Headers have already been
sent"</strong></span></p><p>A common mistake is to have a space in the beginning of the image
script which the HTTP server will send back to the browser. The browser
now assumes that the data coming back from this script is text since it
hasn't received an explicit header. When then the image headers get sent
back to the browser to forewarn the browser of the forthcoming image
data the browser will not like that as it has already assumed the data
stream was a text stream. The browser will then give the infamous
"Headers already sent error".</p><p>Make sure that your script has no white space before the opening
"<code class="code">&lt;?php</code>" statement or a number of blank lines after
the concluding "<code class="code">?&gt;</code>"</p></li><li><p><span class="bold"><strong>Issues specific to Windows and IIS</strong></span></p><p>Some windows installations seems to have a problem with a PHP script
ending in more than one newline (This newline seems to be sent to the
browser and will cause a <span class="italic">Header already sent error</span>). To correct this
problem check all your scripts for more than one empty newline after the
ending "<code class="code">?&gt;</code>" statement. All files provided with the library
end in exactly one final newline and should not be a problem.</p></li><li><p><span class="bold"><strong>TTF fonts are not displayed correctly</strong></span></p><p>If the TTF fonts only shows up as yellow then the installation is used
a buggy (too old) installation of the FreeType font library and the only
thing to do is to re-install and setup PHP+GD again with a newer version
of the FreeType library. Another symptom of a an (old) buggy FreeType
library is that the fonts are not correctly rotated (the text string is
rotated but not the individual characters).</p></li></ol></div><p>As a final advise you should read the FAQ (available in this manual
see <a class="xref" href="apc.html" title="Appendix C. FAQ">Appendix C</a>) or on the JpGraph website at <code class="uri"><a class="uri" href="http://www.aditus.nu/jpgraph/jpgraphfaq.php" target="_top">http://www.aditus.nu/jpgraph/jpgraphfaq.php</a></code></p><p>Depending on your sever it might also help to recompile PHP yourself instead of
the version included with the system. You can find typical configuration scripts to
compile PHP4 and PHP5 in the appendices, see <a class="xref" href="api.html" title="Appendix I. Compiling PHP">Appendix I</a>
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch03s06.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="pt02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">3.6. Verifying the library installation </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Part II. Basic graph creation</td></tr></table></div></body></html>

View File

@ -0,0 +1,13 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Chapter 4. Your first graph script</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="pt02.html" title="Part II. Basic graph creation"><link rel="prev" href="pt02.html" title="Part II. Basic graph creation"><link rel="next" href="ch04s02.html" title="4.2. Graphing the number of sun spots during the 19th Century"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 4. Your first graph script</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="pt02.html">Prev</a> </td><th width="60%" align="center">Part II. Basic graph creation</th><td width="20%" align="right"> <a accesskey="n" href="ch04s02.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2496880"></a>Chapter 4. Your first graph script</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ch04.html#id2496900">4.1. Some words of caution</a></span></dt><dt><span class="sect1"><a href="ch04s02.html">4.2. Graphing the number of sun spots during the 19th Century</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch04s02.html#id2496944">4.2.1. The historic data</a></span></dt><dt><span class="sect2"><a href="ch04s02.html#sec.preparing-sunspots-data">4.2.2. Preparing the data</a></span></dt><dt><span class="sect2"><a href="ch04s02.html#id2498157">4.2.3. A basic line graph</a></span></dt><dt><span class="sect2"><a href="ch04s02.html#id2516422">4.2.4. A basic bar graph</a></span></dt></dl></dd></dl></div><p><b>What you will learn in this chapter. </b>This chapter will illustrate how a basic line and bar graph can be created and it
will also show how input data should be prepared so it can be read and used by the
library.</p><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2496900"></a>4.1. Some words of caution</h2></div></div></div><p>In order to quickly show a very first example we will create both a basic line
graph and a basic bar graph that depicts the number of sun spots (a.k.a. solar
flares) during the 19th century. The goal of this example is not to show every
possible configuration and parameter supported by the library but rather show how
simple it is to create a basic graph.</p><p>In the sections following this one we will describe more in details the
idiosyncrasies about dynamic graph generation and JpGraph so even if you don't fully
understand all the detail it will give a flavor of what is to come. As with all
complex libraries one has to start somewhere and sometimes accept some practices
without yet fully understand them. However, the goal of this manual is that after
reading it through you will fully understand every single detail shown in this
script.</p><p>So, without further due, let's start.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="pt02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="pt02.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch04s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part II. Basic graph creation </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 4.2. Graphing the number of sun spots during the 19th Century</td></tr></table></div></body></html>

View File

@ -0,0 +1,451 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>4.2. Graphing the number of sun spots during the 19th Century</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch04.html" title="Chapter 4. Your first graph script"><link rel="prev" href="ch04.html" title="Chapter 4. Your first graph script"><link rel="next" href="ch05.html" title="Chapter 5. Fundamentals of dynamic graph generation"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">4.2. Graphing the number of sun spots during the 19th Century</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch04.html">Prev</a> </td><th width="60%" align="center">Chapter 4. Your first graph script</th><td width="20%" align="right"> <a accesskey="n" href="ch05.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec1.graphing-sun-spots"></a>4.2. Graphing the number of sun spots during the 19th Century</h2></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2496944"></a>4.2.1. The historic data</h3></div></div></div><p>It is a well known fact that sun spots have a certain pattern and regularity.
The cause of these regular patterns are not currently fully understood (even
though investigation into this phenomenon has been made since beginning of the
17:th century). The fact that solar storms affects the earth in terms of
interference with radio traffic and other sensitive electronic devices makes it
very interesting to keep careful records of the suns activities.</p><p>For this reason the data of solar storm is readily available and makes an
interesting first example. The data used here is taken from SIDC (The Solar
Influences Data Analysis Center) in Belgium (<code class="uri"><a class="uri" href="http://sidc.oma.be/sunspot-data/SIDCpub.php" target="_top">http://sidc.oma.be/sunspot-data/SIDCpub.php</a></code>).
In this example we will use the summary historical data that shows the total
number of sun spots per year since 1700.. </p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sec.preparing-sunspots-data"></a>4.2.2. Preparing the data</h3></div></div></div><p>The first step is to get the data into our PHP script which makes for a first
good discussion since all graphs needs to get data from some source. The library
itself is agnostic in regards to from where the data is collected and only needs
(and requires) data stored in a PHP array of numbers (integers or floats). </p><p>In principle the data to be plotted in the graph can come from :</p><p>
</p><div class="orderedlist"><ol type="1"><li><p>Hard-coded data in the script. This is the least flexible and can
only really be recommended for examples and really static
data.</p></li><li><p>Data stored in plain text files. (This is what we will use in this
example.)</p></li><li><p>Data stored in binary format in flat files. </p></li><li><p>Data stored in a database</p></li><li><p>Data sent to the script via URI parameter passing (either GET or
POST HTTP constructs can be used).</p></li></ol></div><p>
</p><p>What is common among all these methods is that the creator of the script has
to read the data into one (or several) data arrays that can be used by the
library. For our example the data of sunspots are stored in a plain text file in
two columns, one column for the year (with a ".5" added which indicates the
average of the year) and one column for the number of sunspots for the
corresponding year. As illustration the first 10 lines of data is shown in <a class="xref" href="ch04s02.html#fig.first-ten-sunspot" title="Figure 4.1. The first ten rows of data of sunspot activities from year 1700">Figure 4.1</a>.</p><p>
</p><div class="figure"><a name="fig.first-ten-sunspot"></a><p class="title"><b>Figure 4.1. The first ten rows of data of sunspot activities from year
1700</b></p><div class="figure-contents"><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-code">1700.5 5.0
1701.5 11.0
1702.5 16.0
1703.5 23.0
1704.5 36.0
1705.5 58.0
1706.5 29.0
1707.5 20.0
1708.5 10.0
1709.5 8.0</span></pre></td></tr></table></div></div></div><p><br class="figure-break">
</p><p>From this data we need to create two arrays, one with the number of sunspots
and one with the corresponding years. If we assume that the data is stored in a
text file named "<code class="filename">yearssn.txt</code>" in the same directory as the
script file the function in <a class="xref" href="ch04s02.html#fig.getsunspots" title="Figure 4.2. Reading numeric tabulated sunspot data from a file">Figure 4.2</a>will read the data into two arrays</p><p>
</p><div class="figure"><a name="fig.getsunspots"></a><p class="title"><b>Figure 4.2. Reading numeric tabulated sunspot data from a file</b></p><div class="figure-contents"><a name="pl.getsunspots"></a><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-reserved">function</span><span class="hl-code"> </span><span class="hl-identifier">readsunspotdata</span><span class="hl-brackets">(</span><span class="hl-var">$aFile</span><span class="hl-code">, &amp;</span><span class="hl-var">$aYears</span><span class="hl-code">, &amp;</span><span class="hl-var">$aSunspots</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">
</span><span class="hl-var">$lines</span><span class="hl-code"> = @</span><span class="hl-identifier">file</span><span class="hl-brackets">(</span><span class="hl-var">$aFile</span><span class="hl-code">,</span><span class="hl-identifier">FILE_IGNORE_NEW_LINES</span><span class="hl-code">|</span><span class="hl-identifier">FILE_SKIP_EMPTY_LINES</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-reserved">if</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-var">$lines</span><span class="hl-code"> === </span><span class="hl-reserved">false</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">
</span><span class="hl-reserved">throw</span><span class="hl-code"> </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">JpGraphException</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Can not read sunspot data file.</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-brackets">}</span><span class="hl-code">
</span><span class="hl-reserved">foreach</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-var">$lines</span><span class="hl-code"> </span><span class="hl-reserved">as</span><span class="hl-code"> </span><span class="hl-var">$line</span><span class="hl-code"> =&gt; </span><span class="hl-var">$datarow</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">
</span><span class="hl-var">$split</span><span class="hl-code"> = </span><span class="hl-identifier">preg_split</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">/[\s]+/</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-var">$datarow</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$aYears</span><span class="hl-brackets">[</span><span class="hl-brackets">]</span><span class="hl-code"> = </span><span class="hl-identifier">substr</span><span class="hl-brackets">(</span><span class="hl-identifier">trim</span><span class="hl-brackets">(</span><span class="hl-var">$split</span><span class="hl-brackets">[</span><span class="hl-number">0</span><span class="hl-brackets">]</span><span class="hl-brackets">)</span><span class="hl-code">,</span><span class="hl-number">0</span><span class="hl-code">,</span><span class="hl-number">4</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$aSunspots</span><span class="hl-brackets">[</span><span class="hl-brackets">]</span><span class="hl-code"> = </span><span class="hl-identifier">trim</span><span class="hl-brackets">(</span><span class="hl-var">$split</span><span class="hl-brackets">[</span><span class="hl-number">1</span><span class="hl-brackets">]</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-brackets">}</span><span class="hl-code">
</span><span class="hl-brackets">}</span><span class="hl-code">
</span><span class="hl-var">$year</span><span class="hl-code"> = </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$ydata</span><span class="hl-code"> = </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-identifier">readsunspotdata</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">yearssn.txt</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-var">$year</span><span class="hl-code">,</span><span class="hl-var">$ydata</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div></div></div><p><br class="figure-break">
</p><p>In the function above we have deviated from the common practice of not
including even the most basic error handling in examples by adding an exception
in case the data file could not be read. This is to emphasize that graph scripts
which reads data from potentially disconnected sources must have real quality
error and exception handling. As this is the first example we will not discuss
the details of the error handling other than saying that the library provides
one exception class <code class="code">JpGraphException</code> that is meant to be used by
clients to signal unrecoverable errors in the code. The full details on error
handling in the library is discussed in <a class="xref" href="ch06.html" title="Chapter 6. Error handling">Chapter 6</a></p><p>
</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3><p>In the library there is an auxiliary utility class
<code class="code">ReadFileData</code> to help read data from text files. In this
class there are methods to read data from a file in either of the
following formats</p><p>
</p><div class="itemizedlist"><ul type="disc"><li><p> CSV (Comma Separated Values) format.
<code class="code">ReadFileData::FromCSV()</code></p></li><li><p>two column format (almost) as we did manually above with
<code class="code">ReadFileData::From2Col()</code></p></li><li><p>one column format
<code class="code">ReadFileData::From1Col()</code></p></li></ul></div><p>
</p></div><p>
</p><p>Armed with the data in the two arrays <code class="code">$year</code> and
<code class="code">$ydata</code> we will now plot the data in a basic line graph with
some variations and then show the data in a bar graph.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2498157"></a>4.2.3. A basic line graph</h3></div></div></div><p>As the very first start we will create a line graph which shows sun spots as a
line graph. To keep the code focused on the graph we do not include the previous
function to read the data again in the code snippet shown below. Before we get
into the code we start by briefly discuss how your script can include the
necessary library files.</p><p>All graph scripts must include at least two files,
<code class="filename">jpgraph.php</code> and some plot module. If we want to create
a line plot we must include <code class="filename">jpgraph_line.php</code>. Slightly
depending on the server setup and what paths are defined for PHP include files
(as discussed in <a class="xref" href="ch03s03.html#sec2.adjusting-php-include-path" title="3.3.3. Adjusting PHP include path">Section 3.3.3</a>) the include paths for the
library might look a bit different. However, we recommend that you install the
library files so they can be accessed, for example using,
<code class="code">require_once('jpgraph/jpgraph.php')</code> (since this is what is
assumed by the library examples). Furthermore, we would recommend that the
<code class="code">require_once()</code> construct is used to avoid including the same
file multiple times.</p><p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Width and height of the graph</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$width</span><span class="hl-code"> = </span><span class="hl-number">600</span><span class="hl-code">; </span><span class="hl-var">$height</span><span class="hl-code"> = </span><span class="hl-number">200</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Create a graph instance</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">Graph</span><span class="hl-brackets">(</span><span class="hl-var">$width</span><span class="hl-code">,</span><span class="hl-var">$height</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Specify what scale we want to use,</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> int = integer scale for the X-axis</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> int = integer scale for the Y-axis</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetScale</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">intint</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Setup a title for the graph</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">title</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Set</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Sunspot example</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Setup titles and X-axis labels</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">xaxis</span><span class="hl-code">-&gt;</span><span class="hl-identifier">title</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Set</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">(year from 1701)</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Setup Y-axis title</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">yaxis</span><span class="hl-code">-&gt;</span><span class="hl-identifier">title</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Set</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">(# sunspots)</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Create the linear plot</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$lineplot</span><span class="hl-code">=</span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">LinePlot</span><span class="hl-brackets">(</span><span class="hl-var">$ydata</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Add the plot to the graph</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Add</span><span class="hl-brackets">(</span><span class="hl-var">$lineplot</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Display the graph</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
</p><p>Before we explain this code in some more detail it is a good idea to visualize
what we get when we execute this as script. The result of running this script is
shown in <a class="xref" href="ch04s02.html#fig.sunspotsex1" title="Figure 4.3. Line plot showing the number of sun spots since 1700 (sunspotsex1.php)">Figure 4.3</a></p><p>
</p><div class="figure"><a name="fig.sunspotsex1"></a><p class="title"><b>Figure 4.3. Line plot showing the number of sun spots since 1700 <code class="uri"><a class="uri" href="example_src/sunspotsex1.html" target="_top">(<code class="filename">sunspotsex1.php</code>)</a></code> </b></p><div class="figure-contents"><span class="inlinemediaobject"><img src="images/sunspotsex1.png" alt="Line plot showing the number of sun spots since 1700 (sunspotsex1.php)"></span></div></div><p><br class="figure-break">
</p><p>
</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3><p>You can always click on the filename in the title of a figure to view
the complete source code.</p></div><p>
</p><p>Let us now walk through this code in some details.</p><p>
</p><div class="variablelist"><dl><dt><span class="term">Line 1-12</span></dt><dd><p>The size of the graph must always be specified so the first
thing to do is to create a new graph object and set the width
and height of the overall graph. All graph scripts will need to
create at least one instance of the <code class="code">Graph()</code> class.
By convention in all our scripts we will name the created
instance of the Graph class "<code class="code">$graph</code>"..</p><p>The second thing that all graph scripts must specify is what
kind of scales should be used. The library supports linear,
integer, logarithmic, text and date scales. Since we know that
our data consist of only integers we keep things simple and set
both the X and the Y axis scale to be integers. The scale is
specified as a string where the first half of the string
denominates the X-axis scale and the second half denominates the
Y-axis scale. So in our example we specify
'<code class="code">intint'</code>. With this explanation you can probably
guess what '<code class="code">intlog</code>' or '<code class="code">linlog</code>' would
do. Why not try it ?</p></dd><dt><span class="term">Line 13-21</span></dt><dd><p>These lines sets some different text labels. By the naming
convention used in the library you can probably guess what all
those lines are doing. They set the overall graph title as well
as the X- and Y-axis titles. To keep the example as lean as
possible we use the default font and default size and color of
the text strings.</p></dd><dt><span class="term">Line 22-27</span></dt><dd><p>Each graph must have at least one plot (data series) that is
added to the graph. In our case we wanted to create a line graph
so we must create an instance of the class
'<code class="code">LinePlot</code>'. We create a new instance of this
class and as a parameter use the data for the data series we
want to create the line plot from, in our case the data array
with the sun spot numbers.</p></dd><dt><span class="term">Line 29</span></dt><dd><p>Understanding this single line is key to understanding dynamic
graph generation with PHP. This line instructs the library to
actually create the graph as an image, encode it in the chosen
image format (e.g. png, jpg, gif, etc) and stream it back to the
browser with the correct header identifying the data stream that
the client receives as a valid image stream. When the client
(most often a browser) calls the PHP script it will return data
that will make the browser think it is receiving an image and
not, as you might have done up to now from PHP scripts, text. </p><p>This is something that can be conceptually difficult to fully
understand at first and that is why we are spending the entire
next chapter <a class="xref" href="ch05.html" title="Chapter 5. Fundamentals of dynamic graph generation">Chapter 5</a> on further exploring
this. But for now please accept that this works and by calling
the script above in your browser (it is available in the
"<code class="filename">Examples/</code>" directory in the
distribution as '<code class="filename">sunspotsex1.php</code>') you
should get the exact same image as shown above in <a class="xref" href="ch04s02.html#fig.sunspotsex1" title="Figure 4.3. Line plot showing the number of sun spots since 1700 (sunspotsex1.php)">Figure 4.3</a></p></dd></dl></div><p>
</p><p>Let's now make a small variation of the above line graph. Let's make it a
filled line graph. instead. In order to do this we only have to add one single
line</p><p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-var">$lineplot</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetFillColor</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">orange@0.5</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
</p><p>The line above actually does two things. First it sets the basic color to
'orange' and then it modifies this color to be 50% opaque (0.5) which makes the
grid line shine through the fill color to some extent. The whole color handling
in the library is further describe both in <a class="xref" href="apd.html" title="Appendix D. Named color list">Appendix D</a> as well as in <a class="xref" href="ch07.html" title="Chapter 7. Color handling">Chapter 7</a>. The result of adding the line above is
shown in <a class="xref" href="ch04s02.html#fig.sunspotsex2" title="Figure 4.4. Displaying sun spots with a semi filled line graph (sunspotsex2.php)">Figure 4.4</a></p><p>
</p><div class="figure"><a name="fig.sunspotsex2"></a><p class="title"><b>Figure 4.4. Displaying sun spots with a semi filled line graph <code class="uri"><a class="uri" href="example_src/sunspotsex2.html" target="_top">(<code class="filename">sunspotsex2.php</code>)</a></code> </b></p><div class="figure-contents"><span class="inlinemediaobject"><img src="images/sunspotsex2.png" alt="Displaying sun spots with a semi filled line graph (sunspotsex2.php)"></span></div></div><p><br class="figure-break">
</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2516032"></a>Adding tick labels to the X-axis</h4></div></div></div><p>
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This section can be skipped at first reading since it contains
some slightly more advanced material. The reason why we have
included this section already now is that some of the issues
discussed here is an often repeated question among newcomers to the
library.</p></div><p>
</p><p>There is one bit of the available data that we haven't used yet and that
is the actual years. In the example above we can only see the count from
1700. (If we just want to look at the cyclic behaviour of the number of
sunspots this is fine since what year a specific number of sunspots appeared
is not relevant.) To make it easier to see what year corresponds to the
different sunspot numbers we must change the label on the X-axis scale to
show the years instead.</p><p>There is actually a couple of ways to do this. The easiest way is to just
add the labels we have (<code class="code">$years</code>) on the X-axis and instruct the
library to use them instead. This is done with a call to the method
<code class="code">SetTickLabels()</code> on the X-axis. This method call takes an
array as argument and uses the values in that array to populate all labels
on major tick marks. In order to make adequate room for the scale the
library automatically selects a suitable distance between each major tick
mark.</p><p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">xaxis</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetTickLabels</span><span class="hl-brackets">(</span><span class="hl-var">$year</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
</p><p>Adding this line to our previous graph will generate the graph shown in <a class="xref" href="ch04s02.html#fig.sunspotsex3" title="Figure 4.5. Adding tick labels to the graph (sunspotsex3.php)">Figure 4.5</a></p><p>
</p><div class="figure"><a name="fig.sunspotsex3"></a><p class="title"><b>Figure 4.5. Adding tick labels to the graph <code class="uri"><a class="uri" href="example_src/sunspotsex3.html" target="_top">(<code class="filename">sunspotsex3.php</code>)</a></code> </b></p><div class="figure-contents"><span class="inlinemediaobject"><img src="images/sunspotsex3.png" alt="Adding tick labels to the graph (sunspotsex3.php)"></span></div></div><p><br class="figure-break">
</p><p>However, there is a problem in the graph above. There are valid years on
the X-axis up to "2000" but then there is a single label "320". </p><p><span class="bold"><strong>What is going on here?</strong></span> Have we already discovered
a bug in the library? </p><p>No, not really. In the way we have setup the graph we have not provided
the library with enough labels. What has happened is that the integer scale
has chosen a suitable interval between each tick label to have enough space
to be able to show the labels. As can be seen from the figure the distance
chosen with this particular graph seems to be 20 years between each tick.
The way the default labeling works is that the end tick should be labelled
and hence be an even multiple of 20 years (in this case).</p><p>Since the library needs to have tick labels for all ticks it uses the
labels we supplied as far as they go (up to 2008) but since we didn't supply
data more than up to "2008" (in the <code class="code">$year</code> array) the library
does what it can do and continues with the ordinal numbers where we failed
to provide enough labels.</p><p>Now, there are a some standard ways of correcting this abomination.</p><p>
</p><div class="orderedlist"><ol type="1"><li><p>We can set a manual scale to make sure the scale ends exactly
at 2008, i.e. the scale is exactly as long as our data. This is
done by submitting the wanted scale min/max as additional
argument in the <code class="code">SetScale()</code> method. First the
min/max for the Y-axis and then the min/max for the X-scale.
Since we still want the Y-scale to be fully automatically
determined we just put a "0" for both min and max on the Y-scale
and specify 0 for the min x-value and then the exact number of
sunspots we have measured as the maximum x-value.</p><p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetScale</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">intint</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-number">0</span><span class="hl-code">,</span><span class="hl-number">0</span><span class="hl-code">,</span><span class="hl-number">0</span><span class="hl-code">,</span><span class="hl-identifier">max</span><span class="hl-brackets">(</span><span class="hl-var">$year</span><span class="hl-brackets">)</span><span class="hl-code">-</span><span class="hl-identifier">min</span><span class="hl-brackets">(</span><span class="hl-var">$year</span><span class="hl-brackets">)</span><span class="hl-code">+</span><span class="hl-number">1</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
</p><p>The result of this is shown in <a class="xref" href="ch04s02.html#fig.sunspotsex4" title="Figure 4.6. Manually specifying the X scale to use just the supplied X values (sunspotsex4.php)">Figure 4.6</a></p><p>
</p><div class="figure"><a name="fig.sunspotsex4"></a><p class="title"><b>Figure 4.6. Manually specifying the X scale to use just the supplied X values <code class="uri"><a class="uri" href="example_src/sunspotsex4.html" target="_top">(<code class="filename">sunspotsex4.php</code>)</a></code> </b></p><div class="figure-contents"><span class="inlinemediaobject"><img src="images/sunspotsex4.png" alt="Manually specifying the X scale to use just the supplied X values (sunspotsex4.php)"></span></div></div><p><br class="figure-break">
</p></li><li><p>An alternative way to get labels is to use a callback function
to specify the labels. This works so that the library calls the
user specified function and as argument passes the label (or the
value of the label) that the library intends to put on a tick.
The library will then use as the actual label whatever string
value we return from our function. Since we know that the
integer label 0 (the first tick) corresponds to the first value,
i.e. "1700" we can simply take whatever label we get as
argument, add "1700" and return that value. This way all labels
will be properly named and even if the scale extends far beyond
where we have data a sensible tick label will be shown.</p><p>A suitable callback function together with the method to
instruct the library to use this callback would be</p><p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> ...</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Label callback</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">function</span><span class="hl-code"> </span><span class="hl-identifier">year_callback</span><span class="hl-brackets">(</span><span class="hl-var">$aLabel</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">
</span><span class="hl-reserved">return</span><span class="hl-code"> </span><span class="hl-number">1700</span><span class="hl-code">+</span><span class="hl-brackets">(</span><span class="hl-identifier">int</span><span class="hl-brackets">)</span><span class="hl-var">$aLabel</span><span class="hl-code">;
</span><span class="hl-brackets">}</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> ...</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">xaxis</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetLabelFormatCallback</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">year_callback</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> ...</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
</p><p>and the result can be seen in <a class="xref" href="ch04s02.html#fig.sunspotsex5" title="Figure 4.7. Using a callback to get correct values on the x axis (sunspotsex5.php)">Figure 4.7</a></p><p>
</p><div class="figure"><a name="fig.sunspotsex5"></a><p class="title"><b>Figure 4.7. Using a callback to get correct values on the x axis <code class="uri"><a class="uri" href="example_src/sunspotsex5.html" target="_top">(<code class="filename">sunspotsex5.php</code>)</a></code> </b></p><div class="figure-contents"><span class="inlinemediaobject"><img src="images/sunspotsex5.png" alt="Using a callback to get correct values on the x axis (sunspotsex5.php)"></span></div></div><p><br class="figure-break">
</p></li><li><p>There is one more way to handle this issue which we will not
cover in detail yet. This is to use a "text" scale. The
"text"scale can be used when there is no need to show numeric
values on the axis. A typical use for text scale would be to add
labels to mark bar graphs. Of course a text can contain numeric
strings that would make it visually indistinguishable from a
"real" numeric value.</p><p>For text scales every label counts. So by default the library
will assign a tick mark for each ordinal so that every label is
used. In some cases this will just be two dense and then the
tick and the labelling can be adjusted by calling the two
methods <code class="code">Axis::SetTextTickInterval()</code> and
<code class="code">Axis::SetTextLabelInterval()</code> to get to a wanted
result. But for now we do not discuss this technique further
here since it would bring too far.</p></li></ol></div><p>
</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2516422"></a>4.2.4. A basic bar graph</h3></div></div></div><p>As a final illustration we will show how easy it is to change the plot type.
We will make a small modification of the previous script and display the sun
spots as a bar graph instead. In order to do this we take the code from <a class="xref" href="ch04s02.html#fig.sunspotsex2" title="Figure 4.4. Displaying sun spots with a semi filled line graph (sunspotsex2.php)">Figure 4.4</a> and just change the creation of an instance
of the <code class="code">LinePlot()</code> class to instead be an instance of the
<code class="code">BarPlot()</code> class (to make the code more readable we also change
the name of the variable where we store the instance so it makes more sense). In
order to use this class we must also change the include statement so that the
bar module is included by adding the statement
<code class="code">require_once('jpgraph/jpgraph_barplot.php')</code>. The changed code
would now look like this</p><p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> ...</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Create the bar plot</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$barplot</span><span class="hl-code">=</span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">BarPlot</span><span class="hl-brackets">(</span><span class="hl-var">$ydata</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Add the plot to the graph</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Add</span><span class="hl-brackets">(</span><span class="hl-var">$barplot</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Display the graph</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
</p><p>and would result in the graph displayed in <a class="xref" href="ch04s02.html#fig.sunspotsex6" title="Figure 4.8. Changing the plot type to a bar plot instead (sunspotsex6.php)">Figure 4.8</a></p><p>
</p><div class="figure"><a name="fig.sunspotsex6"></a><p class="title"><b>Figure 4.8. Changing the plot type to a bar plot instead <code class="uri"><a class="uri" href="example_src/sunspotsex6.html" target="_top">(<code class="filename">sunspotsex6.php</code>)</a></code> </b></p><div class="figure-contents"><span class="inlinemediaobject"><img src="images/sunspotsex6.png" alt="Changing the plot type to a bar plot instead (sunspotsex6.php)"></span></div></div><p><br class="figure-break">
</p><p>Since there are so many bars in small space we cannot see the individual bars
in the example in <a class="xref" href="ch04s02.html#fig.sunspotsex6" title="Figure 4.8. Changing the plot type to a bar plot instead (sunspotsex6.php)">Figure 4.8</a>. So lets modify the script so that it only
shows the last 20 years of measurements so that we can see the individual bars.
To set this up there are two things we must do</p><p>
</p><div class="orderedlist"><ol type="1"><li><p>Change the scale ot a text scale since we want to make sure each
value is displayed. In addition the text scale actually changes one
more thing that we haven't mentioned. Using a text scale also
changes the alignment of the labels. For linear, integer,
logarithmic scales the labels are placed cantered below the tick
marks. For text labels they are instead place in between the tick
marks. This is the most common way of displaying bar graphs. This is
one more reason to think of text scales as a special scale mostly
suitable for bar graphs.</p></li><li><p>Add two lines of code to "chop off" the extra not wanted data in
the input data arrays.</p></li></ol></div><p>
</p><p>The following code snippet shows the necessary modifications to the previous
script</p><p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Just keep the last 20 values in the arrays</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$year</span><span class="hl-code"> = </span><span class="hl-identifier">array_slice</span><span class="hl-brackets">(</span><span class="hl-var">$year</span><span class="hl-code">, -</span><span class="hl-number">20</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$ydata</span><span class="hl-code"> = </span><span class="hl-identifier">array_slice</span><span class="hl-brackets">(</span><span class="hl-var">$ydata</span><span class="hl-code">, -</span><span class="hl-number">20</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> ...</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Specify what scale we want to use,</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> text = txt scale for the X-axis</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> int = integer scale for the Y-axis</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">SetScale</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">textint</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> ...</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
</p><p>The final graph with the "zoomed" last 20 years can now be seen in</p><p>
</p><div class="figure"><a name="fig.sunspotsex7"></a><p class="title"><b>Figure 4.9. Sunspots zoomed to only show the last 20 years <code class="uri"><a class="uri" href="example_src/sunspotsex7.html" target="_top">(<code class="filename">sunspotsex7.php</code>)</a></code> </b></p><div class="figure-contents"><span class="inlinemediaobject"><img src="images/sunspotsex7.png" alt="Sunspots zoomed to only show the last 20 years (sunspotsex7.php)"></span></div></div><p><br class="figure-break">
</p><p>Since the scale is larger we can now actually see the individual bars. By
default the library choses a light blue color to fill the interior. (Try to see
what happens if you add the method call
"<code class="code">$barplot-&gt;SetFillColor('orange@0.5');</code>" just after the
"<code class="code">$barplot</code>" variable has been assigned the new BarPlot
object.)</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch04.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch04.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch05.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 4. Your first graph script </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 5. Fundamentals of dynamic graph generation</td></tr></table></div></body></html>

View File

@ -0,0 +1,29 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Chapter 5. Fundamentals of dynamic graph generation</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="pt02.html" title="Part II. Basic graph creation"><link rel="prev" href="ch04s02.html" title="4.2. Graphing the number of sun spots during the 19th Century"><link rel="next" href="ch05s02.html" title="5.2. What is an image?"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 5. Fundamentals of dynamic graph generation</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch04s02.html">Prev</a> </td><th width="60%" align="center">Part II. Basic graph creation</th><td width="20%" align="right"> <a accesskey="n" href="ch05s02.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="chap.fund-dynamic-graph"></a>Chapter 5. Fundamentals of dynamic graph generation</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ch05.html#sec1.making-sense-of-HTTP-streams">5.1. Making sense of HTTP streams and MIME types</a></span></dt><dt><span class="sect1"><a href="ch05s02.html">5.2. What is an image?</a></span></dt><dt><span class="sect1"><a href="ch05s03.html">5.3. Static vs dynamic images</a></span></dt><dt><span class="sect1"><a href="ch05s04.html">5.4. Dynamic images on the command line</a></span></dt><dt><span class="sect1"><a href="ch05s05.html">5.5. How to generate images with JpGraph library</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch05s05.html#id2517177">5.5.1. The standard steps of setting up a graph</a></span></dt><dt><span class="sect2"><a href="ch05s05.html#id2517378">5.5.2. Choosing the image compression format for JpGraph</a></span></dt><dt><span class="sect2"><a href="ch05s05.html#id2517477">5.5.3. Sending back the image to the browser</a></span></dt><dt><span class="sect2"><a href="ch05s05.html#sec2.writing-miage-to-file">5.5.4. Writing the image directly to a file</a></span></dt><dt><span class="sect2"><a href="ch05s05.html#id2517790">5.5.5. Alternatives to streaming or storing the image</a></span></dt><dt><span class="sect2"><a href="ch05s05.html#sec2.forcing-browser-update">5.5.6. Forcing the browser to update your graph</a></span></dt><dt><span class="sect2"><a href="ch05s05.html#id2517933">5.5.7. Printing the generated image</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch05s06.html">5.6. Efficient graph generation using the built-in cache subsystem</a></span></dt></dl></div><p><b>What you will learn in this chapter. </b>The purpose of this chapter is to put dynamic image generation in perspective and
illustrate how HTML tags is used to call image generating scripts. Even if You are
familiar with PHP it is strongly recommended to quickly browse through this chapter
to make sure all concepts are known. If You fully understand and can explain the
concept of MIME types, HTTP streams and why the "<span class="italic">Headers already sent error</span>" error is a very common
error when generating dynamic images with PHP it is probably safe to skip this
chapter. Otherwise it might be wise to read through this chapter at least
once.</p><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec1.making-sense-of-HTTP-streams"></a>5.1. Making sense of HTTP streams and MIME types</h2></div></div></div><p>The following explanation is slightly simplified since a full description of the
HTTP protocol would bring us a bit too far in this manual </p><div class="orderedlist"><ol type="1"><li><p>A client (e.g. browser) requests data from the server by issuing a GET
(or possible a POST) command to the server. This is what happens when
you enter a URI in the address bar in the browser.</p></li><li><p>The server replies with a data stream (or an error if the requested
data wasn't available). This data stream is prepended with header (MIME
header) that tells the client (e.g. the browser) how to interpret the
data that follows. The most common type (and the default type if no
header is sent by a faulty server) is "<span class="bold"><strong>text/html</strong></span>" . This tells the client to
interpret the data as plain text with embedded HTML encoding. </p><p>When the data is to be interpreted as an image the header will instead
be one of the image headers, for example "<span class="bold"><strong>image/png</strong></span>" or "<span class="bold"><strong>image/jpeg</strong></span>". When the client receives this
header it will interpret all the following data as an image encoded in
the indicated format. </p><p>The important thing to keep in mind here is that each server reply
(initiated by a call from the client) can only have one and only one
MIME type. This is the key to further understanding the specific issues
with dynamic image generation. This explains why if a PHP script running
on the server sends a header first indicating that the following data it
sends should be interpreted by the client as an image it cannot also
include text since only one header can be used for one HTTP stream.
</p></li></ol></div><p>What happens on a WEB-page with, for example, multiple <span class="markup">&lt;img&gt;</span>
tags is that the browser issues a separate GET command for each of these images. So
even though it can look like a fetching a single WEB-page can have different content
each individual request to the server only have one single MIME type.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch04s02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="pt02.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch05s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">4.2. Graphing the number of sun spots during the 19th Century </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 5.2. What is an image?</td></tr></table></div></body></html>

View File

@ -0,0 +1,38 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>5.2. What is an image?</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch05.html" title="Chapter 5. Fundamentals of dynamic graph generation"><link rel="prev" href="ch05.html" title="Chapter 5. Fundamentals of dynamic graph generation"><link rel="next" href="ch05s03.html" title="5.3. Static vs dynamic images"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5.2. What is an image?</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch05.html">Prev</a> </td><th width="60%" align="center">Chapter 5. Fundamentals of dynamic graph generation</th><td width="20%" align="right"> <a accesskey="n" href="ch05s03.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2516797"></a>5.2. What is an image?</h2></div></div></div><p>This might be strange question and you might already now the answer but having a
true understanding will help. An image is simply a data stream of octets (bytes)
specifying the exact color of a number of pixels. A typical image uses 32 bits to
specify the color which means it can encode 2^32 different colors (Homework: How
many gray levels is possible with 32 bits?). It would be perfectly possible to send
this data stream as it is and indeed this is how the bitmap (BMP) format specifies
the data. However, image data usually have a lot of redundancies that can be used to
reduce the size of the data that needs to be transmitted to specify any given image.
These compression formats are what is more commonly known as for example PNG, JPEG
or GIF type of images. So it is actually more correct, in our view, to look upon
these formats as different compression techniques rather than as true image formats. </p><p>Contrary to popular belief it is not the suffix on a file per se that identifies a
particular file as an image on a HTTP server but rather the mapping on the server
that instructs the server to send back a particular header for a particular file
type (as identified by the file suffix), the MIME type. This might not seem like an
important distinction to make but keeping this in mind will help understanding how
images are created with a PHP script.</p><p>A normal PHP scripts sends back character data (or more likely HTML encoded
character data) that is displayed by the browser. However it is nothing that stops
the PHP script from sending back data that instead should be interpreted as an image
assuming of course we know how to create such data.. </p><p>How the client (i.e. the browser) should interpret the data sent is all controlled
by the header that is sent before the data. So this now leads us to the idea that if
our PHP script by some means constructs a valid image, compressed in a known format
(say PNG), we can tell the client to interpret the data we send back as an image by
just making sure we first send a header indicating that the data is an image.</p><p>This could now lead us to the perhaps surprising but crucial insight that if we
call our script that sends back valid image data "<code class="filename">myimage.php</code>"
and open it in a browser, for example by opening the local URI
"<code class="filename">http://localhost/myimage.php</code>" for the browser this is no
different then opening an image directly (for example
"<code class="filename">http://localhost/myimage.png</code>") </p><p>The only difference is that in the first case (our PHP script) we create the
header and data our self and in the second case the HTTP server looks up the file
suffix (*.png) to find out what kind of header to send before reading the file and
just passing on the data to the client.</p><p>Armed with this new knowledge we realize that our PHP script <span class="italic">is</span> an image for all practical purposes and intent from
a clients point of view. So we could safely name our PHP script as a target for an
<span class="markup">&lt;img&gt;</span> tag. This gives us the final and most common way to
call a graph script in a HTML page. </p><p><code class="code">&lt;img src="myimage.php"&gt;</code></p><p>in exactly the same way as we would do with the old type of images. The "*.php"
suffix is no problem since the client (e.g. the browser) don't care what the file
ending is. It only cares about what header the server returns. If that header tells
the browser that the data received should be interpreted as a PNG image it will do
so regardless of the name of the source file on the server.</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch05.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch05.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch05s03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 5. Fundamentals of dynamic graph generation </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 5.3. Static vs dynamic images</td></tr></table></div></body></html>

View File

@ -0,0 +1,18 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>5.3. Static vs dynamic images</title><link rel="stylesheet" href="manual.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.74.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch05.html" title="Chapter 5. Fundamentals of dynamic graph generation"><link rel="prev" href="ch05s02.html" title="5.2. What is an image?"><link rel="next" href="ch05s04.html" title="5.4. Dynamic images on the command line"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5.3. Static vs dynamic images</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch05s02.html">Prev</a> </td><th width="60%" align="center">Chapter 5. Fundamentals of dynamic graph generation</th><td width="20%" align="right"> <a accesskey="n" href="ch05s04.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2516926"></a>5.3. Static vs dynamic images</h2></div></div></div><p>Having understood how we can generate images using a PHP script a new idea might
be forming. There is nothing that says that we have to create the same image using
the same data every time the graph script is called. We could for example randomly
select a pre-stored image in a directory and every time we call (the same) graph
script and new image is returned. Hence, with PHP scripts we can create dynamic
images that generate different images depending on some yet to be specified
parameters even though the script name stays the same. This is a new behaviour
compared with our normal images. </p><p>This could also lead to a new, and very real, problem which has to do with the
local caching most browsers do in order to avoid re-fetching already fetched objects
such as images. Normally a browser will check the time stamp on the file on the
server and compare with the latest fetched version it has stored locally. If the
browser sees that the file on the server is older than what it already has it will
not re-fetch the file. </p><p>Since a dynamic image is produced by a script and the script will stay the same
even if the produced image is changing (due to new data) the browser might still
think that the image has not changed since the script is the same and will not
bother re-fetching it again. The exact behavior of the browser cache is usually
adjustable by the end user and hence out of control for us who writes the script. A
simple way to always force the client to re-fetch the dynamic image is described in <a class="xref" href="ch05s05.html#sec2.forcing-browser-update" title="5.5.6. Forcing the browser to update your graph">Section 5.5.6</a></p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch05s02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch05.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch05s04.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5.2. What is an image? </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 5.4. Dynamic images on the command line</td></tr></table></div></body></html>

Some files were not shown because too many files have changed in this diff Show More