From afe738490837fa1cbc41daaaf6754c2feb2be024 Mon Sep 17 00:00:00 2001 From: Harvie Date: Fri, 17 Dec 2010 13:29:57 +0100 Subject: [PATCH] Added define SYSTEM_IMAGES and using it to generate image URLs --- wwwroot/config/config_default.inc | 1 + wwwroot/inc/eventz/configure.inc | 4 ++-- wwwroot/inc/eventz/configure_image.inc | 2 +- wwwroot/inc/eventz/upload_data_file.inc | 4 ++-- .../inc/smarty/node_methodz/function.get_image_link.php | 8 ++++---- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/wwwroot/config/config_default.inc b/wwwroot/config/config_default.inc index 96e1021..98cea28 100644 --- a/wwwroot/config/config_default.inc +++ b/wwwroot/config/config_default.inc @@ -11,6 +11,7 @@ date_default_timezone_set('Europe/Prague'); define('SYSTEM_ROOT', '/srv/kyberia/'); define('SYSTEM_DATA', SYSTEM_ROOT . '/wwwroot/_data/'); +define('SYSTEM_IMAGES', '/_images/'); define('CONFIG_DIR', SYSTEM_ROOT . 'config/'); define('AJAX_DIR', SYSTEM_ROOT . 'wwwroot/ajax/'); define('INCLUDE_DIR', SYSTEM_ROOT . 'wwwroot/inc/'); diff --git a/wwwroot/inc/eventz/configure.inc b/wwwroot/inc/eventz/configure.inc index 756abc2..8479152 100644 --- a/wwwroot/inc/eventz/configure.inc +++ b/wwwroot/inc/eventz/configure.inc @@ -13,10 +13,10 @@ else $width=123; if (stristr($image_name,".jpg") || stristr($image_name,".jpeg") ){ - $cmd=UTILZ_DIR."/jpegtopnm $image |".UTILZ_DIR."/pnmscale -width=$width | ".UTILZ_DIR."ppmquant 256 |".UTILZ_DIR."ppmtogif >".SYSTEM_ROOT."images/nodes/".substr($node['node_id'],0,1)."/".substr($node['node_id'],1,1)."/".$node['node_id'].".gif"; + $cmd=UTILZ_DIR."/jpegtopnm $image |".UTILZ_DIR."/pnmscale -width=$width | ".UTILZ_DIR."ppmquant 256 |".UTILZ_DIR."ppmtogif >".SYSTEM_ROOT.SYSTEM_IMAGES.'/nodes/'.substr($node['node_id'],0,1)."/".substr($node['node_id'],1,1)."/".$node['node_id'].".gif"; } elseif (stristr($image_name,".gif")) { - $cmd=UTILZ_DIR."/gifsicle --resize ".$width."x_ $image > ".SYSTEM_ROOT."images/nodes/".substr($node['node_id'],0,1)."/".substr($node['node_id'],1,1)."/".$node['node_id'].".gif"; + $cmd=UTILZ_DIR."/gifsicle --resize ".$width."x_ $image > ".SYSTEM_ROOT.SYSTEM_IMAGES.'/nodes/'.substr($node['node_id'],0,1)."/".substr($node['node_id'],1,1)."/".$node['node_id'].".gif"; } if ($cmd) { shell_exec($cmd); diff --git a/wwwroot/inc/eventz/configure_image.inc b/wwwroot/inc/eventz/configure_image.inc index 4ac3d00..4e4bc5d 100644 --- a/wwwroot/inc/eventz/configure_image.inc +++ b/wwwroot/inc/eventz/configure_image.inc @@ -67,7 +67,7 @@ $_required_dims = ($node['node_id'] == $_SESSION['user_id'])?50:NODE_IMAGE_WIDTH; $_prepared_fname = sprintf('%s/prepared/%03s_%s.gif.upload', $_PROCESS_IMG_PATH, $_required_dims, $node['node_id']); - $_nodeimg_fname = sprintf('%s/images/nodes/%s/%s/%d.gif', $_WEBROOT_PATH, $node['node_id'][0], $node['node_id'][1], $node['node_id']); + $_nodeimg_fname = sprintf('%s/'.SYSTEM_IMAGES.'/nodes/%s/%s/%d.gif', $_WEBROOT_PATH, $node['node_id'][0], $node['node_id'][1], $node['node_id']); if (!is_uploaded_file($_FILES['description_image']['tmp_name'])) { $error = '#02: Invalid file upload'; diff --git a/wwwroot/inc/eventz/upload_data_file.inc b/wwwroot/inc/eventz/upload_data_file.inc index 070d758..09aa33e 100644 --- a/wwwroot/inc/eventz/upload_data_file.inc +++ b/wwwroot/inc/eventz/upload_data_file.inc @@ -70,10 +70,10 @@ function upload_data_file() { stristr($image_name,".jpeg") ){ /// XXX UTILZ_DIR is not set. remove? - $cmd=UTILZ_DIR."/jpegtopnm $image |".UTILZ_DIR."/pnmscale -width=$width | ".UTILZ_DIR."ppmquant 256 |".UTILZ_DIR."ppmtogif >".SYSTEM_ROOT."images/nodes/".substr($datanode_id,0,1)."/".substr($datanode_id,1,1)."/".$datanode_id.".gif"; + $cmd=UTILZ_DIR."/jpegtopnm $image |".UTILZ_DIR."/pnmscale -width=$width | ".UTILZ_DIR."ppmquant 256 |".UTILZ_DIR."ppmtogif >".SYSTEM_ROOT.SYSTEM_IMAGES.'/nodes/'.substr($datanode_id,0,1)."/".substr($datanode_id,1,1)."/".$datanode_id.".gif"; } elseif (stristr($image_name,".gif")) { - $cmd=UTILZ_DIR."/gifsicle --resize ".$width."x_ $image > ".SYSTEM_ROOT."images/nodes/".substr($datanode_id,0,1)."/".substr($datanode_id,1,1)."/".$datanode_id.".gif"; + $cmd=UTILZ_DIR."/gifsicle --resize ".$width."x_ $image > ".SYSTE_ROOT.SYSTEM_IMAGES.'/nodes/'.substr($datanode_id,0,1)."/".substr($datanode_id,1,1)."/".$datanode_id.".gif"; } if ($cmd) { shell_exec($cmd); diff --git a/wwwroot/inc/smarty/node_methodz/function.get_image_link.php b/wwwroot/inc/smarty/node_methodz/function.get_image_link.php index fe9a891..606e3d3 100644 --- a/wwwroot/inc/smarty/node_methodz/function.get_image_link.php +++ b/wwwroot/inc/smarty/node_methodz/function.get_image_link.php @@ -2,17 +2,17 @@ function smarty_function_get_image_link($params,&$smarty) { global $db; $id = $params['id']; - $img = SYSTEM_DATA."/images/nodes/".substr($id,0,1)."/".substr($id,1,1)."/$id.gif"; + $img = SYSTEM_DATA.SYSTEM_IMAGES.'/nodes/'.substr($id,0,1)."/".substr($id,1,1)."/$id.gif"; if (file_exists($img)) { - echo "/images/nodes/".substr($id,0,1)."/".substr($id,1,1)."/$id.gif"; + echo SYSTEM_IMAGES.'/nodes/'.substr($id,0,1)."/".substr($id,1,1)."/$id.gif"; } else { $set = $db->query("select user_id from users where user_id = $id"); if ($set->getNumRows() > 0) { - $imglink = "/images/nodes///.gif"; + $imglink = SYSTEM_IMAGES.'/nodes///.gif'; } else { - $imglink = "/images/nodes/1/0/101.gif"; + $imglink = SYSTEM_IMAGES.'/nodes/1/0/101.gif'; } echo $imglink; } -- 2.30.2