Part 1 of 4
[ PHP ]
<?
$Short_Date_Format = "M j, Y";
$Date_Format = "F j, Y";
$DateTime_Format = "M j, Y, g:i a";
$DateTime_Form = "m/j/Y g:i a";
$DateTime_MySQL = "Y/m/d H:i:s";
$DB_User = "########";
$DB_Pass = "########";
$DB_Name = "#######";
$DB_Table_Prefix = "cls";
$Upload_Location_URI = '';
$Upload_Location = '';
$db = mysql_pconnect("localhost", $DB_User,$DB_Pass) or die("Unable to connect to SQL server!\n");
MySQL_select_db ($DB_Name, $db);
function set_oops ($String = "") {
static $oops = "";
$oops .= $String;
return $oops;
} // end set_oops ();
function set_message ($String = "") {
static $message = "";
$message .= $String;
return $message;
} // end set_message ();
function set_upload ($Upload_Target = "") {
static $Uploaded_Files = array();
$Uploaded_Files[] = $Upload_Target;
return $Uploaded_Files;
} // end set_upload ($Upload_Target);
function set_sql ($String = "") {
static $sql = "";
$sql .= $String;
return $sql;
} // end set_sql ();
function set_output ($String = "") {
static $Output = "";
$Output .= $String;
return $Output;
} // end set_output ();
function ref_addslashes (&$Process_Value, $Process_Key = "") {
$Process_Value = addslashes($Process_Value);
} // end custom_addslashes ();
function display_file_link ($Target_File, $Target_Text = "", $Target_Window = "_blank", $Status_Text = "Download this file") {
global $Session;
if (! $Target_Text) $Target_Text = $Target_File;
return $Session->display_link($Target_File, $Target_Text, $Target_Window, $Status_Text, "");
} // end display_file_link ($Target_File, $Target_Text = "")
function display_image ($Image_Name, $Alt_Tag = "", $Image_Path = "") {
$Handling_Speed = application_vars("Image_Handling_Speed");
if (! $Image_Path) $Image_Path = application_vars("Image_Storage_Path");
if (($Handling_Speed == "Fast")
OR (($Handling_Speed == "Medium") AND (strpos($Image_Name, "http://") !== false))) {
// runs faster because it doesn't have to check the size of the image.
// Medium speed only checks images located on the local file system.
if (strpos($Image_Name, "/") !== false) {
return "<IMG SRC=\"$Image_Name\" alt=\"".addslashes($Alt_Tag)."\" border=\"0\">";
} else {
return "<IMG SRC=\"/$Image_Path/$Image_Name\" alt=\"".addslashes($Alt_Tag)."\" border=\"0\">";
}
} else {
$Base_Directory = application_vars("Base_Application_Directory");
$Image_Directory = assemble_path_parts ($Base_Directory, $Image_Path);
if ((strpos($Image_Name, "/") !== false) && ($size = @GetImageSize("$Image_Name"))) {
return "<IMG SRC=\"$Image_Name\"" . $size[3] ." alt=\"".addslashes($Alt_Tag)."\" border=\"0\">";
} elseif ($size = @GetImageSize("$Image_Directory/$Image_Name")) {
return "<IMG SRC=\"/$Image_Path/$Image_Name\"" . $size[3] ." alt=\"".addslashes($Alt_Tag)."\" border=\"0\">";
} else {
if (strpos($Image_Name, "/") !== false) {
return display_file_link ($Image_Name, $Image_Name);
} else {
return display_file_link ("/$Image_Path/$Image_Name", "<font size=+2>$Image_Name</font>");
} // end if
} // end if/elseif
}
} // end display_image ($Image_Name, $Alt_Tag = "", $Image_Path = "")
function handle_incoming_data ($Field_Data) {
static $Files_Existing;
// Set this to true if you want to encrypt passwords in the database
// remember to run MySQL password on any existing passwords when you change this to true
// update users set User_Password = Password(User_Password);
$Encrypt_Passwords = true;
extract ($Field_Data);
if (is_array($_POST[$Post_Key])) {
foreach($_POST[$Post_Key] as $Key => $Value) {
$_POST[$Post_Key][$Key] = trim($Value);
} // end for loop
} // end if
else {
$_POST[$Post_Key] = trim ($_POST[$Post_Key]);
} // end else
// qualified function handling goes here...
// soon...
switch (strtolower($Qualify_Function)) {
case 'date_format':
case 'date_formatted':
if (($_POST[$Post_Key]) and ($_POST[$Post_Key] != '0000-00-00 00:00:00'))
$_POST[$Post_Key] = date ($GLOBALS["DateTime_MySQL"], strtotime($_POST[$Post_Key]));
break;
case 'upload_thumbnail':
case 'thumbnail_upload':
case 'upload_thumb':
case 'thumb_upload':
$Image_Resize = 'thumbnail';
case 'upload_image':
case 'image_upload':
$Image_Resize = best_of($Image_Resize,'full_image');
case 'upload_file':
case 'file_upload':
$File_Data = $_FILES[$Post_Key];
if (! $Field_Upload_Directory) {
$Base_Directory = application_vars("Base_Application_Directory");
$Field_Upload_Directory = assemble_path_parts ($Base_Directory, application_vars("File_Storage_Path"));
} // end if
if (! $File_Data["error"]) {
$Original_File_Name = $File_Data['name'];
if (strpos($Original_File_Name,'.'))
preg_match ("/(.+)(\.[^.]+)$/",$Original_File_Name, $File_Name);
else $File_Name = array (0,$Original_File_Name);
$Working_File_Name = preg_replace ("|[^a-zA-Z0-9._]|", "", $File_Name[1]);
$File_Extension = preg_replace ("|[^a-zA-Z0-9._]|", "", $File_Name[2]);
if (strlen($Working_File_Name) > 20) {
$Working_File_Name = substr($Working_File_Name, 0, 20);
} // end if (strlen($Working_File_Name) > 20)
if (! $Files_Existing) {
$Files_Existing = array();
$handle=opendir($Field_Upload_Directory);
while ($file = readdir($handle)) {
$Files_Existing[] = $file;
} // end while
} // end if (! $Files_Existing)
$File_Name = $Working_File_Name;
while (in_array("{$File_Name}{$File_Extension}", $Files_Existing) !== FALSE) {
$File_Name = $Working_File_Name . "_" . str_pad(++$i, 2, "0", STR_PAD_LEFT);
} // end while loop
if ($File_Extension) $File_Name .= $File_Extension;
$Upload_Target = assemble_path_parts ($Field_Upload_Directory, $File_Name);
if (move_uploaded_file($File_Data['tmp_name'], $Upload_Target)) {
chmod($Upload_Target,0606);
switch ($Image_Resize) {
case 'thumbnail':
$Thumbnail_Target = assemble_path_parts ($Base_Directory,
application_vars("Image_Thumbnail_Storage_Path"),
$File_Name);
$Thumb_Name = make_thumbnail ($Upload_Target,
$Thumbnail_Target,
[/code]