/** * @param array Smiley * @param array Override params, e.g. "class" */ function get_smiley_img_tag($smiley, $override_fields = array()) { $attribs = array('src' => $smiley['image'], 'title' => format_to_output($smiley['code'], 'htmlattr'), 'alt' => format_to_output($smiley['code'], 'htmlattr'), 'class' => 'middle'); if ($smiley_wh = imgsize($smiley['path'], 'widthheight_assoc')) { $attribs += $smiley_wh; } if ($override_fields) { $attribs = $override_fields + $attribs; } return '<img' . get_field_attribs_as_string($attribs) . ' />'; }
} if (isset($_POST['upload'])) { $myfile = $_POST['myfile']; $imgname = unhack($_POST['name']); $email = unhack($_POST['email']); $imgdate = unhack($_POST['date']); $phone = unhack($_POST['phone']); $get_prev_id = mysql_query("select MAX(docs_id) from mydocs") or die(mysql_error() . " Prev id not fetched"); $docs_id = mysql_fetch_array($get_prev_id); $d_id = $docs_id[0]; //Properties of the uploaded file $name = $_FILES['myfile']['name']; $nam = isimg($name); $type = $_FILES['myfile']['type']; $siz = $_FILES['myfile']['size']; $size = imgsize($siz); $tmp_name = $_FILES['myfile']['tmp_name']; $error = $_FILES['myfile']['error']; //Validate must upload file and not empty receipt no and patient name if ($error > 0) { echo "<font color='red'><h3>Please Choose file first</h3></font>"; } if ($size == FALSE) { echo "Your Image is Grater then 5 mb Please upload image less then 5 mb "; } if ($nam == FALSE) { echo "You can only upload images"; } elseif (file_exists("mydocs/" . $username)) { ////////////////////SuperScriptStart////////////////////////////////////// $increement = $d_id + 1; $new_name = "img.{$increement}";
/** * Get properties of an icon. * * Note: to get a file type icon, use {@link File::get_icon()} instead. * * @uses get_icon_info() * @param string icon for what? (key) * @param string what to return for that icon ('imgtag', 'alt', 'legend', 'file', 'url', 'size' {@link imgsize()}) * @param array additional params * - 'class' => class name when getting 'imgtag', * - 'size' => param for 'size', * - 'title' => title attribute for 'imgtag' * @param boolean true to include this icon into the legend at the bottom of the page (works for 'imgtag' only) * @return mixed False on failure, string on success. */ function get_icon($iconKey, $what = 'imgtag', $params = NULL, $include_in_legend = false) { global $admin_subdir, $Debuglog, $use_strict; global $conf_path; global $rsc_path, $rsc_uri; if (!function_exists('get_icon_info')) { require_once $conf_path . '_icons.php'; } $icon = get_icon_info($iconKey); if (!$icon) { $Debuglog->add('No image defined for ' . var_export($iconKey, true) . '!', 'icons'); return false; } if (!isset($icon['file']) && $what != 'imgtag') { $icon['file'] = 'icons/icons_sprite.png'; } switch ($what) { case 'rollover': if (isset($icon['rollover'])) { // Image has rollover available return $icon['rollover']; } return false; /* BREAK */ /* BREAK */ case 'file': return $rsc_path . $icon['file']; /* BREAK */ /* BREAK */ case 'alt': if (isset($icon['alt'])) { // alt tag from $map_iconfiles return $icon['alt']; } else { // fallback to $iconKey as alt-tag return $iconKey; } /* BREAK */ /* BREAK */ case 'legend': if (isset($icon['legend'])) { // legend tag from $map_iconfiles return $icon['legend']; } else { if (isset($icon['alt'])) { // alt tag from $map_iconfiles return $icon['alt']; } else { // fallback to $iconKey as alt-tag return $iconKey; } } /* BREAK */ /* BREAK */ case 'class': if (isset($icon['class'])) { return $icon['class']; } else { return ''; } /* BREAK */ /* BREAK */ case 'url': return $rsc_uri . $icon['file']; /* BREAK */ /* BREAK */ case 'size': if (!isset($icon['size'])) { $Debuglog->add('No iconsize for [' . $iconKey . ']', 'icons'); $icon['size'] = imgsize($rsc_path . $icon['file']); } switch ($params['size']) { case 'width': return $icon['size'][0]; case 'height': return $icon['size'][1]; case 'widthxheight': return $icon['size'][0] . 'x' . $icon['size'][1]; case 'width': return $icon['size'][0]; case 'string': return 'width="' . $icon['size'][0] . '" height="' . $icon['size'][1] . '"'; default: return $icon['size']; } /* BREAK */ /* BREAK */ case 'xy': if (isset($icon['xy'])) { // Return data for style property "background-position" return "-" . $icon['xy'][0] . "px -" . $icon['xy'][1] . "px"; } return false; case 'sprite': if (isset($icon['xy'])) { // Image uses spite file return true; } return false; /* BREAK */ /* BREAK */ case 'imgtag': if (!isset($icon['file'])) { // Use span tag with sprite instead of img $styles = array(); if (isset($params['xy'])) { // Get background position from params $styles[] = "background-position: " . $params['xy'][0] . "px " . $params['xy'][1] . "px"; unset($params['xy']); } else { if (isset($icon['xy'])) { // Set background position in the icons_sprite.png $styles[] = "background-position: -" . $icon['xy'][0] . "px -" . $icon['xy'][1] . "px"; } } if (isset($params['size'])) { // Get sizes from params $icon['size'] = $params['size']; unset($params['size']); } if (isset($icon['size'])) { // Set width & height if ($icon['size'][0] != 16) { $styles[] = "width: " . $icon['size'][0] . "px"; } if ($icon['size'][1] != 16) { $styles[] = "height: " . $icon['size'][1] . "px; line-height: " . $icon['size'][1] . "px"; } } if (isset($params['style'])) { // Get styles from params $styles[] = $params['style']; } if (count($styles) > 0) { $params['style'] = implode('; ', $styles); } if (!isset($params['title'])) { // Use 'alt' for 'title' if (isset($params['alt'])) { $params['title'] = $params['alt']; unset($params['alt']); } else { if (!isset($params['alt']) && isset($icon['alt'])) { $params['title'] = $icon['alt']; } } } if (isset($params['class'])) { // Get class from params $params['class'] = 'icon ' . $params['class']; } else { // Set default class $params['class'] = 'icon'; } // Add all the attributes: $params = get_field_attribs_as_string($params, false); $r = '<span' . $params . '> </span>'; } else { // Use img tag $r = '<img src="' . $rsc_uri . $icon['file'] . '" '; if (!$use_strict) { // Include non CSS fallbacks - transitional only: $r .= 'border="0" align="top" '; } // Include class (will default to "icon"): if (!isset($params['class'])) { if (isset($icon['class'])) { // This icon has a class $params['class'] = $icon['class']; } else { $params['class'] = ''; } } // Include size (optional): if (isset($icon['size'])) { $r .= 'width="' . $icon['size'][0] . '" height="' . $icon['size'][1] . '" '; } // Include alt (XHTML mandatory): if (!isset($params['alt'])) { if (isset($icon['alt'])) { // alt-tag from $map_iconfiles $params['alt'] = $icon['alt']; } else { // $iconKey as alt-tag $params['alt'] = $iconKey; } } // Add all the attributes: $r .= get_field_attribs_as_string($params, false); // Close tag: $r .= '/>'; if ($include_in_legend && ($IconLegend =& get_IconLegend())) { // This icon should be included into the legend: $IconLegend->add_icon($iconKey); } } return $r; /* BREAK */ /* BREAK */ case 'noimg': // Include size (optional): if (isset($icon['size'])) { $params['size'] = $icon['size']; } $params['style'] = 'margin: 0 2px'; return get_icon('pixel', 'imgtag', $params); /* BREAK */ /* $blank_icon = get_icon_info('pixel'); $r = '<img src="'.$rsc_uri.$blank_icon['file'].'" '; // TODO: dh> add this only for !$use_strict, like above? // Include non CSS fallbacks (needed by bozos... and basic skin): $r .= 'border="0" align="top" '; // Include class (will default to "noicon"): if( ! isset( $params['class'] ) ) { if( isset($icon['class']) ) { // This icon has a class $params['class'] = $icon['class']; } else { $params['class'] = 'no_icon'; } } // Include size (optional): if( isset( $icon['size'] ) ) { $r .= 'width="'.$icon['size'][0].'" height="'.$icon['size'][1].'" '; } // Include alt (XHTML mandatory): if( ! isset( $params['alt'] ) ) { $params['alt'] = ''; } // Add all the attributes: $r .= get_field_attribs_as_string( $params, false ); // Close tag: $r .= '/>'; return $r;*/ /* BREAK */ } }
} // Set all params for requested size: list($thumb_type, $thumb_width, $thumb_height, $thumb_quality, $thumb_percent_blur) = $thumbnail_sizes[$size_name]; $Filetype =& $File->get_Filetype(); // pre_dump( $Filetype ); // TODO: dh> Filetype may be NULL here! see also r1.18 (IIRC) $mimetype = $Filetype->mimetype; // pre_dump( $mimetype ); // Try to output the cached thumbnail: $err = $File->output_cached_thumb($size_name, $mimetype, $mtime, $size_x); //pre_dump( $err ); if ($err == '!Thumbnail not found in' . $Settings->get('evocache_foldername')) { // The thumbnail wasn't already in the cache, try to generate and cache it now: $err = NULL; // Short error code list($src_width, $src_height) = imgsize($File->get_full_path()); if (!$resample_all_images && check_thumbnail_sizes($thumb_type, $thumb_width, $thumb_height, $src_width, $src_height)) { // There is no need to resample, use original! $err = $File->get_af_thumb_path($size_name, $mimetype, true, $size_x); if ($err[0] != '!' && @copy($File->get_full_path(), $err)) { // File was saved. Ouput that same file immediately: // note: @copy returns FALSE on failure, if not muted it'll print the error on screen $err = $File->output_cached_thumb($size_name, $mimetype, $mtime, $size_x); } } else { // Resample list($err, $src_imh) = load_image($File->get_full_path(), $mimetype); if (empty($err)) { list($err, $dest_imh) = generate_thumb($src_imh, $thumb_type, $thumb_width, $thumb_height, $thumb_percent_blur, $size_x); if (empty($err)) { $err = $File->save_thumb_to_cache($dest_imh, $size_name, $mimetype, $thumb_quality, $size_x);
/** * Process file uploads (this can process multiple file uploads at once) * * @param string FileRoot id string * @param string the upload dir relative path in the FileRoot * @param boolean Shall we create path dirs if they do not exist? * @param boolean Shall we check files add permission for current_User? * @param boolean upload quick mode * @param boolean show warnings if filename is not valid * @param integer minimum size for pictures in pixels (width and height) * @return mixed NULL if upload was impossible to complete for some reason (wrong fileroot ID, insufficient user permission, etc.) * array, which contains uploadedFiles, failedFiles, renamedFiles and renamedMessages */ function process_upload($root_ID, $path, $create_path_dirs = false, $check_perms = true, $upload_quickmode = true, $warn_invalid_filenames = true, $min_size = 0) { global $Settings, $Plugins, $Messages, $current_User, $force_upload_forbiddenext; if (empty($_FILES)) { // We have NO uploaded files to process... return NULL; } /** * Remember failed files (and the error messages) * @var array */ $failedFiles = array(); /** * Remember uploaded files * @var array */ $uploadedFiles = array(); /** * Remember renamed files * @var array */ $renamedFiles = array(); /** * Remember renamed Messages * @var array */ $renamedMessages = array(); $FileRootCache =& get_FileRootCache(); $fm_FileRoot =& $FileRootCache->get_by_ID($root_ID, true); if (!$fm_FileRoot) { // fileRoot not found: return NULL; } if ($check_perms && (!isset($current_User) || $current_User->check_perm('files', 'add', false, $fm_FileRoot))) { // Permission check required but current User has no permission to upload: return NULL; } // Let's get into requested list dir... $non_canonical_list_path = $fm_FileRoot->ads_path . $path; // Dereference any /../ just to make sure, and CHECK if directory exists: $ads_list_path = get_canonical_path($non_canonical_list_path); // check if the upload dir exists if (!is_dir($ads_list_path)) { if ($create_path_dirs) { // Create path mkdir_r($ads_list_path); } else { // This case should not happen! If it happens then there is a bug in the code where this function was called! return NULL; } } // Get param arrays for all uploaded files: $uploadfile_title = param('uploadfile_title', 'array/string', array()); $uploadfile_alt = param('uploadfile_alt', 'array/string', array()); $uploadfile_desc = param('uploadfile_desc', 'array/string', array()); $uploadfile_name = param('uploadfile_name', 'array/string', array()); // LOOP THROUGH ALL UPLOADED FILES AND PROCCESS EACH ONE: foreach ($_FILES['uploadfile']['name'] as $lKey => $lName) { if (empty($lName)) { // No file name: if ($upload_quickmode || !empty($uploadfile_title[$lKey]) || !empty($uploadfile_alt[$lKey]) || !empty($uploadfile_desc[$lKey]) || !empty($uploadfile_name[$lKey])) { // User specified params but NO file! Warn the user: $failedFiles[$lKey] = T_('Please select a local file to upload.'); } // Abort upload for this file: continue; } if ($Settings->get('upload_maxkb') && $_FILES['uploadfile']['size'][$lKey] > $Settings->get('upload_maxkb') * 1024) { // File is larger than allowed in settings: $failedFiles[$lKey] = sprintf(T_('The file is too large: %s but the maximum allowed is %s.'), bytesreadable($_FILES['uploadfile']['size'][$lKey]), bytesreadable($Settings->get('upload_maxkb') * 1024)); // Abort upload for this file: continue; } if (!empty($min_size)) { // Check pictures for small sizes $image_sizes = imgsize($_FILES['uploadfile']['tmp_name'][$lKey], 'widthheight'); if ($image_sizes[0] < $min_size || $image_sizes[1] < $min_size) { // Abort upload for this file: $failedFiles[$lKey] = sprintf(T_('Your profile picture must have a minimum size of %dx%d pixels.'), $min_size, $min_size); continue; } } if ($_FILES['uploadfile']['error'][$lKey]) { // PHP itself has detected an error!: switch ($_FILES['uploadfile']['error'][$lKey]) { case UPLOAD_ERR_FORM_SIZE: // The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form. // This can easily be edited by the user/hacker, so we do not use it.. file size gets checked for real just above. break; case UPLOAD_ERR_INI_SIZE: // File is larger than allowed in php.ini: $failedFiles[$lKey] = 'The file exceeds the upload_max_filesize directive in php.ini.'; // Configuration error, no translation // Abort upload for this file: continue; case UPLOAD_ERR_PARTIAL: $failedFiles[$lKey] = T_('The file was only partially uploaded.'); // Abort upload for this file: continue; case UPLOAD_ERR_NO_FILE: // Is probably the same as empty($lName) before. $failedFiles[$lKey] = T_('No file was uploaded.'); // Abort upload for this file: continue; case 6: // numerical value of UPLOAD_ERR_NO_TMP_DIR # (min_php: 4.3.10, 5.0.3) case UPLOAD_ERR_NO_TMP_DIR: // Missing a temporary folder. $failedFiles[$lKey] = 'Temporary upload dir is missing! (upload_tmp_dir in php.ini)'; // Configuration error, no translation // Abort upload for this file: continue; default: $failedFiles[$lKey] = T_('An unknown error has occurred!') . ' Error code #' . $_FILES['uploadfile']['error'][$lKey]; // Abort upload for this file: continue; } } if (!isset($_FILES['uploadfile']['_evo_fetched_url'][$lKey]) && !is_uploaded_file($_FILES['uploadfile']['tmp_name'][$lKey])) { // Ensure that a malicious user hasn't tried to trick the script into working on files upon which it should not be working. $failedFiles[$lKey] = T_('The file does not seem to be a valid upload! It may exceed the upload_max_filesize directive in php.ini.'); // Abort upload for this file: continue; } // Use new name on server if specified: $newName = !empty($uploadfile_name[$lKey]) ? $uploadfile_name[$lKey] : $lName; // validate file name if ($error_filename = process_filename($newName, !$warn_invalid_filenames)) { // Not a valid file name or not an allowed extension: $failedFiles[$lKey] = $error_filename; // Abort upload for this file: continue; } // Check if the uploaded file type is an image, and if is an image then try to fix the file extension based on mime type // If the mime type is a known mime type and user has right to upload files with this kind of file type, // this part of code will check if the file extension is the same as admin defined for this file type, and will fix it if it isn't the same // Note: it will also change the jpeg extensions to jpg. $uploadfile_path = $_FILES['uploadfile']['tmp_name'][$lKey]; // this image_info variable will be used again to get file thumb $image_info = getimagesize($uploadfile_path); if ($image_info) { // This is an image, validate mimetype vs. extension: $image_mimetype = $image_info['mime']; $FiletypeCache =& get_FiletypeCache(); // Get correct file type based on mime type $correct_Filetype = $FiletypeCache->get_by_mimetype($image_mimetype, false, false); // Check if file type is known by us, and if it is allowed for upload. // If we don't know this file type or if it isn't allowed we don't change the extension! The current extension is allowed for sure. if ($correct_Filetype && $correct_Filetype->is_allowed()) { // A FileType with the given mime type exists in database and it is an allowed file type for current User // The "correct" extension is a plausible one, proceed... $correct_extension = array_shift($correct_Filetype->get_extensions()); $path_info = pathinfo($newName); $current_extension = $path_info['extension']; // change file extension to the correct extension, but only if the correct extension is not restricted, this is an extra security check! if (strtolower($current_extension) != strtolower($correct_extension) && !in_array($correct_extension, $force_upload_forbiddenext)) { // change the file extension to the correct extension $old_name = $newName; $newName = $path_info['filename'] . '.' . $correct_extension; $Messages->add(sprintf(T_('The extension of the file «%s» has been corrected. The new filename is «%s».'), $old_name, $newName), 'warning'); } } } // Get File object for requested target location: $oldName = strtolower($newName); list($newFile, $oldFile_thumb) = check_file_exists($fm_FileRoot, $path, $newName, $image_info); $newName = $newFile->get('name'); // Trigger plugin event if ($Plugins->trigger_event_first_false('AfterFileUpload', array('File' => &$newFile, 'name' => &$_FILES['uploadfile']['name'][$lKey], 'type' => &$_FILES['uploadfile']['type'][$lKey], 'tmp_name' => &$_FILES['uploadfile']['tmp_name'][$lKey], 'size' => &$_FILES['uploadfile']['size'][$lKey]))) { // Plugin returned 'false'. // Abort upload for this file: continue; } // Attempt to move the uploaded file to the requested target location: if (isset($_FILES['uploadfile']['_evo_fetched_url'][$lKey])) { // fetched remotely if (!rename($_FILES['uploadfile']['tmp_name'][$lKey], $newFile->get_full_path())) { $failedFiles[$lKey] = T_('An unknown error occurred when moving the uploaded file on the server.'); // Abort upload for this file: continue; } } elseif (!move_uploaded_file($_FILES['uploadfile']['tmp_name'][$lKey], $newFile->get_full_path())) { $failedFiles[$lKey] = T_('An unknown error occurred when moving the uploaded file on the server.'); // Abort upload for this file: continue; } // change to default chmod settings if ($newFile->chmod(NULL) === false) { // add a note, this is no error! $Messages->add(sprintf(T_('Could not change permissions of «%s» to default chmod setting.'), $newFile->dget('name')), 'note'); } // Refreshes file properties (type, size, perms...) $newFile->load_properties(); if (!empty($oldFile_thumb)) { // The file name was changed! if ($image_info) { $newFile_thumb = $newFile->get_preview_thumb('fulltype'); } else { $newFile_thumb = $newFile->get_size_formatted(); } //$newFile_size = bytesreadable ($_FILES['uploadfile']['size'][$lKey]); $renamedMessages[$lKey]['message'] = sprintf(T_('"%s was renamed to %s. Would you like to replace %s with the new version instead?'), '«' . $oldName . '»', '«' . $newName . '»', '«' . $oldName . '»'); $renamedMessages[$lKey]['oldThumb'] = $oldFile_thumb; $renamedMessages[$lKey]['newThumb'] = $newFile_thumb; $renamedFiles[$lKey]['oldName'] = $oldName; $renamedFiles[$lKey]['newName'] = $newName; } // Store extra info about the file into File Object: if (isset($uploadfile_title[$lKey])) { // If a title text has been passed... (does not happen in quick upload mode) $newFile->set('title', trim(strip_tags($uploadfile_title[$lKey]))); } if (isset($uploadfile_alt[$lKey])) { // If an alt text has been passed... (does not happen in quick upload mode) $newFile->set('alt', trim(strip_tags($uploadfile_alt[$lKey]))); } if (isset($uploadfile_desc[$lKey])) { // If a desc text has been passed... (does not happen in quick upload mode) $newFile->set('desc', trim(strip_tags($uploadfile_desc[$lKey]))); } // Store File object into DB: $newFile->dbsave(); $uploadedFiles[] = $newFile; } prepare_uploaded_files($uploadedFiles); return array('uploadedFiles' => $uploadedFiles, 'failedFiles' => $failedFiles, 'renamedFiles' => $renamedFiles, 'renamedMessages' => $renamedMessages); }
/** * Get properties of an icon. * * Note: to get a file type icon, use {@link File::get_icon()} instead. * * @uses get_icon_info() * @param string icon for what? (key) * @param string what to return for that icon ('imgtag', 'alt', 'legend', 'file', 'url', 'size' {@link imgsize()}) * @param array additional params ( * 'class' => class name when getting 'imgtag', * 'size' => param for 'size', * 'title' => title attribute for 'imgtag') * @param boolean true to include this icon into the legend at the bottom of the page (works for 'imgtag' only) */ function get_icon($iconKey, $what = 'imgtag', $params = NULL, $include_in_legend = false) { global $admin_subdir, $Debuglog, $IconLegend, $use_strict; global $conf_path; global $rsc_path, $rsc_url; if (!function_exists('get_icon_info')) { require_once $conf_path . '_icons.php'; } $icon = get_icon_info($iconKey); if (!$icon || !isset($icon['file'])) { return '[no image defined for ' . var_export($iconKey, true) . '!]'; } switch ($what) { case 'rollover': if (isset($icon['rollover'])) { // Image has rollover available return $icon['rollover']; } return false; /* BREAK */ /* BREAK */ case 'file': return $rsc_path . $icon['file']; /* BREAK */ /* BREAK */ case 'alt': if (isset($icon['alt'])) { // alt tag from $map_iconfiles return $icon['alt']; } else { // fallback to $iconKey as alt-tag return $iconKey; } /* BREAK */ /* BREAK */ case 'legend': if (isset($icon['legend'])) { // legend tag from $map_iconfiles return $icon['legend']; } else { if (isset($icon['alt'])) { // alt tag from $map_iconfiles return $icon['alt']; } else { // fallback to $iconKey as alt-tag return $iconKey; } } /* BREAK */ /* BREAK */ case 'class': if (isset($icon['class'])) { return $icon['class']; } else { return ''; } /* BREAK */ /* BREAK */ case 'url': return $rsc_url . $icon['file']; /* BREAK */ /* BREAK */ case 'size': if (!isset($icon['size'])) { $Debuglog->add('No iconsize for [' . $iconKey . ']', 'icons'); $icon['size'] = imgsize($rsc_path . $icon['file']); } switch ($params['size']) { case 'width': return $icon['size'][0]; case 'height': return $icon['size'][1]; case 'widthxheight': return $icon['size'][0] . 'x' . $icon['size'][1]; case 'width': return $icon['size'][0]; case 'string': return 'width="' . $icon['size'][0] . '" height="' . $icon['size'][1] . '"'; default: return $icon['size']; } /* BREAK */ /* BREAK */ case 'imgtag': $r = '<img src="' . $rsc_url . $icon['file'] . '" '; if (!$use_strict) { // Include non CSS fallbacks - transitional only: $r .= 'border="0" align="top" '; } // Include class (will default to "icon"): if (!isset($params['class'])) { if (isset($icon['class'])) { // This icon has a class $params['class'] = $icon['class']; } else { $params['class'] = ''; } } // Include size (optional): if (isset($icon['size'])) { $r .= 'width="' . $icon['size'][0] . '" height="' . $icon['size'][1] . '" '; } // Include alt (XHTML mandatory): if (!isset($params['alt'])) { if (isset($icon['alt'])) { // alt-tag from $map_iconfiles $params['alt'] = $icon['alt']; } else { // $iconKey as alt-tag $params['alt'] = $iconKey; } } // Add all the attributes: $r .= get_field_attribs_as_string($params, false); // Close tag: $r .= '/>'; if ($include_in_legend && isset($IconLegend)) { // This icon should be included into the legend: $IconLegend->add_icon($iconKey); } return $r; /* BREAK */ /* BREAK */ case 'noimg': $blank_icon = get_icon_info('pixel'); $r = '<img src="' . $rsc_url . $blank_icon['file'] . '" '; // Include non CSS fallbacks: $r .= 'border="0" align="top" '; // Include class (will default to "noicon"): if (!isset($params['class'])) { if (isset($icon['class'])) { // This icon has a class $params['class'] = $icon['class']; } else { $params['class'] = 'no_icon'; } } // Include size (optional): if (isset($icon['size'])) { $r .= 'width="' . $icon['size'][0] . '" height="' . $icon['size'][1] . '" '; } // Include alt (XHTML mandatory): if (!isset($params['alt'])) { $params['alt'] = ''; } // Add all the attributes: $r .= get_field_attribs_as_string($params, false); // Close tag: $r .= '/>'; return $r; /* BREAK */ } }
/** * Get size of an image or false if not an image * * @todo cache this data (NOTE: we have different params here! - imgsize() does caching already!) * * @uses imgsize() * @param string {@link imgsize()} * @return false|mixed false if the File is not an image, the requested data otherwise */ function get_image_size($param = 'widthxheight') { return imgsize($this->_adfp_full_path, $param); }
/** * Get properties of an icon. * * Note: to get a file type icon, use {@link File::get_icon()} instead. * * @uses get_icon_info() * @param string icon for what? (key) * @param string what to return for that icon ('imgtag', 'alt', 'legend', 'file', 'url', 'size' {@link imgsize()}) * @param array additional params * - 'class' => class name when getting 'imgtag', * - 'size' => param for 'size', * - 'title' => title attribute for 'imgtag' * @param boolean true to include this icon into the legend at the bottom of the page (works for 'imgtag' only) * @return mixed False on failure, string on success. */ function get_icon($iconKey, $what = 'imgtag', $params = NULL, $include_in_legend = false) { global $admin_subdir, $Debuglog, $use_strict; global $conf_path; global $rsc_path, $rsc_uri; if (!function_exists('get_icon_info')) { require_once $conf_path . '_icons.php'; } $icon = get_icon_info($iconKey); if (!$icon) { $Debuglog->add('No image defined for ' . var_export($iconKey, true) . '!', 'icons'); return false; } if (!isset($icon['file']) && $what != 'imgtag') { $icon['file'] = 'icons/icons_sprite.png'; } switch ($what) { case 'rollover': if (isset($icon['rollover'])) { // Image has rollover available global $b2evo_icons_type; if (isset($b2evo_icons_type) && (!empty($icon['glyph']) || !empty($icon['fa']))) { // Glyph and font-awesome icons don't have rollover effect return false; } return $icon['rollover']; } return false; /* BREAK */ /* BREAK */ case 'file': return $rsc_path . $icon['file']; /* BREAK */ /* BREAK */ case 'alt': if (isset($icon['alt'])) { // alt tag from $map_iconfiles return $icon['alt']; } else { // fallback to $iconKey as alt-tag return $iconKey; } /* BREAK */ /* BREAK */ case 'legend': if (isset($icon['legend'])) { // legend tag from $map_iconfiles return $icon['legend']; } else { if (isset($icon['alt'])) { // alt tag from $map_iconfiles return $icon['alt']; } else { // fallback to $iconKey as alt-tag return $iconKey; } } /* BREAK */ /* BREAK */ case 'class': if (isset($icon['class'])) { return $icon['class']; } else { return ''; } /* BREAK */ /* BREAK */ case 'url': return $rsc_uri . $icon['file']; /* BREAK */ /* BREAK */ case 'size': if (!isset($icon['size'])) { $Debuglog->add('No iconsize for [' . $iconKey . ']', 'icons'); $icon['size'] = imgsize($rsc_path . $icon['file']); } switch ($params['size']) { case 'width': return $icon['size'][0]; case 'height': return $icon['size'][1]; case 'widthxheight': return $icon['size'][0] . 'x' . $icon['size'][1]; case 'width': return $icon['size'][0]; case 'string': return 'width="' . $icon['size'][0] . '" height="' . $icon['size'][1] . '"'; default: return $icon['size']; } /* BREAK */ /* BREAK */ case 'xy': if (isset($icon['xy'])) { // Return data for style property "background-position" return "-" . $icon['xy'][0] . "px -" . $icon['xy'][1] . "px"; } return false; case 'sprite': if (isset($icon['xy'])) { // Image uses spite file return true; } return false; /* BREAK */ /* BREAK */ case 'imgtag': global $b2evo_icons_type; if (isset($b2evo_icons_type)) { // Specific icons type is defined $current_icons_type = $b2evo_icons_type; if ($current_icons_type == 'fontawesome-glyphicons') { // Use fontawesome icons as a priority over the glyphicons $current_icons_type = isset($icon['fa']) ? 'fontawesome' : 'glyphicons'; } switch ($current_icons_type) { case 'glyphicons': // Use glyph icons of bootstrap $icon_class_prefix = 'glyphicon glyphicon-'; $icon_param_name = 'glyph'; $icon_content = ' '; break; case 'fontawesome': // Use the icons from http://fortawesome.github.io/Font-Awesome/icons/ $icon_class_prefix = 'fa fa-'; $icon_param_name = 'fa'; $icon_content = ''; break; } } if (isset($icon_class_prefix) && !empty($icon[$icon_param_name])) { // Use glyph or fa icon if it is defined in icons config if (isset($params['class'])) { // Get class from params $params['class'] = $icon_class_prefix . $icon[$icon_param_name] . ' ' . $params['class']; } else { // Set default class $params['class'] = $icon_class_prefix . $icon[$icon_param_name]; } $styles = array(); if (isset($icon['color-' . $icon_param_name])) { // Set a color for icon only for current type if ($icon['color-' . $icon_param_name] != 'default') { $styles[] = 'color:' . $icon['color-' . $icon_param_name]; } } elseif (isset($icon['color'])) { // Set a color for icon for all types if ($icon['color'] != 'default') { $styles[] = 'color:' . $icon['color']; } } if (isset($icon['color-over'])) { // Set a color for mouse over event $params['data-color'] = $icon['color-over']; } if (isset($icon['toggle-' . $icon_param_name])) { // Set a color for mouse over event $params['data-toggle'] = $icon['toggle-' . $icon_param_name]; } if (!isset($params['title'])) { // Use 'alt' for 'title' if (isset($params['alt'])) { $params['title'] = $params['alt']; unset($params['alt']); } else { if (!isset($params['alt']) && isset($icon['alt'])) { $params['title'] = $icon['alt']; } } } if (isset($icon['size-' . $icon_param_name])) { // Set a size for icon only for current type if (isset($icon['size-' . $icon_param_name][0])) { // Width $styles['width'] = 'width:' . $icon['size-' . $icon_param_name][0] . 'px'; } if (isset($icon['size-' . $icon_param_name][1])) { // Height $styles['width'] = 'height:' . $icon['size-' . $icon_param_name][1] . 'px'; } } if (isset($params['style'])) { // Keep styles from params $styles[] = $params['style']; } if (!empty($styles)) { // Init attribute 'style' $params['style'] = implode(';', $styles); } // Add all the attributes: $params = get_field_attribs_as_string($params, false); $r = '<span' . $params . '>' . $icon_content . '</span>'; } elseif (!isset($icon['file'])) { // Use span tag with sprite instead of img $styles = array(); if (isset($params['xy'])) { // Get background position from params $styles[] = "background-position: " . $params['xy'][0] . "px " . $params['xy'][1] . "px"; unset($params['xy']); } else { if (isset($icon['xy'])) { // Set background position in the icons_sprite.png $styles[] = "background-position: -" . $icon['xy'][0] . "px -" . $icon['xy'][1] . "px"; } } if (isset($params['size'])) { // Get sizes from params $icon['size'] = $params['size']; unset($params['size']); } if (isset($icon['size'])) { // Set width & height if ($icon['size'][0] != 16) { $styles[] = "width: " . $icon['size'][0] . "px"; } if ($icon['size'][1] != 16) { $styles[] = "height: " . $icon['size'][1] . "px; line-height: " . $icon['size'][1] . "px"; } } if (isset($params['style'])) { // Get styles from params $styles[] = $params['style']; } if (count($styles) > 0) { $params['style'] = implode('; ', $styles); } if (!isset($params['title'])) { // Use 'alt' for 'title' if (isset($params['alt'])) { $params['title'] = $params['alt']; unset($params['alt']); } else { if (!isset($params['alt']) && isset($icon['alt'])) { $params['title'] = $icon['alt']; } } } if (isset($params['class'])) { // Get class from params $params['class'] = 'icon ' . $params['class']; } else { // Set default class $params['class'] = 'icon'; } // Add all the attributes: $params = get_field_attribs_as_string($params, false); $r = '<span' . $params . '> </span>'; } else { // Use img tag $r = '<img src="' . $rsc_uri . $icon['file'] . '" '; if (!$use_strict) { // Include non CSS fallbacks - transitional only: $r .= 'border="0" align="top" '; } // Include class (will default to "icon"): if (!isset($params['class'])) { if (isset($icon['class'])) { // This icon has a class $params['class'] = $icon['class']; } else { $params['class'] = ''; } } // Include size (optional): if (isset($icon['size'])) { $r .= 'width="' . $icon['size'][0] . '" height="' . $icon['size'][1] . '" '; } // Include alt (XHTML mandatory): if (!isset($params['alt'])) { if (isset($icon['alt'])) { // alt-tag from $map_iconfiles $params['alt'] = $icon['alt']; } else { // $iconKey as alt-tag $params['alt'] = $iconKey; } } // Add all the attributes: $r .= get_field_attribs_as_string($params, false); // Close tag: $r .= '/>'; if ($include_in_legend && ($IconLegend =& get_IconLegend())) { // This icon should be included into the legend: $IconLegend->add_icon($iconKey); } } return $r; /* BREAK */ /* BREAK */ case 'noimg': global $b2evo_icons_type; if (isset($b2evo_icons_type)) { // Specific icons type is defined $current_icons_type = $b2evo_icons_type; if ($current_icons_type == 'fontawesome-glyphicons') { // Use fontawesome icons as a priority over the glyphicons $current_icons_type = isset($icon['fa']) ? 'fontawesome' : 'glyphicons'; } switch ($current_icons_type) { case 'glyphicons': // Use glyph icons of bootstrap $icon_param_name = 'glyph'; break; case 'fontawesome': // Use the icons from http://fortawesome.github.io/Font-Awesome/icons/ $icon_param_name = 'fa'; break; } } $styles = array(); if (isset($icon_param_name) && !empty($icon[$icon_param_name])) { // Use glyph or fa icon if it is defined in icons config if (isset($icon['size-' . $icon_param_name])) { // Set a size for icon only for current type if (isset($icon['size-' . $icon_param_name][0])) { // Width $styles['width'] = 'width:' . $icon['size-' . $icon_param_name][0] . 'px'; } if (isset($icon['size-' . $icon_param_name][1])) { // Height $styles['width'] = 'height:' . $icon['size-' . $icon_param_name][1] . 'px'; } if (isset($icon['size'])) { // Unset size for sprite icon unset($icon['size']); } } } // Include size (optional): if (isset($icon['size'])) { $params['size'] = $icon['size']; } $styles[] = 'margin:0 2px'; if (isset($params['style'])) { // Keep styles from params $styles[] = $params['style']; } if (!empty($styles)) { // Init attribute 'style' $params['style'] = implode(';', $styles); } return get_icon('pixel', 'imgtag', $params); /* BREAK */ /* $blank_icon = get_icon_info('pixel'); $r = '<img src="'.$rsc_uri.$blank_icon['file'].'" '; // TODO: dh> add this only for !$use_strict, like above? // Include non CSS fallbacks (needed by bozos... and basic skin): $r .= 'border="0" align="top" '; // Include class (will default to "noicon"): if( ! isset( $params['class'] ) ) { if( isset($icon['class']) ) { // This icon has a class $params['class'] = $icon['class']; } else { $params['class'] = 'no_icon'; } } // Include size (optional): if( isset( $icon['size'] ) ) { $r .= 'width="'.$icon['size'][0].'" height="'.$icon['size'][1].'" '; } // Include alt (XHTML mandatory): if( ! isset( $params['alt'] ) ) { $params['alt'] = ''; } // Add all the attributes: $r .= get_field_attribs_as_string( $params, false ); // Close tag: $r .= '/>'; return $r;*/ /* BREAK */ } }
/** * Moves the image file to a new location. * * @access protected * @param Symfony\Component\HttpFoundation\File\UploadedFile $file * @param integer $id * @return string|null - en caso de fallo al guardar el archivo. */ protected function saveImage(UploadedFile $file, $id) { $uniq = uniqid($file->getClientOriginalName(), true); $hash = sha1($uniq); $name = sprintf("%s.%s", $hash, $file->guessExtension()); $directory = $this->makeDirectory(self::LOGOTIPO_DIRECTORY_PATH . $id); if ($file = $file->move($directory, $name)) { // recupero la ruta relativa del archivo: $file = path_segment($file->getRealPath(), self::LOGOTIPO_DIRECTORY_PATH); $size = imgsize($file); // cambia el tamaño del logotipo proporcionalmente a 160px: if ($size->getWidth() > 160 or $size->getHeight() > 160) { $file = imgscale($file, 160); } $file = path_segment($file, self::LOGOTIPO_DIRECTORY_PATH); } else { $file = null; } return $file; }
?> <a href="https://twitter.com/‎" title="twitter" target="_blank"><img src="img/twitter.jpg" border="0"></a> <a href="http://line.naver.jp/ja/" title="line" target="_blank"><img src="img/linex.jpg" height="27px" border="0"></a> <a href="https://ja-jp.facebook.com/" title="facebook" target="_blank"><img src="img/facebook.jpg" border="0"></a> <a href="http://www.youtube.com/?gl=JP&hl=ja" title="YouTube" target="_blank"><img src="img/youtube.jpg" border="0"></a> <a href="http://www.nicovideo.jp/" title="ニコニコ動画" target="_blank"><img src="img/nico.jpg" border="0"></a> <a href="http://www.ustream.tv/new" title="Ustream" target="_blank"><img src="img/ust1.jpg" border="0"></a> <?php $sql = "select id,title,url,img_path, priority\r\n\tfrom link where delete_flg = '0' order by priority asc"; $db = new DBLib($sg); $db->connect(); $db->prepare($sql); $arr = $db->execute(); $db->close(); $fmt = '<a href="%s" title="%s" target="_blank"><img src="%s" border="0"%s></a>' . "\n"; foreach ($arr as $ar) { $img = "img/noimage.jpg"; if ($ar["img_path"] != "") { $img = $ar["img_path"]; if (!file_exists($img)) { $img = "img/noimage.jpg"; } else { } } $v = sprintf($fmt, ht($ar["url"]), ht($ar["title"]), $img, imgsize($img, 120, 20)); print $v; } ?> <br /><br /><img src="img/QRcode.gif" width="100px"> <?php }
/** * Returns an array of things like: * - src * - title * - alt * - width * - height * * @param string what size do we want src to link to, can be "original" or a thumnbail size * @param string Title img attribute * @param string Alt img attribute * @param integer Ratio size, can be 1, 2 and etc. * @param string Change size of the attributes "width" & "height". * Example: ( $tag_size = '160' ) => width="160" height="160" * ( $tag_size = '160x320' ) => width="160" height="320" * NULL - use real size * 'none' - don't use attributes "width" & "height" * @return array List of HTML attributes for the image. */ function get_img_attribs($size_name = 'fit-80x80', $title = NULL, $alt = NULL, $size_x = 1, $tag_size = NULL) { $img_attribs = array('title' => isset($title) ? $title : $this->get('title'), 'alt' => isset($alt) ? $alt : $this->get('alt')); if (!isset($img_attribs['alt'])) { // use title for alt, too $img_attribs['alt'] = $img_attribs['title']; } if (!isset($img_attribs['alt'])) { // always use empty alt $img_attribs['alt'] = ''; } if ($size_name == 'original') { // We want src to link to the original file $img_attribs['src'] = $this->get_url(); if ($tag_size != 'none') { // Add attributes "width" & "height" only when they are not disabled: if ($size_arr = $this->get_image_size('widthheight_assoc')) { $img_attribs += $size_arr; } } } else { // We want src to link to a thumbnail $img_attribs['src'] = $this->get_thumb_url($size_name, '&', $size_x); if ($tag_size != 'none') { // Add attributes "width" & "height" only when they are not disabled: $thumb_path = $this->get_af_thumb_path($size_name, NULL, true); if ($tag_size !== NULL) { // Change size values $tag_size = explode('x', $tag_size); $img_attribs['width'] = $tag_size[0]; $img_attribs['height'] = empty($tag_size[1]) ? $tag_size[0] : $tag_size[1]; } elseif (substr($thumb_path, 0, 1) != '!' && ($size_arr = imgsize($thumb_path, 'widthheight_assoc'))) { // no error, add width and height attribs $img_attribs += $size_arr; } elseif ($thumb_sizes = $this->get_thumb_size($size_name)) { // Get sizes that are used for thumbnail really $img_attribs['width'] = $thumb_sizes[0]; $img_attribs['height'] = $thumb_sizes[1]; } } } return $img_attribs; }
/** * Returns an array of things like: * - src * - title * - alt * - width * - height * * @param string what size do we want src to link to, can be "original" or a thumnbail size * @param string * @param string * @return array List of HTML attributes for the image. */ function get_img_attribs($size_name = 'fit-80x80', $title = NULL, $alt = NULL) { $img_attribs = array('title' => isset($title) ? $title : $this->get('title'), 'alt' => isset($alt) ? $alt : $this->get('alt')); if (!isset($img_attribs['alt'])) { // use title for alt, too $img_attribs['alt'] = $img_attribs['title']; } if (!isset($img_attribs['alt'])) { // always use empty alt $img_attribs['alt'] = ''; } if ($size_name == 'original') { // We want src to link to the original file $img_attribs['src'] = $this->get_url(); if ($size_arr = $this->get_image_size('widthheight_assoc')) { $img_attribs += $size_arr; } } else { // We want src to link to a thumbnail $img_attribs['src'] = $this->get_thumb_url($size_name, '&'); $thumb_path = $this->get_af_thumb_path($size_name, NULL, true); if (substr($thumb_path, 0, 1) != '!' && ($size_arr = imgsize($thumb_path, 'widthheight_assoc'))) { // no error, add width and height attribs $img_attribs += $size_arr; } } return $img_attribs; }