• Home
  • Tools
    • Color Chart
  • Software
    • Windows tricks
      • Windows 11 Speed Up Tricks
      • Windows Command Prompt CMD
    • Android Phone
      • Android – Dangerous Settings to Turn Off
    • Projects
      • Copy Files
      • Php Autoscript
      • Web Tools
  • Payments
  • Notes
  • System Tips

Notes

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 |

ABCDEFGHIJKLMNOPQRSTUVWXYZ
ON
PRT
OFF

<- Look Inside Data
Conditions:
Order:
1|2|
50 Language Operation Title
Keywords
Application
Code Languageid
Show Html
Show Iframe
Make Public
Viewed
Viewed Date
Php Archive Software Web Activation.php
reg75
Reg75.php
Php



2
01/30/2023
Php Archive Color Change Script
color convert javascript step
Home Page
Php



7
12/28/2022
Php Archive Code Zoom Backup Code
zoom format html_entity_decode
Codezoom.php
Php



0
12/28/2022
Php Constants Setting The Absolute Path
absolute path define constant
Library
Php



3
09/09/2023
Php Customizing Convert Words Into A Graphic
text graphic image convert
$im = imagecreate(400, 30);

// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);

// The text to draw
$text = 'Testing...';
// Replace path by your own font path
$font = 'arial.ttf';

// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);

// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);


*************************************
The below script would be called with a tag like this from a page:

Header("Content-type: image/gif");
if(!isset($s)) $s=11;
$size = imagettfbbox($s,0,"/fonts/TIMES.TTF",$text);
$dx = abs($size[2]-$size[0]);
$dy = abs($size[5]-$size[3]);
$xpad=9;
$ypad=9;
$im = imagecreate($dx+$xpad,$dy+$ypad);
$blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black);
ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white);
ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black, "/fonts/TIMES.TTF", $text);
ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white, "/fonts/TIMES.TTF", $text);
ImageGif($im);
ImageDestroy($im);
?>

It is very important to realize that you cannot put any HTML tags in this file. There should also not be any spaces or blank lines before or after the tags. If you are getting a broken image using this script, chances are you have a stray carriage return somewhere outside the PHP tags
Php



1860
09/09/2023
Php Customizing Rename A File In PHP
rename file
Change File Names
rename a file in PHP, use the built-in
rename() function. This function takes the old filename/path and the new filename/path as mandatory arguments and returns true on success or false on failure.
rename() Function Syntax


rename($oldname, $newname, $context);

$oldname (Mandatory): Specifies the current name/path of the file or directory.
$newname (Mandatory): Specifies the new name/path for the file or directory.
$context (Optional): Specifies the behavior of the stream.
Php



0
12/19/2025
Php Customizing Using Strip_tags
strip tags html
Unwanted Table Breaks
Php



0
12/20/2025
Php Database Concat - Combine Fields Or Text
add join concat
Php



2
09/09/2023
Php Database Count
count query

count records that link to same file


$sql="SELECT * FROM eqMaintenance WHERE maintenanceid = $value_";
$r->dbsql($sql);$row=$r->data1;
$upfile="../maintenance/".$row['img'];

Start count query


$sql="SELECT count(img) as dog FROM eqMaintenance WHERE img='".$row['img']."' GROUP BY img";
$r->dbsql($sql);$dog=$r->data1[0];
if(file_exists($upfile) && $dog<2)unlink($upfile);

//example from php file creator

SELECT hide,count(hide) as dog FROM `invoice` GROUP BY hide LIMIT 0, 30

SELECT invoices.customerid, `last_name` , `first_name`, COUNT(`last_name`) AS dog,
count(if(`date`< ADDDATE(NOW(), INTERVAL -365 DAY), 1, null)) AS year1, count(if(`date`>= ADDDATE(NOW(), INTERVAL -365 DAY), 1, null)) AS year0, count(if(`date`< ADDDATE(NOW(), INTERVAL -730 DAY), 1, null)) AS year2
FROM `invoices`
INNER JOIN `customer` ON customer.customerid = invoices.customerid
GROUP BY invoices.customerid, `last_name` , `first_name`
ORDER BY year0,year1
Php



3
12/28/2023
Php Database Delete
left join delete orphans
Php



2
09/09/2023
Php Database Find Orphans
left join orphan delete
Php



2
09/09/2023
Php Database Group By
group by inner join
Php



2
09/09/2023
Php Database Insert Table
insert table
Php



2
09/09/2023
Php Database Insert Using Select
insert select
Php



2
09/09/2023
Php Database Variable Lenghts
variable description size
Php



2
09/09/2023
Php Database Inserting Multiple Rows Into A Table
insert multiple records
Database
Php



0
12/04/2023
Php Date Date Functions
time date
$sessionid=strtotime(date("Y-m-d H:i:s"));

