Posts

Showing posts with the label PHP

Upload temp folder server settings error

upload_tmp_dir = /tmp/

Upload images

$c1 = rand(0,9);$c2 = rand(0,9);$c3 = rand(0,9);$c4 = rand(0,9); $rand = $c1.$c2.$c3.$c4; $dir_path = "album/".$rand.$_FILES['upload1']['name']; $dir_patha = $dir_path; $file=$rand.$_FILES['upload1']['name']; if(move_uploaded_file($_FILES['upload1']['tmp_name'],"../".$dir_path)){

Unlink

unlink($arr1[$y]);

PDF to imGAE code

Image
[R-sig-mediawiki] Revised Rext 0.03 with better error reporting Alex Brown alex at transitive.com Tue Sep 26 15:03:44 CEST 2006 * Previous message: [R-sig-mediawiki] Revised Rext 0.02 with better error reporting * Next message: [R-sig-mediawiki] R-News article * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Attached is a version of Rext 0.03 with my previous changes plus a set of changes to improve error reporting, including: if iframe images cannot render, you get the program text + the error if inline R (default output) contains an error, you get the error message in red inlined with the wiki page if inline R (output=display) fails to render, you get the program text + the error inlined with the wiki page In the long run, I plan to unify the 3 different output modes, starting with default and display - I have a prototype (not included) that does this. I have attached a patch as well as the complete file. -Alex ...

Create handle for new PDF document

// create handle for new PDF document $pdf = pdf_new(); // open a file pdf_open_file($pdf, "philosophy.pdf"); // start a new page (A4) pdf_begin_page($pdf, 595, 842); // get and use a font object $arial = pdf_findfont($pdf, "Arial", "host", 1); pdf_setfont($pdf, $arial, 10); // print text pdf_show_xy($pdf, "There are more things in heaven and earth, Horatio,", 50, 750); pdf_show_xy($pdf, "than are dreamt of in your philosophy", 50, 730); // end page pdf_end_page($pdf); // close and save file pdf_close($pdf);

Upload initial setup

ini_set("upload_max_filesize","10M"); ini_set("post_max_size","10M"); ini_set("max_execution_time","10M"); ini_set("max_input_time","10M");

Image upload

$video_file1=$_FILES["fileupload3"]["name"]; $c1 = rand(0,9);$c2 = rand(0,9);$c3 = rand(0,9);$c4 = rand(0,9); $rand = $c1.$c2.$c3.$c4; $date = date("Y-m-d"); if($video_file1!='') { move_uploaded_file($_FILES['fileupload3']['tmp_name'],'../product_images/'.$rand.$_FILES['fileupload3']['name']); } if($video_file1!='') { $path3 = 'product_images/'.$rand.$_FILES['fileupload3']['name']; } else { $path3=$image; }

Mktime and date

$current_sdate = mktime(); $current_edate = mktime(date('h'),date('m'),date('s'),date('m'),date('d')+10,date('y')); $sdate=date("Y-m-d",$current_sdate); $edate=date("Y-m-d",$current_edate);

make DIR

if(is_dir($refer_folder_name)) { } else { mkdir($refer_folder_name); }

ini set

ini_set('display_errors','On'); ini_set('display_errors','Off'); error_reporting(E_ALL); ini_set("display_error",true);

IMAP configuration by php5ini

1) Set /etc/php5/apache2/php.ini to increase: - PHP Memory Limit from 16M to 40M memory_limit = 40M - Upload File Size: upload_max_filesize = 48M 2) Install cURL for the purpose of transferring data. apt-get install php5-curl 3) Install IMAP Module: InboundEmail and Campaigns (Email) require the IMAP libraries. Neither will be functional. apt-get install php5-imap 4) Create an empty .htacess file under the root directory of SugarCRM and chmod it to 777. After hitting the “Install” button, the Wizard will create all tables in MySQL. If you selected the “Sample Data”, it will also create it for you. It will also write following data to the .htaccess file created by you. # BEGIN SUGARCRM RESTRICTIONS RedirectMatch 403 (?i).*\.log$ RedirectMatch 403 (?i)/+not_imported_.*\.txt RedirectMatch 403 (?i)/+(soap|cache|xtemplate|data|examples|include|log4php|metadata|modules)/+.*\.(php|tpl) RedirectMatch 403 (?i)/+emailmandelivery\.php RedirectMatch 403 (?i)/+cache/+upload Re...

Image effetcs

