$myEnv["module"] = "general"; $myEnv["output"] = "html"; $myEnv['stdsmenu'] = false; //return; require_once ("../../config.inc.php"); require_once (SMARTY_DIR . "Smarty.class.php"); // definition of moregroupware class, holding application vars include (INCLUDEPATH . 'mgw.class.php'); // functions for translation include (INCLUDEPATH . 'lang.inc.php'); // array for tracking file revision number used in sql error report screen $Revisions_array = Array (); // important functions like connect to database include (INCLUDEPATH . 'userfunc.inc.php'); // definition of moregroupware version and label include (INCLUDEPATH . 'version.inc.php'); // Logging facilities include (INCLUDEPATH . 'log.inc.php'); // Notify include (INCLUDEPATH . 'notify.inc.php'); include (INCLUDEPATH . 'appconfig.inc.php'); print_r($_GET) ; //return; //$ID_company = $_GET["company_ID"]; $ID_person = $_GET["personal_ID"]; if (isset ($HTTP_POST_FILES["Filedata"]) && $ID_person > 0) { //template store image uploaded. $tmp_image = INCLUDEPATH . 'flar/ajax/flash_upload/files_data/'; //get dir, and name of image. $uploadname = $tmp_image . $HTTP_POST_FILES['Filedata']['name']; //Resize Image when Upload if (move_uploaded_file($HTTP_POST_FILES['Filedata']['tmp_name'], $uploadname)) { //source and destination stored image. $source_img = INCLUDEPATH . 'flar/ajax/flash_upload/files_data/' . $HTTP_POST_FILES['Filedata']['name']; $dest_img = ROOTPATH . '/modules/general/templates/'.THEME.'/media/flare/personalman/' . $HTTP_POST_FILES['Filedata']['name']; //get file normal info, include extension if (file_exists($source_img)) { $file_normal_parts = explode(".", $HTTP_POST_FILES['Filedata']['name']); //get string extension of file image. $format = substr(strrchr($source_img, "."), 1); switch ($format) { case 'png' : $type = "png"; $src_img = imagecreatefrompng($source_img); break; case 'jpg' : $type = "jpg"; $src_img = imagecreatefromjpeg($source_img); break; case 'jpeg' : $type = "jpg"; $src_img = imagecreatefromjpeg($source_img); break; case 'gif' : $type = "gif"; $src_img = imagecreatefromgif($source_img); break; default : break; } //get width and height of image list ($width, $height) = getimagesize($source_img); $max_width = 150; $max_height = 150; $x_ratio = $max_width / $width; $y_ratio = $max_height / $height; if (($width <= $max_width) && ($height <= $max_height)) { $tmp_width = $width; $tmp_height = $height; } elseif (($x_ratio * $height) < $max_height) { $tmp_height = ceil($x_ratio * $height); $tmp_width = $max_width; } else { $tmp_width = ceil($y_ratio * $width); $tmp_height = $max_height; } $tmp_image = imagecreatetruecolor($tmp_width, $tmp_height); $bSuccess = imagecopyresampled($tmp_image, $src_img, 0, 0, 0, 0, $tmp_width, $tmp_height, $width, $height); if ($type == "jpg") { imagejpeg($tmp_image, $dest_img, 100); } elseif ($type == "png") { imagepng($tmp_image, $dest_img, null, 100); } elseif ($type == "gif") { imagegif($tmp_image, $dest_img, null, 100); } imagedestroy($src_img); imagedestroy($tmp_image); //Update data to Database require_once ('DB/DataObject.php'); $config = parse_ini_file(INCLUDEPATH . 'flar/flar.ini', TRUE); foreach ($config as $class => $values) { $options = & PEAR :: getStaticProperty($class, 'options'); $options = $values; } // require_once (INCLUDEPATH . 'flar/Company.php'); // // $db_company = new Flar_Company(); // $db_company->query("SET NAMES 'utf8'"); // $row = $db_company->get((int) $ID_company); // $db_company->company_image = $HTTP_POST_FILES['Filedata']['name']; // if ($row) $db_company->update(); // $db_company->free(); require_once (INCLUDEPATH . 'flar/Res_personal.php'); $res_personal = new Flar_Res_personal(); $res_personal->query("SET NAMES 'utf8'"); $row2 = $res_personal->get((int) $ID_person); $res_personal->image = $HTTP_POST_FILES['Filedata']['name']; if ($row2) $res_personal->update(); $res_personal->free(); } } //Delete template image unlink($uploadname); // return "test ".(int)$bSuccess; } ?>