format character Description Example returned values
a Lowercase Ante meridiem and Post meridiem am or pm
A Uppercase Ante meridiem and Post meridiem AM or PM
B Swatch Internet time 000 through 999
c ISO 8601 date (added in PHP 5) 2004-02-12T15:19:21+00:00
d Day of the month, 2 digits with leading zeros 01 to 31
D A textual representation of a day, three letters Mon through Sun
F A full textual representation of a month, such as January or March January through December
g 12-hour format of an hour without leading zeros 1 through 12
G 24-hour format of an hour without leading zeros 0 through 23
h 12-hour format of an hour with leading zeros 01 through 12
H 24-hour format of an hour with leading zeros 00 through 23
i Minutes with leading zeros 00 to 59
I (capital i) Whether or not the date is in daylights savings time 1 if Daylight Savings Time, 0 otherwise.
j Day of the month without leading zeros 1 to 31
l (lowercase 'L') A full textual representation of the day of the week Sunday through Saturday
L Whether it's a leap year 1 if it is a leap year, 0 otherwise.
m Numeric representation of a month, with leading zeros 01 through 12
M A short textual representation of a month, three letters Jan through Dec
n Numeric representation of a month, without leading zeros 1 through 12
O Difference to Greenwich time (GMT) in hours Example: +0200
r RFC 2822 formatted date Example: Thu, 21 Dec 2000 16:01:07 +0200
s Seconds, with leading zeros 00 through 59
S English ordinal suffix for the day of the month, 2 characters st, nd, rd or th. Works well with j
t Number of days in the given month 28 through 31
T Timezone setting of this machine Examples: EST, MDT ...
U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) See also time()
w Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday)
W ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0) Example: 42 (the 42nd week in the year)
Y A full numeric representation of a year, 4 digits Examples: 1999 or 2003
y A two digit representation of a year Examples: 99 or 03
z The day of the year (starting from 0) 0 through 365
Z Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. -43200 through 43200


Unrecognized characters in the format string will be printed as-is. The Z format will always return 0 when using gmdate().

Example 1. date() examples
****************************************
a "am" or "pm"
A "AM" or "PM"
B Swatch Internet time
d day of the month, 2 digits with leading zeros; i.e. "01" to "31"
D day of the week, textual, 3 letters; i.e. "Fri"
F month, textual, long; i.e. "January"
g hour, 12-hour format without leading zeros; i.e. "1" to "12"
G hour, 24-hour format without leading zeros; i.e. "0" to "23"
h hour, 12-hour format; i.e. "01" to "12"
H hour, 24-hour format; i.e. "00" to "23"
i minutes; i.e. "00" to "59"
I (capital i) "1" if Daylight Savings Time, "0" otherwise.
j day of the month without leading zeros; i.e. "1" to "31"
l (lowercase 'L') day of the week, textual, long; i.e. "Friday"
L boolean for whether it is a leap year; i.e. "0" or "1"
m month; i.e. "01" to "12"
M month, textual, 3 letters; i.e. "Jan"
n month without leading zeros; i.e. "1" to "12"
r RFC 822 formatted date; i.e. "Thu, 21 Dec 2000 16:01:07 +0200" (added in PHP 4.0.4)
s seconds; i.e. "00" to "59"
S English ordinal suffix, textual, 2 characters; i.e. "th", "nd"
t number of days in the given month; i.e. "28" to "31"
T Timezone setting of this machine; i.e. "MDT"
U seconds since the epoch
w day of the week, numeric, i.e. "0" (Sunday) to "6" (Saturday)
Y year, 4 digits; i.e. "1999"
y year, 2 digits; i.e. "99"
z day of the year; i.e. "0" to "365"
Z timezone offset in seconds (i.e. "-43200" to "43200"). The offset for timezones west of UTC is always negative, and for those east of UTC is always positive
Php



2090
09/09/2023
Php Date Add Day
add day
Php



3
09/09/2023
Php Date Current Date
today
Php



2
09/09/2023
Php Date Getdate
date breakdown
Php



2
09/09/2023
Php Date Mktime - Create New Date
build date new date
Php



2
09/09/2023
Php Date String To Time
strtotime function convert
Php



4
02/12/2024
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



1402
09/09/2023
Php Files Getting A Files Extension
file extension
File Management
Php



0
11/20/2025
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



1289
09/09/2023
Php Files Write To Txt File
fopen fwrite rewind fopen write 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);
?>



Php



990
09/09/2023
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



1325
09/09/2023
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



752
09/09/2023
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



1
05/11/2025
Php Files Upload Multiple Files
multiple files upload download
Developer
Php



2
12/23/2023
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



0
05/11/2025
Php Files Create Directory File List After Database Backup
file list database backup example
Backup Sites
Php



0
12/19/2025
Php Files Copy A File In PHP
file copy
Copying Files
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



0
12/20/2025
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



1189
09/09/2023
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



808
09/09/2023
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



4
09/09/2023
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



2
09/09/2023
Php Formatting Html_entity_decode
decode format
Restoring Html Saves
Php



2
09/09/2023
Php Formatting Htmlentities
html convert format
Html, Php Saves
Php



2
09/09/2023
Php Formatting Remove Ascii > 127
ascii remove delete
String Cleanup
Php



0
03/07/2024
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



1235
09/09/2023
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



1617
09/09/2023
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



1767
09/09/2023
Php Function Quick Debug Routine
debug
Php



1
03/01/2024
Php Function Preg_match Is The Ereg Replacement
ereg eregi preg_match preg match
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



1253
09/09/2023
Php Function String
Length ord sub
Php



2
09/09/2023
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



2
09/09/2023
Php Function Get Current Directory Name And Path In PHP
working directory 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:
Php



2
09/09/2023
Php Function Protecting Passwords
Encrypt Decrypt security password
Security Code App
Php



3
02/22/2024

Software Web Design