$H_NW ){ $NW = $W_NW ; $NH = $W_NH ; }else{ $NW = $H_NW ; $NH = $H_NH ; } }else{ $NW = $OW ; $NH = $OH ; } $newImage = imagecreatetruecolor( $NW, $NH ); imagecopyresampled($newImage, $srcImage, 0, 0, 0, 0, $NW, $NH, $OW, $OH ); imagejpeg($newImage, $imageDir . $ResultFile, "90"); @imagedestroy($newImage); @imagedestroy($srcImage); return $ResultFile; } /********End make thumb***********/ /**********************/ function Upload_SFile( $ThisFile, $DestFolder, $ImgName ) { $filename = ""; if( $ThisFile["name"] != "" && $ThisFile["size"] > 0 ) { $FileDotExt = strtolower( strrchr( $ThisFile["name"] , '.' )); if($FileDotExt=='.jpeg' || $FileDotExt=='.jpg' || $FileDotExt=='.gif' || $FileDotExt=='.png' ) { $name=$ImgName; $dest = $name . $FileDotExt ; $size=getimagesize($ThisFile["tmp_name"]); //$_SESSION['imgsize']=$size; //if($size[0] >= 320 && $size[1] >=400 ) if($size[0] >= 25 && $size[1] >=5 )//modify by rizwan { if ( !copy($ThisFile["tmp_name"],$DestFolder.$dest) ){//local //if ( !copy($ThisFile["tmp_name"], '/home/noble/public_html/pakistanfashionmag.com'.$DestFolder.$dest) ){ //for online $filename = ''; $_SESSION['msg']="Server is unable to ulpload file at this time. Please try again."; $_SESSION['error']=1; }else { $filename = "$dest"; $_SESSION['error']=0; $_SESSION['msg']=""; } }else { $filename = ""; $_SESSION['error']=1; $_SESSION['msg']="Image Size are unacceptable to server"; } }else { $_SESSION['msg']="Uploaded image format is not accpetable."; $_SESSION['error']=1; $filename = ''; } } return $filename; } function make_image_name($imageName, $id='') { if( $imageName == '' )return; $FileDotExt = strtolower( strrchr( $imageName , '.' ) ); $FileBase = substr( $imageName , 0 , strrpos( $imageName , '.' ) ); if( $id == '' ) $id = rand(999999,9999999); $add_id = '-'.$id; $ResultFile = $FileBase.$add_id .$FileDotExt ; return $ResultFile; } function Makeimage( $imageDir ,$imageName, $MaxWH, $id='' ){ if( $imageName == '' )return; $FileDotExt = strtolower( strrchr( $imageName , '.' ) ); $FileBase = substr( $imageName , 0 , strrpos( $imageName , '.' ) ); /*if( $id == '' ) $id = rand(999999,9999999);*/ //$add_id = '-'.$id; $ResultFile = $FileBase.$add_id .$FileDotExt ; $srcImage = @imagecreatefromstring(file_get_contents($imageDir . $imageName));//local //$srcImage = @imagecreatefromstring(file_get_contents('/home/noble/public_html/pakistanfashionmag.com'.$imageDir . $imageName)); //for online if(!$srcImage) return '' ; $OW = imagesx( $srcImage ) ; // Origional Width $OH = imagesy( $srcImage ) ; // Origional Height if( !($OW <= $MaxWH['W'] && $OH <= $MaxWH['H']) ){ // //====== Width Fit ============ $W_NW = $MaxWH['W']; $W_NH = $MaxWH['W'] * $OH / $OW ; //====== Height Fit ============ $H_NH = $MaxWH['H']; $H_NW = $MaxWH['H'] * $OW / $OH ; //------------------------------ if( $W_NW < $H_NW ){ $NW = $W_NW ; $NH = $W_NH ; }else{ $NW = $H_NW ; $NH = $H_NH ; } }else{ $NW = $OW ; $NH = $OH ; } $newImage = imagecreatetruecolor( $NW, $NH ); imagecopyresampled($newImage, $srcImage, 0, 0, 0, 0, $NW, $NH, $OW, $OH ); imagejpeg($newImage, $imageDir . $ResultFile, "90");//local //imagejpeg($newImage, '/home/noble/public_html/pakistanfashionmag.com'.$imageDir . $ResultFile, "90"); //for online @imagedestroy($newImage); @imagedestroy($srcImage); return $ResultFile; } function just_clean($string) { // Replace other special chars $specialCharacters = array( '#' => '', '$' => '', '%' => '', '&' => '', '@' => '', '.' => '', '' => '', '+' => '', '=' => '', '' => '', '\\' => '', '/' => '', " " => '-', " " => '', "," => '', "'" => '', ); while (list($character, $replacement) = each($specialCharacters)) { $string = str_replace($character, '' . $replacement . '', $string); } $string = strtr($string, "? ","AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn" ); // Remove all remaining other unknown characters $string = preg_replace('/[^a-zA-Z0-9\-]/', ' ', $string); $string = preg_replace('/^[\-]+/', '', $string); $string = preg_replace('/[\-]+$/', '', $string); $string = preg_replace('/[\-]{2,}/', ' ', $string); return trim( $string ); } function verify_image($img, $alt='', $class='', $path) { $full_path = $_SERVER['DOCUMENT_ROOT'].$path.$img; if( file_exists( $full_path ) ) return ''.$alt.''; else return false; } function is_home(){ $home = $_SERVER["REQUEST_URI"]; $page = basename($home); if($home == '/' || $page == 'index.html' || $page == 'index.php'){ return true; } else { return false; } } function current_url(){ $url = basename($_SERVER["REQUEST_URI"]); return $url; } function banner_img($id){ // echo $id;exit(); $query = mysql_query("select image from banners where id=$id"); $img_name = mysql_result($query, 0, 0); return $img_name; } function get_extension($file){ $FileDotExt = strtolower( strrchr( $file['name'] , '.' ) ); return $FileDotExt; } function get_basename($file){ $FileBase = substr( $file['name'] , 0 , strrpos( $file['name'] , '.' ) ); return $FileBase; } function makeURL($url, $table){ global $ReqId; $cond = ''; if( $ReqId > 0 ) { $cond = ' and id<>'.$ReqId; } $q = mysql_query("select url from ".$table." where url='".$url."'".$cond); if( @mysql_num_rows($q) >= 1 ){ $chk = true; $i = 1; $image_base = ''; while($chk == true){ $new_url = $url.'-'.$i; $rows = @mysql_num_rows( mysql_query("select url from ".$table." where url='$new_url'") ); if( $rows < 1 ){ $chk = false; } $i++; } } else{ $new_url = $url; } return $new_url; } function get_member_name($email){ $name = mysql_result( mysql_query( "select company_name from members where contact_email='$email'" ), 0 ); return $name; } function CleanFileName( $Raw ){ $Raw = trim($Raw); $RemoveChars = array( "([\40])" , "([^a-zA-Z0-9-])", "(-{2,})" ); $ReplaceWith = array("-", "", "-"); return preg_replace($RemoveChars, $ReplaceWith, $Raw); } function Upload_CFile( $ThisFile, $DestFolder, $ImgName ) { $filename = ""; if( $ThisFile["name"] != "" && $ThisFile["size"] > 0 ) { $FileDotExt = strtolower( strrchr( $ThisFile["name"] , '.' )); $name=$ImgName; $dest = "$name" . $FileDotExt ; if ( !copy( $ThisFile["tmp_name"], $DestFolder.$dest) ){ $filename = ''; $_SESSION['msg']="Server is unable to ulpload file at this time. Please try again."; $_SESSION['error']=1; }else{ $filename = "$dest"; $_SESSION['error']=0; $_SESSION['msg']=""; } } return $filename; } function clean_for_csv($str){ $result = str_replace(array("\n","\r",","),array(" "," ","-"),$str); return $result; } function Upload_Image( $ThisFile, $DestFolder, $ImgName ){ $filename = ""; $ImgName = CleanFileName( $ImgName ); // auto filename clean if( $ThisFile["name"] != "" && $ThisFile["size"] > 0 ) { $FileDotExt = strtolower( strrchr( $ThisFile["name"] , '.' )); if ( strpos( "---".$ThisFile["type"] , "image" ) > 0 ){ $dest = "$ImgName" . $FileDotExt ; if ( !copy( $ThisFile["tmp_name"], $DestFolder.$dest) ){ $filename = ''; }else{ $filename = "$dest"; } } } return $filename; } function get_custom($url='', $title=false) { global $lang; if( $title ) { $q = mysql_query("select * from customhtml where url='".$url."'"); $custom_Arr = mysql_fetch_assoc( $q ); return $custom_Arr; } else { if( $lang ){ return @mysql_result( mysql_query("select contents_fr from customhtml where url='".$url."'"), 0 ); } else{ return @mysql_result( mysql_query("select contents from customhtml where url='".$url."'"), 0 ); } } } function form_names( $ind = '' ){ $forms = array('getfrank_interviews' => 'Getfrank Interviews', 'getfrank_competitions' => 'Getfrank Competitions', 'chelsey_interviews' => 'Chelsey Interviews', 'chelsey_competitions' => 'Chelsey Competitions' ); if( $ind ){ return $forms[$ind]; } else{ return $forms; } } function ad_date( $date ){ return date('F j, Y', strtotime($date) ); } function us_states(){ $state_list = array('AL'=>"Alabama", 'AK'=>"Alaska", 'AZ'=>"Arizona", 'AR'=>"Arkansas", 'CA'=>"California", 'CO'=>"Colorado", 'CT'=>"Connecticut", 'DE'=>"Delaware", 'DC'=>"District Of Columbia", 'FL'=>"Florida", 'GA'=>"Georgia", 'HI'=>"Hawaii", 'ID'=>"Idaho", 'IL'=>"Illinois", 'IN'=>"Indiana", 'IA'=>"Iowa", 'KS'=>"Kansas", 'KY'=>"Kentucky", 'LA'=>"Louisiana", 'ME'=>"Maine", 'MD'=>"Maryland", 'MA'=>"Massachusetts", 'MI'=>"Michigan", 'MN'=>"Minnesota", 'MS'=>"Mississippi", 'MO'=>"Missouri", 'MT'=>"Montana", 'NE'=>"Nebraska", 'NV'=>"Nevada", 'NH'=>"New Hampshire", 'NJ'=>"New Jersey", 'NM'=>"New Mexico", 'NY'=>"New York", 'NC'=>"North Carolina", 'ND'=>"North Dakota", 'OH'=>"Ohio", 'OK'=>"Oklahoma", 'OR'=>"Oregon", 'PA'=>"Pennsylvania", 'RI'=>"Rhode Island", 'SC'=>"South Carolina", 'SD'=>"South Dakota", 'TN'=>"Tennessee", 'TX'=>"Texas", 'UT'=>"Utah", 'VT'=>"Vermont", 'VA'=>"Virginia", 'WA'=>"Washington", 'WV'=>"West Virginia", 'WI'=>"Wisconsin", 'WY'=>"Wyoming"); return $state_list; } function country_list(){ $_countries = array( "GB" => "United Kingdom", "US" => "United States", "AF" => "Afghanistan", "AL" => "Albania", "DZ" => "Algeria", "AS" => "American Samoa", "AD" => "Andorra", "AO" => "Angola", "AI" => "Anguilla", "AQ" => "Antarctica", "AG" => "Antigua And Barbuda", "AR" => "Argentina", "AM" => "Armenia", "AW" => "Aruba", "AU" => "Australia", "AT" => "Austria", "AZ" => "Azerbaijan", "BS" => "Bahamas", "BH" => "Bahrain", "BD" => "Bangladesh", "BB" => "Barbados", "BY" => "Belarus", "BE" => "Belgium", "BZ" => "Belize", "BJ" => "Benin", "BM" => "Bermuda", "BT" => "Bhutan", "BO" => "Bolivia", "BA" => "Bosnia And Herzegowina", "BW" => "Botswana", "BV" => "Bouvet Island", "BR" => "Brazil", "IO" => "British Indian Ocean Territory", "BN" => "Brunei Darussalam", "BG" => "Bulgaria", "BF" => "Burkina Faso", "BI" => "Burundi", "KH" => "Cambodia", "CM" => "Cameroon", "CA" => "Canada", "CV" => "Cape Verde", "KY" => "Cayman Islands", "CF" => "Central African Republic", "TD" => "Chad", "CL" => "Chile", "CN" => "China", "CX" => "Christmas Island", "CC" => "Cocos (Keeling) Islands", "CO" => "Colombia", "KM" => "Comoros", "CG" => "Congo", "CD" => "Congo, The Democratic Republic Of The", "CK" => "Cook Islands", "CR" => "Costa Rica", "CI" => "Cote D'Ivoire", "HR" => "Croatia (Local Name: Hrvatska)", "CU" => "Cuba", "CY" => "Cyprus", "CZ" => "Czech Republic", "DK" => "Denmark", "DJ" => "Djibouti", "DM" => "Dominica", "DO" => "Dominican Republic", "TP" => "East Timor", "EC" => "Ecuador", "EG" => "Egypt", "SV" => "El Salvador", "GQ" => "Equatorial Guinea", "ER" => "Eritrea", "EE" => "Estonia", "ET" => "Ethiopia", "FK" => "Falkland Islands (Malvinas)", "FO" => "Faroe Islands", "FJ" => "Fiji", "FI" => "Finland", "FR" => "France", "FX" => "France, Metropolitan", "GF" => "French Guiana", "PF" => "French Polynesia", "TF" => "French Southern Territories", "GA" => "Gabon", "GM" => "Gambia", "GE" => "Georgia", "DE" => "Germany", "GH" => "Ghana", "GI" => "Gibraltar", "GR" => "Greece", "GL" => "Greenland", "GD" => "Grenada", "GP" => "Guadeloupe", "GU" => "Guam", "GT" => "Guatemala", "GN" => "Guinea", "GW" => "Guinea-Bissau", "GY" => "Guyana", "HT" => "Haiti", "HM" => "Heard And Mc Donald Islands", "VA" => "Holy See (Vatican City State)", "HN" => "Honduras", "HK" => "Hong Kong", "HU" => "Hungary", "IS" => "Iceland", "IN" => "India", "ID" => "Indonesia", "IR" => "Iran (Islamic Republic Of)", "IQ" => "Iraq", "IE" => "Ireland", "IL" => "Israel", "IT" => "Italy", "JM" => "Jamaica", "JP" => "Japan", "JO" => "Jordan", "KZ" => "Kazakhstan", "KE" => "Kenya", "KI" => "Kiribati", "KP" => "Korea, Democratic People's Republic Of", "KR" => "Korea, Republic Of", "KW" => "Kuwait", "KG" => "Kyrgyzstan", "LA" => "Lao People's Democratic Republic", "LV" => "Latvia", "LB" => "Lebanon", "LS" => "Lesotho", "LR" => "Liberia", "LY" => "Libyan Arab Jamahiriya", "LI" => "Liechtenstein", "LT" => "Lithuania", "LU" => "Luxembourg", "MO" => "Macau", "MK" => "Macedonia, Former Yugoslav Republic Of", "MG" => "Madagascar", "MW" => "Malawi", "MY" => "Malaysia", "MV" => "Maldives", "ML" => "Mali", "MT" => "Malta", "MH" => "Marshall Islands", "MQ" => "Martinique", "MR" => "Mauritania", "MU" => "Mauritius", "YT" => "Mayotte", "MX" => "Mexico", "FM" => "Micronesia, Federated States Of", "MD" => "Moldova, Republic Of", "MC" => "Monaco", "MN" => "Mongolia", "MS" => "Montserrat", "MA" => "Morocco", "MZ" => "Mozambique", "MM" => "Myanmar", "NA" => "Namibia", "NR" => "Nauru", "NP" => "Nepal", "NL" => "Netherlands", "AN" => "Netherlands Antilles", "NC" => "New Caledonia", "NZ" => "New Zealand", "NI" => "Nicaragua", "NE" => "Niger", "NG" => "Nigeria", "NU" => "Niue", "NF" => "Norfolk Island", "MP" => "Northern Mariana Islands", "NO" => "Norway", "OM" => "Oman", "PK" => "Pakistan", "PW" => "Palau", "PA" => "Panama", "PG" => "Papua New Guinea", "PY" => "Paraguay", "PE" => "Peru", "PH" => "Philippines", "PN" => "Pitcairn", "PL" => "Poland", "PT" => "Portugal", "PR" => "Puerto Rico", "QA" => "Qatar", "RE" => "Reunion", "RO" => "Romania", "RU" => "Russian Federation", "RW" => "Rwanda", "KN" => "Saint Kitts And Nevis", "LC" => "Saint Lucia", "VC" => "Saint Vincent And The Grenadines", "WS" => "Samoa", "SM" => "San Marino", "ST" => "Sao Tome And Principe", "SA" => "Saudi Arabia", "SN" => "Senegal", "SC" => "Seychelles", "SL" => "Sierra Leone", "SG" => "Singapore", "SK" => "Slovakia (Slovak Republic)", "SI" => "Slovenia", "SB" => "Solomon Islands", "SO" => "Somalia", "ZA" => "South Africa", "GS" => "South Georgia, South Sandwich Islands", "ES" => "Spain", "LK" => "Sri Lanka", "SH" => "St. Helena", "PM" => "St. Pierre And Miquelon", "SD" => "Sudan", "SR" => "Suriname", "SJ" => "Svalbard And Jan Mayen Islands", "SZ" => "Swaziland", "SE" => "Sweden", "CH" => "Switzerland", "SY" => "Syrian Arab Republic", "TW" => "Taiwan", "TJ" => "Tajikistan", "TZ" => "Tanzania, United Republic Of", "TH" => "Thailand", "TG" => "Togo", "TK" => "Tokelau", "TO" => "Tonga", "TT" => "Trinidad And Tobago", "TN" => "Tunisia", "TR" => "Turkey", "TM" => "Turkmenistan", "TC" => "Turks And Caicos Islands", "TV" => "Tuvalu", "UG" => "Uganda", "UA" => "Ukraine", "AE" => "United Arab Emirates", "UM" => "United States Minor Outlying Islands", "UY" => "Uruguay", "UZ" => "Uzbekistan", "VU" => "Vanuatu", "VE" => "Venezuela", "VN" => "Viet Nam", "VG" => "Virgin Islands (British)", "VI" => "Virgin Islands (U.S.)", "WF" => "Wallis And Futuna Islands", "EH" => "Western Sahara", "YE" => "Yemen", "YU" => "Yugoslavia", "ZM" => "Zambia", "ZW" => "Zimbabwe" ); return $_countries; } ?> BlueSky Media