From 86d9c9e82f10c2c89a58ed3785c6b00a1bf5bc85 Mon Sep 17 00:00:00 2001 From: hugetoad Date: Fri, 7 Jan 2005 22:43:03 +0000 Subject: Finished form for image management. git-svn-id: svn://svn.zabbix.com/trunk@1590 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- frontends/php/config.php | 11 ++++++++--- frontends/php/include/config.inc.php | 32 ++++++++++++++++++++++++++++++++ frontends/php/include/local_en.inc.php | 4 ++++ 3 files changed, 44 insertions(+), 3 deletions(-) (limited to 'frontends/php') diff --git a/frontends/php/config.php b/frontends/php/config.php index f4876d4e..86f62cf1 100644 --- a/frontends/php/config.php +++ b/frontends/php/config.php @@ -46,8 +46,8 @@ { if($_POST["register"]=="add image") { - $result=add_image($_POST["imageid"]); - show_messages($result, S_IMAGE_DELETED, S_CANNOT_DELETE_IMAGE); + $result=add_image($_POST["name"],$_POST["imagetype"],$_FILES); + show_messages($result, S_IMAGE_ADDED, S_CANNOT_ADD_IMAGE); if($result) { add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_ZABBIX_CONFIG,"Image deleted"); @@ -211,6 +211,7 @@ $row=DBfetch($result); $name=$row["name"]; $imagetype=$row["imagetype"]; + $imageid=$row["imageid"]; } $col=0; @@ -222,6 +223,10 @@ echo "
"; echo ""; echo ""; + if(isset($imageid)) + { + echo ""; + } echo nbsp(S_NAME); show_table2_h_delimiter(); echo ""; @@ -245,7 +250,7 @@ show_table2_v_delimiter($col++); echo S_UPLOAD; show_table2_h_delimiter(); - echo ""; + echo ""; show_table2_v_delimiter2(); echo ""; diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 1060655f..4aa07b0f 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -2354,6 +2354,38 @@ echo ""; } + function add_image($name,$imagetype,$files) + { + global $ERROR_MSG; + + if(isset($files)) + { + if($files["image"]["error"]==0) + if($files["image"]["size"]<1024*1024) + { + $image=addslashes(fread(fopen($files["image"]["tmp_name"],"r"),filesize($files["image"]["tmp_name"]))); + $sql="insert into images (name,imagetype,image) values ('$name',$imagetype,'$image')"; + return DBexecute($sql); + } + else + { + $ERROR_MSG="Image size must be less than 1Mb"; + return FALSE; + } + } + else + { + $ERROR_MSG="Select image to download"; + return FALSE; + } + } + + function delete_image($imageid) + { + $sql="delete from images where imageid=$imageid"; + return DBexecute($sql); + } + function add_service_link($servicedownid,$serviceupid,$softlink) { global $ERROR_MSG; diff --git a/frontends/php/include/local_en.inc.php b/frontends/php/include/local_en.inc.php index a3ae3ea4..4c2a3c89 100644 --- a/frontends/php/include/local_en.inc.php +++ b/frontends/php/include/local_en.inc.php @@ -172,6 +172,10 @@ define("S_NO_IMAGES_DEFINED", "No images defined"); define("S_BACKGROUND", "Background"); define("S_UPLOAD", "Upload"); + define("S_IMAGE_ADDED", "Image added"); + define("S_CANNOT_ADD_IMAGE", "Cannot add image"); + define("S_IMAGE_DELETED", "Image deleted"); + define("S_CANNOT_DELETE_IMAGE", "Cannot delete image"); // Latest values define("S_LATEST_VALUES", "Latest values"); -- cgit