function returnAdaNodeIcon($icon, $type) { //$pathAr = explode(MEDIA_PATH_DEFAULT); //if(preg_match((explode(MEDIA_PATH_DEFAULT))),$icon) == 0 ) return "img/".returnAdaNodeType($type).".png"; $file_pathAR = explode("/", $icon); $num_el = count($file_pathAR); if ($num_el < 2) { return "img/" . returnAdaNodeType($type) . ".png"; } // it is a path to a file // if(preg_match("/services\/media/",$icon) == 0 ) return "img/".returnAdaNodeType($type).".png"; $iconAR = explode("/", $icon); // $len = count($iconAR); //$file_name = $iconAR[count($iconAR)-1]; // $file_thumb = 'thumb'.$file_name; $file_thumb = 'thumb_' . $iconAR[count($iconAR) - 1]; $iconAR[count($iconAR) - 1] = $file_thumb; $icon_thumb = implode("/", $iconAR); if (file_exists($icon_thumb)) { return ereg_replace(ROOT_DIR, HTTP_ROOT_DIR, $icon_thumb); } $id_img = new ImageDevice(); $new_icon = $id_img->resize_image($icon); imagejpeg($new_icon, $icon_thumb); if (file_exists($icon_thumb)) { return ereg_replace(ROOT_DIR, HTTP_ROOT_DIR, $icon_thumb); } else { return "img/" . returnAdaNodeType($type) . ".png"; } }
<?php $debug = 0; $ada_config_path = realpath(dirname(__FILE__) . '/..'); include_once "{$ada_config_path}/config_path.inc.php"; include_once "{$ada_config_path}/include/utilities.inc.php"; include_once "include/class_image.inc.php"; include_once "include/graph_map.inc.php"; //vito 2 feb 2009 //$encode_children = $_GET['ec']; $self = whoami(); $ID = new ImageDevice(); $type = $ID->imageDevice(); if (!is_array($type)) { print $type; } else { //print_r( $type); // vito, 27 apr 2009, commentare riga seguente in debug header("Content-type: image/" . $type[0]); // type element 1 contain gif or png. } session_start(); //session_register('sess_node_map'); //session_register('sess_user_level'); //session_register('sess_template'); $sess_user_level = $_SESSION['sess_user_level']; $sess_template = $_SESSION['sess_template']; $sess_node_map = $_SESSION['sess_node_map']; //print_r($_SESSION); $children_ha = $sess_node_map; // vito 2 feb 2009
function show_image_FN($im_dest) { $id_img = new ImageDevice(); if (empty($id_img->error)) { $id_img->ImageX($im_dest); } }
/** * Reduce image using GD * */ public function reduceImage() { require_once ROOT_DIR . '/browsing/include/class_image.inc.php'; $id_img = new ImageDevice(); $new_img = $id_img->resize_image($this->_tmpName, AVATAR_MAX_WIDTH, AVATAR_MAX_HEIGHT); if (stristr($this->_type, 'png')) { imagepng($new_img, $this->_tmpName); } if (stristr($this->_type, 'jpeg')) { imagejpeg($new_img, $this->_tmpName); } if (stristr($this->_type, 'gif')) { imagegif($new_img, $this->_tmpName); } // imagejpeg($new_img,$this->_tmpName); }
/** * callback method for addADA success handling, called by * parent::addADAUser just before redirecting * * This will download user avatar image to proper location * * @param ADALoggableUser $userObj * @param string $downloadURL * * @access public */ public function addADASuccessCallBack($userObj, $downloadURL, $avatar) { if (is_object($userObj) && $userObj instanceof ADALoggableUser) { if (!is_null($avatar) && !is_null($downloadURL)) { $destDir = ADA_UPLOAD_PATH . $userObj->getId(); if (!is_dir($destDir)) { mkdir($destDir); } $destFile = $destDir . DIRECTORY_SEPARATOR . $avatar; /** * save the image locally from the url */ $ch = curl_init($downloadURL); $fp = fopen($destFile, 'wb'); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); fclose($fp); /** * resize the image if needed */ require_once ROOT_DIR . '/browsing/include/class_image.inc.php'; $id_img = new ImageDevice(); $new_img = $id_img->resize_image($destFile, AVATAR_MAX_WIDTH, AVATAR_MAX_HEIGHT); if (stristr($destFile, 'png')) { imagepng($new_img, $destFile); } else { if (stristr($destFile, 'jpeg') !== false || stristr($destFile, 'jpg') !== false) { imagejpeg($new_img, $destFile); } else { if (stristr($destFile, 'gif')) { imagegif($new_img, $destFile); } } } } } }