WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : These 2 functions write and read the contents of a specially designated multi-dimensional array to and from a text file.
Categories : Algorithms, PHP, Filesystem Update Picture
Mark Henderson
Date : Jan 17th 1999
Grade : 1 of 5 (graded 1 times)
Viewed : 6606
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Mark Henderson
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?
// ------------------------------------------------------------------
// PHP Session Management Functions
// ------------------------------------------------------------------
// Author: Mark Henderson (mark@togglemedia.com)
// Version: 0.01 (alpha)
// Disclaimer: Use of this code at your own risk
//
// These two functions read and write the contents of a
// multi-dimesional array, $session, to a file with a file name
// $session_id, stored in a directory $session_path.
//
// This is useful for applications wishing to keep state, where a
// "session id" is passed from page to page using either a cookie
// or a variable embeded in all URL's.
// ------------------------------------------------------------------

// ------------------------------------------------------------------
// READ SESSION
// ------------------------------------------------------------------

Function read_session() {

global $session, $session_path, $session_id;

/* set up session variables */

/* What should we do if the script cannot find the session file? */

$fp = fopen( $session_path.$session_id, "r" );

while(!feof($fp))
{
$line = fgets($fp,100);
$tok = strtok($line, "=");
$a = $tok;
$tok = strtok( "=");
$b = chop($tok);
$c = UrlDecode($b);
if((strlen($c) > 0) && (strlen($a) > 0))
{
eval( "\$session$a = \$c;");
}
}

fclose($fp);

return($fp);

}

// ------------------------------------------------------------------
// WRITE SESSION
// ------------------------------------------------------------------

Function write_session() {

global $session_path, $session_id, $session, $sm_string_array;

$level = 0;
unset($sm_string_array);
reset($session);

/* Write array to session file */
$fp = fopen($session_path . $session_id, "w");
if($fp != "false")
{
write_session_loop($fp);
} else {
echo "<h2>Session Error " . $fp . ": Cannot Write to File!</h2><br>\n";
}
fclose($fp);

}

Function write_session_loop($fp) {

global $session, $sm_string_array;
static $level=0;

if(IsSet($sm_string_array))
{
$num_elements_string_array = count($sm_string_array);
} else {
$num_elements_string_array = 0;
}

if($num_elements_string_array > 0)
{
$s=0;
$string = "";

while(($s < $num_elements_string_array) && IsSet($sm_string_array[$s]))
{
if(gettype($sm_string_array[$s]) == "string")
{
$string = $string . "['" . $sm_string_array[$s] . "']";
} else {
$string = $string . "[" . $sm_string_array[$s] . "]";
}

$s++;
}

} else {
$string= "";
}

eval( "\$test_array= \$session$string;");
if(gettype($test_array) == "array")
{
$num_elements = count($test_array);
} else {
$num_elements = 0;
eval( "\$value = \$session$string;");
$value_url = UrlEncode($value);
$pair = $string . "=" . $value_url;
fputs($fp, "$pair\n");
}
eval( "reset(\$session$string);");
$x=0;
while($x < $num_elements)
{
eval( "\$key = key(\$session$string);");
$sm_string_array[$level] = $key;
$level++;
unset($sm_string_array[$level]);
write_session_loop($fp); // loop recursively!!!
$level--;
eval( "next(\$session$string);");
$x++;
}
}
?>



Recursive function to move files on a filesystem. It can be minor changed in order to copy recursively.
Categories : PHP, Filesystem, Algorithms
Kasskooye($path) tell you the complete size of a folder
Categories : PHP, Algorithms, Utilities, Filesystem
Execute a command to a string
Categories : PHP, Program Execution, Filesystem
Fetching product details from the commission junction website using php
Categories : PHP, FTP, Filesystem, Compression
Single-file PHP news system with automatic folder structure creation
Categories : PHP, Filesystem, Arrays
Calculate the great circle distance between two latitude/longitudes
Categories : Algorithms, PHP
A PHP Script that shows how to use FTP to run a shell script, read two local files and update data in a database.
Categories : PHP, Filesystem, FTP, Date Time, Databases
A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
Read DPI value from image with PHP
Categories : PHP, Graphics, Filesystem
getDirArray(Path,Filter,Sorted): Returns an array of the files in a directory, filtered by regular expression and either sorted or randomized. Good for random pictures and graphics.
Categories : PHP, Filesystem, Directories
Grab images from one or more URLs and save them to a specified local directory.
Categories : PHP, Filesystem, Strings, Arrays
Listing the 10 most recently updated files in a given dir by using last- modified variable and printing to html with link to the file
Categories : PHP, Directories, Filesystem
The toll booth
Categories : PHP, Java Script, Filesystem
SHA: Implementation of the Secure Hash Algorithm in pure PHP. This is a secure one-way function that can be used to perform challenge response login algorithms over an insecure connection.
Categories : Algorithms, PHP, Security