/*$image = imagecreatefrompng("galapagos.jpg"); imagefilter($image, IMG_FILTER_GRAYSCALE); imagefilter($image, IMG_FILTER_NEGATE); header("content-type: image/png"); imagepng($image); imagedestroy($image);*/ $base_img_dir = "img/"; $img_conv_dir = "./bin/"; echo "filename :".$filename= "galapagos.jpg"; // retrieve image info $imginfo = getimagesize($filename); echo "imageinfo:".$imginfo[2]; // handle image according to type switch ($imginfo[2]) { case 1: // gif // convert gif to png using shell command $command = $img_conv_dir."gif2png $filename"; exec($command); // remove original gif file and rename converted png unlink($filename); rename("$filename.png", $filename); // check png image by loading and saving the file // to prevent wrong uploaded fi...

Image color change effects

Special effects using imagefilter() bool imagefilter ( resource image, int filter_type [, int parameter1 [, int parameter2 [, int parameter3]]]) The filters described here were written for the PHP-bundled build of GD, and may not be available in other releases. This is quite an odd function, as it happens, because the number of arguments you need to pass to it vary depending on the effect. The best way to explain this function is simply to explain briefly how it works then show a code example, so let's get started straight away. No matter what, the function returns true if the filter was applied successfully and false otherwise. First up is IMG_FILTER_BRIGHTNESS, which takes a number between -255 and 255 that represents how much you want to brighten or darken the image. Setting it to 0 leaves the picture unchanged, 255 sets it to full white (brightest), and -255 sets it to full black (darkest). Most pictures tend to get almost invisible beyond +200 or -200. This code...

GMT TIME

No matter the server is in which GMT time zone here is extremely easy way to get time and date for any time zone. This is done with time() and gmdate() function. gmdate() function normally give us GMT time but by doing a trick with time() function we can get GMT+N or GMT-N means we can get time for any GMT time zone. For example you have to get time for GMT+5 we will do it like following $offset=5*60*60; //converting 5 hours to seconds. $dateFormat="d-m-Y H:i"; $timeNdate=gmdate($dateFormat, time()+$offset); ?> Now if you have to get the time which is GMT-5 now we will just subtract the offset from the time() instead of adding into time like in following example we are getting time for GMT-4 $offset=4*60*60; //converting 5 hours to seconds. $dateFormat="d-m-Y H:i"; $timeNdate=gmdate($dateFormat, time()-$offset); ?> -12 = GMT - 12 Hours -11 = GMT - 11 Hours -10 = GMT - 10 Hours -9 = GMT - 9 Hours -8 = G...

Get XML feed data

$file = "http://xml.altinkaynak.com/doviz.xml"; function startElement($parser, $name, $attrs) { global $ShwText; if($name == 'DOVIZ') $ShwText .= " "; } function endElement($parser, $name) { global $ShwText; if($name == 'DOVIZ') $ShwText .= " "; } function characterData($parser, $data) { global $ShwText; if($data != '') $ShwText .= " ".$data." "; } $ShwText = " "; $xml_parser = xml_parser_create(); xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); if (!($fp = fopen($file, "r"))) { die("AltınKaynak XML yüklenemedi. "); $ShwText = ""; } while ($data = fread($fp, 4096)) { if (!xml_parse($xml_parser, $data, feof($fp))) { die(sprintf("XML Yüklenme hatası : %s...

Get image size

$imginfo = getimagesize($filename); echo "imageinfo:".$imginfo[2];

Get URL for header

/*Get link uri*/ $path=$_SERVER['PHP_SELF']; $path_arr=explode("/",$path); $size=sizeof($path_arr); $URI=$path_arr[$size-1];

Get folder files Details

$debug='false'; $folder='book/'.$sessionid; $d = dir($folder); while (false !== ($entry = $d->read())) { $isdir = is_dir($folder."/".$entry); if (!$isdir and $entry!="." and $entry!="..") { $file=$folder."/".$entry; $stringDataBody.= ' '.$file.' '.$file.' Page: '.$i.' '; $in="insert into ".TEMP." set `path`='$file' ,`sessionid`='$sessionid' "; $out=mysql_query($in); } } $d->close();

Get File Extension

$banner_imagex= $path_info['extension']; if($banner_imagex!="swf") {?> "> " width="233" height="157" border="0" /> "> "> " pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="233" height="157">

Folder creation dynamically

if(is_dir($refer_folder_name)) { } else { mkdir($refer_folder_name); } $filename = $refer_folder_name.$pname."_".$examname."_".$services.".pdf";

POPULAR POSTS ::

JOIN QUERY

Add multiple upload box

HTML and PHP INTRODUCTION

The top Web development PHP frameworks

Mobile App Development Trends: Emerging Technologies and Innovations

String Separation