How to Code ACCESS 2022 | Browsers | Css | Htacess | Html | Html5 | Javascript | Microsoft Excel | Mysql | Mysql Dumps | Php | Vb.net | VBscript | Windows <=8 | Windows >=10 | WP | WP Plugin | WP Themes | _Misc Software | ABCDEFGHIJKLMNOPQRSTUVWXYZONPRTOFF codeid operationid title keywords application code languageid show_html show_iframe make_public viewed viewed_date language operation <- Look Inside DataConditions:Order: 1|2|3|4|5|6|7|8|50 Language Operation Title Keywords Application Code Languageid Show Html Show Iframe Make Public Viewed Viewed Date Php Date String To Time strtotime function convert $date = date('m/d/Y',strtotime($date.' + 2 days')); [compare difference] $date = date('Y-m-d',strtotime(date('Y-m-d').' + 10 days')); $priority="";if(strtotime($date)>strtotime($daterequested)) $priority="!"; [Subraction] $date = date('Y-m-d',strtotime(date('Y-m-d'))-(10*24*60*60)); <?php echo (strtotime("2009-09-28")-strtotime(date("Y-m-d H:i:s")))/3600; echo"<br>"; echo (31*24); ?> function convertdatetime($date1){ // m/d/Y format to mysql formate if($date1=="") return date("Y-m-d H:i:s"); $date1= date('Y-m-d H:i:s',strtotime($date1)); return $date1; } function convertdate($date1){ echo "dt=".$date1; $time_input = strtotime($date1);//return getDate($time_input); if(strpos($date1,"-")>0) return date("Y-m-d",$time_input); if(strpos($date1,"/")>0) return date("Y-m-d",$time_input); /* if($date1=="") return date('Y-m-d'); $date1=str_replace("/","|",$date1); //$date1=str_replace("-","|",$date1); $time=explode("|",$date1); if(strlen($time[0])==1) $time[0]="0".$time[0]; if(strlen($time[1])==1) $time[1]="0".$time[1]; $new=trim($time[2])."-".$time[0]."-".$time[1]; $date1= date('Y-m-d',strtotime($new)); return $date1; */ } Php 6 05/05/2026 Php Files Download Files While Changing Name download header $filename = "theDownloadedFileIsCalledThis.mp3"; $myFile = "/absolute/path/to/my/file.mp3"; $mm_type="application/octet-stream"; header("Cache-Control: public, must-revalidate"); header("Pragma: hack"); // WTF? oh well, it works... header("Content-Type: " . $mm_type); header("Content-Length: " .(string)(filesize($myFile)) ); header('Content-Disposition: attachment; filename="'.$filename.'"'); header("Content-Transfer-Encoding: binaryn"); readfile($myFile); Php 1404 05/05/2026 Php Files Clean Url ? url clean & # if you ever add variables to the url line you need to use this function urldecode for passing gets. $urlpart1=urldecode($urlpart1); $urlpart2=urldecode($urlpart2); $url="http://www.mydomain.com?$urlpart1&$urlpart2; Do not use it on a completed url. It will totally mess everything up. Php 1326 05/05/2026 Php Files Warning: Mkdir() [function.mkdir]: Permission Denied mkdir permission denied 777 I had difficulty using mkdir() function until I set the above folder permission to 777. So anytime you write files or create directories using php, check your folder permissions using your cpanel's file manager. 755 did not help only 777 would work for me. $topDir=dirname(__FILE__); $folder0="/".$PHPfolder; $source_dir = $topDir."/"; //.$folder0."/"; if(is_dir($topDir."/BACKED")==false){ mkdir($topDir."/BACKED", 0777,true); } Php 1196 09/09/2023 Php Files Making An Image Viewer files images viewer Sometimes i have pictures that people want to view but are too numerous or inconvenient to email. I just do a batch conversion on the images (I use Irfan view a free app) and upload them to a new folder I called "stylists". Using this script in an index.php, I dump it with the pictures. It will show them in your browser. [Create image viewer] $imagedirectory="../stylists/"; $dir = opendir($imagedirectory); while ($file = readdir($dir)){ //for ($i=1; $i<=500; $i++){ // $file = readdir($dir); $fullpath=$current_dir.$file; echo "$file"; } closedir($dir); ?> You can tweak it to your folder requirements Php 753 05/05/2026 Php Files Getting A Files Extension file folder extension File Management function browseDirectoryBFS($startDir) { // Initialize the queue with the starting directory $queue = [realpath($startDir)]; while (!empty($queue)) { // Pull the next directory from the front of the queue $currentDir = array_shift($queue); echo "=== Entering Directory: " . $currentDir . " ===n"; // Use scandir to grab all items inside the directory $items = array_diff(scandir($currentDir), ['.', '..']); // Step 1: Separate files and subdirectories at this level $filesAtCurrentLevel = []; $subDirsAtCurrentLevel = []; foreach ($items as $item) { $fullPath = $currentDir . DIRECTORY_SEPARATOR . $item; if (is_dir($fullPath)) { $subDirsAtCurrentLevel[] = $fullPath; } else { $filesAtCurrentLevel[] = $fullPath; } } // Step 2: Read/Process all files in the current folder first foreach ($filesAtCurrentLevel as $file) { echo "".basename($file) . "n"; // To read the content of the files, uncomment the lines below: // $content = file_get_contents($file); // echo "Content: " . substr($content, 0, 100) . "...n"; } // Step 3: Add subdirectories to the back of the queue // This ensures they wait until all items at the current level finish foreach ($subDirsAtCurrentLevel as $dir) { $queue[] = $dir; } echo "n"; } } // Example usage: Pass your target folder here $path = "/var/www/html/images/photo.jpg"; $pathParts = pathinfo($path); $folder = $pathParts['dirname']; // Returns: /var/www/html/images $file = $pathParts['basename']; // Returns: photo.jpg In PHP, there are several methods to retrieve the file extension from a given filename or path. 1. Using pathinfo(): The pathinfo() function is a versatile function that can extract various components of a file path, including the extension. Code 2. Using SplFileInfo::getExtension(): For object-oriented file handling, the SplFileInfo class provides the getExtension() method. Code getExtension(); echo $extension; // Outputs: jpg ?> 3. Using DirectoryIterator::getExtension(): When iterating through a directory, DirectoryIterator objects also offer the getExtension() method for individual files. Code isFile()) { echo $fileinfo->getFilename() . " extension: " . $fileinfo->getExtension() . "n"; } } ?> Note: If a file does not have an extension, these methods will typically return an empty string. If the filename starts with a dot (e.g., .htaccess), the characters following the dot will be considered the extension. Php 2 05/05/2026 Php Files Reading TXT Files fclose fgets fopen fread filesize feof read file whole line character [Reading the Whole File] The fread function reads a number of bytes from a file, up to the end of the file (whichever comes first). The filesize function returns the size of the file in bytes, and can be used with the fread function, as in the following example. $listFile = "junk.txt"; if (!($fp = fopen($listFile, "r"))) exit("Unable to open the input file, $listFile."); $buffer = fread($fp, filesize($listFile)); print "$buffer\n"; fclose($fp); ?> [Reading Line by Line] The fgets function is used to read a line at a time. The function takes two parameters, the file handle, and the number of bytes to read. The function reads data up to a new line, or the number of bytes specified (whichever comes first), and returns the line read. The following is an example of using the fgets function. if (!($fp = fopen("junk.txt", "r"))) exit("Unable to open the input file."); while (!feof($fp)) { $buffer = fgets($fp, 1024); print "$buffer\n"; } fclose($fp); ?> [Reading a Character at a time] The fgetc() function is used to read a single character from a file. Note: After a call to this function the file pointer has moved to the next character. Example The example below reads a file character by character, until the end of file is true: if (!($f=fopen("welcome.txt","r"))) exit("Unable to open file."); while (!feof($f)) { $x=fgetc($f); echo $x; } fclose($f); ?> Php 1291 05/05/2026 Php Files Write To Txt File fopen fwrite rewind fopen write file Write Text to File The easiest way to write text to a file in PHP is by using the file_put_contents() function, which handles opening, writing, and closing the file automatically. If you need more control, you can use the traditional fopen() and fwrite() method. Method 1: The Quickest Way (file_put_contents)This method overwrites the file by default or creates it if it doesn't exist. ?php $file = 'log.txt'; $text = "Hello, World!n"; // Overwrite file content (or create file if it doesn't exist) file_put_contents($file, $text); Use code with caution. To Append Text (Don't Overwrite) Pass the FILE_APPEND flag as the third parameter to add text to the end of the file. php ?php $file = 'log.txt'; $text = "This line is appended.n"; // Append text to the file file_put_contents($file, $text, FILE_APPEND); Use code with caution. Method 2: The Traditional Way (fopen + fwrite) Use this if you are performing multiple write operations on an open file stream. $file = 'log.txt'; $text = "Writing with fwrite.n"; // Open file for writing ('w' overwrites, 'a' appends) $handle = fopen($file, 'w') or die('Cannot open file'); // Write data fwrite($handle, $text); // Always close the handle fclose($handle); Use code with caution. Quick Reference: File Modes for fopen 'w' (Write-only): Erases the file content or creates a new file if it doesn't exist. 'a' (Append): Preserves existing data and moves the pointer to the end of the file. Writing to Files The fwrite function is used to write a string, or part of a string to a file. The function takes three parameters, the file handle, the string to write, and the number of bytes to write. If the number of bytes is omitted, the whole string is written to the file. If you want the lines to appear on separate lines in the file, use the \n character. Note: Windows requires a carriage return character as well as a new line character, so if you're using Windows, terminate the string with \r\n. The following example logs the visitor to a file, then displays all the entries in the file. $logFile = "stats.txt"; // Open the file in append/read mode $fp = fopen($logFile, "a+"); // Create a string containing the user details $userDetails = $HTTP_USER_AGENT; if (isset($HTTP_REFERER)) $userDetails = $userDetails . " $HTTP_REFERER \r\n"; else $userDetails = $userDetails . "\r\n"; // Write the user details to the file fwrite($fp, "$userDetails"); // Move to the start of the file rewind($fp); $entries = 0; // Display each line in the file while(!feof($fp)) { $buffer = fgets($fp, 1024); if ($buffer != "") { print $buffer; $entries++; } } // Show a summary print "There are $entries entries in the log file"; fclose ($fp); ?> Insert Character by Position these are results for php read text line by line and insert character in position 9 of each line Search instead for php read text line by line and insert character in poition 9 of each line AI Overview You can read a text file line by line in PHP using fgets() or file() and insert a character at position 9 using substr_replace() [?php function insert_character($value){ $inputFile = 'input.txt'; file_put_contents($inputfile, $value); $outputFile = 'output.txt'; $charToInsert[0] = $_POST["char1"];$charToInsert[1] = $_POST["char2"]; // Change to your desired character $position[0] = $_POST["pos1"]; $position[1] = $_POST["pos2"]; // 0-indexed position 9 (10th character) $handle = fopen($inputFile, 'r'); $output = fopen($outputFile, 'w'); if ($handle && $output) { while (($line = fgets($handle)) !== false) { // Remove trailing newline for accurate length/position handling $eol = ''; if (substr($line, -1) === "n" || substr($line, -1) === "r") { $eol = PHP_EOL; $line = rtrim($line, "rn"); } // Insert character if line is long enough, otherwise pad or append if (strlen($line) >= $position) { $newLine = substr_replace($line, $charToInsert, $position[0], 0); } else { // Optional: pad with spaces if line is shorter than 9 chars $newLine = str_pad($line, $position[0], ' ') . $charToInsert[0]; } fwrite($output, $newLine . $eol); } fclose($handle); fclose($output); if (file_exists($outputfile)) { return file_get_contents($outputfile); //echo $text; } else { echo "File not found.";} echo "Processing complete!"; } else { echo "Error opening files."; } } ?] Key Functions Usedfopen(): Opens the source file for reading and a destination file for writing. fgets(): Reads the file line by line safely to conserve memory. substr_replace(): Inserts the character at the specified index without removing existing text (using a length of 0). Php 993 09/27/2026 Php Files Config.php config Config.php config.php-> require_once($_SERVER['DOCUMENT_ROOT']."/activate75.php"); if($_SERVER['REMOTE_ADDR']=="127.0.0.1"){ $server='localhost';$user='greatone';$password='gr38t0n3';$database='hairshoppe'; $_SESSION['LEVEL']=10; $_SESSION["EMPLOYEE"]=1;} else{ $server='localhost';$user='softwax3_Steve99';$password='pay99.bill';$database='softwax3_hairShoppe'; }// if($_SESSION['EMPLOYEE']==""){ echo "Login Again";exit; } } $LEVEL=$_SESSION['LEVEL'];$debug=true;$domain="softwarewebdesign.com|127.0.0.1"; $sessionListSave="EMPLOYEE";$lightbox="https://www.softwarewebdesign.com"; define('SWD_KEY', 'KingOfKings'); setcookie("humans_21909", "", time() - 3600, "/"); //define('SWD_AUTHENTICATE', true); // inactivate75.php activate75.php -> if($bypass!=true){ $user='softwax3_build99';$password='Web2Build.now';$database='softwax3_SoftwareUsers'; $connection = swd_mysql("localhost", $user,$password,$database); //if($appid>"636390303046554897"){$qu=new mysqli_swd();}else{$qu=new dbase();} $qu=new mysqli_swd(); $sql="SELECT lock_device FROM users WHERE device_name='".$_COOKIE["machine_id"]."'"; $qu->dbsql($sql); if($qu->num==0 || $qu->data1[0]==1) { echo "You are locked out";exit; } $_SESSION['LEVEL']=10; mysqli_close($connection); define('SWD_AUTHENTICATE', true); }define('SWD_KEY', 'JesusIsLord'); if($bypass==true){define('SWD_AUTHENTICATE', true);} Php 2 05/05/2026 Php Files Upload Multiple Files multiple files upload download Developer example1: Select and upload multiple files to the server Upload Files Select files to upload: file_upload.php The file_upload.php script will handle the file uploading and show the upload status. / Check if form was submitted if(isset($_POST['submit'])) { // Configure upload directory and allowed file types $upload_dir = 'uploads'.DIRECTORY_SEPARATOR; $allowed_types = array('jpg', 'png', 'jpeg', 'gif'); // Define maxsize for files i.e 2MB $maxsize = 2 * 1024 * 1024; // Checks if user sent an empty form if(!empty(array_filter($_FILES['files']['name']))) { // Loop through each file in files[] array foreach ($_FILES['files']['tmp_name'] as $key => $value) { $file_tmpname = $_FILES['files']['tmp_name'][$key]; $file_name = $_FILES['files']['name'][$key]; $file_size = $_FILES['files']['size'][$key]; $file_ext = pathinfo($file_name, PATHINFO_EXTENSION); // Set upload file path $filepath = $upload_dir.$file_name; // Check file type is allowed or not if(in_array(strtolower($file_ext), $allowed_types)) { // Verify file size - 2MB max if ($file_size > $maxsize) echo "Error: File size is larger than the allowed limit."; // If file with name already exist then append time in // front of name of the file to avoid overwriting of file if(file_exists($filepath)) { $filepath = $upload_dir.time().$file_name; if( move_uploaded_file($file_tmpname, $filepath)) { echo "{$file_name} successfully uploaded "; } else { echo "Error uploading {$file_name} "; } } else { if( move_uploaded_file($file_tmpname, $filepath)) { echo "{$file_name} successfully uploaded "; } else { echo "Error uploading {$file_name} "; } } } else { // If file extension not valid echo "Error uploading {$file_name} "; echo "({$file_ext} file type is not allowed)"; } } } else { // If no files selected echo "No files selected."; } } ?> Example 2: PHP: //$files = array_filter($_FILES['upload']['name']); //something like that to be used before processing files. // Count # of uploaded files in array $total = count($_FILES['upload']['name']); // Loop through each file for( $i=0 ; $i < $total ; $i++ ) { //Get the temp file path $tmpFilePath = $_FILES['upload']['tmp_name'][$i]; //Make sure we have a file path if ($tmpFilePath != ""){ //Setup our new file path $newFilePath = "./uploadFiles/" . $_FILES['upload']['name'][$i]; //Upload the file into the temp dir if(move_uploaded_file($tmpFilePath, $newFilePath)) { //Handle other code here } } } ==================================================== $url) { $file = $save_path . '/' . basename($url); if(!is_file($file)) { $curl_handles[$key] = curl_init($url); $file_pointers[$key] = fopen($file, "w"); curl_setopt($curl_handles[$key], CURLOPT_FILE, $file_pointers[$key]); curl_setopt($curl_handles[$key], CURLOPT_HEADER, 0); curl_setopt($curl_handles[$key], CURLOPT_CONNECTTIMEOUT, 60); curl_multi_add_handle($multi_handle,$curl_handles[$key]); } } // Download the files do { curl_multi_exec($multi_handle,$running); } while ($running > 0); // Free up objects foreach ($urls as $key => $url) { curl_multi_remove_handle($multi_handle, $curl_handles[$key]); curl_close($curl_handles[$key]); fclose ($file_pointers[$key]); } curl_multi_close($multi_handle); } // Files to download $urls = [ 'http://static.scribd.com/docs/cdbwpohq0ayey.pdf', 'http://static.scribd.com/docs/8wyxlxfufftas.pdf', 'http://static.scribd.com/docs/9q29bbglnc2gk.pdf' ]; multiple_download($urls); Php 4 10/01/2026 Php Files Activate75.php activate security Developer //require_once($_SERVER['DOCUMENT_ROOT']."/activate75.php"); if($bypass!=true){ $appid="636390303046554890"; $user='softwax3_build99';$password='Web2Build.now';$database='softwax3_SoftwareUsers'; $connection = swd_mysql("localhost", $user,$password,$database); //if($appid>"636390303046554897"){$qu=new mysqli_swd();}else{$qu=new dbase();} $qu=new mysqli_swd(); $sql="SELECT lock_device,security_level FROM users WHERE device_name='".$_COOKIE["machine_id"]."'"; $qu->dbsql($sql); if($qu->num==0 || $qu->data1[0]==1) { echo "You are locked out";exit; } $_SESSION['LEVEL']=$qu->data1[1]; $LEVEL=$qu->data1[1]; define('SWD_AUTHENTICATE', true);define('SWD_KEY', 'JesusIsLord'); } if($bypass==true){define('SWD_AUTHENTICATE', true);} ?> Php 1 05/05/2026 Php Files Create Directory File List After Database Backup file list database backup example Backup Sites %s', escapeshellarg($host), escapeshellarg($user), escapeshellarg($pass), escapeshellarg($dbname), escapeshellarg($filename) ); $output = []; $result_code = 0; // Execute the command exec($command, $output, $result_code); if ($result_code === 0) { return "Database dump successful."; } else { return "Error creating database dump. Command output: " . implode("n", $output); } } // Configuration variables //$server='localhost';$user='softwax3_Steve99';$password='pay99.bill';$database='softwax3_accounting'; $DBHOST = $server; $DBUSER = $user; $DBPASS = $password; $DBNAME = $database; $BACKUP_FILE = 'backup_'.$database. date('Y-m-d_H-i-s') . '.sql'; // Run the backup function $message = backup_mysql_database($DBHOST, $DBUSER, $DBPASS, $DBNAME, $BACKUP_FILE); echo $message; $newname=str_replace(".sql",".txt",$BACKUP_FILE); rename($BACKUP_FILE, $newname); $current_dir="./"; $dir = opendir($current_dir); echo "directory=".$current_dir; while ($file = readdir($dir)){ $fullpath=$current_dir.$file; $filedate=date('Y-m-j', filemtime($fullpath)); $fsize=filesize($fullpath)/1000; $fsize=(int)$fsize;$fsize=$fsize/1000; $bulletin[]=$file."@".$fsize."@".$filedate; } closedir($dir); $count1=count($bulletin); sort($bulletin); reset($bulletin); //if($DI=='')ECHO "?DI="; $dis.="Files(by Name)"; //while (list ($key, $val) = each ($bulletin)){ foreach($bulletin as $key=>$val) { //} while (list ($key, $val) = each ($bulletin)){ $mark=explode('@',$val); $count+=1; if($mark[0]=="index.php")continue; if(strpos($mark[0],".")==0) $dis.="".$mark[0]."Directory"; else $dis.="".$mark[0]."(".$mark[1].") MB ".$mark[2].""; //if($count==(int)($count1/2)) echo " "; } $dis.=""; echo $dis; ?> Php 1 05/05/2026 Php Files Copy A File In PHP file copy move Copying & Moving Files Copy File$source = 'uploads/document.pdf'; $destination = 'backup/document.pdf'; // Must include the filename if (copy($source, $destination)) { echo "File copied successfully!"; } else { echo "Failed to copy file."; } Keeping the Same Filename Dynamically If you have a path to a folder and want to keep the original file's name, combine copy() with basename() to extract the filename $sourceFile = 'uploads/images/photo.jpg'; $targetDir = 'archive/'; // Safely joins the directory and the original file name $destinationFile = $targetDir . basename($sourceFile); if (copy($sourceFile, $destinationFile)) { echo "File copied to: " . $destinationFile; } Copy Across Multiple Folders [?php $title="ledger View"; $appid="639016745369596833";$appidLast='';$bodyAppend=''; error_reporting( E_ERROR ); $folder_list=explode(",","accounting,ACCT,Bible/admin31,CODE,EMAIL,HAIRSHOPPE,invoice/admin31,iqofpost/admin31,MAP,scripture,WINTERBROS/admin31,WinterBrother/admin31"); foreach($folder_list as $k=>$value) { $source = __DIR__ ."/".$value. '/configBKUP.php'; $destination = __DIR__ ."/".$value. '/config.php'; if (file_exists($source)) { if (copy($source, $destination)) { touch($destination); //echo "Config file restored successfully."; } else { echo "copy problem ".$source; exit; } } else { echo "file $source does not exist."; } // look for htacess $source = __DIR__ ."/".$value. '/.htaccessBKUP'; $destination = __DIR__ ."/".$value. '/.htaccess.php'; if (file_exists($source)) { if (copy($source, $destination)) { touch($destination); //echo "Config file restored successfully."; } else { echo "copy problem ".$source; exit; } } else { echo "file $source does not exist."; } } echo "It has run"; ?] Merge Many Files Into One [?php $file1 = 'destination.txt'; $file2 = 'source_to_merge.txt'; // Read the contents of the second file $contents2 = file_get_contents($file2); // Append it to the destination file // FILE_APPEND prevents overwriting the existing data in destination.txt file_put_contents($file1, $contents2, FILE_APPEND); ?] Move Files$old_path = 'images/photo.jpg'; $new_path = 'archive/photo.jpg'; // Ensure the target directory exists before moving if (!is_dir('archive')) { mkdir('archive', 0755, true); } // Move the file if (rename($old_path, $new_path)) { echo "File moved successfully."; } else { echo "Failed to move the file."; } To copy a file in PHP, you use the built-in copy() function. This function takes the source file path and the destination path as arguments and returns true on success or false on failure. Syntax php bool copy(string $source, string $destination, resource $context = null): bool $source (Required): The path to the original file you want to copy. $destination (Required): The path, including the new filename, where the file will be copied. If the destination file already exists, it will be overwritten. $context (Optional): A context resource created with stream_context_create(). Example Here is a basic example of how to copy a file and check the result: =?php // Specify the source file path $source_file = 'path/to/original_file.txt'; // Specify the destination path, including the new filename $destination_file = 'path/to/new_directory/copied_file.txt'; // Use the copy() function if (copy($source_file, $destination_file)) { echo "File copied successfully!"; } else { echo "Something went wrong while copying the file. Check permissions."; } ?= Important Considerations File Permissions: The PHP script must have permission to read the source file and write to the destination directory. Permission errors are a common reason for failure. Destination Path: The destination must include the new filename, not just the directory name. For example, you need .../new_dir/copied.txt, not just .../new_dir/. Error Handling: The copy() function returns a boolean, so it is important to use an if statement to handle potential errors gracefully. Moving vs. Copying: If you want to move a file (delete the original after copying), use the rename() function instead. Uploaded Files: For handling files uploaded via an HTML form (HTTP POST method), you must use the specialized move_uploaded_file() function, not copy(). Php 1 05/05/2026 Php Form Using Arrays In Forms form arrays Form Pasing Data form data using arrays Enter your top filter replace variables: Submit Response to form [?php if ($_SERVER["REQUEST_METHOD"] === "POST") { // $_POST['books'] is a regular PHP array //$books = $_POST['books'] ?? []; $filters = $_POST['filter'] ?? []; foreach ($filterss as $index => $filter) { // Sanitize the input to prevent XSS $safe_filter = htmlspecialchars($filter); echo "Filter " . ($index + 1) . ": " . $safe_filter . ""; } $replaces = $_POST['replace'] ?? []; foreach ($replaces as $index => $replace) { // Sanitize the input to prevent XSS $safe_replace = htmlspecialchars($replace); echo "Replace " . ($index + 1) . ": " . $safe_replace . ""; } } ?] Php 4 09/12/2026 Php Formatting Preparing Url For Passing With Php url encoding encode special characters Special characters such as spaces will mess up a url to the point where it will not work. PHP has these functions to handle this. Your will need to apply for each parameter passed or the "&" sign will be replaced for passing $_GETS rawurlencode() urlencode($var1) and urldecode($var1) //return the information into a readable format Php 809 05/05/2026 Php Formatting Physically Resize An Image resize image /* * File: SimpleImage.php * Author: Simon Jarvis * Copyright: 2006 Simon Jarvis * Date: 08/11/06 * Link: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details: * http://www.gnu.org/licenses/gpl.html * */ class SimpleImage { var $image; var $image_type; function load($filename) { $image_info = getimagesize($filename); $this->image_type = $image_info[2]; if( $this->image_type == IMAGETYPE_JPEG ) { $this->image = imagecreatefromjpeg($filename); } elseif( $this->image_type == IMAGETYPE_GIF ) { $this->image = imagecreatefromgif($filename); } elseif( $this->image_type == IMAGETYPE_PNG ) { $this->image = imagecreatefrompng($filename); } } function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this->image,$filename,$compression); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this->image,$filename); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image,$filename); } if( $permissions != null) { chmod($filename,$permissions); } } function output($image_type=IMAGETYPE_JPEG) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this->image); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this->image); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image); } } function getWidth() { return imagesx($this->image); } function getHeight() { return imagesy($this->image); } function resizeToHeight($height) { $ratio = $height / $this->getHeight(); $width = $this->getWidth() * $ratio; $this->resize($width,$height); } function resizeToWidth($width) { $ratio = $width / $this->getWidth(); $height = $this->getheight() * $ratio; $this->resize($width,$height); } function scale($scale) { $width = $this->getWidth() * $scale/100; $height = $this->getheight() * $scale/100; $this->resize($width,$height); } function resize($width,$height) { $new_image = imagecreatetruecolor($width, $height); imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight()); $this->image = $new_image; } } ?> ============ Save the above file as SimpleImage.php and take a look at the following examples of how to use the script. The first example below will load a file named picture.jpg resize it to 250 pixels wide and 400 pixels high and resave it as picture2.jpg include('SimpleImage.php'); $image = new SimpleImage(); $image->load('picture.jpg'); $image->resize(250,400); $image->save('picture2.jpg'); ?> If you want to resize to a specifed width but keep the dimensions ratio the same then the script can work out the required height for you, just use the resizeToWidth function. include('SimpleImage.php'); $image = new SimpleImage(); $image->load('picture.jpg'); $image->resizeToWidth(250); $image->save('picture2.jpg'); ?> You may wish to scale an image to a specified percentage like the following which will resize the image to 50% of its original width and height include('SimpleImage.php'); $image = new SimpleImage(); $image->load('picture.jpg'); $image->scale(50); $image->save('picture2.jpg'); ?> You can of course do more than one thing at once. The following example will create two new images with heights of 200 pixels and 500 pixels include('SimpleImage.php'); $image = new SimpleImage(); $image->load('picture.jpg'); $image->resizeToHeight(500); $image->save('picture2.jpg'); $image->resizeToHeight(200); $image->save('picture3.jpg'); ?> The output function lets you output the image straight to the browser without having to save the file. Its useful for on the fly thumbnail generation header('Content-Type: image/jpeg'); include('SimpleImage.php'); $image = new SimpleImage(); $image->load('picture.jpg'); $image->resizeToWidth(150); $image->output(); ?> The following example will resize and save an image which has been uploaded via a form if( isset($_POST['submit']) ) { include('SimpleImage.php'); $image = new SimpleImage(); $image->load($_FILES['uploaded_image']['tmp_name']); $image->resizeToWidth(150); $image->output(); } else { ?> } ?> Php 1190 05/05/2026 Php Formatting Strip Html Tags strip html Library $text = 'Test paragraph. Other text'; echo strip_tags($text); echo "n"; // Allow and echo strip_tags($text, ''); // as of PHP 7.4.0 the line above can be written as: // echo strip_tags($text, ['p', 'a']); ?> The strip_tags() function strips a string from HTML, XML, and PHP tags. Note: HTML comments are always stripped. This cannot be changed with the allow parameter. Note: This function is binary-safe. Syntax strip_tags(string,allow) Parameter Values Parameter Description string Required. Specifies the string to check allow Optional. Specifies allowable tags. These tags will not be removed Technical Details Return Value: Returns the stripped string Example Strip the string from HTML tags, but allow <b> tags to be used: <?php echo strip_tags("Hello <b><i>world!</i></b>","<b>"); ?> Php 5 05/05/2026 Php Formatting Formating For Numbers number format Ereg Eregi Preg_match Preg Match keywords: ereg eregi preg_match preg match Syntax: preg_replace( $pattern, $replacement, $subject, $limit, $count ) Return Value: This function returns an array if the subject parameter is an array, or a string otherwise. Example: In this example we use preg_replace to remove non-numeric characters from a string, leaving only the numbers. It then prints the extracted numbers from the string. // PHP program to illustrate // preg_replace function // Declare a variable and initialize it $geeks = 'Welcome 2 Geeks 4 Geeks.'; // Filter the Numbers from String $int_var = preg_replace('/[^0-9]/', '', $geeks); // print output of function echo("The numbers are: $int_var n"); ?> Output The numbers are: 24 =========================================== filter_var You can use filter_var and sanitize the string to only include integers. $s = "Lesson 001: Complete"; echo filter_var($s, FILTER_SANITIZE_NUMBER_INT); ========================================== $s = "Lesson 001: Complete"; preg_match("/([0-9]+)/", $s, $matches); echo $matches[1]; ========================================== number_format (1234.567); //Returns the number 1,235 number_format (1234.567, 2); //Returns the number 1,234.57 number_format (1234.567, 2, ',', ' '); //Returns the number 1 234,57 number_format (1234.567, 1, 'a', 'b'); //Returns the number 1b234a6 Php 3 05/05/2026 Php Formatting Htmlarea Example html area SWD Bible Form 'WP PLUGIN') * Description: Use short code to check for priveleges and creates Admin access. * Version: 1.0 * Author: Software Web Design * Author URI: https://softwarewebdesign.com */ if(file_exists("header_global.php")) require_once("header_global.php"); include("scripture_header.php"); ?> "; ?> dbsql($sql);$result=$r->data;$num=$r->num; if ($num > 0) { while($row = $result->fetch_assoc()) { $res[$row["COLUMN_NAME"]]= $row["CHARACTER_MAXIMUM_LENGTH"]; } } $varVerify="scriptureVerify.php"; $varView="scriptureView.php"; $FORM=$_REQUEST['FORM'];$PID=$_GET['PID'];$INX=$_GET['INX'];$NUM=$_GET['NUM'];$ALPHA=$_GET['ALPHA'];$VIEW=$_GET['VIEW']; $url1=$_REQUEST['url1']; $actual_link = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; $part=parse_url($actual_link); $passVariable=$part["query"]; // `Start Form` if($FORM=='')$FORM=0; $ciphering = "AES-128-CTR";$iv_length = openssl_cipher_iv_length($ciphering);$options_key = 0; $decryption_key = SWD_KEY;$decryption_iv = '1234567891011121'; switch($FORM){ Case 0: $caption99='New '; if($SVE==''){ $bookid=''; $chapter=''; $keywords=''; $scripture=''; $folder=''; $scripture2=''; } // `New Form Default` break; default: //Update Form $caption99='+++++++ Update +++++'; $query="SELECT * FROM scripture WHERE scriptureid=$PID"; $r->dbsql($query);$row=$r->data1; //`Form Variable Start` $scriptureid=$row['scriptureid']; $bookid=$row['bookid']; $chapter=$row['chapter']; $keywords=$row['keywords']; $keywords=replaceForm($keywords); $scripture=$row['scripture']; $scripture=replaceForm($scripture); $folder=$row['folder']; $folder=replaceForm($folder); $scripture2=$row['scripture2']; $scripture2=replaceForm($scripture2); break; } echo ""; //Print the Form up $dis1 = "$caption99 Form scripture "; if($FORM==1){ $dis1.=""; } // `Form Add Variables` $dis1.="n"; $dis1.=""; $where_book=""; $orderby="ORDER BY book"; $grouping=false; // `Form Combo Start bookid` section to add code to the txx file here for combo variable $STID=$bookid; $query="SELECT * FROM books $where_book $orderby "; //queryMODbooks $r->dbsql($query);$result=$r->data;$num=$r->num; $dis1.= "Bookid:----------------n"; For ($i=0; $i< $num; $i++){ $row=$r->dbRow($result); $bookid=replacepunctuation($row['bookid']); $book=replacepunctuation($row['book']); // `Form Combo bookid` section to add code to the txx file here for combo alterations if ($bookid == $STID){ $dis1 .= "$bookn"; } else{ $dis1 .= "$bookn"; } } if($grouping==true)$dis1 .= ""; $dis1 .= ""; $dis1.="nChapter: "; $dis1.="nKeywords:".$res["keywords"]." $keywords"; $dis1.="nScripture:".$res["scripture"]." $scripture"; $where_version=""; $orderby="ORDER BY version"; $grouping=false; // `Form Combo Start folder` section to add code to the txx file here for combo variable $STID=$folder; $query="SELECT * FROM versions $where_version $orderby "; //queryMODversions $r->dbsql($query);$result=$r->data;$num=$r->num; $dis1.= "Folder:----------------n"; For ($i=0; $i< $num; $i++){ $row=$r->dbRow($result); $folder=replacepunctuation($row['folder']); $version=replacepunctuation($row['version']); // `Form Combo folder` section to add code to the txx file here for combo alterations if ($folder == $STID){ $dis1 .= "$versionn"; } else{ $dis1 .= "$versionn"; } } if($grouping==true)$dis1 .= ""; $dis1 .= ""; $dis1.="nScripture2:".$res["scripture2"]." $scripture2"; $dis1.="n"; echo $dis1; ?> Php 2 05/05/2026 Php Formatting Html_entity_decode decode format Restoring Html Saves (PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8) html_entity_decode — Convert HTML entities to their corresponding characters Description ¶ html_entity_decode(string $string, int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ?string $encoding = null): string html_entity_decode() is the opposite of htmlentities() in that it converts HTML entities in the string to their corresponding characters. More precisely, this function decodes all the entities (including all numeric entities) that a) are necessarily valid for the chosen document type — i.e., for XML, this function does not decode named entities that might be defined in some DTD — and b) whose character or characters are in the coded character set associated with the chosen encoding and are permitted in the chosen document type. All other entities are left as is. Parameters ¶ string The input string. flags A bitmask of one or more of the following flags, which specify how to handle quotes and which document type to use. The default is ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401. Available flags constants Constant Name Description ENT_COMPAT Will convert double-quotes and leave single-quotes alone. ENT_QUOTES Will convert both double and single quotes. ENT_NOQUOTES Will leave both double and single quotes unconverted. ENT_SUBSTITUTE Replace invalid code unit sequences with a Unicode Replacement Character U+FFFD (UTF-8) or &#xFFFD; (otherwise) instead of returning an empty string. ENT_HTML401 Handle code as HTML 4.01. ENT_XML1 Handle code as XML 1. ENT_XHTML Handle code as XHTML. ENT_HTML5 Handle code as HTML 5. encoding An optional argument defining the encoding used when converting characters. If omitted, encoding defaults to the value of the default_charset configuration option. Although this argument is technically optional, you are highly encouraged to specify the correct value for your code if the default_charset configuration option may be set incorrectly for the given input. The following character sets are supported: Supported charsets Charset Aliases Description ISO-8859-1 ISO8859-1 Western European, Latin-1. ISO-8859-5 ISO8859-5 Little used cyrillic charset (Latin/Cyrillic). ISO-8859-15 ISO8859-15 Western European, Latin-9. Adds the Euro sign, French and Finnish letters missing in Latin-1 (ISO-8859-1). UTF-8 ASCII compatible multi-byte 8-bit Unicode. cp866 ibm866, 866 DOS-specific Cyrillic charset. cp1251 Windows-1251, win-1251, 1251 Windows-specific Cyrillic charset. cp1252 Windows-1252, 1252 Windows specific charset for Western European. KOI8-R koi8-ru, koi8r Russian. BIG5 950 Traditional Chinese, mainly used in Taiwan. GB2312 936 Simplified Chinese, national standard character set. BIG5-HKSCS Big5 with Hong Kong extensions, Traditional Chinese. Shift_JIS SJIS, SJIS-win, cp932, 932 Japanese EUC-JP EUCJP, eucJP-win Japanese MacRoman Charset that was used by Mac OS. '' An empty string activates detection from script encoding (Zend multibyte), default_charset and current locale (see nl_langinfo() and setlocale()), in this order. Not recommended. Note: Any other character sets are not recognized. The default encoding will be used instead and a warning will be emitted. Return Values ¶ Returns the decoded string. Changelog ¶ Version Description 8.1.0 flags changed from ENT_COMPAT to ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401. 8.0.0 encoding is nullable now. Examples ¶ Example #1 Decoding HTML entities <?php $orig = "I'll "walk" the <b>dog</b> now"; $a = htmlentities($orig); $b = html_entity_decode($a); echo $a; // I'll &quot;walk&quot; the &lt;b&gt;dog&lt;/b&gt; now echo $b; // I'll "walk" the <b>dog</b> now ?> Notes ¶ Php 3 05/05/2026 Php Formatting Htmlentities html convert format Html, Php Saves (PHP 4, PHP 5, PHP 7, PHP 8) htmlentities — Convert all applicable characters to HTML entities Description ¶ htmlentities( string $string, int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ?string $encoding = null, bool $double_encode = true ): string This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities. The get_html_translation_table() function can be used to return the translation table used dependent upon the provided flags constants. If you want to decode instead (the reverse) you can use html_entity_decode(). Parameters ¶ string The input string. flags A bitmask of one or more of the following flags, which specify how to handle quotes, invalid code unit sequences and the used document type. The default is ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401. Available flags constants Constant Name Description ENT_COMPAT Will convert double-quotes and leave single-quotes alone. ENT_QUOTES Will convert both double and single quotes. ENT_NOQUOTES Will leave both double and single quotes unconverted. ENT_IGNORE Silently discard invalid code unit sequences instead of returning an empty string. Using this flag is discouraged as it » may have security implications. ENT_SUBSTITUTE Replace invalid code unit sequences with a Unicode Replacement Character U+FFFD (UTF-8) or &#FFFD; (otherwise) instead of returning an empty string. ENT_DISALLOWED Replace invalid code points for the given document type with a Unicode Replacement Character U+FFFD (UTF-8) or &#FFFD; (otherwise) instead of leaving them as is. This may be useful, for instance, to ensure the well-formedness of XML documents with embedded external content. ENT_HTML401 Handle code as HTML 4.01. ENT_XML1 Handle code as XML 1. ENT_XHTML Handle code as XHTML. ENT_HTML5 Handle code as HTML 5. encoding An optional argument defining the encoding used when converting characters. If omitted, encoding defaults to the value of the default_charset configuration option. Although this argument is technically optional, you are highly encouraged to specify the correct value for your code if the default_charset configuration option may be set incorrectly for the given input. The following character sets are supported: Supported charsets Charset Aliases Description ISO-8859-1 ISO8859-1 Western European, Latin-1. ISO-8859-5 ISO8859-5 Little used cyrillic charset (Latin/Cyrillic). ISO-8859-15 ISO8859-15 Western European, Latin-9. Adds the Euro sign, French and Finnish letters missing in Latin-1 (ISO-8859-1). UTF-8 ASCII compatible multi-byte 8-bit Unicode. cp866 ibm866, 866 DOS-specific Cyrillic charset. cp1251 Windows-1251, win-1251, 1251 Windows-specific Cyrillic charset. cp1252 Windows-1252, 1252 Windows specific charset for Western European. KOI8-R koi8-ru, koi8r Russian. BIG5 950 Traditional Chinese, mainly used in Taiwan. GB2312 936 Simplified Chinese, national standard character set. BIG5-HKSCS Big5 with Hong Kong extensions, Traditional Chinese. Shift_JIS SJIS, SJIS-win, cp932, 932 Japanese EUC-JP EUCJP, eucJP-win Japanese MacRoman Charset that was used by Mac OS. '' An empty string activates detection from script encoding (Zend multibyte), default_charset and current locale (see nl_langinfo() and setlocale()), in this order. Not recommended. Note: Any other character sets are not recognized. The default encoding will be used instead and a warning will be emitted. double_encode When double_encode is turned off PHP will not encode existing html entities. The default is to convert everything. Return Values ¶ Returns the encoded string. If the input string contains an invalid code unit sequence within the given encoding an empty string will be returned, unless either the ENT_IGNORE or ENT_SUBSTITUTE flags are set. Changelog ¶ Version Description 8.1.0 flags changed from ENT_COMPAT to ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401. 8.0.0 encoding is nullable now. Examples ¶ Example #1 A htmlentities() example <?php $str = "A 'quote' is <b>bold</b>"; // Outputs: A 'quote' is <b>bold</b> echo htmlentities($str); // Outputs: A 'quote' is <b>bold</b> echo htmlentities($str, ENT_QUOTES); ?> Example #2 Usage of ENT_IGNORE <?php $str = "x8F!!!"; // Outputs an empty string echo htmlentities($str, ENT_QUOTES, "UTF-8"); // Outputs "!!!" echo htmlentities($str, ENT_QUOTES | ENT_IGNORE, "UTF-8"); ?> See Also ¶ html_entity_decode() - Convert HTML entities to their corresponding characters get_html_translation_table() - Returns the translation table used by htmlspecialchars and htmlentities htmlspecialchars() - Convert special characters to HTML entities nl2br() - Inserts HTML line breaks before all newlines in a string urlencode() - URL-encodes string Php 3 05/05/2026 Php Formatting Remove Fancy Ascii ascii replace delete clean string String Cleanup function clean_keyboard_characters($text) { // 1. Replace Unicode smart/curly quotes and typographical dashes $replacements = [ // Left and right double quotes -> " 'x{201C}' => '"', 'x{201D}' => '"', // Left and right single quotes / apostrophes -> ' 'x{2018}' => "'", 'x{2019}' => "'", // En dash and Em dash -> - 'x{2013}' => '-', 'x{2014}' => '-' ]; foreach ($replacements as $pattern => $replace) { $text = preg_replace('/' . $pattern . '/u', $replace, $text); } // 2. Replace the black diamond question mark (EF BF BD in hex) // Often caused by UTF-8 decoding errors; replaced with a standard dash or space $text = str_replace("xEFxBFxBD", chr(160), $text); return $text; } //scriptureView uses this function Php 2 07/23/2026 Php Function Create Graphic Button On The Fly grapic button image color session_start(); session_register('sessioncode'); //Header("Content-type: image/jpeg"); //echo "beg test"; $filename = "images/image1.gif"; $im = imagecreate(55, 15); $bg = imagecolorallocate($im, 255, 255, 255); $textcolor = imagecolorallocate($im, 100, 100, 100); imagecolortransparent($im, $bg); //imagestring($im, 5, 0, 0, substr(strtoupper(md5("Myshit".$sessioncode)), 0,6), $textcolor); imagestring($im, 5, 0, 0, substr(strtoupper("Myshit"), 0,6), $textcolor); imageGif($im,$filename); ImageDestroy($im); //*************************************************************** $filename = "images/image.gif"; $img = ImageCreate(200,20); $red = ImageColorAllocate($img, 255, 0, 0); $white = ImageColorAllocate($img, 255, 255, 255); ImageString($img, 3, 3, 3, "Uh, this is an image!", $white); ImageGif($img, $filename); ImageDestroy($img); echo ""; echo "Finished"; exit(); ?> Php 1236 05/05/2026 Php Function Ziping And Unziping Server Folders Using Php zip unzip directory folder backup mysql backup directory // I use a browser script that send the proper data to back up since if have multiple accounts. I separate the small files in one zip and large files in another. Under case 1. you will notice mp3 and zip this prevents bloated zips which may fail. Video and music should be done seperately from the rest of the files. I included a mysql backup that gets the data and makes a .sql file if you give it database information. class Utils{ public static function listDirectory($dir) { $result = array(); $root = scandir($dir); foreach($root as $value) { if($value === '.' || $value === '..') { continue; } if(is_file("$dir$value")) { $result[] = "$dir$value"; continue; } if(is_dir("$dir$value")) { $result[] = "$dir$value/"; } foreach(self::listDirectory("$dir$value/") as $value) { $result[] = $value; } } return $result; } } /* use if you need to rename or auto download $file = '/path/to/zip/file.zip'; $file_name = basename($file); header("Content-Type: application/zip"); header("Content-Disposition: attachment; filename=" . $file_name); header("Content-Length: " . filesize($file)); readfile($file); exit; */ $project=$_GET["pr"];$projectid=$_GET["id"];$PHPfolder=$_GET["fo"];$PHPdatabase=$_GET["db"];$user=$_GET["us"]; $password=$_GET["pa"];$return1=$_GET["re"]; $exportstring="pr=$project&fo=$PHPfolder&db=$PHPdatabase&us=$user&pa=$password&re=$return1&id=$projectid"; $server="localhost"; $AC=$_GET["L"]; $topDir=dirname(__FILE__); $folder0="/".$PHPfolder; $source_dir = $topDir.$folder0."/"; if(strlen($PHPfolder)==1)$source_dir = $topDir."/"; // For those sites where zipdemo is in their root if(is_dir($topDir."/BACKED")==false){ mkdir($topDir."/BACKED", 0777); } if($AC=="" && strlen($PHPdatabase)>1){ mysql_connect($server,$user,$password); mysql_select_db($PHPdatabase); $backupFile =$source_dir.$PHPdatabase.".sql"; $result .= "# MySQL Data Backup of ".$PHPdatabase."\n"; $result .= "# This was generated on " . date("m/d/Y") . "\n\n"; $tables = mysql_list_tables($PHPdatabase); for($i = 0; $i < mysql_num_rows($tables); $i++){ $table = mysql_tablename ($tables, $i); if(substr($table,0,7)!="tblStat"){ $result .= "# Start of $table \n"; $result .= "TRUNCATE TABLE $table;\n"; $query = mysql_query("select * from $table"); $num_fields = mysql_num_fields($query); $result .= "$table fields (\n"; for($ii = 0; $ii < $num_fields; $ii++) { $result.= mysql_field_name($query,$ii)."-".mysql_field_type($query,$ii)."(".mysql_field_len($query,$ii).")".mysql_field_flags($query,$ii)."\n"; } $result.=");\n"; $numrow = mysql_num_rows($query); while( $row = mysql_fetch_array($query, MYSQL_NUM)) { $result .= "INSERT INTO ".$table." VALUES("; for($j=0; $j<$num_fields; $j++) { $row[$j] = addslashes($row[$j]); $row[$j] = str_replace("\n","\\n",$row[$j]); $row[$j] = str_replace("\r","",$row[$j]); if (isset($row[$j])) $result .= "\"$row[$j]\""; else $result .= "\"\""; if ($j<($num_fields-1)) $result .= ", "; } $result .= ");\n"; } } if ($i+1 != mysql_num_rows($tables)) $result .= "\n"; } $ID++; // =================== $fp = fopen($backupFile, "w"); fwrite($fp, $result); // Move to the start of the file fclose($fp); } //echo $topDir."/BACKED".$folder0."L.zip"; echo $exportstring;exit; switch($AC){ case 1: $zip_file = $topDir."/BACKED/".$project."L.zip"; $fi0=$_GET["fi0"]; $exportstring.="&fi0=$fi0&fi1=/BACKED/".$project."L.zip"; break; default: $zip_file = $topDir."/BACKED/".$project.".zip"; $exportstring.="&fi0=/BACKED/".$project.".zip"; break; } //echo $zip_file;exit; $file_list = Utils::listDirectory($source_dir); //echo "shit2";exit; $zip = new ZipArchive(); if ($zip->open($zip_file, ZIPARCHIVE::CREATE) === true) { foreach ($file_list as $file) { if ($file !== $zip_file) { switch($AC){ case 1: if(filesize($file)>= 250000 && strpos($file,".zip")==0 && strpos($file,".mp3")==0) $zip->addFile($file, substr($file, strlen($source_dir))); break; default: if(filesize($file)<= 250000) $zip->addFile($file, substr($file, strlen($source_dir))); break; } } //$i++;if($i==10)break; } $zip->close(); } if($AC==""){ header("location:zipdemo.php?$exportstring&L=1");exit; } else{ header("location:http://$return1?$exportstring"); exit; } ?> This script includes header files which may hiccup if error reporting is set to show warnings. The one below will handle warnings. class Utils { public static function listDirectory($dir) { $result = array(); $root = scandir($dir); foreach($root as $value) { if($value === '.' || $value === '..') { continue; } if(is_file("$dir$value")) { $result[] = "$dir$value"; continue; } if(is_dir("$dir$value")) { $result[] = "$dir$value/"; } foreach(self::listDirectory("$dir$value/") as $value) { $result[] = $value; } } return $result; } } /* $file = '/path/to/zip/file.zip'; $file_name = basename($file); header("Content-Type: application/zip"); header("Content-Disposition: attachment; filename=" . $file_name); header("Content-Length: " . filesize($file)); readfile($file); exit; */ $project=$_GET["pr"];$projectid=$_GET["id"];$PHPfolder=$_GET["fo"];$PHPdatabase=$_GET["db"];$user=$_GET["us"]; $password=$_GET["pa"];$return1=$_GET["re"]; $project="Peak_Wellness";$PHPdatabase="the1324812461410";$user="the1324812461410";$password="v4K#htNPNfeG"; $return1="www.softwarewebdesign.com/SWD/EMAIL/backmeup.php";$projectid=27; $exportstring="pr=$project&fo=$PHPfolder&db=$PHPdatabase&us=$user&pa=$password&re=$return1&id=$projectid"; $server="the1324812461410.db.11744884.hostedresource.com"; $AC=$_GET["L"]; $topDir=dirname(__FILE__); $folder0="/".$PHPfolder; $source_dir = $topDir."/"; //.$folder0."/"; if(is_dir($topDir."/BACKED")==false){ mkdir($topDir."/BACKED", 0777); } if($AC=="" && strlen($PHPdatabase)>1){ mysql_connect($server,$user,$password); mysql_select_db($PHPdatabase); $backupFile =$source_dir.$PHPdatabase.".sql"; $result .= "# MySQL Data Backup of ".$PHPdatabase."\n"; $result .= "# This was generated on " . date("m/d/Y") . "\n\n"; $tables = mysql_list_tables($PHPdatabase); for($i = 0; $i < mysql_num_rows($tables); $i++){ $table = mysql_tablename ($tables, $i); if(substr($table,0,7)!="tblStat"){ $result .= "# Start of $table \n"; $result .= "TRUNCATE TABLE $table;\n"; $query = mysql_query("select * from $table"); $num_fields = mysql_num_fields($query); $result .= "$table fields (\n"; for($ii = 0; $ii < $num_fields; $ii++) { $result.= mysql_field_name($query,$ii)."-".mysql_field_type($query,$ii)."(".mysql_field_len($query,$ii).")".mysql_field_flags($query,$ii)."\n"; } $result.=");\n"; $numrow = mysql_num_rows($query); while( $row = mysql_fetch_array($query, MYSQL_NUM)) { $result .= "INSERT INTO ".$table." VALUES("; for($j=0; $j<$num_fields; $j++) { $row[$j] = addslashes($row[$j]); $row[$j] = str_replace("\n","\\n",$row[$j]); $row[$j] = str_replace("\r","",$row[$j]); if (isset($row[$j])) $result .= "\"$row[$j]\""; else $result .= "\"\""; if ($j<($num_fields-1)) $result .= ", "; } $result .= ");\n"; } } if ($i+1 != mysql_num_rows($tables)) $result .= "\n"; } $ID++; // =================== $fp = fopen($backupFile, "w"); fwrite($fp, $result); // Move to the start of the file fclose($fp); } //echo "Done sql";exit; //echo $topDir."/BACKED".$folder0."L.zip"; echo $exportstring;exit; switch($AC){ case 1: $zip_file = $topDir."/BACKED/".$project."L.zip"; $fi0=$_GET["fi0"]; $exportstring.="&fi0=$fi0&fi1=/BACKED/".$project."L.zip"; break; default: $zip_file = $topDir."/BACKED/".$project.".zip"; $exportstring.="&fi0=/BACKED/".$project.".zip"; break; } //echo $zip_file;exit; $file_list = Utils::listDirectory($source_dir); //echo "shit2";exit; $zip = new ZipArchive(); if ($zip->open($zip_file, ZIPARCHIVE::CREATE) === true) { foreach ($file_list as $file) { if ($file !== $zip_file) { switch($AC){ case 1: if(filesize($file)>= 250000 && strpos($file,".zip")==0 && strpos($file,".mp3")==0) $zip->addFile($file, substr($file, strlen($source_dir))); break; default: if(filesize($file)<= 250000) $zip->addFile($file, substr($file, strlen($source_dir))); break; } } //$i++;if($i==10)break; } $zip->close(); } /* if($AC==""){ header("location:zipdemo.php?$exportstring&L=1");exit; } else{ header("location:http://$return1?$exportstring"); exit; } */ if($AC==""){ echo "Continue"; exit; } else{ echo "Continue"; exit; } ?> To unzip an archive just upload the archive and this script into the directory and run. Do this for both zips to get the complete archive. UNZIP SCRIPT $topDir=dirname(__FILE__)."/"; //echo $topDir;exit; $zip = new ZipArchive; if ($zip->open('SUBWAYL.zip') === TRUE) { $zip->extractTo($topDir); $zip->close(); echo 'ok'; } else { echo 'failed'; } ?> Php 1768 05/05/2026 Php Function Quick Debug Routine debug function ec($vari,$sect){ return "Section ".$sect." -- ".$vari.""; } $debug.=ec($_SESSION["FIELDSAVE1"],154); //line 154 Php 2 05/05/2026 Php Function Automatically Make Urls Clickable hyperlinks click email url link function _make_url_clickable_cb($matches) { $ret = ''; $url = $matches[2]; if ( empty($url) ) return $matches[0]; // removed trailing [.,;:] from URL if ( in_array(substr($url, -1), array('.', ',', ';', ':')) === true ) { $ret = substr($url, -1); $url = substr($url, 0, strlen($url)-1); } //return $matches[1] . "$url" . $ret; return $matches[1] . "$url" . $ret; } function _make_web_ftp_clickable_cb($matches) { $ret = ''; $dest = $matches[2]; $dest = 'http://' . $dest; if ( empty($dest) ) return $matches[0]; // removed trailing [,;:] from URL if ( in_array(substr($dest, -1), array('.', ',', ';', ':')) === true ) { $ret = substr($dest, -1); $dest = substr($dest, 0, strlen($dest)-1); } return $matches[1] . "$dest" . $ret; } function _make_email_clickable_cb($matches) { $email = $matches[2] . '@' . $matches[3]; return $matches[1] . "$email"; } function MakeHyperlink($ret) { $ret = ' ' . $ret; // in testing, using arrays here was found to be faster $ret = preg_replace_callback('#([\s>])([\w]+?://[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_url_clickable_cb', $ret); $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_web_ftp_clickable_cb', $ret); $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret); // this one is not in an array because we need it to run last, for cleanup of accidental links within links $ret = preg_replace("#(]+?>|>))]+?>([^>]+?)#i", "$1$3", $ret); $ret = trim($ret); return $ret; } Php 1618 05/05/2026 Php Function String Length ord sub ____String length____strlen($val) ___String to ascii code____ord($val) $newstring=substr($val,25,1);$acii=ord($newstring); The 160 is a space problem for browsers ____section of string____substr($val,start,extract#of char) $newstring=substr($teaser,5,1); start at char 5 and remove 1 letter Php 3 05/05/2026 Php Function Choosing What Errors To See error reporting Developer php_flag display_startup_errors on .htacess php_flag display_errors on / Turn off all error reporting error_reporting(0); // Report simple running errors error_reporting(E_ERROR | E_WARNING | E_PARSE); // Reporting E_NOTICE can be good too (to report uninitialized // variables or catch variable name misspellings ...) error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); // Report all errors except E_NOTICE error_reporting(E_ALL & ~E_NOTICE); // Report all PHP errors error_reporting(E_ALL); // Report all PHP errors error_reporting(-1); // Same as error_reporting(E_ALL); ini_set('error_reporting', E_ALL) Php 3 05/05/2026 Php Function Preg_match Is The Ereg Replacement ereg eregi preg_match preg match clean $text = "Start    middle    end"; // Inserts strictly before any group of non-breaking spaces $newText = preg_replace('/(&$nbsp;)+/', '$0', $text); echo $newText; To remove "weird" characters (like malformed UTF-8, symbols, emojis, or control characters) from a string while keeping standard alphanumeric text, spaces, and punctuation, you should use the PHP function preg_replace() with a Unicode regular expression $string = "Hello, World! “This� is crazy... ???? Keep this? No #weird stuff. 123."; // Keeps letters, numbers, spaces, punctuation (p{P}), and currency/math symbols (p{S}) $clean = preg_replace('/[^p{L}p{N}sp{P}p{S}]+/u', '', $string); echo $clean; // Output: Hello, World! This is crazy... Keep this? No #weird stuff. 123. If you define "punctuation" strictly as standard keyboard characters (.,;:!?@#-$%^&*()_+=[]{}|/<>~'"), it is often safer to explicitly whitelist exactly what you want to keep. $string = "Hello, World! “This� is crazy... ???? Keep this? No #weird stuff. 123."; // Whitelist: letters, numbers, spaces, and standard keyboard punctuation marks // Note: The hyphen (-) is placed at the very end so it isn't treated as a range $clean = preg_replace('/[^A-Za-z0-9 .,;:!?()[]{}'"@#$%^&*_+=/\|<>`~-]/', '', $string); echo $clean; // Output: Hello, World! This is crazy... Keep this? No #weird stuff. 123. preg_match() Would be the pcre equivalent. The patterns will pretty much be the same, only real difference is that the preg_xxx functions require an opening/closing delimiter in the pattern and modifiers (if needed) are specified after the closing delimiter. So for instance: ereg(".",$var1) would be preg_match("~.~",$var1) // ~ is used as the pattern delimiter. or for instance, eregi(".",$var1) // case in-sensitive would be preg_match("~.~i",$var1) // i modifier added to make it case in-sensitive if(eregi("color",$fieldName)) preg_match("~color~i",$fieldName)) Php 1256 06/27/2026 Php Function SESSION VARIABLES NOT WORKING DEBUG $_SESSION HEMPDBASE " size="20" maxlength="50" required> Php 1 05/05/2026 Php Function Back Up Of Mystuff.php mystuff Vps & Shared Servers VPS SERVER ?php // PHP 7.0 conversion Mysql class mysqli_swd{ var $num=0; var $id=0; var $fieldflags="";var $fieldlength=0;var $fieldname="";var $fieldtable;var $fieldtype=""; var $data; var $data1=array(); var $row=array(); var $fields=0; var $insertoption=""; var $quickarray=true; function multipleRecs($value){ if($value==true)$value=false; else $value=true; $this->quickarray=$value;return true; } function tableOption($query){ global $connection; $q = mysqli_query($connection,$query); //mysql_query($query); $num_fields = mysqli_num_fields($q); for($ii = 0; $ii < $num_fields; $ii++) { //$result.= mysql_field_name($query,$ii)."-".mysql_field_type($query,$ii)."(".mysql_field_len($query,$ii).")".mysql_field_flags($query,$ii)."n"; $fieldinfo=mysqli_field_flags($q,$ii); if(strpos($fieldinfo,"rimary_key")>0){ $this->fieldname=mysql_field_name($q,$ii);break; } } } function dbRow($result){ return mysqli_fetch_array($result,MYSQLI_BOTH); //,MYSQLI_BOTH } function dbTable($result,$k){ $table_info = mysqli_fetch_field_direct($result, $k); //print_r($table_info);echo""; $this->fieldlength = $table_info->max_length; $this->fieldname = $table_info->name; $this->fieldtable = $table_info->table; $this->fieldtype = $table_info->type; $this->fieldflag = $table_info->flags; } function dbsql2($query){ $this->insertoption=$query; } function dbsql($query){ global $db; global $dc;global $debug; global $appid; global $connection; //if (strpos($sql,"nsert into")==1) { echo "---".$query; exit; } try { $result=mysqli_query($connection,$query); //echo "query successfully to MariaDB using MySQLi!"; } catch (mysqli_sql_exception $e) { // Handle query failures gracefully echo ("query failed: " . $e->getMessage()); if($debug==true){ echo "Error:".$query."";exit; } } //end try $sql= strtolower($query); if(strpos($sql,"nsert into")==1)$AC=1; if(strpos($sql,"elect")==1){ $AC=2;$this->num=mysqli_num_rows($result); } if(strpos($sql,"pdate")==1 || strpos($sql,"elete")==1)$AC=3; //if($AC==""){echo $AC."==".$query;exit; } switch($AC){ case 1: $this->id=mysqli_insert_id($connection); break; case 2: if($this->num==0 && $this->insertoption!=""){ $this->dbq($this->insertoption); return false; } if($this->num==0) return false; if($appid!=""){ $this->data1=mysqli_fetch_array($result,MYSQLI_BOTH);mysqli_data_seek($result,0); //mysql_data_seek($result,0); $this->data=$result; }else{ if($this->num==1 && $this->quickarray==true)$this->data=mysqli_fetch_array($result,MYSQLI_BOTH); //mysql_fetch_array($result); else $this->data=$result; } $this->fields = mysqli_num_fields($result); return true; break; case 3: return true; break; } // end switch } } // end class function swd_mysql($server, $user,$password,$database){ global $appid; mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); try { // Establish the connection $connection = mysqli_connect($server,$user,$password,$database,3306); //echo "Connected successfully to MariaDB using MySQLi!"; } catch (mysqli_sql_exception $e) { // Handle connection failures gracefully die("Connection failed: " . $e->getMessage()); } return $connection; } session_start(); include("config.php");//$bypass=true; $connection = swd_mysql($server,$user,$password,$database); if($pageLevel=='')$pageLevel=3; ? OLD SERVER ?php // PHP 7.0 conversion Mysql class mysqli_swd{ var $num=0; var $id=0; var $fieldflags="";var $fieldlength=0;var $fieldname="";var $fieldtable;var $fieldtype=""; var $data; var $data1=array(); var $row=array(); var $fields=0; var $insertoption=""; var $quickarray=true; function multipleRecs($value){ if($value==true)$value=false; else $value=true; $this->quickarray=$value;return true; } function tableOption($query){ global $connection; $q = mysqli_query($connection,$query); //mysql_query($query); $num_fields = mysqli_num_fields($q); for($ii = 0; $ii < $num_fields; $ii++) { //$result.= mysql_field_name($query,$ii)."-".mysql_field_type($query,$ii)."(".mysql_field_len($query,$ii).")".mysql_field_flags($query,$ii)."n"; $fieldinfo=mysqli_field_flags($q,$ii); if(strpos($fieldinfo,"rimary_key")>0){ $this->fieldname=mysql_field_name($q,$ii);break; } } } function dbRow($result){ return mysqli_fetch_array($result,MYSQLI_BOTH); //,MYSQLI_BOTH } function dbTable($result,$k){ $table_info = mysqli_fetch_field_direct($result, $k); //print_r($table_info);echo""; $this->fieldlength = $table_info->max_length; $this->fieldname = $table_info->name; $this->fieldtable = $table_info->table; $this->fieldtype = $table_info->type; $this->fieldflag = $table_info->flags; } function dbsql2($query){ $this->insertoption=$query; } function dbsql($query){ global $db; global $dc;global $debug; global $appid; global $connection; //if (strpos($sql,"nsert into")==1) { echo "---".$query; exit; } $result=mysqli_query($connection,$query); // or die(mysqli_error().' from '.$query); //;mysql_query($query) if(!$result){ if($debug==true){ echo "Error:".$query;exit; }else{ echo "Error:".substr($query,0,1000);exit;} } $sql= strtolower($query); if(strpos($sql,"nsert into")==1)$AC=1; if(strpos($sql,"elect")==1){ $AC=2;$this->num=mysqli_num_rows($result); } if(strpos($sql,"pdate")==1 || strpos($sql,"elete")==1)$AC=3; //if($AC==""){echo $AC."==".$query;exit; } switch($AC){ case 1: $this->id=mysqli_insert_id($connection); break; case 2: if($this->num==0 && $this->insertoption!=""){ $this->dbq($this->insertoption); return false; } if($this->num==0) return false; if($appid!=""){ $this->data1=mysqli_fetch_array($result,MYSQLI_BOTH);mysqli_data_seek($result,0); //mysql_data_seek($result,0); $this->data=$result; }else{ if($this->num==1 && $this->quickarray==true)$this->data=mysqli_fetch_array($result,MYSQLI_BOTH); //mysql_fetch_array($result); else $this->data=$result; } $this->fields = mysqli_num_fields($result); return true; break; case 3: return true; break; } // end switch } } // end class function swd_mysql($server, $user,$password,$database){ global $appid; $connection = mysqli_connect($server, $user,$password); mysqli_select_db($connection, $database); if (!$connection){ echo 'Error: Could not connect to Mysqli database. Please try again later.'; exit; } return $connection; } session_start(); include("config.php");//$bypass=true; $connection = swd_mysql($server, $user,$password,$database); if($pageLevel=='')$pageLevel=3; ? Php 1 07/14/2026 Php Function Get Current Directory Name And Path In PHP working directory list path file Directory Use the getcwd() Function to Get the Current Directory Name in PHP Use the dirname() Function to Get the Current Directory Name in PHP Use the basename() Function to Get the Current Directory Name in PHP Use the getcwd() Function to Get the Current Directory Name in PHP The getcwd() function gives the current working directory. The returned value is a string on success. The function does not take any parameters. The function returns false in case of failure. Let�s consider the following directory structure. ??? var ? ??? www ? ??? html | ???project | ???index.php The PHP file lies inside the project directory. The getcwd() function will return the name of the current working directory, which is project. We can use the echo function to display the content of the function. We can see in the output section that the getcwd() function returns the current working directory with its path. echo getcwd(); Output: /var/www/html/project Use the dirname() Function to Get the Current Directory Name in PHP We can also use the dirname() function to get the current directory name in PHP. The function returns the path of the parent directory. It accepts two parameters where the first one is the path and the second one is levels. Levels indicate the number of directories to move up. Finally, we can use the __FILE__ magic constants in the dirname() function to get the name of the current directory. The __FILE__ constant returns the full path of the current file along with the file name. We can demonstrate these constants and the function in the above directory structure. For example, we get the following result when we echo the __FILE__ constant from the index.php file. echo __FILE__; Output: /var/www/html/project/index.php For example, write the dirname() function in the index.php file with the __FILE__ constant as the parameter. echo dirname(__FILE__); $topDir=dirname(__FILE__); Output: /var/www/html/project In this way, we can get the current working directory name in PHP. Use the basename() Function to Get the Current Directory Name in PHP We can use the basename() function to get the current working directory name without the path in PHP. We can apply this function with the result of the above two functions. The basename() function returns the name of the base file or folder from the given path. For example, if the path provided is /var/www/html/project, the output will be project. For example, use the functions dirname(__FILE__) and getcwd() as the parameters for the basename() function. In this way, we can get the current working directory name in PHP. echo basename(dirname(__FILE__)).""; echo basename(getcwd())."n"; Output: Directory List $current_dir="./uploads/"; $dir = opendir($current_dir); echo "directory=".$current_dir; while ($file = readdir($dir)){ $fullpath=$current_dir.$file; $filedate=date('Y-m-j', filemtime($fullpath)); $fsize=filesize($fullpath)/1000; $fsize=(int)$fsize;$fsize=$fsize/1000; $bulletin[]=$file."@".$fsize."@".$filedate; } closedir($dir); $count1=count($bulletin); sort($bulletin); reset($bulletin); html code in php //if($DI=='')ECHO "?DI="; $dis="Files(by Name)"; //while (list ($key, $val) = each ($bulletin)){ foreach($bulletin as $key=>$val) { //} while (list ($key, $val) = each ($bulletin)){ $mark=explode('@',$val); $count+=1; if($mark[0]=="index.php")continue; if(strpos($mark[0],".")==0 && $mark[0]!="error_log") $dis.="".$mark[0]."Directory"; else $dis.="".$mark[0]."(".$mark[1].") MB ".$mark[2].""; //if($count==(int)($count1/2)) echo " "; } $dis.=""; echo $dis; Php 3 05/05/2026 Php Function Protecting Passwords Encrypt Decrypt security password Security Code App $qu=new mysqli_swd();$sql="SELECT loginid,username,password FROM loginInfo";$qu->dbsql($sql); $ciphering = "AES-128-CTR";$iv_length = openssl_cipher_iv_length($ciphering);$options = 0;$encryption_iv = '1234567891011121'; $encryption_key = SWD_KEY; if(SWD_KEY!="JesusIsLord"){ECHO "SHIT";EXIT;} for($i=1;$i<=$qu->num;$i++){ $row=$qu->dbRow($qu->data); $username=addslashes(openssl_encrypt($row[1], $ciphering,$encryption_key, $options, $encryption_iv)); $password= addslashes(openssl_encrypt($row[2], $ciphering,$encryption_key, $options, $encryption_iv)); $sql="UPDATE loginInfo SET username='$username',password='$password' WHERE loginid=".$row[0];$r->dbsql($sql); } exit; Php 4 05/05/2026 Php Function Create Lionks Backup links $PDS_ Developer function CreateLinks($inx,$num,$range){ global $ALPHA; global $VIEW;global $txWhere;global $PDS_; $SubCat="&PDS_=";if($PDS_>0)$SubCat="&PDS_=".$PDS_; echo "ododo=".$PDS_; $ratio=(int)($num/$range);$start=1;$maxlinks=30; if($ratio<$num/$range)$ratio+=1; $end=$ratio; if($ratio>$maxlinks){ $start=$inx/$range-$maxlinks/2; if($start<1)$start=1; $end=$start+$maxlinks; if($end>$ratio){ $end=$ratio;$start=$end-$maxlinks; } } for($i=$start;$i<=$end;$i++){ switch($VIEW){ case 2: $submenu.="$i|"; break; default: $submenu.="$i|"; } } $dis1.=$submenu; return $dis1; } Php 1 05/05/2026 Php Function Deletefile.php delete exist file switch Backup File Info "; switch($AC){ case 1: if(file_exists($upfile))unlink($upfile); $upfile=str_replace("/thm/","/",$upfile); if(file_exists($upfile))unlink($upfile); echo "File is Deleted. Please close this window"; break; default: if(file_exists($upfile)){ if(file_exists($upfile)){ if(mime_content_type($upfile)=="image/jpeg"){ $dimen=sizepicture($upfile,300,400); echo " "; }else{ echo $upfile.""; } echo "If not, just close this window"; } }else echo "This file does not exist. Close this window."; break; } ?> Using single line of code switch ($variable) { case '1': case '2': case '3': // Code to run if $variable is '1', '2', or '3' echo "Value is 1, 2, or 3"; break; default: // Optional default action echo "Other value"; break; } Php 1 05/05/2026 Php Ini Php Ini Partial ini Filter List Textarea disable_functions no value no value display_errors Off Off display_startup_errors Off Off doc_root no value no value docref_ext no value no value docref_root no value no value enable_dl Off Off enable_post_data_reading On On error_append_string no value no value error_log error_log error_log error_prepend_string no value no value error_reporting 22519 22519 expose_php Off Off extension_dir /opt/cpanel/ea-php80/root/usr/lib64/php/modules /opt/cpanel/ea-php80/root/usr/lib64/php/modules file_uploads On On hard_timeout 2 2 highlight.comment #FF8000 #FF8000 highlight.default #0000BB #0000BB highlight.html #000000 #000000 highlight.keyword #007700 #007700 highlight.string #DD0000 #DD0000 html_errors On On ignore_repeated_errors Off Off ignore_repeated_source Off Off ignore_user_abort Off Off implicit_flush Off Off include_path .:/opt/cpanel/ea-php80/root/usr/share/pear .:/opt/cpanel/ea-php80/root/usr/share/pear input_encoding no value no value internal_encoding no value no value log_errors On On log_errors_max_len 1024 1024 mail.add_x_header On On mail.force_extra_parameters no value no value mail.log no value no value max_execution_time 60 60 max_file_uploads 20 20 max_input_nesting_level 64 64 max_input_time 60 60 max_input_vars 1000 1000 max_multipart_body_parts -1 -1 memory_limit 512M 512M open_basedir no value no value output_buffering no value no value output_encoding no value no value output_handler no value no value post_max_size 516M 516M precision 14 14 Php 1 05/05/2026 Php Internet Drag And Drop File Upload drag drop upload Uplioad Drag and Drop File Upload Drag & drop your file here or Browse File =========== CREATE UPLOAD.PHP NEXT===================== 'error', 'message' => 'No file uploaded or upload error occurred.']); exit; } $file = $_FILES['uploaded_file']; // Security definitions $allowedExtensions = ['jpg', 'jpeg', 'png', 'pdf', 'zip']; $maxFileSize = 5 * 1024 * 1024 * 100; // 5 Megabytes $uploadDir = 'uploads/'; // Validate size if ($file['size'] > $maxFileSize) { echo json_encode(['status' => 'error', 'message' => 'File size exceeds the SET limit.']); exit; } // Validate extension $fileExtension = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)); if (!in_array($fileExtension, $allowedExtensions)) { echo json_encode(['status' => 'error', 'message' => 'Invalid file extension type.']); exit; } // Create target directory if it does not exist if (!is_dir($uploadDir)) { mkdir($uploadDir, 0755, true); } // Sanitize filename to prevent directory traversal attacks $safeFilename = time() . '_' . preg_replace("/[^a-zA-Z0-9._-]/", "", $file['name']); $targetFilePath = $uploadDir . $safeFilename; // Move file from temporary directory to storage location if (move_uploaded_file($file['tmp_name'], $targetFilePath)) { echo json_encode([ 'status' => 'success', 'message' => 'File successfully uploaded!', 'filename' => $safeFilename ]); } else { echo json_encode(['status' => 'error', 'message' => 'Failed to save uploaded file.']); } } else { echo json_encode(['status' => 'error', 'message' => 'Invalid HTTP request method.']); } Php 0 06/27/2026 Php Language Number Type integer pow(5, 3) (float)$val (int)$val Php 3 05/05/2026 Php Language HtmlEntities ,html_entity_decode html convert formatt You could use htmlspecialchars and htmlspecialchars_decode combined with htmlEntities ,html_entity_decode htmlspecialchars — Convert special characters to HTML entities See documentation here http://php.net/htmlspecialchars htmlspecialchars_decode — Convert special HTML entities back to characters See documentation here http://php.net/manual/en/function.htmlspecialchars-decode.php $htmlcode = htmlentities(htmlspecialchars(thehmldata)); echo $htmlcode; echo html_entity_decode(htmlspecialchars_decode($htmlcode) Php 3 05/05/2026 Php Language Empty strip tag Developer <?php $text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>'; echo strip_tags($text); echo "n"; // Allow <p> and <a> echo strip_tags($text, '<p><a>'); // as of PHP 7.4.0 the line above can be written as: // echo strip_tags($text, ['p', 'a']); ?> Php 3 05/05/2026 Php Language Finds The Position Of The Last Occurrence Of A String search find Developer PHP strrpos() Function Example Find the position of the last occurrence of "php" inside the string: echo strrpos("I love php, I love php too!","php"); ?> Definition and Usage The strrpos() function finds the position of the last occurrence of a string inside another string. Note: The strrpos() function is case-sensitive. Related functions: strpos() - Finds the position of the first occurrence of a string inside another string (case-sensitive) stripos() - Finds the position of the first occurrence of a string inside another string (case-insensitive) strripos() - Finds the position of the last occurrence of a string inside another string (case-insensitive) Syntax Php 1 05/05/2026 Php Language Loops In Php loops do while Php Set $i = 8, then print $i as long as $i is less than 6: $i = 8; do { echo $i; $i++; } while ($i < 6); The code will be executed once, even if the condition is never true. Print $i as long as $i is less than 6: $i = 1; while ($i < 6) { echo $i; $i++; } Stop the loop when $i is 3: $i = 1; while ($i < 6) { if ($i == 3) break; echo $i; $i++; } Stop, and jump to the next iteration if $i is 3: $i = 0; while ($i < 6) { $i++; if ($i == 3) continue; echo $i; } Count to 100 by tens: $i = 0; while ($i < 100) { $i+=10; echo $i ""; } Php 1 05/05/2026 Php Language PHP Language random Generate randoms "); echo(rand() . ""); echo(rand(10,100)); ?> Definition and Usage The rand() function generates a random integer. Example tip: If you want a random integer between 10 and 100 (inclusive), use rand (10,100). Tip: As of PHP 7.1, the rand() function has been an alias of the mt_rand() function. =====random strings =========== function generateRandomString($length = 10) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[random_int(0, $charactersLength - 1)]; } return $randomString; } Output the random string with the call below: // Echo the random string. echo generateRandomString(); // Optionally, you can give it a desired string length. echo generateRandomString(64); Php 1 05/05/2026 Php Network Doing Email In Php email Send Emails $notify=false;$subject="Subject Here."; $body="$Body Here ".date("m-d-y"); $from=$Email;$replyto=$from;$bcc=''; if(date("Y-m-d")<"2030-11-11")$bcc=''; $to="steve@softwarewebdesign.com"; $headers = "MIME-Version: 1.0rn"; $headers .= "Content-type: text/html; charset=iso-8859-1rn"; $headers .= "From: ".$from."rn"; $headers .= "Reply-To: ".$replyto."rn"; if($bcc!='')$headers .= "bcc:$bccrn"; mail($to, $subject, $body, $headers); Php 2 05/05/2026 Php Object USING IMAGES image resize function getimagesize Images function sizepicture($picture){ $maxwidth=110; $maxheight=110; list($width, $height, $type, $attr) = getimagesize($picture); $hratio=$height/$maxheight; $wratio=$width/$maxwidth; if ($wratio>$hratio){ $ratio=$width/$height; if($width>$maxwidth){ $height=(int)($maxwidth/$ratio);$width=$maxwidth; } }else{ $ratio=$height/$width; if($height>$maxheight){ $width=(int)($maxheight/$ratio);$height=$maxheight; } } $size[0]=$width;$size[1]=$height; return $size; } <?php $picture="../logo/logo14.jpg"; $maxwidth=300; $maxheight=200; list($width, $height, $type, $attr) = getimagesize($picture); $hratio=$height/$maxheight; $wratio=$width/$maxwidth; if ($wratio>$hratio){ $ratio=$width/$height; if($width>$maxwidth){ $height=(int)($maxwidth/$ratio);$width=$maxwidth; } }else{ $ratio=$height/$width; if($height>$maxheight){ $width=(int)($maxheight/$ratio);$height=$maxheight; } } $dis.="<img src='$picture' width=$width height=$height><BR><img src='$picture'>n"; echo $dis; ?> ......................MAKE THUMBNAILS................................... function make_thumb($file) { $image = "/home/dunning/public_html/images/" . $file; $thumb = "/home/dunning/public_html/images/t_" . $file; //echo "Creating thumbnail..." . $thumb . "<br>"; if(!$max_width) $max_width = 199; if(!$max_height) $max_height = 134; $size = GetImageSize($image); $width = $size[0]; $height = $size[1]; $x_ratio = $max_width / $width; $y_ratio = $max_height / $height; if( ($width <= $max_width) && ($height <= $max_height) ) { $tn_width = $width; $tn_height = $height; } else if(($x_ratio * $height) < $max_height) { $tn_height = ceil($x_ratio * $height); $tn_width = $max_width; } else { $tn_width = ceil($y_ratio * $width); $tn_height = $max_height; } $src = imagecreatefromjpeg($image); $dst = imagecreatetruecolor($tn_width, $tn_height); imagecopyresized($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width, $height); imagejpeg($dst, $thumb, 90); imagedestroy($src);//imagedestroy($src, $dst); } ----------FUNCTION.................................. Part I: The HTML Form <form action="upload.php" method="post" enctype="multipart/form-data > <input type="file" name="uploadfile"/> <input type="submit"/> Part II: Getting at the file, resizing the image, and saving to the server. (upload.php) <?php // This is the temporary file created by PHP $uploadedfile = $_FILES['uploadfile']['tmp_name']; // Create an Image from it so we can do the resize $src = imagecreatefromjpeg($uploadedfile); // Capture the original size of the uploaded image list($width,$height)=getimagesize($uploadedfile); // For our purposes, I have resized the image to be // 600 pixels wide, and maintain the original aspect // ratio. This prevents the image from being "stretched" // or "squashed". If you prefer some max width other than // 600, simply change the $newwidth variable $newwidth=600; $newheight=($height/$width)*600; $tmp=imagecreatetruecolor($newwidth,$newheight); // this line actually does the image resizing, copying from the original // image into the $tmp image imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); // now write the resized image to disk. I have assumed that you want the // resized, uploaded image file to reside in the ./images subdirectory. $filename = "images/". $_FILES['uploadfile']['name']; imagejpeg($tmp,$filename,100); imagedestroy($src); imagedestroy($tmp); // NOTE: PHP will clean up the temp file it created when the request // has completed. ?> ================ 2nd example ============================================ There are some things you will want to keep in mind when use PHP to resize your images. Resizing images in PHP takes CPU time so it's not something that you want to do frequently. Sometimes people will ask me how to create thumbnail images on-the-fly without having to save them to disk every time. This is a bad idea because you will put unnecessary load on your web server and depending on how many visitors you have, your server could crash. It is better to resize the image to thumbnail size and save the thumbnails for later use even though it might take up a little more disk space on your server. Here is the function that I use to resize jpg images. It uses the GD2 library, and as you'll see, it preserves the colors in true color images. <?php function resampimagejpg( $forcedwidth, $forcedheight, $sourcefile, $destfile ) { $fw = $forcedwidth; $fh = $forcedheight; $is = getimagesize( $sourcefile ); if( $is[0] >= $is[1] ) { $orientation = 0; } else { $orientation = 1; $fw = $forcedheight; $fh = $forcedwidth; } if ( $is[0] > $fw || $is[1] > $fh ) { if( ( $is[0] - $fw ) >= ( $is[1] - $fh ) ) { $iw = $fw; $ih = ( $fw / $is[0] ) * $is[1]; } else { $ih = $fh; $iw = ( $ih / $is[1] ) * $is[0]; } $t = 1; } else { $iw = $is[0]; $ih = $is[1]; $t = 2; } if ( $t == 1 ) { $img_src = imagecreatefromjpeg( $sourcefile ); $img_dst = imagecreatetruecolor( $iw, $ih ); imagecopyresampled( $img_dst, $img_src, 0, 0, 0, 0, $iw, $ih, $is[0], $is[1] ); if( !imagejpeg( $img_dst, $destfile, 90 ) ) { exit( ); } } else if ( $t == 2 ) { copy( $sourcefile, $destfile ); } } ?> To use the resize function you must pass in the forced width, forced height, source image, and destination image. The function then uses the GD2 library functions to read the source image's size. It will then calculate the new image's size based off of the forced width and height. This function will maintain the original image's aspect ratio so your image won't look distorted. It won't change the source image at all but when the function is done running you will end up with the destination image which is resized to the dimensions you passed into the function. As far as I know, this function requires the GD2 library although you might be able to get it to work with the GD1 library. The GD library extension must be enabled in PHP before you can use GD2 functions so keep that in mind as well. You can use the PHP function phpinfo() to see if GD2 is enabled or to see what version of the GD library your server is using. Update - March 22nd, 2007 When I originally wrote this article there were not many digital cameras or other devices capable or creating images larger than about 6 megapixels. Now that 7,8, and 10 megapixel cameras are more commonplace, some people who use this resizing function have run into a problem with PHP running out of memory. The problem is that the user's web host has set the PHP memory limit to a low value so that the server's resources can be shared somewhat equally between all the users on the server. Larger files require more memory to resize so when the resizing script hits the memory limit it chokes and gives an internal server error. Possible solutions to the problem: Contact your host and ask them to increase the PHP memory limit so your script can resize the larger files. Use a different program to resize the images such as ImageMagick if your host provides it. If your host does not provide it you may be able to install it yourself if you have shell access available on your hosting account. Don't allow users to upload such large files. It consumes a lot of bandwidth on your server and can be very slow for the user depending on the speed of their internet connection. Have them resize the image before uploading it so that it is under 1MB or so. I hope this PHP function will allow you to resize images easily. It has worked very well for me. ............................ GETIMAGESIZE..................................... Returns an array with 4 elements. Index 0 contains the width of the image in pixels. Index 1 contains the height. Index 2 is a flag indicating the type of the image: 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF. These values correspond to the IMAGETYPE constants that were added in PHP 4.3. Index 3 is a text string with the correct height="yyy" width="xxx" string that can be used directly in an IMG tag. list($width, $height, $type, $attr) = getimagesize('images/'.$picture); Php 6 05/05/2026 Php Object Determin A Files Type file type Checking Files if looking for images The following constants are defined, and represent possible exif_imagetype() return values: Imagetype Constants Value Constant 1 IMAGETYPE_GIF 2 IMAGETYPE_JPEG 3 IMAGETYPE_PNG 4 IMAGETYPE_SWF 5 IMAGETYPE_PSD 6 IMAGETYPE_BMP 7 IMAGETYPE_TIFF_II (intel byte order) 8 IMAGETYPE_TIFF_MM (motorola byte order) 9 IMAGETYPE_JPC 10 IMAGETYPE_JP2 11 IMAGETYPE_JPX 12 IMAGETYPE_JB2 13 IMAGETYPE_SWC 14 IMAGETYPE_IFF 15 IMAGETYPE_WBMP 16 IMAGETYPE_XBM 17 IMAGETYPE_ICO 18 IMAGETYPE_WEBP 19 IMAGETYPE_AVIF Note: exif_imagetype() will emit an E_NOTICE and return false if it is unable to read enough bytes from the file to determine the image type. Example 2 In PHP, you can determine the file type of a movie, PDF, or image using several functions. mime_content_type() returns the MIME type, finfo provides more detailed information, and exif_imagetype() is specifically for images. Detailed Explanation: 1. mime_content_type(): This function uses the magic.mime file to return the MIME type of a file. For example: mime_content_type('movie.mp4') might return video/mp4. mime_content_type('document.pdf') might return application/pdf. mime_content_type('image.jpg') might return image/jpeg. 2. finfo: This function provides more detailed information about a file, including its type. It can be used to check for specific file types or extensions. 3. exif_imagetype(): This function is specifically designed for images. It reads the first few bytes of an image file to determine its type. It can be used to verify that a file is actually an image before processing it further. Example: Code // Check file type using mime_content_type() $file = 'movie.mp4'; $mime_type = mime_content_type($file); if ($mime_type == 'video/mp4') { echo "The file is a video."; } elseif ($mime_type == 'application/pdf') { echo "The file is a PDF."; } elseif (strpos($mime_type, 'image/') !== false) { // Check if MIME type starts with 'image/' echo "The file is an image."; } else { echo "The file type is unknown."; } // Check file type using finfo (more robust) $finfo = finfo_open(FILEINFO_MIME_TYPE); // Open a fileinfo handle $mime_type = finfo_file($finfo, $file, FILEINFO_MIME_TYPE); finfo_close($finfo); if ($mime_type == 'video/mp4') { echo "The file is a video (finfo)."; } elseif ($mime_type == 'application/pdf') { echo "The file is a PDF (finfo)."; } elseif (strpos($mime_type, 'image/') !== false) { echo "The file is an image (finfo)."; } else { echo "The file type is unknown (finfo)."; } // Check image type using exif_imagetype() $file = 'image.jpg'; $image_type = exif_imagetype($file); if ($image_type == IMAGETYPE_JPEG) { echo "The file is a JPEG image."; } elseif ($image_type == IMAGETYPE_PNG) { echo "The file is a PNG image."; } elseif ($image_type == IMAGETYPE_GIF) { echo "The file is a GIF image."; } else { echo "The file is not a supported image type."; } ?> Key Considerations: Security: . Always validate file types on the server-side to prevent malicious files from being uploaded. MIME Type vs. File Extension: . File extensions can be easily spoofed, so relying solely on them is not secure. MIME types provide a more reliable indication of file content. finfo for Detailed Information: . finfo can be used to check for specific file types or extensions, providing more flexibility than mime_content_type(). exif_imagetype() for Image Validation: . This function is specifically designed for images and can be used to verify that a file is actually an image before processing it. is_dir($path): Returns true if it’s a directory. is_link($path): Returns true if it’s a symbolic link. Php 2 05/18/2026 Php Server Get Information About Your User page refer php self My current page is: $PHP_SELF $ref=$_SERVER['HTTP_REFERER']; page they came from $ip=$_SERVER['REMOTE_ADDR']; get their ipaddress echo $_SERVER['HTTP_USER_AGENT'] . "\n\n"; $browser = get_browser(null, true); print_r($browser); ?> The above example will output something similar to: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3 Array ( [browser_name_regex] => ^mozilla/5\.0 (windows; .; windows nt 5\.1; .*rv:.*) gecko/.* firefox/0\.9.*$ [browser_name_pattern] => Mozilla/5.0 (Windows; ?; Windows NT 5.1; *rv:*) Gecko/* Firefox/0.9* [parent] => Firefox 0.9 [platform] => WinXP [browser] => Firefox [version] => 0.9 [majorver] => 0 [minorver] => 9 [css] => 2 [frames] => 1 [iframes] => 1 [tables] => 1 [cookies] => 1 [backgroundsounds] => [vbscript] => [javascript] => 1 [javaapplets] => 1 [activexcontrols] => [cdf] => [aol] => [beta] => 1 [win16] => [crawler] => [stripper] => [wap] => [netclr] => ) Php 1501 05/05/2026 Php Server Get Ipaddress ipaddress Reading Serve Ip To read your server's internal IP address in PHP, you should use the $_SERVER['SERVER_ADDR'] superglobal. For the server's external (public) IP address, the most reliable way is to query an external service. Internal Server IP Address The $_SERVER superglobal array contains various server and request-related information. The SERVER_ADDR key typically holds the IP address of the host server running the script. php $server_ip = $_SERVER['SERVER_ADDR']; echo "Server Internal IP Address: " . $server_ip; ?> Note: This may return 127.0.0.1 (localhost) in some configurations or if running from a command line interface (CLI). External Server IP Address To get the IP address that your server uses to communicate with the internet (its public IP), you generally need to make a request to an external service that simply echoes back the IP address it sees. A common and reliable method is to use Amazon's check IP service via file_get_contents() or curl. php // Use file_get_contents to fetch the IP from a reliable external service $external_ip = file_get_contents('https://checkip.amazonaws.com'); // Filter and validate the IP address before use if (filter_var($external_ip, FILTER_VALIDATE_IP) !== false) { echo "Server External IP Address: " . trim($external_ip); } else { echo "Could not retrieve external IP address."; } ?> Alternative Methods Using DNS: If your server has a domain name, you can use PHP's gethostbyname() function to find the IP associated with that hostname. php $domain_name = 'yourdomain.com'; $ip_from_dns = gethostbyname($domain_name); echo "IP from DNS lookup: " . $ip_from_dns; ?> Using Sockets (Linux/Unix): A more robust dynamic method, especially useful in CLI environments, involves connecting to a public DNS server (like Google's 8.8.8.8) to determine the outgoing interface IP address. php $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_connect($sock, '8.8.8.8', 53); socket_getsockname($sock, $addr); socket_close($sock); echo "Server Outgoing IP: " . $addr; ?> $ip=$_SERVER['REMOTE_ADDR']; if($_SERVER['REMOTE_ADDR']=="208.73.252.147"){ function get_ip() { if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { //check ip from share internet $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { //to check ip is pass from proxy $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } return $ip; } Php 1191 05/05/2026 Php Server Server Information - Using The $_SERVER server information function URL INFO [USE parse_url under langueage 'PHP_SELF' The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar. The __FILE__ constant contains the full path and filename of the current (i.e. included) file. If PHP is running as a command-line processor this variable contains the script name since PHP 4.3.0. Previously it was not available. 'argv' Array of arguments passed to the script. When the script is run on the command line, this gives C-style access to the command line parameters. When called via the GET method, this will contain the query string. 'argc' Contains the number of command line parameters passed to the script (if run on the command line). 'GATEWAY_INTERFACE' What revision of the CGI specification the server is using; i.e. 'CGI/1.1'. 'SERVER_ADDR' The IP address of the server under which the current script is executing. 'SERVER_NAME' The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host. 'SERVER_SOFTWARE' Server identification string, given in the headers when responding to requests. 'SERVER_PROTOCOL' Name and revision of the information protocol via which the page was requested; i.e. 'HTTP/1.0'; 'REQUEST_METHOD' Which request method was used to access the page; i.e. 'GET', 'HEAD', 'POST', 'PUT'. Note: PHP script is terminated after sending headers (it means after producing any output without output buffering) if the request method was HEAD. 'REQUEST_TIME' The timestamp of the start of the request. Available since PHP 5.1.0. 'REQUEST_TIME_FLOAT' The timestamp of the start of the request, with microsecond precision. Available since PHP 5.4.0. 'QUERY_STRING' The query string, if any, via which the page was accessed. 'DOCUMENT_ROOT' The document root directory under which the current script is executing, as defined in the server's configuration file. 'HTTP_ACCEPT' Contents of the Accept: header from the current request, if there is one. 'HTTP_ACCEPT_CHARSET' Contents of the Accept-Charset: header from the current request, if there is one. Example: 'iso-8859-1,*,utf-8'. 'HTTP_ACCEPT_ENCODING' Contents of the Accept-Encoding: header from the current request, if there is one. Example: 'gzip'. 'HTTP_ACCEPT_LANGUAGE' Contents of the Accept-Language: header from the current request, if there is one. Example: 'en'. 'HTTP_CONNECTION' Contents of the Connection: header from the current request, if there is one. Example: 'Keep-Alive'. 'HTTP_HOST' Contents of the Host: header from the current request, if there is one. 'HTTP_REFERER' The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted. 'HTTP_USER_AGENT' Contents of the User-Agent: header from the current request, if there is one. This is a string denoting the user agent being which is accessing the page. A typical example is: Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586). Among other things, you can use this value with get_browser() to tailor your page's output to the capabilities of the user agent. 'HTTPS' if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} Set to a non-empty value if the script was queried through the HTTPS protocol. Note: Note that when using ISAPI with IIS, the value will be off if the request was not made through the HTTPS protocol. 'REMOTE_ADDR' The IP address from which the user is viewing the current page. if($_SERVER['REMOTE_ADDR']=="127.0.0.1"){ $server='localhost';$user='greatone';$password='gr38t0n3';$database='angel'; $_SESSION['LEVEL']=10;} else{ $server="localhost";$user="angelde_flunky1";$password="wied55";$database="angelde_a1"; } 'REMOTE_HOST' The Host name from which the user is viewing the current page. The reverse dns lookup is based off the REMOTE_ADDR of the user. Note: Your web server must be configured to create this variable. For example in Apache you'll need HostnameLookups On inside httpd.conf for it to exist. See also gethostbyaddr(). 'REMOTE_PORT' The port being used on the user's machine to communicate with the web server. 'REMOTE_USER' The authenticated user. 'REDIRECT_REMOTE_USER' The authenticated user if the request is internally redirected. 'SCRIPT_FILENAME' The absolute pathname of the currently executing script. Note: If a script is executed with the CLI, as a relative path, such as file.php or ../file.php, $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user. 'SERVER_ADMIN' The value given to the SERVER_ADMIN (for Apache) directive in the web server configuration file. If the script is running on a virtual host, this will be the value defined for that virtual host. 'SERVER_PORT' The port on the server machine being used by the web server for communication. For default setups, this will be '80'; using SSL, for instance, will change this to whatever your defined secure HTTP port is. 'SERVER_SIGNATURE' String containing the server version and virtual host name which are added to server-generated pages, if enabled. 'PATH_TRANSLATED' Filesystem- (not document root-) based path to the current script, after the server has done any virtual-to-real mapping. Note: As of PHP 4.3.2, PATH_TRANSLATED is no longer set implicitly under the Apache 2 SAPI in contrast to the situation in Apache 1, where it's set to the same value as the SCRIPT_FILENAME server variable when it's not populated by Apache. This change was made to comply with the CGI specification that PATH_TRANSLATED should only exist if PATH_INFO is defined. Apache 2 users may use AcceptPathInfo = On inside httpd.conf to define PATH_INFO. 'SCRIPT_NAME' Contains the current script's path. This is useful for pages which need to point to themselves. The __FILE__ constant contains the full path and filename of the current (i.e. included) file. 'REQUEST_URI' The URI which was given in order to access this page; for instance, '/index.html'. 'PHP_AUTH_DIGEST' When doing Digest HTTP authentication this variable is set to the 'Authorization' header sent by the client (which you should then use to make the appropriate validation). 'PHP_AUTH_USER' When doing HTTP authentication this variable is set to the username provided by the user. 'PHP_AUTH_PW' When doing HTTP authentication this variable is set to the password provided by the user. 'AUTH_TYPE' When doing HTTP authenticated this variable is set to the authentication type. 'PATH_INFO' Contains any client-provided pathname information trailing the actual script filename but preceding the query string, if available. For instance, if the current script was accessed via the URL http://www.example.com/php/path_info.php/some/stuff?foo=bar, then $_SERVER['PATH_INFO'] would contain /some/stuff. 'ORIG_PATH_INFO' Original version of 'PATH_INFO' before processed by PHP. Php 1007 05/05/2026 Php String Manipulate Strings language find replace first caps upper case lower case section substring date array convert a date into a string $dateString = strval($paid_date[$value]); Find postion of something: strpos($string,$character,$offset); Html tags REMOVE: $allowTheseTags="List all tags allowed" echo strip_tags($text, '$allowTheseTags'); Length of: strlen($string) Lower and Upper Case:$stringnew=strtolower($string); $stringnew=strtoupper($string); Replace$longadd=str_replace(chr(13),'',$longadd); $string = "The quick brown fox jumps over the lazy dog."; $search = array(""," Using arrays to replace on $search = array("??????","???"); // Substrings to be replaced $replace = array("->"," "); // Corresponding replacement substrings $scripture=str_replace($search,$replace,$scripture); // REPLACE WEIRD QUOTES $search=("“","â€","—","’"); $replace=('"','"',"--","'"); XXXX=str_replace($search,$replace,XXXXX) Specific replace $text = "One two three four five six sevennFirst second third fourth fifth sixth seventh"; $replacement = "-"; // The character you want to insert // Looking for the 5th space to insert {4} // Regex pattern to target the 5th space of each line $pattern = '/^((?:[^ n]* ){4}[^ n]*) /m'; $result = preg_replace($pattern, '$1' . $replacement, $text); echo $result; OUTPUT: One two three four five-six seven First second third fourth fifth-sixth seventh //EXAMPLE 2: REPLACING 3rd dash $text = "a-b-c-d-en1-2-3-4-5"; $replacement = ':'; // The character you want to use $result = preg_replace('/^((?:[^-]*-[^-]*){2}[^-]*)-/m', '$1' . $replacement, $text); echo $result; ASK:php replace 3rd dash in each line with a character Replace Indenting Spaces $text = " Line one with four spaces. Line two with eight spaces. No indentation here."; $result = preg_replace_callback('/^( +)/m', function($matches) { return str_repeat('*nbsp;', strlen($matches[1])); // replace '*' with "&" }, $text); //echo nl2br($result); // actual PHP function CodeView uses this solution Php 1400 09/13/2026