From: Steve Sutton Date: Wed, 30 Nov 2016 19:57:41 +0000 (-0500) Subject: new sources X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;ds=inline;p=web%2Fwww.n8dnx.org.git new sources --- 3b5146a1a7c1b4da41606f9a3cb546dbe2ac276c diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..cf7ee90 --- /dev/null +++ b/.htaccess @@ -0,0 +1,6 @@ +Options +FollowSymLinks +RewriteEngine On +RewriteBase / +RewriteRule ^.*-([0-9]*)/$ index\.phtml?catid=$1 +RewriteRule site-map sitemap.php + diff --git a/FileExchange/data/index.html b/FileExchange/data/index.html new file mode 100644 index 0000000..26ae812 --- /dev/null +++ b/FileExchange/data/index.html @@ -0,0 +1,6 @@ + + + + + + diff --git a/FileExchange/help.phtml b/FileExchange/help.phtml new file mode 100644 index 0000000..84a92a5 --- /dev/null +++ b/FileExchange/help.phtml @@ -0,0 +1,45 @@ + + + Help + + +
'.$TOOLS_TITLE.'


+' ); + +include( "$TOOLS_HELP_PATH/$HELP_PAGE" ); + +print( ' +
+
+ Close Help Window +
+ + +' ); + +?> diff --git a/FileExchange/help_files/confirm_delete_file.hlp b/FileExchange/help_files/confirm_delete_file.hlp new file mode 100644 index 0000000..59386ad --- /dev/null +++ b/FileExchange/help_files/confirm_delete_file.hlp @@ -0,0 +1,6 @@ +
+

Confirm Delete File

+
+This page indicates that a file has been successfully deleted. You may click any menu item at the top +of the page to continue. +

diff --git a/FileExchange/help_files/customer_login.hlp b/FileExchange/help_files/customer_login.hlp new file mode 100644 index 0000000..d0655cb --- /dev/null +++ b/FileExchange/help_files/customer_login.hlp @@ -0,0 +1,27 @@ +

+

Logging in to File Exchange

+
+Before you can upload or download files, you must login with the ID and Password assigned to you.

+Once you login, you will be able to upload, download and delete files.

+If you don't know your ID and Password, you will need to contact the vendor who manages this file exchange +for assistance.

+


+

+

+

Menu Options

+
+At the top of each page you will find a menu. Items in this menu may or may not be available depending on +what you're doing at the time. If the items in this menu are not highlighted, they are not available. If +they are highlighted, you may click on them to access those functions + +
+
List Files +
Return to the list of files that have been uploaded. +

+

Upload a new file +
Display a form used to upload a new file. +

+

Login as a different customer +
If you have more than one customer account with this vendor, you may select this function to + login with a different ID and password. +

diff --git a/FileExchange/help_files/delete_file.hlp b/FileExchange/help_files/delete_file.hlp new file mode 100644 index 0000000..144b227 --- /dev/null +++ b/FileExchange/help_files/delete_file.hlp @@ -0,0 +1,7 @@ +

+

Delete File

+
+You will be presented with this screen when you select the "Delete" action for a file in the file list. +To actually delete the file, select "Confirm Delete" in the Action field. If you do not select "Confirm Delete", +the file will not be deleted. +

diff --git a/FileExchange/help_files/error.hlp b/FileExchange/help_files/error.hlp new file mode 100644 index 0000000..c6114c0 --- /dev/null +++ b/FileExchange/help_files/error.hlp @@ -0,0 +1,6 @@ +

+

Error

+
+ An error of some sort has occured. Please read the error message displayed on the + screen to determine what went wrong. +

diff --git a/FileExchange/help_files/list_files.hlp b/FileExchange/help_files/list_files.hlp new file mode 100644 index 0000000..3ae0744 --- /dev/null +++ b/FileExchange/help_files/list_files.hlp @@ -0,0 +1,40 @@ +

+

List files

+
+This screen lists all files that are currently available, whether they were uploaded by you or by the +vendor.

+


+

+

+

Fields listed

+
+
+
File +
This is the name of the file. You may view or download this file by clicking on the file name. + To force the file to download rather than displaying on your screen, click your right mouse + button and select "Save target as..." (or whatever is appropriate for your browser). +

+

Date +
This field contains the date and time the file was uploaded. The list of files is ordered by + date and time, with the more receint uploads near the top. +

+

Size +
Size in "bytes" of this file. +

+

Type +
This is the type of the file. The File Exchange will make a best guess at the type of the file. +

+

Direction +
This field indicates whether the file was uploaded by you (From You) or by the vendor (To You). + The color of this field is either green or blue (From You or To You respectively). +

+

Action +
This field indicates actions that you may take on the file. In general, the only option available + will be to delete the file. +

+

(Second Line) +
The second line of information for each file contains any description that may have been provided + when the file was uploaded. +

+ + diff --git a/FileExchange/help_files/login_failure.hlp b/FileExchange/help_files/login_failure.hlp new file mode 100644 index 0000000..d9c5934 --- /dev/null +++ b/FileExchange/help_files/login_failure.hlp @@ -0,0 +1,6 @@ +

+

Login Failure

+
+You have reached this page because you failed to login correctly. You will need both an ID and a password +to access this file exchange. For assistance, contact the vendor who manages this file exchange. +

diff --git a/FileExchange/help_files/upload_file.hlp b/FileExchange/help_files/upload_file.hlp new file mode 100644 index 0000000..8b67463 --- /dev/null +++ b/FileExchange/help_files/upload_file.hlp @@ -0,0 +1,7 @@ +

+

Upload File

+
+This page indicates that the file was properly uploaded and that an E-Mail message has been sent +to the vendor to let them know the file is available. Click on "Continue" or select an item from +the menu at the top of the screen. +

diff --git a/FileExchange/help_files/upload_new_file.hlp b/FileExchange/help_files/upload_new_file.hlp new file mode 100644 index 0000000..96fa708 --- /dev/null +++ b/FileExchange/help_files/upload_new_file.hlp @@ -0,0 +1,20 @@ +

+

Upload New File

+
+This form is used to upload a new file. When you upload a new file, the vendor will receive +E-Mail informing them that the file is available. +

+


+

+

+

Fields

+
+
+
File to upload +
Enter the complete path and filename of the file you would like to upload or + click "Browse..." to select a file from your system. +

+

Description +
Enter a description, comments or instructions you would like to be sent to the + vendor along with this file +

diff --git a/FileExchange/images/closewindow.gif b/FileExchange/images/closewindow.gif new file mode 100644 index 0000000..c54ed89 Binary files /dev/null and b/FileExchange/images/closewindow.gif differ diff --git a/FileExchange/images/gaslight.gif b/FileExchange/images/gaslight.gif new file mode 100644 index 0000000..7ca754f Binary files /dev/null and b/FileExchange/images/gaslight.gif differ diff --git a/FileExchange/images/gaslight_small.jpg b/FileExchange/images/gaslight_small.jpg new file mode 100644 index 0000000..1179f68 Binary files /dev/null and b/FileExchange/images/gaslight_small.jpg differ diff --git a/FileExchange/images/help.gif b/FileExchange/images/help.gif new file mode 100644 index 0000000..4915678 Binary files /dev/null and b/FileExchange/images/help.gif differ diff --git a/FileExchange/images/helpbg.gif b/FileExchange/images/helpbg.gif new file mode 100644 index 0000000..0b62415 Binary files /dev/null and b/FileExchange/images/helpbg.gif differ diff --git a/FileExchange/index.phtml b/FileExchange/index.phtml new file mode 100644 index 0000000..55cac95 --- /dev/null +++ b/FileExchange/index.phtml @@ -0,0 +1,454 @@ + + + '.$TOOLS_TITLE.' + + + +

+ + + + + + + + + + +
+ + + + + + +
  + '.$TOOLS_TITLE.'
+ '.$page_title.' +
+ + +
+
+
+ '; + + switch( $current_page ) + { + case "customer_login": + $list_files_link = FALSE; + $upload_new_file_link = FALSE; + $login_link = FALSE; + break; + case "login_failure": + $list_files_link = FALSE; + $upload_new_file_link = FALSE; + $login_link = TRUE; + break; + case "list_files": + $list_files_link = FALSE; + $upload_new_file_link = TRUE; + $login_link = TRUE; + break; + case "upload_new_file": + $list_files_link = TRUE; + $upload_new_file_link = FALSE; + $login_link = TRUE; + break; + case "upload_file": + $list_files_link = TRUE; + $upload_new_file_link = TRUE; + $login_link = TRUE; + break; + case "delete_file": + $list_files_link = TRUE; + $upload_new_file_link = TRUE; + $login_link = TRUE; + break; + case "confirm_delete_file": + $list_files_link = TRUE; + $upload_new_file_link = TRUE; + $login_link = TRUE; + break; + case "error": + $list_files_link = TRUE; + $upload_new_file_link = TRUE; + $login_link = TRUE; + break; + default: + error_msg( "Invalid page ID", __FILE__, __LINE__, $current_page ); + break; + } + + echo "| "; + + // if not permitted to upload, don't display link + if( $cust_data['post'] == "f" ) + $upload_new_file_link = FALSE; + + if( $list_files_link ) + echo 'List files | '; + else + echo 'List files | '; + + if( $upload_new_file_link ) + echo 'Upload new file | '; + else + echo 'Upload new file | '; + + if( $login_link ) + echo 'Login as different customer | '; + else + echo 'Login as different customer | '; + + echo ' 

+ '; + + +} + +function do_footer() +{ + + global $LF_FOOTER_CLR, $LF_COPYWRIGHT_CLR, $GM_COPYWRIGHT; + + echo '  

+

'.$GM_COPYWRIGHT.'
+
+ + + '; + +} + +function error_msg( $message ) +{ + do_header(); + echo $message; + do_footer(); + exit; +} + + // Open Database + +if( !$conn = pg_connect( SI_CONN_STR ) ) + error_msg( "Can't open database", __FILE__, __LINE__, "" ); + + // If customer number is supplied, retrieve data + +$page_title = "Error"; // Just in case we have a failure we'll have something for the header +$current_page = "error"; + +if( isset($cust) && ($cust != "") ) + { + if( !($cust_result = pg_Exec( $conn, "SELECT * FROM cust WHERE custnum = $cust;") ) ) + error_msg( "Can't retrieve customer information", __FILE__, __LINE__, "" ); + if( pg_NumRows( $cust_result ) != 1 ) + error_msg( "Retrieved wrong number of results", __FILE__, __LINE__, "" ); + if( !($cust_data = pg_fetch_array($cust_result, 0)) ) + error_msg( "Can't retrieve customer data", __FILE__, __LINE__, "" ); + + // Check for valid login + + if( $usercode != $cust_data['directory'] ) + error_msg( "Invalid customer session", __FILE__, __LINE__, "" ); + } + + // If file number is supplied, retrieve data + +if( isset($file) && ($file != "") ) + { + if( !($file_result = pg_Exec( $conn, "SELECT * FROM file WHERE filenum = $file;") ) ) + error_msg( "Can't retrieve file information", __FILE__, __LINE__, "" ); + if( pg_NumRows( $file_result ) == 0 ) + error_msg( "File was not found", __FILE__, __LINE__, "" ); + if( pg_NumRows( $file_result ) != 1 ) + error_msg( "Retrieved wrong number of results", __FILE__, __LINE__, "" ); + if( !($file_data = pg_fetch_array($file_result, 0)) ) + error_msg( "Can't retrieve file data", __FILE__, __LINE__, "" ); + } + +switch( $action ) + { + + case "Login": + $page_title = "Login Failure"; + $current_page = "login_failure"; + + // Check to see if ID and Password are supplied + + if( !isset($id) || ($id == "") || !isset($passwd) || ($passwd == "") ) + error_msg( "Both ID and password are required", __FILE__, __LINE__, "" ); + + // Retrieve customer record + + if( !($cust_result = pg_Exec( $conn, "SELECT * FROM cust WHERE id = '$id' AND passwd = '".md5($passwd)."';") ) ) + error_msg( "ID and password do not match", __FILE__, __LINE__, "" ); + if( pg_NumRows( $cust_result ) != 1 ) + error_msg( "ID and password do not match any listed customer", __FILE__, __LINE__, + 'Continue' ); + if( !($cust_data = pg_fetch_array($cust_result, 0)) ) + error_msg( "Can't retrieve customer data", __FILE__, __LINE__, "" ); + + $usercode = $cust_data['directory']; + $cust = $cust_data['custnum']; + + // No break here. If login is successfull, it falls down to "List Files" + + case "List Files": + $page_title = "List Files"; + $current_page = "list_files"; + do_header(); + + // Retrieve List of Files + + if( !($files_result = pg_Exec( $conn, "SELECT * FROM file WHERE custnum = $cust ORDER BY date DESC;") ) ) + error_msg( "Can't retrieve files information", __FILE__, __LINE__, "" ); + + // Display Files Table Header + + echo $LF_HEAD1.'Files List
+

+ + + '; + + // List each file with actions + + if( ($num = pg_NumRows($files_result)) == 0 ) + echo ''; + else + for( $i=0 ; $i<$num ; $i++ ) + { + $file_data = pg_Fetch_Array($files_result, $i); + + echo ' + + + + + + + + + + '; + } + + echo "
FileDateSizeTypeDirectionAction
No Files Listed
' + .$file_data['name'].''.$file_data['date'].''.$file_data['size'].''.$file_data['type'].''.($file_data['source']==0 ? 'To You' : + 'From You').''; + + if( $cust_data['delete'] == "t" ) + echo 'Delete'; + else + echo ' '; + + echo '
 ' + .($file_data['descr']!=""?$file_data['descr']:"(description not supplied)").'
"; + + do_footer(); + break; + + case "Upload New File": + $page_title = "Upload New File"; + $current_page = "upload_new_file"; + do_header(); + + if( !($admin_result = pg_Exec( $conn, "SELECT * FROM admin;" )) ) + error_msg( "Can't retrieve system information", __FILE__, __LINE__, "" ); + if( !($admin_data = pg_fetch_array($admin_result, 0)) ) + error_msg( "Can't retrieve system information", __FILE__, __LINE__, "" ); + + + echo $LF_HEAD1.'Upload file for: '.$admin_data['name'].'
+

+

+ + + + + + + + + +
File to upload
Description
+
+ '; + + do_footer(); + break; + + + case "Upload File": + $page_title = "Upload File"; + $current_page = "upload_file"; + do_header(); + + // Check to see if file was uploaded + + if( !file_exists($uploadfile) ) + error_msg( "No file uploaded.", __FILE__, __LINE__, "" ); + + // Check to see if a file of the same name is currently listed + + $converted_file_name = str_replace( " ", "_", $uploadfile_name ); // Convert " " to "_" + $filename = $converted_file_name; + for( $seq=0 ; ; $seq++ ) + { + + // If this isn't the first try, afix a sequence number on the end of the filename + + if( $seq > 0 ) + $filename = $seq."_".$converted_file_name; + + // Check to see if there's already a file of that name + + if( !($file_result = pg_Exec( $conn, "SELECT * FROM file WHERE name = '$filename';") ) ) + error_msg( "Can't retrieve customer information", __FILE__, __LINE__, "" ); + if( pg_NumRows( $file_result ) == 0 ) // If not + break; // Exit for() + + } + + // Copy file to customers directory + + if( !copy( $uploadfile, "$DATA_PATH/".$cust_data['directory']."/$filename" ) ) + error_msg( "Can't copy file to customer's directory.", __FILE__, __LINE__, "" ); + + // Store information on this file + + if( !isset($uploadfile_type) ) + $uploadfile_type = "(unknown)"; + + if( !pg_exec( $conn, "INSERT INTO file (custnum, name, date, size, type, source, ipaddr, descr) + VALUES ($cust, '$filename', 'now', $uploadfile_size, '$uploadfile_type', 1, + '".getenv("REMOTE_ADDR")."', '$description');" ) ) + error_msg( "Can't store file information.", __FILE__, __LINE__, "" ); + + // Notify customer + + if( !($admin_result = pg_Exec( $conn, "SELECT * FROM admin;") ) ) + error_msg( "Can't retrieve customer information", __FILE__, __LINE__, "" ); + $admin = pg_Result( $admin_result, 0, "name" ); + $admin_email = pg_Result( $admin_result, 0, "email" ); + + mail( $admin_email, "New file available from ".$cust_data['name'], + "\nA new file is available for you to download.\n\n" + ."From: ".$cust_data['name']."\n" + ."File Name: $filename\n" + ."Size: $uploadfile_size\n" + ."Type: $uploadfile_type\n\n" + ."File Description\n" + ."----------------\n" + ."$description\n\n", "From: ".$cust_data['email'] ); + + + echo 'File Uploaded

+ Continue + '; + + do_footer(); + break; + + + case "Delete File": + $page_title = "Delete File"; + $current_page = "delete_file"; + do_header(); + + echo $LF_HEAD1.'Delete File
+ + + + + + + + + + + +
FileDateSizeTypeDirectionIP AddressAction
' + .$file_data['name'].''.$file_data['date'].''.$file_data['size'].''.$file_data['type'].''.($file_data['source']==0 ? 'To Customer' : + 'From Customer').''.$file_data['ipaddr'].' + Confirm Delete +
 ' + .($file_data['descr']!=""?$file_data['descr']:"(description not supplied)").'
+ '; + + do_footer(); + break; + + case "Confirm Delete File": + $page_title = "Confirm Delete File"; + $current_page = "confirm_delete_file"; + do_header(); + + pg_Exec( $conn, "DELETE FROM file WHERE filenum = $file;" ); + + if( ! unlink($DATA_PATH.'/'.$cust_data['directory'].'/'.$file_data['name']) ) + error_msg( "Unable to delete file", __FILE__, __LINE__, "" ); + + + echo $file_data['name'].' DELETED

+ '; + + do_footer(); + break; + + + default: + $page_title = "Customer Login"; + $current_page = "customer_login"; + do_header(); + echo $LF_HEAD1.'Please login... +

+

+ Customer ID + Password + +
+ '; + do_footer(); + break; + + } + +?> diff --git a/FileExchange/setup.inc b/FileExchange/setup.inc new file mode 100644 index 0000000..bce1227 --- /dev/null +++ b/FileExchange/setup.inc @@ -0,0 +1,262 @@ +'; + + // Misc Definitions + +$ENTRIES_PER_PAGE = 10; +$GM_COPYWRIGHT = "Copyright © 1998-2000 Gaslight Media - All rights reserved."; + +$header_sent = FALSE; + +//***************************** FUNCTION DECLARATIONS *********************************** + + // Display error message + +function error_msg( $error, $file, $line, $other ) +{ + global $DEBUG, $header_sent, $TOOLS_TITLE; + + if( !isset($header_sent) || !$header_sent ) + { + $page_title = "$TOOLS_TITLE - ERROR"; + $current_page = "error"; + do_header(); + } + print( " 

An error occured: $error
" ); + if( $DEBUG ) + print( "

File:              $file
Line: $line
Other Info:
" ); + + + if( is_array($other) ) + while( list($key,$val) = each($other) ) + print( $val ); + else + print( $other ); + + print( "
 

" ); + do_footer(); + exit; +} + +function do_header() +{ + + global $page_title, $current_page, $LF_BG_CLR, $LF_LINK_CLR, $LF_VLINK_CLR, $LF_ALINK_CLR, $LF_TABLE_CLR, + $LF_HEADER_CLR, $LF_TITLE_CLR, $LF_TITLE_2_CLR, $LF_NOLINK_CLR, $TOOLS_IMAGES_URL, $TOOLS_TITLE, + $TOOLS_URL, $session, $domains, $current_page, $header_sent, $domain, $cust, $usercode, $cust_data; + + $header_sent = TRUE; + + echo ' + + + '.$TOOLS_TITLE.' + + + +

+ + + + + + + + + + +
+ + + + + + +
+ '.$TOOLS_TITLE.'
+ '.$page_title.' +
+ + +
+
+
+ '; + + switch( $current_page ) + { + case "customer_login": + $list_files_link = FALSE; + $upload_new_file_link = FALSE; + $login_link = FALSE; + break; + case "login_failure": + $list_files_link = FALSE; + $upload_new_file_link = FALSE; + $login_link = TRUE; + break; + case "list_files": + $list_files_link = FALSE; + $upload_new_file_link = TRUE; + $login_link = TRUE; + break; + case "upload_new_file": + $list_files_link = TRUE; + $upload_new_file_link = FALSE; + $login_link = TRUE; + break; + case "upload_file": + $list_files_link = TRUE; + $upload_new_file_link = TRUE; + $login_link = TRUE; + break; + case "delete_file": + $list_files_link = TRUE; + $upload_new_file_link = TRUE; + $login_link = TRUE; + break; + case "confirm_delete_file": + $list_files_link = TRUE; + $upload_new_file_link = TRUE; + $login_link = TRUE; + break; + case "error": + $list_files_link = TRUE; + $upload_new_file_link = TRUE; + $login_link = TRUE; + break; + default: + error_msg( "Invalid page ID", __FILE__, __LINE__, $current_page ); + break; + } + + echo "| "; + + // if not permitted to upload, don't display link + if( $cust_data['post'] == "f" ) + $upload_new_file_link = FALSE; + + if( $list_files_link ) + echo 'List files | '; + else + echo 'List files | '; + + if( $upload_new_file_link ) + echo 'Upload new file | '; + else + echo 'Upload new file | '; + + if( $login_link ) + echo 'Login as different customer | '; + else + echo 'Login as different customer | '; + + echo ' 

+ '; + + +} + +function do_footer() +{ + + global $LF_FOOTER_CLR, $LF_COPYWRIGHT_CLR, $GM_COPYWRIGHT; + + echo '  

+

'.$GM_COPYWRIGHT.'
+
+ + + '; + +} + +function fail( $message ) +{ + do_header(); + echo $message; + do_footer(); + exit; +} diff --git a/GLM_site_check.phtml b/GLM_site_check.phtml new file mode 100644 index 0000000..3a1cd37 --- /dev/null +++ b/GLM_site_check.phtml @@ -0,0 +1,19 @@ + + diff --git a/NQSMHS_to_VXR5000.pdf b/NQSMHS_to_VXR5000.pdf new file mode 100644 index 0000000..7cec87c Binary files /dev/null and b/NQSMHS_to_VXR5000.pdf differ diff --git a/admin/GLMbug.gif b/admin/GLMbug.gif new file mode 100755 index 0000000..20b12d8 Binary files /dev/null and b/admin/GLMbug.gif differ diff --git a/admin/Toolbox/business.sql b/admin/Toolbox/business.sql new file mode 100755 index 0000000..4d4dcc4 --- /dev/null +++ b/admin/Toolbox/business.sql @@ -0,0 +1,89 @@ +\connect - postgres + +CREATE TABLE "bus" ( + "id" SERIAL, + "name" text, + "description" text, + "description2" text, + "description3" text, + "image" text, + "imagename" text, + "image2" text, + "image2name" text, + "image3" text, + "image3name" text, + "urlname" text, + "url" text, + "address" text, + "city" text, + "state" text, + "zip" text, + "phone" text, + "fax" text, + "email" text, + "pos" integer, + "file" text, + "filename" text, + "file2" text, + "file2name" text, + "file3" text, + "file3name" text, + "contactname" text +); + +REVOKE ALL on "bus" from PUBLIC; +GRANT ALL on "bus" to "nobody"; +GRANT ALL on "bus" to "postgres"; + +REVOKE ALL on "bus_id_seq" from PUBLIC; +GRANT ALL on "bus_id_seq" to "nobody"; +GRANT ALL on "bus_id_seq" to "postgres"; + +CREATE TABLE "bus_category" ( + "id" SERIAL, + "parent" integer, + "category" text, + "intro" text, + "description" text, + "image" text, + "active" bool, + "pos" integer, + "keyword" text, + "template" int +); + +REVOKE ALL on "bus_category" from PUBLIC; +GRANT ALL on "bus_category" to "nobody"; +GRANT ALL on "bus_category" to "postgres"; + +REVOKE ALL on "bus_category_id_seq" from PUBLIC; +GRANT ALL on "bus_category_id_seq" to "nobody"; +GRANT ALL on "bus_category_id_seq" to "postgres"; + +CREATE TABLE "bus_category_bus" ( + "id" SERIAL, + "busid" integer, + "catid" integer, + "pos" integer +); + +REVOKE ALL on "bus_category_bus" from PUBLIC; +GRANT ALL on "bus_category_bus" to "nobody"; +GRANT ALL on "bus_category_bus" to "postgres"; + +REVOKE ALL on "bus_category_bus_id_seq" from PUBLIC; +GRANT ALL on "bus_category_bus_id_seq" to "nobody"; +GRANT ALL on "bus_category_bus_id_seq" to "postgres"; + +CREATE UNIQUE INDEX bus_id_indx ON bus (id); + +CREATE UNIQUE INDEX bus_category_id_indx ON bus_category (id); +CREATE INDEX bus_category_parent_indx ON bus_category (parent); +CREATE INDEX bus_category_pos_indx ON bus_category (pos); +CREATE INDEX bus_category_keyword_indx ON bus_category (keyword); +CREATE INDEX bus_category_template_indx ON bus_category (template); + +CREATE UNIQUE INDEX bus_category_bus_id_indx ON bus_category_bus (id); +CREATE INDEX bus_category_bus_busid_indx ON bus_category_bus (busid); +CREATE INDEX bus_category_bus_catid_indx ON bus_category_bus (catid); + diff --git a/admin/Toolbox/edit_bus.phtml b/admin/Toolbox/edit_bus.phtml new file mode 100755 index 0000000..37b73a0 --- /dev/null +++ b/admin/Toolbox/edit_bus.phtml @@ -0,0 +1,246 @@ + "", + "catid" => $catid, + "address" => "", + "city" => "", + "state" => "", + "zip" => "", + "phone" => "", + "fax" => "", + "email" => "", + "url" => "", + "description" => "", + "image" => "", + "description2" => "", + "image2" => "", + "description3" => "", + "image3" => "", + "file" => "", + "file2" => "", + "file3" => "" + ); +} + +top2("Updatable Paragraphs (Add/Edit)", HELP_BASE."bus.phtml?key=edit","ToolboxUserGuide_1.0"); + +$lnav["List Paragraphs"] = "list_bus.phtml?catid=$catid"; +html_nav_table($lnav, 3); + +$qs = "SELECT id,category +FROM bus_category +ORDER BY parent,pos"; + +if(!$altcats = db_exec($dbd,$qs)) +html_error(DB_ERROR_MSG.$qs,0); + +?> + + + +
+ + + + "; + + echo "Pages:"; + if(isset($id) && $id != "") { + $qs = "SELECT bc.id as catid, bcb.id as id,bc.category,bcb.pos + FROM bus_category bc,bus_category_bus bcb,bus b + WHERE bcb.busid = $id + AND bcb.catid = bc.id + AND b.id = bcb.busid + ORDER BY bc.category"; + + if(!$altres = db_exec($dbd,$qs)) + html_error(DB_ERROR_MSG.$qs,0); + + for($rel=0;$rel + Page: + + + + + + + + +
"; + +foreach($fields as $key=>$value) { + if($value[type] == "text") { + ?> + + + +
'; + echo ''.$value["name"].''; +} +elseif($value[type] == "img") { +?> + +"; +if($row[$value[name]] != "") { + echo "Current Image:"; + echo " + + + + Delete this image: + + Yes + No + + "; +} +echo "New $value[title]:"; + echo ""; + echo ""; + } + elseif($value[type] == "file") { + ?> + + "; + if($row[$value[name]] != "") { + echo "Current File:"; + echo "".$row[$value[name]]." + + + + Delete this File: + + Yes + No + + "; + } + echo "New $value[title]:"; + echo ""; + echo ""; +} +if($value[type] == "desc") { + echo "$value[title]:"; + text_area("$value[name]",htmlspecialchars($row[$value[name]])); + echo ""; +} +elseif($value[type] == "hide") { + echo ""; +} +elseif($value[type] == "bool") { + echo "$value[title]:"; + echo "Yes"; + echo "No"; + + echo ""; + } +} +htmlcode(570,400); +echo "\n"; +echo " +"; +echo ''; +if(isset($id)) { +?> + + + + + + "; + +footer(); +?> diff --git a/admin/Toolbox/edit_bus_category.phtml b/admin/Toolbox/edit_bus_category.phtml new file mode 100755 index 0000000..405b68e --- /dev/null +++ b/admin/Toolbox/edit_bus_category.phtml @@ -0,0 +1,229 @@ + "list_bus_category.phtml" + ); +if(!CAT_LOCK) + $lnav["Add Page"] = "edit_bus_category.phtml"; + html_nav_table($lnav, 2); + +if(!$dbd = db_connect()) html_error(DB_ERROR_MSG, 1); + +if(isset($id)) + { + if( DELUXE_TOOLBOX == 1 ) + { + $qs = "SELECT id,category,intro,parent,description,image,keyword,template,pos + FROM bus_category + WHERE id = $id"; + } + else + { + $qs = "SELECT id,category,intro,parent,description,image,pos + FROM bus_category + WHERE id = $id"; + } + + if(!$res = db_exec($dbd, $qs)) + html_error(DB_ERROR_MSG,1); + + $row = db_fetch_array($res,0, PGSQL_ASSOC); + if(!$row[id]) + { + html_error(DB_ERROR_MSG,1); + } + } +else + { + if( DELUXE_TOOLBOX == 1 ) + { + $row = array( + "category" => "", + "intro" => "", + "parent" => "", + "description" => "", + "image" => "", + "keyword" => "", + "template" => "1" + ); + } + else + { + $row = array( + "category" => "", + "intro" => "", + "parent" => "", + "description" => "", + "image" => "" + ); + } + } +form_header("update_bus_category.phtml?".SID,"POST",""); +echo ""; + +foreach($row as $key=>$value) { + switch($key) { + + case "id": + echo ""; + break; + + case "pos": + echo ""; + break; + + case "parent": + echo ""; + $output = parent_select($value,$id); + if(!$dbd = db_connect()) html_error(DB_ERROR_MSG, 1); + echo ""; + echo ""; + break; + + case "category": + + echo ""; + text_box("category",$value); + echo ""; + break; + + case "intro": + + echo ""; + text_box("intro",$value); + echo ""; + break; + + case "image": + echo ""; + echo " + + + + "; + } + echo ""; + break; + + case "description": + echo ""; + text_area("description",htmlspecialchars($value),15,60); + echo ""; + break; + + case "keyword": + echo ""; + text_box("keyword",$value); + echo ""; + break; + + case "template": + echo ""; + echo ""; + break; + + default: + html_error("Incorrect Value -> ".$key,1); + break; + } +} + +htmlcode(); +if(isset($id)) { + $qs = "SELECT count(*) as count + FROM bus_category_bus + WHERE catid = $id"; + + if(!$res = db_exec($dbd,$qs)) + html_error(DB_ERROR_MSG.$qs,0); + + $row = db_fetch_array($res,0,PGSQL_ASSOC); + ?> + + "; + +footer(); +?> diff --git a/admin/Toolbox/help/bus.phtml b/admin/Toolbox/help/bus.phtml new file mode 100755 index 0000000..7676d61 --- /dev/null +++ b/admin/Toolbox/help/bus.phtml @@ -0,0 +1,186 @@ + + +Help + + + +

Listings Help

+
+ +

List Listings

+ +

+This page lists the existing Listings. +

+

+Add A New Listing +

+

This link will allow you to add new Listing

+

+List Listings +

+

This link is the page you are currently viewing

+ +

+[Edit] +

+

This link will let you edit an existing Listing

+ +

Edit a Listing

+

+This page is for editing and modifying an existing Listing in the database. +When editing is complete, click on the "Submit Query" button. The database will +be updated, and you will be directed back to the "List Listings" page. +

+

+Name: +This is the name of the listing. +

+ +

+Category +Choose the correct category for this listing. Default to the category that you +have choosen to list. +

+ +

+Description: +

+

This is the text which will appear as a complete description of the Link, +in the Detailed output of the Link

+

+Address: +This is the address of the listing. +

+ +

+Phone: +This is the Phone Number of the listing. +

+ +

+Fax: +This is the Fax Number of the listing. +

+ +

+Email: +This is the Email of the listing. +

+ +

+URL: +

+

This is the web site 5 you want the users to go to when they click the +link. Don't enter in http://. +

+

+Picture for Listing: +

+

If you choose, you may upload an image which will be displayed on the +Detailed output for the Listing. To upload an image, click the "Browse" button. +For the image to be displayed properly, it must be either a "GIF" or "JPEG" +formatted image. Generally, these are saved as filename.gif or filename.jpg. +If you receive an error message while trying to upload an image, the most +common error is that the image is neither a JPEG nor a GIF. Also note that +simply renaming the file from filename.foo to filename.gif will not reformat +the image as a GIF. +

+ +

+Submit Query +

+

When you have made the changes you want to the Link, +you can click "Submit Query." This will update the information about the +Link in the database. +

+ +

ADD an Link

+

+This page is for Adding Links in the database. +When form is complete, click on the "Submit Query" button. The database will +be updated, and you will be directed back to the "List Links" page. +

+ +

+Name: +This is the name of the listing. +

+ +

+Category +Choose the correct category for this listing. Default to the category that you +have choosen to list. +

+ +

+Description: +

+

This is the text which will appear as a complete description of the Link, +in the Detailed output of the Link

+

+Address: +This is the address of the listing. +

+ +

+Phone: +This is the Phone Number of the listing. +

+ +

+Fax: +This is the Fax Number of the listing. +

+ +

+Email: +This is the Email of the listing. +

+ +

+URL: +

+

This is the web site 5 you want the users to go to when they click the +link. Don't enter in http://. +

+ +

+Picture for Link: +

+

If you choose, you may upload an image which will be displayed on the +Detailed output for the Link. To upload an image, click the "Browse" button. +For the image to be displayed properly, it must be either a "GIF" or "JPEG" +formatted image. Generally, these are saved as filename.gif or filename.jpg. +If you receive an error message while trying to upload an image, the most +common error is that the image is neither a JPEG nor a GIF. Also note that +simply renaming the file from filename.foo to filename.gif will not reformat +the image as a GIF. +

+ +

+Submit Query +

+

When you have made the changes you want to the Link, +you can click "Submit Query." This will update the information about the +Link in the database. +

+ +
+
+ + diff --git a/admin/Toolbox/help/buscat.phtml b/admin/Toolbox/help/buscat.phtml new file mode 100755 index 0000000..69e4785 --- /dev/null +++ b/admin/Toolbox/help/buscat.phtml @@ -0,0 +1,159 @@ + + +Help + + + +

Listings Help

+
+ +

List Categories

+

+This page lists the existing Listings Categories in the database. +

+

+Add A New Category +

+

This link will allow you to add new Categories

+

+List Categories +

+

This link is the page you are currently viewing

+ +

+[Edit] +

+

This link will let you edit an existing Category

+

+[Listings] +

+

+This link will list out the Listings Items associated with a particular Category +

+

+

Notice:

The categories are Displayed in a order based on there +hierarchy. +

+ + +

Edit a Category

+

+This page is for editing and modifying the existing Listings Categories in the database. +When editing is complete, click on the "Update" button. The database will +be updated, and you will be directed back to the "List Categories" page. +

+ +

+Title: +

+

This is the title that will appear for the "Category" i.e. "Pictures of The Island"

+

+Intro: +

+

This is the text which will introduce the Category. This text will be +displayed below the Category Title. +

+ +

+Description: +

+

This is the text which will fully describe the Category. This text will be +displayed below the Category Title and Intro. +

+

+Current Image: +

+

If the record you are editing has an uploaded image, you will see the Current Image: header, and a small version of the image associated with this Category. +

+Delete This Image: +

+

If the record you are editing has an uploaded image, you will see the Delete This Image: header, and "Yes" and "No" radio buttons. If you choose "Yes" and then "Update" the Room Rate, you will have permanently removed the "Current Image". The default value is "No." +

+

+New Image: +

+

+If you choose, you may upload an image which will be displayed on the +output for the Category. To upload an image, click the "Browse" button. +For the image to be displayed properly, it must be either a "GIF" or "JPEG" +formatted image. Generally, these are saved as filename.gif or filename.jpg. +If you receive an error message while trying to upload an image, the most +common error is that the image is neither a JPEG nor a GIF. Also note that +simply renaming the file from filename.foo to filename.gif will not reformat +the image as a GIF. +

+ +

+Update +

+

When you have made the changes you want to the 0, +you can click "Update." This will update the information about the Category +in the database. +

+

+Delete +

+

If you want to remove the current Category, press the "Delete" button. +

+ +

Add Category

+

+This page is for adding Listings Categories in the database. +When editing is complete, click on the "Insert" button. The database will +be updated, and you will be directed back to the "List Categories" page. +

+

+Title: +

+

This is the title that will appear for the "Category" i.e. "Pictures of The Island"

+

+Intro: +

+

This is the text which will introduce the Category. This text will be +displayed below the Category Title in the Gallery. +

+ +

+Description: +

+

This is the text which will fully describe the Category. This text will be +displayed below the Category Title and Intro in the Gallery. +

+

+Image: +

+

+If you choose, you may upload an image which will be displayed on the +output for the Category. To upload an image, click the "Browse" button. +For the image to be displayed properly, it must be either a "GIF" or "JPEG" +formatted image. Generally, these are saved as filename.gif or filename.jpg. +If you receive an error message while trying to upload an image, the most +common error is that the image is neither a JPEG nor a GIF. Also note that +simply renaming the file from filename.foo to filename.gif will not reformat +the image as a GIF. +

+

+Insert +

+

When you have entered the information you want for the 0, +you can click "Insert." This will add the information about the new Category +in the database. +

+ +
+
+ + diff --git a/admin/Toolbox/help/closewindow.gif b/admin/Toolbox/help/closewindow.gif new file mode 100755 index 0000000..c54ed89 Binary files /dev/null and b/admin/Toolbox/help/closewindow.gif differ diff --git a/admin/Toolbox/help/helpbg.gif b/admin/Toolbox/help/helpbg.gif new file mode 100755 index 0000000..0b62415 Binary files /dev/null and b/admin/Toolbox/help/helpbg.gif differ diff --git a/admin/Toolbox/images/collapse.png b/admin/Toolbox/images/collapse.png new file mode 100755 index 0000000..d10e051 Binary files /dev/null and b/admin/Toolbox/images/collapse.png differ diff --git a/admin/Toolbox/images/ed_about.gif b/admin/Toolbox/images/ed_about.gif new file mode 100755 index 0000000..d476271 Binary files /dev/null and b/admin/Toolbox/images/ed_about.gif differ diff --git a/admin/Toolbox/images/ed_align_center.gif b/admin/Toolbox/images/ed_align_center.gif new file mode 100755 index 0000000..0966910 Binary files /dev/null and b/admin/Toolbox/images/ed_align_center.gif differ diff --git a/admin/Toolbox/images/ed_align_justify.gif b/admin/Toolbox/images/ed_align_justify.gif new file mode 100755 index 0000000..94a1ea7 Binary files /dev/null and b/admin/Toolbox/images/ed_align_justify.gif differ diff --git a/admin/Toolbox/images/ed_align_left.gif b/admin/Toolbox/images/ed_align_left.gif new file mode 100755 index 0000000..595eef6 Binary files /dev/null and b/admin/Toolbox/images/ed_align_left.gif differ diff --git a/admin/Toolbox/images/ed_align_right.gif b/admin/Toolbox/images/ed_align_right.gif new file mode 100755 index 0000000..514a5e4 Binary files /dev/null and b/admin/Toolbox/images/ed_align_right.gif differ diff --git a/admin/Toolbox/images/ed_blank.gif b/admin/Toolbox/images/ed_blank.gif new file mode 100755 index 0000000..d7ae406 Binary files /dev/null and b/admin/Toolbox/images/ed_blank.gif differ diff --git a/admin/Toolbox/images/ed_charmap.gif b/admin/Toolbox/images/ed_charmap.gif new file mode 100755 index 0000000..b0dc889 Binary files /dev/null and b/admin/Toolbox/images/ed_charmap.gif differ diff --git a/admin/Toolbox/images/ed_color_bg.gif b/admin/Toolbox/images/ed_color_bg.gif new file mode 100755 index 0000000..f6ff05d Binary files /dev/null and b/admin/Toolbox/images/ed_color_bg.gif differ diff --git a/admin/Toolbox/images/ed_color_fg.gif b/admin/Toolbox/images/ed_color_fg.gif new file mode 100755 index 0000000..90e5123 Binary files /dev/null and b/admin/Toolbox/images/ed_color_fg.gif differ diff --git a/admin/Toolbox/images/ed_copy.gif b/admin/Toolbox/images/ed_copy.gif new file mode 100755 index 0000000..f598fa2 Binary files /dev/null and b/admin/Toolbox/images/ed_copy.gif differ diff --git a/admin/Toolbox/images/ed_custom.gif b/admin/Toolbox/images/ed_custom.gif new file mode 100755 index 0000000..3c406a5 Binary files /dev/null and b/admin/Toolbox/images/ed_custom.gif differ diff --git a/admin/Toolbox/images/ed_cut.gif b/admin/Toolbox/images/ed_cut.gif new file mode 100755 index 0000000..92972fc Binary files /dev/null and b/admin/Toolbox/images/ed_cut.gif differ diff --git a/admin/Toolbox/images/ed_delete.gif b/admin/Toolbox/images/ed_delete.gif new file mode 100755 index 0000000..1218349 Binary files /dev/null and b/admin/Toolbox/images/ed_delete.gif differ diff --git a/admin/Toolbox/images/ed_format_bold.gif b/admin/Toolbox/images/ed_format_bold.gif new file mode 100755 index 0000000..3d01d0b Binary files /dev/null and b/admin/Toolbox/images/ed_format_bold.gif differ diff --git a/admin/Toolbox/images/ed_format_italic.gif b/admin/Toolbox/images/ed_format_italic.gif new file mode 100755 index 0000000..e8e1cb0 Binary files /dev/null and b/admin/Toolbox/images/ed_format_italic.gif differ diff --git a/admin/Toolbox/images/ed_format_strike.gif b/admin/Toolbox/images/ed_format_strike.gif new file mode 100755 index 0000000..4885361 Binary files /dev/null and b/admin/Toolbox/images/ed_format_strike.gif differ diff --git a/admin/Toolbox/images/ed_format_sub.gif b/admin/Toolbox/images/ed_format_sub.gif new file mode 100755 index 0000000..489f7a9 Binary files /dev/null and b/admin/Toolbox/images/ed_format_sub.gif differ diff --git a/admin/Toolbox/images/ed_format_sup.gif b/admin/Toolbox/images/ed_format_sup.gif new file mode 100755 index 0000000..8e66b99 Binary files /dev/null and b/admin/Toolbox/images/ed_format_sup.gif differ diff --git a/admin/Toolbox/images/ed_format_underline.gif b/admin/Toolbox/images/ed_format_underline.gif new file mode 100755 index 0000000..b05384e Binary files /dev/null and b/admin/Toolbox/images/ed_format_underline.gif differ diff --git a/admin/Toolbox/images/ed_help.gif b/admin/Toolbox/images/ed_help.gif new file mode 100755 index 0000000..4d66154 Binary files /dev/null and b/admin/Toolbox/images/ed_help.gif differ diff --git a/admin/Toolbox/images/ed_hr.gif b/admin/Toolbox/images/ed_hr.gif new file mode 100755 index 0000000..92fc80e Binary files /dev/null and b/admin/Toolbox/images/ed_hr.gif differ diff --git a/admin/Toolbox/images/ed_html.gif b/admin/Toolbox/images/ed_html.gif new file mode 100755 index 0000000..380de29 Binary files /dev/null and b/admin/Toolbox/images/ed_html.gif differ diff --git a/admin/Toolbox/images/ed_image.gif b/admin/Toolbox/images/ed_image.gif new file mode 100755 index 0000000..a715019 Binary files /dev/null and b/admin/Toolbox/images/ed_image.gif differ diff --git a/admin/Toolbox/images/ed_indent_less.gif b/admin/Toolbox/images/ed_indent_less.gif new file mode 100755 index 0000000..6054d61 Binary files /dev/null and b/admin/Toolbox/images/ed_indent_less.gif differ diff --git a/admin/Toolbox/images/ed_indent_more.gif b/admin/Toolbox/images/ed_indent_more.gif new file mode 100755 index 0000000..c5dd55d Binary files /dev/null and b/admin/Toolbox/images/ed_indent_more.gif differ diff --git a/admin/Toolbox/images/ed_link.gif b/admin/Toolbox/images/ed_link.gif new file mode 100755 index 0000000..0482da3 Binary files /dev/null and b/admin/Toolbox/images/ed_link.gif differ diff --git a/admin/Toolbox/images/ed_list_bullet.gif b/admin/Toolbox/images/ed_list_bullet.gif new file mode 100755 index 0000000..7b07303 Binary files /dev/null and b/admin/Toolbox/images/ed_list_bullet.gif differ diff --git a/admin/Toolbox/images/ed_list_num.gif b/admin/Toolbox/images/ed_list_num.gif new file mode 100755 index 0000000..ae4e03b Binary files /dev/null and b/admin/Toolbox/images/ed_list_num.gif differ diff --git a/admin/Toolbox/images/ed_paste.gif b/admin/Toolbox/images/ed_paste.gif new file mode 100755 index 0000000..6892053 Binary files /dev/null and b/admin/Toolbox/images/ed_paste.gif differ diff --git a/admin/Toolbox/images/ed_redo.gif b/admin/Toolbox/images/ed_redo.gif new file mode 100755 index 0000000..2b5ebbd Binary files /dev/null and b/admin/Toolbox/images/ed_redo.gif differ diff --git a/admin/Toolbox/images/ed_show_border.gif b/admin/Toolbox/images/ed_show_border.gif new file mode 100755 index 0000000..23a01a4 Binary files /dev/null and b/admin/Toolbox/images/ed_show_border.gif differ diff --git a/admin/Toolbox/images/ed_splitcel.gif b/admin/Toolbox/images/ed_splitcel.gif new file mode 100755 index 0000000..48442e2 Binary files /dev/null and b/admin/Toolbox/images/ed_splitcel.gif differ diff --git a/admin/Toolbox/images/ed_undo.gif b/admin/Toolbox/images/ed_undo.gif new file mode 100755 index 0000000..05f041e Binary files /dev/null and b/admin/Toolbox/images/ed_undo.gif differ diff --git a/admin/Toolbox/images/expand.png b/admin/Toolbox/images/expand.png new file mode 100755 index 0000000..38dcfc0 Binary files /dev/null and b/admin/Toolbox/images/expand.png differ diff --git a/admin/Toolbox/images/fullscreen_maximize.gif b/admin/Toolbox/images/fullscreen_maximize.gif new file mode 100755 index 0000000..0536fec Binary files /dev/null and b/admin/Toolbox/images/fullscreen_maximize.gif differ diff --git a/admin/Toolbox/images/fullscreen_minimize.gif b/admin/Toolbox/images/fullscreen_minimize.gif new file mode 100755 index 0000000..b12c3f7 Binary files /dev/null and b/admin/Toolbox/images/fullscreen_minimize.gif differ diff --git a/admin/Toolbox/images/insert_table.gif b/admin/Toolbox/images/insert_table.gif new file mode 100755 index 0000000..4ce3ff4 Binary files /dev/null and b/admin/Toolbox/images/insert_table.gif differ diff --git a/admin/Toolbox/index.phtml b/admin/Toolbox/index.phtml new file mode 100755 index 0000000..550afb8 --- /dev/null +++ b/admin/Toolbox/index.phtml @@ -0,0 +1,3 @@ + diff --git a/admin/Toolbox/list_bus.phtml b/admin/Toolbox/list_bus.phtml new file mode 100755 index 0000000..eabcb33 --- /dev/null +++ b/admin/Toolbox/list_bus.phtml @@ -0,0 +1,109 @@ + "edit_bus.phtml?catid=$catid", + "List Pages" => "list_bus_category.phtml" + ); +html_nav_table($lnav, 2); + +echo "
+ + Parent Category:".$output."
Page Name:
Page Header:
Current Image: + "; + if($value != "") { + echo " +
Delete this image: + Yes + No +
+ New Image:
Description:
Keyword:
Template: + + + + + + + + + + + + + + + +
"; + echo "1"; + echo ""; + echo "2"; + echo ""; + echo "3"; + echo ""; + echo "4"; + echo ""; + echo "5"; + echo "
+
+ + + + + +
"; +?> + + + + + + + + + + + \n"; +footer(); +?> diff --git a/admin/Toolbox/list_bus_category.phtml b/admin/Toolbox/list_bus_category.phtml new file mode 100755 index 0000000..62ad8cf --- /dev/null +++ b/admin/Toolbox/list_bus_category.phtml @@ -0,0 +1,173 @@ + +
+ + Function + + + + Records + +
+ + + + + +
+ + Function + + + + Pos + + + + Category + +
+ + + +
+ + + '; + if($data[active] == "t") + { + $active .= "\"Don't"; + } + else + { + $active .= "\"Display\""; + } + } + if($show_pos) + { + $qs = "SELECT MAX(pos) as maxpos + FROM bus_category + WHERE parent = $parent"; + + if(!$maxresult = db_exec($conn,$qs)) + { + html_error(DB_ERROR_MSG.$qs,0); + } + $max_data = db_fetch_array($maxresult,0,PGSQL_ASSOC); + $maxpos = $max_data['maxpos']; + $pos = "
+ diff --git a/admin/Toolbox/popups/about.html b/admin/Toolbox/popups/about.html new file mode 100755 index 0000000..9b05218 --- /dev/null +++ b/admin/Toolbox/popups/about.html @@ -0,0 +1,55 @@ + +About HTMLArea + + + + + +
+
+HTML Area +3.0 [ rev. beta ]
+ +
+Released on Aug 11, 2003 [21:30] GMT +
+
+ +
+ +

A free WYSIWYG editor replacement for <textarea> fields.

+ +

For full source code and docs, visit:
+http://www.interactivetools.com/products/htmlarea/

+ +

Version 3.0 developed and maintained by mishoo.

+ +

© 2002, 2003 interactivetools.com, inc. All Rights Reserved.

+ +
+ +
+ +
+ + + + diff --git a/admin/Toolbox/popups/blank.html b/admin/Toolbox/popups/blank.html new file mode 100755 index 0000000..8c7fe21 --- /dev/null +++ b/admin/Toolbox/popups/blank.html @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/admin/Toolbox/popups/custom2.html b/admin/Toolbox/popups/custom2.html new file mode 100755 index 0000000..5591f6c --- /dev/null +++ b/admin/Toolbox/popups/custom2.html @@ -0,0 +1,35 @@ + + + Select Phrase + + + + + +
+ + + + + +
+ + \ No newline at end of file diff --git a/admin/Toolbox/popups/editor_help.html b/admin/Toolbox/popups/editor_help.html new file mode 100755 index 0000000..b34de82 --- /dev/null +++ b/admin/Toolbox/popups/editor_help.html @@ -0,0 +1,16 @@ + + + Editor Help + + + + +

Editor Help

+ +Todo... + + + + \ No newline at end of file diff --git a/admin/Toolbox/popups/fullscreen.html b/admin/Toolbox/popups/fullscreen.html new file mode 100755 index 0000000..cd67bdd --- /dev/null +++ b/admin/Toolbox/popups/fullscreen.html @@ -0,0 +1,162 @@ + +Fullscreen Editor + + + + + + + + + + +
+ +
+ + diff --git a/admin/Toolbox/popups/insert_image.html b/admin/Toolbox/popups/insert_image.html new file mode 100755 index 0000000..55e56a0 --- /dev/null +++ b/admin/Toolbox/popups/insert_image.html @@ -0,0 +1,216 @@ + + + + Insert Image + + + + + + + + + + + +
Insert Image
+ +
+ + + + + + + + + + + + + +
Image URL: + +
Alternate text:
+ +

+ +

+Layout + +
+ +
Alignment:
+ + +

+ +

Border thickness:
+ + +
+ +
+ +
+Spacing + +
+ +
Horizontal:
+ + +

+ +

Vertical:
+ + +
+ +
+ +
+
+ + +
+ +
+ + + diff --git a/admin/Toolbox/popups/insert_table.html b/admin/Toolbox/popups/insert_table.html new file mode 100755 index 0000000..efdf3f0 --- /dev/null +++ b/admin/Toolbox/popups/insert_table.html @@ -0,0 +1,173 @@ + + + + Insert Table + + + + + + + + + + + +
Insert Table
+ +
+ + + + + + + + + + + + + + + + + + + +
Rows:
Cols:Width:
+ +

+ +

+Layout + +
+ +
Alignment:
+ + +

+ +

Border thickness:
+ + +
+ +
+ +
+Spacing + +
+ +
Cell spacing:
+ + +

+ +

Cell padding:
+ + +
+ +
+ +
+
+ + +
+ +
+ + + diff --git a/admin/Toolbox/popups/old-fullscreen.html b/admin/Toolbox/popups/old-fullscreen.html new file mode 100755 index 0000000..7c00d91 --- /dev/null +++ b/admin/Toolbox/popups/old-fullscreen.html @@ -0,0 +1,131 @@ + +Fullscreen Editor + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/admin/Toolbox/popups/old_insert_image.html b/admin/Toolbox/popups/old_insert_image.html new file mode 100755 index 0000000..613f460 --- /dev/null +++ b/admin/Toolbox/popups/old_insert_image.html @@ -0,0 +1,206 @@ + + + + + + + +Insert Image + + + + + +
Image URL:
+ + +
Alternate Text:
+ + +
+Layout +
+ +
+Spacing +
+ +
Alignment:
+ + +
Horizontal:
+ + +
Border Thickness:
+ + +
Vertical:
+ + + + + + + \ No newline at end of file diff --git a/admin/Toolbox/popups/popup.js b/admin/Toolbox/popups/popup.js new file mode 100755 index 0000000..68cbeb2 --- /dev/null +++ b/admin/Toolbox/popups/popup.js @@ -0,0 +1,42 @@ +function __dlg_onclose() { + if (!document.all) { + opener.Dialog._return(null); + } +}; + +function __dlg_init() { + if (!document.all) { + // init dialogArguments, as IE gets it + window.dialogArguments = opener.Dialog._arguments; + window.sizeToContent(); + window.sizeToContent(); // for reasons beyond understanding, + // only if we call it twice we get the + // correct size. + window.addEventListener("unload", __dlg_onclose, true); + // center on parent + var px1 = opener.screenX; + var px2 = opener.screenX + opener.outerWidth; + var py1 = opener.screenY; + var py2 = opener.screenY + opener.outerHeight; + var x = (px2 - px1 - window.outerWidth) / 2; + var y = (py2 - py1 - window.outerHeight) / 2; + window.moveTo(x, y); + var body = document.body; + window.innerHeight = body.offsetHeight; + window.innerWidth = body.offsetWidth; + } else { + var body = document.body; + window.dialogHeight = body.offsetHeight + 50 + "px"; + window.dialogWidth = body.offsetWidth + "px"; + } +}; + +// closes the dialog and passes the return info upper. +function __dlg_close(val) { + if (document.all) { // IE + window.returnValue = val; + } else { + opener.Dialog._return(val); + } + window.close(); +}; diff --git a/admin/Toolbox/popups/select_color.html b/admin/Toolbox/popups/select_color.html new file mode 100755 index 0000000..d1fd26b --- /dev/null +++ b/admin/Toolbox/popups/select_color.html @@ -0,0 +1,346 @@ + + +Select Color + + + + + + + +
+ + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + diff --git a/admin/Toolbox/threads.phtml b/admin/Toolbox/threads.phtml new file mode 100755 index 0000000..8871b62 --- /dev/null +++ b/admin/Toolbox/threads.phtml @@ -0,0 +1,161 @@ +"; + var $beginLevel2 = "
    "; + var $endLevel = "
"; + var $beginItem = "
  • "; + var $beginItem2 = "
  • "; + var $endItem = "
  • "; + var $wholeThread; + +/****************************************************************************** + * + * Threads(string $code = "") + * + ****************************************************************************** + * + * Class constructor + * + ****************************************************************************** + * + * Parameters: + * $code = array( + * beginLevel => "", + * endLevel => "", + * beginItem => "", + * endItem => "") + * + * + * + ****************************************************************************** + * + * Return value: + * Returns 1 on success 0 on failure + * + *****************************************************************************/ + + function Thread($code="") + { + if(!empty($code)) + { + $this->beginLevel = $code[beginLevel]; + $this->beginLevel2 = $code[beginLevel2]; + $this->endLevel = $code[endLevel]; + $this->beginItem = $code[beginItem]; + $this->beginItem2 = $code[beginItem2]; + $this->endItem = $code[endItem]; + } + } + +/****************************************************************************** + * + * sortChilds(array $threads) + * + ****************************************************************************** + * + * Sorts the childs under their parent + * + ****************************************************************************** + * + * Parameters: + * $threads array(); + * + ****************************************************************************** + * + * Return value: + * Returns array $childs + * + *****************************************************************************/ + + function sortChilds($threads) + { while(list($var, $value) = each($threads)) + $childs[$value[parent]][$value[ID]] = $value; + return $childs; + } + +/****************************************************************************** + * + * convertToThreads(array $threads) + * + ****************************************************************************** + * + * Creates the output of the sorted $threads array + * + ****************************************************************************** + * + * Parameters: + * + * + ****************************************************************************** + * + * Return value: + * + * + *****************************************************************************/ + + function convertToThread($threads, $thread) + { + static $count; + if( !$count ) + { + $this->wholeThread .= $this->beginLevel2; + } + else + { + $this->wholeThread .= $this->beginLevel; + } + while(list($parent, $value) = each($thread)) + { + if( $threads[$parent] && $value['closed'] ) + { + $this->wholeThread .= $this->beginItem2; + $this->wholeThread .= ' '; + } + elseif( $threads[$parent] && !$value['closed'] ) + { + $this->wholeThread .= $this->beginItem2; + $this->wholeThread .= ' '; + } + else + { + $this->wholeThread .= $this->beginItem; + } + $count++; + $this->wholeThread .= "[Edit]" . "[Paragraphs]" + . $value[pos] + . "".$value[active]; + $this->wholeThread .= $value['content'] . "" . $this->endItem ."\n"; + if( $threads[$parent] && !$value['closed'] ) + { + $this->convertToThread($threads, $threads[$parent]); + } + } + $this->wholeThread .= $this->endLevel; + return $this->wholeThread; + } +} + + +?> diff --git a/admin/Toolbox/toolbox_setup.inc b/admin/Toolbox/toolbox_setup.inc new file mode 100755 index 0000000..85843f7 --- /dev/null +++ b/admin/Toolbox/toolbox_setup.inc @@ -0,0 +1,192 @@ + "id", title => "id", type => "hide"); + $fields[] = array( name => "image", title => "Image", type => "img"); + $fields[] = array( name => "name", title => "Name", type => "text"); + break; + case "support": + $fields[] = array( name => "id", title => "id", type => "hide"); + $fields[] = array( name => "image", title => "Image", type => "img"); + $fields[] = array( name => "name", title => "Name", type => "text"); + $fields[] = array( name => "title", title=> "Title",type => "text"); + $fields[] = array( name => "org", title => "Organization/Company Name", type => "text"); + $fields[] = array( name => "phone", title => "Phone", type => "text"); + $fields[] = array( name => "email", title => "Email", type => "text"); + $fields[] = array( name => "description", title => "Description", type => "desc"); + break; + default: + $fields[] = array( name => "id", title => "id", type => "hide"); + $fields[] = array( name => "name", title => "Header", type => "text"); + //$fields[] = array( name => "address", title => "Address", type => "text"); + //$fields[] = array( name => "city", title => "City", type => "text"); + // $fields[] = array( name => "state", title => "State", type => "text"); + //$fields[] = array( name => "zip", title => "Zip", type => "text"); + // $fields[] = array( name => "phone", title => "Phone", type => "text"); + // $fields[] = array( name => "fax", title => "Fax", type => "text"); + // $fields[] = array( name => "email", title => "Email", type => "text"); + // $fields[] = array( name => "urlname", title => "URL Name", type => "text"); + // $fields[] = array( name => "url", title => "URL", type => "text"); + //$fields[] = array( name => "Images and Descriptions", type => "seperator"); + $fields[] = array( name => "description", title => "Description", type => "desc"); + //$fields[] = array( name => "imagename", title=> "Image Name",type => "text"); + $fields[] = array( name => "image", title => "Image", type => "img"); + //$fields[] = array( name => "description2", title => "Description 2", type => "desc"); + //$fields[] = array( name => "image2name", title=> "Image Name 2",type => "text"); + //$fields[] = array( name => "image2", title => "Image 2", type => "img"); + //$fields[] = array( name => "description3", title => "Description 3", type => "desc"); + //$fields[] = array( name => "image3name", title=> "Image Name 3",type => "text"); + //$fields[] = array( name => "image3", title => "Image 3", type => "img"); + $fields[] = array( name => "File uploads", type => "seperator"); + $fields[] = array( name => "filename", title=> "File Name",type => "text"); + $fields[] = array( name => "file", title => "File 1", type => "file"); + $fields[] = array( name => "file2name", title=> "File Name 2",type => "text"); + $fields[] = array( name => "file2", title => "File 2", type => "file"); + $fields[] = array( name => "file3name", title=> "File Name 3",type => "text"); + $fields[] = array( name => "file3", title => "File 3", type => "file"); + break; + } +function check_lock($id) +{ + if( isset( $id ) && $id != '' && is_numeric( $id ) ) + { + if( file_exists( BASE.'static/'.$id.'.phtml' ) ) + { + return( true ); + } + else + { + return( false ); + } + } + else + { + return( false ); + } + +} +function sort_by_parent($data) + { + if(!is_array($data)) + return(false); + foreach($data as $key=>$value) + { + $data_new[$value["parent"]][$value["id"]] = $value; + } + return($data_new); + } + +function convertParent($threads,$thread) + { + static $select,$count; + if(!$count) + $count = 0; + $bgcolor[] = "#ffffff"; + $bgcolor[] = "#ffffff"; + $bgcolor[] = "#03A9BC"; + $bgcolor[] = "#6FD579"; + $bgcolor[] = "#E36BCB"; + $bgcolor[] = "#F92A23"; + if(is_array($thread)) + { + foreach($thread as $parent=>$value) + { + $color = $bgcolor[$count]; + $select[$value["id"]]["color"] = $color; + $select[$value["id"]]["category"] = $value["category"]; + $select[$value["id"]]["count"] = $count; + + if(isset($threads[$parent])) + { + $count++; + convertParent($threads, $threads[$parent]); + } + } + } + $count--; + return $select; + } + +function parent_select($catid,$id,$sel_name = "parent") + { + // select catid portion + $qs = "SELECT id,category,parent + FROM bus_category + ORDER BY parent,pos"; + + $data = db_auto_get_data($qs,CONN_STR); + $data1 = sort_by_parent($data); + $select = " + +
    + + + +
    + + + + +
    +
    Mihai Bazon
    + + Last modified: Wed Jan 28 11:10:40 EET 2004 + + + diff --git a/admin/htmlarea/examples/context-menu.html b/admin/htmlarea/examples/context-menu.html new file mode 100755 index 0000000..388195b --- /dev/null +++ b/admin/htmlarea/examples/context-menu.html @@ -0,0 +1,95 @@ + + + Test of ContextMenu plugin + + + + + + + + + + + +

    Test of ContextMenu plugin

    + + + + +
    +
    Mihai Bazon
    + + Last modified: Wed Jan 28 11:10:29 EET 2004 + + + diff --git a/admin/htmlarea/examples/core.html b/admin/htmlarea/examples/core.html new file mode 100755 index 0000000..536be0e --- /dev/null +++ b/admin/htmlarea/examples/core.html @@ -0,0 +1,184 @@ + + +Example of HTMLArea 3.0 + + + + + + + + + + + + + + + + +

    HTMLArea 3.0

    + +

    A replacement for TEXTAREA elements. © InteractiveTools.com, 2003-2004.

    + +
    + + + +

    + + + + + +submit + + + +

    + + + diff --git a/admin/htmlarea/examples/css.html b/admin/htmlarea/examples/css.html new file mode 100755 index 0000000..5700d63 --- /dev/null +++ b/admin/htmlarea/examples/css.html @@ -0,0 +1,88 @@ + + + Test of CSS plugin + + + + + + + + + + + +

    Test of FullPage plugin

    + + + +
    +
    Mihai Bazon
    + + Last modified: Wed Jan 28 11:10:16 EET 2004 + + + diff --git a/admin/htmlarea/examples/custom.css b/admin/htmlarea/examples/custom.css new file mode 100755 index 0000000..e2690df --- /dev/null +++ b/admin/htmlarea/examples/custom.css @@ -0,0 +1,29 @@ +body { background-color: #234; color: #dd8; font-family: tahoma; font-size: 12px; } + +a:link, a:visited { color: #8cf; } +a:hover { color: #ff8; } + +h1 { background-color: #456; color: #ff8; padding: 2px 5px; border: 1px solid; border-color: #678 #012 #012 #678; } + +/* syntax highlighting (used by the first combo defined for the CSS plugin) */ + +pre { margin: 0px 1em; padding: 5px 1em; background-color: #000; border: 1px dotted #02d; border-left: 2px solid #04f; } +.code { color: #f5deb3; } +.string { color: #00ffff; } +.comment { color: #8fbc8f; } +.variable-name { color: #fa8072; } +.type { color: #90ee90; font-weight: bold; } +.reference { color: #ee82ee; } +.preprocessor { color: #faf; } +.keyword { color: #ffffff; font-weight: bold; } +.function-name { color: #ace; } +.html-tag { font-weight: bold; } +.html-helper-italic { font-style: italic; } +.warning { color: #ffa500; font-weight: bold; } +.html-helper-bold { font-weight: bold; } + +/* info combo */ + +.quote { font-style: italic; color: #ee9; } +.highlight { background-color: yellow; color: #000; } +.deprecated { text-decoration: line-through; color: #aaa; } diff --git a/admin/htmlarea/examples/full-page.html b/admin/htmlarea/examples/full-page.html new file mode 100755 index 0000000..74666b8 --- /dev/null +++ b/admin/htmlarea/examples/full-page.html @@ -0,0 +1,75 @@ + + + Test of FullPage plugin + + + + + + + + + + + +

    Test of FullPage plugin

    + + + +
    +
    Mihai Bazon
    + + Last modified: Wed Jan 28 11:10:07 EET 2004 + + + diff --git a/admin/htmlarea/examples/fully-loaded.html b/admin/htmlarea/examples/fully-loaded.html new file mode 100755 index 0000000..abced3e --- /dev/null +++ b/admin/htmlarea/examples/fully-loaded.html @@ -0,0 +1,256 @@ + + +Example of HTMLArea 3.0 + + + + + + + + + + + + + + + + + + + + + +

    HTMLArea 3.0

    + +

    A replacement for TEXTAREA elements. © InteractiveTools.com, 2003-2004.

    + +
    + + + +

    + + + + + +submit + + + +

    + + + diff --git a/admin/htmlarea/examples/images.html b/admin/htmlarea/examples/images.html new file mode 100755 index 0000000..ae38f9e --- /dev/null +++ b/admin/htmlarea/examples/images.html @@ -0,0 +1,66 @@ + + + + Test of Image Manager plugin + + + + + + + +

    HTMLArea 3 RC1 + Image Manager + Image Editor

    +

    PHP Image Manager, Image Editor for HTMLArea. Requires PHP, GD or NetPBM or + ImageMagick.

    +
      +
    • Auto cache thumbnails (JPEG, PNG, GIF depending on GD).
    • +
    • Filmstrip view.
    • +
    • Online Image Editor.
    • +
    • Create folders (if permitting).
    • +
    • Editor - Resize, Crop, Rotate, Save as.
    • +
    +
    +
    +
    + Xiang Wei Zhuo +
    + + diff --git a/admin/htmlarea/examples/index.html b/admin/htmlarea/examples/index.html new file mode 100755 index 0000000..1fdeb30 --- /dev/null +++ b/admin/htmlarea/examples/index.html @@ -0,0 +1,29 @@ + + +HTMLArea examples index + + + +

    HTMLArea: auto-generated examples index

    + +
      +% while (<*.html>) { +% next if /^index.html$/; +
    • + <% $_ %> +
    • +% } +
    + +
    +
    mishoo@infoiasi.ro
    + Last modified: Sun Feb 1 13:30:39 EET 2004 + + +<%INIT> +my $dir = $m->interp->comp_root; +$dir =~ s{/+$}{}g; +#$dir =~ s{/[^/]+$}{}g; +$dir .= $m->current_comp->dir_path; +chdir $dir; + diff --git a/admin/htmlarea/examples/list-type.html b/admin/htmlarea/examples/list-type.html new file mode 100755 index 0000000..61233ac --- /dev/null +++ b/admin/htmlarea/examples/list-type.html @@ -0,0 +1,66 @@ + + + +Example of HTMLArea 3.0 -- ListType plugin + + + + + + + + + + + + + + +

    HTMLArea :: the ListType plugin

    + +
    + + + +
    + + + diff --git a/admin/htmlarea/examples/makefile.xml b/admin/htmlarea/examples/makefile.xml new file mode 100755 index 0000000..25a3877 --- /dev/null +++ b/admin/htmlarea/examples/makefile.xml @@ -0,0 +1,4 @@ + + + + diff --git a/admin/htmlarea/examples/pieng.png b/admin/htmlarea/examples/pieng.png new file mode 100755 index 0000000..bea80e0 Binary files /dev/null and b/admin/htmlarea/examples/pieng.png differ diff --git a/admin/htmlarea/examples/spell-checker.html b/admin/htmlarea/examples/spell-checker.html new file mode 100755 index 0000000..06c71a3 --- /dev/null +++ b/admin/htmlarea/examples/spell-checker.html @@ -0,0 +1,132 @@ + + +Example of HTMLArea 3.0 + + + + + + + + + + + + + + + + + +

    HTMLArea 3.0

    + +

    A replacement for TEXTAREA elements. © InteractiveTools.com, 2003-2004.

    + +

    Plugins: + SpellChecker (sponsored by American Bible Society). +

    + +
    + + + +

    + + + + + +submit + + + +

    + + + diff --git a/admin/htmlarea/examples/table-operations.html b/admin/htmlarea/examples/table-operations.html new file mode 100755 index 0000000..e5545ba --- /dev/null +++ b/admin/htmlarea/examples/table-operations.html @@ -0,0 +1,116 @@ + + +Example of HTMLArea 3.0 + + + + + + + + + + + + + + + + + +

    HTMLArea 3.0

    + +

    A replacement for TEXTAREA elements. © InteractiveTools.com, 2003-2004.

    + +

    Page that demonstrates the additional features of the +TableOperations plugin (sponsored by Zapatec Inc.).

    + +
    + + + +

    + + + + + +submit + + + +

    + + + diff --git a/admin/htmlarea/htmlarea.css b/admin/htmlarea/htmlarea.css new file mode 100755 index 0000000..b7c50bb --- /dev/null +++ b/admin/htmlarea/htmlarea.css @@ -0,0 +1,181 @@ +.htmlarea { background: #fff; } + +.htmlarea .toolbar { + cursor: default; + background: ButtonFace; + padding: 1px 1px 2px 1px; + border: 1px solid; + border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; +} +.htmlarea .toolbar table { font-family: tahoma,verdana,sans-serif; font-size: 11px; } +.htmlarea .toolbar img { border: none; } +.htmlarea .toolbar .label { padding: 0px 3px; } + +div.backtotop {font-size:11px;text-align:center; clear:both;} +.htmlarea .toolbar .button { + background: ButtonFace; + color: ButtonText; + border: 1px solid ButtonFace; + padding: 1px; + margin: 0px; + width: 18px; + height: 18px; +} +.htmlarea .toolbar .buttonHover { + border: 1px solid; + border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; +} +.htmlarea .toolbar .buttonActive, .htmlarea .toolbar .buttonPressed { + padding: 2px 0px 0px 2px; + border: 1px solid; + border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow; +} +.htmlarea .toolbar .buttonPressed { + background: ButtonHighlight; +} +.htmlarea .toolbar .indicator { + padding: 0px 3px; + overflow: hidden; + width: 20px; + text-align: center; + cursor: default; + border: 1px solid ButtonShadow; +} + +.htmlarea .toolbar .buttonDisabled img { + filter: alpha(opacity = 25); + -moz-opacity: 0.25; +} + +.htmlarea .toolbar .separator { + position: relative; + margin: 3px; + border-left: 1px solid ButtonShadow; + border-right: 1px solid ButtonHighlight; + width: 0px; + height: 16px; + padding: 0px; +} + +.htmlarea .toolbar .space { width: 5px; } + +.htmlarea .toolbar select { font: 11px Tahoma,Verdana,sans-serif; } + +.htmlarea .toolbar select, +.htmlarea .toolbar select:hover, +.htmlarea .toolbar select:active { background: FieldFace; color: ButtonText; } + +.htmlarea .statusBar { + border: 1px solid; + border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow; + padding: 2px 4px; + background-color: ButtonFace; + color: ButtonText; + font: 11px Tahoma,Verdana,sans-serif; +} + +.htmlarea .statusBar .statusBarTree a { + padding: 2px 5px; + color: #00f; +} + +.htmlarea .statusBar .statusBarTree a:visited { color: #00f; } +.htmlarea .statusBar .statusBarTree a:hover { + background-color: Highlight; + color: HighlightText; + padding: 1px 4px; + border: 1px solid HighlightText; +} + + +/* Hidden DIV popup dialogs (PopupDiv) */ + +.dialog { + color: ButtonText; + background: ButtonFace; +} + +.dialog .content { padding: 2px; } + +.dialog, .dialog button, .dialog input, .dialog select, .dialog textarea, .dialog table { + font: 11px Tahoma,Verdana,sans-serif; +} + +.dialog table { border-collapse: collapse; } + +.dialog .title { + background: #008; + color: #ff8; + border-bottom: 1px solid #000; + padding: 1px 0px 2px 5px; + font-size: 12px; + font-weight: bold; + cursor: default; +} + +.dialog .title .button { + float: right; + border: 1px solid #66a; + padding: 0px 1px 0px 2px; + margin-right: 1px; + color: #fff; + text-align: center; +} + +.dialog .title .button-hilite { border-color: #88f; background: #44c; } + +.dialog button { + width: 5em; + padding: 0px; +} + +.dialog .buttonColor { + padding: 1px; + cursor: default; + border: 1px solid; + border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; +} + +.dialog .buttonColor-hilite { + border-color: #000; +} + +.dialog .buttonColor .chooser, .dialog .buttonColor .nocolor { + height: 0.6em; + border: 1px solid; + padding: 0px 1em; + border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow; +} + +.dialog .buttonColor .nocolor { padding: 0px; } +.dialog .buttonColor .nocolor-hilite { background-color: #fff; color: #f00; } + +.dialog .label { text-align: right; width: 6em; } +.dialog .value input { width: 100%; } +.dialog .buttons { text-align: right; padding: 2px 4px 0px 4px; } + +.dialog legend { font-weight: bold; } +.dialog fieldset table { margin: 2px 0px; } + +.popupdiv { + border: 2px solid; + border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; +} + +.popupwin { + padding: 0px; + margin: 0px; +} + +.popupwin .title { + background: #fff; + color: #000; + font-weight: bold; + font-size: 120%; + padding: 3px 10px; + margin-bottom: 10px; + border-bottom: 1px solid black; + letter-spacing: 2px; +} + +form { margin: 0px; border: none; } diff --git a/admin/htmlarea/htmlarea.js b/admin/htmlarea/htmlarea.js new file mode 100755 index 0000000..8992ce3 --- /dev/null +++ b/admin/htmlarea/htmlarea.js @@ -0,0 +1,2228 @@ +// htmlArea v3.0 - Copyright (c) 2002-2004 interactivetools.com, inc. +// This copyright notice MUST stay intact for use (see license.txt). +// +// Portions (c) dynarch.com, 2003-2004 +// +// A free WYSIWYG editor replacement for + +
    +
    Mihai Bazon
    + + +Last modified on Sat Oct 25 01:06:59 2003 + + + + diff --git a/admin/htmlarea/plugins/HtmlTidy/README b/admin/htmlarea/plugins/HtmlTidy/README new file mode 100755 index 0000000..a3e19f2 --- /dev/null +++ b/admin/htmlarea/plugins/HtmlTidy/README @@ -0,0 +1,104 @@ +// Plugin for htmlArea to run code through the server's HTML Tidy +// By Adam Wright, for The University of Western Australia +// +// Email: zeno@ucc.gu.uwa.edu.au +// Homepage: http://blog.hipikat.org/ +// +// Distributed under the same terms as HTMLArea itself. +// This notice MUST stay intact for use (see license.txt). +// +// Version: 0.5 +// Released to the outside world: 04/03/04 + + +HtmlTidy is a plugin for the popular cross-browser TTY WYSIWYG editor, +htmlArea (http://www.interactivetools.com/products/htmlarea/). HtmlTidy +basically queries HTML Tidy (http://tidy.sourceforge.net/) on the +server side, getting it to make-html-nice, instead of relying on masses +of javascript, which the client would have to download. + +Hi, this is a quick explanation of how to install HtmlTidy. Much better +documentation is probably required, and you're welcome to write it :) + + +* The HtmlTidy directory you should have found this file in should + include the following: + + - README + This file, providing help installing the plugin. + + - html-tidy-config.cfg + This file contains the configuration options HTML Tidy uses to + clean html, and can be modified to suit your organizations + requirements. + + - html-tidy-logic.php + This is the php script, which is queried with dirty html and is + responsible for invoking HTML Tidy, getting nice new html and + returning it to the client. + + - html-tidy.js + The main htmlArea plugin, providing functionality to tidy html + through the htmlArea interface. + + - htmlarea.js.onmode_event.diff + At the time of publishing, an extra event handler was required + inside the main htmlarea.js file. htmlarea.js may be patched + against this file to make the changes reuquired, but be aware + that the event handler may either now be in the core or + htmlarea.js may have changed enough to invalidate the patch. + + UPDATE: now it exists in the official htmlarea.js; applying + this patch is thus no longer necessary. + + - img/html-tidy.gif + The HtmlTidy icon, for the htmlArea toolbar. Created by Dan + Petty for The University of Western Australia. + + - lang/en.js + English language file. Add your own language files here and + please contribute back into the htmlArea community! + + The HtmlArea directory should be extracted to your htmlarea/plugins/ + directory. + + +* Make sure the onMode event handler mentioned above, regarding + htmlarea.js.onmode_event.diff, exists in your htmlarea.js + + +* html-tidy-logic.php should be executable, and your web server should + be configured to execute php scripts in the directory + html-tidy-logic.php exists in. + + +* HTML Tidy needs to be installed on your server, and 'tidy' should be + an alias to it, lying in the PATH known to the user executing such + web scripts. + + +* In your htmlArea configuration, do something like this: + + HTMLArea.loadPlugin("HtmlTidy"); + + editor = new HTMLArea("doc"); + editor.registerPlugin("HtmlTidy"); + + +* Then, in your htmlArea toolbar configuration, use: + + - "HT-html-tidy" + This will create the 'tidy broom' icon on the toolbar, which + will attempt to tidy html source when clicked, and; + + - "HT-auto-tidy" + This will create an "Auto Tidy" / "Don't Tidy" dropdown, to + select whether the source should be tidied automatically when + entering source view. On by default, if you'd like it otherwise + you can do so programatically after generating the toolbar :) + (Or just hack it to be otherwise...) + + +Thank you. + +Any bugs you find can be emailed to zeno@ucc.gu.uwa.edu.au diff --git a/admin/htmlarea/plugins/HtmlTidy/html-tidy-config.cfg b/admin/htmlarea/plugins/HtmlTidy/html-tidy-config.cfg new file mode 100755 index 0000000..996e1ff --- /dev/null +++ b/admin/htmlarea/plugins/HtmlTidy/html-tidy-config.cfg @@ -0,0 +1,29 @@ +// Default configuration file for the htmlArea, HtmlTidy plugin +// By Adam Wright, for The University of Western Australia +// +// Evertything you always wanted to know about HTML Tidy * +// can be found at http://tidy.sourceforge.net/, and a +// quick reference to the configuration options exists at +// http://tidy.sourceforge.net/docs/quickref.html +// +// * But were afraid to ask +// +// Distributed under the same terms as HTMLArea itself. +// This notice MUST stay intact for use (see license.txt). + +word-2000: yes +clean: no +drop-font-tags: yes +doctype: auto +drop-empty-paras: yes +drop-proprietary-attributes: yes +enclose-block-text: yes +enclose-text: yes +escape-cdata: yes +logical-emphasis: yes +indent: auto +indent-spaces: 2 +break-before-br: yes +output-xhtml: yes + +force-output: yes diff --git a/admin/htmlarea/plugins/HtmlTidy/html-tidy-logic.php b/admin/htmlarea/plugins/HtmlTidy/html-tidy-logic.php new file mode 100755 index 0000000..6e17b6d --- /dev/null +++ b/admin/htmlarea/plugins/HtmlTidy/html-tidy-logic.php @@ -0,0 +1,83 @@ + array("pipe", "r"), + 1 => array("pipe", "w"), + 2 => array("file", "/dev/null", "a") + ); + $process = proc_open("tidy -config html-tidy-config.cfg", $descriptorspec, $pipes); + + // Make sure the program started and we got the hooks... + // Either way, get some source code into $source + if (is_resource($process)) { + + // Feed untidy source into the stdin + fwrite($pipes[0], $source); + fclose($pipes[0]); + + // Read clean source out to the browser + while (!feof($pipes[1])) { + //echo fgets($pipes[1], 1024); + $newsrc .= fgets($pipes[1], 1024); + } + fclose($pipes[1]); + + // Clean up after ourselves + proc_close($process); + + } else { + // Better give them back what they came with, so they don't lose it all... + $newsrc = "\n" .$source. "\n"; + } + + // Split our source into an array by lines + $srcLines = explode("\n",$newsrc); + + // Get only the lines between the body tags + $startLn = 0; + while ( strpos( $srcLines[$startLn++], ' + + + + + + + + + + diff --git a/admin/htmlarea/plugins/HtmlTidy/html-tidy.js b/admin/htmlarea/plugins/HtmlTidy/html-tidy.js new file mode 100755 index 0000000..7fc5252 --- /dev/null +++ b/admin/htmlarea/plugins/HtmlTidy/html-tidy.js @@ -0,0 +1,128 @@ +// Plugin for htmlArea to run code through the server's HTML Tidy +// By Adam Wright, for The University of Western Australia +// +// Distributed under the same terms as HTMLArea itself. +// This notice MUST stay intact for use (see license.txt). + +function HtmlTidy(editor) { + this.editor = editor; + + var cfg = editor.config; + var tt = HtmlTidy.I18N; + var bl = HtmlTidy.btnList; + var self = this; + + this.onMode = this.__onMode; + + // register the toolbar buttons provided by this plugin + var toolbar = []; + for (var i in bl) { + var btn = bl[i]; + if (btn == "html-tidy") { + var id = "HT-html-tidy"; + cfg.registerButton(id, tt[id], editor.imgURL(btn[0] + ".gif", "HtmlTidy"), true, + function(editor, id) { + // dispatch button press event + self.buttonPress(editor, id); + }, btn[1]); + toolbar.push(id); + } else if (btn == "html-auto-tidy") { + var ht_class = { + id : "HT-auto-tidy", + options : { "Auto-Tidy" : "auto", "Don't Tidy" : "noauto" }, + action : function (editor) { self.__onSelect(editor, this); }, + refresh : function (editor) { }, + context : "body" + }; + cfg.registerDropdown(ht_class); + } + } + + for (var i in toolbar) { + cfg.toolbar[0].push(toolbar[i]); + } +}; + +HtmlTidy._pluginInfo = { + name : "HtmlTidy", + version : "1.0", + developer : "Adam Wright", + developer_url : "http://blog.hipikat.org/", + sponsor : "The University of Western Australia", + sponsor_url : "http://www.uwa.edu.au/", + license : "htmlArea" +}; + +HtmlTidy.prototype.__onSelect = function(editor, obj) { + // Get the toolbar element object + var elem = editor._toolbarObjects[obj.id].element; + + // Set our onMode event appropriately + if (elem.value == "auto") + this.onMode = this.__onMode; + else + this.onMode = null; +}; + +HtmlTidy.prototype.__onMode = function(mode) { + if ( mode == "textmode" ) { + this.buttonPress(this.editor, "HT-html-tidy"); + } +}; + +HtmlTidy.btnList = [ + null, // separator + ["html-tidy"], + ["html-auto-tidy"] +]; + +HtmlTidy.prototype.onGenerateOnce = function() { + var editor = this.editor; + + var ifr = document.createElement("iframe"); + ifr.name = "htiframe_name"; + var s = ifr.style; + s.position = "absolute"; + s.width = s.height = s.border = s.left = s.top = s.padding = s.margin = "0px"; + document.body.appendChild(ifr); + + var frm = '
    '; + + var newdiv = document.createElement('div'); + newdiv.style.display = "none"; + newdiv.innerHTML = frm; + document.body.appendChild(newdiv); +}; + +HtmlTidy.prototype.buttonPress = function(editor, id) { + var i18n = HtmlTidy.I18N; + + switch (id) { + case "HT-html-tidy": + + var oldhtml = editor.getHTML(); + + // Ask the server for some nice new html, based on the old... + var myform = document.getElementById('htiform_id'); + var txtarea = document.getElementById('htisource_id'); + txtarea.value = editor.getHTML(); + + // Apply the 'meanwhile' text, e.g. "Tidying HTML, please wait..." + editor.setHTML(i18n['tidying']); + + // The returning tidying processing script needs to find the editor + window._editorRef = editor; + + // ...And send our old source off for processing! + myform.submit(); + break; + } +}; + +HtmlTidy.prototype.processTidied = function(newSrc) { + editor = this.editor; + editor.setHTML(newSrc); +}; diff --git a/admin/htmlarea/plugins/HtmlTidy/img/html-tidy.gif b/admin/htmlarea/plugins/HtmlTidy/img/html-tidy.gif new file mode 100755 index 0000000..ed1cbb1 Binary files /dev/null and b/admin/htmlarea/plugins/HtmlTidy/img/html-tidy.gif differ diff --git a/admin/htmlarea/plugins/HtmlTidy/img/makefile.xml b/admin/htmlarea/plugins/HtmlTidy/img/makefile.xml new file mode 100755 index 0000000..7e96531 --- /dev/null +++ b/admin/htmlarea/plugins/HtmlTidy/img/makefile.xml @@ -0,0 +1,3 @@ + + + diff --git a/admin/htmlarea/plugins/HtmlTidy/lang/en.js b/admin/htmlarea/plugins/HtmlTidy/lang/en.js new file mode 100755 index 0000000..79ee372 --- /dev/null +++ b/admin/htmlarea/plugins/HtmlTidy/lang/en.js @@ -0,0 +1,18 @@ +// I18N constants + +// LANG: "en", ENCODING: UTF-8 | ISO-8859-1 +// Author: Adam Wright, http://blog.hipikat.org/ + +// FOR TRANSLATORS: +// +// 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE +// (at least a valid email address) +// +// 2. PLEASE TRY TO USE UTF-8 FOR ENCODING; +// (if this is not possible, please include a comment +// that states what encoding is necessary.) + +HtmlTidy.I18N = { + "tidying" : "\n Tidying up the HTML source, please wait...", + "HT-html-tidy" : "HTML Tidy" +}; diff --git a/admin/htmlarea/plugins/HtmlTidy/lang/makefile.xml b/admin/htmlarea/plugins/HtmlTidy/lang/makefile.xml new file mode 100755 index 0000000..eed81b0 --- /dev/null +++ b/admin/htmlarea/plugins/HtmlTidy/lang/makefile.xml @@ -0,0 +1,3 @@ + + + diff --git a/admin/htmlarea/plugins/HtmlTidy/makefile.xml b/admin/htmlarea/plugins/HtmlTidy/makefile.xml new file mode 100755 index 0000000..84f1fd3 --- /dev/null +++ b/admin/htmlarea/plugins/HtmlTidy/makefile.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/admin/htmlarea/plugins/ImageManager/Classes/Files.php b/admin/htmlarea/plugins/ImageManager/Classes/Files.php new file mode 100755 index 0000000..165e4cd --- /dev/null +++ b/admin/htmlarea/plugins/ImageManager/Classes/Files.php @@ -0,0 +1,215 @@ +read())) + { + if ($entry != '.' && $entry != '..') + { + $obj = Files::fixPath($folder).$entry; + //var_dump($obj); + if (is_file($obj)) + { + $deleted &= Files::delFile($obj); + } + else if(is_dir($obj)) + { + $deleted &= Files::delFolder($obj, $recursive); + } + + } + } + $d->close(); + + } + + //$folder= $folder.'/thumbs'; + //var_dump($folder); + if(is_dir($folder)) + $deleted &= rmdir($folder); + else + $deleted &= false; + + Return $deleted; + } + + /** + * Append a / to the path if required. + * @param string $path the path + * @return string path with trailing / + */ + function fixPath($path) + { + //append a slash to the path if it doesn't exists. + if(!(substr($path,-1) == '/')) + $path .= '/'; + Return $path; + } + + /** + * Concat two paths together. Basically $pathA+$pathB + * @param string $pathA path one + * @param string $pathB path two + * @return string a trailing slash combinded path. + */ + function makePath($pathA, $pathB) + { + $pathA = Files::fixPath($pathA); + if(substr($pathB,0,1)=='/') + $pathB = substr($pathB,1); + Return Files::fixPath($pathA.$pathB); + } + + /** + * Similar to makePath, but the second parameter + * is not only a path, it may contain say a file ending. + * @param string $pathA the leading path + * @param string $pathB the ending path with file + * @return string combined file path. + */ + function makeFile($pathA, $pathB) + { + $pathA = Files::fixPath($pathA); + if(substr($pathB,0,1)=='/') + $pathB = substr($pathB,1); + + Return $pathA.$pathB; + } + + + /** + * Format the file size, limits to Mb. + * @param int $size the raw filesize + * @return string formated file size. + */ + function formatSize($size) + { + if($size < 1024) + return $size.' bytes'; + else if($size >= 1024 && $size < 1024*1024) + return sprintf('%01.2f',$size/1024.0).' Kb'; + else + return sprintf('%01.2f',$size/(1024.0*1024)).' Mb'; + } +} + +?> \ No newline at end of file diff --git a/admin/htmlarea/plugins/ImageManager/Classes/GD.php b/admin/htmlarea/plugins/ImageManager/Classes/GD.php new file mode 100755 index 0000000..15148a3 --- /dev/null +++ b/admin/htmlarea/plugins/ImageManager/Classes/GD.php @@ -0,0 +1,503 @@ + +** Filename......: GD.php +** Last changed..: 30 Aug 2003 +** Notes.........: Orginal is from PEAR +**/ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2002 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 2.02 of the PHP license, | +// | that is bundled with this package in the file LICENSE, and is | +// | available at through the world-wide-web at | +// | http://www.php.net/license/2_02.txt. | +// | If you did not receive a copy of the PHP license and are unable to | +// | obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +----------------------------------------------------------------------+ +// | Authors: Peter Bowyer | +// | Alan Knowles | +// +----------------------------------------------------------------------+ +// +// Usage : +// $img = new Image_Transform_GD(); +// $angle = -78; +// $img->load('magick.png'); +// +// if($img->rotate($angle,array('autoresize'=>true,'color_mask'=>array(255,0,0)))){ +// $img->addText(array('text'=>"Rotation $angle",'x'=>0,'y'=>100,'font'=>'/usr/share/fonts/default/TrueType/cogb____.ttf')); +// $img->display(); +// } else { +// echo "Error"; +// } +// +// +// $Id: GD.php,v 1.1.1.1 2006/03/27 14:44:13 cscott Exp $ +// +// Image Transformation interface using the GD library +// + +require_once "Transform.php"; + +Class Image_Transform_Driver_GD extends Image_Transform +{ + /** + * Holds the image file for manipulation + */ + var $imageHandle = ''; + + /** + * Holds the original image file + */ + var $old_image = ''; + + /** + * Check settings + * + * @return mixed true or or a PEAR error object on error + * + * @see PEAR::isError() + */ + function Image_Transform_GD() + { + return; + } // End function Image + + /** + * Load image + * + * @param string filename + * + * @return mixed none or a PEAR error object on error + * @see PEAR::isError() + */ + function load($image) + { + $this->uid = md5($_SERVER['REMOTE_ADDR']); + $this->image = $image; + $this->_get_image_details($image); + $functionName = 'ImageCreateFrom' . $this->type; + if(function_exists($functionName)) + { + $this->imageHandle = $functionName($this->image); + } + } // End load + + /** + * addText + * + * @param array options Array contains options + * array( + * 'text' The string to draw + * 'x' Horizontal position + * 'y' Vertical Position + * 'Color' Font color + * 'font' Font to be used + * 'size' Size of the fonts in pixel + * 'resize_first' Tell if the image has to be resized + * before drawing the text + * ) + * + * @return none + * @see PEAR::isError() + */ + function addText($params) + { + $default_params = array( + 'text' => 'This is Text', + 'x' => 10, + 'y' => 20, + 'color' => array(255,0,0), + 'font' => 'Arial.ttf', + 'size' => '12', + 'angle' => 0, + 'resize_first' => false // Carry out the scaling of the image before annotation? Not used for GD + ); + $params = array_merge($default_params, $params); + extract($params); + + if( !is_array($color) ){ + if ($color[0]=='#'){ + $this->colorhex2colorarray( $color ); + } else { + include_once('Image/Transform/Driver/ColorsDefs.php'); + $color = isset($colornames[$color])?$colornames[$color]:false; + } + } + + $c = imagecolorresolve ($this->imageHandle, $color[0], $color[1], $color[2]); + + if ('ttf' == substr($font, -3)) { + ImageTTFText($this->imageHandle, $size, $angle, $x, $y, $c, $font, $text); + } else { + ImagePSText($this->imageHandle, $size, $angle, $x, $y, $c, $font, $text); + } + return true; + } // End addText + + + /** + * Rotate image by the given angle + * Uses a fast rotation algorythm for custom angles + * or lines copy for multiple of 90 degrees + * + * @param int $angle Rotation angle + * @param array $options array( 'autoresize'=>true|false, + * 'color_mask'=>array(r,g,b), named color or #rrggbb + * ) + * @author Pierre-Alain Joye + * @return mixed none or a PEAR error object on error + * @see PEAR::isError() + */ + function rotate($angle, $options=null) + { + if(function_exists('imagerotate')) { + $white = imagecolorallocate ($this->imageHandle, 255, 255, 255); + $this->imageHandle = imagerotate($this->imageHandle, $angle, $white); + return true; + } + + if ( $options==null ){ + $autoresize = true; + $color_mask = array(255,255,0); + } else { + extract( $options ); + } + + while ($angle <= -45) { + $angle += 360; + } + while ($angle > 270) { + $angle -= 360; + } + + $t = deg2rad($angle); + + if( !is_array($color_mask) ){ + if ($color[0]=='#'){ + $this->colorhex2colorarray( $color_mask ); + } else { + include_once('Image/Transform/Driver/ColorDefs.php'); + $color = isset($colornames[$color_mask])?$colornames[$color_mask]:false; + } + } + + // Do not round it, too much lost of quality + $cosT = cos($t); + $sinT = sin($t); + + $img =& $this->imageHandle; + + $width = $max_x = $this->img_x; + $height = $max_y = $this->img_y; + $min_y = 0; + $min_x = 0; + + $x1 = round($max_x/2,0); + $y1 = round($max_y/2,0); + + if ( $autoresize ){ + $t = abs($t); + $a = round($angle,0); + switch((int)($angle)){ + case 0: + $width2 = $width; + $height2 = $height; + break; + case 90: + $width2 = $height; + $height2 = $width; + break; + case 180: + $width2 = $width; + $height2 = $height; + break; + case 270: + $width2 = $height; + $height2 = $width; + break; + default: + $width2 = (int)(abs(sin($t) * $height + cos($t) * $width)); + $height2 = (int)(abs(cos($t) * $height+sin($t) * $width)); + } + + $width2 -= $width2%2; + $height2 -= $height2%2; + + $d_width = abs($width - $width2); + $d_height = abs($height - $height2); + $x_offset = $d_width/2; + $y_offset = $d_height/2; + $min_x2 = -abs($x_offset); + $min_y2 = -abs($y_offset); + $max_x2 = $width2; + $max_y2 = $height2; + } + + $img2 = @imagecreate($width2,$height2); + + if ( !is_resource($img2) ){ + return false;/*PEAR::raiseError('Cannot create buffer for the rotataion.', + null, PEAR_ERROR_TRIGGER, E_USER_NOTICE);*/ + } + + $this->img_x = $width2; + $this->img_y = $height2; + + + imagepalettecopy($img2,$img); + + $mask = imagecolorresolve($img2,$color_mask[0],$color_mask[1],$color_mask[2]); + + // use simple lines copy for axes angles + switch((int)($angle)){ + case 0: + imagefill ($img2, 0, 0,$mask); + for ($y=0; $y < $max_y; $y++) { + for ($x = $min_x; $x < $max_x; $x++){ + $c = @imagecolorat ( $img, $x, $y); + imagesetpixel($img2,$x+$x_offset,$y+$y_offset,$c); + } + } + break; + case 90: + imagefill ($img2, 0, 0,$mask); + for ($x = $min_x; $x < $max_x; $x++){ + for ($y=$min_y; $y < $max_y; $y++) { + $c = imagecolorat ( $img, $x, $y); + imagesetpixel($img2,$max_y-$y-1,$x,$c); + } + } + break; + case 180: + imagefill ($img2, 0, 0,$mask); + for ($y=0; $y < $max_y; $y++) { + for ($x = $min_x; $x < $max_x; $x++){ + $c = @imagecolorat ( $img, $x, $y); + imagesetpixel($img2, $max_x2-$x-1, $max_y2-$y-1, $c); + } + } + break; + case 270: + imagefill ($img2, 0, 0,$mask); + for ($y=0; $y < $max_y; $y++) { + for ($x = $max_x; $x >= $min_x; $x--){ + $c = @imagecolorat ( $img, $x, $y); + imagesetpixel($img2,$y,$max_x-$x-1,$c); + } + } + break; + // simple reverse rotation algo + default: + $i=0; + for ($y = $min_y2; $y < $max_y2; $y++){ + + // Algebra :) + $x2 = round((($min_x2-$x1) * $cosT) + (($y-$y1) * $sinT + $x1),0); + $y2 = round((($y-$y1) * $cosT - ($min_x2-$x1) * $sinT + $y1),0); + + for ($x = $min_x2; $x < $max_x2; $x++){ + + // Check if we are out of original bounces, if we are + // use the default color mask + if ( $x2>=0 && $x2<$max_x && $y2>=0 && $y2<$max_y ){ + $c = imagecolorat ( $img, $x2, $y2); + } else { + $c = $mask; + } + imagesetpixel($img2,$x+$x_offset,$y+$y_offset,$c); + + // round verboten! + $x2 += $cosT; + $y2 -= $sinT; + } + } + break; + } + $this->old_image = $this->imageHandle; + $this->imageHandle = $img2; + return true; + } + + + /** + * Resize Action + * + * For GD 2.01+ the new copyresampled function is used + * It uses a bicubic interpolation algorithm to get far + * better result. + * + * @param $new_x int new width + * @param $new_y int new height + * + * @return true on success or pear error + * @see PEAR::isError() + */ + function _resize($new_x, $new_y) { + if ($this->resized === true) { + return false; /*PEAR::raiseError('You have already resized the image without saving it. Your previous resizing will be overwritten', null, PEAR_ERROR_TRIGGER, E_USER_NOTICE);*/ + } + if(function_exists('ImageCreateTrueColor')){ + $new_img =ImageCreateTrueColor($new_x,$new_y); + } else { + $new_img =ImageCreate($new_x,$new_y); + } + if(function_exists('ImageCopyResampled')){ + ImageCopyResampled($new_img, $this->imageHandle, 0, 0, 0, 0, $new_x, $new_y, $this->img_x, $this->img_y); + } else { + ImageCopyResized($new_img, $this->imageHandle, 0, 0, 0, 0, $new_x, $new_y, $this->img_x, $this->img_y); + } + $this->old_image = $this->imageHandle; + $this->imageHandle = $new_img; + $this->resized = true; + + $this->new_x = $new_x; + $this->new_y = $new_y; + return true; + } + + /** + * Crop the image + * + * @param int $crop_x left column of the image + * @param int $crop_y top row of the image + * @param int $crop_width new cropped image width + * @param int $crop_height new cropped image height + */ + function crop($new_x, $new_y, $new_width, $new_height) + { + if(function_exists('ImageCreateTrueColor')){ + $new_img =ImageCreateTrueColor($new_width,$new_height); + } else { + $new_img =ImageCreate($new_width,$new_height); + } + if(function_exists('ImageCopyResampled')){ + ImageCopyResampled($new_img, $this->imageHandle, 0, 0, $new_x, $new_y,$new_width,$new_height,$new_width,$new_height); + } else { + ImageCopyResized($new_img, $this->imageHandle, 0, 0, $new_x, $new_y, $new_width,$new_height,$new_width,$new_height); + } + $this->old_image = $this->imageHandle; + $this->imageHandle = $new_img; + $this->resized = true; + + $this->new_x = $new_x; + $this->new_y = $new_y; + return true; + } + + /** + * Flip the image horizontally or vertically + * + * @param boolean $horizontal true if horizontal flip, vertical otherwise + */ + function flip($horizontal) + { + if(!$horizontal) { + $this->rotate(180); + } + + $width = imagesx($this->imageHandle); + $height = imagesy($this->imageHandle); + + for ($j = 0; $j < $height; $j++) { + $left = 0; + $right = $width-1; + + + while ($left < $right) { + //echo " j:".$j." l:".$left." r:".$right."\n
    "; + $t = imagecolorat($this->imageHandle, $left, $j); + imagesetpixel($this->imageHandle, $left, $j, imagecolorat($this->imageHandle, $right, $j)); + imagesetpixel($this->imageHandle, $right, $j, $t); + $left++; $right--; + } + + } + + return true; + } + + + /** + * Adjust the image gamma + * + * @param float $outputgamma + * + * @return none + */ + function gamma($outputgamma=1.0) { + ImageGammaCorrect($this->imageHandle, 1.0, $outputgamma); + } + + /** + * Save the image file + * + * @param $filename string the name of the file to write to + * @param $quality int output DPI, default is 85 + * @param $types string define the output format, default + * is the current used format + * + * @return none + */ + function save($filename, $type = '', $quality = 85) + { + $type = $type==''? $this->type : $type; + $functionName = 'image' . $type; + + if(function_exists($functionName)) + { + $this->old_image = $this->imageHandle; + if($type=='jpeg') + $functionName($this->imageHandle, $filename, $quality); + else + $functionName($this->imageHandle, $filename); + $this->imageHandle = $this->old_image; + $this->resized = false; + } + } // End save + + + /** + * Display image without saving and lose changes + * + * @param string type (JPG,PNG...); + * @param int quality 75 + * + * @return none + */ + function display($type = '', $quality = 75) + { + if ($type != '') { + $this->type = $type; + } + $functionName = 'Image' . $this->type; + if(function_exists($functionName)) + { + header('Content-type: image/' . strtolower($this->type)); + $functionName($this->imageHandle, '', $quality); + $this->imageHandle = $this->old_image; + $this->resized = false; + ImageDestroy($this->old_image); + $this->free(); + } + } + + /** + * Destroy image handle + * + * @return none + */ + function free() + { + if ($this->imageHandle){ + ImageDestroy($this->imageHandle); + } + } + +} // End class ImageGD +?> diff --git a/admin/htmlarea/plugins/ImageManager/Classes/IM.php b/admin/htmlarea/plugins/ImageManager/Classes/IM.php new file mode 100755 index 0000000..4348c81 --- /dev/null +++ b/admin/htmlarea/plugins/ImageManager/Classes/IM.php @@ -0,0 +1,235 @@ + +** Filename......: IM.php +** Last changed..: 30 Aug 2003 +** Notes.........: Orginal is from PEAR +**/ + +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2002 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 2.02 of the PHP license, | +// | that is bundled with this package in the file LICENSE, and is | +// | available at through the world-wide-web at | +// | http://www.php.net/license/2_02.txt. | +// | If you did not receive a copy of the PHP license and are unable to | +// | obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +----------------------------------------------------------------------+ +// | Authors: Peter Bowyer | +// +----------------------------------------------------------------------+ +// +// $Id: IM.php,v 1.1.1.1 2006/03/27 14:44:13 cscott Exp $ +// +// Image Transformation interface using command line ImageMagick +// + +require_once "Transform.php"; + +Class Image_Transform_Driver_IM extends Image_Transform +{ + /** + * associative array commands to be executed + * @var array + */ + var $command = array(); + + /** + * + * + */ + function Image_Transform_Driver_IM() + { + return true; + } // End Image_IM + + /** + * Load image + * + * @param string filename + * + * @return mixed none or a PEAR error object on error + * @see PEAR::isError() + */ + function load($image) + { + + $this->uid = md5($_SERVER['REMOTE_ADDR']); + /*if (!file_exists($image)) { + return PEAR::raiseError('The image file ' . $image . ' does\'t exist', true); + }*/ + $this->image = $image; + $this->_get_image_details($image); + } // End load + + /** + * Resize Action + * + * @param int new_x new width + * @param int new_y new height + * + * @return none + * @see PEAR::isError() + */ + function _resize($new_x, $new_y) + { + /*if (isset($this->command['resize'])) { + return PEAR::raiseError("You cannot scale or resize an image more than once without calling save or display", true); + }*/ + $this->command['resize'] = "-geometry ${new_x}x${new_y}!"; + + $this->new_x = $new_x; + $this->new_y = $new_y; + } // End resize + + /** + * Crop the image + * + * @param int $crop_x left column of the image + * @param int $crop_y top row of the image + * @param int $crop_width new cropped image width + * @param int $crop_height new cropped image height + */ + function crop($crop_x, $crop_y, $crop_width, $crop_height) + { + $this->command['crop'] = "-crop {$crop_width}x{$crop_height}+{$crop_x}+{$crop_y}"; + } + + /** + * Flip the image horizontally or vertically + * + * @param boolean $horizontal true if horizontal flip, vertical otherwise + */ + function flip($horizontal) + { + if($horizontal) + $this->command['flop'] = "-flop"; + else + $this->command['flip'] = "-flip"; + } + /** + * rotate + * + * @param int angle rotation angle + * @param array options no option allowed + * + */ + function rotate($angle, $options=null) + { + if ('-' == $angle{0}) { + $angle = 360 - substr($angle, 1); + } + $this->command['rotate'] = "-rotate $angle"; + } // End rotate + + /** + * addText + * + * @param array options Array contains options + * array( + * 'text' The string to draw + * 'x' Horizontal position + * 'y' Vertical Position + * 'Color' Font color + * 'font' Font to be used + * 'size' Size of the fonts in pixel + * 'resize_first' Tell if the image has to be resized + * before drawing the text + * ) + * + * @return none + * @see PEAR::isError() + */ + function addText($params) + { + $default_params = array( + 'text' => 'This is Text', + 'x' => 10, + 'y' => 20, + 'color' => 'red', + 'font' => 'Arial.ttf', + 'resize_first' => false // Carry out the scaling of the image before annotation? + ); + $params = array_merge($default_params, $params); + extract($params); + if (true === $resize_first) { + // Set the key so that this will be the last item in the array + $key = 'ztext'; + } else { + $key = 'text'; + } + $this->command[$key] = "-font $font -fill $color -draw 'text $x,$y \"$text\"'"; + // Producing error: gs: not found gs: not found convert: Postscript delegate failed [No such file or directory]. + } // End addText + + /** + * Adjust the image gamma + * + * @param float $outputgamma + * + * @return none + */ + function gamma($outputgamma=1.0) { + $this->command['gamma'] = "-gamma $outputgamma"; + } + + /** + * Save the image file + * + * @param $filename string the name of the file to write to + * @param $quality quality image dpi, default=75 + * @param $type string (JPG,PNG...) + * + * @return none + */ + function save($filename, $type='', $quality = 85) + { + $type == '' ? $this->type : $type; + $cmd = '' . IMAGE_TRANSFORM_LIB_PATH . 'convert '; + $cmd .= implode(' ', $this->command) . " -quality $quality "; + $cmd .= '"'.($this->image) . '" "' . ($filename) . '" 2>&1'; + + //$cmd = str_replace('/', '\\', $cmd); + //echo($cmd.'
    '); + exec($cmd,$retval); + //error_log('IM '.print_r($retval,true)); + } // End save + + /** + * Display image without saving and lose changes + * + * @param string type (JPG,PNG...); + * @param int quality 75 + * + * @return none + */ + function display($type = '', $quality = 75) + { + if ($type == '') { + header('Content-type: image/' . $this->type); + passthru(IMAGE_TRANSFORM_LIB_PATH . 'convert ' . implode(' ', $this->command) . " -quality $quality " . escapeshellarg($this->image) . ' ' . strtoupper($this->type) . ":-"); + } else { + header('Content-type: image/' . $type); + passthru(IMAGE_TRANSFORM_LIB_PATH . 'convert ' . implode(' ', $this->command) . " -quality $quality " . escapeshellarg($this->image) . ' ' . strtoupper($type) . ":-"); + } + } + + + /** + * Destroy image handle + * + * @return none + */ + function free() + { + return true; + } + +} // End class ImageIM +?> diff --git a/admin/htmlarea/plugins/ImageManager/Classes/ImageEditor.php b/admin/htmlarea/plugins/ImageManager/Classes/ImageEditor.php new file mode 100755 index 0000000..eed6e5f --- /dev/null +++ b/admin/htmlarea/plugins/ImageManager/Classes/ImageEditor.php @@ -0,0 +1,446 @@ +manager = $manager; + $this->_uid = md5($_SERVER['REMOTE_ADDR']); + } + + /** + * Did we save a file? + * @return int 1 if the file was saved sucessfully, + * 0 no save operation, -1 file save error. + */ + function isFileSaved() + { + Return $this->filesaved; + } + + /** + * Process the image, if not action, just display the image. + * @return array with image information, empty array if not an image. + * array('src'=>'url of the image', 'dimensions'=>'width="xx" height="yy"', + * 'file'=>'image file, relative', 'fullpath'=>'full path to the image'); + */ + function processImage() + { + if(isset($_GET['img'])) + $relative = rawurldecode($_GET['img']); + else + Return array(); + + //$relative = '/Series2004NoteFront.jpg'; + + $imgURL = $this->manager->getFileURL($relative); + $fullpath = $this->manager->getFullPath($relative); + + $imgInfo = @getImageSize($fullpath); + if(!is_array($imgInfo)) + Return array(); + + $action = $this->getAction(); + + if(!is_null($action)) + { + $image = $this->processAction($action, $relative, $fullpath); + } + else + { + $image['src'] = $imgURL; + $image['dimensions'] = $imgInfo[3]; + $image['file'] = $relative; + $image['fullpath'] = $fullpath; + } + + Return $image; + } + + /** + * Process the actions, crop, scale(resize), rotate, flip, and save. + * When ever an action is performed, the result is save into a + * temporary image file, see createUnique on the filename specs. + * It does not return the saved file, alway returning the tmp file. + * @param string $action, should be 'crop', 'scale', 'rotate','flip', or 'save' + * @param string $relative the relative image filename + * @param string $fullpath the fullpath to the image file + * @return array with image information + * array('src'=>'url of the image', 'dimensions'=>'width="xx" height="yy"', + * 'file'=>'image file, relative', 'fullpath'=>'full path to the image'); + */ + function processAction($action, $relative, $fullpath) + { + $params = ''; + + if(isset($_GET['params'])) + $params = $_GET['params']; + + $values = explode(',',$params,4); + $saveFile = $this->getSaveFileName($values[0]); + + $img = Image_Transform::factory(IMAGE_CLASS); + $img->load($fullpath); + + switch ($action) + { + case 'crop': + $img->crop(intval($values[0]),intval($values[1]), + intval($values[2]),intval($values[3])); + break; + case 'scale': + $img->resize(intval($values[0]),intval($values[1])); + break; + case 'rotate': + $img->rotate(floatval($values[0])); + break; + case 'flip': + if ($values[0] == 'hoz') + $img->flip(true); + else if($values[0] == 'ver') + $img->flip(false); + break; + case 'save': + if(!is_null($saveFile)) + { + $quality = intval($values[1]); + if($quality <0) $quality = 85; + $newSaveFile = $this->makeRelative($relative, $saveFile); + $newSaveFile = $this->getUniqueFilename($newSaveFile); + + //get unique filename just returns the filename, so + //we need to make the relative path once more. + $newSaveFile = $this->makeRelative($relative, $newSaveFile); + $newSaveFullpath = $this->manager->getFullPath($newSaveFile); + $img->save($newSaveFullpath, $values[0], $quality); + if(is_file($newSaveFullpath)) + $this->filesaved = 1; + else + $this->filesaved = -1; + } + break; + } + + //create the tmp image file + $filename = $this->createUnique($fullpath); + $newRelative = $this->makeRelative($relative, $filename); + $newFullpath = $this->manager->getFullPath($newRelative); + $newURL = $this->manager->getFileURL($newRelative); + + //save the file. + $img->save($newFullpath); + $img->free(); + + //get the image information + $imgInfo = @getimagesize($newFullpath); + + $image['src'] = $newURL; + $image['dimensions'] = $imgInfo[3]; + $image['file'] = $newRelative; + $image['fullpath'] = $newFullpath; + + Return $image; + + } + + /** + * Get the file name base on the save name + * and the save type. + * @param string $type image type, 'jpeg', 'png', or 'gif' + * @return string the filename according to save type + */ + function getSaveFileName($type) + { + if(!isset($_GET['file'])) + Return null; + + $filename = Files::escape(rawurldecode($_GET['file'])); + $index = strrpos($filename,'.'); + $base = substr($filename,0,$index); + $ext = strtolower(substr($filename,$index+1,strlen($filename))); + + if($type == 'jpeg' && !($ext=='jpeg' || $ext=='jpg')) + { + Return $base.'.jpeg'; + } + if($type=='png' && $ext != 'png') + Return $base.'.png'; + if($type=='gif' && $ext != 'gif') + Return $base.'.gif'; + + Return $filename; + } + + /** + * Get the default save file name, used by editor.php. + * @return string a suggestive filename, this should be unique + */ + function getDefaultSaveFile() + { + if(isset($_GET['img'])) + $relative = rawurldecode($_GET['img']); + else + Return null; + + Return $this->getUniqueFilename($relative); + } + + /** + * Get a unique filename. If the file exists, the filename + * base is appended with an increasing integer. + * @param string $relative the relative filename to the base_dir + * @return string a unique filename in the current path + */ + function getUniqueFilename($relative) + { + $fullpath = $this->manager->getFullPath($relative); + + $pathinfo = pathinfo($fullpath); + + $path = Files::fixPath($pathinfo['dirname']); + $file = Files::escape($pathinfo['basename']); + + $filename = $file; + + $dotIndex = strrpos($file, '.'); + $ext = ''; + + if(is_int($dotIndex)) + { + $ext = substr($file, $dotIndex); + $base = substr($file, 0, $dotIndex); + } + + $counter = 0; + while(is_file($path.$filename)) + { + $counter++; + $filename = $base.'_'.$counter.$ext; + } + + Return $filename; + + } + + /** + * Specifiy the original relative path, a new filename + * and return the new filename with relative path. + * i.e. $pathA (-filename) + $file + * @param string $pathA the relative file + * @param string $file the new filename + * @return string relative path with the new filename + */ + function makeRelative($pathA, $file) + { + $index = strrpos($pathA,'/'); + if(!is_int($index)) + Return $file; + + $path = substr($pathA, 0, $index); + Return Files::fixPath($path).$file; + } + + /** + * Get the action GET parameter + * @return string action parameter + */ + function getAction() + { + $action = null; + if(isset($_GET['action'])) + $action = $_GET['action']; + Return $action; + } + + /** + * Generate a unique string based on md5(microtime()). + * Well not so uniqe, as it is limited to 6 characters + * @return string unique string. + */ + function uniqueStr() + { + return substr(md5(microtime()),0,6); + } + + /** + * Create unique tmp image file name. + * The filename is based on the tmp file prefix + * specified in config.inc.php plus + * the UID (basically a md5 of the remote IP) + * and some random 6 character string. + * This function also calls to clean up the tmp files. + * @param string $file the fullpath to a file + * @return string a unique filename for that path + * NOTE: it only returns the filename, path no included. + */ + function createUnique($file) + { + $pathinfo = pathinfo($file); + $path = Files::fixPath($pathinfo['dirname']); + $imgType = $this->getImageType($file); + + $unique_str = $this->manager->getTmpPrefix().$this->_uid.'_'.$this->uniqueStr().".".$imgType; + + //make sure the the unique temp file does not exists + while (file_exists($path.$unique_str)) + { + $unique_str = $this->manager->getTmpPrefix().$this->_uid.'_'.$this->uniqueStr().".".$imgType; + } + + $this->cleanUp($path,$pathinfo['basename']); + + Return $unique_str; + } + + /** + * Delete any tmp image files. + * @param string $path the full path + * where the clean should take place. + */ + function cleanUp($path,$file) + { + $path = Files::fixPath($path); + + if(!is_dir($path)) + Return false; + + $d = @dir($path); + + $tmp = $this->manager->getTmpPrefix(); + $tmpLen = strlen($tmp); + + $prefix = $tmp.$this->_uid; + $len = strlen($prefix); + + while (false !== ($entry = $d->read())) + { + //echo $entry."
    "; + if(is_file($path.$entry) && $this->manager->isTmpFile($entry)) + { + if(substr($entry,0,$len)==$prefix && $entry != $file) + Files::delFile($path.$entry); + else if(substr($entry,0,$tmpLen)==$tmp && $entry != $file) + { + if(filemtime($path.$entry)+$this->lapse_time < time()) + Files::delFile($path.$entry); + } + } + } + $d->close(); + } + + /** + * Get the image type base on an image file. + * @param string $file the full path to the image file. + * @return string of either 'gif', 'jpeg', 'png' or 'bmp' + * otherwise it will return null. + */ + function getImageType($file) + { + $imageInfo = @getImageSize($file); + + if(!is_array($imageInfo)) + Return null; + + switch($imageInfo[2]) + { + case 1: + Return 'gif'; + case 2: + Return 'jpeg'; + case 3: + Return 'png'; + case 6: + Return 'bmp'; + } + + Return null; + } + + /** + * Check if the specified image can be edit by GD + * mainly to check that GD can read and save GIFs + * @return int 0 if it is not a GIF file, 1 is GIF is editable, -1 if not editable. + */ + function isGDEditable() + { + if(isset($_GET['img'])) + $relative = rawurldecode($_GET['img']); + else + Return 0; + if(IMAGE_CLASS != 'GD') + Return 0; + + $fullpath = $this->manager->getFullPath($relative); + + $type = $this->getImageType($fullpath); + if($type != 'gif') + Return 0; + + if(function_exists('ImageCreateFrom'+$type) + && function_exists('image'+$type)) + Return 1; + else + Return -1; + } + + /** + * Check if GIF can be edit by GD. + * @return int 0 if it is not using the GD library, 1 is GIF is editable, -1 if not editable. + */ + function isGDGIFAble() + { + if(IMAGE_CLASS != 'GD') + Return 0; + + if(function_exists('ImageCreateFromGif') + && function_exists('imagegif')) + Return 1; + else + Return -1; + } +} + +?> \ No newline at end of file diff --git a/admin/htmlarea/plugins/ImageManager/Classes/ImageManager.php b/admin/htmlarea/plugins/ImageManager/Classes/ImageManager.php new file mode 100755 index 0000000..8cd210b --- /dev/null +++ b/admin/htmlarea/plugins/ImageManager/Classes/ImageManager.php @@ -0,0 +1,617 @@ +config = $config; + } + + /** + * Get the base directory. + * @return string base dir, see config.inc.php + */ + function getBaseDir() + { + Return $this->config['base_dir']; + } + + /** + * Get the base URL. + * @return string base url, see config.inc.php + */ + function getBaseURL() + { + Return $this->config['base_url']; + } + + function isValidBase() + { + return is_dir($this->getBaseDir()); + } + + /** + * Get the tmp file prefix. + * @return string tmp file prefix. + */ + function getTmpPrefix() + { + Return $this->config['tmp_prefix']; + } + + /** + * Get the sub directories in the base dir. + * Each array element contain + * the relative path (relative to the base dir) as key and the + * full path as value. + * @return array of sub directries + * array('path name' => 'full directory path', ...) + */ + function getDirs() + { + if(is_null($this->dirs)) + { + $dirs = $this->_dirs($this->getBaseDir(),'/'); + ksort($dirs); + $this->dirs = $dirs; + } + return $this->dirs; + } + + /** + * Recursively travese the directories to get a list + * of accessable directories. + * @param string $base the full path to the current directory + * @param string $path the relative path name + * @return array of accessiable sub-directories + * array('path name' => 'full directory path', ...) + */ + function _dirs($base, $path) + { + $base = Files::fixPath($base); + $dirs = array(); + + if($this->isValidBase() == false) + return $dirs; + + $d = @dir($base); + + while (false !== ($entry = $d->read())) + { + //If it is a directory, and it doesn't start with + // a dot, and if is it not the thumbnail directory + if(is_dir($base.$entry) + && substr($entry,0,1) != '.' + && $this->isThumbDir($entry) == false) + { + $relative = Files::fixPath($path.$entry); + $fullpath = Files::fixPath($base.$entry); + $dirs[$relative] = $fullpath; + $dirs = array_merge($dirs, $this->_dirs($fullpath, $relative)); + } + } + $d->close(); + + Return $dirs; + } + + /** + * Get all the files and directories of a relative path. + * @param string $path relative path to be base path. + * @return array of file and path information. + * array(0=>array('relative'=>'fullpath',...), 1=>array('filename'=>fileinfo array(),...) + * fileinfo array: array('url'=>'full url', + * 'relative'=>'relative to base', + * 'fullpath'=>'full file path', + * 'image'=>imageInfo array() false if not image, + * 'stat' => filestat) + */ + function getFiles($path) + { + $files = array(); + $dirs = array(); + + if($this->isValidBase() == false) + return array($files,$dirs); + + $path = Files::fixPath($path); + $base = Files::fixPath($this->getBaseDir()); + $fullpath = Files::makePath($base,$path); + + + $d = @dir($fullpath); + + while (false !== ($entry = $d->read())) + { + //not a dot file or directory + if(substr($entry,0,1) != '.') + { + if(is_dir($fullpath.$entry) + && $this->isThumbDir($entry) == false) + { + $relative = Files::fixPath($path.$entry); + $full = Files::fixPath($fullpath.$entry); + $count = $this->countFiles($full); + $dirs[$relative] = array('fullpath'=>$full,'entry'=>$entry,'count'=>$count); + } + else if(is_file($fullpath.$entry) && $this->isThumb($entry)==false && $this->isTmpFile($entry) == false) + { + $img = $this->getImageInfo($fullpath.$entry); + + if(!(!is_array($img)&&$this->config['validate_images'])) + { + $file['url'] = Files::makePath($this->config['base_url'],$path).$entry; + $file['relative'] = $path.$entry; + $file['fullpath'] = $fullpath.$entry; + $file['image'] = $img; + $file['stat'] = stat($fullpath.$entry); + $files[$entry] = $file; + } + } + } + } + $d->close(); + ksort($dirs); + ksort($files); + + Return array($dirs, $files); + } + + /** + * Count the number of files and directories in a given folder + * minus the thumbnail folders and thumbnails. + */ + function countFiles($path) + { + $total = 0; + + if(is_dir($path)) + { + $d = @dir($path); + + while (false !== ($entry = $d->read())) + { + //echo $entry."
    "; + if(substr($entry,0,1) != '.' + && $this->isThumbDir($entry) == false + && $this->isTmpFile($entry) == false + && $this->isThumb($entry) == false) + { + $total++; + } + } + $d->close(); + } + return $total; + } + + /** + * Get image size information. + * @param string $file the image file + * @return array of getImageSize information, + * false if the file is not an image. + */ + function getImageInfo($file) + { + Return @getImageSize($file); + } + + /** + * Check if the file contains the thumbnail prefix. + * @param string $file filename to be checked + * @return true if the file contains the thumbnail prefix, false otherwise. + */ + function isThumb($file) + { + $len = strlen($this->config['thumbnail_prefix']); + if(substr($file,0,$len)==$this->config['thumbnail_prefix']) + Return true; + else + Return false; + } + + /** + * Check if the given directory is a thumbnail directory. + * @param string $entry directory name + * @return true if it is a thumbnail directory, false otherwise + */ + function isThumbDir($entry) + { + if($this->config['thumbnail_dir'] == false + || strlen(trim($this->config['thumbnail_dir'])) == 0) + Return false; + else + Return ($entry == $this->config['thumbnail_dir']); + } + + /** + * Check if the given file is a tmp file. + * @param string $file file name + * @return boolean true if it is a tmp file, false otherwise + */ + function isTmpFile($file) + { + $len = strlen($this->config['tmp_prefix']); + if(substr($file,0,$len)==$this->config['tmp_prefix']) + Return true; + else + Return false; + } + + /** + * For a given image file, get the respective thumbnail filename + * no file existence check is done. + * @param string $fullpathfile the full path to the image file + * @return string of the thumbnail file + */ + function getThumbName($fullpathfile) + { + $path_parts = pathinfo($fullpathfile); + + $thumbnail = $this->config['thumbnail_prefix'].$path_parts['basename']; + + if($this->config['safe_mode'] == true + || strlen(trim($this->config['thumbnail_dir'])) == 0) + { + Return Files::makeFile($path_parts['dirname'],$thumbnail); + } + else + { + if(strlen(trim($this->config['thumbnail_dir'])) > 0) + { + $path = Files::makePath($path_parts['dirname'],$this->config['thumbnail_dir']); + if(!is_dir($path)) + Files::createFolder($path); + Return Files::makeFile($path,$thumbnail); + } + else //should this ever happen? + { + //error_log('ImageManager: Error in creating thumbnail name'); + } + } + } + + /** + * Similar to getThumbName, but returns the URL, base on the + * given base_url in config.inc.php + * @param string $relative the relative image file name, + * relative to the base_dir path + * @return string the url of the thumbnail + */ + function getThumbURL($relative) + { + $path_parts = pathinfo($relative); + $thumbnail = $this->config['thumbnail_prefix'].$path_parts['basename']; + if($path_parts['dirname']=='\\') $path_parts['dirname']='/'; + + if($this->config['safe_mode'] == true + || strlen(trim($this->config['thumbnail_dir'])) == 0) + { + Return Files::makeFile($this->getBaseURL(),$thumbnail); + } + else + { + if(strlen(trim($this->config['thumbnail_dir'])) > 0) + { + $path = Files::makePath($path_parts['dirname'],$this->config['thumbnail_dir']); + $url_path = Files::makePath($this->getBaseURL(), $path); + Return Files::makeFile($url_path,$thumbnail); + } + else //should this ever happen? + { + //error_log('ImageManager: Error in creating thumbnail url'); + } + + } + } + + /** + * Check if the given path is part of the subdirectories + * under the base_dir. + * @param string $path the relative path to be checked + * @return boolean true if the path exists, false otherwise + */ + function validRelativePath($path) + { + $dirs = $this->getDirs(); + if($path == '/') + Return true; + //check the path given in the url against the + //list of paths in the system. + for($i = 0; $i < count($dirs); $i++) + { + $key = key($dirs); + //we found the path + if($key == $path) + Return true; + + next($dirs); + } + Return false; + } + + /** + * Process uploaded files, assumes the file is in + * $_FILES['upload'] and $_POST['dir'] is set. + * The dir must be relative to the base_dir and exists. + * If 'validate_images' is set to true, only file with + * image dimensions will be accepted. + * @return null + */ + function processUploads() + { + if($this->isValidBase() == false) + return; + + $relative = null; + + if(isset($_POST['dir'])) + $relative = rawurldecode($_POST['dir']); + else + return; + + //check for the file, and must have valid relative path + if(isset($_FILES['upload']) && $this->validRelativePath($relative)) + { + $this->_processFiles($relative, $_FILES['upload']); + } + } + + /** + * Process upload files. The file must be an + * uploaded file. If 'validate_images' is set to + * true, only images will be processed. Any duplicate + * file will be renamed. See Files::copyFile for details + * on renaming. + * @param string $relative the relative path where the file + * should be copied to. + * @param array $file the uploaded file from $_FILES + * @return boolean true if the file was processed successfully, + * false otherwise + */ + function _processFiles($relative, $file) + { + + if($file['error']!=0) + { + Return false; + } + + if(!is_file($file['tmp_name'])) + { + Return false; + } + + if(!is_uploaded_file($file['tmp_name'])) + { + Files::delFile($file['tmp_name']); + Return false; + } + + + if($this->config['validate_images'] == true) + { + $imgInfo = @getImageSize($file['tmp_name']); + if(!is_array($imgInfo)) + { + Files::delFile($file['tmp_name']); + Return false; + } + } + + //now copy the file + $path = Files::makePath($this->getBaseDir(),$relative); + $result = Files::copyFile($file['tmp_name'], $path, $file['name']); + + //no copy error + if(!is_int($result)) + { + Files::delFile($file['tmp_name']); + Return true; + } + + //delete tmp files. + Files::delFile($file['tmp_name']); + Return false; + } + + /** + * Get the URL of the relative file. + * basically appends the relative file to the + * base_url given in config.inc.php + * @param string $relative a file the relative to the base_dir + * @return string the URL of the relative file. + */ + function getFileURL($relative) + { + Return Files::makeFile($this->getBaseURL(),$relative); + } + + /** + * Get the fullpath to a relative file. + * @param string $relative the relative file. + * @return string the full path, .ie. the base_dir + relative. + */ + function getFullPath($relative) + { + Return Files::makeFile($this->getBaseDir(),$relative);; + } + + /** + * Get the default thumbnail. + * @return string default thumbnail, empty string if + * the thumbnail doesn't exist. + */ + function getDefaultThumb() + { + if(is_file($this->config['default_thumbnail'])) + Return $this->config['default_thumbnail']; + else + Return ''; + } + + + /** + * Get the thumbnail url to be displayed. + * If the thumbnail exists, and it is up-to-date + * the thumbnail url will be returns. If the + * file is not an image, a default image will be returned. + * If it is an image file, and no thumbnail exists or + * the thumbnail is out-of-date (i.e. the thumbnail + * modified time is less than the original file) + * then a thumbs.php?img=filename.jpg is returned. + * The thumbs.php url will generate a new thumbnail + * on the fly. If the image is less than the dimensions + * of the thumbnails, the image will be display instead. + * @param string $relative the relative image file. + * @return string the url of the thumbnail, be it + * actually thumbnail or a script to generate the + * thumbnail on the fly. + */ + function getThumbnail($relative) + { + $fullpath = Files::makeFile($this->getBaseDir(),$relative); + + //not a file??? + if(!is_file($fullpath)) + Return $this->getDefaultThumb(); + + $imgInfo = @getImageSize($fullpath); + + //not an image + if(!is_array($imgInfo)) + Return $this->getDefaultThumb(); + + //the original image is smaller than thumbnails, + //so just return the url to the original image. + if ($imgInfo[0] <= $this->config['thumbnail_width'] + && $imgInfo[1] <= $this->config['thumbnail_height']) + Return $this->getFileURL($relative); + + $thumbnail = $this->getThumbName($fullpath); + + //check for thumbnails, if exists and + // it is up-to-date, return the thumbnail url + if(is_file($thumbnail)) + { + if(filemtime($thumbnail) >= filemtime($fullpath)) + Return $this->getThumbURL($relative); + } + + //well, no thumbnail was found, so ask the thumbs.php + //to generate the thumbnail on the fly. + Return 'thumbs.php?img='.rawurlencode($relative); + } + + /** + * Delete and specified files. + * @return boolean true if delete, false otherwise + */ + function deleteFiles() + { + if(isset($_GET['delf'])) + $this->_delFile(rawurldecode($_GET['delf'])); + } + + /** + * Delete and specified directories. + * @return boolean true if delete, false otherwise + */ + function deleteDirs() + { + if(isset($_GET['deld'])) + return $this->_delDir(rawurldecode($_GET['deld'])); + else + Return false; + } + + /** + * Delete the relative file, and any thumbnails. + * @param string $relative the relative file. + * @return boolean true if deleted, false otherwise. + */ + function _delFile($relative) + { + $fullpath = Files::makeFile($this->getBaseDir(),$relative); + + //check that the file is an image + if($this->config['validate_images'] == true) + { + if(!is_array($this->getImageInfo($fullpath))) + return false; //hmmm not an Image!!??? + } + + $thumbnail = $this->getThumbName($fullpath); + + if(Files::delFile($fullpath)) + Return Files::delFile($thumbnail); + else + Return false; + } + + /** + * Delete directories recursively. + * @param string $relative the relative path to be deleted. + * @return boolean true if deleted, false otherwise. + */ + function _delDir($relative) + { + $fullpath = Files::makePath($this->getBaseDir(),$relative); + if($this->countFiles($fullpath) <= 0) + return Files::delFolder($fullpath,true); //delete recursively. + else + Return false; + } + + /** + * Create new directories. + * If in safe_mode, nothing happens. + * @return boolean true if created, false otherwise. + */ + function processNewDir() + { + if($this->config['safe_mode'] == true) + Return false; + + if(isset($_GET['newDir']) && isset($_GET['dir'])) + { + $newDir = rawurldecode($_GET['newDir']); + $dir = rawurldecode($_GET['dir']); + $path = Files::makePath($this->getBaseDir(),$dir); + $fullpath = Files::makePath($path, Files::escape($newDir)); + if(is_dir($fullpath)) + Return false; + + Return Files::createFolder($fullpath); + } + } +} + +?> \ No newline at end of file diff --git a/admin/htmlarea/plugins/ImageManager/Classes/NetPBM.php b/admin/htmlarea/plugins/ImageManager/Classes/NetPBM.php new file mode 100755 index 0000000..dc7826e --- /dev/null +++ b/admin/htmlarea/plugins/ImageManager/Classes/NetPBM.php @@ -0,0 +1,257 @@ + +** Filename......: NetPBM.php +** Last changed..: 30 Aug 2003 +** Notes.........: Orginal is from PEAR +**/ + +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2002 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 2.02 of the PHP license, | +// | that is bundled with this package in the file LICENSE, and is | +// | available at through the world-wide-web at | +// | http://www.php.net/license/2_02.txt. | +// | If you did not receive a copy of the PHP license and are unable to | +// | obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +----------------------------------------------------------------------+ +// | Authors: Peter Bowyer | +// +----------------------------------------------------------------------+ +// +// $Id: NetPBM.php,v 1.1.1.1 2006/03/27 14:44:13 cscott Exp $ +// +// Image Transformation interface using command line NetPBM + +require_once "Transform.php"; + +Class Image_Transform_Driver_NetPBM extends Image_Transform +{ + + /** + * associative array commands to be executed + * @var array + */ + var $command = array(); + + /** + * Class Constructor + */ + function Image_Transform_Driver_NetPBM() + { + $this->uid = md5($_SERVER['REMOTE_ADDR']); + + return true; + } // End function Image_NetPBM + + /** + * Load image + * + * @param string filename + * + * @return mixed none or a PEAR error object on error + * @see PEAR::isError() + */ + function load($image) + { + //echo $image; + $this->image = $image; + $this->_get_image_details($image); + } // End load + + /** + * Resizes the image + * + * @return none + * @see PEAR::isError() + */ + function _resize($new_x, $new_y) + { + // there's no technical reason why resize can't be called multiple + // times...it's just silly to do so + + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . + "pnmscale -width $new_x -height $new_y"; + + $this->_set_new_x($new_x); + $this->_set_new_y($new_y); + } // End resize + + /** + * Crop the image + * + * @param int $crop_x left column of the image + * @param int $crop_y top row of the image + * @param int $crop_width new cropped image width + * @param int $crop_height new cropped image height + */ + function crop($crop_x, $crop_y, $crop_width, $crop_height) + { + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . + "pnmcut -left $crop_x -top $crop_y -width $crop_width -height $crop_height"; + } + + /** + * Rotates the image + * + * @param int $angle The angle to rotate the image through + */ + function rotate($angle) + { + $angle = -1*floatval($angle); + + if($angle > 90) + { + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . "pnmrotate -noantialias 90"; + $this->rotate(-1*($angle-90)); + } + else if ($angle < -90) + { + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . "pnmrotate -noantialias -90"; + $this->rotate(-1*($angle+90)); + } + else + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . "pnmrotate -noantialias $angle"; + } // End rotate + + /** + * Flip the image horizontally or vertically + * + * @param boolean $horizontal true if horizontal flip, vertical otherwise + */ + function flip($horizontal) + { + if($horizontal) + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . "pnmflip -lr"; + else + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . "pnmflip -tb"; + } + + /** + * Adjust the image gamma + * + * @param float $outputgamma + * + * @return none + */ + function gamma($outputgamma = 1.0) { + $this->command[13] = IMAGE_TRANSFORM_LIB_PATH . "pnmgamma $outputgamma"; + } + + /** + * adds text to an image + * + * @param array options Array contains options + * array( + * 'text' // The string to draw + * 'x' // Horizontal position + * 'y' // Vertical Position + * 'Color' // Font color + * 'font' // Font to be used + * 'size' // Size of the fonts in pixel + * 'resize_first' // Tell if the image has to be resized + * // before drawing the text + * ) + * + * @return none + */ + function addText($params) + { + $default_params = array('text' => 'This is Text', + 'x' => 10, + 'y' => 20, + 'color' => 'red', + 'font' => 'Arial.ttf', + 'size' => '12', + 'angle' => 0, + 'resize_first' => false); + // we ignore 'resize_first' since the more logical approach would be + // for the user to just call $this->_resize() _first_ ;) + extract(array_merge($default_params, $params)); + $this->command[] = "ppmlabel -angle $angle -colour $color -size " + ."$size -x $x -y ".$y+$size." -text \"$text\""; + } // End addText + + function _postProcess($type, $quality, $save_type) + { + $type = is_null($type) || $type==''? $this->type : $type; + $save_type = is_null($save_type) || $save_type==''? $this->type : $save_type; + //echo "TYPE:". $this->type; + array_unshift($this->command, IMAGE_TRANSFORM_LIB_PATH + . $type.'topnm '. $this->image); + $arg = ''; + switch(strtolower($save_type)){ + case 'gif': + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . "ppmquant 256"; + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . "ppmto$save_type"; + break; + case 'jpg': + case 'jpeg': + $arg = "--quality=$quality"; + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . "ppmto$save_type $arg"; + break; + default: + $this->command[] = IMAGE_TRANSFORM_LIB_PATH . "pnmto$save_type $arg"; + break; + } // switch + return implode('|', $this->command); + } + + /** + * Save the image file + * + * @param $filename string the name of the file to write to + * @param string $type (jpeg,png...); + * @param int $quality 75 + * @return none + */ + function save($filename, $type=null, $quality = 85) + { + $cmd = $this->_postProcess('', $quality, $type) . ">$filename"; + + //if we have windows server + if(isset($_ENV['OS']) && eregi('window',$_ENV['OS'])) + $cmd = ereg_replace('/','\\',$cmd); + //echo $cmd."##"; + $output = system($cmd); + error_log('NETPBM: '.$cmd); + //error_log($output); + $this->command = array(); + } // End save + + + /** + * Display image without saving and lose changes + * + * @param string $type (jpeg,png...); + * @param int $quality 75 + * @return none + */ + function display($type = null, $quality = 75) + { + header('Content-type: image/' . $type); + $cmd = $this->_postProcess($type, $quality); + + passthru($cmd); + $this->command = array(); + } + + /** + * Destroy image handle + * + * @return none + */ + function free() + { + // there is no image handle here + return true; + } + + +} // End class NetPBM +?> diff --git a/admin/htmlarea/plugins/ImageManager/Classes/Thumbnail.php b/admin/htmlarea/plugins/ImageManager/Classes/Thumbnail.php new file mode 100755 index 0000000..13d3353 --- /dev/null +++ b/admin/htmlarea/plugins/ImageManager/Classes/Thumbnail.php @@ -0,0 +1,126 @@ +driver = Image_Transform::factory(IMAGE_CLASS); + $this->width = $width; + $this->height = $height; + } + + /** + * Create a thumbnail. + * @param string $file the image for the thumbnail + * @param string $thumbnail if not null, the thumbnail will be saved + * as this parameter value. + * @return boolean true if thumbnail is created, false otherwise + */ + function createThumbnail($file, $thumbnail=null) + { + if(!is_file($file)) + Return false; + + //error_log('Creating Thumbs: '.$file); + + $this->driver->load($file); + + if($this->proportional) + { + $width = $this->driver->img_x; + $height = $this->driver->img_y; + + if ($width > $height) + $this->height = intval($this->width/$width*$height); + else if ($height > $width) + $this->width = intval($this->height/$height*$width); + } + + $this->driver->resize($this->width, $this->height); + + if(is_null($thumbnail)) + $this->save($file); + else + $this->save($thumbnail); + + + $this->free(); + + if(is_file($thumbnail)) + Return true; + else + Return false; + } + + /** + * Save the thumbnail file. + * @param string $file file name to be saved as. + */ + function save($file) + { + $this->driver->save($file); + } + + /** + * Free up the graphic driver resources. + */ + function free() + { + $this->driver->free(); + } +} + + +?> \ No newline at end of file diff --git a/admin/htmlarea/plugins/ImageManager/Classes/Transform.php b/admin/htmlarea/plugins/ImageManager/Classes/Transform.php new file mode 100755 index 0000000..526ec6e --- /dev/null +++ b/admin/htmlarea/plugins/ImageManager/Classes/Transform.php @@ -0,0 +1,569 @@ + +** Filename......: Transform.php +** Last changed..: 30 Aug 2003 +** Notes.........: Orginal is from PEAR + + Added a few extra, + - create unique filename in a particular directory, + used for temp image files. + - added cropping to GD, NetPBM, ImageMagick +**/ + +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2002 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 2.02 of the PHP license, | +// | that is bundled with this package in the file LICENSE, and is | +// | available at through the world-wide-web at | +// | http://www.php.net/license/2_02.txt. | +// | If you did not receive a copy of the PHP license and are unable to | +// | obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +----------------------------------------------------------------------+ +// | Authors: Peter Bowyer | +// | Alan Knowles | +// | Vincent Oostindie | +// +----------------------------------------------------------------------+ +// +// $Id: Transform.php,v 1.1.1.1 2006/03/27 14:44:13 cscott Exp $ +// +// Image Transformation interface +// + + +/** + * The main "Image_Resize" class is a container and base class which + * provides the static methods for creating Image objects as well as + * some utility functions (maths) common to all parts of Image Resize. + * + * The object model of DB is as follows (indentation means inheritance): + * + * Image_Resize The base for each Image implementation. Provides default + * | implementations (in OO lingo virtual methods) for + * | the actual Image implementations as well as a bunch of + * | maths methods. + * | + * +-Image_GD The Image implementation for the PHP GD extension . Inherits + * Image_Resize + * When calling DB::setup for GD images the object returned is an + * instance of this class. + * + * @package Image Resize + * @version 1.00 + * @author Peter Bowyer + * @since PHP 4.0 + */ +Class Image_Transform +{ + /** + * Name of the image file + * @var string + */ + var $image = ''; + /** + * Type of the image file (eg. jpg, gif png ...) + * @var string + */ + var $type = ''; + /** + * Original image width in x direction + * @var int + */ + var $img_x = ''; + /** + * Original image width in y direction + * @var int + */ + var $img_y = ''; + /** + * New image width in x direction + * @var int + */ + var $new_x = ''; + /** + * New image width in y direction + * @var int + */ + var $new_y = ''; + /** + * Path the the library used + * e.g. /usr/local/ImageMagick/bin/ or + * /usr/local/netpbm/ + */ + var $lib_path = ''; + /** + * Flag to warn if image has been resized more than once before displaying + * or saving. + */ + var $resized = false; + + + var $uid = ''; + + var $lapse_time =900; //15 mins + + /** + * Create a new Image_resize object + * + * @param string $driver name of driver class to initialize + * + * @return mixed a newly created Image_Transform object, or a PEAR + * error object on error + * + * @see PEAR::isError() + * @see Image_Transform::setOption() + */ + function &factory($driver) + { + if ('' == $driver) { + die("No image library specified... aborting. You must call ::factory() with one parameter, the library to load."); + + } + $this->uid = md5($_SERVER['REMOTE_ADDR']); + + include_once "$driver.php"; + + $classname = "Image_Transform_Driver_{$driver}"; + $obj =& new $classname; + return $obj; + } + + + /** + * Resize the Image in the X and/or Y direction + * If either is 0 it will be scaled proportionally + * + * @access public + * + * @param mixed $new_x (0, number, percentage 10% or 0.1) + * @param mixed $new_y (0, number, percentage 10% or 0.1) + * + * @return mixed none or PEAR_error + */ + function resize($new_x = 0, $new_y = 0) + { + // 0 means keep original size + $new_x = (0 == $new_x) ? $this->img_x : $this->_parse_size($new_x, $this->img_x); + $new_y = (0 == $new_y) ? $this->img_y : $this->_parse_size($new_y, $this->img_y); + // Now do the library specific resizing. + return $this->_resize($new_x, $new_y); + } // End resize + + + /** + * Scale the image to have the max x dimension specified. + * + * @param int $new_x Size to scale X-dimension to + * @return none + */ + function scaleMaxX($new_x) + { + $new_y = round(($new_x / $this->img_x) * $this->img_y, 0); + return $this->_resize($new_x, $new_y); + } // End resizeX + + /** + * Scale the image to have the max y dimension specified. + * + * @access public + * @param int $new_y Size to scale Y-dimension to + * @return none + */ + function scaleMaxY($new_y) + { + $new_x = round(($new_y / $this->img_y) * $this->img_x, 0); + return $this->_resize($new_x, $new_y); + } // End resizeY + + /** + * Scale Image to a maximum or percentage + * + * @access public + * @param mixed (number, percentage 10% or 0.1) + * @return mixed none or PEAR_error + */ + function scale($size) + { + if ((strlen($size) > 1) && (substr($size,-1) == '%')) { + return $this->scaleByPercentage(substr($size, 0, -1)); + } elseif ($size < 1) { + return $this->scaleByFactor($size); + } else { + return $this->scaleByLength($size); + } + } // End scale + + /** + * Scales an image to a percentage of its original size. For example, if + * my image was 640x480 and I called scaleByPercentage(10) then the image + * would be resized to 64x48 + * + * @access public + * @param int $size Percentage of original size to scale to + * @return none + */ + function scaleByPercentage($size) + { + return $this->scaleByFactor($size / 100); + } // End scaleByPercentage + + /** + * Scales an image to a factor of its original size. For example, if + * my image was 640x480 and I called scaleByFactor(0.5) then the image + * would be resized to 320x240. + * + * @access public + * @param float $size Factor of original size to scale to + * @return none + */ + function scaleByFactor($size) + { + $new_x = round($size * $this->img_x, 0); + $new_y = round($size * $this->img_y, 0); + return $this->_resize($new_x, $new_y); + } // End scaleByFactor + + /** + * Scales an image so that the longest side has this dimension. + * + * @access public + * @param int $size Max dimension in pixels + * @return none + */ + function scaleByLength($size) + { + if ($this->img_x >= $this->img_y) { + $new_x = $size; + $new_y = round(($new_x / $this->img_x) * $this->img_y, 0); + } else { + $new_y = $size; + $new_x = round(($new_y / $this->img_y) * $this->img_x, 0); + } + return $this->_resize($new_x, $new_y); + } // End scaleByLength + + + /** + * + * @access public + * @return void + */ + function _get_image_details($image) + { + //echo $image; + $data = @GetImageSize($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 + if (is_array($data)){ + switch($data[2]){ + case 1: + $type = 'gif'; + break; + case 2: + $type = 'jpeg'; + break; + case 3: + $type = 'png'; + break; + case 4: + $type = 'swf'; + break; + case 5: + $type = 'psd'; + case 6: + $type = 'bmp'; + case 7: + case 8: + $type = 'tiff'; + default: + echo("We do not recognize this image format"); + } + $this->img_x = $data[0]; + $this->img_y = $data[1]; + $this->type = $type; + + return true; + } else { + echo("Cannot fetch image or images details."); + return null; + } + /* + $output = array( + 'width' => $data[0], + 'height' => $data[1], + 'type' => $type + ); + return $output; + */ + } + + + /** + * Parse input and convert + * If either is 0 it will be scaled proportionally + * + * @access private + * + * @param mixed $new_size (0, number, percentage 10% or 0.1) + * @param int $old_size + * + * @return mixed none or PEAR_error + */ + function _parse_size($new_size, $old_size) + { + if ('%' == $new_size) { + $new_size = str_replace('%','',$new_size); + $new_size = $new_size / 100; + } + if ($new_size > 1) { + return (int) $new_size; + } elseif ($new_size == 0) { + return (int) $old_size; + } else { + return (int) round($new_size * $old_size, 0); + } + } + + + function uniqueStr() + { + return substr(md5(microtime()),0,6); + } + + //delete old tmp files, and allow only 1 file per remote host. + function cleanUp($id, $dir) + { + $d = dir($dir); + $id_length = strlen($id); + + while (false !== ($entry = $d->read())) { + if (is_file($dir.'/'.$entry) && substr($entry,0,1) == '.' && !ereg($entry, $this->image)) + { + //echo filemtime($this->directory.'/'.$entry)."
    "; + //echo time(); + + if (filemtime($dir.'/'.$entry) + $this->lapse_time < time()) + unlink($dir.'/'.$entry); + + if (substr($entry, 1, $id_length) == $id) + { + if (is_file($dir.'/'.$entry)) + unlink($dir.'/'.$entry); + } + } + } + $d->close(); + } + + + function createUnique($dir) + { + $unique_str = '.'.$this->uid.'_'.$this->uniqueStr().".".$this->type; + + //make sure the the unique temp file does not exists + while (file_exists($dir.$unique_str)) + { + $unique_str = '.'.$this->uid.'_'.$this->uniqueStr().".".$this->type; + } + + $this->cleanUp($this->uid, $dir); + + return $unique_str; + } + + + /** + * Set the image width + * @param int $size dimension to set + * @since 29/05/02 13:36:31 + * @return + */ + function _set_img_x($size) + { + $this->img_x = $size; + } + + /** + * Set the image height + * @param int $size dimension to set + * @since 29/05/02 13:36:31 + * @return + */ + function _set_img_y($size) + { + $this->img_y = $size; + } + + /** + * Set the image width + * @param int $size dimension to set + * @since 29/05/02 13:36:31 + * @return + */ + function _set_new_x($size) + { + $this->new_x = $size; + } + + /** + * Set the image height + * @param int $size dimension to set + * @since 29/05/02 13:36:31 + * @return + */ + function _set_new_y($size) + { + $this->new_y = $size; + } + + /** + * Get the type of the image being manipulated + * + * @return string $this->type the image type + */ + function getImageType() + { + return $this->type; + } + + /** + * + * @access public + * @return string web-safe image type + */ + function getWebSafeFormat() + { + switch($this->type){ + case 'gif': + case 'png': + return 'png'; + break; + default: + return 'jpeg'; + } // switch + } + + /** + * Place holder for the real resize method + * used by extended methods to do the resizing + * + * @access private + * @return PEAR_error + */ + function _resize() { + return null; //PEAR::raiseError("No Resize method exists", true); + } + + /** + * Place holder for the real load method + * used by extended methods to do the resizing + * + * @access public + * @return PEAR_error + */ + function load($filename) { + return null; //PEAR::raiseError("No Load method exists", true); + } + + /** + * Place holder for the real display method + * used by extended methods to do the resizing + * + * @access public + * @param string filename + * @return PEAR_error + */ + function display($type, $quality) { + return null; //PEAR::raiseError("No Display method exists", true); + } + + /** + * Place holder for the real save method + * used by extended methods to do the resizing + * + * @access public + * @param string filename + * @return PEAR_error + */ + function save($filename, $type, $quality) { + return null; //PEAR::raiseError("No Save method exists", true); + } + + /** + * Place holder for the real free method + * used by extended methods to do the resizing + * + * @access public + * @return PEAR_error + */ + function free() { + return null; //PEAR::raiseError("No Free method exists", true); + } + + /** + * Reverse of rgb2colorname. + * + * @access public + * @return PEAR_error + * + * @see rgb2colorname + */ + function colorhex2colorarray($colorhex) { + $r = hexdec(substr($colorhex, 1, 2)); + $g = hexdec(substr($colorhex, 3, 2)); + $b = hexdec(substr($colorhex, 4, 2)); + return array($r,$g,$b); + } + + /** + * Reverse of rgb2colorname. + * + * @access public + * @return PEAR_error + * + * @see rgb2colorname + */ + function colorarray2colorhex($color) { + $color = '#'.dechex($color[0]).dechex($color[1]).dechex($color[2]); + return strlen($color)>6?false:$color; + } + + + /* Methods to add to the driver classes in the future */ + function addText() + { + return null; //PEAR::raiseError("No addText method exists", true); + } + + function addDropShadow() + { + return null; //PEAR::raiseError("No AddDropShadow method exists", true); + } + + function addBorder() + { + return null; //PEAR::raiseError("No addBorder method exists", true); + } + + function crop() + { + return null; //PEAR::raiseError("No crop method exists", true); + } + + function flip() + { + return null; + } + + function gamma() + { + return null; //PEAR::raiseError("No gamma method exists", true); + } +} +?> diff --git a/admin/htmlarea/plugins/ImageManager/README.txt b/admin/htmlarea/plugins/ImageManager/README.txt new file mode 100755 index 0000000..e95bf50 --- /dev/null +++ b/admin/htmlarea/plugins/ImageManager/README.txt @@ -0,0 +1,12 @@ +This is a plug-in for HTMLArea 3.0 + +The PHP ImageManager + Editor provides an interface to +browser for image files on your web server. The Editor +allows some basic image manipulations such as, cropping, +rotation, flip, and scaling. + +Further and up-to-date documentation can be found at +http://www.zhuo.org/htmlarea/docs/index.html + +Cheer, +Wei \ No newline at end of file diff --git a/admin/htmlarea/plugins/ImageManager/assets/EditorContent.js b/admin/htmlarea/plugins/ImageManager/assets/EditorContent.js new file mode 100755 index 0000000..97788ad --- /dev/null +++ b/admin/htmlarea/plugins/ImageManager/assets/EditorContent.js @@ -0,0 +1,744 @@ +/*********************************************************************** +** Title.........: Online Image Editor Interface +** Version.......: 1.0 +** Author........: Xiang Wei ZHUO +** Filename......: EditorContents.js +** Last changed..: 31 Mar 2004 +** Notes.........: Handles most of the interface routines for the ImageEditor. +* +* Added: 29 Mar 2004 - Constrainted resizing/scaling +**/ + + +function MM_findObj(n, d) { //v4.01 + var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { + d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} + if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i-1 && navigator.appVersion.indexOf("Mac")>-1)) { + ox=0;oy=0;if(g.style.left){x=parseInt(g.style.left);y=parseInt(g.style.top); + }else{var w1=parseInt(el.style.width);bx=(a<0)?-5-w1:-10; + a=(Math.abs(a)<1000)?0:a;b=(Math.abs(b)<1000)?0:b; + //alert(event.clientX); + if (event == null) x=document.body.scrollLeft + bx; + else x=document.body.scrollLeft + event.clientX + bx; + if (event == null) y=document.body.scrollTop; + else y=document.body.scrollTop + event.clientY;}} + }else if (document.layers) {x=g.x;y=g.y;var q0=document.layers,dd=""; + for(var s=0;s4){xx+="px";yy+="px";} + if(navigator.appVersion.indexOf("MSIE 5")>-1 && navigator.appVersion.indexOf("Mac")>-1){ + xx+=parseInt(document.body.leftMargin);yy+=parseInt(document.body.topMargin); + xx+="px";yy+="px";}e.left=xx;e.top=yy;} + pic_x = parseInt(xx); pic_y = parseInt(yy); + //alert(xx+":"+yy); + } +} + +var ie=document.all +var ns6=document.getElementById&&!document.all + +var dragapproved=false +var z,x,y,status, ant, canvas, content, pic_width, pic_height, image, resizeHandle, oa_w, oa_h, oa_x, oa_y, mx2, my2; + + +function init_resize() +{ + if(mode == "scale") + { + P7_Snap('theImage','ant',0,0); + + if (canvas == null) + canvas = MM_findObj("imgCanvas"); + + if (pic_width == null || pic_height == null) + { + image = MM_findObj("theImage"); + pic_width = image.width; + pic_height = image.height; + } + + if (ant == null) + ant = MM_findObj("ant"); + + ant.style.left = pic_x; ant.style.top = pic_y; + ant.style.width = pic_width; ant.style.height = pic_height; + ant.style.visibility = "visible"; + + drawBoundHandle(); + jg_doc.paint(); + } +} + +initEditor = function () +{ + init_crop(); + init_resize(); + var markerImg = MM_findObj('markerImg', window.top.document); + + if (markerImg.src.indexOf("img/t_white.gif")>0) + toggleMarker() ; +} + +function init_crop() +{ + //if(mode == "crop") { + P7_Snap('theImage','ant',0,0); + //} +} + +function setMode(newMode) +{ + mode = newMode; + reset(); +} + +function reset() +{ + if (ant == null) + ant = MM_findObj("ant"); + + ant.style.visibility = "hidden"; + ant.style.left = 0; + ant.style.top = 0; + ant.style.width = 0; + ant.style.height = 0; + + mx2 = null; + my2 = null; + + jg_doc.clear(); + if(mode != 'measure') + showStatus(); + + if(mode == "scale") { + init_resize(); + } + + P7_Snap('theImage','ant',0,0); +} + +function toggleMarker() +{ + //alert("Toggle"); + if (ant == null) + ant = MM_findObj("ant"); + + if(ant.className=="selection") + ant.className="selectionWhite"; + else + ant.className="selection"; + + if (jg_doc.getColor() == "#000000") + jg_doc.setColor("#FFFFFF"); + else + jg_doc.setColor("#000000"); + + drawBoundHandle + jg_doc.paint(); +} + + +function move(e) +{ + if (dragapproved) + { + //z.style.left=ns6? temp1+e.clientX-x: temp1+event.clientX-x + //z.style.top=ns6? temp2+e.clientY-y : temp2+event.clientY-y + var w = ns6? temp1+e.clientX - x : temp1+event.clientX - x; + var h = ns6? temp2+e.clientY - y : temp2+event.clientY - y; + + //alert(canvas.style.left); + /*if (status !=null) + { + status.innerHTML = "x:"+x+" y:"+y+" w:"+w+" h:"+h+" can_h:"+pic_height; + status.innerHTML += " can_w:"+pic_width+" px:"+pic_x+" py:"+pic_y; + status.innerHTML += " pix:"+image.style.left+" piy:"+image.style.top+" obj:"+obj.id; + }*/ + + /*jg_doc.clear(); + jg_doc.fillRectPattern(0,0,Math.abs(w),Math.abs(h),pattern); + jg_doc.paint(); +*/ + if (ant != null) + { + if (w >= 0) + { + ant.style.left = x; + ant.style.width = w; + } + else + { + ant.style.left = x+w; + ant.style.width = -1*w; + } + + if (h >= 0) + { + ant.style.top = y; + ant.style.height = h; + } + else + { + ant.style.top = y+h; + ant.style.height = -1*h + } + } + + showStatus(); + return false + } +} + +function moveContent(e) +{ + if (dragapproved) + { + + var dx =ns6? oa_x + e.clientX-x: oa_x + event.clientX-x + var dy =ns6? oa_y + e.clientY-y : oa_y + event.clientY-y + + + /*if (status !=null) + { + status.innerHTML = "x:"+x+" y:"+y+" dx:"+dx+" dy:"+dy; + }*/ + + ant.style.left = dx; + ant.style.top = dy; + + showStatus(); + + return false; + } +} + +//Code add for constraints by Frédéric Klee +function moveHandle(e) +{ + if (dragapproved) + { + var w = ns6? e.clientX - x : event.clientX - x; + var h = ns6? e.clientY - y : event.clientY - y; + + var constrained = MM_findObj('constProp', window.top.document); + var orginal_height = document.theImage.height ; + var orginal_width = document.theImage.width ; + rapp = orginal_width/orginal_height ; + rapp_inv = orginal_height / orginal_width ; + + switch(resizeHandle) + { + + case "s-resize": + if (oa_h + h >= 0) + { + ant.style.height = oa_h + h; + if(constrained.checked) + { + ant.style.width = rapp * (oa_h + h) ; + ant.style.left = oa_x - rapp * h/2; + } + + } + break; + case "e-resize": + if(oa_w + w >= 0) + { + ant.style.width = oa_w + w; + if(constrained.checked) + { + ant.style.height = rapp_inv * (oa_w + w) ; + ant.style.top = oa_y - rapp_inv * w/2; + } + + } + break; + case "n-resize": + if (oa_h - h >= 0) + { + ant.style.top = oa_y + h; + ant.style.height = oa_h - h; + if(constrained.checked) + { + ant.style.width = rapp * (oa_h - h) ; + ant.style.left = oa_x + rapp * h/2; + } + + } + break; + case "w-resize": + if(oa_w - w >= 0) + { + ant.style.left = oa_x + w; + ant.style.width = oa_w - w; + if(constrained.checked) + { + ant.style.height = rapp_inv * (oa_w - w) ; + ant.style.top = oa_y + rapp_inv * w/2; + } + + }break; + case "nw-resize": + if(oa_h - h >= 0 && oa_w - w >= 0) { + ant.style.left = oa_x + w; + ant.style.width = oa_w - w; + ant.style.top = oa_y + h; + if(constrained.checked) + ant.style.height = rapp_inv * (oa_w - w) ; + else + ant.style.height = oa_h - h; + } + break; + case "ne-resize": + if (oa_h - h >= 0 && oa_w + w >= 0){ + ant.style.top = oa_y + h; + ant.style.width = oa_w + w; + if(constrained.checked) + ant.style.height = rapp_inv * (oa_w + w) ; + else + ant.style.height = oa_h - h; + } + break; + case "se-resize": + if (oa_h + h >= 0 && oa_w + w >= 0) + { + ant.style.width = oa_w + w; + if(constrained.checked) + ant.style.height = rapp_inv * (oa_w + w) ; + else + ant.style.height = oa_h + h; + } + break; + case "sw-resize": + if (oa_h + h >= 0 && oa_w - w >= 0) + { + ant.style.left = oa_x + w; + ant.style.width = oa_w - w; + if(constrained.checked) + ant.style.height = rapp_inv * (oa_w - w) ; + else + ant.style.height = oa_h + h; + } + } + + showStatus(); + return false; + + } +} + +function drags(e) +{ + if (!ie&&!ns6) + return + + var firedobj=ns6? e.target : event.srcElement + var topelement=ns6? "HTML" : "BODY" + + while (firedobj.tagName!=topelement&& + !(firedobj.className=="crop" + || firedobj.className=="handleBox" + || firedobj.className=="selection" || firedobj.className=="selectionWhite")) + { + firedobj=ns6? firedobj.parentNode : firedobj.parentElement + } + + if(firedobj.className=="handleBox") { + + if(content != null) { + if(content.width != null && content.height != null) { + content.width = 0; + content.height = 0; + } + //alert(content.width+":"+content.height); + } + resizeHandle = firedobj.id; + + /*if(status!=null) { + status.innerHTML = " obj:"+firedobj.id; + }*/ + + x=ns6? e.clientX: event.clientX + y=ns6? e.clientY: event.clientY + + oa_w = parseInt(ant.style.width); + oa_h = parseInt(ant.style.height); + oa_x = parseInt(ant.style.left); + oa_y = parseInt(ant.style.top); + + dragapproved=true + document.onmousemove=moveHandle; + return false; + } + else + if((firedobj.className == "selection" || firedobj.className=="selectionWhite")&& mode == "crop") { + + x=ns6? e.clientX: event.clientX + y=ns6? e.clientY: event.clientY + + oa_x = parseInt(ant.style.left); + oa_y = parseInt(ant.style.top); + + dragapproved=true + document.onmousemove=moveContent; + return false; + } + else + if (firedobj.className=="crop" && mode == "crop") + { + if(content != null) { + if(content.width != null && content.height != null) { + content.width = 0; + content.height = 0; + } + //alert(content.width+":"+content.height); + } + + if (status == null) + status = MM_findObj("status"); + + if (ant == null) + ant = MM_findObj("ant"); + + if (canvas == null) + canvas = MM_findObj("imgCanvas"); + if(content == null) { + content = MM_findObj("cropContent"); + } + + if (pic_width == null || pic_height == null) + { + image = MM_findObj("theImage"); + pic_width = image.width; + pic_height = image.height; + } + + ant.style.visibility = "visible"; + + obj = firedobj; + dragapproved=true + z=firedobj + temp1=parseInt(z.style.left+0) + temp2=parseInt(z.style.top+0) + x=ns6? e.clientX: event.clientX + y=ns6? e.clientY: event.clientY + document.onmousemove=move + return false + } + else if(firedobj.className=="crop" && mode == "measure") { + + if (ant == null) + ant = MM_findObj("ant"); + + if (canvas == null) + canvas = MM_findObj("imgCanvas"); + + x=ns6? e.clientX: event.clientX + y=ns6? e.clientY: event.clientY + + //jg_doc.draw + dragapproved=true + document.onmousemove=measure + + return false + } +} + +function measure(e) +{ + if (dragapproved) + { + mx2 = ns6? e.clientX : event.clientX; + my2 = ns6? e.clientY : event.clientY; + + jg_doc.clear(); + jg_doc.setStroke(Stroke.DOTTED); + jg_doc.drawLine(x,y,mx2,my2); + jg_doc.paint(); + showStatus(); + return false; + } +} + +function setMarker(nx,ny,nw,nh) +{ + if (ant == null) + ant = MM_findObj("ant"); + + if (canvas == null) + canvas = MM_findObj("imgCanvas"); + if(content == null) { + content = MM_findObj("cropContent"); + } + + if (pic_width == null || pic_height == null) + { + image = MM_findObj("theImage"); + pic_width = image.width; + pic_height = image.height; + } + + ant.style.visibility = "visible"; + + nx = pic_x + nx; + ny = pic_y + ny; + + if (nw >= 0) + { + ant.style.left = nx; + ant.style.width = nw; + } + else + { + ant.style.left = nx+nw; + ant.style.width = -1*nw; + } + + if (nh >= 0) + { + ant.style.top = ny; + ant.style.height = nh; + } + else + { + ant.style.top = ny+nh; + ant.style.height = -1*nh + } + + +} + +function max(x,y) +{ + if(y > x) + return x; + else + return y; +} + +function drawBoundHandle() +{ + if(ant == null || ant.style == null) + return false; + + var ah = parseInt(ant.style.height); + var aw = parseInt(ant.style.width); + var ax = parseInt(ant.style.left); + var ay = parseInt(ant.style.top); + + jg_doc.drawHandle(ax-15,ay-15,30,30,"nw-resize"); //upper left + jg_doc.drawHandle(ax-15,ay+ah-15,30,30,"sw-resize"); //lower left + jg_doc.drawHandle(ax+aw-15,ay-15,30,30,"ne-resize"); //upper right + jg_doc.drawHandle(ax+aw-15,ay+ah-15,30,30,"se-resize"); //lower right + + jg_doc.drawHandle(ax+max(15,aw/10),ay-8,aw-2*max(15,aw/10),8,"n-resize"); //top middle + jg_doc.drawHandle(ax+max(15,aw/10),ay+ah,aw-2*max(15,aw/10),8,"s-resize"); //bottom middle + jg_doc.drawHandle(ax-8, ay+max(15,ah/10),8,ah-2*max(15,ah/10),"w-resize"); //left middle + jg_doc.drawHandle(ax+aw, ay+max(15,ah/10),8,ah-2*max(15,ah/10),"e-resize"); //right middle + + + + jg_doc.drawHandleBox(ax-4,ay-4,8,8,"nw-resize"); //upper left + jg_doc.drawHandleBox(ax-4,ay+ah-4,8,8,"sw-resize"); //lower left + jg_doc.drawHandleBox(ax+aw-4,ay-4,8,8,"ne-resize"); //upper right + jg_doc.drawHandleBox(ax+aw-4,ay+ah-4,8,8,"se-resize"); //lower right + + jg_doc.drawHandleBox(ax+aw/2-4,ay-4,8,8,"n-resize"); //top middle + jg_doc.drawHandleBox(ax+aw/2-4,ay+ah-4,8,8,"s-resize"); //bottom middle + jg_doc.drawHandleBox(ax-4, ay+ah/2-4,8,8,"w-resize"); //left middle + jg_doc.drawHandleBox(ax+aw-4, ay+ah/2-4,8,8,"e-resize"); //right middle + + //jg_doc.paint(); +} + +function showStatus() +{ + if(ant == null || ant.style == null) { + return false; + } + + if(mode == "measure") { + //alert(pic_x); + mx1 = x - pic_x; + my1 = y - pic_y; + + mw = mx2 - x; + mh = my2 - y; + + md = parseInt(Math.sqrt(mw*mw + mh*mh)*100)/100; + + ma = (Math.atan(-1*mh/mw)/Math.PI)*180; + if(mw < 0 && mh < 0) + ma = ma+180; + + if (mw <0 && mh >0) + ma = ma - 180; + + ma = parseInt(ma*100)/100; + + if (m_sx != null && !isNaN(mx1)) + m_sx.value = mx1+"px"; + if (m_sy != null && !isNaN(my1)) + m_sy.value = my1+"px"; + if(m_w != null && !isNaN(mw)) + m_w.value = mw + "px"; + if(m_h != null && !isNaN(mh)) + m_h.value = mh + "px"; + + if(m_d != null && !isNaN(md)) + m_d.value = md + "px"; + if(m_a != null && !isNaN(ma)) + m_a.value = ma + ""; + + if(r_ra != null &&!isNaN(ma)) + r_ra.value = ma; + + //alert("mx1:"+mx1+" my1"+my1); + return false; + } + + var ah = parseInt(ant.style.height); + var aw = parseInt(ant.style.width); + var ax = parseInt(ant.style.left); + var ay = parseInt(ant.style.top); + + var cx = ax-pic_x<0?0:ax-pic_x; + var cy = ay-pic_y<0?0:ay-pic_y; + cx = cx>pic_width?pic_width:cx; + cy = cy>pic_height?pic_height:cy; + + var cw = ax-pic_x>0?aw:aw-(pic_x-ax); + var ch = ay-pic_y>0?ah:ah-(pic_y-ay); + + ch = ay+ah0 && s_sh.value.indexOf('%')>0) + { + sw = cw/pic_width; + sh = ch/pic_height; + } + if (s_sw != null) + s_sw.value = sw; + if (s_sh != null) + s_sh.value = sh; + } + +} + +function dragStopped() +{ + dragapproved=false; + + if(ant == null || ant.style == null) { + return false; + } + + if(mode == "measure") { + jg_doc.drawLine(x-4,y,x+4,y); + jg_doc.drawLine(x,y-4,x,y+4); + jg_doc.drawLine(mx2-4,my2,mx2+4,my2); + jg_doc.drawLine(mx2,my2-4,mx2,my2+4); + + jg_doc.paint(); + showStatus(); + return false; + } + var ah = parseInt(ant.style.height); + var aw = parseInt(ant.style.width); + var ax = parseInt(ant.style.left); + var ay = parseInt(ant.style.top); + jg_doc.clear(); + + if(content != null) { + if(content.width != null && content.height != null) { + content.width = aw-1; + content.height = ah-1; + } + //alert(content.width+":"+content.height); + } + if(mode == "crop") { + //alert(pic_y); + jg_doc.fillRectPattern(pic_x,pic_y,pic_width,ay-pic_y,pattern); + + var h1 = ah; + var y1 = ay; + if (ah+ay >= pic_height+pic_y) + h1 = pic_height+pic_y-ay; + else if (ay <= pic_y) + { + h1 = ay+ah-pic_y; + y1 = pic_y; + } + jg_doc.fillRectPattern(pic_x,y1,ax-pic_x,h1,pattern); + jg_doc.fillRectPattern(ax+aw,y1,pic_x+pic_width-ax-aw,h1,pattern); + jg_doc.fillRectPattern(pic_x,ay+ah,pic_width,pic_height+pic_y-ay-ah,pattern); + } + else if(mode == "scale") { + //alert("Resizing: iw:"+image.width+" nw:"+aw); + document.theImage.height = ah; + document.theImage.width = aw; + document.theImage.style.height = ah+" px"; + document.theImage.style.width = aw+" px"; + + P7_Snap('theImage','ant',0,0); + + //alert("After Resizing: iw:"+image.width+" nw:"+aw); + } + + drawBoundHandle(); + jg_doc.paint(); + + showStatus(); + return false; +} + +document.onmousedown=drags +document.onmouseup=dragStopped; + diff --git a/admin/htmlarea/plugins/ImageManager/assets/ImageEditor.css b/admin/htmlarea/plugins/ImageManager/assets/ImageEditor.css new file mode 100755 index 0000000..7cefe46 --- /dev/null +++ b/admin/htmlarea/plugins/ImageManager/assets/ImageEditor.css @@ -0,0 +1,76 @@ +.icons { + font: 11px Tahoma,Verdana,sans-serif; + color: #666699; + text-align: center; + text-decoration: none; + border: 1px solid #EEEEFF; + -Moz-Border-Radius: 6px 6px 6px 6px; +} + +body, td, p { + font: 11px Tahoma,Verdana,sans-serif; +} +.iconsOver { + font: 11px Tahoma,Verdana,sans-serif; + color: #666699; + text-align: center; + text-decoration: none; + background-color: #F9F9FF; + border: 1px solid #666699; + -Moz-Border-Radius: 6px 6px 6px 6px; +} +.topBar { + font: 11px Tahoma,Verdana,sans-serif; + color: #666699; +} +.iconsSel { + font: 11px Tahoma,Verdana,sans-serif; + color: #666699; + text-align: center; + text-decoration: none; + border: 1px solid #666699; + -Moz-Border-Radius: 6px 6px 6px 6px; +} +.iconText { + font: 11px Tahoma,Verdana,sans-serif; + color: #666699; + text-decoration: none; + text-align: center; +} +.measureStats{ + width: 50px; +} + +#slidercasing { + /*border:1px solid #CCCCCC; + background-color:#FFFFFF;*/ + width:100px; + height:5px; + position:relative; + z-index:4; + padding:10px; +} + + +#slidertrack { + position:relative; + border:1px solid #CCCCCC; + background-color:#FFFFCC; + z-index:5; + height:5px; +} + + +#sliderbar { + position:absolute; + z-index:6; + border:1px solid #CCCCCC; + background-color:#DDDDDD; + width:15px; + padding:0px; + height:20px; + cursor: pointer; + top:2px; +} + +select, input, button { font: 11px Tahoma,Verdana,sans-serif; } diff --git a/admin/htmlarea/plugins/ImageManager/assets/dialog.js b/admin/htmlarea/plugins/ImageManager/assets/dialog.js new file mode 100755 index 0000000..e82769c --- /dev/null +++ b/admin/htmlarea/plugins/ImageManager/assets/dialog.js @@ -0,0 +1,111 @@ +// Dialog v3.0 - Copyright (c) 2003-2004 interactivetools.com, inc. +// This copyright notice MUST stay intact for use (see license.txt). +// +// Portions (c) dynarch.com, 2003-2004 +// +// A free WYSIWYG editor replacement for + + + diff --git a/admin/htmlarea/popups/insert_image.html b/admin/htmlarea/popups/insert_image.html new file mode 100755 index 0000000..cef3adb --- /dev/null +++ b/admin/htmlarea/popups/insert_image.html @@ -0,0 +1,191 @@ + + + + Insert Image + + + + + + + + + + + +
    Insert Image
    + +
    + + + + + + + + + + + + + +
    Image URL: + +
    Alternate text:
    + +

    + +

    +Layout + +
    + +
    Alignment:
    + + +

    + +

    Border thickness:
    + + +
    + +
    + +
    +Spacing + +
    + +
    Horizontal:
    + + +

    + +

    Vertical:
    + + +
    + +
    +
    + + + + + +
    + Image Preview:
    + +
    +
    + +
    +
    + + diff --git a/admin/htmlarea/popups/insert_table.html b/admin/htmlarea/popups/insert_table.html new file mode 100755 index 0000000..49cf3f0 --- /dev/null +++ b/admin/htmlarea/popups/insert_table.html @@ -0,0 +1,174 @@ + + + + Insert Table + + + + + + + + + + + +
    Insert Table
    + +
    + + + + + + + + + + + + + + + + + + + +
    Rows:
    Cols:Width:
    + +

    + +

    +Layout + +
    + +
    Alignment:
    + + +

    + +

    Border thickness:
    + + +
    + +
    + +
    +Spacing + +
    + +
    Cell spacing:
    + + +

    + +

    Cell padding:
    + + +
    + +
    + +
    + + +
    + +
    + + + diff --git a/admin/htmlarea/popups/link.html b/admin/htmlarea/popups/link.html new file mode 100755 index 0000000..1a87171 --- /dev/null +++ b/admin/htmlarea/popups/link.html @@ -0,0 +1,142 @@ + + + + Insert/Modify Link + + + + + + + + +
    Insert/Modify Link
    + + + + + + + + + + + + + + +
    URL:
    Title (tooltip):
    Target: + +
    + +
    + + +
    + + + diff --git a/admin/htmlarea/popups/makefile.xml b/admin/htmlarea/popups/makefile.xml new file mode 100755 index 0000000..106730e --- /dev/null +++ b/admin/htmlarea/popups/makefile.xml @@ -0,0 +1,4 @@ + + + + diff --git a/admin/htmlarea/popups/old-fullscreen.html b/admin/htmlarea/popups/old-fullscreen.html new file mode 100755 index 0000000..6ecfb8e --- /dev/null +++ b/admin/htmlarea/popups/old-fullscreen.html @@ -0,0 +1,131 @@ + +Fullscreen Editor + + + + + + +
    + +
    + + \ No newline at end of file diff --git a/admin/htmlarea/popups/old_insert_image.html b/admin/htmlarea/popups/old_insert_image.html new file mode 100755 index 0000000..632bb7a --- /dev/null +++ b/admin/htmlarea/popups/old_insert_image.html @@ -0,0 +1,206 @@ + + + + + + + +Insert Image + + + + + +
    Image URL:
    + + +
    Alternate Text:
    + + +
    +Layout +
    + +
    +Spacing +
    + +
    Alignment:
    + + +
    Horizontal:
    + + +
    Border Thickness:
    + + +
    Vertical:
    + + + + + + + \ No newline at end of file diff --git a/admin/htmlarea/popups/popup.js b/admin/htmlarea/popups/popup.js new file mode 100755 index 0000000..6f37710 --- /dev/null +++ b/admin/htmlarea/popups/popup.js @@ -0,0 +1,109 @@ +// htmlArea v3.0 - Copyright (c) 2002, 2003 interactivetools.com, inc. +// This copyright notice MUST stay intact for use (see license.txt). +// +// Portions (c) dynarch.com, 2003 +// +// A free WYSIWYG editor replacement for + + +

    Where can I find out more info, download the latest version and talk to +other HTMLArea users?

    + +

    You can find out more about HTMLArea and download the latest version on +the HTMLArea +homepage and you can talk to other HTMLArea users and post any comments +or suggestions you have in the HTMLArea forum.

    + +

    Keyboard shortcuts

    + +

    The editor provides the following key combinations:

    + +
      +
    • CTRL-A -- select all
    • +
    • CTRL-B -- bold
    • +
    • CTRL-I -- italic
    • +
    • CTRL-U -- underline
    • +
    • CTRL-S -- strikethrough
    • +
    • CTRL-L -- justify left
    • +
    • CTRL-E -- justify center
    • +
    • CTRL-R -- justify right
    • +
    • CTRL-J -- justify full
    • +
    • CTRL-1 .. CTRL-6 -- headings (<h1> .. <h6>)
    • +
    • CTRL-0 (zero) -- clean content pasted from Word
    • +
    + +

    Installation

    + +

    How do I add HTMLArea to my web page?

    + +

    It's easy. First you need to upload HTMLArea files to your website. +Just follow these steps.

    + +
      +
    1. Download the latest version from the htmlArea + homepage.
    2. +
    3. Unzip the files onto your local computer (making sure to maintain the + directory structure contained in the zip).
    4. +
    5. Create a new folder on your website called /htmlarea/ (make sure it's + NOT inside the cgi-bin).
    6. +
    7. Transfer all the HTMLArea files from your local computer into the + /htmlarea/ folder on your website.
    8. +
    9. Open the example page /htmlarea/examples/core.html with your browser to make + sure everything works.
    10. +
    + +

    Once htmlArea is on your website all you need to do is add some +JavaScript to any pages that you want to add WYSIWYG editors to. Here's how +to do that.

    + +
      + +
    1. Define some global variables. "_editor_url" has to be the absolute + URL where HTMLArea resides within your + website; as we discussed, this would be “/htmlarea/”. "_editor_lang" must + be the language code in which you want HTMLArea to appear. This defaults + to "en" (English); for a list of supported languages, please look into + the "lang" subdirectory in the distribution. +
      <script type="text/javascript">
      +   _editor_url = "/htmlarea/";
      +   _editor_lang = "en";
      +</script>
      + +
    2. Include the "htmlarea.js" script: +
      <script type="text/javascript" src="/htmlarea/htmlarea.js"></script>
      +
    3. + +
    4. If you want to change all your <textarea>-s into + HTMLArea-s then you can use the simplest way to create HTMLArea:

      +
      <script type="text/javascript" defer="1">
      +    HTMLArea.replaceAll();
      +</script>
      +

      Note: you can also add the + HTMLArea.replaceAll() code to the onload + event handler for the body element, if you find it more appropriate.

      + +

      A different approach, if you have more than one textarea and only want + to change one of them, is to use HTMLArea.replace("id") -- + pass the id of your textarea. Do not use the + name attribute anymore, it's not a standard solution!

      + +
    + +

    This section applies to HTMLArea-3.0 release candidate 1 or later; prior +to this version, one needed to include more files; however, now HTMLArea is +able to include other files too (such as stylesheet, language definition +file, etc.) so you only need to define the editor path and load +"htmlarea.js". Nice, eh? ;-)

    + +

    I want to change the editor settings, how do I do that?

    + +

    While it's true that all you need is one line of JavaScript to create an +htmlArea WYSIWYG editor, you can also specify more config settings in the +code to control how the editor works and looks. Here's an example of some of +the available settings:

    + +
    var config = new HTMLArea.Config(); // create a new configuration object
    +                                    // having all the default values
    +config.width = '90%';
    +config.height = '200px';
    +
    +// the following sets a style for the page body (black text on yellow page)
    +// and makes all paragraphs be bold by default
    +config.pageStyle =
    +  'body { background-color: yellow; color: black; font-family: verdana,sans-serif } ' +
    +  'p { font-width: bold; } ';
    +
    +// the following replaces the textarea with the given id with a new
    +// HTMLArea object having the specified configuration
    +HTMLArea.replace('id', config);
    + +

    Important: It's recommended that you add +custom features and configuration to a separate file. This will ensure you +that when we release a new official version of HTMLArea you'll have less +trouble upgrading it.

    + +

    How do I customize the toolbar?

    + +

    Using the configuration object introduced above allows you to completely +control what the toolbar contains. Following is an example of a one-line, +customized toolbar, much simpler than the default one:

    + +
    var config = new HTMLArea.Config();
    +config.toolbar = [
    +  ['fontname', 'space',
    +   'fontsize', 'space',
    +   'formatblock', 'space',
    +   'bold', 'italic', 'underline']
    +];
    +HTMLArea.replace('id', config);
    + +

    The toolbar is an Array of Array objects. Each array in the toolbar +defines a new line. The default toolbar looks like this:

    + +
    config.toolbar = [
    +[ "fontname", "space",
    +  "fontsize", "space",
    +  "formatblock", "space",
    +  "bold", "italic", "underline", "separator",
    +  "strikethrough", "subscript", "superscript", "separator",
    +  "copy", "cut", "paste", "space", "undo", "redo" ],
    +		
    +[ "justifyleft", "justifycenter", "justifyright", "justifyfull", "separator",
    +  "insertorderedlist", "insertunorderedlist", "outdent", "indent", "separator",
    +  "forecolor", "hilitecolor", "textindicator", "separator",
    +  "inserthorizontalrule", "createlink", "insertimage", "inserttable", "htmlmode", "separator",
    +  "popupeditor", "separator", "showhelp", "about" ]
    +];
    + +

    Except three strings, all others in the examples above need to be defined +in the config.btnList object (detailed a bit later in this +document). The three exceptions are: 'space', 'separator' and 'linebreak'. +These three have the following meaning, and need not be present in +btnList:

    + +
      +
    • 'space' -- Inserts a space of 5 pixels (the width is configurable by external + CSS) at the current + position in the toolbar.
    • +
    • 'separator' -- Inserts a small vertical separator, for visually grouping related + buttons.
    • +
    • 'linebreak' -- Starts a new line in the toolbar. Subsequent controls will be + inserted on the new line.
    • +
    + +

    Important: It's recommended that you add +custom features and configuration to a separate file. This will ensure you +that when we release a new official version of HTMLArea you'll have less +trouble upgrading it.

    + +

    How do I create custom buttons?

    + +

    By design, the toolbar is easily extensible. For adding a custom button +one needs to follow two steps.

    + +

    1. Register the button in config.btnList.

    + +

    For each button in the toolbar, HTMLArea needs to know the following +information:

    +
      +
    • a name for it (we call it the ID of the button);
    • +
    • the path to an image to be displayed in the toolbar;
    • +
    • a tooltip for it;
    • +
    • whether the button is enabled or not in text mode;
    • +
    • what to do when the button is clicked;
    • +
    +

    You need to provide all this information for registering a new button +too. The button ID can be any string identifier and it's used when +defining the toolbar, as you saw above. We recommend starting +it with "my-" so that it won't clash with the standard ID-s (those from +the default toolbar).

    + +

    Register button example #1

    + +
    // get a default configuration
    +var config = new HTMLArea.Config();
    +// register the new button using Config.registerButton.
    +// parameters:        button ID,   tooltip,          image,           textMode,
    +config.registerButton("my-hilite", "Highlight text", "my-hilite.gif", false,
    +// function that gets called when the button is clicked
    +  function(editor, id) {
    +    editor.surroundHTML('<span class="hilite">', '</span>');
    +  }
    +);
    + +

    An alternate way of calling registerButton is exemplified above. Though +the code might be a little bit larger, using this form makes your code more +maintainable. It doesn't even needs comments as it's pretty clear.

    + +

    Register button example #2

    + +
    var config = new HTMLArea.Config();
    +config.registerButton({
    +  id        : "my-hilite",
    +  tooltip   : "Highlight text",
    +  image     : "my-hilite.gif",
    +  textMode  : false,
    +  action    : function(editor, id) {
    +                editor.surroundHTML('<span class="hilite">', '</span>');
    +              }
    +});
    + +

    You might notice that the "action" function receives two parameters: +editor and id. In the examples above we only used the +editor parameter. But it could be helpful for you to understand +both:

    + +
      +
    • editor is a reference to the HTMLArea object. Since our entire + code now has an OOP-like + design, you need to have a reference to + the editor object in order to do things with it. In previous versions of + HTMLArea, in order to identify the object an ID was used -- the ID of the + HTML element. In this version ID-s are no longer necessary.
    • + +
    • id is the button ID. Wondering why is this useful? Well, you + could use the same handler function (presuming that it's not an anonymous + function like in the examples above) for more buttons. You can see an example a bit later in this document.
    • +
    + +

    2. Inserting it into the toolbar

    + +

    At this step you need to specify where in the toolbar to insert the +button, or just create the whole toolbar again as you saw in the previous +section. You use the button ID, as shown in the examples of customizing the +toolbar in the previous section.

    + +

    For the sake of completion, following there are another examples.

    + +

    Append your button to the default toolbar

    + +
    config.toolbar.push([ "my-hilite" ]);
    + +

    Customized toolbar

    + +
    config.toolbar = [
    +  ['fontname', 'space',
    +   'fontsize', 'space',
    +   'formatblock', 'space',
    +   'separator', 'my-hilite', 'separator', 'space', // here's your button
    +   'bold', 'italic', 'underline', 'space']
    +];
    + +

    Note: in the example above our new button is +between two vertical separators. But this is by no means required. You can +put it wherever you like. Once registered in the btnList (step 1) your custom button behaves just like a default +button.

    + +

    Important: It's recommended that you add +custom features and configuration to a separate file. This will ensure you +that when we release a new official version of HTMLArea you'll have less +trouble upgrading it.

    + +

    A complete example

    + +

    Please note that it is by no means necessary to include the following +code into the htmlarea.js file. On the contrary, it might not work there. +The configuration system is designed such that you can always customize the +editor from outside files, thus keeping the htmlarea.js file +intact. This will make it easy for you to upgrade your HTMLArea when we +release a new official version. OK, I promise it's the last time I said +this. ;)

    + +
    // All our custom buttons will call this function when clicked.
    +// We use the buttonId parameter to determine what button
    +// triggered the call.
    +function clickHandler(editor, buttonId) {
    +  switch (buttonId) {
    +    case "my-toc":
    +      editor.insertHTML("<h1>Table Of Contents</h1>");
    +      break;
    +    case "my-date":
    +      editor.insertHTML((new Date()).toString());
    +      break;
    +    case "my-bold":
    +      editor.execCommand("bold");
    +      editor.execCommand("italic");
    +      break;
    +    case "my-hilite":
    +      editor.surroundHTML("<span class=\"hilite\">", "</span>");
    +      break;
    +  }
    +};
    +
    +// Create a new configuration object
    +var config = new HTMLArea.Config();
    +
    +// Register our custom buttons
    +config.registerButton("my-toc",  "Insert TOC", "my-toc.gif", false, clickHandler);
    +config.registerButton("my-date", "Insert date/time", "my-date.gif", false, clickHandler);
    +config.registerButton("my-bold", "Toggle bold/italic", "my-bold.gif", false, clickHandler);
    +config.registerButton("my-hilite", "Hilite selection", "my-hilite.gif", false, clickHandler);
    +
    +// Append the buttons to the default toolbar
    +config.toolbar.push(["linebreak", "my-toc", "my-date", "my-bold", "my-hilite"]);
    +
    +// Replace an existing textarea with an HTMLArea object having the above config.
    +HTMLArea.replace("textAreaID", config);
    + + +
    +
    © InteractiveTools.com 2002-2004. +
    +© dynarch.com 2003-2004
    +HTMLArea v3.0 developed by Mihai Bazon. +
    +Documentation written by Mihai Bazon. +
    + Last modified: Wed Jan 28 12:18:23 EET 2004 + + diff --git a/admin/htmlarea/release-notes.html b/admin/htmlarea/release-notes.html new file mode 100755 index 0000000..d47dfb4 --- /dev/null +++ b/admin/htmlarea/release-notes.html @@ -0,0 +1,208 @@ + + + + <% $basename %> release notes + + + + + +

    <% $basename %> release notes

    + +

    This release was compiled on <% $time %>.

    + +

    3.0-rc1

    + +

    Changes since 3.0-Beta:

    + +
      +
    • + New plugins +
        +
      • + ContextMenu plugin (provides a nice context menu with common + operations, including table ops, link ops, etc.) +
      • +
      • + CSS plugin (provides an easy way to insert/change CSS classes) +
      • +
      • + FullPage plugin (allows HTMLArea to edit a whole HTML file, + not only the content within <body>.) +
      • +
      +
    • +
    • + Changes in the SpellChecker plugin +
        +
      • + Many bugfixes: now it works ;-) Fully Unicode-safe. +
      • +
      • + Speed and bandwidth optimization: reports the list of + suggestions only once for each mispelled word; this helps + in cases where you have, for instance, the word “HTMLArea” + in 10 places all over the document; the list of + suggestions for it--which is kind of huge--will only be + included once. +
      • +
      • + User interface improvements: the highlighted word will + remain in view; in cases where it's normally outside, the + window will be scrolled to it. +
      • +
      • + Added a "Revert" button for those that change their minds ;-) +
      • +
      • + Added a "Info" button which reports information about the + document, retrieved by the server-side spell checker: + total number of words, total number of mispelled words, + number of suggestions made, spell check time, etc. More + can be easily added. FIXME: this part + is not yet internationalized. +
      • +
      • + The server-side spell checker now uses XML::DOM instead of + HTML::Parser, which means that it will be unable to parse + “tag-soup” HTML. It needs valid code. Usually HTMLArea + generates valid code, but on rare occasions it might fail + and the spell checker will report a gross error message. + This gonna have to be fixed, but instead of making the + spell checker accept invalid HTML I prefer to make + HTMLArea generate valid code, so changes are to be done in + other places ;-) +
      • +
      +
    • +
    • + Changes in the core editor +
        +
      • + Easier to setup: you only need to load + htmlarea.js; other scripts will be loaded + automatically. Documentation + and examples updated. +
      • +
      • + Better plugin support (they register information about + themselves with the editor; can register event handlers for + the editor, etc.) +
      • +
      • + New about box; check it out, it's cool ;-) +
      • +
      • + Word cleaner (can be enabled to automatically kill Word crap + on paste (see Config.killWordOnPaste); otherwise accessible by + pressing CTRL-0 in the editor; a toolbar button will come up + soon) +
      • +
      • + Image preview in "insert image" dialog. Also allows + modification of current image, if selected. +
      • +
      • + New "insert link" dialog, allows target and title + specification, allows editing links. +
      • +
      • + Implemented support for text direction (left-to-right or + right-to-left). +
      • +
      • + Lots of bug fixes! ... and more, I guess ;-) an + automatically generated change log + is now available. +
      • +
      +
    • +
    + +

    I don't have the power to go through the bug +system at SourceForge + now. Some of the bugs reported there may be fixed; I'll update + their status, some other time. If you reported bugs there and now + find them to be fixed, please let me know.

    + +

    3.0-Beta

    + +

    Changes since 3.0-Alpha:

    + +
      + +
    • Performance improvements.
    • + +
    • Many bugs fixed.
    • + +
    • Plugin infrastructure.
    • + +
    • TableOperations plugin.
    • + +
    • SpellChecker plugin.
    • + +
    • Status bar.
    • + +
    • API for registering custom buttons and drop-down boxes in the + toolbar.
    • + +
    • Toolbar can contain text labels.
    • + +
    • Cut, copy, paste, undo, redo buttons.
    • + +
    +<%doc> +

    Rationale for Beta

    + +

    Why was this released as "Beta"? The code is quite stable and it + didn't deserve a "Beta" qualification. However, there are some things + left to do for the real 3.0 version. These things will not affect the + API to work with HTMLArea, in other words, you can install the Beta + right now and then install the final release without modifying your + code. That's if you don't modify HTMLArea itself. ;-)

    + +

    To-Do before 3.0 final

    + +
      + +
    1. We should use a single popup interface. Currently there are two: + dialog.js and popupwin.js; dialog.js emulates modal dialogs, which + sucks when you want to open "select-color" from another popup and not + from the editor itself. Very buggy in IE. We should probably use only + modeless dialogs (that is, popupwin.js).
    2. + +
    3. Internationalization for the SpellChecker plugin.
    4. + +
    5. Internationalization for the TableOperations plugin.
    6. + +
    7. People who sent translations are invited to re-iterate through + their work and make it up-to-date with lang/en.js which is the main + lang file for HTMLArea-3.0. Some things have changed but not all + translations are updated.
    8. + +
    9. Documentation.
    10. + +
    + +
    +
    Mihai Bazon
    + + Last modified: Sun Feb 1 13:16:10 EET 2004 + + + + +<%ARGS> + $project => 'HTMLArea' + $version => '3.0' + $release => 'rc1' + $basename => 'HTMLArea-3.0-rc1' + + +<%INIT>; +use POSIX qw(strftime); +my $time = strftime '%b %e, %Y [%H:%M] GMT', gmtime; + diff --git a/admin/htmlarea/tests/display-none.html b/admin/htmlarea/tests/display-none.html new file mode 100755 index 0000000..f70c0bb --- /dev/null +++ b/admin/htmlarea/tests/display-none.html @@ -0,0 +1,29 @@ + + + + + + + +
    + +
    + + + diff --git a/admin/index.phtml b/admin/index.phtml new file mode 100755 index 0000000..bbaf20c --- /dev/null +++ b/admin/index.phtml @@ -0,0 +1,20 @@ + + + +<?=SITENAME?> Administration + + + + + + + +<body> +<p>Admin Requires Frames Capable Browser</p> +<ul>You can get a Standard Compliant browser from: +<li>Microsoft <a href="http://www.microsoft.com/windows/ie/">Internet Explorer</a></li> +<li>Mozilla's <a href="http://www.mozilla.org/products/firefox/">Firefox</a></li> +</ul> +</body> + + diff --git a/admin/main.css b/admin/main.css new file mode 100755 index 0000000..f6022a3 --- /dev/null +++ b/admin/main.css @@ -0,0 +1,57 @@ +body { background-color: #FFFFFF; } +.navlink { font-size: 80%; font-family: arial; } +TD { font-size: 11px; font-family: arial,helvetica; } +INPUT { font-size: 12px; font-family: arial,helvetica; } +SELECT { font-size: 12px; font-family: arial,helvetica; } +OPTION { font-size: 12px; font-family: arial,helvetica; } +TH { font-size: 11px; font-family: arial,helvetica; font-weight: bold; } +.theader { font-size: 120%; font-family: arial,helvetica; color: #FFFFFF; } +.text { font-size: 100%; font-family: arial,helvetica; color: #000000; } +.theadertd { background-color: #000080; } +.pac_std_text { font-size: 12px; font-weight: normal; } +.pac_bold_text { font-size: 12px; font-weight: bold; } +.pac_std_small { font-size: 10px; font-weight: normal } +.pac_bold_small { font-size: 10px; font-weight: bold } +.pac_redtext { font-size: 12px; color: #CC0000 ; font-family: Arial, Helvetica, sans-serif; font-weight: normal; } +.pac_redhead { font-size: 12px; font-weight: bold; color: #CC0000; font-family: Arial, Helvetica, sans-serif; } +.title1 { font-size: 22px; font-weight: bold; color: blue; font-family: Arial, Helvetica, sans-serif; } +.title2 { font-size: 22px; font-weight: bold; color: black; font-family: Arial, Helvetica, sans-serif; } + +INPUT { FONT-SIZE: 12px; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; } +SELECT { FONT-SIZE: 12px; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; } +.navlink { + font-size: 12px; + font-family: arial; +} + +td { + font-size: 12px; + font-family: arial,helvetica; +} + +.theader { + font-size: 14px; + font-family: arial,helvetica; + color: #FFFFFF; +} + +.theadertd { + background-color: #000080; +} + +.topheader { + font-family:ms sans serif,arial,helvetica; + font-size:12px; + color:#FFFFFF; + font-weight:bold; +} +.footer { + text-align:center; + color:#999999; + font-size:10px; + width:600px; +} +/* TOOLBOX NAV */ +ul#toolbox {list-style-position:inside;list-style-type:circle;} +ul#toolbox li {list-style-type:circle} +ul#toolbox li.toolboxArrow {list-style-type:none;padding-left:0;margin-left:-7px;} diff --git a/admin/msg.js b/admin/msg.js new file mode 100755 index 0000000..8ed837d --- /dev/null +++ b/admin/msg.js @@ -0,0 +1,29 @@ +function glm_confirm(o) { + var p = o.msg.split("\n"); + var k = 0; + for(i = 0;i < p.length;i++) { + if(k > p[i].length) + continue; + else + k = p[i].length; + } + + var bound = ""; + for(i = 0; i < k; i++) { + bound = bound+'_'; + } + var str = bound+"\n\n"+o.msg+"\n\n"+bound+"\n\nAre You Sure?"; + if(confirm(str)) { + if(o.popup == '1') { + var nw = new Object(); + nw.url = o.url; + nw.name = o.popup.name; + nw.width = o.width; + nw.height = o.height; + glm_open(nw); + } + else { + location.replace(o.url); + } + } +} diff --git a/admin/nav.phtml b/admin/nav.phtml new file mode 100755 index 0000000..b6e2886 --- /dev/null +++ b/admin/nav.phtml @@ -0,0 +1,87 @@ + + + +Admin Navigation + + + +

    + + +
  • + Support Form +
  • +'; +if(!defined('GLM_APP_BASE_URL')){ + define('GLM_APP_BASE_URL', 'http://app.gaslightmedia.com/'); +} +if(!defined('SITENAME')) { + define('SITENAME', 'http://www.aretenorth.com/'); +} +printf( + $format, + GLM_APP_BASE_URL, + urlencode(SITENAME) +); +?> +GLMbug (3K) + + diff --git a/admin/phpinfo.php b/admin/phpinfo.php new file mode 100644 index 0000000..3c6efe1 --- /dev/null +++ b/admin/phpinfo.php @@ -0,0 +1,4 @@ + diff --git a/admin/setup_log.txt b/admin/setup_log.txt new file mode 100755 index 0000000..14fa337 --- /dev/null +++ b/admin/setup_log.txt @@ -0,0 +1,238 @@ +U Toolbox/business.sql +U Toolbox/edit_bus.phtml +U Toolbox/edit_bus_category.phtml +U Toolbox/index.phtml +U Toolbox/list_bus.phtml +U Toolbox/list_bus_category.phtml +U Toolbox/threads.phtml +U Toolbox/toolbox_setup.inc +U Toolbox/update_bus.phtml +U Toolbox/update_bus_category.phtml +U Toolbox/updatetoolset.php +U Toolbox/help/bus.phtml +U Toolbox/help/buscat.phtml +U Toolbox/help/closewindow.gif +U Toolbox/help/helpbg.gif +U Toolbox/images/collapse.png +U Toolbox/images/ed_about.gif +U Toolbox/images/ed_align_center.gif +U Toolbox/images/ed_align_justify.gif +U Toolbox/images/ed_align_left.gif +U Toolbox/images/ed_align_right.gif +U Toolbox/images/ed_blank.gif +U Toolbox/images/ed_charmap.gif +U Toolbox/images/ed_color_bg.gif +U Toolbox/images/ed_color_fg.gif +U Toolbox/images/ed_copy.gif +U Toolbox/images/ed_custom.gif +U Toolbox/images/ed_cut.gif +U Toolbox/images/ed_delete.gif +U Toolbox/images/ed_format_bold.gif +U Toolbox/images/ed_format_italic.gif +U Toolbox/images/ed_format_strike.gif +U Toolbox/images/ed_format_sub.gif +U Toolbox/images/ed_format_sup.gif +U Toolbox/images/ed_format_underline.gif +U Toolbox/images/ed_help.gif +U Toolbox/images/ed_hr.gif +U Toolbox/images/ed_html.gif +U Toolbox/images/ed_image.gif +U Toolbox/images/ed_indent_less.gif +U Toolbox/images/ed_indent_more.gif +U Toolbox/images/ed_link.gif +U Toolbox/images/ed_list_bullet.gif +U Toolbox/images/ed_list_num.gif +U Toolbox/images/ed_paste.gif +U Toolbox/images/ed_redo.gif +U Toolbox/images/ed_show_border.gif +U Toolbox/images/ed_splitcel.gif +U Toolbox/images/ed_undo.gif +U Toolbox/images/expand.png +U Toolbox/images/fullscreen_maximize.gif +U Toolbox/images/fullscreen_minimize.gif +U Toolbox/images/insert_table.gif +U Toolbox/popups/about.html +U Toolbox/popups/blank.html +U Toolbox/popups/custom2.html +U Toolbox/popups/editor_help.html +U Toolbox/popups/fullscreen.html +U Toolbox/popups/insert_image.html +U Toolbox/popups/insert_table.html +U Toolbox/popups/old-fullscreen.html +U Toolbox/popups/old_insert_image.html +U Toolbox/popups/popup.js +U Toolbox/popups/select_color.html + + +U Toolbox/business.sql +U Toolbox/edit_bus.phtml +U Toolbox/edit_bus_category.phtml +U Toolbox/index.phtml +U Toolbox/list_bus.phtml +U Toolbox/list_bus_category.phtml +U Toolbox/threads.phtml +U Toolbox/toolbox_setup.inc +U Toolbox/update_bus.phtml +U Toolbox/update_bus_category.phtml +U Toolbox/updatetoolset.php +U Toolbox/help/bus.phtml +U Toolbox/help/buscat.phtml +U Toolbox/help/closewindow.gif +U Toolbox/help/helpbg.gif +U Toolbox/images/collapse.png +U Toolbox/images/ed_about.gif +U Toolbox/images/ed_align_center.gif +U Toolbox/images/ed_align_justify.gif +U Toolbox/images/ed_align_left.gif +U Toolbox/images/ed_align_right.gif +U Toolbox/images/ed_blank.gif +U Toolbox/images/ed_charmap.gif +U Toolbox/images/ed_color_bg.gif +U Toolbox/images/ed_color_fg.gif +U Toolbox/images/ed_copy.gif +U Toolbox/images/ed_custom.gif +U Toolbox/images/ed_cut.gif +U Toolbox/images/ed_delete.gif +U Toolbox/images/ed_format_bold.gif +U Toolbox/images/ed_format_italic.gif +U Toolbox/images/ed_format_strike.gif +U Toolbox/images/ed_format_sub.gif +U Toolbox/images/ed_format_sup.gif +U Toolbox/images/ed_format_underline.gif +U Toolbox/images/ed_help.gif +U Toolbox/images/ed_hr.gif +U Toolbox/images/ed_html.gif +U Toolbox/images/ed_image.gif +U Toolbox/images/ed_indent_less.gif +U Toolbox/images/ed_indent_more.gif +U Toolbox/images/ed_link.gif +U Toolbox/images/ed_list_bullet.gif +U Toolbox/images/ed_list_num.gif +U Toolbox/images/ed_paste.gif +U Toolbox/images/ed_redo.gif +U Toolbox/images/ed_show_border.gif +U Toolbox/images/ed_splitcel.gif +U Toolbox/images/ed_undo.gif +U Toolbox/images/expand.png +U Toolbox/images/fullscreen_maximize.gif +U Toolbox/images/fullscreen_minimize.gif +U Toolbox/images/insert_table.gif +U Toolbox/popups/about.html +U Toolbox/popups/blank.html +U Toolbox/popups/custom2.html +U Toolbox/popups/editor_help.html +U Toolbox/popups/fullscreen.html +U Toolbox/popups/insert_image.html +U Toolbox/popups/insert_table.html +U Toolbox/popups/old-fullscreen.html +U Toolbox/popups/old_insert_image.html +U Toolbox/popups/popup.js +U Toolbox/popups/select_color.html +You are now connected as new user "postgres". +CREATE TABLE "bus" ( + "id" SERIAL, + "name" text, + "description" text, + "description2" text, + "description3" text, + "image" text, + "imagename" text, + "image2" text, + "image2name" text, + "image3" text, + "image3name" text, + "urlname" text, + "url" text, + "address" text, + "city" text, + "state" text, + "zip" text, + "phone" text, + "fax" text, + "email" text, + "pos" integer, + "file" text, + "filename" text, + "file2" text, + "file2name" text, + "file3" text, + "file3name" text, + "contactname" text +); +CREATE TABLE +REVOKE ALL on "bus" from PUBLIC; +REVOKE +GRANT ALL on "bus" to "nobody"; +GRANT +GRANT ALL on "bus" to "postgres"; +GRANT +REVOKE ALL on "bus_id_seq" from PUBLIC; +REVOKE +GRANT ALL on "bus_id_seq" to "nobody"; +GRANT +GRANT ALL on "bus_id_seq" to "postgres"; +GRANT +CREATE TABLE "bus_category" ( + "id" SERIAL, + "parent" integer, + "category" text, + "intro" text, + "description" text, + "image" text, + "active" bool, + "pos" integer, + "keyword" text, + "template" int +); +CREATE TABLE +REVOKE ALL on "bus_category" from PUBLIC; +REVOKE +GRANT ALL on "bus_category" to "nobody"; +GRANT +GRANT ALL on "bus_category" to "postgres"; +GRANT +REVOKE ALL on "bus_category_id_seq" from PUBLIC; +REVOKE +GRANT ALL on "bus_category_id_seq" to "nobody"; +GRANT +GRANT ALL on "bus_category_id_seq" to "postgres"; +GRANT +CREATE TABLE "bus_category_bus" ( + "id" SERIAL, + "busid" integer, + "catid" integer, + "pos" integer +); +CREATE TABLE +REVOKE ALL on "bus_category_bus" from PUBLIC; +REVOKE +GRANT ALL on "bus_category_bus" to "nobody"; +GRANT +GRANT ALL on "bus_category_bus" to "postgres"; +GRANT +REVOKE ALL on "bus_category_bus_id_seq" from PUBLIC; +REVOKE +GRANT ALL on "bus_category_bus_id_seq" to "nobody"; +GRANT +GRANT ALL on "bus_category_bus_id_seq" to "postgres"; +GRANT +CREATE UNIQUE INDEX bus_id_indx ON bus (id); +CREATE INDEX +CREATE UNIQUE INDEX bus_category_id_indx ON bus_category (id); +CREATE INDEX +CREATE INDEX bus_category_parent_indx ON bus_category (parent); +CREATE INDEX +CREATE INDEX bus_category_pos_indx ON bus_category (pos); +CREATE INDEX +CREATE INDEX bus_category_keyword_indx ON bus_category (keyword); +CREATE INDEX +CREATE INDEX bus_category_template_indx ON bus_category (template); +CREATE INDEX +CREATE UNIQUE INDEX bus_category_bus_id_indx ON bus_category_bus (id); +CREATE INDEX +CREATE INDEX bus_category_bus_busid_indx ON bus_category_bus (busid); +CREATE INDEX +CREATE INDEX bus_category_bus_catid_indx ON bus_category_bus (catid); +CREATE INDEX + + diff --git a/admin/splash.phtml b/admin/splash.phtml new file mode 100755 index 0000000..242d701 --- /dev/null +++ b/admin/splash.phtml @@ -0,0 +1,28 @@ + + + +"> + + + + +
    + + + + +
    + +Welcome To The Administration Area +

    +Please Choose The Area You Wish To Update. + +

    + +

    +
    + + + diff --git a/admin/template1.gif b/admin/template1.gif new file mode 100755 index 0000000..327d943 Binary files /dev/null and b/admin/template1.gif differ diff --git a/admin/template2.gif b/admin/template2.gif new file mode 100755 index 0000000..edf3d8b Binary files /dev/null and b/admin/template2.gif differ diff --git a/admin/template3.gif b/admin/template3.gif new file mode 100755 index 0000000..16e2107 Binary files /dev/null and b/admin/template3.gif differ diff --git a/admin/template4.gif b/admin/template4.gif new file mode 100755 index 0000000..32174dd Binary files /dev/null and b/admin/template4.gif differ diff --git a/admin/template5.gif b/admin/template5.gif new file mode 100755 index 0000000..6c36b50 Binary files /dev/null and b/admin/template5.gif differ diff --git a/admin/verify.js b/admin/verify.js new file mode 100755 index 0000000..d9a6812 --- /dev/null +++ b/admin/verify.js @@ -0,0 +1,80 @@ +function isblank(s) { + for(var i = 0; i < s.length; i++) { + var c = s.charAt(i); + if((c != ' ') && (c != '\n') && (c != '\t')) + return(false); + } + return(true); +} + +function verify(f) { + var msg; + var empty_fields = ""; + var errors = ""; + + for(var i = 0; i < f.length; i++) { + var e = f.elements[i]; + if(((e.type == "text") || (e.type == "textarea")) && !e.optional) { + if((e.value == null) || (e.value == "") || isblank(e.value)) { + empty_fields += "\n " + e.r; + continue; + } + + if(e.d) { + if(isNaN(Date.parse(e.value))) + errors += "- The field " +e.r+" must be formated like 01/17/2001\n"; + } + if(e.numeric || (e.min != null) || (e.max != null)) { + if(e.i) { + var v = parseInt(e.value); + if(v != e.value) { + errors += "- The field " +e.r + " must be a "; + errors += "number with no decimal\n"; + continue; + } + } + else + var v = parseFloat(e.value); + if(isNaN(v) || + ((e.min != null) && (v < e.min)) || + ((e.max != null) && (v > e.max))) { + + errors += "- The field " + e.r + " must be a number"; + if(e.min != null) + errors += " that is greater than " + e.min; + if(e.max != null && e.min != null) + errors += " and less than " + e.max; + else if (e.max != null) + errors += " that is less than " + e.max; + errors += ".\n"; + } + } + } + if (e.options && !e.optional) + { + if((e.value == null) || (e.value == "") || isblank(e.value)) + { + empty_fields += "\n " + e.r; + continue; + } + } + } + + if(!empty_fields && !errors) + return(true); + + msg = "_____________________________________________________\n\n"; + msg +="The form was not submitted because of the following error(s).\n"; + msg +="Please correct these error(s) and re-submit.\n"; + msg +="_____________________________________________________\n\n"; + + if(empty_fields) { + msg += "- The following required field(s) are empty:" + + empty_fields + "\n"; + if(errors) + msg += "\n"; + } + msg += errors; + alert(msg); + return(false); +} diff --git a/admin/wm.js b/admin/wm.js new file mode 100755 index 0000000..7a7323e --- /dev/null +++ b/admin/wm.js @@ -0,0 +1,13 @@ +function glm_open(o) { + var x = (screen.width/2) - (o.width/2); + var y = (screen.height/2) - (o.height/2); + var args = "width="+o.width+",height="+o.height+",screenX="+x+",screenY="+y+",top="+y+",left="+x; + if(o.scroll == true) + args += ",scrollbars=1"; + //args += "\'"; + //alert(args); + pow=window.open(o.url,o.name,args); + //confirm(args); + if (pow.opener == null) + pow.opener = self; +} diff --git a/assets/Heights.pdf b/assets/Heights.pdf new file mode 100644 index 0000000..9fc0a8c Binary files /dev/null and b/assets/Heights.pdf differ diff --git a/assets/bg.jpg b/assets/bg.jpg new file mode 100755 index 0000000..4c7c88e Binary files /dev/null and b/assets/bg.jpg differ diff --git a/assets/top-image.gif b/assets/top-image.gif new file mode 100755 index 0000000..ea43675 Binary files /dev/null and b/assets/top-image.gif differ diff --git a/assets/top-image2.gif b/assets/top-image2.gif new file mode 100755 index 0000000..1f66b85 Binary files /dev/null and b/assets/top-image2.gif differ diff --git a/assets/top-image3.gif b/assets/top-image3.gif new file mode 100755 index 0000000..a01eb27 Binary files /dev/null and b/assets/top-image3.gif differ diff --git a/bottom.php b/bottom.php new file mode 100755 index 0000000..6e04577 --- /dev/null +++ b/bottom.php @@ -0,0 +1,8 @@ + + + + + diff --git a/classes/class_auth.inc b/classes/class_auth.inc new file mode 100755 index 0000000..a700024 --- /dev/null +++ b/classes/class_auth.inc @@ -0,0 +1,332 @@ +DB =& new GLM_DB(); + $this->auth['perms'] = 1; + $this->page = $GLOBALS['PHP_SELF']; + $this->usertable = "authuser"; + $this->cookie_name = "GLM_AUTH"; + $this->cookie_exp = "2592000"; + $this->cookie_domain = URL_BASE; + $this->fill_data(); + } + + function fill_data() + { + if( $_SESSION['auth'] ) + { + $this->auth_data =& $_SESSION['auth']; + return( $this->auth_data ); + } + else + { + return( false ); + } + } + /** verify + Checks the user login. Checks the users IP address to be sure + it is not hijacked. + @param level - If a level is giving and the user doesn't match the + level then the page is not shown. + @return void + */ + function verify($level=NULL) + { + global $username,$password,$perms,$auth,$LOGOUT,$REMOTE_ADDR; + //$dbd = $this->connect(); + /* Check to see if user is logging out */ + if($LOGOUT) + { + $this->logout(); + } + + /* Check to see if GLM-AUTH cookie is set then check if + $auth is registered in session. + */ + if($_COOKIE[$this->cookie_name]) + { + $auth = unserialize(stripslashes($_COOKIE[$this->cookie_name])); + // double check the username and password only if the time is greater than checktime + $query = "SELECT password + FROM ".$this->usertable." + WHERE id = ".$auth['userid']; + + if(!$res = $this->DB->db_exec($query)) + { + echo "failed ->".$query; + } + $row = pg_fetch_array($res,0); + $pCheck = md5($row['password']); + if($pCheck != $auth['password']) + { + session_start(); + session_destroy(); + $p = session_get_cookie_params(); + setcookie(session_name(), "", 0, $p["path"], $p["domain"]); + setcookie($this->cookie_name,"",0,"/"); + if(!$this->login()) + { + $this->failed(); + } + } + + $this->auth = $auth; + session_register("auth"); + setcookie($this->cookie_name,"",time() - 3600,$this->cookie_domain); + $sessenc = serialize($auth); + setcookie($this->cookie_name,$sessenc,time()+(integer)$this->cookie_exp,$this->cookie_domain); + } + elseif(!session_is_registered("auth")) + { + return( false ); + } + else + { + if($auth['siteid'] != $this->cookie_name) + { + return( false ); + } + } + + + + /* Refresh the perms */ + $oldperms = $this->auth['perms']; + $qs = "SELECT perms + FROM ".$this->usertable." + WHERE id = ".$auth['userid']; + + if(!$res = pg_exec($this->dbd,$qs)) + { + echo "failed ->".$qs; + } + $this->auth['perms'] = pg_result($res,0,'perms'); + if($level) + { + if($this->auth['perms'] & $level) + { + //echo "GOOD"; + } + else + { + $this->failed("You cannot see this page(Not enough Permissions)"); + } + } + return( true ); + } + + /** login + User login funtcion. Now this will check for a cookie + which can be set if the user selects remember my login. + @return boolean - True if login in successful False not. + */ + function login() + { + global $auth,$remember_login,$bus_name; + + if( isset( $_POST['username'] ) && $_POST['username'] != "" ) + { + $qs = "SELECT * + FROM ".$this->usertable." + WHERE username = '".$_POST['username']."' + AND password = '".$_POST['password']."';"; + + if(!$res = $this->DB->db_exec($qs)) + { + echo $qs; + } + if(pg_numrows($res)>0) + { + $row = pg_fetch_array($res,0,PGSQL_ASSOC); + $this->auth['uname'] = $row['fname'].' '.$row['lname']; + $this->auth['perms'] = $row['perms']; + $this->auth['ip'] = $_SERVER['REMOTE_ADDR']; + $this->auth['userid'] = $row['id']; + $this->auth['siteid'] = $this->cookie_name; + $_SESSION['auth'] =& $this->auth; + if( isset( $_POST['remember_login'] ) && $_POST['remember_login'] == "t" ) + { + $sessenc = serialize($auth); + setcookie($this->cookie_name,$sessenc,time()+(integer)$this->cookie_exp,$this->cookie_domain); + } + return(true); + } + else + { + session_register("auth"); + $auth['failed'] = true; + return(false); + } + } + else + { + session_register("auth"); + $auth['failed'] = true; + return(false); + } + } + + function is_admin() + { + if( $_SESSION['auth']['admin'] == 't' ) + { + return( true ); + } + else + { + return( false ); + } + } + /** login_screen + Outputs the login screen + @return void + */ + + function login_screen() + { + $out = '
    + + + + '; + if( $this->remember == true ) + { + $out .= ' + + '; + } + $out .= ' + + + + + + + + + + + + + + +
    Forgot your password Click here.
    Remember My Login!
     
    Username:auth["uname"]; + } + $out .= '" size=32 maxlength=32>
    Password:
     
    +

    '; + if ( isset( $_GET['username']) ) + { + $out .= ' +

    + + + + +
    Either your username or your password + are invalid.
    + Please try again!
    '; + } + $out .= ' +

    + '; + return( $out ); + } + + /** logout + Ends the current session and distroys any cookies that were + created + @return void + */ + function logout() + { + session_start(); + session_destroy(); + $p = session_get_cookie_params(); + setcookie(session_name(), "", 0, $p["path"], $p["domain"]); + setcookie($this->cookie_name,"",0,"/"); + header("Location: index.phtml"); + exit(); + } + + /** failed + Stop the script from going any further. + @param reply - string to show user if any. + @return void + */ + function failed($reply=NULL) + { + if(isset($reply)) + { + die(''.$reply.''); + } + else + { + exit; + } + } +} + +?> diff --git a/classes/class_contact_form.inc b/classes/class_contact_form.inc new file mode 100755 index 0000000..57c113f --- /dev/null +++ b/classes/class_contact_form.inc @@ -0,0 +1,437 @@ +CDB =& new GLM_DB(); // creates DB object + $this->set_DB_fields(); // set up the DB_fields array (configuration) + $this->set_int_array(); // interest array + $this->email = OWNER_EMAIL; // email address for mail function + $this->table_name = 'contact'; // the contact table + $this->styleLabel = "labelcell";// css style for the labelcell + $this->fieldcell = "fieldcell"; // css style for the field input + $this->styleLabelSmall = "smalllabelcell";// css style for the labelcell + $this->fieldcellSmall = "smallfieldcell"; // css style for the field input + $this->contact_db = 1; // if they have contact database or not + } + + + /** + * get_form: one function to rule them all + * + * @return void + * @access + **/ + function get_form() + { + if( $_POST ) + { + if( $error = $this->form_process() ) + { + echo 'Some fields are empty!
    '; + echo $this->display_form( $error ); + } + } + else + { + echo $this->display_form(); + } + } + + + /** + * set_DB_fields: + * + * @return + * @access + **/ + function set_DB_fields() + { + $DB_fields[]=array('name'=>'fname', 'title'=>'First Name', 'type' => 'text', 'size'=>35, 'colspan'=>2,'req'=>1); + $DB_fields[]=array('name'=>'lname', 'title'=>'Last Name', 'type' => 'text', 'size'=>35, 'colspan'=>2,'req'=>1); + $DB_fields[]=array('name'=>'add1', 'title'=>'Address 1', 'type' => 'text', 'size'=>35, 'colspan'=>2); + $DB_fields[]=array('name'=>'add2', 'title'=>'Address 2', 'type' => 'text', 'size'=>35, 'colspan'=>2); + $DB_fields[]=array('name'=>'city', 'title'=>'City', 'type' => 'text', 'size'=>30, 'colspan'=>2); + $DB_fields[]=array('name'=>'state', 'title'=> 'State', 'type' => 'state', 'size'=>2, 'colspan'=>1); + $DB_fields[]=array('name'=>'zip', 'title' => 'Zip', 'type' => 'text', 'size'=>5, 'colspan'=>1); + $DB_fields[]=array('name'=>'email', 'title' => 'Email', 'type' => 'text', 'size'=>35, 'colspan'=>2,'req'=>1); + $DB_fields[]=array('name'=>'phone', 'title' => 'Phone', 'type' => 'text', 'size'=>20, 'colspan'=>2); + $DB_fields[]=array('name'=>'fax', 'title' => 'Fax', 'type' => 'text', 'size'=>20, 'colspan'=>2); + $DB_fields[]=array('name'=>'comments','title' =>'Comments', 'type' => 'desc'); + $DB_fields[]=array('name'=>'mail_ok','title' => 'Mail Ok?', 'type' => 'radio'); + //$DB_fields[] = array( 'name'=>'interest','title' => 'Interest','type' => 'interest'); + //$DB_fields[]=array('name'=>'hidden_field','type'=>'hide','val'=>'1'); + $this->DB_fields = &$DB_fields; + } + + /** + * set_int_array: + * + * @return + * @access + **/ + + function set_int_array() + { + $int_array = array( + "capital_campaign" => "Capital Campaign Information", + "membership" => "Membership Information", + "class_registration" => "Class Registration", + "ticket_sales" => "Ticket Sales", + "no_preference" => "No Preference", + ); + $this->int_array = $int_array; + } + + + /** + * interest: + * @param $field: + * + * @return + * @access + **/ + function interest($field) + { + $out .= ''; + $count = 0; + foreach($this->int_array as $key=>$value) + { + if($count==0) + { + $out .= ''; + } + $count++; + } + $out .= "
    '; + } + $out .= ''; + if($count==5) + { + $out .= ''; + } + if($count==11) + { + $out .= '
    "; + return( $out ); + } + + + /** + * display_form: shows the form and any errors in it + * @param $error = NULL: error array + * + * @return string $out + * @access public + **/ + function display_form($error=NULL) + { + if(is_array($_POST)) + { + foreach($_POST as $k=>$v) + { + $_POST[$k] = trim(stripslashes($v)); + } + } + $colcount = 1; + $out = "
    "; + $out .= ""; + foreach($this->DB_fields as $key=>$value) + { + switch( $value['type'] ) + { + case "state": + if( $value['colspan'] == 2 || $colcount == 1 ) + { + $out .= ''; + } + if( $value['colspan'] == 1 ) + { + $label = $this->styleLabelSmall; + $field = $this->fieldcellSmall; + } + else + { + $label = $this->styleLabel; + $field = $this->fieldcell; + } + $out .= ' + '; + if( $value['colspan'] == 2 || $colcount == 2 ) + { + $out .= ''; + } + if( $colcount == 2 && $value['colspan'] == 1 ) + { + $colcount = 1; + } + + if( $value['colspan'] == 1 ) + { + $colcount++; + } + break; + case "text": + if( $value['colspan'] == 2 || $colcount == 1 ) + { + $out .= ''; + } + if( $value['colspan'] == 1 ) + { + $label = $this->styleLabelSmall; + $field = $this->fieldcellSmall; + } + else + { + $label = $this->styleLabel; + $field = $this->fieldcell; + } + $out .= ' + '; + if( $value['colspan'] == 2 || $colcount == 2 ) + { + $out .= ''; + } + + if( $colcount == 2 && $value['colspan'] == 1 ) + { + $colcount = 1; + } + if( $value['colspan'] == 1 ) + { + $colcount++; + } + break; + + case "static": + $out .= ' + + '; + break; + + case "interest": + $out .= ' + + '; + break; + + case "img": + $out .= ''; + $out .= ''; + if($_POST[$value['name']] != "") + { + $out .= ''; + $out .= ' + + + + + '; + } + $out .= ''; + $out .= ''; + $out .= ''; + break; + + case "file": + $out .= ''; + $out .= ''; + if($_POST[$value['name']] != "") + { + $out .= ''; + $out .= ' + + + + + '; + } + $out .= ''; + $out .= ''; + $out .= ''; + break; + + case "desc": + $rows=''; + $cols=''; + if($value['rows']) + { + $rows=' rows="'.$value['rows'].'"'; + } + if($value['cols']) + { + $cols=' cols="'.$value['cols'].'"'; + } + + $out .= ''; + break; + + case "hide": + $out .= ''; + break; + + case "radio": + $out .= ''; + $out .= '$Text"; + } + + function TDC($Text) + { + return TD(Center($Text)); + } + + function TD($Text) + { + return ""; + } + + function TDWC($Text, $Width) + { + return TDW(Center($Text), $Width); + } + + function TDW($Text, $Width) + { + return ""; + } + + //Returns the string "selected" if $Type1 and $Type2 are the same (Not case sensitive). + function Selected($Type1, $Type2) + { + $Result = ""; + if (strtoupper($Type1) == strtoupper($Type2)) + { + $Result = "selected"; + } + return $Result; + } + + function PopUp($Page,$Name,$W,$H,$Caption) + { + $Result = "$Caption"; + return $Result; + } + + //GetParam checks against POST, GET and then Cookies. If they don't exist + // then $Default is used. + function GetParam($Param, $Default) + { + $Result = ""; + + //Get the parameter if has been past in via POST + if(isset($_POST[$Param])) + { + $Result = rawurldecode($_POST[$Param]); + } + else + { + //Get the parameter if has been past in via GET + if(isset($_GET[$Param])) + { + $Result = rawurldecode($_GET[$Param]); + } + else + { + //Get the paramenter if a cookie exists for it. + if (isset($_COOKIE[strtoupper($Param)])) + { + $Result = rawurldecode($_COOKIE[strtoupper($Param)]); + } + else + { + //The parameter hasn't been set. + $Result = $Default; + } + } + } + return $Result; + } +?> \ No newline at end of file diff --git a/google/index.php b/google/index.php new file mode 100755 index 0000000..ff796e5 --- /dev/null +++ b/google/index.php @@ -0,0 +1,8 @@ + diff --git a/google/nusoap.php b/google/nusoap.php new file mode 100755 index 0000000..1bbf04b --- /dev/null +++ b/google/nusoap.php @@ -0,0 +1,3275 @@ + prefix +* +* @var namespaces +* @access public +*/ +$namespaces = array( + 'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/', + 'xsd' => $XMLSchemaVersion, + 'xsi' => $XMLSchemaVersion.'-instance', + 'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/', + 'si' => 'http://soapinterop.org/xsd'); + +/** +* +* nusoap_base +* +* @author Dietrich Ayala +* @version v 0.6 +* @access public +*/ + +class nusoap_base { + + var $title = 'NuSOAP'; + var $version = '0.6'; + var $error_str = false; + // toggles automatic encoding of special characters + var $charencoding = true; + + /** + * set default encoding + * + * @var soap_defencoding + * @access public + */ + var $soap_defencoding = 'UTF-8'; + + /** + * load namespace uris into an array of uri => prefix + * + * @var namespaces + * @access public + */ + var $namespaces = array( + 'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/', + 'xsd' => 'http://www.w3.org/2001/XMLSchema', + 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/', + 'si' => 'http://soapinterop.org/xsd'); + /** + * load types into typemap array + * is this legacy yet? + * @var typemap + * @access public + */ + var $typemap = array( + 'http://www.w3.org/2001/XMLSchema' => array( + 'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double', + 'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'', + 'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string', + // derived datatypes + 'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'', + 'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer', + 'negativeInteger'=>'integer','long'=>'','int'=>'integer','short'=>'','byte'=>'','nonNegativeInteger'=>'integer', + 'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''), + 'http://www.w3.org/1999/XMLSchema' => array( + 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', + 'float'=>'double','dateTime'=>'string', + 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), + 'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'), + 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array') + ); + + /** + * entities to convert + * + * @var xmlEntities + * @access public + */ + var $xmlEntities = array('quot' => '"','amp' => '&', + 'lt' => '<','gt' => '>','apos' => "'"); + + /** + * constructor: loads schema version + */ + function nusoap_base(){ + global $XMLSchemaVersion; + $this->XMLSchemaVersion = $XMLSchemaVersion; + } + + /** + * adds debug data to the class level debug string + * + * @param string $string debug data + * @access private + */ + function debug($string){ + $this->debug_str .= get_class($this).": $string\n"; + } + + /** + * returns error string if present + * + * @return boolean $string error string + * @access public + */ + function getError(){ + if($this->error_str != ""){ + return $this->error_str; + } + return false; + } + + /** + * sets error string + * + * @return boolean $string error string + * @access private + */ + function setError($str){ + $this->error_str = $str; + } + + /** + * serializes PHP values in accordance w/ section 5 + * @return string + * @access public + */ + function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false){ + //print "in serialize_val: $val, $name, $type, $name_ns, $type_ns
    "; + // if no name, use item + $name = (!$name|| is_numeric($name)) ? 'noname' : $name; + // if name has ns, add ns prefix to name + if($name_ns){ + $prefix = 'nu'.rand(1000,9999); + $name = $prefix.':'.$name; + $xmlns .= " xmlns:$prefix=\"$name_ns\""; + } + // if type is prefixed, create type prefix + if($type_ns == $this->namespaces['xsd'] || $type_ns == ''){ + // need to fix this. shouldn't default to if no ns specified + // w/o checking against typemap + $type_prefix = 'xsd'; + } elseif($type_ns){ + $type_prefix = 'ns'.rand(1000,9999); + $xmlns .= " xmlns:$type_prefix=\"$type_ns\""; + } + // serialize attributes if present + if($attributes){ + foreach($attributes as $k => $v){ + $atts .= " $k=\"$v\""; + } + } + // detect type and serialize + switch(true) { + case is_null($val): + $xml .= "<$name$xmlns xsi:type=\"xsd:nil\"/>\n"; + break; + case (is_bool($val) || $type == 'boolean'): + if(!$val){ + $val = 0; + } + $xml .= "<$name$xmlns xsi:type=\"".$type_prefix.":boolean\"$atts>$val\n"; + break; + case (is_int($val) || is_long($val) || $type == 'int'): + $xml .= "<$name$xmlns xsi:type=\"".$type_prefix.":int\"$atts>$val\n"; + break; + case (is_float($val)|| is_double($val) || $type == 'float'): + $xml .= "<$name$xmlns xsi:type=\"".$type_prefix.":float\"$atts>$val\n"; + break; + case (is_string($val) || $type == 'string'): + if($this->charencoding){ + $val = htmlspecialchars($val); + } + $xml .= "<$name$xmlns xsi:type=\"".$type_prefix.":string\"$atts>$val\n"; + break; + case is_object($val): + break; + break; + case (is_array($val) || $type): + // detect if struct or array + if(ereg("^[0-9]+$",key($val)) || ereg('^ArrayOf',$type)){ + foreach($val as $v){ + $tt = gettype($v); + $array_types[$tt] = 1; + $xml .= $this->serialize_val($v,'item'); + if(is_array($v) && is_numeric(key($v))){ + $i += sizeof($v); + } else { + $i += 1; + unset($array_types['array']); + } + } + if(count($array_types) > 1){ + $array_typename = "xsd:ur-type"; + } else { + $array_typename = "xsd:".$tt; + } + if($array_types['array']){ + $array_type = $i.",".$i; + } else { + $array_type = $i; + } + $xml = "<$name xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\"$atts>\n".$xml."\n"; + } else { + // got a struct + if($type && $type_prefix){ + $type_str = " xsi:type=\"$type_prefix:$type\""; + } + $xml .= "<$name$xmlns$type_str$atts>\n"; + foreach($val as $k => $v){ + $xml .= $this->serialize_val($v,$k); + } + $xml .= "\n"; + } + break; + default: + $xml .= "not detected, got ".gettype($val)." for $val\n"; + break; + } + return $xml; + } + + /** + * serialize message + * + * @param string body + * @param string headers + * @param array namespaces + * @return string message + * @access public + */ + function serializeEnvelope($body,$headers=false,$namespaces=array()){ + // serialize namespaces + foreach(array_merge($this->namespaces,$namespaces) as $k => $v){ + $ns_string .= "\n xmlns:$k=\"$v\""; + } + // serialize headers + if($headers){ + $headers = "\n".$headers."\n"; + } + // serialize envelope + return + "\n". + "\n". + $headers. + "\n". + $body. + "\n". + "\n"; + } + + function formatDump($str){ + $str = htmlspecialchars($str); + return nl2br($str); + } +} + +// XML Schema Datatype Helper Functions + +//xsd:dateTime helpers + +/** +* convert unix timestamp to ISO 8601 compliant date string +* +* @param string $timestamp Unix time stamp +* @access public +*/ +function timestamp_to_iso8601($timestamp,$utc=true){ + $datestr = date("Y-m-d\TH:i:sO",$timestamp); + if($utc){ + $eregStr = + "([0-9]{4})-". // centuries & years CCYY- + "([0-9]{2})-". // months MM- + "([0-9]{2})". // days DD + "T". // separator T + "([0-9]{2}):". // hours hh: + "([0-9]{2}):". // minutes mm: + "([0-9]{2})(\.[0-9]*)?". // seconds ss.ss... + "(Z|[+\-][0-9]{2}:?[0-9]{2})?"; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's + + if(ereg($eregStr,$datestr,$regs)){ + return sprintf("%04d-%02d-%02dT%02d:%02d:%02dZ",$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]); + } + return false; + } else { + return $datestr; + } +} + +/** +* convert ISO 8601 compliant date string to unix timestamp +* +* @param string $datestr ISO 8601 compliant date string +* @access public +*/ +function iso8601_to_timestamp($datestr){ + $eregStr = + "([0-9]{4})-". // centuries & years CCYY- + "([0-9]{2})-". // months MM- + "([0-9]{2})". // days DD + "T". // separator T + "([0-9]{2}):". // hours hh: + "([0-9]{2}):". // minutes mm: + "([0-9]{2})(\.[0-9]+)?". // seconds ss.ss... + "(Z|[+\-][0-9]{2}:?[0-9]{2})?"; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's + if(ereg($eregStr,$datestr,$regs)){ + // not utc + if($regs[8] != "Z"){ + $op = substr($regs[8],0,1); + $h = substr($regs[8],1,2); + $m = substr($regs[8],strlen($regs[8])-2,2); + if($op == "-"){ + $regs[4] = $regs[4] + $h; + $regs[5] = $regs[5] + $m; + } elseif($op == "+"){ + $regs[4] = $regs[4] - $h; + $regs[5] = $regs[5] - $m; + } + } + return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z"); + } else { + return false; + } +} + + +?> +faultcode = $faultcode; + $this->faultactor = $faultactor; + $this->faultstring = $faultstring; + $this->faultdetail = $faultdetail; + } + + /** + * serialize a fault + * + * @access public + */ + function serialize(){ + foreach($this->namespaces as $k => $v){ + $ns_string .= "\n xmlns:$k=\"$v\""; + } + $return_msg = + "\n". + "\n". + "\n". + "\n". + "$this->faultcode\n". + "$this->faultactor\n". + "$this->faultstring\n". + "$this->faultdetail\n". + "\n". + "\n". + "\n"; + return $return_msg; + } +} + +?> +* @access public +*/ +class XMLSchema extends nusoap_base { + + /** + * constructor + * + * @param string $schema schema document URI + * @param string $xml xml document URI + * @access public + */ + function XMLSchema($schema="",$xml=""){ + + $this->debug('xmlschema class instantiated, inside constructor'); + // files + $this->schema = $schema; + $this->xml = $xml; + + // define internal arrays of bindings, ports, operations, messages, etc. + $this->complexTypes = array(); + + // parser vars + $this->parser; + $this->position; + $this->depth; + $this->depth_array = array(); + + // parse schema file + if($schema != ""){ + $this->debug("initial schema file: $schema"); + $this->parseFile($schema); + } + + // parse xml file + if($xml != ""){ + $this->debug("initial xml file: $xml"); + $this->parseFile($xml); + } + + } + + /** + * parse an XML file + * + * @param string $xml, path/URL to XML file + * @param string $type, (schema | xml) + * @return boolean + * @access public + */ + function parseFile($xml,$type){ + // parse xml file + if($xml != ""){ + $this->debug("parsing $xml"); + $xmlStr = @join("",@file($xml)); + if($xmlStr == ""){ + $this->setError("No file at the specified URL: $xml."); + return false; + } else { + $this->parseString($xmlStr,$type); + return true; + } + } + return false; + } + + /** + * parse an XML string + * + * @param string $xml path or URL + * @param string $type, (schema|xml) + * @access private + */ + function parseString($xml,$type){ + // parse xml string + if($xml != ""){ + + // Create an XML parser. + $this->parser = xml_parser_create(); + // Set the options for parsing the XML data. + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); + + // Set the object for the parser. + xml_set_object($this->parser, $this); + + // Set the element handlers for the parser. + if($type == "schema"){ + xml_set_element_handler($this->parser, "schemaStartElement","schemaEndElement"); + xml_set_character_data_handler($this->parser,"schemaCharacterData"); + } elseif($type == "xml"){ + xml_set_element_handler($this->parser, "xmlStartElement","xmlEndElement"); + xml_set_character_data_handler($this->parser,"xmlCharacterData"); + } + + // Parse the XML file. + if(!xml_parse($this->parser,$xml,true)){ + // Display an error message. + $errstr = sprintf("XML error on line %d: %s", + xml_get_current_line_number($this->parser), + xml_error_string(xml_get_error_code($this->parser)) + ); + $this->debug("XML parse error: $errstr"); + $this->setError("Parser error: $errstr"); + } + xml_parser_free($this->parser); + } else{ + $this->debug("no xml passed to parseString()!!"); + $this->setError("no xml passed to parseString()!!"); + } + } + + /** + * start-element handler + * + * @param string $parser XML parser object + * @param string $name element name + * @param string $attrs associative array of attributes + * @access private + */ + function schemaStartElement($parser, $name, $attrs) { + + // position in the total number of elements, starting from 0 + $pos = $this->position++; + $depth = $this->depth++; + // set self as current value for this depth + $this->depth_array[$depth] = $pos; + + // loop through atts, logging ns declarations + foreach($attrs as $key => $value){ + // if ns declarations, add to class level array of valid namespaces + if(ereg("^xmlns",$key)){ + if($ns_prefix = substr(strrchr($key,":"),1)){ + $this->namespaces[$ns_prefix] = $value; + } else { + $this->namespaces['ns'.(count($this->namespaces)+1)] = $value; + } + if($value == 'http://www.w3.org/2001/XMLSchema'){ + $this->XMLSchemaVersion = $value; + $this->namespaces['xsi'] = $value.'-instance'; + } elseif($value == 'http://www.w3.org/1999/XMLSchema'){ + $this->XMLSchemaVersion = $value; + $this->namespaces['xsi'] = $value.'-instance'; + } + } + } + + // get element prefix + if(ereg(":",$name)){ + // get ns prefix + $prefix = substr($name,0,strpos($name,":")); + // get unqualified name + $name = substr(strstr($name,":"),1); + } + //$this->debug("name: $name, prefix: $prefix"); + + // find status, register data + switch($name){ + case "all": + $this->complexTypes[$this->currentComplexType]["compositor"] = "all"; + $this->complexTypes[$this->currentComplexType]["phpType"] = "struct"; + break; + case "attribute": + if($attrs["name"]){ + $this->attributes[$attrs["name"]] = $attrs; + $aname = $attrs["name"]; + } elseif($attrs["ref"]){ + $aname = $this->expandQName($attrs["ref"]); + } + + if($this->currentComplexType){ + $this->complexTypes[$this->currentComplexType]["attrs"][$aname] = $attrs; + } elseif($this->currentElement){ + $this->elements[$this->currentElement]['attrs'][$aname] = $attrs; + } + + if($aname == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){ + foreach($attrs as $k => $v){ + if(strstr($k,':') == ':arrayType'){ + if(strpos($v,'[,]')){ + $this->complexTypes[$this->currentComplexType]["multidimensional"] = true; + } + $v = substr($v,0,strpos($v,'[')); // clip the [] + if(strpos($v,':')){ + $v = $this->expandQName($v); + } else { + $v = $this->XMLSchemaVersion.':'.$v; + } + $this->complexTypes[$this->currentComplexType]["arrayType"] = $v; + break; + } + } + } + break; + case "complexContent": + + break; + case 'complexType': + if($attrs['name']){ + $this->currentElement = false; + $this->currentComplexType = $attrs['name']; + $this->complexTypes[$this->currentComplexType] = $attrs; + $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; + if(ereg(':Array$',$attrs['base'])){ + $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; + } else { + $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; + } + $this->xdebug("processing complexType $attrs[name]"); + } + break; + case 'element': + if(isset($attrs['type'])){ + $this->xdebug("processing element ".$attrs['name']); + $this->currentElement = $attrs['name']; + $this->elements[ $attrs['name'] ] = $attrs; + $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; + $ename = $attrs['name']; + } elseif(isset($attrs['ref'])){ + $ename = $attrs['ref']; + } else { + $this->xdebug("adding complexType $attrs[name]"); + $this->currentComplexType = $attrs['name']; + $this->complexTypes[ $attrs['name'] ] = $attrs; + $this->complexTypes[ $attrs['name'] ]['element'] = 1; + $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; + } + if($ename && $this->currentComplexType){ + $this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs; + } + break; + case 'restriction': + $this->xdebug("in restriction for ct: $this->currentComplexType and ce: $this->currentElement"); + if($this->currentElement){ + $this->elements[$this->currentElement]['type'] = $attrs['base']; + } elseif($this->currentComplexType){ + $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base']; + if(strstr($attrs['base'],':') == ':Array'){ + $this->complexTypes[$this->currentComplexType]['phpType'] = "array"; + } + } + break; + case 'schema': + $this->schema = $attrs; + $this->schema['schemaVersion'] = $this->getNamespaceFromPrefix($prefix); + break; + case 'sequence': + $this->complexTypes[$this->currentComplexType]['compositor'] = 'sequence'; + break; + case 'simpleType': + $this->currentElement = $attrs['name']; + $this->elements[ $attrs['name'] ] = $attrs; + $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; + break; + } + } + + /** + * end-element handler + * + * @param string $parser XML parser object + * @param string $name element name + * @access private + */ + function schemaEndElement($parser, $name) { + // position of current element is equal to the last value left in depth_array for my depth + $pos = $this->depth_array[$this->depth]; + // bring depth down a notch + $this->depth--; + // move on... + if($name == 'complexType'){ + $this->currentComplexType = false; + $this->currentElement = false; + } + if($name == 'element'){ + $this->currentElement = false; + } + } + + /** + * element content handler + * + * @param string $parser XML parser object + * @param string $data element content + * @access private + */ + function schemaCharacterData($parser, $data){ + $pos = $this->depth_array[$this->depth]; + $this->message[$pos]["cdata"] .= $data; + } + + /** + * serialize the schema + * + * @access public + */ + function serializeSchema(){ + + $schemaPrefix = $this->getPrefixFromNamespace($this->schema['schemaVersion']); + // complex types + foreach($this->complexTypes as $typeName => $attrs){ + $contentStr = ""; + // serialize child elements + if(count($attrs["elements"]) > 0){ + foreach($attrs["elements"] as $element => $eParts){ + $contentStr .= "\n"; + } + } + // serialize attributes + if(count($attrs["attrs"]) > 0){ + foreach($attrs["attrs"] as $attr => $aParts){ + $contentStr .= "\n"; + } + } + + // if restriction + if($attrs["restrictionBase"]){ + $contentStr = "<$schemaPrefix:restriction base=\"".$attrs["restrictionBase"]."\">\n". + $contentStr."\n"; + } + if($attrs["complexContent"]){ + $contentStr = "<$schemaPrefix:complexContent>\n". + $contentStr."\n"; + } elseif($attrs["sequence"]){ + $contentStr = "<$schemaPrefix:sequence>\n". + $contentStr."\n"; + } elseif($attrs["all"]){ + $contentStr = "<$schemaPrefix:all>\n". + $contentStr."\n"; + } + if($attrs['element']){ + if($contentStr != ""){ + $contentStr = "<$schemaPrefix:element name=\"$typeName\">\n"."<$schemaPrefix:complexType>\n". + $contentStr."\n"."\n"; + } else { + $contentStr = "<$schemaPrefix:element name=\"$typeName\">\n"."<$schemaPrefix:complexType/>\n". + "\n"; + } + } else { + if($contentStr != ""){ + $contentStr = "<$schemaPrefix:complexType name=\"$typeName\">\n". + $contentStr."\n"; + } else { + $contentStr = "<$schemaPrefix:complexType name=\"$typeName\"/>\n"; + } + } + $xml .= $contentStr; + } + // elements + if(count($this->elements) > 0){ + foreach($this->elements as $element => $eParts){ + $xml .= "<$schemaPrefix:element name=\"$element\" type=\"".$eParts['type']."\"/>\n"; + } + } + // attributes + if(count($this->attributes) > 0){ + foreach($this->attributes as $attr => $aParts){ + $xml .= "<$schemaPrefix:attribute name=\"$attr\" type=\"".$aParts['type']."\"/>\n"; + } + } + $xml = "<$schemaPrefix:schema targetNamespace=\"".$this->schema["targetNamespace"]."\">\n". + $xml."\n"; + + return $xml; + } + + /** + * expands a qualified name + * + * @param string $string qname + * @return string expanded qname + * @access private + */ + function expandQname($qname){ + // get element prefix + if(ereg(":",$qname)){ + // get unqualified name + $name = substr(strstr($qname,":"),1); + // get ns prefix + $prefix = substr($qname,0,strpos($qname,":")); + if(isset($this->namespaces[$prefix])){ + return $this->namespaces[$prefix].":".$name; + } else { + return false; + } + } else { + return $qname; + } + } + + /** + * adds debug data to the clas level debug string + * + * @param string $string debug data + * @access private + */ + function xdebug($string){ + $this->debug(" xmlschema: $string"); + } + + /** + * get the PHP type of a user defined type in the schema + * PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays + * returns false if no type exists, or not w/ the given namespace + * else returns a string that is either a native php type, or 'struct' + * + * @param string $type, name of defined type + * @param string $ns, namespace of type + * @return mixed + * @access public + */ + function getPHPType($type,$ns){ + global $typemap; + if(isset($typemap[$ns][$type])){ + //print "found type '$type' and ns $ns in typemap
    "; + return $typemap[$ns][$type]; + } elseif(isset($this->complexTypes[$type])){ + //print "getting type '$type' and ns $ns from complexTypes array
    "; + return $this->complexTypes[$type]["phpType"]; + } + return false; + } + + /** + * returns the local part of a prefixed string + * returns the original string, if not prefixed + * + * @param string + * @return string + * @access public + */ + function getLocalPart($str){ + if($sstr = strrchr($str,':')){ + // get unqualified name + return substr( $sstr, 1 ); + } else { + return $str; + } + } + + /** + * returns the prefix part of a prefixed string + * returns false, if not prefixed + * + * @param string + * @return mixed + * @access public + */ + function getPrefix($str){ + if($pos = strrpos($str,':')){ + // get prefix + return substr($str,0,$pos); + } + return false; + } + + /** + * pass it a prefix, it returns a namespace + * or false if no prefixes registered for the given namespace + * + * @param string + * @return mixed + * @access public + */ + function getNamespaceFromPrefix($prefix){ + if(isset($this->namespaces[$prefix])){ + return $this->namespaces[$prefix]; + } + //$this->setError("No namespace registered for prefix '$prefix'"); + return false; + } + + /** + * returns the prefix for a given namespace + * returns false if no namespace registered with the given prefix + * + * @param string + * @return mixed + * @access public + */ + function getPrefixFromNamespace($ns){ + foreach($this->namespaces as $p => $n){ + if($ns == $n){ + $this->usedNamespaces[$p] = $ns; + return $p; + } + } + return false; + } + + /** + * returns an array of information about a given type + * returns false if no type exists by the given name + * + * typeDef = array( + * 'elements' => array(), // refs to elements array + * 'restrictionBase' => '', + * 'phpType' => '', + * 'order' => '(sequence|all)', + * 'attrs' => array() // refs to attributes array + * ) + * + * @param string + * @return mixed + * @access public + */ + function getTypeDef($type){ + if(isset($this->complexTypes[$type])){ + return $this->complexTypes[$type]; + } elseif(isset($this->elements[$type])){ + return $this->elements[$type]; + } elseif(isset($this->attributes[$type])){ + return $this->attributes[$type]; + } + return false; + } + + /** + * returns a sample serialization of a given type, or false if no type by the given name + * + * @param string $type, name of type + * @return mixed + * @access public + */ + function serializeTypeDef($type){ + //print "in sTD() for type $type
    "; + if($typeDef = $this->getTypeDef($type)){ + $str .= "<$type"; + if(is_array($typeDef['attrs'])){ + foreach($attrs as $attName => $data){ + $str .= " $attName=\"{type = ".$data['type']."}\""; + } + } + $str .= " xmlns=\"".$this->schema['targetNamespace']."\""; + if(count($typeDef['elements']) > 0){ + $str .= ">\n"; + foreach($typeDef['elements'] as $element => $eData){ + $str .= $this->serializeTypeDef($element); + } + $str .= "\n"; + } elseif($typeDef['typeClass'] == 'element') { + $str .= ">\n"; + } else { + $str .= "/>\n"; + } + return $str; + } + return false; + } + + /** + * returns HTML form elements that allow a user + * to enter values for creating an instance of the given type. + * + * @param string $name, name for type instance + * @param string $type, name of type + * @return string + * @access public + */ + function typeToForm($name,$type){ + // get typedef + if($typeDef = $this->getTypeDef($type)){ + // if struct + if($typeDef['phpType'] == 'struct'){ + $buffer .= '
    '; + $out .= GLM_TEMPLATE::build_picklist($value['name'],$GLOBALS['states_US'],$_POST['state']); + $out .= ( $error[$value['name']] ) ? 'Required!' : ''; + $out .= '
    + '; + $out .= ( $error[$value['name']] ) ? 'Required!' : ''; + $out .= '
    '.$value["title"].''.$_POST[$value["name"]].'
    '.$value["title"].''.$this->interest($_POST[$value["name"]]).'
    Current Image: +
    Delete this image: + Yes + No +
    New '.$value["title"].':
    Current File:'.$_POST[$value["name"]].' +
    Delete this File: + Yes + No +
    New '.$value["title"].':
    '.$value[title].': + '; + $out .= '
    '.$value[title].':$v) + { + $_POST[$k] = trim(stripslashes($v)); + } + } + $in_fields[] = create_date; + $in_vars[] = date("m-d-Y"); + foreach($this->DB_fields as $key=>$value) + { + if($value["req"] == 1 && $_POST[$value["name"]] == "") + { + $error[$value["name"]] = 1; + } + if($value['name']!="comments") + { + $in_fields[] = $value['name']; + $in_vars[] = addslashes(trim($_POST[$value['name']])); + } + } + if(count($error) > 0) + { + return($error); + } + if(is_array($in_fields)) + { + $infds = implode(",",$in_fields); + } + if(is_array($in_vars)) + { + $invars = implode("','",$in_vars); + } + $query = "INSERT INTO ".$this->table_name." + ($infds) + VALUES + ('$invars')"; + if($this->contact_db) + $this->CDB->db_auto_exec($query); + // adding comments again + $in_fields[] = "comments"; + $in_vars[] = $_POST['comments']; + if($this->email!="") + { + //mail the contact info to mail address. + $body = ''; + foreach($this->DB_fields as $key=>$value) + { + if($value['name']=="mail_ok") + { + $body .= $value['title'].": "; + $body .= ($_POST[$value['name']]=="t")?"Yes":"No"; + $body .= "\n"; + } + elseif($_POST[$value['name']] != '') + { + $body .= $value['title'].": ".$_POST[$value[name]]."\n"; + } + } + $subject = "new contact at ".SITENAME; + $headers = "From: <".SITENAME.">".OWNER_EMAIL."\n" + . "Reply-To: <".SITENAME.">".REPLY_TO."\n"; + + mail($this->email,$subject,$body,$headers); + echo '
    Thank You
    '; + } + } +} +?> diff --git a/classes/class_db.inc b/classes/class_db.inc new file mode 100755 index 0000000..c0ff126 --- /dev/null +++ b/classes/class_db.inc @@ -0,0 +1,342 @@ +host = ""; + $this->dbname = ""; + $this->user = "nobody"; + $this->password = ""; + $this->conn = $conn; + $this->trans = 0; + $this->dbd = ""; + } + + /** db_connect + Creates a connection to database specified $conn_str, + and returns a boolean for success. + @param conn_str Connect String + @param fail_mode Failure Mode + TRUE = Abort with HTML + FALSE = Return with fail code + @returns int - Returns an index or fails using html_error() function + */ + + function db_connect() + { + if( isset( $this->dbd ) && $this->dbd != "" ) + { + return( $this->dbd ); + } + switch ( DB_TYPE ) + { + case "postgres": + if( $this->host == "" && $this->dbname == "" ) + { + $conn = $this->conn;// CONN_STR; + } + else + { + $conn .= ( $this->host ) ? 'host='.$this->host.' ' : ''; + $conn .= ( $this->dbname ) ? 'dbname='.$this->dbname.' ' : ''; + $conn .= ( $this->user ) ? 'user='.$this->user." " : ''; + $conn .= ( $this->password ) ? "password=".$this->password : ''; + } + if( !$this->dbd = pg_connect( $conn ) ) + { + echo pg_errormessage( $conn ); + } + break; + + default: + return( 0 ); + break; + } + return( $this->dbd ); + } + /** db_close + Closes the connection to database specified by the handle dbd + returns a boolean for success + @returns bool - Returns 1 on success 0 if dbd is not a valid connection + */ + + function db_close() + { + switch (DB_TYPE) + { + case "postgres": + @pg_close($this->dbd); + break; + default: + return(0); + } + } + + /** db_exec + Execute an SQL query, * returning a valid result index or zero(0) on + failure. + @param $qs -- SQL query string + @returns int Returns a valid result index on success 0 on failure + */ + function db_exec( $qs ) + { + if( !$this->dbd ) + { + $this->dbd = $this->db_connect(); + } + switch ( DB_TYPE ) + { + case "postgres": + if(!$ret = pg_exec( $this->dbd, $qs ) ) + echo "".$qs.""; + break; + default: + return( 0 ); + } + return( $ret ); + } + + /** db_fetch_array + Stores the data in associative indices, using the field names as + keys. + @param $res -- valid database result index + @param $i -- row number + @param $type -- PGSQL_ASSOC,PGSQL_BOTH,PGSQL_NUM + @returns array Returns an associative array of key-value pairs + */ + + function db_fetch_array( $res, $i, $type ) + { + switch ( DB_TYPE ) + { + case "postgres": + $row = pg_fetch_array( $res, $i, $type ); + break; + + default: + return( 0 ); + } + return( $row ); + } + + /** db_freeresult + Free result memory. + @param $res -- valid database result index + @returns bool - Returns 1 for success 0 for failure + */ + + function db_freeresult( $res ) + { + switch ( DB_TYPE ) + { + case "postgres": + $ret = pg_freeresult( $res ); + break; + + default: + return( 0 ); + } + return( $ret ); + } + + /** db_numrows + Determine number of rows in a result index + @param $res -- valid database result index + @returns int - Returns number of rows + */ + + function db_numrows( $res ) + { + + switch ( DB_TYPE ) + { + case "postgres": + $ret = pg_numrows( $res ); + break; + + default: + return( -1 ); + } + return( $ret ); + } + /** db_auto_get_array + The auto function for retrieving an array based soley on a query + string. This function makes the connection, does the exec, fetches + the array, closes the connection, frees memory used by the result, + and then returns the array + @param $qs SQL query string + @param $i row number + @param $type PGSQL_ASSOC or PGSQL_BOTH or PSQL_NUM + @returns array - Returns an associative array of key-value pairs + */ + + function db_auto_array( $qs, $i, $type ) + { + + $dbd = $this->db_connect(); + if( !$dbd ) + { + return( 0 ); + } + $res = db_exec( $dbd, $qs ); + if( !$res ) + { + return( 0 ); + } + + $row = db_fetch_array( $res, $i, $type ); + + if(!db_freeresult( $res ) ) + { + return( 0 ); + } + + return( $row ); + } + + /** db_auto_exec + The auto function for executing a query. + This function makes the connection, does the exec, fetches + the array, closes the connection, frees memory used by the result, + and then returns success (not a valid result index) + @param $qs SQL query string + @returns int - Returns 1 for success 0 for failure + */ + + function db_auto_exec( $qs ) + { + $this->db_connect(); + if( !$this->dbd ) + { + return( 0 ); + } + if( !$this->db_exec( $qs ) ) + { + return( 0 ); + } + else + { + return( 1 ); + } + } + /** db_auto_get_data + @discussion The auto function for retrieving an array based soley on a query + string. This function makes the connection, does the exec, fetches + the array, closes the connection, frees memory used by the result, + and then returns the array + @param string $qs SQL query string + @returns Returns an associative array of key-value pairs or 0 on error + */ + + function db_auto_get_data( $qs ) + { + if( !$this->dbd ) + { + $this->db_connect(); + } + if( !( $res = $this->db_exec( $qs ) ) ) + { + return( FALSE ); + } + $totalrows = pg_NumRows( $res ); + for( $i = 0 ; $i < $totalrows ; $i++ ) + { + $data[$i] = $this->db_fetch_array ($res, $i, PGSQL_ASSOC ); + } + if( isset( $data ) && $data != "" ) + { + return( $data ); + } + else + { + return( 0 ); + } + } + + /** trans_start + Start a postgres transaction + @returns bool true if sucessful + */ + function trans_start() + { + if( !$this->trans ) + { + if( !$this->dbd = $this->db_connect() ) + { + $this->trans = false; + return( false ); + } + else + { + $this->db_exec( "BEGIN WORK;" ); + $this->trans = true; + return( true ); + } + } + else + { + return( true ); + } + } + + /** trans_end + Commit the postgres transaction + @returns bool true if successful + */ + function trans_end() + { + if( !$this->trans ) + { + if(!$this->db_exec( "COMMIT WORK;" ) ) + { + return( false ); + } + else + return( true ); + } + else + return( false ); + } + /** trans_exec + exec a postgres query in a + postgres transaction + @param string query + */ + function trans_exec( $query ) + { + if( $query != "" ) + { + if(!$ret = $this->db_exec( $query ) ) + { + $this->db_exec( "ABORT WORK;" ); + return( false ); + } + else + { + return( $ret ); + } + } + else + { + return( false ); + } + } + } +?> diff --git a/classes/class_events.inc b/classes/class_events.inc new file mode 100755 index 0000000..0655b56 --- /dev/null +++ b/classes/class_events.inc @@ -0,0 +1,510 @@ +topicid = $topicid; + $this->page_name = $GLOBALS['PHP_SELF']; + } + + // date helper funcs + function lastDayOfMonth($timestamp = '') + { + if($timestamp=='') $timestamp=time(); + return( + mktime(0,0,0, + date("m",$timestamp)+1, + 1, + date("Y",$timestamp) + )-3600*24); + } + + function firstDayOfMonth($timestamp=''){ + if($timestamp=='') $timestamp=time(); + return(mktime(0,0,0, + date("m",$timestamp), + 1, + date("Y",$timestamp) + )); + } + + // end date helper + + + function get_by_topic($topic) + { + // method fetches events based on topic id + + if(!$year) + { + $year = date("Y"); + } + if(!$month || $month == "All") + { + $month = date("n"); + } + if(ereg("^0([0-9]).*",$month,$part)) + $month = $part[1]; + $st = mktime(0,0,0,$month,1,$year); + $starting = date("m-d-Y",$this->firstDayOfMonth($st)); + $ending = date("m-d-Y",$this->lastDayOfMonth($st)); + + $query = "SET DATESTYLE TO 'SQL,US'; + SELECT id,header, + date_part('month',bdate) as mon, + date_part('day',bdate) as day, + date_part('year',bdate) as yr, + date_part('month',edate) as mon2, + date_part('day',edate) as day2, + date_part('year',edate) as yr2, + bdate as sdate, edate as edate, + btime,etime,descr,loc,contact,email,url,img,daysow,reacur + FROM event + WHERE visable = 't'"; + + $topqs=" AND topicid = $topic "; + + if($topic!='All') + { + $query.=$topqs; + } + //$query .= "AND bdate <= '$ending' AND edate >= '$starting' "; + $query .= "ORDER BY bdate DESC,btime ASC"; + $events_data = $this->DB->db_auto_get_data($query); + return $events_data; + } + + /** + * getEventSearch: + * + * @return + * @access + **/ + function get_event_search( $cal = 0 ) + { + + unset($emonths); + $month_id = array( "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ); + + // Set up the $selection array to get a query box use only item fields + $selection = array( ); + + if( $this->topicid != 24 && $this->topicid != 'All' && $this->topicid != '' ) + { + $topic_qs = ' and topicid = '.$this->topicid; + } + + // Month part do not change + $qs = "SELECT bdate,date_part('month', bdate) as d1_month, + date_part('month', edate) as d2_month, + date_part('year', bdate) as d1_year, + date_part('year', edate) as d2_year + FROM event + WHERE edate >= CURRENT_DATE + $topic_qs + AND visable = 't' + ORDER BY bdate ASC;"; + + $result = $this->DB->db_exec($qs); + + $page = BASE_URL.'events.phtml'; + + for($i=0;$iDB->db_fetch_array($result,$i,PGSQL_ASSOC); + $s_month = $data['d1_month']; + $s_year = $data['d1_year']; + $e_month = $data['d2_month']; + $e_year = $data['d2_year']; + + $watchdog = 20; + for( $y=$s_year, $m=$s_month; !($y==$e_year && $m==$e_month+1) ; ) + { + if( $m == 13 ) + { + $y++; + $m = 1; + } + + $emonth = sprintf( "%02d %04d", $m, $y ); + if( !isset($emonths["$emonth"]) ) + { + $emonths["$emonth"] = 0; + } + $emonths["$emonth"]++; + + if( $watchdog-- == 0 ) + { + break 1; + } + $m++; + } + } + + // Selections part + while( list($key,$value) = each($selection)) + { + $qs = "SELECT + DISTINCT $key + FROM event + WHERE visable = 't' + AND edate >= CURRENT_DATE + $topic_qs + ORDER BY $key;"; + + $result = $this->DB->db_exec($qs); + + echo "\n"; + } + echo '
    '; + if( !$cal ) + { + // topic part + $qs = "SELECT + DISTINCT ON (t.descr) t.id,t.descr + FROM topic t, event e + WHERE e.visable = 't' + AND e.edate >= CURRENT_DATE + AND e.topicid = t.id + $topic_qs + ORDER BY t.descr"; + + $result = $this->DB->db_exec($qs); + + // form header + echo '
    '; + echo 'Search By Topic: \n"; + echo ''; + echo '
    '; + } + // Month part (output) + $month_qs = "SELECT + DISTINCT bdate + FROM event + WHERE visable = 't' + AND edate >= CURRENT_DATE + ORDER BY bdate;"; + + $result = $this->DB->db_exec($month_qs); + + echo '
    '; + echo "By Month: '; + echo ''; + echo '

    '; + } + /** + * get_events: + * @param $type: + * + * @return + * @access + **/ + function get_events() + { + if( $_POST['month'] ) + { + $month = (int)substr($_POST['month'],0,2); + $year = (int)substr($_POST['month'],3,6); + } + elseif( $_GET['month'] ) + { + $month = (int)$_GET['month']; + $year = (int)$_GET['year']; + } + else + { + $month = (int)date("m"); + $year = (int)date("Y"); + } + $GLOBALS['month'] = $month; + $GLOBALS['year'] = $year; + + require_once(BASE."classes/glm-Events-calendar-2-0.phtml"); + if(!$GLOBALS["eventid"]) + { + $this->get_event_search(); + calendar($month,$year,2,$this->page_name.'?catid=24&event=1&month=',$this->page_name.'?catid=24&event=1&eventid=1&month='.$month,$newdata); + } + else + { + // include("classes/glm-Events-2-0.phtml"); + $qs="SET DATESTYLE TO 'SQL,US';SELECT * FROM event WHERE id = ".$GLOBALS["eventid"]; + + $row=$this->DB->db_auto_get_data($qs); + echo $this->make_events($row); + $this->get_event_search(); + calendar($month,$year,2,$this->page_name.'?catid=24&event=1&month=',$this->page_name.'?catid=24&eventid=1&month='.$month,$newdata); + // echo ''; + } + + } + /** + * make_events: + * @param $row: + * + * @return + * @access + **/ + function make_events($row) + { + //$event='
    '."\n"; + $event='
    '."\n"; + for($i=0;$i".$row[$i][header]."
    "; + + + + // Date + if($row[$i][bdate]!='') + { + $event.='
    '; + $sdate = strtotime($row[$i]["bdate"]); + $edate = strtotime($row[$i]["edate"]); + $thedate = GLM_TEMPLATE::get_event_date($sdate,$edate,"timestamp"); + $event.=$thedate; + /* + $event.= date('M d, Y',strtotime($row[$i][bdate])); + if($row[$i][edate]!='' && $row[$i][edate]!=$row[$i][bdate]) + { + $event.=" - ".date('M d, Y',strtotime($row[$i][edate])); + } + */ + $event.="
    \n"; + } + + // time + $days[1] = "Sundays"; + $days[2] = "Mondays"; + $days[4] = "Tuesday"; + $days[8] = "Wednesdays"; + $days[16] = "Thursdays"; + $days[32] = "Fridays"; + $days[64] = "Saturdays"; + if($row[$i][btime]) + { + if($row[$i]['btime'] && $row[$i]['etime']) + { + $time = "".$this->format_to_time($row[$i]['btime'])." to ".$this->format_to_time($row[$i]['etime'])."
    "; + } + elseif($row[$i]['btime'] && !$row[$i]['etime']) + { + $time = "@ ".$this->format_to_time($row[$i]['btime'])."
    "; + } + else + { + $time = ""; + } + $event.=$time; + } + if( $row[$i]['reacur'] == 't') + { + if($row[$i]["weekom"]) + { + switch($row[$i]["weekom"]) + { + case 1: + $reacur .= "1st "; + break; + + case 2: + $reacur .= "2nd "; + break; + + case 3: + $reacur .= "3rd "; + break; + + case 4: + $reacur .= "4th "; + break; + + } + } + if( $row[$i]['daysow']) + { + $ri = 1; + for($r=1;$r<8;$r++) + { + if($row[$i]["daysow"]&$ri) + $reacur .= $days[$ri]; + $ri = $ri << 1; + } + } + $event.=$reacur; + } + // Location + if($row[$i][loc]!='') + { + $event.='
    Location: '; + $event.=$row[$i][loc]; + $event.="
    \n"; + } + + // URL + if($row[$i][url]!='') + { + $event.='
    URL: '; + $event.=''.$row[$i][url].''; + $event.="
    \n"; + } + // FILE + if($row[$i]['file']!='') + { + $filename = ($row[$i]['filename']) ? $row[$i]['filename'] : $row[$i]['file']; + $event.='
    File:'; + $event.=''.$filename.''; + $event.="
    \n"; + } + + // Image + if($row[$i][img]!='') + { + $image = $row[$i][img]; + if( is_file( ORIGINAL_PATH.$image ) ) + { + $size = getImageSize( ORIGINAL_PATH.$image ); + $width = $size[0]; + $height = $size[1]; + } + $event.='
    + + '.$image.' + +
    '."\n"; + } + + // Description + if($row[$i][descr]!='') + { + $event.='
    '; + $event.=nl2br($row[$i][descr])."
    "; + $event.="
    \n"; + } + + + // Description2 + if($row[$i][descr2]!='') + { + $event.='
    '; + $event.=nl2br($row[$i][descr2])."
    "; + $event.="
    \n"; + } + + // Image + if($row[$i][img2]!='') + { + $event.='
    '."\n"; + } + // Image + if($row[$i][img3]!='') + { + $event.='
    '."\n"; + } + + // Description3 + if($row[$i][descr3]!='') + { + $event.='
    '; + $event.=nl2br($row[$i][descr3])."
    "; + $event.="
    \n"; + } + + // Contact + if($row[$i][contact]!='') + { + $event.='
    Contact Information:
    '; + $event.=$row[$i][contact]; + $event.="
    \n"; + } + + // E-mail + if($row[$i][email]!='') + { + $event.='
    E-Mail: '; + $event.=''.$row[$i][email].''; + $event.="
    \n"; + } + + // Phone + if($row[$i][phone]!='') + { + $event.='
    Phone: '; + $event.=$row[$i][phone]; + $event.="
    \n"; + } + + + + + //Seperator + // $event.="
    "; + $event.="
    "; + } + return $event; + } + + /** + * format_to_time: + * @param $time: + * + * @return + * @access + **/ + function format_to_time($time) + { + return($time); + + $timestamp = strtotime("today $time"); + $newtime = date("g:i A",$timestamp); + return($newtime); + } + +} +?> diff --git a/classes/class_photos.inc b/classes/class_photos.inc new file mode 100755 index 0000000..293b5df --- /dev/null +++ b/classes/class_photos.inc @@ -0,0 +1,161 @@ +DB->db_auto_get_data($query2); + if(is_array($data2)) + { + $count = 0; + foreach($data2 as $key=>$value) + { + if($value['image']) + { + $url = GLM_TEMPLATE::get_seo_url($value['id']); + $output .= '
    '.$value["category"].'
    '.$value[
    '; + } + if(++$count == 4) + $output .= '
    '; + } + } + return($output); + } + + + /** + * get_photos: get the photo items for the catid + * @param $catid: the photo catid + * + * @return string $output + * @access public + **/ + function getPhotos($catid) + { + $output = ''; + $query2 = "SELECT b.id,b.name,b.image FROM bus b LEFT OUTER JOIN bus_category_bus bcb ON + (bcb.busid = b.id) WHERE bcb.catid = $catid order by bcb.pos"; + $data2 = $this->DB->db_auto_get_data($query2); + if(is_array($data2)) + { + $count = 0; + foreach($data2 as $key=>$value) + { + if($value['image']) + { + if(file_exists(ORIGINAL_PATH.$value['image'])) + { + $size2 = getimagesize(ORIGINAL_PATH.$value['image']); + $width = $size2[0] + 0; + $height = $size2[1] + 0; + } + /* + $output .= '
    '.$value[
    '.$value["name"].'
    + '; + */ + $url = GLM_TEMPLATE::get_seo_url(5); + if( SEO_URL ) + { + $url .= GLM_TEMPLATE::set_name_url($value['name']).'-'.$value['id'].'/'; + } + else + { + $url .= '&id='.$value['id']; + } + $output .= '
    '.$value[
    '.$value["name"].'
    + '; + /* + $output .= '
    '.$value[
    '.$value["name"].'
    + '; + */ + } + if(++$count == 4) + { + $output .= '
    + '; + $count = 0; + } + } + } + return($output); + } + + + + /** + * getPhotoDetails: + * @param $$id : + * + * @return + * @access + **/ + function getPhotoDetails( $id ) + { + $output = ''; + $query2 = "SELECT b.id,b.name,b.image FROM bus b LEFT OUTER JOIN bus_category_bus bcb ON + (bcb.busid = b.id) WHERE bcb.catid = $catid order by bcb.pos"; + $data2 = $this->DB->db_auto_get_data($query2); + if(is_array($data2)) + { + $count = 0; + foreach($data2 as $key=>$value) + { + if($value['image']) + { + if(file_exists(ORIGINAL_PATH.$value['image'])) + { + $size2 = getimagesize(ORIGINAL_PATH.$value['image']); + $width = $size2[0] + 0; + $height = $size2[1] + 0; + } + $url = GLM_TEMPLATE::get_seo_url(5); + if( SEO_URL ) + { + $url .= GLM_TEMPLATE::set_name_url($value['name']).'-'.$value['id'].'/'; + } + else + { + $url .= '&id='.$value['id']; + } + $output .= '
    '.$value[
    '.$value["name"].'
    + '; + } + if(++$count == 4) + { + $output .= '
    + '; + $count = 0; + } + } + } + return($output); + } + +} +?> diff --git a/classes/class_search.inc b/classes/class_search.inc new file mode 100755 index 0000000..7af5b9d --- /dev/null +++ b/classes/class_search.inc @@ -0,0 +1,346 @@ +newsyquery = ""; + $this->bussyquery = ""; + $this->eventquery = ""; + $this->pages = array(); + $this->parentshow = array(); + $this->type = "general"; + } + + /** set_events + Sets up the query for the event search + @param none + @returns none + */ + function set_events() + { + $eventf[] = "e.header".$this->sr; + $eventf[] = "e.descr".$this->sr; + $eventf[] = "e.loc".$this->sr; + $eventf[] = "e.contact".$this->sr; + $this->eventquery = "SELECT e.* + FROM event e + WHERE "; + $eevent = implode(" OR ",$eventf); + $this->eventquery .= $eevent; + } + + /** set_bus + Sets the query for the business_listing db search + @param none + @returns none + */ + function set_bus() + { + $busf[] = "b.name".$this->sr; + $busf[] = "b.description".$this->sr; + $busf[] = "b.city".$this->sr; + $busf[] = "b.state".$this->sr; + $busf[] = "b.zip".$this->sr; + $busf[] = "b.phone".$this->sr; + $busf[] = "b.fax".$this->sr; + $busf[] = "b.email".$this->sr; + $buscatf[] = "bc.category".$this->sr; + $buscatf[] = "bc.description".$this->sr; + $buscatf[] = "bc.intro".$this->sr; + $this->bussyquery = "SELECT DISTINCT ON (bc.category) bc.*, b.*,bc.id as catid + FROM (bus_category bc LEFT OUTER JOIN bus_category_bus bcb ON (bcb.catid = bc.id)) + LEFT OUTER JOIN bus b ON (b.id = bcb.busid) + WHERE ("; + $ebus = implode(" OR ",$busf); + $ebuscat = implode(" OR ",$buscatf); + $this->bussyquery .= $ebus." OR ".$ebuscat.")"; + } + + /** set_news + Sets the newsletter query for the search + @param none + @returns none + */ + function set_news() + { + $newsf[] = "n.title".$this->sr; + $newsf[] = "n.header".$this->sr; + $newsf[] = "n.description".$this->sr; + $newsblockf[] = "nb.header".$this->sr; + $newsblockf[] = "nb.description".$this->sr; + $this->newsyquery = "SELECT n.*, nb.* + FROM news n LEFT OUTER JOIN news_block nb ON (n.id = nb.news_id) + WHERE "; + + $enews = implode(" OR ",$newsf); + $enewsblock = implode(" OR ",$newsblockf); + $this->newsyquery .= $enews." OR ".$enewsblock; + } + + /** set_query + calls the queries for events,bus,and the newsletter + @param none + @returns none + */ + function set_queries() + { + $this->set_events(); + $this->set_bus(); + $this->set_news(); + } + + /** posted + Sets sr variable with the POST var search + @param none + @returns none + */ + function posted() + { + if($_POST && $_POST["search"]) + { + //$this->show_form(); + if($_POST["search"]) + $this->sr = " ~* '".$_POST["search"]."'"; + $this->set_queries(); + $this->execute_search(); + } + else + { + //$this->show_form(); + } + } + + /** show_form + Outputs the form for the search + @param none + @returns none + */ + function show_form() + { + ?> + +
    " method="POST" onSubmit=" + this.search.optional = false; + this.search.r = 'Search Field'; + return(verify(this)); + "> + + + +
    + type) + { + case "events"://Events + $qs = $this->eventquery; + $qs .= " AND edate > CURRENT_DATE"; + $href = $this->pages["events"]; + break; + + case "general"://General + $qs = $this->bussyquery; + break; + + case "newsletter"://Library + $qs = $this->newsyquery; + $href = $this->pages["newsletter"]; + break; + + default: + html_error("All",1); + break; + } + + //echo $qs; + $this->result = db_auto_get_data($qs,CONN_STR); + if($this->result != "") + { + echo "
    Found ".count($this->result); + if(count($this->result)>1) + echo " matches for \"".$search."\""; + else + echo " match for \"".$search."\""; + echo "

    "; + } + else + { + echo "
    No Matches
    "; + } + if($this->type == "general") + { + if($this->result != "") + { + foreach($this->result as $key=>$data) + { + $this->threads[] = array( + "ID" => $data[catid], + "content" => $data[category], + "parent" => $data[parent] + ); + } + } + } + elseif($this->type == "events") + { + if($this->result != "") + { + foreach($this->result as $key=>$data) + { + printf("%s
    ",$href,$data[id],$data[header]); + } + } + } + elseif($this->type == "newsletter") + { + if($this->result != "") + { + foreach($this->result as $key=>$data) + { + printf("%s
    ",$href,$data[title]); + } + } + } + + if(is_array($this->threads)) + { + $this->get_parentshow(); + $output = $this->printout($this->threads); + echo $output; + } + } + + /** get_parent + Finds the parent. Will traverse up until it reaches top of + chain. + @param id - The catid to find parent of + @returns Parent - The parent id + */ + function get_parent($id) + { + if($id == 0) + return(0); + if($this->parentshow[$id]['parent'] != "") + { + + $test = $this->parentshow[$id]['parent']; + if($test === 0) + { + return($id); + } + else + { + $id = $this->get_parent($test); + } + if($id == 0) + return($test); + return($id); + } + return($id); + } + + /** get_parentshow + Sets the array parentshow with all categories. + @param none + @returns none + */ + function get_parentshow() + { + $qs = "SELECT id,parent,category + FROM bus_category"; + + $parentrow = db_auto_get_data($qs,CONN_STR); + + foreach($parentrow as $key=>$value) + { + $this->parentshow[$value[id]] = $value[parent]; + } + } + + /** printout + Print the results out as links to their pages. + @param none + @returns none + */ + function printout() + { + if(is_array($this->threads)) + { + foreach($this->threads as $key=>$value) + { + $p = $this->get_parent($value[ID]); + if($p!=1) + { + $string .= "".$value[content]."
    "; + } + else + { + $string .= "".$value[content]."
    "; + } + } + echo $string; + } + } +} +?> diff --git a/classes/class_staff.inc b/classes/class_staff.inc new file mode 100755 index 0000000..1ae48e6 --- /dev/null +++ b/classes/class_staff.inc @@ -0,0 +1,149 @@ +get_seo_url(5); + $output = ''; + $query = "SELECT * FROM bus_category WHERE id = ".$catid; + $data = $this->DB->db_auto_get_data($query); + if(is_array($data)) + { + foreach($data as $key=>$value) + { + if($value['category']) + { + $catname = $value["category"]; + } + + } + } + $query2 = "SELECT * FROM bus where id = $busid"; + $data2 = $this->DB->db_auto_get_data($query2); + if(is_array($data2)) + { + $count = 0; + foreach($data2 as $key=>$value) + { + if($value['image']) + { + if($value["email"]) + { + $name = ($value["name"] != '') ? ''.$value["name"].'
    ': ''; + } + else + { + $name = ($value["name"] != '') ? ''.$value["name"].'
    ': ''; + } + $title = ($value["title"] != '') ? ''.$value["title"].'
    ': ''; + $org = ($value["org"] != '') ? ''.$value["org"].'
    ': ''; + $phone = ($value["phone"] != '') ? ''.$value["phone"].'
    ': ''; + //$email = ($value["email"] != '') ? ''.$value["email"].'
    ': ''; + $description = ($value["description"] != '') ? ''.nl2br($value["description"]).'
    ': ''; + $output .= '

    '.$value["name"].'

    '; + $output .= ' +
    '.$value[
    +
    '. + $name. + $title. + $org. + $phone. + $email. + $description. + '
    + '; + } + if(++$count == 4) + { + $output .= '
    + '; + $count = 0; + } + } + } + $output = GLM_TEMPLATE::clean_text($output); + return('
    '.$output.'
    '); + } + /** + * getStaff: used for output of staff listings + * @param $catid: id for bus_category table + * + * @return string $outpu + * @access public + **/ + function getStaff($catid) + { + $output = ''; + $query = "SELECT * FROM bus_category WHERE id = ".$catid; + $data = $this->DB->db_auto_get_data($query); + $output .= '

    Click an image to view details

    + '; + + $query2 = "SELECT b.* FROM bus b LEFT OUTER JOIN bus_category_bus bcb ON + (bcb.busid = b.id) WHERE bcb.catid = $catid order by bcb.pos"; + $data2 = $this->DB->db_auto_get_data($query2); + if(is_array($data2)) + { + $count = 0; + foreach($data2 as $key=>$value) + { + if($value['image']) + { + if($value["email"]) + { + $name = ($value["name"] != '') ? ''.$value["name"].'
    ': ''; + } + else + { + $name = ($value["name"] != '') ? ''.$value["name"].'
    ': ''; + } + $title = ($value["title"] != '') ? ''.$value["title"].'
    ': ''; + $org = ($value["org"] != '') ? ''.$value["org"].'
    ': ''; + $phone = ($value["phone"] != '') ? ''.$value["phone"].'
    ': ''; + //$email = ($value["email"] != '') ? ''.$value["email"].'
    ': ''; + $pagename = BASE_URL.'staff/';//GLM_TEMPLATE::get_seo_url( 5 ); + //$busname = 'busid='.$value['id']; + $busname = GLM_TEMPLATE::set_name_url( $value['name'] ); + if( SEO_URL ) + { + $busname = GLM_TEMPLATE::set_name_url($value['name']).'-'.$value['id'].'/'; + } + else + { + $busname = '&id='.$value['id']; + } + $description = ($value["description"] != '') ? ''.nl2br($value["description"]).'
    ': ''; + $output .= '
    '.$value[ +
    '. + $name. + $title. + $org. + $phone. + $email. + '
    + '; + } + if(++$count == 4) + { + $output .= '
    + '; + $count = 0; + } + } + } + $output = GLM_TEMPLATE::clean_text($output); + return('
    '.$output.'
    '); + } +} +?> diff --git a/classes/class_tellfriend.inc b/classes/class_tellfriend.inc new file mode 100755 index 0000000..66cb849 --- /dev/null +++ b/classes/class_tellfriend.inc @@ -0,0 +1,210 @@ +base_url=$base_url; + + // set post to + if($postto==''){ + $dvar=explode('/',$_SERVER[PHP_SELF]); + $this->postto=$dvar[(sizeof($dvar)-1)]; // Neat way to get the last element + }else + { + $this->postto=$postto; + } + // Set the formvals to 0 + $this->formvals=0; + + // Set message text + if($message!='') + { + // If a message string has been passed in, use it + $this->message = $message; + }else{ // Otherwise, set a default +$message="Dear {friend_name}, +Your friend {senders_name} has been to http://www.gaslightmedia.com, and thought you might be interested in it. + +Message from {senders_name}: +{message}"; + $this->message = $message; + } + // Set thankyou text + if($thankyou!='') + { + $this->thankyou=$thankyou; + }else{ + $thankyou="Thank you {senders_name}, your message has been sent to {friend_name}."; + $this->thankyou=$thankyou; + } + // End of constructor method + } + + /** show_form + shows the Tell a Friend form + @param int r number of rows in the message textarea + @param int c number of columns in the message textarea + @return void + */ + function show_form($r=3,$c=30) + { + // $r is the number of rows on the message + // $c is the number of columns on the message + + if($this->formvals == 0) + { + $fname=''; + $femail=''; + $yname=''; + $yemail=''; + $msg=''; + }elseif(is_array($this->formvals)) + { + $fname=$this->formvals[fname]; + $femail=$this->formvals[femail]; + $yname=$this->formvals[yname]; + $yemail=$this->formvals[yemail]; + $msg=$this->formvals[msg]; + } + $output='
    +
    +
    + + +
    +
    + + +
    +
    +
    + +
    +
    + + +
    +
    + + +
    +
    + +
    + '; + + $output.="
    \n
    \n"; + echo $output; + //phpinfo(); + } + + /** valid email + Checks for a valid format and good (mx check) + email address. + @param string email the email address as string. + @return boolean + */ + function valid_email ($email) { + $check=''; + $validate_email_temp=''; + if (eregi('^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$', $email, $check)) { + if ( getmxrr(substr(strstr($check[0], '@'), 1), $validate_email_temp) ) { + return TRUE; + } + } + return FALSE; + } + + /** process_form + validates the email addresses, htmlspecialchars the message, sends the email + @return boolean + **/ + function process_form() + { + //phpinfo(); + // Double check that stuff was submitted + if(!isset($_POST[submit])) + { + return 0; + }else + { + // The real work begins + // Check the email addresses + if($this->valid_email($_POST[senders_email])==FALSE) + { + $error[]="Error: the email address you entered for yourself is invalid
    \n"; + } + if($this->valid_email($_POST[friend_email])==FALSE) + { + $error[]="Error: the email address you entered for your associate is invalid
    \n"; + } + // See if $error isset and is_array, if it is, the buck stops here, because they screwed up. + if(isset($error) && is_array($error)) + { + $this->formvals=array( + "fname" => $_POST[friend_name], + "femail" =>$_POST[friend_email], + "yname" =>$_POST[senders_name], + "yemail" =>$_POST[senders_email], + "msg" =>$_POST[message]); + + for($i=0;$ishow_form(); + return 0; + }else + { + // Everything looks good, process the form and mail it out. + $message = str_replace('{senders_name}',$_POST[senders_name],$this->message); // only the first replace references the class message + $message = str_replace('{friend_name}',$_POST[friend_name],$message); + $message = str_replace('{message}',$_POST[message],$message); + // Same thing with the thankyou msg, only the first replace needs the $this->thankyou + $thankyou = str_replace('{senders_name}',$_POST[senders_name],$this->thankyou); + $thankyou = str_replace('{friend_name}',$_POST[friend_name],$thankyou); + $subject = $_POST[senders_name].' wanted you to see this site'; + $headers = "From: ".$_POST[senders_email]."\n"; + + mail($_POST[friend_email],"Tell a friend",$message,$headers); + + //echo "
    Mail command params\n".$_POST[friend_email]." \n
    ".$subject."\n
    ".$message."\n\n"; + echo $thankyou; + } + + } + } + + function jfdi() + { + if(isset($_POST[submit])) + { + $res = $this->process_form(); + }else + { + $this->show_form(); + } + } +} +?> diff --git a/classes/class_template.inc b/classes/class_template.inc new file mode 100755 index 0000000..3795828 --- /dev/null +++ b/classes/class_template.inc @@ -0,0 +1,1807 @@ + example follows: +Options +FollowSymLinks +ErrorDocument 404 /www.?????.com/sitemap.php?nf=1 +RewriteEngine On +RewriteBase / +RewriteRule (.*)-([0-9]{1,4}) index\.phtml?catid=$2 +RewriteRule site-map sitemap.php +*/ +require_once(BASE."classes/class_db.inc"); +class GLM_TEMPLATE{ + + /** @var header_begin The style starting for header */ + var $header_begin; + /** @var header_end The style ending for header*/ + var $header_end; + /** @var subheader_begin The style starting for header */ + var $subheader_begin; + /** @var subheader_end The style ending for header*/ + var $subheader_end; + /** @var img_align The alignment of images*/ + var $img_align; + /** @var img_alternate 1 alternate images 0 not*/ + var $img_alternate; + /** @var img_size The path to the image directory*/ + var $img_size; + /** @var DB The database class*/ + var $DB; + /** @var data The category array*/ + var $data; + /** @var items The items array*/ + var $items; + /** @var type The type*/ + var $type; + /** @var whole_thread The thread string*/ + var $whole_thread; + /** @var thread_count The thread count*/ + var $thread_count; + /** @var catid catid for te page */ + var $catid; + /** @var array $pages */ + var $pages; + /** @var $active_query string adding active = 't' to queries only if ACTIVE_FLAG is set to true */ + var $active_query; + /** @var $template integer determines page layout */ + var $template; + /** @var $php_ext pgae extension for php pages .php or .phtml */ + + /** + * GLM_TEMPLATE:Contsructor of the class + * This function is run on intialization. + * Any setup vars should be overwritten by creating a new class + * that extends this one and setting new vars in the constructor. + * + * @param $catid: catid Must be set + * + * @return void + * @access + **/ + function GLM_TEMPLATE( $catid, $DB = NULL ) + { + $this->get_catid( $catid ); // sets $this->catid + $this->set_DB( &$DB ); // using a reference to $DB (should be started on setup.phtml + $this->header_begin = "

    "; // class="content" should not be used anymore + $this->header_end = "

    "; // create style for p h1 h2 tags if needed try to keep it clean + $this->subheader_begin = "

    ";// should not be using h3 here duh go from 1 to 2 instead + $this->subheader_end = "

    "; // like your suppose to + $this->img_alternate = 1; // for alternating images set to 1 else leave alone + $this->img_align = "left"; // the starting postion for images change to left if needed + $this->img_size = MIDSIZED; // img_size are RESIZED,MIDSIZED,THUMB do not use ORIGINAL + $this->whole_thread = ""; // do not touch this it is used for menu generation + $this->thread_count = 1; // also used for menu generation + $this->php_ext = '.phtml'; // defaults to .phtml + $this->set_pages( &$GLOBALS['PAGES'] ); + } + + + /** + * set_active_query: some toolboxes have an active flag some do not + * so this is to allow both with and without a flag. + * + * @return + * @access + **/ + function set_active_query() + { + if( ACTIVE_FLAG ) + { + $this->active_query = " and active = 't'"; + } + return( $this->active_query ); + } + + + /** + * get_hit_count: find out how many top level categories have at least one category under + * them. + * @param $&$DB : Database object + * + * @return + * @access + **/ + function get_hit_count( &$DB ) + { + $query = 'select id from bus_category where parent in ( select id from bus_category where + parent = 0) and parent != 0'; + $res = $DB->db_auto_get_data( $query ); + if( !$res ) + { + return( 0 ); + } + else + { + return( count( $res ) ); + } + } + + /** + * get_seo_url: grab category part of the seoarch engine friendly url + looks at define for seo_url to see weather to use the seach engine friendly url's or not + * @param $id: + * @param $$slash = 1 : to put a slash on end or not + * + * @return string $url for page. + * @access public + **/ + function get_seo_url( $id, $slash = 1 ) + { + if( SEO_URL ) + { + $url = BASE_URL; + $url .= GLM_TEMPLATE::set_name_url( GLM_TEMPLATE::get_category_name( $id, "bus_category", $this->DB ) ); + $url = strip_tags( $url ); + $url = htmlspecialchars( $url ); + if( $slash ) + { + $url .= '/'; + } + } + else + { + $url = $this->get_base_url( $id ); + if( $url ) + { + $url = BASE_URL.$url; + $url .= $this->php_ext.'?catid='.$id; + } + else + { + $url = BASE_URL; + } + } + + return( $url ); + } + /** + * set_DB: set the DB up to be that of the global one if it exists + * @param $$DB : the DB object + * + * @return void + * @access public + **/ + function set_DB( $DB ) + { + if( isset( $DB ) ) + { + $this->DB =& $DB; + } + else + { + $this->DB =& new GLM_DB(); + } + } + + /** + * set_pages: grab the globals for the pages an use this for + the pages array for the class + * + * @return void + * @access public + **/ + function set_pages( $pages ) + { + if( is_array( $pages ) ) + { + $this->pages =& $pages; + } + } + + /** + * set_catid:Set the class catid var + * @param $catid: $catid + * + * @return void + * @access public + **/ + function set_catid( $catid ) + { + if( is_numeric( $catid ) ) + { + $this->catid = $catid; + } + else + { + $this->catid = 1; + } + } + + /** + * get_id_from_path_info: takes the path_info and gets a catid from bus_category table + * @param $PATH_INFO: GLOBAL PATH_INFO + * @param $&$dbd : object database + * + * @return int catid + * @access public + **/ + function get_id_from_path_info( $PATH_INFO, &$dbd ) + { + //echo "$PATH_INFO"; + $var_array = explode( "/", $PATH_INFO ); + if( count( $var_array ) > 0 ) + { + $it=$var_array[(sizeof($var_array) - $chop)]; + if( $it != "" && $it != "blank") + { + $catid = GLM_TEMPLATE::get_id_from_name( $it,"bus_category", &$dbd ); + } + } + return( $catid ); + } + + /** + * get_catid: calls the get_id_from_path and can be placed into the consructor + * + * @return int catid + * @access public + **/ + function get_catid( $catid ) + { + if( isset( $catid ) && is_numeric( $catid ) ) + { + return( $this->catid = $catid ); + } + if(!isset($_GET[page])) + { + $this->catid = $this->get_id_from_path_info( $PATH_INFO, &$this->DB ); + } + else + { + $this->catid = $this->get_id_from_name($page, "bus_category",&$this->DB); + } + return( $this->catid ); + } + + /** + * set_contact:Set the contact string + + * @param $text: The text as string + * @param $email: email if givin + * + * @return string $text + * @access + **/ + function set_contact( $text, $email ) + { + if( $email != "" ) + { + $text = ""; + } + else + { + $text = '

    Contact Name: '.$text.'

    '; + } + return($text); + } + + function fix_urls($string) + { + preg_match_all ("|href\=\"?'?`?([[:alnum:]:?=&@/._-]+)\"?'?`?|i", $string, &$matches); + if( is_array( $matches[1] ) ) + { + foreach( $matches[1] as $key => $val ) + { + if( !stristr( $val, "http" ) && !stristr( $val, "mailto" ) ) + { + $ret[] = array( 'in'=>$val,'out'=>BASE_URL.$val); + } + } + } + if( is_array( $ret ) ) + { + foreach( $ret as $k => $val ) + { + $string = str_replace( $val['in'], $val['out'], $string ); + } + } + return $string; + } + /** + * set_text:Set the contact string + * @param $text: The text as string + * + * @return string $text + * @access + **/ + function set_text( $text ) + { + if("" == str_replace("
    ","",trim($text))) + { + return(false); + } + if( $text != "" ) + { + //$text = str_replace( "keyword_replace( $text ); + $text = nl2br( $text ); + //$text = $this->fix_urls( $text ); + } + return($text); + } + + /** + * get_image_path: get image path from the size used + * + * @return path for images + * @access public + **/ + function get_image_path() + { + if( strstr($this->img_size,'midsized/') ) + { + return( MIDSIZED_PATH ); + } + if( strstr($this->img_size,'resized/') ) + { + return( RESIZED_PATH ); + } + if( strstr($this->img_size,'thumb/') ) + { + return( THUMB_PATH ); + } + } + + /** + * set_img:Set the image string + * @param $image: The image + * @param $size: The path + * @param $align: The alignment + * @param $name: The image_name (displayed under image) + * @param $title: Title if given + * + * @return + * @access + **/ + function set_img( $image, $size, $align, $title ) + { + if( $image != "" ) + { + if( $title != '') + { + $titletag = 'title="'.htmlspecialchars(strip_tags($title)).'"'; + $titletag .= ' alt="'.htmlspecialchars(strip_tags($title)).'"'; + } + else + { + $titletag = 'title="'.htmlspecialchars(strip_tags($image)).'"'; + $titletag .= ' alt="'.htmlspecialchars(strip_tags($image)).'"'; + } + if( $align != "" ) + { + $img_align = 'class="image'.$align.'"'; + } + $path = $this->get_image_path(); + if( is_file( $path.$image ) ) + { + $image_size = getimagesize( $path.$image ); + $img_attr = $image_size[3]; + } + if(file_exists(ORIGINAL_PATH.$image)) + { + $size2 = getimagesize(ORIGINAL_PATH.$image); + $width = $size2[0] + 0; + $height = $size2[1] + 0; + } + $img .= ''; + $this->imgfloat["$img"] = $align; + return($img); + } + } + + /** + * set_url:Set the url string + * @param $url: The url + * @param $text: The text as string + * + * @return string $text + * @access + **/ + function set_url( $url, $text ) + { + if( $url != "" ) + { + if( !$text ) + { + $text = $url; + } + if( strtolower( substr( $url, 0, 7 ) ) == "https://" ) + { + $url = '

    '.$text.'

    '; + } + else + { + $url = '

    '.$text.'

    '; + } + } + return( $url ); + } + + /** + * set_email:Set the email string + * @param $email: The email as string + * @param $contact: The contactname this is used as the link text + * + * @return string $text + * @access + **/ + function set_email( $email, $contact ) + { + if( $email != "" ) + { + if( $contact != "" ) + { + $email = '

    Contact:  '.$contact.'

    '; + } + else + { + $email = '

    Email:  '.$email.'

    '; + } + } + return( $email ); + } + + /** + * set_header:Set the header string + * @param $text: The text as string + * + * @return string $text + * @access + **/ + function set_header( $text ) + { + if( $text != "" ) + { + $text = $this->header_begin.$text.$this->header_end; + } + return( $text ); + } + + /** + * set_subheader:Set the subheader string + * @param $text: The text as string + + * + * @return string $text + * @access + **/ + function set_subheader( $text ) + { + if( $text != "" ) + { + $text = $this->subheader_begin.$text.$this->subheader_end; + } + return( $text ); + } + + /** + * set_phone:Set the phone string + * @param $text: The text as string + * + * @return string $text + * @access + **/ + function set_phone( $text ) + { + if( $text != "" ) + { + $text = '

    Phone:  '.$text.'

    '; + } + return( $text ); + } + + /** + * set_fax:Set the fax string + * @param $text: The text as string + * + * @return string $text + * @access + **/ + function set_fax( $text ) + { + if( $text != "" ) + { + $text = '

    Fax:  '.$text.'

    '; + } + return( $text ); + } + + /** + * set_file:Set the file string + * @param $text: The text as string + * @param $name: The file name displayed + * + * @return string $text + * @access + **/ + function set_file( $text, $name ) + { + if( $text != "" ) + { + $outtext = '

    '; + if($name) + $outtext .= $name; + else + $outtext .= $text; + $outtext .= '

    '; + } + return( $outtext ); + } + + /** + * set_address:set_address + * @param $data: data contain the address info for display. + * + * @return string $address + * @access + **/ + function set_address( $data ) + { + $address = ""; + if( $data["address"] ) + { + $address .= $data["address"]; + } + if( $data["city"] && $data["state"] && $data["zip"] ) + { + $address .= '
    '.$data["city"].', '.$data["state"].' '.$data["zip"]; + } + elseif( $data["city"] && $data["state"] ) + { + $address .= '
    '.$data["city"].', '.$data["state"]; + } + elseif( $data["city"] ) + { + $address .= '
    '.$data["city"]; + } + if( $address != "" ) + { + return( '

    '.$address.'

    ' ); + } + } + + /** + * get_all:Does the query and set_data calls boths arrays + * + * @return void + * @access + **/ + function get_all( $type = NULL ) + { + $catid = $this->catid; + if( $type == 1 || !$type ) + { + $cat_query = "select * from bus_category where id = $catid ".$this->active_query." order by pos"; + $res = $this->set_data( $this->DB->db_auto_get_data( $cat_query ) ); + $this->data = $res[0]; + } + if( $type == 2 || !$type ) + { + $item_query = "select b.* from bus b left outer join bus_category_bus bcb on (bcb.busid = b.id) where bcb.catid = $catid order by bcb.pos"; + $this->items = $this->set_data( $this->DB->db_auto_get_data( $item_query ) ); + } + } + + /** + * set_data:Calls each function of the class + * based on the key af the array $data[0][$key] + * @param $data: The input array from db query + * + * @return array data The finished array + * @access + **/ + function set_data( $data ) + { + if( is_array( $data ) ) + { + foreach( $data as $k => $val ) + { + foreach( $val as $key => $value ) + { + if( strstr( $key, "image" ) && !strstr( $key, "name") && $value != "" ) + { + $titletag = ( $data[$k]['category'] ) ? $data[$k]['category'] : $data[$k]['name']; + $data[$k][$key."_name"] = $value; + $data[$k][$key] = $this->set_img( $value, $this->img_size, $this->img_align, $data[$k][$key."name"].$titletag ); + if( !strstr( $key, "name" ) ) + { + if( $this->img_align == "right" && $this->img_alternate ) + { + $this->img_align = "left"; + } + elseif( $this->img_alternate ) + { + $this->img_align = "right"; + } + } + } + elseif( strstr($key,"file") && strstr($key,"name") && $value!="" ) + { + } + elseif( strstr($key,"url") && strstr($key,"name") && $value!="" ) + { + } + elseif( strstr($key,"descr") && $value != "" ) + { + $data[$k][$key] = GLM_TEMPLATE::set_text( $value ); + } + elseif( $key == "contactname" && $value != "" ) + { + $data[$k][$key] = GLM_TEMPLATE::set_contact( $value, $data[$k]['email'] ); + } + elseif($key == "name" && $value!="") + { + $data[$k][$key] = GLM_TEMPLATE::set_subheader( $value ); + } + elseif( strstr( $key, "header" ) && $value != "" ) + { + $data[$k][$key] = GLM_TEMPLATE::set_subheader( $value ); + } + elseif( $key == "intro" && $value != "" ) + { + $data[$k][$key] = GLM_TEMPLATE::set_header( $value ); + } + elseif( $key == "category" && $value != "" ) + { + $data[$k][$key] = GLM_TEMPLATE::set_header( $value ); + } + elseif( $key == "url" && $value != "" ) + { + $data[$k][$key] = GLM_TEMPLATE::set_url( $value, $data[$k]["urlname"] ); + } + elseif( $key == "email" && $value!="") + { + $data[$k][$key] = GLM_TEMPLATE::set_email( $value, $data[$k]["contactname"] ); + } + elseif( $key == "phone" && $value != "" ) + { + $data[$k][$key] = GLM_TEMPLATE::set_phone($value); + } + elseif( $key == "fax" && $value != "" ) + { + $data[$k][$key] = GLM_TEMPLATE::set_fax( $value ); + } + elseif (strstr( $key, "file" ) && $value!="") + { + $data[$k][$key] = GLM_TEMPLATE::set_file( $value, $data[$k][$key.'name'] ); + } + elseif( $key == "address" ) + { + $data[$k][$key] = GLM_TEMPLATE::set_address( $data[$k] ); + } + elseif( $key == "id" ) + { + $data[$k][$key] = $value; + } + else + { + $data[$k][$key] = GLM_TEMPLATE::set_text( $value ); + } + } + } + return( $data ); + } + return( false ); + } + + /** + * load_static_page:using object buffer include the page $catid.phtml from static dir + and return it as string + * + * @return string $text + * @access + **/ + function load_static_page() + { + if( file_exists( BASE."static/".$this->catid.".phtml" ) ) + { + ob_start(); + include("static/".$this->catid.".phtml"); + $text = ob_get_contents(); + ob_end_clean(); + return($text); + } + } + + /** + * clean_text:Do some text clean up. + * @param $output: + * + * @return string text cleaned + * @access + **/ + function clean_text($output) + { + $output = str_replace("
    ","
    ",$output); + $output = str_replace("


    ","",$output); + return($output); + } + + /** + * get_category: grab just category contents + * @param $catid: id of bus_category + * @param $DB: + * @param $$showimg=1: weather or not to show category image + * + * @return string $output + * @access public + **/ + function get_category( $showimg = 1,$showdiv=1 ) + { + if( DELUXE_TOOLBOX ) + { + $this->get_template( "cat" ); + } + + if( !$this->data ) + { + $this->get_all( 1 ); + } + $data = $this->data; + if($showdiv==1) + { + $output .= '
    '."\n"; + } + if( $this->catid == 1 ) + { + // $output .= $this->get_home_events(); + } + if($data["image"] || $data["description"] || $data["intro"] ) + { + //$output .=$data["intro"]." "; + if($showimg == 1) + { + $output .=$data["image"]." "; + } + $output .=$data["intro"]." "; + $output .=$data["description"]." "; + } + if($showdiv==1) + { + $output .= '
    '."\n"; + } + $output = GLM_TEMPLATE::clean_text($output); + return( $output ); + + } + + /** + * get_page: replacing template_parser with get-page function + * + * @return + * @access + **/ + function get_page( $showimg = 1,$showdiv=1 ) + { + $out .= $this->get_category( $showimg,$showdiv ); + $out .= $this->get_listings(); + return( $out ); + } + + /** + * get_template: get the template type of the bus_category + * @param $$type : 'cat' or 'list' + * + * @return void + * @access public + **/ + function get_template( $type ) + { + $query = "select template from bus_category where id = ".$this->catid; + $data = $this->DB->db_auto_get_data( $query ); + switch( $type ) + { + case "cat": + switch( $data[0]['template'] ) + { + case "5": + case "4": + case "2": + $this->img_align = "left"; + break; + + default: + $this->img_align = "right"; + break; + } + break; + + case "list": + switch( $data[0]['template'] ) + { + case "5": + $this->img_align = "right"; + $this->img_alternate = 0; + break; + case "4": + $this->img_align = "right"; + $this->img_alternate = 1; + break; + + case "3": + $this->img_align = "left"; + $this->img_alternate = 1; + break; + + case "2": + $this->img_align = "left"; + $this->img_alternate = 0; + break; + + case "1": + $this->img_align = "right"; + $this->img_alternate = 0; + break; + + default: + break; + } + break; + } + return( $this->template = $data[0]['template'] ); + } + /** + * template_parser:This function creates data + * and items arrays and does the output for the page. + * + * @return void + * @access + **/ + function get_listings() + { + // grab category and items into data and items respectfully + if( DELUXE_TOOLBOX ) + { + $this->get_template( "list" ); + } + + if( !is_array( $this->items ) ) + { + $this->get_all( 2 ); + } + + // load any static category page from the static directory + // hard codded content would have $catid.phtml page for it + $output .= $this->load_static_page(); + switch($this->type) + { + + default: + if(is_array($this->items)) + { + foreach($this->items as $key=>$val) + { + // items can be moved around as needed + $output .= '
    '."\n"; + $output .= $val["image"]; + $output .= $val["name"]; + $output .= $val["address"]; + $output .= $val["description"]; + $output .= $val["contactname"]; + $output .= $val["email"]; + $output .= $val["phone"]; + $output .= $val["fax"]; + $output .= $val["url"]; + $output .= $val["file"]; + $output .= $val["file2"]; + $output .= $val["file3"]; + $output .= "
    "."\n"; + } + } + break; + } + $output = GLM_TEMPLATE::clean_text($output); + return( $output ); + } + + /** + * sub_nav:Create a sub navigation 4 across + * @param $catid: The catid for the page + * + * @return void + * @access + **/ + function sub_nav($catid) + { + //$catid = $this->get_top_parent($catid); + $query = "SELECT id,category FROM bus_category WHERE parent = $catid ".$this->active_query." ORDER BY pos"; + $data = $this->DB->db_auto_get_data($query); + if(is_array($data)) + { + $counter = 1; + foreach($data as $key=>$val) + { + $url = $this->get_seo_url( $val['id'] ); + //GLM_TEMPLATE::set_name_url( GLM_TEMPLATE::get_category_Name( $val['id'],"bus_category",$this->DB ) ); + echo ''; + echo $val["category"]; + echo '
    '; + } + } + } + + /** + * get_home_events: get events flaged as home events + * @param $DB: DB reference to DB obj + + * + * @returnvoid + * @access + **/ + function get_home_events() + { + $query = "SELECT id,header,substr(descr,0,30) as descr, bdate, edate + FROM event WHERE home = 't'"; + $data = $this->DB->db_auto_get_data($query); + if(is_array($data)) + { + $output = '
    UPCOMING EVENTS
    + '; + foreach($data as $key=>$value) + { + $id = $value['id']; + $header = $value['header']; + $sdate = strtotime($value['bdate']); + $edate = strtotime($value['edate']); + $dates = GLM_TEMPLATE::get_event_date($sdate,$edate,"timestamp"); + $output .= $dates; + $output .= '

    '.$header.'

    '; + } + $output .= '
    '; + return($output); + } + else + { + return( '' ); + } + } + + /** + * get_event_date: make the event date human readable + * @param $sdate: start date + * @param $edate: end date + * @param $dateType: dateType Postgres,etc + * + * @return string + * @access + **/ + function get_event_date($sdate,$edate,$dateType) + { + switch($dateType) + { + case "Postgres": + if(ereg("([0-9]{1,2})[/-]([0-9]{1,2})[/-]([0-9]{4})",$sdate,$spt)) + { + $mon = $spt[1]; + $day = $spt[2]; + $yr = $spt[3]; + } + + if(ereg("([0-9]{1,2})[/-]([0-9]{1,2})[/-]([0-9]{4})",$edate,$ept)) + { + $mon2 = $ept[1]; + $day2 = $ept[2]; + $yr2 = $ept[3]; + } + break; + + case "timestamp": + $mon = date("m",$sdate); + $day = date("d",$sdate); + $yr = date("Y",$sdate); + $mon2 = date("m",$edate); + $day2 = date("d",$edate); + $yr2 = date("Y",$edate); + break; + + }$start = mktime(0,0,0,$mon,$day,$yr); + $end = mktime(0,0,0,$mon2,$day2,$yr2); + if ($day == $day2 && $mon == $mon2 && $yr == $yr2) + { + $dateparam = "F jS, Y"; + $date_begin = date($dateparam, $start) ; + $date_end = ""; + } + elseif ($day == $day2 AND $mon == $mon2 AND $yr != $yr2) + { + $dateparam1 = "F jS, Y -"; + $dateparam2 = "Y"; + $date_begin = date($dateparam1, $start); + $date_end = date($dateparam2, $end); + } + elseif ($day != $day2 AND $mon == $mon2 AND $yr == $yr2) + { + $dateparam1 = "F jS -"; + $dateparam2 = "jS, Y"; + $date_begin = date($dateparam1, $start); + $date_end = date($dateparam2, $end); + } + elseif ($day != $day2 AND $mon == $mon2 AND $yr != $yr2) + { + $dateparam1 = "F jS, Y -"; + $dateparam2 = "F jS, Y"; + $date_begin = date($dateparam1, $start); + $date_end = date($dateparam2, $end); + } + elseif ($yr == $yr2) + { + $dateparam1 = "F jS -"; + $dateparam2 = "F jS, Y"; + $date_begin = date($dateparam1, $start); + $date_end = date($dateparam2, $end); + } + else + { + $dateparam1 = "F jS, Y -"; + $dateparam2 = "F jS, Y"; + $date_begin = date($dateparam1, $start); + $date_end = date($dateparam2, $end); + } + + return($date_begin." ".$date_end); + } + + /** + * is_sub_id:Check to see if catid is sub of category + * @param $catid: the catid looking at + * @param $category: to see if it is in category + * @param $DB: Db object reference + * + * @return bool + * @access + **/ + function is_sub_id($catid,$category,&$DB) + { + if($category==$catid) + { + return(true); + } + $query = "select id,parent from bus_category where id = $catid"; + $data = $DB->db_auto_get_data($query); + $parent = $data[0]['parent']; + if($parent == 0) + { + return(false); + } + else + { + return( GLM_TEMPLATE::is_sub_id($parent,$category,&$DB) ); + } + } + + /** + * get_parent: get parent for this category + * @param $catid: id + * @param $DB: database obj + * + * @return int $parent + * @access + **/ + function get_parent($catid,&$DB) + { + $query = "SELECT parent FROM bus_category WHERE id = $catid ORDER BY pos"; + $data = $DB->db_auto_get_data($query); + return( $data[0]["parent"] ); + } + + /** + * get_sub_nav: + * @param $catid: + * @param $DB: + * + * @return + * @access + **/ + function get_sub_nav($catid,&$DB) + { + $parentid = GLM_TEMPLATE::get_parent($catid,&$DB); + //echo $parentid.'
    '; + $query = "SELECT id,category FROM bus_category WHERE parent = $parentid ".$this->active_query." ORDER BY pos"; + $data = $DB->db_auto_get_data($query); + if(is_array($data)) + { + $output = ''; + $output = GLM_TEMPLATE::clean_text($output); + echo $output; + } + return(false); + } + + /** + * has_subs: + * @param $catid: + * @param $DB: + * + * @return + * @access + **/ + function has_subs($catid,&$DB) + { + $query = "SELECT id FROM bus_category WHERE parent = $catid ".$this->active_query." ORDER BY pos"; + $data = $DB->db_auto_get_data($query); + if(is_array($data)) + { + return(true); + } + else + { + return(false); + } + } + + + /** + * get_top_parent:Get the highest level parent id (not 0 )for the category. + * @param $id: The catid for the page. + * @param $DB: obj + * + * @return int $parent + * @access + **/ + function get_top_parent($id,&$DB) + { + if( $id == 0 ) + { + return( 0 ); + } + $qs = "select parent from bus_category where id = $id"; + $parentrow = $DB->db_auto_get_data( $qs ); + if($parentrow[0]['parent'] == 0) + { + return($id); + } + else + { + return( GLM_TEMPLATE::get_top_parent($parentrow[0]['parent'],&$DB) ); + } + } + + /** + * show_catimg:output the category image. + * @param $catid: The catid for the page. + * + * @return void + * @access + **/ + function show_catimg($catid) + { + $query = "SELECT image FROM bus_category WHERE id = $catid"; + $data = $this->DB->db_auto_get_data($query); + if($data[0]["image"]!="") + { + $img = ''; + } + else + { + $img = 'Birchwood Construction
    '; + } + echo $img; + echo '
    '; + } + + + /** + * get_catheader:output the category name. + * @param $catid: The catid for the page + * @param $DB: db obj + * + * @return void + * @access + **/ + function get_catheader($catid,$DB) + { + $query = "SELECT category FROM bus_category WHERE id = $catid"; + $data = $DB->db_auto_get_data($query); + if($data[0]['category']!="") + { + $header = strip_tags($data[0]['category']); + } + else + { + $header = ''; + } + return( $header ); + } + + /** + * get_catintro: return the category page name. + * @param $catid: The catid for the page + * @param $DB: db obj + * + * @return void + * @access + **/ + function get_catintro($catid) + { + $query = "SELECT intro FROM bus_category WHERE id = $catid"; + $data = $this->DB->db_auto_get_data($query); + if($data[0]['intro']!="") + { + $header = strip_tags($data[0]['intro']); + } + else + { + $header = ''; + } + return( $header ); + } + + /** + * show_catheader: + * @param $catid: + * + * @return + * @access + **/ + function show_catheader($catid) + { + $query = "SELECT category FROM bus_category WHERE id = $catid"; + $data = $this->DB->db_auto_get_data($query); + if($data[0][category]!="") + { + $header = $data[0][category]; + } + else + { + $header = ' '; + } + echo $header; + } + + /** + * get_menu_string:get categories for the phplayermenu + * + * @return string + * @access + **/ + function get_menu_string() + { + $query = "SELECT id,parent,category FROM bus_category ORDER BY parent,pos"; + $data = $this->DB->db_auto_get_data($query); + $newdata = GLM_TEMPLATE::sort_childs($data); + $string = GLM_TEMPLATE::convert_to_thread($newdata,$newdata[0]); + return($string); + } + + function get_menu_array() + { + $query = "SELECT id,parent,category FROM bus_category WHERE active='t' ORDER BY parent,pos"; + $data = $this->DB->db_auto_get_data($query); + $newdata = GLM_TEMPLATE::sort_childs($data); + return $newdata; + } + + /** + * sort_childs: + * @param $threads: + * + * @return + * @access + **/ + function sort_childs($threads) + { + foreach($threads as $var=>$value) + { + $childs[$value["parent"]][$value["id"]] = $value; + } + return($childs); + } + + /** + * convert_to_thread: + * @param $threads: + * @param $thread: + * + * @return + * @access + **/ + function convert_to_thread($threads, $thread) + { + foreach($thread as $parent=>$value) + { + $this->whole_thread .= str_repeat(".",$this->thread_count); + $this->whole_thread .= "|".$value[category]; + $url = $this->get_seo_url( $value['id'] ); + $this->whole_thread .= "|".$url; + $this->whole_thread .="\n"; + if($threads[$parent]) + { + $this->thread_count++; + GLM_TEMPLATE::convert_to_thread($threads, $threads[$parent]); + } + } + $this->thread_count--; + return $this->whole_thread; + } + + function has_children($catid) + { + // returns number of children that $catid has + $qs="SELECT count(*) FROM bus_category WHERE parent=$catid"; + $row=$this->DB->db_auto_get_data($qs); + return $row[0]['count']; + } + + /** + * get_ancesters:get the ancesters for this category + * @param $catid: catid + * @param $count: starting counter + * + * @return array + * @access + **/ + function get_ancesters($catid,$count) + { + if($catid) + { + $query = "SELECT id,category,parent + FROM bus_category + WHERE id = ".$catid." + ".$this->active_query; + $res = $this->DB->db_auto_get_data($query); + $id = $res[0]['id']; + $parent = $res[0]['parent']; + $category = $res[0]['category']; + $this->ancesters[$count]['id'] = $id; + $this->ancesters[$count]['label'] = $category; + + $url = $this->get_seo_url( $id ); + $this->ancesters[$count]['link'] = $url; + GLM_TEMPLATE::get_ancesters($parent,$count+1,$conn); + + return (array_reverse($this->ancesters) ); + } + } + function meta_tags() + { + $query = "select description from bus_category where id = ".$this->catid; + $data = $this->DB->db_auto_get_data( $query ); + $description = substr( strip_tags( $data[0]['description'] ), 0, 100 ); + return( $description ); + } + + function title() + { + $query = "select category,intro from bus_category where id = ".$this->catid; + $data = $this->DB->db_auto_get_data( $query ); + if( $data[0]['intro'] ) + { + $title = strip_tags( $data[0]['intro'] ); + } + else + { + $title = strip_tags( $data[0]['category'] ); + } + return( $title.' - ' ); + } + + function get_bottom_nav($parent=0) + { + $return=''; + $qs="SELECT id, category FROM bus_category WHERE id != 1 and parent=$parent ORDER BY pos ASC"; + $row=$this->DB->db_auto_get_data($qs); + if( $GLOBALS['GLM_SERVER_ID'] == 'ws1.gaslightmedia.com' ) + { + $links[] = 'Home'; + } + else + { + $links[] = 'Home'; + } + if( !is_array( $row ) ) + { + return FALSE; + } + else + { + for( $i=0; $iget_seo_url( $row[$i]['id'] ); + $links[] = ''.$row[$i]['category']."\n"; + } + if( is_array( $links) ) + { + $return = implode(" | ",$links); + } + return $return; + } + } + + + /** + * make_ul_menu: create url list of categories + * @param $parent: parent to start from + * @param $$url='': page to go to + * @param $$catid=0: + * + * @return + * @access + **/ + function make_ul_menu( $parent = 0 ) + { + $qs = "SELECT id,category FROM bus_category WHERE parent=$parent AND active='t' ORDER BY pos"; + $data = $this->DB->db_auto_get_data($qs); + if(!is_array($data)) + { + return( false ); + } + else + { + foreach( $data as $key => $row ) + { + $url = $this->get_seo_url( $row['id'] ); + $return.="
  • ".'catid == $row['id'] ) + { + $return .= ' id="current"'; + } + $return .= '>'.$row['category'].""; + if( !$GLOBALS['non_active'] && $this->has_subs( $row['id'], &$this->DB ) && + ( $this->is_sub_id( $this->catid, $row['id'], &$this->DB ) || $this->catid == $row['id'] ) ) + { + $ret2 = $this->make_ul_menu( $row['id'] ); + $return.=$ret2; + $return.=""; + } + $return .= '
  • '; + } + + if( $parent == 0 ) + { + return '"; + } + else + { + return '
      '.$return."
    \n"; + } + } + } + function make_custom_menu($parent,$url='',$onhome=0) + { + $url==''?$url=$_SERVER['PHP_SELF']:''; + //$url=BASE_URL; + if($onhome==1) + { + //$opt="AND onhome='t' "; + $qs="SELECT id,category,image FROM bus_category WHERE onhome='t' AND active='t' ORDER BY homepos ASC"; + }else + { + $qs="SELECT id,category,image FROM bus_category WHERE parent=$parent $opt AND active='t' ORDER BY pos"; + } + + $row=$this->DB->db_auto_get_data($qs); + if(!is_array($row)) + { + return FALSE; + }else + { + $z=1; // used to find the 3rd image + for($i=0;$iget_seo_url( $row[$i]['id'] ); + $return.='$brtag\n"; + } + return $return; + } + } + + /** + * print_ancesters:print out the ancesters + * @param $catid: the id to start at. + * + * @return + * @access + **/ + function print_ancesters($catid) + { + $string = GLM_TEMPLATE::get_ancesters($catid,0); + if(is_array($string)) + { + if(count($string) > 1) + { + $url = $this->get_seo_url( 1 ); + $outarray[] = 'Home'; + } + for($i=0;$i<$end;$i++) + { + $outarray[] = ''.$string[$i]["label"].''; + } + $outarray[] = $this->get_catheader( $catid, &$this->DB ); + if( is_array( $outarray ) && count( $outarray ) > 1 ) + { + $out .= implode( " » ", $outarray ); + } + } + return( '' ); + } + + /** + * build_picklist: + * @param $fieldname: + * @param $data: + * @param $selected: + * @param $$type = "standard": + * @param $$auto = 0: + * @param $$width = NULL : + * + * @return + * @access + **/ + function build_picklist( $fieldname, $data, $selected, $type = "standard",$auto = 0,$width = NULL ) + { + if(!is_array($selected)) + { + $sel[0] = $selected; + } + else + { + $sel = $selected; + } + if($auto == 1) + { + $autosubmit = "onChange=\"form.submit()\""; + } + if($width) + { + $autosubmit .= "style=\"width:".$width."px;\""; + } + switch( $type ) + { + case "multiple": + $str = "\n"; + for( $i=0 ; $i".$data[$i]."\n"; + } + break; + + case "standard": + default: + $str = "\n"; + return( $str ); + } + + /** + * keyword_replace: + * @param $string: + * + * @return + * @access + **/ + function keyword_replace($string) + { + //return($string); + $page = "main.phtml"; + if($search = strstr($string,"{")) + { + if(ereg("\{([A-Za-z0-9\&\-\,\'\" ]*)\}",$string,$needle)) + { + if($needle[0] != "") + { + $qs = "SELECT id,category + FROM bus_category + WHERE trim(keyword) = '".trim($needle[1])."'"; + + $keyres = $this->DB->db_auto_get_data($qs); + $parent = $this->get_top_parent($keyres[0]['id'],&$this->DB); + $url = $this->get_seo_url( $keyres[0]['id'] ); + $replacement = "".$keyres[0]['category'].""; + $string = str_replace($needle[0],$replacement,$string); + } + } + else{ + return($string); + } + if($search = strstr($string,"{")) + return($this->keyword_replace($string)); + } + return($string); + } + /** + * getIdFromName: + * @param $name: + * @param $table: + * @param $DB: + * + * @return + * @access + **/ + function get_id_from_name( $name, $table, &$DB) + { + if( $name == "" ) + { + return( 0 ); + } + if( is_numeric( $name ) ) + { + return( $name ); + } + if( ereg("(.*)/$",$name,$tmp) ) + { + $name = $tmp[1]; + } + $category = "category"; + if( ereg("-([0-9]*)$",$name,$tmp ) ) + { + $id = $tmp[1]; + return( $id ); + } + // should already be returning id at this point + // putting the _id on the end of all url's as + // the other way is very inifiecent for the database. + $name = str_replace( "-"," ",$name ); + $query = "select id from $table where trim(lower(replace(replace(replace(replace(replace(replace($category,'\'',''),'/',''),'-',' '),'#',''),'&',''),'?',''))) = '".trim(strtolower($name))."'"; + $data = $DB->db_auto_get_data( $query ); + if( is_array( $data ) ) + { + foreach( $data as $key=>$val ) + { + $catid = $val['id']; + } + return( $catid ); + } + else + { + return( 0 ); + } + } + + function get_base_url( $id ) + { + if( $this->pages[$id] ) + { + $page = $this->pages[$id]; + } + else + { + $page = $this->pages['default']; + } + if( $GLOBALS['GLM_SERVER_ID'] == 'ws1.gaslightmedia.com' && $id == 1 ) + { + $page = ''; + } + return( $page ); + } + + /** + * getCategoryName: + * @param $id: + * @param $table: + * @param $&$DB : + * + * @return + * @access + **/ + function get_category_name( $id, $table,&$DB ) + { + if( !is_numeric( $id ) ) + { + return( false ); + } + if($table == "class_category") + { + $category = "name"; + } + else + { + $category = "category"; + } + $query = "select $category from $table where id = $id"; + $data = $DB->db_auto_get_data( $query ); + if( is_array( $data ) ) + { + + $add = '-'.$id; + if( $data[0]['category'] ) + { + $category = $data[0]['category'].$add; + } + elseif( $data[0]['name']) + { + $category = $data[0]['name'].$add; + } + else + { + $category = $add; + } + return( $category ); + } + } + + + /** + * setNameUrl: + * @param $$name : + * + * @return + * @access + **/ + function set_name_url( $name ) + { + $name = strtolower( trim( str_replace( " ","-",$name ) ) ); + $name = str_replace( "/","",$name ); + $name = str_replace( "#","",$name ); + $name = str_replace( "&","",$name ); + $name = str_replace( "?","",$name ); + $name = str_replace( "'","",$name ); + return( $name ); + } + + /** valid email + Checks for a valid format and good (mx check) + email address. + @param string email the email address as string. + @return boolean + */ + function valid_email ($email) { + if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$", $email, $check)) { + if ( getmxrr(substr(strstr($check[0], '@'), 1), $validate_email_temp) ) { + return TRUE; + } + } + return FALSE; + } +} +?> diff --git a/classes/class_template.mshp.inc b/classes/class_template.mshp.inc new file mode 100755 index 0000000..0e871c9 --- /dev/null +++ b/classes/class_template.mshp.inc @@ -0,0 +1,2300 @@ +set_catid( $catid ); +// $this->set_id( $id ); + $this->set_DB( $DB ); + $this->header_begin = "

    "; // class="content" should not be used anymore + $this->header_end = "

    "; // create style for p h1 h2 tags if needed try to keep it clean + $this->subheader_begin = "

    "; // should not be using h3 here duh go from 1 to 2 instead + $this->subheader_end = "

    "; // like your suppose to + $this->img_alternate = 0; // for alternating images set to 1 else leave alone + $this->img_align = ""; // the starting postion for images change to left if needed + $this->img_size = RESIZED; // img_size are RESIZED,MIDSIZED,THUMB do not use ORIGINAL + $this->whole_thread = ""; // do not touch this it is used for menu generation + $this->thread_count = 1; // also used for menu generation + $this->set_pages( $GLOBALS['PAGES'] ); + $this->set_parks(); + $this->set_news(); + $this->set_park_maps(); + $this->set_park_tours(); + } + + /** + * set_park_maps: create array with links tot the maps pages. + * + * @return void + * @access + **/ + function set_park_maps() + { + $maps[6] = 143; + $maps[7] = 144; + $maps[8] = 145; + $maps[9] = 146; + $maps[10] = 147; + $maps[11] = 148; + $this->maps =& $maps; + } + + function meta_tags() + { + $query = "select description from bus_category where id = ".$this->catid; + $data = $this->DB->db_auto_get_data( $query ); + $description = substr( strip_tags( $data[0]['description'] ), 0, 50 ); + return( $description ); + } + + function title() + { + $query = "select category,intro from bus_category where id = ".$this->catid; + $data = $this->DB->db_auto_get_data( $query ); + if( $data[0]['intro'] ) + { + $title = strip_tags( $data[0]['intro'] ); + } + else + { + $title = strip_tags( $data[0]['category'] ); + } + return( $title.' - ' ); + } + + function set_park_tours() + { + $tours[6] = 'http://vm.mackinacparks.com/index.php?category=1'; + $tours[7] = 'http://vm.mackinacparks.com/index.php?category=4'; + $tours[8] = 'http://vm.mackinacparks.com/index.php?category=2'; + $tours[9] = 'http://vm.mackinacparks.com/index.php?category=3'; + $tours[10] = 'http://vm.mackinacparks.com/index.php?category=6'; + $tours[11] = 'http://vm.mackinacparks.com/index.php?category=5'; + $this->tours =& $tours; + } + + /** + * set_news: + * + * @return + * @access + **/ + function set_news() + { + $news[77] = 2; + $news[78] = 3; + $news[17] = 1; + $news[80] = 4; + $news[93] = 6; + $news[84] = 5; + $news[6] = 9; + $news[7] = 10; + $news[8] = 11; + $news[9] = 12; + $news[10] = 13; + $news[11] = 14; + + $this->news =& $news; + } + + /** + * under_parks: + * @param $$id : + * + * @return + * @access + **/ + function under_parks( $id ) + { + foreach( $this->parks as $k => $park ) + { + if( $this->is_sub_id( $id, $park, $this->DB ) ) + { + return( $park ); + } + } + return( false ); + } + + /** + * in_parks: check to see if the id is in the parks + * @param $$id : the id of the bus_category + * + * @return false if not a park or park id if it is one + * @access public + **/ + function in_parks( $id ) + { + foreach( $this->parks as $k => $park ) + { + if( $id == $park ) + { + return( $park ); + } + } + return( false ); + } + + /** + * set_parks: set up the parks array 6 - 11 + * + * @return void + * @access public + **/ + function set_parks() + { + $parks = array(6,7,8,9,10,11); + $this->parks = $parks; + } + + function get_park_events() + { + if( $park_id = $this->in_parks( $this->catid ) ) + { + // get the topic name from the topic table + $query = "select descr from topic where id = $park_id"; + $event_topic_data = $this->DB->db_auto_get_data( $query ); + + $query = "SET DATESTYLE TO 'SQL,US';select id,header,img,descr,bdate,edate from event where topicid = $park_id"; + $event_data = $this->DB->db_auto_get_data( $query ); + if( is_array( $event_data ) ) + { + $out .= '

    Special Events at '.$event_topic_data[0]['descr'].'

    '; + foreach( $event_data as $key => $val ) + { + $date = $this->get_event_date($val['bdate'],$val['edate'],'Postgres'); + // $image = ( $val['img'] ) ? '': ''; + $park = $this->get_seo_url( $park_id ); + $event_name = $this->set_name_url( $val['header'] ); + $link = ''.$val["header"].''; + $out .= 'events-divider (1K)' . + $link . + $date; + } + $out .= '
    '; + } + return( $out ); + } + else + { + return( false ); + } + } + + /** + * set_DB: set the DB up to be that of the global one if it exists + * @param $$DB : the DB object + * + * @return void + * @access public + **/ + function set_DB( $DB ) + { + if( isset( $DB ) ) + { + $this->DB =& $DB; + } + else + { + $this->DB =& new GLM_DB(); + } + } + + /** + * set_pages: grab the globals for the pages an use this for + the pages array for the class + * + * @return void + * @access public + **/ + function set_pages( $pages ) + { + if( is_array( $pages ) ) + { + $this->pages =& $pages; + } + } + + /** + * set_catid:Set the class catid var + * @param $catid: $catid + * + * @return void + * @access public + **/ + function set_catid( $catid ) + { + if( is_numeric( $catid ) ) + { + $this->catid = $catid; + } + else + { + $this->catid = 1; + } + } + + function set_id( $id ) + { + if( is_numeric( $id ) ) + { + $this->id = $id; + } + else + { + $this->id = 1; + } + } + + /** + * set_contact:Set the contact string + + * @param $text: The text as string + * @param $email: email if givin + * + * @return string $text + * @access + **/ + function set_contact( $text, $email ) + { + if( $email != "" ) + { + $text = ""; + } + else + { + $text = '

    Contact Name: '.$text.'

    '; + } + return($text); + } + + /** + * set_text:Set the contact string + * @param $text: The text as string + * + * @return string $text + * @access + **/ + function set_text( $text ) + { + if("" == str_replace("
    ","",trim($text))) + { + return(false); + } + if( $text != "" ) + { + $text = str_replace( "imgfloat["$image"] = $align; + if( is_file( ORIGINAL_PATH.$image ) ) + { + $size2 = getimagesize(ORIGINAL_PATH.$image); + $width = $size2[0] + 0; + $height = $size2[1] + 0; + if( !$this->catimg ) + { + //$img = '
    '; + } + $img .= ''.$image.''; + if( $title ) + { + $img .= '
    '.$title.'
    '; + } + if( !$this->catimg ) + { + //$img .= '
    '; + } + return( '
    '.$img.'
    ' ); + } + } + } + + /** + * set_url:Set the url string + * @param $url: The url + * @param $text: The text as string + * + * @return string $text + * @access + **/ + function set_url( $url, $text ) + { + if( $url != "" ) + { + if( !$text ) + { + $text = $url; + } + if( strtolower( substr( $url, 0, 7 ) ) == "https://" ) + { + $url = '

    '.$text.'

    '; + } + else + { + $url = '

    '.$text.'

    '; + } + } + return( $url ); + } + + /** + * set_email:Set the email string + * @param $email: The email as string + * @param $contact: The contactname this is used as the link text + * + * @return string $text + * @access + **/ + function set_email( $email, $contact ) + { + if( $email != "" ) + { + if( $contact != "" ) + { + $email = '

    Contact:  '.$contact.'

    '; + } + else + { + $email = '

    Email:  '.$email.'

    '; + } + } + return( $email ); + } + + /** + * set_header:Set the header string + * @param $text: The text as string + * + * @return string $text + * @access + **/ + function set_header( $text ) + { + if( $text != "" ) + { + $text = $this->header_begin.$text.$this->header_end; + } + return( $text ); + } + + /** + * set_subheader:Set the subheader string + * @param $text: The text as string + + * + * @return string $text + * @access + **/ + function set_subheader( $text ) + { + if( $text != "" ) + { + $text = $this->subheader_begin.$text.$this->subheader_end; + } + return( $text ); + } + + /** + * set_phone:Set the phone string + * @param $text: The text as string + * + * @return string $text + * @access + **/ + function set_phone( $text ) + { + if( $text != "" ) + { + $text = '

    Phone:  '.$text.'

    '; + } + return( $text ); + } + + /** + * set_fax:Set the fax string + * @param $text: The text as string + * + * @return string $text + * @access + **/ + function set_fax( $text ) + { + if( $text != "" ) + { + $text = '

    Fax:  '.$text.'

    '; + } + return( $text ); + } + + /** + * set_file:Set the file string + * @param $text: The text as string + * @param $name: The file name displayed + * + * @return string $text + * @access + **/ + function set_file( $text, $name,$filetext ) + { + if( $text != "" ) + { + $outtext = '

    '; + if($name) + { + $outtext .= $name; + } + else + { + $outtext .= $text; + } + $outtext .= ''; + if( $filetext ) + { + $outtext .= '
    '.$filetext; + } + $outtext .= '

    '; + } + return( $outtext ); + } + + /** + * set_address:set_address + * @param $data: data contain the address info for display. + * + * @return string $address + * @access + **/ + function set_address( $data ) + { + $address = ""; + if( $data["address"] ) + { + $address .= $data["address"]; + } + if( $data["city"] && $data["state"] && $data["zip"] ) + { + $address .= '
    '.$data["city"].', '.$data["state"].' '.$data["zip"]; + } + elseif( $data["city"] && $data["state"] ) + { + $address .= '
    '.$data["city"].', '.$data["state"]; + } + elseif( $data["city"] ) + { + $address .= '
    '.$data["city"]; + } + if( $address != "" ) + { + return( '

    '.$address.'

    ' ); + } + } + + function get_template() + { + $query = "select template from bus_category where id = ".$this->catid.";"; + $data = $this->DB->db_auto_get_data( $query ); + return( $data[0]['template'] ); + } + /** + * get_all:Does the query and set_data calls boths arrays + * + * @return void + * @access + **/ + function get_all() + { + $catid = $this->catid; + $template = $this->get_template(); + switch($template) + { + case "5": + $this->img_align = "right"; + $this->img_alternate = 1; + break; + + case "4"; + $this->img_align = "right"; + $this->img_alternate = 1; + break; + + case "3"; + $this->img_align = "left"; + $this->img_alternate = 1; + break; + + case "2": + $this->img_align = "left"; + $this->img_alternate = 0; + break; + + case "1"; + $this->img_align = "right"; + $this->img_alternate = 0; + break; + + default: + break; + } + $this->catimg = 1; + $cat_query = "SELECT * + FROM bus_category + WHERE id = $catid + AND active = 't' + ORDER BY pos"; + $res = $this->set_data( $this->DB->db_auto_get_data( $cat_query ) ); + $this->data = $res[0]; + $this->catimg = 0; + $item_query = "SELECT b.* + FROM bus b LEFT OUTER JOIN bus_category_bus bcb + ON (bcb.busid = b.id) + WHERE bcb.catid = $catid + ORDER BY bcb.pos"; + $this->items = $this->set_data( $this->DB->db_auto_get_data( $item_query ) ); + } + + /** + * set_data:Calls each function of the class + * based on the key af the array $data[0][$key] + * @param $data: The input array from db query + * + * @return array data The finished array + * @access + **/ + function set_data( $data ) + { + if( is_array( $data ) ) + { + foreach( $data as $k => $val ) + { + foreach( $val as $key => $value ) + { + if( strstr( $key, "image" ) && $value != "" ) + { + $titletag = ( $data[$k]['category'] ) ? $data[$k]['category'] : $data[$k]['name']; + $data[$k][$key."_name"] = $value; + $data[$k][$key] = $this->set_img( $value, $this->img_align, $data[$k][$key."name"] ); + if( !strstr( $key, "name" ) ) + { + if( $this->img_align == "right" && $this->img_alternate ) + { + $this->img_align = "left"; + } + elseif( $this->img_alternate ) + { + $this->img_align = "right"; + } + } + } + elseif( strstr($key,"file") && strstr($key,"name") && $value!="" ) + { + } + elseif( strstr($key,"url") && strstr($key,"name") && $value!="" ) + { + } + elseif( strstr($key,"descr") && $value != "" ) + { + $data[$k][$key] = GLM_TEMPLATE::set_text( $value ); + } + elseif( $key == "contactname" && $value != "" ) + { + $data[$k][$key] = GLM_TEMPLATE::set_contact( $value, $data[$k]['email'] ); + } + elseif($key == "name" && $value!="") + { + $data[$k][$key] = GLM_TEMPLATE::set_subheader( $value ); + } + elseif( strstr( $key, "header" ) && $value != "" ) + { + $data[$k][$key] = GLM_TEMPLATE::set_subheader( $value ); + } + elseif( $key == "intro" && $value != "" ) + { + $data[$k][$key] = GLM_TEMPLATE::set_header( $value ); + } + elseif( $key == "category" && $value != "" ) + { + $data[$k][$key] = GLM_TEMPLATE::set_header( $value ); + } + elseif( $key == "url" && $value != "" ) + { + $data[$k][$key] = GLM_TEMPLATE::set_url( $value, $data[$k]["urlname"] ); + } + elseif( $key == "email" && $value!="") + { + $data[$k][$key] = GLM_TEMPLATE::set_email( $value, $data[$k]["contactname"] ); + } + elseif( $key == "phone" && $value != "" ) + { + $data[$k][$key] = GLM_TEMPLATE::set_phone($value); + } + elseif( $key == "fax" && $value != "" ) + { + $data[$k][$key] = GLM_TEMPLATE::set_fax( $value ); + } + elseif (strstr( $key, "file" ) && $value!="") + { + $data[$k][$key] = GLM_TEMPLATE::set_file( $value, $data[$k][$key.'name'],$data[$k][$key."text"] ); + } + elseif( $key == "address" ) + { + $data[$k][$key] = GLM_TEMPLATE::set_address( $data[$k] ); + } + elseif( $key == "id" ) + { + $data[$k][$key] = $value; + } + else + { + $data[$k][$key] = GLM_TEMPLATE::set_text( $value ); + } + } + } + return( $data ); + } + return( false ); + } + + /** + * load_static_page:using object buffer include the page $catid.phtml from static dir + and return it as string + * + * @return string $text + * @access + **/ + function load_static_page() + { + if( file_exists( BASE."static/".$this->catid.".phtml" ) ) + { + ob_start(); + include("static/".$this->catid.".phtml"); + $text = ob_get_contents(); + ob_end_clean(); + return($text); + } + } + + /** + * clean_text:Do some text clean up. + * @param $output: + * + * @return string text cleaned + * @access + **/ + function clean_text($output) + { + $output = str_replace("
    ","
    ",$output); + $output = str_replace("


    ","",$output); + return($output); + } + + /** + * get_category: grab just category contents + * @param $catid: id of bus_category + * @param $DB: + * @param $$showimg=1: weather or not to show category image + * + * @return string $output + * @access public + **/ + function get_category( $showimg = 1,$showbread = 1 ) + { + if( $showbread == 1 ) + { + $output .= $this->print_ancesters( $this->catid ); + } + $cat_query = "SELECT * + FROM bus_category + WHERE id = ".$this->catid." AND active='t' + ORDER BY pos"; + //$res = GLM_TEMPLATE::set_data($DB->db_auto_get_data($cat_query)); + if( !is_array( $this->data ) ) + { + $res = $this->set_data( $this->DB->db_auto_get_data( $cat_query ) ); + $data = $res[0]; + } + else + { + $data = $this->data; + } + $output .= '
    '; + if($data["image"] || $data["description"] || $data["intro"] ) + { + //$output .=$data["intro"]." "; + if($showimg == 1) + { + $output .= '
    '.$data["image"].'
    '.$data["imagename"]."
    "; + } + $output .=$data["intro"]." "; + if( $this->catid == 162 ) + { + $output .= $this->load_static_page(); + } + $output .=$data["description"]." "; + } + else + { + if( $this->catid == 162 ) + { + $output .= $this->load_static_page(); + } + } + $output .= '
    '; + $output = GLM_TEMPLATE::clean_text($output); + return( $output ); + + } + + /** + * has_events: check to see if this park has events + * @param $$id : park id + * + * @return bool + * @access public + **/ + function has_events( $id ) + { + $query = "select id from event where topicid = $id and edate >= CURRENT_DATE"; + $data = $this->DB->db_auto_get_data( $query ); + if( is_array( $data ) ) + { + return( true ); + } + else + { + return( false ); + } + } + + /** + * has_photos: function to check to see if this catid has any sub that are photos + * NOTE: this is only run for the parks section. + * @param $$id : + * + * @return + * @access + **/ + function has_photos( $id ) + { + $query = "select id from bus_category where parent = $id and type = 1 and active = 't';"; + $data = $this->DB->db_auto_get_data( $query ); + if( is_array( $data ) ) + { + return( true ); + } + else + { + return( false ); + } + } + + + /** + * has_books: function to check to see if this catid has any sub that are books + * NOTE: this is only run for the parks section. + * @param $$id : + * + * @return + * @access + **/ + function has_books( $id ) + { + $query = "select id from bus_category where parent = $id and type = 3 and active = 't';"; + $data = $this->DB->db_auto_get_data( $query ); + if( is_array( $data ) ) + { + return( true ); + } + else + { + return( false ); + } + } + /** + * has_jobs: function to check to see if this catid has any sub that are jobs + * NOTE: this is only run for the parks section. + * @param $$id : + * + * @return + * @access + **/ + function has_jobs( $id ) + { + $query = "select postype from availposition where postype = $id;"; + $data = $this->DB->db_auto_get_data( $query ); + if( is_array( $data ) ) + { + return( true ); + } + else + { + return( false ); + } + } + + /** + * has_exhibits: function to check to see if this catid has any sub that are exhibits + * NOTE: this is only run for the parks section. + * @param $$id : + * + * @return + * @access + **/ + function has_exhibits( $id ) + { + $query = "select id from bus_category where parent = $id and type = 2 and active = 't';"; + $data = $this->DB->db_auto_get_data( $query ); + if( is_array( $data ) ) + { + return( true ); + } + else + { + return( false ); + } + } + + /** + * get_parks_page: custom page builder for the parks site + * + * @return string $out + * @access public + **/ + function get_parks_page() + { + if( $park = $this->under_parks( $this->catid ) ) + { + $out .= $this->get_resources( $park ); + $out .= $this->get_page( 0 ); + } + else + { + $out .= $this->get_page(); + } + return( $out ); + } + + /** + * get_resources: + * + * @return + * @access + **/ + function get_resources( $park ) + { + switch( $park ) + { + case 1: + $return = true; + break; + + case 6: + $logo = 'logo-fm'; + break; + + case 7: + $logo = 'logo-cm'; + break; + + case 8: + $logo = '';//'logo-hd'; + break; + + case 9: + $logo = 'logo-misp'; + break; + + case 10: + $logo = 'logo-hmc'; + break; + + case 11: + $logo = 'logo-ompl'; + break; + + } + $query = "select image,imagename from bus_category where id = ".$this->catid; + $data = $this->DB->db_auto_get_data( $query ); + if( is_file( RESIZED_PATH.$data[0]['image'] ) ) + { + $size2 = getimagesize(ORIGINAL_PATH.$data[0]["image"]); + $width = $size2[0] + 0; + $height = $size2[1] + 0; + $image = ''.$data[0]['image'].''; + } + if( $return == 1 ) + { + return( false ); + } + $image_caption = ( $data[0]['imagename'] ) ? '
    '.strip_tags( $data[0]['imagename'] ):''; + $out .= '
    + '.$logo.' + '.$image.' + '.$image_caption.' +
    More information about '.$this->get_catheader($park,$this->DB).':
    '; + if($this->tours[$park]) + { + $out .= 'virtual (1K)'; + } + if( $this->maps[$park] ) + $out .= 'map (1K) + '; + if( $this->has_photos( $park ) ) + { + $out .= 'photos (1K) + '; + } + if( $this->has_exhibits( $park ) ) + { + $out .= 'exhibits (1K)'; + } + + if( $this->has_books( $park ) ) + { + $out .= 'books (1K)'; + } + +// if( $this->has_jobs( $this->catid ) ) +// { + $out .= 'jobs (1K)'; +// } + + $out .= '
    '; + return( $out ); + } + + /** + * get_page: replacing template_parser with get-page function + * + * @return + * @access + **/ + function get_page( $showimg = 1 ) + { + if( !is_array( $this->data ) ) + { + $this->get_all(); + } + $out .= $this->get_category( $showimg ); + $out .= $this->get_listings(); + if( $this->news[$this->catid] ) + { + require_once('classes/class_news.inc'); + $News =& new GLM_NEWS( $this->news[$this->catid] ); + $out .= $News->get_news_page(); + + } + if( $this->catid == 60 ) + { + require_once('classes/class_exhibits.inc'); + $Exhibits =& new GLM_EXHIBITS( $this->catid ); + $out .= $Exhibits->get_all_exhibits(); + } + if( $this->catid == 17 ) + { + require_once('classes/class_news.inc'); + $News =& new GLM_NEWS( $this->catid ); + $out .= $News->get_all_news(); + } + return( $out ); + } + + function get_img_name( $id ) + { + $query = "select image from bus where id = $id;"; + $data = $this->DB->db_auto_get_data( $query ); + return( $data[0]['image'] ); + } + + /** + * template_parser:This function creates data + * and items arrays and does the output for the page. + * + * @return void + * @access + **/ + function get_listings() + { + // grab category and items into data and items respectfully + if( !is_array( $this->data ) ) + { + $this->get_all(); + } + + // load any static category page from the static directory + // hard codded content would have $catid.phtml page for it + if( $this->catid != 162 ) + { + $output .= $this->load_static_page(); + } + /* + echo '
    ';
    +			print_r($this->imgfloat);
    +		echo '
    '; + */ + switch($this->type) + { + + default: + if(is_array($this->items)) + { + foreach($this->items as $key=>$val) + { + + $img = $this->get_img_name( $val['id'] ); + $float = $this->imgfloat[$img]; + switch( $float ) + { + case "left": + $output .= '
    '; + break; + + case "right": + $output .= '
    '; + break; + + default: + $output .= '
    '; + break; + } + // items can be moved around as needed + //$output .= '
    '; + $output .= '

    '; + $output .= $val["image"]; + $output .= $val["name"]; + $output .= $val["address"]; + $output .= $val["description"]; + $output .= $val["contactname"]; + $output .= $val["email"]; + $output .= $val["phone"]; + $output .= $val["fax"]; + $output .= $val["url"]; + $output .= $val["file"]; + $output .= $val["file2"]; + $output .= $val["file3"]; + $output .= '
    '; + } + } + break; + } + $output = GLM_TEMPLATE::clean_text($output); + return( $output ); + } + + /** + * sub_nav:Create a sub navigation + * @param $catid: The catid for the page + * + * @return void + * @access + **/ + function sub_nav( $catid,$level = 1 ) + { + if( $this->in_parks( $catid ) ) + { + $query = "select id,category from bus_category where id = ".$this->catid; + } + else + { + $top = $this->get_parentid( $catid, &$this->DB ); + $query = "SELECT id,category FROM bus_category WHERE active = 't' and parent = $top ORDER BY pos"; + } + $data = $this->DB->db_auto_get_data($query); + if( is_array( $data ) ) + { + $out .= ''; + } + return( $out ); + } + + /** + * get_home_events: get events flaged as home events + * @param $DB: DB reference to DB obj + + * + * @returnvoid + * @access + **/ + function get_home_events(&$DB) + { + $query = "SET DATESTYLE TO 'SQL,US';SELECT id,header,substr(descr,0,30) as descr, bdate, edate + FROM event WHERE home = 't'"; + $data = $DB->db_auto_get_data($query); + if(is_array($data)) + { + foreach($data as $key=>$value) + { + $id = $value['id']; + $header = $value['header']; + $sdate = strtotime($value['bdate']); + $edate = strtotime($value['edate']); + $dates = GLM_TEMPLATE::get_event_date($sdate,$edate,"timestamp"); + $descr = $value['descr']; + $output .= "
    +
    +

    $header

    + $dates +

    $descr

    + +
    +
    "; + } + return($output); + } + } + + /** + * get_event_date: make the event date human readable + * @param $sdate: start date + * @param $edate: end date + * @param $dateType: dateType Postgres,etc + * + * @return string + * @access + **/ + function get_event_date($sdate,$edate,$dateType) + { + switch($dateType) + { + case "Postgres": + if(ereg("([0-9]{1,2})[/-]([0-9]{1,2})[/-]([0-9]{4})",$sdate,$spt)) + { + $mon = $spt[1]; + $day = $spt[2]; + $yr = $spt[3]; + } + + if(ereg("([0-9]{1,2})[/-]([0-9]{1,2})[/-]([0-9]{4})",$edate,$ept)) + { + $mon2 = $ept[1]; + $day2 = $ept[2]; + $yr2 = $ept[3]; + } + break; + + case "timestamp": + $mon = date("m",$sdate); + $day = date("d",$sdate); + $yr = date("Y",$sdate); + $mon2 = date("m",$edate); + $day2 = date("d",$edate); + $yr2 = date("Y",$edate); + break; + + }$start = mktime(0,0,0,$mon,$day,$yr); + $end = mktime(0,0,0,$mon2,$day2,$yr2); + if ($day == $day2 && $mon == $mon2 && $yr == $yr2) + { + $dateparam = "F jS, Y"; + $date_begin = date($dateparam, $start) ; + $date_end = ""; + } + elseif ($day == $day2 AND $mon == $mon2 AND $yr != $yr2) + { + $dateparam1 = "F jS, Y -"; + $dateparam2 = "Y"; + $date_begin = date($dateparam1, $start); + $date_end = date($dateparam2, $end); + } + elseif ($day != $day2 AND $mon == $mon2 AND $yr == $yr2) + { + $dateparam1 = "F jS -"; + $dateparam2 = "jS, Y"; + $date_begin = date($dateparam1, $start); + $date_end = date($dateparam2, $end); + } + elseif ($day != $day2 AND $mon == $mon2 AND $yr != $yr2) + { + $dateparam1 = "F jS, Y -"; + $dateparam2 = "F jS, Y"; + $date_begin = date($dateparam1, $start); + $date_end = date($dateparam2, $end); + } + elseif ($yr == $yr2) + { + $dateparam1 = "F jS -"; + $dateparam2 = "F jS, Y"; + $date_begin = date($dateparam1, $start); + $date_end = date($dateparam2, $end); + } + else + { + $dateparam1 = "F jS, Y -"; + $dateparam2 = "F jS, Y"; + $date_begin = date($dateparam1, $start); + $date_end = date($dateparam2, $end); + } + + return($date_begin." ".$date_end); + } + + /** + * is_sub_id:Check to see if catid is sub of category + * @param $catid: the catid looking at + * @param $category: to see if it is in category + * @param $DB: Db object reference + * + * @return bool + * @access + **/ + function is_sub_id($catid,$category,&$DB) + { + if($category==$catid) + { + return(true); + } + $query = "select id,parent from bus_category where id = $catid"; + $data = $DB->db_auto_get_data($query); + $parent = $data[0]['parent']; + if($parent == 0) + { + return(false); + } + else + { + return( GLM_TEMPLATE::is_sub_id($parent,$category,&$DB) ); + } + } + + /** + * get_parent: get parent for this category + * @param $catid: id + * @param $DB: database obj + * + * @return int $parent + * @access + **/ + function get_parent($catid,&$DB) + { + $query = "SELECT parent FROM bus_category WHERE id = $catid ORDER BY pos"; + $data = $DB->db_auto_get_data($query); + if(is_array($data)) + { + if( $data[0]["parent"] == 0 ) + { + return( $catid ); + } + else + { + return( $data[0]["parent"] ); + //return(GLM_TEMPLATE::get_parent($data[0]["parent"],&$DB)); + } + + } + else + { + return(false); + } + } + + /** + * get_sub_nav: + * @param $catid: + * @param $DB: + * + * @return + * @access + **/ + function get_sub_nav($catid,&$DB) + { + $parentid = GLM_TEMPLATE::get_parent($catid,&$DB); + //echo $parentid.'
    '; + $query = "SELECT id,category FROM bus_category WHERE active = 't' and parent = $parentid ORDER BY pos"; + $data = $DB->db_auto_get_data($query); + if(is_array($data)) + { + $output = ''; + $output = GLM_TEMPLATE::clean_text($output); + echo $output; + } + return(false); + } + + /** + * has_subs: + * @param $catid: + * @param $DB: + * + * @return + * @access + **/ + function has_subs($catid,&$DB) + { + $query = "SELECT id FROM bus_category WHERE active = 't' and parent = $catid ORDER BY pos"; + $data = $DB->db_auto_get_data($query); + if(is_array($data)) + { + return(true); + } + else + { + return(false); + } + } + + + /** + * get_parentid:Get the parent id for the category. + * @param $id: The catid for the page. + * @param $DB: obj + * + * @return int $parent + * @access + **/ + function get_parentid($id,&$DB,$levels = NULL) + { + if( $id == 0 ) + { + return( 0 ); + } + $qs = "select parent from bus_category where id = $id"; + $parentrow = $DB->db_auto_get_data( $qs ); + if($parentrow[0]['parent'] == 0) + { + return($id); + } + else + { + return( GLM_TEMPLATE::get_parentid($parentrow[0]['parent'],&$DB) ); + } + } + + /** + * show_catimg:output the category image. + * @param $catid: The catid for the page. + * + * @return void + * @access + **/ + function show_catimg($catid) + { + $query = "SELECT image FROM bus_category WHERE id = $catid"; + $data = $this->DB->db_auto_get_data($query); + if($data[0]["image"]!="") + { + $img = ''; + } + else + { + $img = 'Birchwood Construction
    '; + } + echo $img; + echo '
    '; + } + + + /** + * get_catheader:output the category name. + * @param $catid: The catid for the page + * @param $DB: db obj + * + * @return void + * @access + **/ + function get_catheader($catid,$DB) + { + $query = "SELECT category FROM bus_category WHERE id = $catid"; + $data = $DB->db_auto_get_data($query); + if($data[0]['category']!="") + { + $header = strip_tags($data[0]['category']); + } + else + { + $header = ''; + } + return( $header ); + } + + /** + * show_catheader: + * @param $catid: + * + * @return + * @access + **/ + function show_catheader($catid) + { + $query = "SELECT category FROM bus_category WHERE id = $catid"; + $data = $this->DB->db_auto_get_data($query); + if($data[0][category]!="") + { + $header = $data[0][category]; + } + else + { + $header = ' '; + } + echo $header; + } + + /** + * get_menu_string:get categories for the phplayermenu + * + * @return string + * @access + **/ + function get_menu_string() + { + $query = "SELECT id,parent,category FROM bus_category where active = 't' ORDER BY parent,pos"; + $data = $this->DB->db_auto_get_data($query); + $newdata = GLM_TEMPLATE::sort_childs($data); + $string = GLM_TEMPLATE::convert_to_thread($newdata,$newdata[0]); + return($string); + } + + /** + * sort_childs: + * @param $threads: + * + * @return + * @access + **/ + function sort_childs($threads) + { + foreach($threads as $var=>$value) + { + $childs[$value["parent"]][$value["id"]] = $value; + } + return($childs); + } + + /** !WARNING this is modified to only show the first two levels + * convert_to_thread: + * @param $threads: + * @param $thread: + * + * @return + * @access + **/ + function convert_to_thread($threads, $thread) + { + static $count; + foreach($thread as $parent=>$value) + { + $p = $this->get_base_url( $value['id'] ); + $this->whole_thread .= str_repeat(".",$this->thread_count); + $this->whole_thread .= "|".$value[category]; + $category = $this->get_seo_url( $value['id'] ); + $this->whole_thread .= "|".URL_BASE."$p/$category"; + $this->whole_thread .="\n"; + if($threads[$parent]) + { + if( $this->thread_count <= 1 ) + { + $this->thread_count++; + GLM_TEMPLATE::convert_to_thread($threads, $threads[$parent]); + } + } + } + + $count++; + $this->thread_count--; + return $this->whole_thread; + } + + /** + * get_ancesters:get the ancesters for this category + * @param $catid: catid + * @param $count: starting counter + * + * @return array + * @access + **/ + function get_ancesters($catid,$count) + { + if($catid) + { + $query = "SELECT id,category,parent + FROM bus_category + WHERE id = ".$catid." + AND active = 't'"; + $res = $this->DB->db_auto_get_data($query); + $id = $res[0]['id']; + $parent = $res[0]['parent']; + $category = $res[0]['category']; + $this->ancesters[$count]['id'] = $id; + $this->ancesters[$count]['label'] = $category; + + $url = $this->get_seo_url($id); + $this->ancesters[$count]['link'] = $this->get_base_url($id)."/$url"; + GLM_TEMPLATE::get_ancesters($parent,$count+1,$conn); + + return (array_reverse($this->ancesters) ); + } + } + + /** + * print_ancesters:print out the ancesters + * @param $catid: the id to start at. + * + * @return + * @access + **/ + function print_ancesters($catid) + { + $string = GLM_TEMPLATE::get_ancesters($catid,0); + if(is_array($string)) + { + if(count($string) > 1) + $outarray[] = 'Home'; + if( strstr( $GLOBALS['PHP_SELF'], 'news.phtml' ) ) + { + $end = count($string); + } + else + { + $end = count($string) - 1; + } + for($i=0;$i<$end;$i++) + { + /* + if( $i == count( $string ) - 1 ) + { + $outarray[] = $string[$i]['label']; + } + else + { + */ + $outarray[] = ''.$string[$i]["label"].''; + //} + } + if( is_array( $outarray ) && count( $outarray ) > 1 ) + { + $out .= implode( " » ", $outarray ); + } + } + return( '' ); + } + + /** + * build_picklist: + * @param $fieldname: + * @param $data: + * @param $selected: + * @param $$type = "standard": + * @param $$auto = 0: + * @param $$width = NULL : + * + * @return + * @access + **/ + function build_picklist( $fieldname, $data, $selected, $type = "standard",$auto = 0,$width = NULL ) + { + if(!is_array($selected)) + { + $sel[0] = $selected; + } + else + { + $sel = $selected; + } + if($auto == 1) + { + $autosubmit = "onChange=\"form.submit()\""; + } + if($width) + { + $autosubmit .= "style=\"width:".$width."px;\""; + } + switch( $type ) + { + case "multiple": + $str = "\n"; + for( $i=0 ; $i".$data[$i]."\n"; + } + break; + + case "standard": + default: + $str = "\n"; + return( $str ); + } + + /** + * keyword_replace: + * @param $string: + * + * @return + * @access + **/ + function keyword_replace($string) + { + //return($string); + $page = "main.phtml"; + if($search = strstr($string,"{")) + { + if(ereg("\{([A-Za-z0-9\&\-\,\'\" ]*)\}",$string,$needle)) + { + if($needle[0] != "") + { + $qs = "SELECT id,category + FROM bus_category + WHERE trim(keyword) = '".trim($needle[1])."'"; + + $keyres = $this->DB->db_auto_get_data($qs); + $parent = $this->get_parentid($keyres[0]['id'],&$this->DB); + $page = $this->get_base_url( $keyres[0]['id'] ); + $page_name = $this->get_seo_url( $keyres[0]['id'] ); + $replacement = "".$keyres[0]['category'].""; + $string = str_replace($needle[0],$replacement,$string); + } + } + else{ + return($string); + } + if($search = strstr($string,"{")) + return($this->keyword_replace($string)); + } + return($string); + } + /** + * getIdFromName: + * @param $name: + * @param $table: + * @param $DB: + * + * @return + * @access + **/ + function get_id_from_name( $name, $table, &$DB) + { + if( $name == "" ) + { + return( 0 ); + } + if( is_numeric( $name ) ) + { + return( $name ); + } + if( ereg("(.*)/$",$name,$tmp) ) + { + $name = $tmp[1]; + } + if( $table == "topic" ) + { + $category = "descr"; + } + elseif( $table == "postype" ) + { + $category = "postypedata"; + } + else + { + $category = "category"; + } + + if( ereg("_([0-9]*)$",$name,$tmp ) ) + { + $id = $tmp[1]; + return( $id ); + } + $name = str_replace( "-"," ",$name ); + $query = "select id from $table where trim(lower( replace( replace( replace( replace( replace($category,'/','') ,'-',' ') ,'#','') ,'&','') ,'?',''))) = '".trim(strtolower($name))."'"; + $data = $DB->db_auto_get_data( $query ); + if( is_array( $data ) ) + { + foreach( $data as $key=>$val ) + { + $catid = $val['id']; + } + return( $catid ); + } + else + { + return( 0 ); + } + } + + function get_base_url( $id ) + { + if( $this->pages[$id] ) + { + return( $this->pages[$id] ); + } + else + { + return( $this->pages['default'] ); + } + } + + /** + * get_seo_url: this calls the needed function all in one to create a seo url + * @param $$id : + * + * @return + * @access + **/ + function get_seo_url( $id, $slash = 1 ) + { + $url = GLM_TEMPLATE::set_name_url( GLM_TEMPLATE::get_category_name( $id, "bus_category", $this->DB ) ); + $url = strip_tags( $url ); + $url = htmlspecialchars( $url ); + if( $slash ) + { + $url .= '/'; + } + return( $url ); + } + /** + * getCategoryName: + * @param $id: + * @param $table: + * @param $&$DB : + * + * @return + * @access + **/ + function get_category_name( $id, $table,&$DB ) + { + if( !is_numeric( $id ) ) + { + return( false ); + } + if($table == "topic") + { + $category = "descr"; + } + else + { + $category = "category"; + } + $query = "select $category from $table where id = $id"; + $data = $DB->db_auto_get_data( $query ); + if( is_array( $data ) ) + { + $query2 = "select id from $table where category = '".addslashes( trim( $data[0]['category'] ) )."'"; + $data2 = $DB->db_auto_get_data( $query2 ); + //echo "count of data2 = ".count($data2)."
    "; + //if( count($data2) > 1 ) + //{ + $add = '-'.$id; + //} + if( $data[0]['category'] ) + { + $category = $data[0]['category'].$add; + } + elseif( $data[0]['name']) + { + $category = $data[0]['name']; + } + else + { + $category = $id; + } + return( $category ); + } + } + + + /** + * setNameUrl: + * @param $$name : + * + * @return + * @access + **/ + function set_name_url( $name ) + { + $name = strtolower( trim( str_replace( " ","-",$name ) ) ); + $name = str_replace( "/","",$name ); + $name = str_replace( "#","",$name ); + $name = str_replace( "&","",$name ); + $name = str_replace( "?","",$name ); + return( trim($name) ); + } + + /** valid email + Checks for a valid format and good (mx check) + email address. + @param string email the email address as string. + @return boolean + */ + function valid_email( $email ) + { + if(!$email) + { + return( false ); + } + if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$", $email, $check)) { + if ( getmxrr(substr(strstr($check[0], '@'), 1), $validate_email_temp) ) { + return TRUE; + } + } + return FALSE; + } +/** + * getEventSearch: + * + * @return + * @access + **/ + function get_event_search() + { + + unset($emonts); + $month_id = array( "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ); + + // Set up the $selection array to get a query box use only item fields + $selection = array( ); + + // Month part do not change + $qs = "SELECT bdate,date_part('month', bdate) as d1_month, + date_part('month', edate) as d2_month, + date_part('year', bdate) as d1_year, + date_part('year', edate) as d2_year + FROM event + WHERE edate > CURRENT_DATE + AND visable = 't' + ORDER BY bdate ASC;"; + + $result = $this->DB->db_exec($qs); + + echo "
    +
    "; + //echo ''; + for($i=0;$iDB->db_fetch_array($result,$i,PGSQL_ASSOC); + $s_month = $data['d1_month']; + $s_year = $data['d1_year']; + $e_month = $data['d2_month']; + $e_year = $data['d2_year']; + + $watchdog = 20; + for( $y=$s_year, $m=$s_month; !($y==$e_year && $m==$e_month+1) ; ) { + if( $m == 13 ) { + $y++; + $m = 1; + } + + $emonth = sprintf( "%02d %04d", $m, $y ); + if( !isset($emonths["$emonth"]) ) + $emonths["$emonth"] = 0; + $emonths["$emonth"]++; + + if( $watchdog-- == 0 ) + break 1; + $m++; + } + } + + // Selections part + while( list($key,$value) = each($selection)) { + $qs = "SELECT + DISTINCT $key + FROM event + WHERE visable = 't' + AND edate >= CURRENT_DATE + ORDER BY $key;"; + + $result = $this->DB->db_exec($qs); + + echo "\n"; + } + // topic part + $qs = "SELECT + DISTINCT ON (t.descr) t.id,t.descr + FROM topic t, event e + WHERE e.visable = 't' + AND e.edate >= CURRENT_DATE + AND e.topicid = t.id + ORDER BY t.descr"; + + $result = $this->DB->db_exec($qs); + + echo "\n"; + // Month part (output) + $month_qs = "SELECT + DISTINCT bdate + FROM event + WHERE visable = 't' + AND edate >= CURRENT_DATE + ORDER BY bdate;"; + + $result = $this->DB->db_exec($month_qs); + + echo " + + '; + } + + + + /** + * format_to_time: + * @param $time: + * + * @return + * @access + **/ + function format_to_time($time) + { + + $timestamp = strtotime("today $time"); + $newtime = date("g:i A",$timestamp); + return($newtime); + } + + function getPhotoCats($catid) + { + $output = ''; + /* + $query = "SELECT * FROM bus_category WHERE id = ".$catid; + $data = $this->DB->db_auto_get_data($query); + if(is_array($data)) + { + foreach($data as $key=>$value) + { + if($value['category']) + $output .= '

    '.$value["category"].'

    '; + } + } + */ + $output .= '

    Click an image to enter a Photo Gallery

    '; + + $query2 = "SELECT * FROM bus_category WHERE parent = ".$catid." and active = 't' order by pos"; + $data2 = $this->DB->db_auto_get_data($query2); + if(is_array($data2)) + { + $count = 0; + foreach($data2 as $key=>$value) + { + if($value['image']) + { + $category = $this->get_seo_url( $value['id'] ); + $output .= '
    '.$value["category"].'
    '.$value[
    '; + } + if(++$count == 4) + $output .= '
    '; + } + } + return($output); + } + function getPhotos($catid) + { + $output = ''; + $query = "SELECT * FROM bus_category WHERE id = ".$catid; + $data = $this->DB->db_auto_get_data($query); + if(is_array($data)) + { + foreach($data as $key=>$value) + { + if($value['category']) + $output .= '

    '.$value["category"].'

    + '; + } + } + $output .= '

    Click an image to enlarge

    + '; + + $query2 = "SELECT b.name,b.image FROM bus b LEFT OUTER JOIN bus_category_bus bcb ON + (bcb.busid = b.id) WHERE bcb.catid = $catid order by bcb.pos"; + $data2 = $this->DB->db_auto_get_data($query2); + if(is_array($data2)) + { + $count = 0; + foreach($data2 as $key=>$value) + { + if($value['image']) + { + if(file_exists(ORIGINAL_PATH.$value['image'])) + { + $size2 = getimagesize(ORIGINAL_PATH.$value['image']); + $width = $size2[0] + 0; + $height = $size2[1] + 0; + } + $output .= '
    '.$value[
    '.$value["name"].'
    + '; + } + if(++$count == 4) + { + $output .= '
    + '; + $count = 0; + } + } + } + return($output); + } +} +?> diff --git a/classes/class_toolbox.inc b/classes/class_toolbox.inc new file mode 100755 index 0000000..22ab55b --- /dev/null +++ b/classes/class_toolbox.inc @@ -0,0 +1,9 @@ + diff --git a/classes/glm-Events-2-0.phtml b/classes/glm-Events-2-0.phtml new file mode 100755 index 0000000..46cfa17 --- /dev/null +++ b/classes/glm-Events-2-0.phtml @@ -0,0 +1,321 @@ +'; +if(!$dbd = db_connect()) + { + html_error(DB_ERROR_MSG,1); + } +$month_id = array( "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ); +// Set up the $selection array to get a query box use only item fields +$selection = array( ); +// Month part do not change +$qs = "SELECT bdate,date_part('month', bdate) as d1_month, + date_part('month', edate) as d2_month, + date_part('year', bdate) as d1_year, + date_part('year', edate) as d2_year + FROM event + WHERE edate > CURRENT_DATE + AND visable = 't' + AND (hotel_id = ".HOTEL_ID." OR hotel_id = 0) + ORDER BY bdate ASC;"; + $result = db_Exec($dbd,$qs); +if(!$result) + { + html_error(DB_ERROR_MSG.$qs,0); + } +echo "
    "; +if($pink) + { + echo "

    Pink Pony Events

    "; + } +echo "
    "; +echo ''; +for($i=0;$i= CURRENT_DATE + ORDER BY $key;"; + $result = db_exec($dbd,$qs); + if(!$result) html_error(DB_ERROR_MSG.$qs,0); + + echo "\n"; + } +// topic part +$qs = "SELECT +DISTINCT ON (t.descr) t.id,t.descr +FROM topic t, event e +WHERE e.visable = 't' +AND e.edate >= CURRENT_DATE +AND e.topicid = t.id +AND (hotel_id = ".HOTEL_ID." OR hotel_id = 0) +ORDER BY t.descr"; +$result = db_exec($dbd,$qs); +if(!$result) html_error(DB_ERROR_MSG.$qs,0); + +echo "\n"; +// Month part (output) +$month_qs = "SELECT +DISTINCT bdate +FROM event +WHERE visable = 't' +AND edate >= CURRENT_DATE +AND (hotel_id = ".HOTEL_ID." OR hotel_id = 0) +ORDER BY bdate;"; + +$result = db_exec($dbd, $month_qs); +if(!$result) html_error(DB_ERROR_MSG.$month_qs,0); +echo " + + + = CURRENT_DATE + AND (hotel_id = ".HOTEL_ID." OR hotel_id = 0)"; + if(isset($topic) && $topic != "All") + { + $qs .= "\nAND topicid = $topic"; + } +if($month != "All") + { + $m = substr($month,0,2); + $y = substr($month,3,4); + $smonth = date("m-d-Y",mktime(0,0,0,$m,1,$y)); + $emonth = date("m-d-Y",mktime(0,0,0,$m+1,0,$y)); + $qs .= "\nAND edate >= '$smonth' + AND bdate <= '$emonth'"; + } +$qs .= "\nORDER BY bdate ASC $stick"; +if(!$res = db_exec($dbd,$qs)) + { + html_error(DB_ERROR_MSG.$qs,0); + } +while($result = pg_fetch_array($res)) + { + $datares[] = $result; + } +if(is_array($datares)) + { + foreach($datares as $eventkey=>$eventval) + { + //$eventrow["$eventval[mon]"][] = $datares[$eventkey]; + for($i = (int)$eventval["mon"];$i <= (int)$eventval["mon2"];$i++) + { + // if monh exists then only show that month + if($month == "All" || ( (int)$month == (int)$i ) ) + { + $eventrow["$i"][] = $datares[$eventkey]; + } + } + } + } +if(is_array($eventrow)) + { + $display_month = ""; + foreach($eventrow as $ekey=>$row) + { + if((int)$display_month != (int)$ekey) + { + echo '

    '.date("F",mktime(0,0,1,$ekey,1,date("Y"))).'

    '; + } + $display_month = (int)$ekey; + foreach($row as $key=>$value) + { + if($value['sdate']) + { + $sdate = strtotime($value["sdate"]); + $edate = strtotime($value["edate"]); + $thedate = GLM_TEMPLATE::getEventDate($sdate,$edate,"timestamp"); + } + else + { + $thedata = ''; + } + if($value['img']) + { + $img = ""; + } + else + { + $img = ""; + } + if($value['email'] && $value['contact']) + { + $email = "Contact: ".$value['contact']."
    "; + } + elseif($value['email'] && !$value['contact']) + { + $email = "Contact:".$value['email']."
    "; + } + elseif($value['contact'] && !$value['email']) + { + $email = "Contact:>".$value['contact']."
    "; + } + else + { + $email = ""; + } + if($value['url']) + { + $url = ""; + } + else + { + $url = ""; + } + if($value['btime'] && $value['etime']) + { + $time = "Time: ".GLM_TEMPLATE::formatToTime($value['btime'])." To ".GLM_TEMPLATE::formatToTime($value['etime'])."
    "; + } + elseif($value['btime'] && !$value['etime']) + { + $time = "Time: ".GLM_TEMPLATE::formatToTime($value['btime'])."
    "; + } + else + { + $time = ""; + } + if($img) + { + echo $img; + } + echo "
    ".$value['header']."
    "; + echo '
    Date: '.$thedate.'
    '; + echo "
    ".$time."
    "; + if($value['topic']) + { + echo "
    Topic:".$value['topic']."
    "; + } + if($value['loc']) + { + echo 'Location: '.$value['loc']."
    "; + } + echo $email."
    "; + if($value['descr']) + { + echo nl2br($value['descr']); + } + echo $url."
    "; + //if(!$eventid) + //echo "

    "; + } + } + } +?> diff --git a/classes/glm-Events-calendar-2-0.phtml b/classes/glm-Events-calendar-2-0.phtml new file mode 100755 index 0000000..2181166 --- /dev/null +++ b/classes/glm-Events-calendar-2-0.phtml @@ -0,0 +1,331 @@ +'; +$RIGHTLINK = ''; +$dbd = db_connect(CONN_STR); +function lastDayOfMonth($timestamp = ''){ + if($timestamp=='') $timestamp=time(); + return( + mktime(0,0,0, + date("m",$timestamp)+1, + 1, + date("Y",$timestamp) + )-3600*24); +} + +function firstDayOfMonth($timestamp=''){ + if($timestamp=='') $timestamp=time(); + return(mktime(0,0,0, + date("m",$timestamp), + 1, + date("Y",$timestamp) + )); +} +if(!$year) + { + $year = date("Y"); + } +if(!$month || $month == "All") + { + $month = date("n"); + } +if(ereg("^0([0-9]).*",$month,$part)) + $month = $part[1]; +$st = mktime(0,0,0,$month,1,$year); +$starting = date("m-d-Y",firstDayOfMonth($st)); +$ending = date("m-d-Y",lastDayOfMonth($st)); +// Topic is disabled for the calendar view output. +/* if(isset($topic) && $topic != "All") +{ + $addpart .= " AND topicid = $topic "; +} */ + +$query = "SET DATESTYLE TO 'SQL,US'; +SELECT id,header, + date_part('month',bdate) as mon, + date_part('day',bdate) as day, + date_part('year',bdate) as yr, + date_part('month',edate) as mon2, + date_part('day',edate) as day2, + date_part('year',edate) as yr2, + bdate as sdate, edate as edate, + btime,etime,descr,loc,contact,email,url,img,daysow,reacur + FROM event + WHERE visable = 't'"; +$query .= "AND bdate <= '$ending' + AND edate >= '$starting' $addpart"; +$query .= "ORDER BY bdate DESC,btime ASC"; +$events_data = db_auto_get_data($query,CONN_STR); +if(is_array($events_data)) + { + foreach($events_data as $key=>$row) + { + $daysow = (int)$row["daysow"]; + $mon = (int)$row["mon"]; + $day = (int)$row["day"]; + $yr = (int)$row["yr"]; + $mon2 = (int)$row["mon2"]; + $day2 = (int)$row["day2"]; + $yr2 = (int)$row["yr2"]; + $sdate = mktime(0,0,30,$mon,$day,$yr); + $edate = mktime(0,0,30,$mon2,$day2,$yr2); + for($d=$day;$d<32;$d++) + { + // find the current_doyow + //echo "current day = $d
    "; + $cur_dow = date("w",mktime(0,0,30,$mon,$d,$yr)); + switch($cur_dow) + { + case 0: + $cur_dow = 1; + break; + case 1: + $cur_dow = 2; + break; + case 2: + $cur_dow = 4; + break; + case 3: + $cur_dow = 8; + break; + case 4: + $cur_dow = 16; + break; + case 5: + $cur_dow = 32; + break; + case 6: + $cur_dow = 64; + break; + } + $date = date("m-d-Y",mktime(0,0,30,(int)$mon,(int)$d,(int)$yr)); + $daysinmonth = date("t",mktime(0,0,30,$mon,$d,$yr)); + $time = mktime(0,0,30,(int)$mon,(int)$d,(int)$yr); + $starttime = mktime(0,0,30,(int)$mon,(int)$d,(int)$yr); + $endtime = mktime(0,0,30,(int)$mon,(int)$d,(int)$yr); + if( $row["reacur"] != "t") + { + if($starttime<=$time && $endtime>=$time ) + $newdata["$date"][] = $row; + } + elseif((int)$cur_dow&$daysow) + { + //echo $cur_dow."
    "; + if($edate>=$time && $sdate<=$time ) + $newdata["$date"][] = $row; + } + if($row["reacur"]=="" || $row["reacur"]=="f") + { + $d = 32; + break; + } + if($mon2>$mon && $d==$daysinmonth) + { + $d=0; + $mon++; + if($mon==13) + $mon=1; + } + if($yr2>$yr && $d==$daysinmonth) + { + $d=0; + $mon++; + if($mon==13) + $mon=1; + } + if($yr2>$yr && $mon==12) + { + $d=0; + $mon=0; + $yr++; + } + } + } + } +$GLOBALS['newdata'] = $newdata; +//echo '
    ';
    +//	print_r($newdata);
    +//echo '
    '; +function show_event_headers($date){ + global $newdata; + if(ereg("([0-9]{1,2})[-/]([0-9]{1,2})[-/]([0-9]{4})",$date,$dpart)) + { + $month = (int)$dpart[1]; + $year = (int)$dpart[3]; + } + if(!is_array($newdata[$date])) + return(false); + else{ + foreach($newdata[$date] as $num=>$data){ + $data2[] = ''.$data[header].''; + } + $output = implode("
    ",$data2); + echo $output; + } +} +function data( $month, $day, $year ) { + global $newdata; + if($month < 10) + $month = '0'.$month; + if((int)$day < 10) + $day = '0'.$day; + $date = $month.'-'.$day.'-'.$year; + //echo "date = $date
    "; + if($newdata[$date]){ + show_event_headers($date); + } + else + { + return(false); + } +} +$name_month = array ( + 1 => "January", + 2 => "Febuary", + 3 => "March", + 4 => "April", + 5 => "May", + 6 => "June", + 7 => "July", + 8 => "August", + 9 => "September", + 10 => "October", + 11 => "November", + 12 => "December" + ); +function calendar( $month, $year, $size, $href ,$href2) { + global $RIGHTLINK,$LEFTLINK; +$LEFTLINK = ''; +$RIGHTLINK = ''; + // Change to month/year to display + if( !isset( $month ) ) + $month = date('m'); + if( !isset( $year ) ) + $year = date('Y'); + $next = $month +1; + $next_year = $year; + $prev = $month -1; + $prev_year = $year; + if( $next == 13 ) + { + $next = 1; + $next_year++; + } + if( $next == 0 ) + { + $next = 12; + $next_year--; + } + if( $prev == 13 ) + { + $prev = 1; + $prev_year++; + } + if( $prev == 0 ) + { + $prev = 12; + $prev_year--; + } + $prev_month = ''.$LEFTLINK.''; + $next_month = ''.$RIGHTLINK.''; + // How to display the titles on the header of the calendar + if( $size == 2 ) + { + $height = 50; + $width = 60; + $table_width = 550 ; + $week_titles = array + ( + 0 => "Sunday", + 1 => "Monday", + 2 => "Tuesday", + 3 => "Wednesday", + 4 => "Thursday", + 5 => "Friday", + 6 => "Saturday" + ); + } + if( $size == 1 ) + { + $height = 1; + $width = 1; + $table_width = 100; + $week_titles = array + ( + 0 => "S", + 1 => "M", + 2 => "T", + 3 => "W", + 4 => "T", + 5 => "F", + 6 => "S" + ); + } + // determine total number of days in a month + $totaldays = 0; + while ( checkdate( $month, $totaldays + 1, $year ) ) + $totaldays++; + // build table + echo ''; + $calendar = date( "F", mktime( 0, 0, 0, $month + 1, 0, $year ) ); + echo ' + + + + '; + echo ''; + //echo ''; + for ( $x = 0; $x < 7; $x++ ) + { + echo ''; + } + echo ''; + // ensure that a number of blanks are put in so that the first day of the month + // lines up with the proper day of the week + $offset = date( "w", mktime( 0, 0, 0, $month, 0, $year ) ) + 1; + echo ''; + if ( $offset > 0 && $offset != 7 ) + echo str_repeat( "",$offset); + if( $offset == 7 ) + $offset = 0; + // start entering in the information + for ( $day = 1; $day <= $totaldays; $day++ ) { + echo ''; + $offset++; + // if we're on the last day of the week, wrap to the other side + if ( $offset > 6 ) + { + $offset = 0; + echo ''; + if ( $day < $totaldays ) + echo ''; + } + } + // fill in the remaining spaces for the end of the month, just to make it look + // pretty + if ( $offset > 0 ) + $offset = 7 - $offset; + if ( $offset > 0 ) + echo str_repeat( "", $offset ); + // end the table + echo '
    '.$prev_month.' '.$calendar.' '.$year.''.$next_month.'
    '.$THFT.'Things to Do'.$week_titles[$x].'
     '; + echo $day.'
    '; + data( $month, $day, $year ); + echo '
     
    '; +} +?> diff --git a/classes/glm-Newsletter-2-0.phtml b/classes/glm-Newsletter-2-0.phtml new file mode 100755 index 0000000..fe50a4f --- /dev/null +++ b/classes/glm-Newsletter-2-0.phtml @@ -0,0 +1,165 @@ +0) + { + for($a=0;$a0) + { + $row = db_fetch_array($res,0,PGSQL_ASSOC); + if($row[image] != "") + { + $img = ""; + } + else + { + $img = " "; + } +/* begin output for main section of newsletter */ +?> +
    + + + + + + + + + + + + +0) + { + for($i=0;$i"; + } + else + { + $blockimg = " "; + } + /* begin output for block sections of newsletter */ + ?> + + + + + + + + + +
     
     
    Newsletters
    +
    +
    +
    + No Newsletter today! +
    + diff --git a/contactform.css b/contactform.css new file mode 100755 index 0000000..3abdaeb --- /dev/null +++ b/contactform.css @@ -0,0 +1,58 @@ +.req {color: c00;} +#contact table { + background-color: #F9FBFD; + color: #000; + width: 400px; + border: 1px solid #D7E5F2; + border-collapse: collapse; + margin-top: 50px; + margin-left: 20px; + font-size: 12px;} + + form, input, textarea, select + {font-size: 12px; + font-family: arial,Arial, Helvetica, sans-serif; + } +.labelcell, .fieldcell, .smalllabelcell, .smallfieldcell, textarea {color: #000;} + +#contact td { + border: 1px solid #D7E5F2; + padding-left: 4px; +} + +.labelcell { + background-color: transparent; + width: 150px; +} + +.fieldcell { + background-color: #F2F7FB; + text-align: left; + margin-right: 0px; + padding-right: 0px; +} + +.smalllabelcell { + background-color: transparent; +} + +.smallfieldcell { + background-color: #F2F7FB; + text-align: left; + +} +.fieldcell input { + background-color: #fff; + margin-right: 0px; + +} + +.smallfieldcell input { + width: 100px; + background-color: #fff; +} + +.smallfieldcell select { + background-color: #fff; +} +textarea {width: 250px; height: 100px;display:block;} diff --git a/gallery.css b/gallery.css new file mode 100755 index 0000000..c4101ce --- /dev/null +++ b/gallery.css @@ -0,0 +1,15 @@ +div.thumb { + margin-right: 3px; + border: 0px solid #EFF3FF; + height: auto; + float: left; + text-align: center; + } +.thumb img{ + display: inline; + margin: 1px; + border: 0px solid #B3D1EF; + } +.thumb a:hover img {border: 0px solid black;} +.photocattitle {text-align: center; font-weight: normal; width: 130px;margin: 2px;} +.phototitle {text-align: center; font-weight: normal; width: 130px;margin: 2px;} diff --git a/gallery.jpg b/gallery.jpg new file mode 100755 index 0000000..3e71c1f Binary files /dev/null and b/gallery.jpg differ diff --git a/google/background.php b/google/background.php new file mode 100755 index 0000000..0b15d6c --- /dev/null +++ b/google/background.php @@ -0,0 +1,66 @@ + diff --git a/google/footer.php b/google/footer.php new file mode 100755 index 0000000..a273117 --- /dev/null +++ b/google/footer.php @@ -0,0 +1,11 @@ +compile_dir = FullSmartyCompileDir(); + return $FooterTemplate ->fetch('footer.tpl.htm'); + } +?> diff --git a/google/footer.tpl.htm b/google/footer.tpl.htm new file mode 100755 index 0000000..182e8ba --- /dev/null +++ b/google/footer.tpl.htm @@ -0,0 +1,18 @@ +
    +
    + + + + + + + + + + +
    +

     

    +

     

    +

    Powered by + ThinkBling.com

    +
    diff --git a/google/htmlfuncs.php b/google/htmlfuncs.php new file mode 100755 index 0000000..c7ad226 --- /dev/null +++ b/google/htmlfuncs.php @@ -0,0 +1,149 @@ +$Text"; + } + + function nbsp($Text) + { + return " $Text "; + } + + function Line($Text) + { + return "".$Text.""; + } + + function Table($HTML) + { + return "$HTML
    "; + } + + function TableW($HTML, $Width) + { + return "$HTML
    "; + } + + function href($HTML, $URL) + { + return "$HTML"; + } + + function hreft($HTML, $URL, $Target) + { + return "$HTML"; + } + + function Img($Text) + { + if ($Text != "") + { + return ""; + } + else + { + return ""; + } + } + + function TRTDW($Text, $Width) + { + return TR(TDW(Center($Text),$Width)); + } + + function TRTDC($Text) + { + return TR(TD(Center($Text))); + } + + function Center($Text) + { + return "
    $Text
    "; + } + + function TRTD($Text) + { + return TR(TD($Text)); + } + + function TR($Text) + { + return "
    $Text$Text
    '; + foreach($typeDef['elements'] as $child => $childDef){ + $buffer .= " + + "; + } + $buffer .= '
    $childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):
    '; + // if array + } elseif($typeDef['phpType'] == 'array'){ + $buffer .= ''; + for($i=0;$i < 3; $i++){ + $buffer .= " + + "; + } + $buffer .= '
    array item (type: $typeDef[arrayType]):
    '; + // if scalar + } else { + $buffer .= ""; + } + } else { + $buffer .= ""; + } + return $buffer; + } +} + +?> + +* @version v 0.6 +* @access public +*/ +class soapval extends nusoap_base { + /** + * constructor + * + * @param string $name optional value name + * @param string $type optional type name + * @param mixed $value optional content of value + * @param string $namespace optional namespace of value + * @param string $type_namespace optional namespace of type + * @param array $attributes associative array of attributes to add to element serialization + * @access public + */ + function soapval($name="noname",$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) { + $this->name = $name; + $this->value = $value; + $this->type = $type; + $this->element_ns = $element_ns; + $this->type_ns = $type_ns; + $this->attributes = $attributes; + } + + /** + * return serialized value + * + * @return string XML data + * @access private + */ + function serialize() { + return $this->serialize_val($this->value,$this->name,$this->type,$this->element_ns,$this->type_ns,$this->attributes); + } + + /** + * decodes a soapval object into a PHP native type + * + * @param object $soapval optional SOAPx4 soapval object, else uses self + * @return mixed + * @access public + */ + function decode(){ + return $this->value; + } +} + +?> +url = $url; + $u = parse_url($url); + foreach($u as $k => $v){ + $this->debug("$k = $v"); + $this->$k = $v; + } + if($u['query'] != ''){ + $this->path .= $u['query']; + } + if(!isset($u['port']) && $u['scheme'] == 'http'){ + $this->port = 80; + } + } + + /** + * if authenticating, set user credentials here + * + * @param string $user + * @param string $pass + * @access public + */ + function setCredentials($user, $pass) { + $this->user = $username; + $this->pass = $pword; + } + + /** + * set the soapaction value + * + * @param string $soapaction + * @access public + */ + function setSOAPAction($soapaction) { + $this->soapaction = $soapaction; + } + + /** + * set proxy info here + * + * @param string $proxyhost + * @param string $proxyport + * @access public + */ + function setProxy($proxyhost, $proxyport) { + $this->proxyhost = $proxyhost; + $this->proxyport = $proxyport; + } + + /** + * send the SOAP message via HTTP 1.0 + * + * @param string $msg message data + * @param integer $timeout set timeout in seconds + * @return string data + * @access public + */ + function send($data, $timeout=0) { + flush(); + $this->debug('entered send() with data of length: '.strlen($data)); + + if($this->proxyhost && $this->proxyport){ + $host = $this->proxyhost; + $port = $this->proxyport; + } else { + $host = $this->host; + $port = $this->port; + } + if($timeout > 0){ + $fp = fsockopen($host, $port, $this->errno, $this->error_str, $timeout); + } else { + $fp = fsockopen($host, $port, $this->errno, $this->error_str); + } + //socket_set_blocking($fp,0); + if (!$fp) { + $this->debug("Couldn't open socket connection to server: $server!"); + $this->setError("Couldn't open socket connection to server: $server."); + return false; + } + + $credentials = ''; + if($this->user != '') { + $credentials = 'Authorization: Basic '.base64_encode('$this->user:$this->pass').'\r\n'; + } + + if($this->proxyhost && $this->proxyport){ + $this-> outgoing_payload = "POST $this->url HTTP/1.0\r\n"; + } else { + $this->outgoing_payload = "POST $this->path HTTP/1.0\r\n"; + } + + $this->outgoing_payload .= + "User-Agent: $this->title v$this->version\r\n". + "Host: ".$this->host."\r\n". + $credentials. + "Content-Type: text/xml\r\nContent-Length: ".strlen($data)."\r\n". + "SOAPAction: \"$this->soapaction\""."\r\n\r\n". + $data; + + // send + if(!fputs($fp, $this->outgoing_payload, strlen($this->outgoing_payload))) { + $this->setError("couldn't write message data to socket"); + $this->debug("Write error"); + } + + // get response + $this->incoming_payload = ""; + while ($data = fread($fp, 32768)) { + $this->incoming_payload .= $data; + } + + // close filepointer + fclose($fp); + $data = $this->incoming_payload; + //print "data: $data"; + // separate content from HTTP headers + if(preg_match("/([^<]*?)\r?\n\r?\n(<.*>)/s",$data,$result)) { + $this->debug("found proper separation of headers and document"); + $this->debug("getting rid of headers, stringlen: ".strlen($data)); + $clean_data = $result[2]; + $this->debug("cleaned data, stringlen: ".strlen($clean_data)); + /* + if(ereg("^(.*)\r?\n\r?\n",$data)) { + $this->debug("found proper separation of headers and document"); + $this->debug("getting rid of headers, stringlen: ".strlen($data)); + $clean_data = ereg_replace("^[^<]*\r\n\r\n","", $data); + $this->debug("cleaned data, stringlen: ".strlen($clean_data)); + */ + } else { + $this->setError('no proper separation of headers and document.'); + return false; + } + if(strlen($clean_data) == 0){ + $this->debug("no data after headers!"); + $this->setError("no data present after HTTP headers."); + return false; + } + + return $clean_data; + } + + + /** + * send the SOAP message via HTTPS 1.0 using CURL + * + * @param string $msg message data + * @param integer $timeout set timeout in seconds + * @return string data + * @access public + */ + function sendHTTPS($data, $timeout=0) { + flush(); + $this->debug('entered sendHTTPS() with data of length: '.strlen($data)); + // init CURL + $ch = curl_init(); + + // set proxy + if($this->proxyhost && $this->proxyport){ + $host = $this->proxyhost; + $port = $this->proxyport; + } else { + $host = $this->host; + $port = $this->port; + } + // set url + $hostURL = ($port != '') ? "https://$host:$port" : "https://$host"; + // add path + $hostURL .= $this->path; + + curl_setopt($ch, CURLOPT_URL, $hostURL); + // set other options + curl_setopt($ch, CURLOPT_HEADER, 1); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + // set timeout + if($timeout != 0){ + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); + } + + $credentials = ''; + if($this->user != '') { + $credentials = 'Authorization: Basic '.base64_encode('$this->user:$this->pass').'\r\n'; + } + + if($this->proxyhost && $this->proxyport){ + $this-> outgoing_payload = "POST $this->url HTTP/1.0\r\n"; + } else { + $this->outgoing_payload = "POST $this->path HTTP/1.0\r\n"; + } + + $this->outgoing_payload .= + "User-Agent: $this->title v$this->version\r\n". + "Host: ".$this->host."\r\n". + $credentials. + "Content-Type: text/xml\r\nContent-Length: ".strlen($data)."\r\n". + "SOAPAction: \"$this->soapaction\""."\r\n\r\n". + $data; + + // set payload + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->outgoing_payload); + + // send and receive + $this->incoming_payload = curl_exec($ch); + $data = $this->incoming_payload; + + $err = "cURL ERROR: ".curl_errno($ch).": ".curl_error($ch)."
    "; + + if($err != ''){ + foreach(curl_getinfo($ch) as $k => $v){ + $err .= "$k: $v
    "; + } + $this->setError($err); + curl_close($ch); + return false; + } + + curl_close($ch); + + // separate content from HTTP headers + if(ereg("^(.*)\r?\n\r?\n",$data)) { + $this->debug("found proper separation of headers and document"); + $this->debug("getting rid of headers, stringlen: ".strlen($data)); + $clean_data = ereg_replace("^[^<]*\r\n\r\n","", $data); + $this->debug("cleaned data, stringlen: ".strlen($clean_data)); + } else { + $this->setError('no proper separation of headers and document.'); + return false; + } + if(strlen($clean_data) == 0){ + $this->debug("no data after headers!"); + $this->setError("no data present after HTTP headers."); + return false; + } + + return $clean_data; + } +} + +?> + +* @version v 0.6 +* @access public +*/ +class soap_server extends nusoap_base { + + // assoc array of operations => opData + var $operations = array(); + var $responseHeaders = false; + var $headers = ""; + var $request = ""; + var $charset_encoding = "UTF-8"; + var $fault = false; + var $result = "successful"; + + /** + * constructor + * + * @param string $wsdl path or URL to a WSDL file + * @access public + */ + function soap_server($wsdl=false){ + + // turn on debugging? + global $debug; + if(isset($debug)){ + $this->debug_flag = true; + } + + $this->wsdl = false; + + // wsdl + if($wsdl){ + $this->wsdl = new wsdl($wsdl); + if($err = $this->wsdl->getError()){ + die("WSDL ERROR: $err"); + } + } + } + + /** + * processes request and returns response + * + * @param string $data usually is the value of $HTTP_RAW_POST_DATA + * @access public + */ + function service($data){ + // print wsdl + if(ereg('^wsdl',$GLOBALS['QUERY_STRING'])){ + header("Content-Type: text/xml\r\n"); + print $this->wsdl->serialize(); + // print web interface + } elseif($data == '' && $this->wsdl){ + print $this->webDescription(); + } else { + // $response is the serialized response message + $response = $this->parse_request($data); + $this->debug("server sending..."); + $payload = $response; + //$payload .= ""; + // print headers + if($this->fault){ + $header[] = "Status: 500 Internal Server Error\r\n"; + } else { + $header[] = "Status: 200 OK\r\n"; + } + $header[] = "Server: $this->title Server v$this->version\r\n"; + $header[] = "Connection: Close\r\n"; + $header[] = "Content-Type: text/xml; charset=$this->charset_encoding\r\n"; + $header[] = "Content-Length: ".strlen($payload)."\r\n\r\n"; + reset($header); + foreach($header as $hdr){ + header($hdr); + } + $this->response = join("\n",$header).$payload; + print $payload; + } + } + + /** + * parses request and posts response + * + * @param string $data XML string + * @return object SOAPx4 soapmsg object + * @access private + */ + function parse_request($data="") { + $this->debug("entering parseRequest() on ".date("H:i Y-m-d")); + // get headers + if(function_exists("getallheaders")){ + $this->headers = getallheaders(); + foreach($this->headers as $k=>$v){ + $dump .= "$k: $v\r\n"; + $this->debug("$k: $v"); + } + // get SOAPAction header + if($this->headers['SOAPAction']){ + $this->SOAPAction = str_replace('"','',$this->headers['SOAPAction']); + } + // get the character encoding of the incoming request + if(strpos($headers_array['Content-Type'],"=")){ + $enc = str_replace("\"","",substr(strstr($headers_array["Content-Type"],"="),1)); + if(eregi("^(ISO-8859-1|US-ASCII|UTF-8)$",$enc)){ + $this->xml_encoding = $enc; + } else { + $this->xml_encoding = 'us-ascii'; + } + } + $this->debug("got encoding: $this->xml_encoding"); + } elseif(is_array($_SERVER)){ + $this->headers['User-Agent'] = $_SERVER['HTTP_USER_AGENT']; + $this->SOAPAction = $_SERVER['SOAPAction']; + } + $this->request = $dump."\r\n\r\n".$data; + // parse response, get soap parser obj + $parser = new soap_parser($data,$this->xml_encoding); + // if fault occurred during message parsing + if($err = $parser->getError()){ + // parser debug + $this->debug("parser debug: \n".$parser->debug_str); + $this->result = "fault: error in msg parsing or eval: $err"; + $this->fault("Server","error in msg parsing or eval:\n".$err); + // return soapresp + return $this->fault->serialize(); + // else successfully parsed request into soapval object + } else { + // get/set methodname + $this->methodname = $parser->root_struct_name; + $this->debug("method name: $this->methodname"); + // does method exist? + if(!function_exists($this->methodname)){ + // "method not found" fault here + $this->debug("method '$this->methodname' not found!"); + $this->debug("parser debug: \n".$parser->debug_str); + $this->result = "fault: method not found"; + $this->fault("Server","method '$this->methodname' not defined in service '$this->service'"); + return $this->fault->serialize(); + } + if($this->wsdl){ + if(!$this->opData = $this->wsdl->getOperationData($this->methodname)){ + $this->fault('Server',"Operation '$this->methodname' is not defined in the WSDL for this service"); + return $this->fault->serialize(); + } + } + $this->debug("method '$this->methodname' exists"); + // evaluate message, getting back parameters + $this->debug("calling parser->get_response()"); + $request_data = $parser->get_response(); + $this->debug('Parsed response dump: $request_data'); + // parser debug + $this->debug("parser debug: \n".$parser->debug_str); + // verify that request parameters match the method's signature + if($this->verify_method($this->methodname,$request_data)){ + // if there are parameters to pass + if($request_data){ + $this->debug("calling '$this->methodname' with params"); + if (! function_exists('call_user_func_array')) { + $this->debug("calling method using eval()"); + $funcCall = $this->methodname."("; + foreach($request_data as $param) { + $funcCall .= "\"$param\","; + } + $funcCall = substr($funcCall, 0, -1).')'; + $this->debug("function call:
    $funcCall"); + eval("\$method_response = $funcCall;"); + } else { + $this->debug("calling method using call_user_func_array()"); + $method_response = call_user_func_array("$this->methodname",$request_data); + } + } else { + // call method w/ no parameters + $this->debug("calling $this->methodname w/ no params"); + //$method_response = call_user_func($this->methodname); + $m = $this->methodname; + $method_response = $m(); + } + $this->debug("done calling method: $this->methodname, received $method_response of type".gettype($method_response)); + // if we got nothing back. this might be ok (echoVoid) + if(isset($method_response) && $method_response != "" || is_bool($method_response)) { + // if fault + if(get_class($method_response) == 'soap_fault'){ + $this->debug('got a fault object from method'); + $this->fault = $method_response; + return $method_response->serialize(); + // if return val is soapval object + } elseif(get_class($method_response) == 'soapval'){ + $this->debug('got a soapval object from method'); + $return_val = $method_response->serialize(); + // returned other + } else { + $this->debug("got a ".gettype($method_response)." from method"); + $this->debug("serializing return value"); + if($this->wsdl){ + if(sizeof($this->opData['output']['parts']) > 1){ + $opParams = $method_response; + } else { + $opParams = array($method_response); + } + $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams); + } else { + $return_val = $this->serialize_val($method_response); + } + } + } + $this->debug("serializing response"); + $payload = "<".$this->methodname."Response>\n".$return_val."methodname."Response>\n"; + $this->result = "successful"; + if($this->wsdl){ + //$this->debug("WSDL debug data:\n".$this->wsdl->debug_str); + } + return $this->serializeEnvelope($payload,$this->responseHeaders); + } else { + // debug + $this->debug("ERROR: request not verified against method signature"); + $this->result = "fault: request failed validation against method signature"; + // return fault + $this->fault("Server","Sorry, operation '$this->methodname' not defined in service."); + return $this->fault->serialize(); + } + } + } + + /** + * takes the soapval object that was created by parsing the request + * and compares to the method's signature, if available. + * + * @param object SOAPx4 soapval object + * @return boolean + * @access private + */ + function verify_method($operation,$request){ + if(isset($this->operations[$operation])){ + return true; + } + return false; + } + + /** + * add a method to the dispatch map + * + * @param string $methodname + * @param string $in array of input values + * @param string $out array of output values + * @access public + */ + function add_to_map($methodname,$in,$out){ + $this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out); + } + + /** + * register a service with the server + * + * @param string $methodname + * @param string $in array of input values + * @param string $out array of output values + * @param string $namespace + * @param string $soapaction + * @param string $style (rpc|literal) + * @access public + */ + function register($name,$in=false,$out=false,$namespace=false,$soapaction=false,$style=false){ + $this->operations[$name] = array( + 'name' => $name, + 'in' => $in, + 'out' => $out, + 'namespace' => $namespage, + 'soapaction' => $soapaction, + 'style' => $style); + return true; + } + + /** + * create a fault. this also acts as a flag to the server that a fault has occured. + * + * @param string faultcode + * @param string faultactor + * @param string faultstring + * @param string faultdetail + * @access public + */ + function fault($faultcode,$faultactor,$faultstring='',$faultdetail=''){ + $this->fault = new soap_fault($faultcode,$faultactor,$faultstring,$faultdetail); + } + + /** + * prints html description of services + * + * @access private + */ + function webDescription(){ + $b .= " + NuSOAP: ".$this->wsdl->serviceName." + + + + +
    +

    +
    ".$this->wsdl->serviceName."
    + +
    + "; + return $b; + } + + /** + * sets up wsdl object + * this acts as a flag to enable internal WSDL generation + * NOTE: NOT FUNCTIONAL + * + * @param string $serviceName, name of the service + * @param string $namespace, tns namespace + */ + function configureWSDL($serviceName,$namespace){ + $this->wsdl = new wsdl; + $this->wsdl->serviceName = $serviceName; + $this->wsdl->namespaces['tns'] = $namespace; + $this->wsdl->namespaces['soap'] = "http://schemas.xmlsoap.org/wsdl/soap/"; + $this->wsdl->namespaces['wsdl'] = "http://schemas.xmlsoap.org/wsdl/"; + } +} + +?> + +* @access public +*/ +class wsdl extends XMLSchema { + + /** + * constructor + * + * @param string $wsdl WSDL document URL + * @access public + */ + function wsdl($wsdl=""){ + $this->wsdl = $wsdl; + // define internal arrays of bindings, ports, operations, messages, etc. + //$this->namespaces = array(); + $this->complexTypes = array(); + $this->messages = array(); + $this->currentMessage; + $this->currentOperation; + $this->portTypes = array(); + $this->currentPortType; + $this->bindings = array(); + $this->currentBinding; + $this->ports = array(); + $this->currentPort; + $this->opData = array(); + $this->status = ""; + $this->documentation = false; + // array of wsdl docs to import + $this->import = array(); + // parser vars + $this->parser; + $this->position; + $this->depth; + $this->depth_array = array(); + + // parse wsdl file + if($wsdl != ""){ + $this->debug("initial wsdl file: $wsdl"); + $this->parseWSDL($wsdl); + } + + // imports + if(sizeof($this->import) > 0){ + foreach($this->import as $ns => $url){ + $this->debug("importing wsdl from $url"); + $this->parseWSDL($url); + } + } + + } + + /** + * parses the wsdl document + * + * @param string $wsdl path or URL + * @access private + */ + function parseWSDL($wsdl=""){ + // parse wsdl file + if($wsdl != ""){ + $this->debug("getting $wsdl"); + if ($fp = @fopen($wsdl,"r")) { + while($data = fread($fp, 32768)) { + $wsdl_string .= $data; + } + fclose($fp); + } else { + $this->setError("bad path to WSDL file."); + return false; + } + // Create an XML parser. + $this->parser = xml_parser_create(); + // Set the options for parsing the XML data. + //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); + // Set the object for the parser. + xml_set_object($this->parser, $this); + // Set the element handlers for the parser. + xml_set_element_handler($this->parser, "start_element","end_element"); + xml_set_character_data_handler($this->parser,"character_data"); + //xml_set_default_handler($this->parser, "default_handler"); + + // Parse the XML file. + if(!xml_parse($this->parser,$wsdl_string,true)){ + // Display an error message. + $errstr = sprintf("XML error on line %d: %s", + xml_get_current_line_number($this->parser), + xml_error_string(xml_get_error_code($this->parser)) + ); + $this->debug("XML parse error: $errstr"); + $this->setError("Parser error: $errstr"); + return false; + } + xml_parser_free($this->parser); + } else{ + $this->debug("no wsdl passed to parseWSDL()!!"); + $this->setError("no wsdl passed to parseWSDL()!!"); + return false; + } + + // add new data to operation data + foreach($this->bindings as $binding => $bindingData){ + if(is_array($bindingData['operations'])){ + foreach($bindingData['operations'] as $operation => $data){ + $this->debug("post-parse data gathering for $operation"); + $this->bindings[$binding]['operations'][$operation]['input'] = array_merge($this->bindings[$binding]['operations'][$operation]['input'],$this->portTypes[ $bindingData['portType'] ][$operation]['input']); + $this->bindings[$binding]['operations'][$operation]['output'] = array_merge($this->bindings[$binding]['operations'][$operation]['output'],$this->portTypes[ $bindingData['portType'] ][$operation]['output']); + $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ]; + $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ]; + if($this->bindings[$binding]['operations'][$operation]['style'] == ''){ + $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style']; + } + $this->bindings[$binding]['operations'][$operation]['transport'] = $bindingData['transport']; + $this->bindings[$binding]['operations'][$operation]['documentation'] = $this->portTypes[ $bindingData['portType'] ][$operation]['documentation']; + $this->bindings[$binding]['operations'][$operation]['endpoint'] = $bindingData['endpoint']; + } + } + } + return true; + } + + /** + * start-element handler + * + * @param string $parser XML parser object + * @param string $name element name + * @param string $attrs associative array of attributes + * @access private + */ + function start_element($parser, $name, $attrs) { + + if($this->status == "schema" || ereg("schema$",$name)){ + //$this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")"); + $this->status = "schema"; + $this->schemaStartElement($parser,$name,$attrs); + } else { + // position in the total number of elements, starting from 0 + $pos = $this->position++; + $depth = $this->depth++; + // set self as current value for this depth + $this->depth_array[$depth] = $pos; + + // get element prefix + if(ereg(":",$name)){ + // get ns prefix + $prefix = substr($name,0,strpos($name,":")); + // get unqualified name + $name = substr(strstr($name,":"),1); + } + //$this->debug("name: $name, prefix: $prefix"); + + // loop through atts, logging ns declarations + foreach($attrs as $key => $value){ + // if ns declarations, add to class level array of valid namespaces + if(ereg("^xmlns",$key)){ + if($ns_prefix = substr(strrchr($key,":"),1)){ + $this->namespaces[$ns_prefix] = $value; + } else { + $this->namespaces['ns'.(count($this->namespaces)+1)] = $value; + } + if($value == 'http://www.w3.org/2001/XMLSchema'){ + $this->XMLSchemaVersion = $value; + $this->namespaces['xsi'] = $value.'-instance'; + } elseif($value == 'http://www.w3.org/1999/XMLSchema'){ + $this->XMLSchemaVersion = $value; + $this->namespaces['xsi'] = $value.'-instance'; + } + } + } + + // find status, register data + switch($this->status){ + case 'message': + if($name == 'part'){ + if($attrs['type']){ + //print "msg ".$this->currentMessage.": found part $attrs[name]: ".implode(',',$attrs)."
    "; + $this->messages[$this->currentMessage][$attrs['name']] = $this->expandQname($attrs['type']); + //print "i've stored it as: ".$this->messages[$this->currentMessage][$attrs['name']]."
    "; + } + if($attrs['element']){ + $this->messages[$this->currentMessage][$attrs['name']] = $this->expandQname($attrs['element']); + } + } + break; + case 'portType': + switch($name){ + case 'operation': + $this->currentPortOperation = $attrs["name"]; + $this->debug("portType $this->currentPortType operation: $this->currentPortOperation"); + $this->portTypes[$this->currentPortType][$attrs["name"]]["parameterOrder"] = $attrs["parameterOrder"]; + break; + case 'documentation': + $this->documentation = true; + break; + // merge input/output data + default: + $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $this->getLocalPart($attrs['message']); + break; + } + break; + case 'binding': + switch($name){ + case 'binding': + // get ns prefix + if(isset($attrs['style'])){ + $this->bindings[$this->currentBinding]['prefix'] = $prefix; + } + $this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding],$attrs); + break; + case 'header': + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs; + break; + case 'operation': + if($attrs['soapAction'] || $attrs['style']){ + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction']; + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style']; + } elseif($attrs['name']) { + $this->currentOperation = $attrs['name']; + $this->debug("current binding operation: $this->currentOperation"); + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name']; + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding; + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = $this->bindings[$this->currentBinding]['endpoint']; + } + break; + case 'input': + $this->opStatus = 'input'; + break; + case 'output': + $this->opStatus = 'output'; + break; + case 'body': + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus],$attrs); + break; + } + break; + case "service": + switch($name){ + case "port": + $this->currentPort = $attrs['name']; + $this->debug("current port: $this->currentPort"); + $this->ports[$this->currentPort]['binding'] = substr(strstr($attrs['binding'],":"),1); + + break; + case "address": + $this->ports[$this->currentPort]['location'] = $attrs['location']; + $this->ports[$this->currentPort]['bindingType'] = $this->getNamespaceFromPrefix($prefix); + $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $this->getNamespaceFromPrefix($prefix); + $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location']; + //echo "port $this->currentPort, has binding ".$this->ports[$this->currentPort]['binding']." and endpoint ".$attrs['location']."
    "; + break; + } + break; + } + // set status + switch($name){ + case "import": + if(isset($attrs['location'])){ + $this->import[$attrs['namespace']] = $attrs['location']; + } + break; + case "types": + $this->status = "schema"; + break; + case "message": + $this->status = "message"; + $this->messages[$attrs["name"]] = array(); + $this->currentMessage = $attrs["name"]; + break; + case "portType": + $this->status = "portType"; + $this->portTypes[$attrs["name"]] = array(); + $this->currentPortType = $attrs["name"]; + break; + case "binding": + if(isset($attrs['name'])){ + // get binding name + if(ereg(":",$attrs['name'])){ + $this->currentBinding = substr(strstr($attrs['name'],":"),1); + $prefix = substr($name,0,strpos($attrs['name'],":")); + } else { + $this->currentBinding = $attrs['name']; + } + $this->status = "binding"; + $this->bindings[$this->currentBinding]['portType'] = substr(strstr($attrs['type'],":"),1); + $this->debug("current binding: $this->currentBinding of portType: ".$attrs['type']); + } + break; + case "service": + $this->serviceName = $attrs["name"]; + $this->status = "service"; + break; + case "definitions": + foreach ($attrs as $name=>$value) { + $this->wsdl_info[$name]=$value; + } + break; + } + } + } + + /** + * end-element handler + * + * @param string $parser XML parser object + * @param string $name element name + * @access private + */ + function end_element($parser, $name) { + // unset schema status + if(ereg('types$',$name) || ereg('schema$',$name)){ + $this->status = ""; + } + if($this->status == 'schema'){ + $this->schemaEndElement($parser, $name); + } else { + // position of current element is equal to the last value left in depth_array for my depth + $pos = $this->depth_array[$this->depth]; + // bring depth down a notch + $this->depth--; + } + // end documentation + if($this->documentation){ + $this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation; + $this->documentation = false; + } + } + + /** + * element content handler + * + * @param string $parser XML parser object + * @param string $data element content + * @access private + */ + function character_data($parser, $data){ + $pos = $this->depth_array[$this->depth]; + $this->message[$pos]["cdata"] .= $data; + if($this->documentation){ + $this->documentation .= $data; + } + } + + + function getBindingData($binding){ + if(is_array($this->bindings[$binding])){ + return $this->bindings[$binding]; + } + } + + function getMessageData($operation,$portType,$msgType){ + $name = $this->opData[$operation][$msgType]['message']; + $this->debug( "getting msgData for $name, using $operation,$portType,$msgType
    " ); + return $this->messages[$name]; + } + + /** + * returns an assoc array of operation names => operation data + * NOTE: currently only supports multiple services of differing binding types + * This method needs some work + * + * @param string $bindingType eg: soap, smtp, dime (only soap is currently supported) + * @return array + * @access public + */ + function getOperations($bindingType = "soap"){ + if($bindingType == "soap"){ + $bindingType = "http://schemas.xmlsoap.org/wsdl/soap/"; + } + // loop thru ports + foreach($this->ports as $port => $portData){ + // binding type of port matches parameter + if($portData['bindingType'] == $bindingType){ + // get binding + return $this->bindings[ $portData['binding'] ]['operations']; + } + } + return array(); + } + + /** + * returns an associative array of data necessary for calling an operation + * + * @param string $operation, name of operation + * @param string $bindingType, type of binding eg: soap + * @return array + * @access public + */ + function getOperationData($operation,$bindingType="soap"){ + if($bindingType == "soap"){ + $bindingType = "http://schemas.xmlsoap.org/wsdl/soap/"; + } + // loop thru ports + foreach($this->ports as $port => $portData){ + // binding type of port matches parameter + if($portData['bindingType'] == $bindingType){ + // get binding + foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData){ + if($operation == $bOperation){ + return $opData; + } + } + } + } + } + + /** + * serialize the parsed wsdl + * + * @return string, serialization of WSDL + * @access public + */ + function serialize(){ + $xml = "namespaces as $k => $v){ + $xml .= " xmlns:$k=\"$v\""; + } + $xml .= ">"; + + // imports + if(sizeof($this->import) > 0){ + foreach($this->import as $ns => $url){ + $xml .= "\n"; + } + } + + // types + if($this->schema){ + $xml .= ""; + //$xml .= $this->serializeSchema(); + $xml .= ""; + } + + // messages + if(count($this->messages) >= 1){ + foreach($this->messages as $msgName => $msgParts){ + $xml .= ""; + foreach($msgParts as $partName => $partType){ + $xml .= ""; + } + $xml .= ""; + } + } + // portTypes + if(count($this->portTypes) >= 1){ + foreach($this->portTypes as $portTypeName => $portOperations){ + $xml .= ""; + foreach($portOperations as $portOperation => $parameterOrder){ + $xml .= ""; + foreach($this->portTypes[$portTypeName][$portOperation] as $name => $attrs){ + $xml .= "<$name"; + if(is_array($attrs)){ + foreach($attrs as $k => $v){ + $xml .= " $k=\"$v\""; + } + } + $xml .= "/>"; + } + $xml .= ""; + } + $xml .= ""; + } + } + // bindings + if(count($this->bindings) >= 1){ + foreach($this->bindings as $bindingName => $attrs){ + $xml .= ""; + $xml .= ""; + foreach($attrs["operations"] as $opName => $opParts){ + $xml .= ""; + $xml .= ""; + $xml .= ""; + $xml .= ""; + $xml .= ""; + $xml .= ""; + $xml .= ""; + $xml .= ""; + $xml .= ""; + } + $xml .= ""; + } + } + // services + $xml .= "serviceName\">"; + if(count($this->ports) >= 1){ + foreach($this->ports as $pName => $attrs){ + $xml .= ""; + $xml .= "soap:address location=\"".$attrs["location"]."\"/>"; + $xml .= ""; + } + } + $xml .= ""; + return $xml.""; + } + + /** + * serialize a PHP value according to a WSDL message definition + * + * TODO + * - only serialize namespaces used in the message + * - multi-ref serialization + * - validate PHP values against type definitions, return errors if invalid + * - probably more stuff :) + * - implement 'out' functionality or write new function for 'out' parameters + * + * @param string type name + * @param mixed param value + * @return mixed new param or false if initial value didn't validate + */ + function serializeRPCParameters($operation,$direction,$parameters){ + if($direction != 'input' && $direction != 'output'){ + $this->setError('The value of the \$direction argument needs to be either "input" or "output"'); + return false; + } + if(!$opData = $this->getOperationData($operation)){ + return false; + } + $this->debug( "in serializeRPCParameters with xml schema version $this->XMLSchemaVersion"); + // set input params + if(sizeof($opData[$direction]['parts']) > 0){ + foreach($opData[$direction]['parts'] as $name => $type){ + $xml .= $this->serializeType($name,$type,array_shift($parameters)); + } + } + return $xml; + } + + /** + * serializes a PHP value according a given type definition + * + * @param string $name, name of type + * @param string $type, type of type, heh + * @param mixed $value, a native PHP value + * @return string serialization + * @access public + */ + function serializeType($name,$type,$value){ + $this->debug("in serializeType: $name, $type, $value"); + if(strpos($type,':')){ + $uqType = substr($type,strrpos($type,":")+1); + $ns = substr($type,0,strrpos($type,":")); + $this->debug("got a prefixed type: $uqType, $ns"); + if($ns == $this->XMLSchemaVersion){ + if($uqType == 'boolean' && !$value){ + $value = 0; + } elseif($uqType == 'boolean'){ + $value = 1; + } + if($uqType == 'string' && $this->charencoding){ + $value = htmlspecialchars($value); + } + // it's a scalar + return "<$name xsi:type=\"".$this->getPrefixFromNamespace($this->XMLSchemaVersion).":$uqType\">$value\n"; + } + } else { + $uqType = $type; + } + $typeDef = $this->getTypeDef($uqType); + $phpType = $typeDef['phpType']; + $this->debug("serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: ".$typeDef['arrayType']); + // if php type == struct, map value to the element names + if($phpType == "struct"){ + $xml = "<$name xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\">\n"; + if(is_array($this->complexTypes[$uqType]["elements"])){ + foreach($this->complexTypes[$uqType]["elements"] as $eName => $attrs){ + // get value + if(isset($value[$eName])){ + $v = $value[$eName]; + } elseif(is_array($value)) { + $v = array_shift($value); + } + if(!isset($attrs['type'])){ + $xml .= $this->serializeType($eName,$attrs['name'],$v); + } else { + $this->debug("calling serialize_val() for $eName, $v, ".$this->getLocalPart($attrs['type'])); + $xml .= $this->serialize_val($v,$eName,$this->getLocalPart($attrs['type']),null,$this->getNamespaceFromPrefix($this->getPrefix($attrs['type']))); + } + } + } + $xml .= "\n"; + } elseif($phpType == "array"){ + $rows = sizeof($value); + if($typeDef['multidimensional']){ + $nv = array(); + foreach($value as $v){ + $cols = ','.sizeof($v); + $nv = array_merge($nv,$v); + } + $value = $nv; + } + if(is_array($value) && sizeof($value) >= 1){ + foreach($value as $k => $v){ + if(strpos($typeDef['arrayType'],':')){ + $contents .= $this->serializeType('item',$typeDef['arrayType'],$v); + } else { + $contents .= $this->serialize_val($v,'item',$typeDef['arrayType'],null,$this->XMLSchemaVersion); + } + } + } + $xml = "<$name xsi:type=\"".$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').":Array\" ". + $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') + .":arrayType=\"" + .$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) + .":".$this->getLocalPart($typeDef['arrayType'])."[$rows$cols]\">\n" + .$contents + ."\n"; + } + return $xml; + } +} + +?> + +* @version v 0.051 +* @access public +*/ +class soap_parser extends nusoap_base { + /** + * constructor + * + * @param string $xml SOAP message + * @param string $encoding character encoding scheme of message + * @access public + */ + function soap_parser($xml,$encoding="UTF-8",$method=""){ + $this->xml = $xml; + $this->xml_encoding = $encoding; + $this->method = $method; + $this->root_struct = ""; + $this->root_struct_name = ""; + $this->root_header = ""; + // determines where in the message we are (envelope,header,body,method) + $this->status = ""; + $this->position = 0; + $this->depth = 0; + $this->default_namespace = ""; + $this->namespaces = array(); + $this->message = array(); + $this->fault = false; + $this->fault_code = ""; + $this->fault_str = ""; + $this->fault_detail = ""; + $this->errstr = ""; + $this->depth_array = array(); + $this->debug_flag = true; + $this->debug_str = ""; + $this->soapresponse = NULL; + $this->responseHeaders = ""; + // for multiref parsing: + // array of id => pos + $this->ids = array(); + // array of id => hrefs => pos + $this->multirefs = array(); + + $this->entities = array ( "&" => "&", "<" => "<", ">" => ">", + "'" => "'", '"' => """ ); + + // Check whether content has been read. + if(!empty($xml)){ + $this->debug("Entering soap_parser()"); + // Create an XML parser. + $this->parser = xml_parser_create($this->xml_encoding); + // Set the options for parsing the XML data. + //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); + // Set the object for the parser. + xml_set_object($this->parser, &$this); + // Set the element handlers for the parser. + xml_set_element_handler($this->parser, "start_element","end_element"); + xml_set_character_data_handler($this->parser,"character_data"); + //xml_set_default_handler($this->parser, "default_handler"); + + // Parse the XML file. + if(!xml_parse($this->parser,$xml,true)){ + // Display an error message. + $err = sprintf("XML error on line %d: %s", + xml_get_current_line_number($this->parser), + xml_error_string(xml_get_error_code($this->parser))); + $this->debug("parse error: $err"); + $this->errstr = $err; + } else { + $this->debug("parsed successfully, found root struct: $this->root_struct of name $this->root_struct_name"); + // get final value + $this->soapresponse = $this->message[$this->root_struct]['result']; + // get header value + if($this->root_header != ""){ + $this->responseHeaders = $this->message[$this->root_header]['result']; + } + } + xml_parser_free($this->parser); + } else { + $this->debug("xml was empty, didn't parse!"); + $this->errstr = "xml was empty, didn't parse!"; + } + } + + /** + * start-element handler + * + * @param string $parser XML parser object + * @param string $name element name + * @param string $attrs associative array of attributes + * @access private + */ + function start_element($parser, $name, $attrs) { + // position in a total number of elements, starting from 0 + // update class level pos + $pos = $this->position++; + // and set mine + $this->message[$pos]["pos"] = $pos; + // depth = how many levels removed from root? + // set mine as current global depth and increment global depth value + $this->message[$pos]["depth"] = $this->depth++; + + // else add self as child to whoever the current parent is + if($pos != 0){ + $this->message[$this->parent]["children"] .= "|$pos"; + } + // set my parent + $this->message[$pos]["parent"] = $this->parent; + // set self as current parent + $this->parent = $pos; + // set self as current value for this depth + $this->depth_array[$this->depth] = $pos; + // get element prefix + if(strpos($name,":")){ + // get ns prefix + $prefix = substr($name,0,strpos($name,":")); + // get unqualified name + $name = substr(strstr($name,":"),1); + } + // set status + if($name == "Envelope"){ + $this->status = "envelope"; + } elseif($name == "Header"){ + $this->root_header = $pos; + $this->status = "header"; + } elseif($name == "Body"){ + $this->status = "body"; + $this->body_position = $pos; + // set method + } elseif($this->status == "body" && $pos == ($this->body_position+1)){ + //if($name == $this->method."Response" || $name == $this->method || $name == "Fault"){ + $this->status = "method"; + $this->root_struct_name = $name; + $this->root_struct = $pos; + $this->message[$pos]["type"] = "struct"; + $this->debug("found root struct $this->root_struct_name, pos $pos"); + //} + } + // set my status + $this->message[$pos]["status"] = $this->status; + // set name + $this->message[$pos]["name"] = htmlspecialchars($name); + // set attrs + $this->message[$pos]["attrs"] = $attrs; + // get namespace + if($prefix){ + $this->message[$pos]["namespace"] = $this->namespaces[$prefix]; + $this->default_namespace = $this->namespaces[$prefix]; + } else { + $this->message[$pos]["namespace"] = $this->default_namespace; + } + // loop through atts, logging ns and type declarations + foreach($attrs as $key => $value){ + + // if ns declarations, add to class level array of valid namespaces + if(strpos($key,'xmlns:')){ + $prefix = substr(strrchr($key,":"),1); + if(ereg('^http://www.w3.org/[0-9]{4}/XMLSchema$',$value)){ + global $XMLSchemaVersion,$namespaces; + $XMLSchemaVersion = $value; + $namespaces["xsd"] = $XMLSchemaVersion; + $namespaces["xsi"] = $XMLSchemaVersion."-instance"; + } + $this->namespaces[substr(strrchr($key,":"),1)] = $value; + // set method namespace + if($name == $this->root_struct_name){ + $this->methodNamespace = $value; + } + // if it's a type declaration, set type + } elseif(strpos($key,":type")){ + $this->message[$pos]["type"] = substr(strrchr($value,":"),1); + $this->message[$pos]["typePrefix"] = substr($value,0,strpos($key,":")-1); + // should do something here with the namespace of specified type? + } elseif(strpos($key,":arrayType")){ + $this->message[$pos]['type'] = 'array'; + /* do arrayType ereg here + [1] arrayTypeValue ::= atype asize + [2] atype ::= QName rank* + [3] rank ::= '[' (',')* ']' + [4] asize ::= '[' length~ ']' + [5] length ::= nextDimension* Digit+ + [6] nextDimension ::= Digit+ ',' + */ + $expr = "([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]"; + if(ereg($expr,$value,$regs)){ + $this->message[$pos]['typePrefix'] = $regs[1]; + $this->message[$pos]['arraySize'] = $regs[3]; + $this->message[$pos]['arrayCols'] = $regs[4]; + } + } + // log id + if($key == "id"){ + $this->ids[$value] = $pos; + } + // root + if(strpos($key,":root") && $value == 1){ + $this->status = "method"; + $this->root_struct_name = $name; + $this->root_struct = $pos; + $this->debug("found root struct $this->root_struct_name, pos $pos"); + } + } + } + + /** + * end-element handler + * + * @param string $parser XML parser object + * @param string $name element name + * @access private + */ + function end_element($parser, $name) { + // position of current element is equal to the last value left in depth_array for my depth + $pos = $this->depth_array[$this->depth]; + // bring depth down a notch + $this->depth--; + + // build to native type + if($pos > $this->body_position){ + // deal w/ multirefs + if(isset($this->message[$pos]['attrs']['href'])){ + // get id + $id = substr($this->message[$pos]['attrs']['href'],1); + // add placeholder to href array + $this->multirefs[$id][$pos] = "placeholder"; + // add set a reference to it as the result value + $this->message[$pos]['result'] =& $this->multirefs[$id][$pos]; + } elseif($this->message[$pos]['children'] != ""){ + $this->message[$pos]['result'] = $this->buildVal($pos); + } else { + $this->message[$pos]['result'] = $this->message[$pos]['cdata']; + } + } + + // switch status + if($pos == $this->root_struct){ + $this->status = "body"; + } elseif(eregi(":Body",$name)){ + $this->status = "header"; + } elseif(eregi(":Header",$name)){ + $this->status = "envelope"; + } elseif(eregi(":Envelope",$name)){ + // resolve hrefs/ids + if(sizeof($this->multirefs) > 0){ + foreach($this->multirefs as $id => $hrefs){ + $this->debug("resolving multirefs for id: $id"); + foreach($hrefs as $refPos => $ref){ + $this->debug("resolving href at pos $refPos"); + $this->multirefs[$id][$refPos] = $this->buildval($this->ids[$id]); + } + } + } + } + // set parent back to my parent + $this->parent = $this->message[$pos]["parent"]; + } + + /** + * element content handler + * + * @param string $parser XML parser object + * @param string $data element content + * @access private + */ + function character_data($parser, $data){ + $pos = $this->depth_array[$this->depth]; + $this->message[$pos]["cdata"] .= $data; + } + + /** + * get the parsed message + * + * @return object SOAPx4 soap_val object + * @access public + */ + function get_response(){ + return $this->soapresponse; + } + + /** + * get the parsed headers + * + * @return mixed object SOAPx4 soapval object or empty if no headers + * @access public + */ + function getHeaders(){ + return $this->responseHeaders; + } + + /** + * decodes entities + * + * @param string $text string to translate + * @access private + */ + function decode_entities($text){ + foreach($this->entities as $entity => $encoded){ + $text = str_replace($encoded,$entity,$text); + } + return $text; + } + + /** + * builds response structures for compound values (arrays/structs) + * + * @param string $pos position in node tree + * @access private + */ + function buildVal($pos){ + // build self + $this->debug("inside buildVal() for ".$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]["type"]); + // if there are children... + if($this->message[$pos]["children"] != ""){ + $children = explode("|",$this->message[$pos]["children"]); + array_shift($children); // knock off empty + // loop thru them, getting params + foreach($children as $child_pos){ + // md array + if($this->message[$pos]['arrayCols']){ + $this->debug("got an MD array element: $r, $c"); + $params[$r][] = $this->message[$child_pos]['result']; + $c++; + if($c == $this->message[$pos]['arrayCols']){ + $c = 0; + $r++; + } + } elseif($this->message[$pos]['type'] == 'array'){ + $params[] =& $this->message[$child_pos]['result']; + } else { + $params[$this->message[$child_pos]["name"]] =& $this->message[$child_pos]['result']; + } + } + return is_array($params) ? $params : array(); + } else { + //return $this->message[$pos]['cdata']; + return strtr($this->message[$pos]['cdata'],array_flip($this->entities)); + } + } + + /** + * for building SOAP header values + * + * @param string $pos position in node tree + * @access private + */ + function buildSoapVal($pos){ + // if there are children... + if($this->message[$pos]["children"] != ""){ + $children = explode("|",$this->message[$pos]["children"]); + // loop thru them, getting params + foreach($children as $c => $child_pos){ + if($this->message[$child_pos]["type"] != NULL) { + $this->debug("adding ".$this->message[$child_pos]["name"].", pos: $child_pos"); + $params[] = $this->message[$child_pos]['result']; + } + } + } + // build self + $this->debug("building ".$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]["type"]); + if($params){ + return new soapval($this->message[$pos]["name"], $this->message[$pos]["type"] , $params); + } else { + return new soapval($this->message[$pos]["name"], $this->message[$pos]["type"] , $this->message[$pos]["cdata"]); + } + } +} + +?> +call( string methodname [ ,array parameters] ); +* +* // bye bye client +* unset($soapclient); +* +* @author Dietrich Ayala +* @version v 0.6 +* @access public +*/ +class soapclient extends nusoap_base { + + var $username; + var $password; + var $requestHeaders = false; + var $responseHeaders; + var $endpoint; + var $portName; + var $error_str = false; + + /** + * fault related variables + * + * @var fault + * @var faultcode + * @var faultstring + * @var faultdetail + * @access public + */ + var $fault, $faultcode, $faultstring, $faultdetail; + + /** + * constructor + * + * @param string $endpoint SOAP server or WSDL URL + * @param string $wsdl optional, set to true if using WSDL + * @param int $portName optional portName in WSDL document + * @access public + */ + function soapclient($endpoint,$wsdl="",$portName=""){ + $this->endpoint = $endpoint; + $this->portName = $portName; + + // make values + if($wsdl != ""){ + $this->endpointType = "wsdl"; + $this->wsdlFile = $this->endpoint; + if($portName != ""){ + $this->portName = $portName; + } + // instantiate wsdl object and parse wsdl file + $this->debug("instantiating wsdl class with doc: $endpoint"); + $this->wsdl = new wsdl($this->wsdlFile); + // catch errors + if($errstr = $this->wsdl->getError()){ + $this->debug("got wsdl error: $errstr"); + $this->debug("wsdl debug: \n".$this->wsdl->debug_str); + $this->setError('wsdl error: '.$errstr); + } elseif($this->operations = $this->wsdl->getOperations()){ + $this->debug( "got ".count($this->operations)." operations from wsdl $this->wsdlFile
    "); + } + } + } + + /** + * calls method, returns PHP native type + * + * @param string $method SOAP server URL or path + * @param array $params array of parameters, can be associative or not + * @param string $namespace optional method namespace + * @param string $soapAction optional SOAPAction value + * @param boolean $headers optional array of soapval objects for headers + * @return mixed + * @access public + */ + function call($operation,$params=array(),$namespace="",$soapAction="",$headers=false){ + $this->operation = $operation; + $this->fault = false; + $this->error_str = ""; + $this->request = ""; + $this->response = ""; + $this->faultstring = ""; + $this->faultcode = ""; + $this->opData = array(); + // if wsdl, get operation data and process parameters + if($this->endpointType == "wsdl" && $opData = $this->getOperationData($operation)){ + + $this->opData = $opData; + $soapAction = $opData["soapAction"]; + $this->endpoint = $opData['endpoint']; + $this->portName = $opData['portName']; + $namespace = $opData['input']['namespace']; + $style = $opData['style']; + // add ns to ns array + if($namespace != '' && !isset($this->wsdl->namespaces[$namespace])){ + $this->wsdl->namespaces['galactivism'] = $namespace; + } + // serialize payload + if($style == 'rpc'){ + $payload .= "<".$this->wsdl->getPrefixFromNamespace($namespace).":$operation>\n". + $this->wsdl->serializeRPCParameters($operation,'input',$params). + "wsdl->getPrefixFromNamespace($namespace).":$operation>\n"; + } elseif($opData['input']['use'] == 'literal') { + $payload .= array_shift($params); + } + // serialize envelope + $soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders,$this->wsdl->usedNamespaces); + $this->debug("wsdl debug: \n".$this->wsdl->debug_str); + } elseif($this->endpointType == "wsdl") { + $this->setError( "operation $operation not present."); + $this->debug("operation '$operation' not present."); + $this->debug("wsdl debug: \n".$this->wsdl->debug_str); + return false; + // no wsdl + } else { + // make message + if(!$style){ + $style = 'rpc'; + } + // add ns to ns array + if($namespace != ''){ + $this->namespaces['galactivism'] = $namespace; + } + // serialize envelope + foreach($params as $k => $v){ + $payload .= $this->serialize_val($v,$k); + } + $payload = "\n".$payload."\n"; + $soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders); + } + $this->debug("endpoint: $this->endpoint, soapAction: $soapAction, namespace: $namespace"); + // send + $this->debug("sending msg (len: ".strlen($soapmsg).") w/ soapaction '$soapAction'..."); + $return = $this->send($soapmsg,$soapAction); + if($errstr = $this->getError()){ + $this->debug("Error: $errstr"); + return false; + } else { + $this->return = $return; + $this->debug($dbg."sent message successfully and got a(n) ".gettype($return)." back"); + + // fault? + if(is_array($return) && $return['faultcode']){ + $this->debug("got fault"); + $this->setError($return['faultcode'].': '.$return['faultstring']); + $this->fault = true; + foreach($return as $k => $v){ + $this->$k = $v; + $this->debug("$k = $v
    "); + } + return $return; + } else { + // array of return values + if(is_array($return)){ + // multiple 'out' parameters + if(sizeof($return) > 1){ + return $return; + } + // single 'out' parameter + return array_shift($return); + // nothing returned (ie, echoVoid) + } else { + return ""; + } + } + } + } + + /** + * get available data pertaining to an operation + * + * @param string $operation operation name + * @return array array of data pertaining to the operation + * @access public + */ + function getOperationData($operation){ + if(isset($this->operations[$operation])){ + return $this->operations[$operation]; + } + } + + /** + * send the SOAP message + * + * Note: if the operation has multiple return values + * the return value of this method will be an array + * of those values. + * + * @param string $msg a SOAPx4 soapmsg object + * @param string $soapaction SOAPAction value + * @param integer $timeout set timeout in seconds + * @return mixed native PHP types. + * @access public + */ + function send($msg, $soapaction = "", $timeout=0) { + // detect transport + switch(true){ + // http(s) + case ereg('^http',$this->endpoint): + $this->debug('transporting via HTTP'); + //require_once('class.soap_transport_http.php'); + $http = new soap_transport_http($this->endpoint); + $http->setSOAPAction($soapaction); + if($this->proxyhost && $this->proxyport){ + $http->setProxy($this->proxyhost,$this->proxyport); + } + $this->debug('sending message, length: '.strlen($msg)); + if(ereg('^http:',$this->endpoint)){ + $response = $http->send($msg,$timeout); + } elseif(ereg('^https',$this->endpoint)){ + if (!extension_loaded('curl')) { + $this->setError('CURL Extension is required for HTTPS'); + return false; + } + $response = $http->sendHTTPS($msg,$timeout); + } + $this->debug("transport debug data...\n".$http->debug_str); + $this->request = $http->outgoing_payload; + $this->response = $http->incoming_payload; + if($err = $http->getError()){ + $this->setError("HTTP Error: $err"); + return false; + } + $this->debug('got response, length: '.strlen($response)); + return $this->parseResponse($response); + break; + default: + $this->setError('no transport found, or selected transport is not yet supported!'); + return false; + break; + } + } + + /** + * processes SOAP message returned from server + * + * @param string unprocessed response data from server + * @return object SOAPx4 soapval object + * @access public + */ + function parseResponse($data) { + $this->debug("Entering parseResponse(), about to create soap_parser instance"); + $parser = new soap_parser($data,$this->xml_encoding,$this->operation); + // if parse errors + if($errstr = $parser->getError()){ + $this->setError( $errstr); + // destroy the parser object + unset($parser); + return false; + } else { + // get SOAP headers + $this->responseHeaders = $parser->getHeaders(); + // get decoded message + $return = $parser->get_response(); + // add parser debug data to our debug + $this->debug($parser->debug_str); + // destroy the parser object + unset($parser); + // return decode message + return $return; + } + } + + /** + * set the SOAP headers + * + * @param $headers string XML + * @access public + */ + function setHeaders($headers){ + $this->requestHeaders = $headers; + } + + /** + * get the response headers + * + * @return mixed object SOAPx4 soapval object or empty if no headers + * @access public + */ + function getHeaders(){ + if($this->responseHeaders != "") { + return $this->responseHeaders; + } + } + + /** + * set proxy info here + * + * @param string $proxyhost + * @param string $proxyport + * @access public + */ + function setHTTPProxy($proxyhost, $proxyport) { + $this->proxyhost = $proxyhost; + $this->proxyport = $proxyport; + } + + /** + * if authenticating, set user credentials here + * + * @param string $username + * @param string $pword + * @access public + */ + function setCredentials($username, $pword) { + $this->user = $username; + $this->pass = $pword; + } + + /** + * dynamically creates proxy class, allowing user to directly call methods from wsdl + * + * @return object soap_proxy object + * @access public + */ + function getProxy(){ + foreach($this->operations as $operation => $opData){ + if($operation != ""){ + // create param string + if(sizeof($opData['input']['parts']) > 0){ + foreach($opData["input"]["parts"] as $name => $type){ + $paramStr .= "\$$name,"; + } + $paramStr = substr($paramStr,0,strlen($paramStr)-1); + } + $evalStr .= " + function $operation ($paramStr){ + // load params into array + \$params = array($paramStr); + return \$this->call('$operation',\$params,'".$opData['namespace']."','".$opData['soapAction']."'); + } + "; + unset($paramStr); + } + } + $evalStr = " + class soap_proxy extends soapclient { + $evalStr + } + "; + //print "proxy class:
    $evalStr
    "; + // eval the class + eval($evalStr); + // instantiate proxy object + $proxy = new soap_proxy(""); + // transfer current wsdl data to the proxy thereby avoiding parsing the wsdl twice + $proxy->endpointType = 'wsdl'; + $proxy->wsdlFile = $this->wsdlFile; + $proxy->wsdl = $this->wsdl; + $proxy->operations = $this->operations; + return $proxy; + } +} + +?> \ No newline at end of file diff --git a/google/pagemenu.php b/google/pagemenu.php new file mode 100755 index 0000000..857956e --- /dev/null +++ b/google/pagemenu.php @@ -0,0 +1,65 @@ += $Total) + { + $MaxPage = $CurrentPage; + } + else + { + $MaxPage = ceil($Total / $MaxPerPage); + if ($MaxPage - PageSpread() >= $CurrentPage) + { + $MaxPage = $CurrentPage + PageSpread(); + } + } + return $MaxPage + 1; + } + + function PageMenu($Query, $Site, $Start, $Total, $MaxPerPage) + { + $CurrentPage = CurrentPage($Start, $MaxPerPage); + + $Site = GetParam("Site", ""); + + $MinPage = MinPage($CurrentPage, $Start, $Total, $MaxPerPage); + $MaxPage = MaxPage($CurrentPage, $Start, $Total, $MaxPerPage); + + for ($i = $MinPage; $i < $MaxPage; $i++) + { + $PageNumber[$i-1] = $i; + $Page[$i-1] = $GLOBALS["PHP_SELF"]."?Query=".$Query."&Site=".$Site."&Start=".(($i-1)*$MaxPerPage); + } + + //return $Result; + $PageMenuTemplate = new Smarty; + $PageMenuTemplate->compile_dir = SmartyCompileDir(); + $PageMenuTemplate->Assign('NumPages', $i + 1); + $PageMenuTemplate->Assign('Page', $Page); + $PageMenuTemplate->Assign('PageNumber', $PageNumber); + + return $PageMenuTemplate->fetch('pagemenu.tpl.htm'); + } +?> diff --git a/google/pagemenu.tpl.htm b/google/pagemenu.tpl.htm new file mode 100755 index 0000000..fc51338 --- /dev/null +++ b/google/pagemenu.tpl.htm @@ -0,0 +1,13 @@ +
    +
    + + + + + {section name=i loop=$Page} + + {/section} + +
    +

    Page

     {$PageNumber[i]} 
    +
    \ No newline at end of file diff --git a/google/readme.txt b/google/readme.txt new file mode 100755 index 0000000..5751c6f --- /dev/null +++ b/google/readme.txt @@ -0,0 +1,28 @@ +1. Copy files to a directory. +2. Modify background.php with a text editor. + + function MainSearchSite() + { + return "thinkbling.com";//Leave blank for the entire web. + } + + function GoogleKey() + { + return "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; + } + + a. Where it says "thinkbling.com", choose your target site or leave blank to have all. + b. If you want all Also modify the options function to return false. + c. Get your Google Key from http://www.google.com/apis/ + There you will need to sign up with Google to get your key. + +3. CHMOD the directory that you created to 777. +4. Run setup.php. +5. CMHMOD the directory back to the original value (Probably 755). + + +VERY IMPORTANT NOTE: +This download contains nusoap.php and Smarty and is restricted by the license detailed at + http://dietrich.ganx4.com/nusoap/ +and... + http://smarty.php.net/copyright.php diff --git a/google/results.php b/google/results.php new file mode 100755 index 0000000..a715d6f --- /dev/null +++ b/google/results.php @@ -0,0 +1,74 @@ +compile_dir = FullSmartyCompileDir(); + + $Query = GetParam("Query", ""); + + if ($Query == "") + { + return; + } + + $Site = GetParam("Site", ""); + if ($Site != "") + { + $Site = " site:$Site"; + } + + $Start = intval(GetParam("Start", 0)); + + $GoogleKey = GoogleKey(); + $GoogleAPIURL = GoogleAPIURL(); + $MaxResults = MaxResults(); + + $Param = array("key" => $GoogleKey, + "q" => $Query.$Site, + "start" => $Start, + "maxResults" => $MaxResults, + "filter" => false, + "restrict" => "", + "safeSearch" => false, + "lr" => "lang_en", + "ie" => "", + "oe" => ""); + + // Create a new client by providing the endpoint to the constructor. + $Client = new soapclient($GoogleAPIURL); + + $QueryResult = $Client->call("doGoogleSearch", $Param, "urn:GoogleSearch"); + $Searchtime = $QueryResult["searchTime"]; + $Begin = $Start + 1; + $End = $Start + $Param["maxResults"]; + $Total = $QueryResult["estimatedTotalResultsCount"]; + + if ($Total > 0) + { + $QueryResult = $QueryResult["resultElements"]; + + for ($i = 0; $i < $MaxResults; $i++) + { + $Element = $QueryResult[$i]; + $Snippet[$i] = $Element["snippet"]; + $URL[$i] = $Element["URL"]; + $Title[$i] = $Element["title"]; + } + } + $ResultsTemplate->Assign('Snippet', $Snippet); + $ResultsTemplate->Assign('URL', $URL); + $ResultsTemplate->Assign('Title', $Title); + + $Result = $ResultsTemplate->fetch('results.tpl.htm') . PageMenu($Query, $Site, $Start, $Total, $MaxResults); + + return $Result; + } + +?> \ No newline at end of file diff --git a/google/results.tpl.htm b/google/results.tpl.htm new file mode 100755 index 0000000..646b7c1 --- /dev/null +++ b/google/results.tpl.htm @@ -0,0 +1,16 @@ +{$SearchResults} +{section name=i loop=$Title} + + + + + + + + + + + + +{/section} +
    {$Title[i]}
    {$Snippet[i]}
    {$URL[i]}
     
    \ No newline at end of file diff --git a/google/search.php b/google/search.php new file mode 100755 index 0000000..1e44a3e --- /dev/null +++ b/google/search.php @@ -0,0 +1,24 @@ +compile_dir = FullSmartyCompileDir(); + $SearchTemplate->Assign('Query', $Query); + + if (ShowOptions()) + { + $SearchTemplate->assign('Options', array(MainSearchSite() => MainSearchSite(), + "" => 'The World')); + $SearchTemplate->Assign('Selected', $Site); + } + + return $SearchTemplate->fetch('search.tpl.htm'); + } +?> diff --git a/google/search.tpl.htm b/google/search.tpl.htm new file mode 100755 index 0000000..63f5eca --- /dev/null +++ b/google/search.tpl.htm @@ -0,0 +1,15 @@ +
    +
    + + + + + + + +
    +{$SearchType} Search: +

    +
    {html_radios name="Site" options=$Options selected=$Selected separator=" "}
    +
    +
    diff --git a/google/setup.php b/google/setup.php new file mode 100755 index 0000000..5bae69f --- /dev/null +++ b/google/setup.php @@ -0,0 +1,29 @@ +Please delete this file."); + } +?> \ No newline at end of file diff --git a/google/smarty/.cvsignore b/google/smarty/.cvsignore new file mode 100755 index 0000000..cdf4cb4 --- /dev/null +++ b/google/smarty/.cvsignore @@ -0,0 +1 @@ +! diff --git a/google/smarty/Config_File.class.php b/google/smarty/Config_File.class.php new file mode 100755 index 0000000..0330f94 --- /dev/null +++ b/google/smarty/Config_File.class.php @@ -0,0 +1,389 @@ + + * @access public + * @package Smarty + */ + +/* $Id: Config_File.class.php,v 1.1.1.1 2006/03/27 14:44:14 cscott Exp $ */ + +/** + * Config file reading class + * @package Smarty + */ +class Config_File { + /**#@+ + * Options + * @var boolean + */ + /** + * Controls whether variables with the same name overwrite each other. + */ + var $overwrite = true; + + /** + * Controls whether config values of on/true/yes and off/false/no get + * converted to boolean values automatically. + */ + var $booleanize = true; + + /** + * Controls whether hidden config sections/vars are read from the file. + */ + var $read_hidden = true; + + /** + * Controls whether or not to fix mac or dos formatted newlines. + * If set to true, \r or \r\n will be changed to \n. + */ + var $fix_newlines = true; + /**#@-*/ + + /** @access private */ + var $_config_path = ""; + var $_config_data = array(); + /**#@-*/ + + /** + * Constructs a new config file class. + * + * @param string $config_path (optional) path to the config files + */ + function Config_File($config_path = NULL) + { + if (isset($config_path)) + $this->set_path($config_path); + } + + + /** + * Set the path where configuration files can be found. + * + * @param string $config_path path to the config files + */ + function set_path($config_path) + { + if (!empty($config_path)) { + if (!is_string($config_path) || !file_exists($config_path) || !is_dir($config_path)) { + $this->_trigger_error_msg("Bad config file path '$config_path'"); + return; + } + if(substr($config_path, -1) != DIRECTORY_SEPARATOR) { + $config_path .= DIRECTORY_SEPARATOR; + } + + $this->_config_path = $config_path; + } + } + + + /** + * Retrieves config info based on the file, section, and variable name. + * + * @param string $file_name config file to get info for + * @param string $section_name (optional) section to get info for + * @param string $var_name (optional) variable to get info for + * @return string|array a value or array of values + */ + function &get($file_name, $section_name = NULL, $var_name = NULL) + { + if (empty($file_name)) { + $this->_trigger_error_msg('Empty config file name'); + return; + } else { + $file_name = $this->_config_path . $file_name; + if (!isset($this->_config_data[$file_name])) + $this->load_file($file_name, false); + } + + if (!empty($var_name)) { + if (empty($section_name)) { + return $this->_config_data[$file_name]["vars"][$var_name]; + } else { + if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name])) + return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name]; + else + return array(); + } + } else { + if (empty($section_name)) { + return (array)$this->_config_data[$file_name]["vars"]; + } else { + if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"])) + return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"]; + else + return array(); + } + } + } + + + /** + * Retrieves config info based on the key. + * + * @param $file_name string config key (filename/section/var) + * @return string|array same as get() + * @uses get() retrieves information from config file and returns it + */ + function &get_key($config_key) + { + list($file_name, $section_name, $var_name) = explode('/', $config_key, 3); + $result = &$this->get($file_name, $section_name, $var_name); + return $result; + } + + /** + * Get all loaded config file names. + * + * @return array an array of loaded config file names + */ + function get_file_names() + { + return array_keys($this->_config_data); + } + + + /** + * Get all section names from a loaded file. + * + * @param string $file_name config file to get section names from + * @return array an array of section names from the specified file + */ + function get_section_names($file_name) + { + $file_name = $this->_config_path . $file_name; + if (!isset($this->_config_data[$file_name])) { + $this->_trigger_error_msg("Unknown config file '$file_name'"); + return; + } + + return array_keys($this->_config_data[$file_name]["sections"]); + } + + + /** + * Get all global or section variable names. + * + * @param string $file_name config file to get info for + * @param string $section_name (optional) section to get info for + * @return array an array of variables names from the specified file/section + */ + function get_var_names($file_name, $section = NULL) + { + if (empty($file_name)) { + $this->_trigger_error_msg('Empty config file name'); + return; + } else if (!isset($this->_config_data[$file_name])) { + $this->_trigger_error_msg("Unknown config file '$file_name'"); + return; + } + + if (empty($section)) + return array_keys($this->_config_data[$file_name]["vars"]); + else + return array_keys($this->_config_data[$file_name]["sections"][$section]["vars"]); + } + + + /** + * Clear loaded config data for a certain file or all files. + * + * @param string $file_name file to clear config data for + */ + function clear($file_name = NULL) + { + if ($file_name === NULL) + $this->_config_data = array(); + else if (isset($this->_config_data[$file_name])) + $this->_config_data[$file_name] = array(); + } + + + /** + * Load a configuration file manually. + * + * @param string $file_name file name to load + * @param boolean $prepend_path whether current config path should be + * prepended to the filename + */ + function load_file($file_name, $prepend_path = true) + { + if ($prepend_path && $this->_config_path != "") + $config_file = $this->_config_path . $file_name; + else + $config_file = $file_name; + + ini_set('track_errors', true); + $fp = @fopen($config_file, "r"); + if (!is_resource($fp)) { + $this->_trigger_error_msg("Could not open config file '$config_file'"); + return false; + } + + $contents = fread($fp, filesize($config_file)); + fclose($fp); + + $this->_config_data[$config_file] = $this->parse_contents($contents); + return true; + } + + /** + * Store the contents of a file manually. + * + * @param string $config_file file name of the related contents + * @param string $contents the file-contents to parse + */ + function set_file_contents($config_file, $contents) + { + $this->_config_data[$config_file] = $this->parse_contents($contents); + return true; + } + + /** + * parse the source of a configuration file manually. + * + * @param string $contents the file-contents to parse + */ + function parse_contents($contents) + { + if($this->fix_newlines) { + // fix mac/dos formatted newlines + $contents = preg_replace('!\r\n?!', "\n", $contents); + } + + $config_data = array(); + $config_data['sections'] = array(); + $config_data['vars'] = array(); + + /* reference to fill with data */ + $vars =& $config_data['vars']; + + /* parse file line by line */ + preg_match_all('!^.*\r?\n?!m', $contents, $match); + $lines = $match[0]; + for ($i=0, $count=count($lines); $i<$count; $i++) { + $line = $lines[$i]; + if (empty($line)) continue; + + if ( $line{0} == '[' && preg_match('!^\[(.*?)\]!', $line, $match) ) { + /* section found */ + if ($match[1]{0} == '.') { + /* hidden section */ + if ($this->read_hidden) { + $section_name = substr($match[1], 1); + } else { + /* break reference to $vars to ignore hidden section */ + unset($vars); + $vars = array(); + continue; + } + } else { + $section_name = $match[1]; + } + if (!isset($config_data['sections'][$section_name])) + $config_data['sections'][$section_name] = array('vars' => array()); + $vars =& $config_data['sections'][$section_name]['vars']; + continue; + } + + if (preg_match('/^\s*(\.?\w+)\s*=\s*(.*)/s', $line, $match)) { + /* variable found */ + $var_name = rtrim($match[1]); + if (strpos($match[2], '"""') === 0) { + /* handle multiline-value */ + $lines[$i] = substr($match[2], 3); + $var_value = ''; + while ($i<$count) { + if (($pos = strpos($lines[$i], '"""')) === false) { + $var_value .= $lines[$i++]; + } else { + /* end of multiline-value */ + $var_value .= substr($lines[$i], 0, $pos); + break; + } + } + $booleanize = false; + + } else { + /* handle simple value */ + $var_value = preg_replace('/^([\'"])(.*)\1$/', '\2', rtrim($match[2])); + $booleanize = $this->booleanize; + + } + $this->_set_config_var($vars, $var_name, $var_value, $booleanize); + } + /* else unparsable line / means it is a comment / means ignore it */ + } + return $config_data; + } + + /**#@+ @access private */ + /** + * @param array &$container + * @param string $var_name + * @param mixed $var_value + * @param boolean $booleanize determines whether $var_value is converted to + * to true/false + */ + function _set_config_var(&$container, $var_name, $var_value, $booleanize) + { + if ($var_name{0} == '.') { + if (!$this->read_hidden) + return; + else + $var_name = substr($var_name, 1); + } + + if (!preg_match("/^[a-zA-Z_]\w*$/", $var_name)) { + $this->_trigger_error_msg("Bad variable name '$var_name'"); + return; + } + + if ($booleanize) { + if (preg_match("/^(on|true|yes)$/i", $var_value)) + $var_value = true; + else if (preg_match("/^(off|false|no)$/i", $var_value)) + $var_value = false; + } + + if (!isset($container[$var_name]) || $this->overwrite) + $container[$var_name] = $var_value; + else { + settype($container[$var_name], 'array'); + $container[$var_name][] = $var_value; + } + } + + /** + * @uses trigger_error() creates a PHP warning/error + * @param string $error_msg + * @param integer $error_type one of + */ + function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING) + { + trigger_error("Config_File error: $error_msg", $error_type); + } + /**#@-*/ +} + +?> diff --git a/google/smarty/Smarty.class.php b/google/smarty/Smarty.class.php new file mode 100755 index 0000000..eb0a0a2 --- /dev/null +++ b/google/smarty/Smarty.class.php @@ -0,0 +1,1984 @@ + + * @author Andrei Zmievski + * @package Smarty + * @version 2.6.2 + */ + +/* $Id: Smarty.class.php,v 1.1.1.1 2006/03/27 14:44:14 cscott Exp $ */ + +/** + * DIR_SEP isn't used anymore, but third party apps might + */ +if(!defined('DIR_SEP')) { + define('DIR_SEP', DIRECTORY_SEPARATOR); +} + +/** + * set SMARTY_DIR to absolute path to Smarty library files. + * if not defined, include_path will be used. Sets SMARTY_DIR only if user + * application has not already defined it. + */ + +if (!defined('SMARTY_DIR')) { + define('SMARTY_DIR', BASE."google/smarty/"); +} + +define('SMARTY_PHP_PASSTHRU', 0); +define('SMARTY_PHP_QUOTE', 1); +define('SMARTY_PHP_REMOVE', 2); +define('SMARTY_PHP_ALLOW', 3); + +/** + * @package Smarty + */ +class Smarty +{ + /**#@+ + * Smarty Configuration Section + */ + + /** + * The name of the directory where templates are located. + * + * @var string + */ + var $template_dir = 'templates'; + + /** + * The directory where compiled templates are located. + * + * @var string + */ + var $compile_dir = 'templates_c'; + + /** + * The directory where config files are located. + * + * @var string + */ + var $config_dir = 'configs'; + + /** + * An array of directories searched for plugins. + * + * @var array + */ + var $plugins_dir = array('plugins'); + + /** + * If debugging is enabled, a debug console window will display + * when the page loads (make sure your browser allows unrequested + * popup windows) + * + * @var boolean + */ + var $debugging = false; + + /** + * When set, smarty does uses this value as error_reporting-level. + * + * @var boolean + */ + var $error_reporting = null; + + /** + * This is the path to the debug console template. If not set, + * the default one will be used. + * + * @var string + */ + var $debug_tpl = ''; + + /** + * This determines if debugging is enable-able from the browser. + *
      + *
    • NONE => no debugging control allowed
    • + *
    • URL => enable debugging when SMARTY_DEBUG is found in the URL.
    • + *
    + * @link http://www.foo.dom/index.php?SMARTY_DEBUG + * @var string + */ + var $debugging_ctrl = 'NONE'; + + /** + * This tells Smarty whether to check for recompiling or not. Recompiling + * does not need to happen unless a template or config file is changed. + * Typically you enable this during development, and disable for + * production. + * + * @var boolean + */ + var $compile_check = true; + + /** + * This forces templates to compile every time. Useful for development + * or debugging. + * + * @var boolean + */ + var $force_compile = false; + + /** + * This enables template caching. + *
      + *
    • 0 = no caching
    • + *
    • 1 = use class cache_lifetime value
    • + *
    • 2 = use cache_lifetime in cache file
    • + *
    + * @var integer + */ + var $caching = 0; + + /** + * The name of the directory for cache files. + * + * @var string + */ + var $cache_dir = 'cache'; + + /** + * This is the number of seconds cached content will persist. + *
      + *
    • 0 = always regenerate cache
    • + *
    • -1 = never expires
    • + *
    + * + * @var integer + */ + var $cache_lifetime = 3600; + + /** + * Only used when $caching is enabled. If true, then If-Modified-Since headers + * are respected with cached content, and appropriate HTTP headers are sent. + * This way repeated hits to a cached page do not send the entire page to the + * client every time. + * + * @var boolean + */ + var $cache_modified_check = false; + + /** + * This determines how Smarty handles "" tags in templates. + * possible values: + *
      + *
    • SMARTY_PHP_PASSTHRU -> print tags as plain text
    • + *
    • SMARTY_PHP_QUOTE -> escape tags as entities
    • + *
    • SMARTY_PHP_REMOVE -> remove php tags
    • + *
    • SMARTY_PHP_ALLOW -> execute php tags
    • + *
    + * + * @var integer + */ + var $php_handling = SMARTY_PHP_PASSTHRU; + + /** + * This enables template security. When enabled, many things are restricted + * in the templates that normally would go unchecked. This is useful when + * untrusted parties are editing templates and you want a reasonable level + * of security. (no direct execution of PHP in templates for example) + * + * @var boolean + */ + var $security = false; + + /** + * This is the list of template directories that are considered secure. This + * is used only if {@link $security} is enabled. One directory per array + * element. {@link $template_dir} is in this list implicitly. + * + * @var array + */ + var $secure_dir = array(); + + /** + * These are the security settings for Smarty. They are used only when + * {@link $security} is enabled. + * + * @var array + */ + var $security_settings = array( + 'PHP_HANDLING' => false, + 'IF_FUNCS' => array('array', 'list', + 'isset', 'empty', + 'count', 'sizeof', + 'in_array', 'is_array', + 'true','false'), + 'INCLUDE_ANY' => false, + 'PHP_TAGS' => false, + 'MODIFIER_FUNCS' => array('count'), + 'ALLOW_CONSTANTS' => false + ); + + /** + * This is an array of directories where trusted php scripts reside. + * {@link $security} is disabled during their inclusion/execution. + * + * @var array + */ + var $trusted_dir = array(); + + /** + * The left delimiter used for the template tags. + * + * @var string + */ + var $left_delimiter = '{'; + + /** + * The right delimiter used for the template tags. + * + * @var string + */ + var $right_delimiter = '}'; + + /** + * The order in which request variables are registered, similar to + * variables_order in php.ini E = Environment, G = GET, P = POST, + * C = Cookies, S = Server + * + * @var string + */ + var $request_vars_order = "EGPCS"; + + /** + * Indicates wether $HTTP_*_VARS[] (request_use_auto_globals=false) + * are uses as request-vars or $_*[]-vars. note: if + * request_use_auto_globals is true, then $request_vars_order has + * no effect, but the php-ini-value "gpc_order" + * + * @var boolean + */ + var $request_use_auto_globals = true; + + /** + * Set this if you want different sets of compiled files for the same + * templates. This is useful for things like different languages. + * Instead of creating separate sets of templates per language, you + * set different compile_ids like 'en' and 'de'. + * + * @var string + */ + var $compile_id = null; + + /** + * This tells Smarty whether or not to use sub dirs in the cache/ and + * templates_c/ directories. sub directories better organized, but + * may not work well with PHP safe mode enabled. + * + * @var boolean + * + */ + var $use_sub_dirs = false; + + /** + * This is a list of the modifiers to apply to all template variables. + * Put each modifier in a separate array element in the order you want + * them applied. example: array('escape:"htmlall"'); + * + * @var array + */ + var $default_modifiers = array(); + + /** + * This is the resource type to be used when not specified + * at the beginning of the resource path. examples: + * $smarty->display('file:index.tpl'); + * $smarty->display('db:index.tpl'); + * $smarty->display('index.tpl'); // will use default resource type + * {include file="file:index.tpl"} + * {include file="db:index.tpl"} + * {include file="index.tpl"} {* will use default resource type *} + * + * @var array + */ + var $default_resource_type = 'file'; + + /** + * The function used for cache file handling. If not set, built-in caching is used. + * + * @var null|string function name + */ + var $cache_handler_func = null; + + /** + * This indicates which filters are automatically loaded into Smarty. + * + * @var array array of filter names + */ + var $autoload_filters = array(); + + /**#@+ + * @var boolean + */ + /** + * This tells if config file vars of the same name overwrite each other or not. + * if disabled, same name variables are accumulated in an array. + */ + var $config_overwrite = true; + + /** + * This tells whether or not to automatically booleanize config file variables. + * If enabled, then the strings "on", "true", and "yes" are treated as boolean + * true, and "off", "false" and "no" are treated as boolean false. + */ + var $config_booleanize = true; + + /** + * This tells whether hidden sections [.foobar] are readable from the + * tempalates or not. Normally you would never allow this since that is + * the point behind hidden sections: the application can access them, but + * the templates cannot. + */ + var $config_read_hidden = false; + + /** + * This tells whether or not automatically fix newlines in config files. + * It basically converts \r (mac) or \r\n (dos) to \n + */ + var $config_fix_newlines = true; + /**#@-*/ + + /** + * If a template cannot be found, this PHP function will be executed. + * Useful for creating templates on-the-fly or other special action. + * + * @var string function name + */ + var $default_template_handler_func = ''; + + /** + * The file that contains the compiler class. This can a full + * pathname, or relative to the php_include path. + * + * @var string + */ + var $compiler_file = 'Smarty_Compiler.class.php'; + + /** + * The class used for compiling templates. + * + * @var string + */ + var $compiler_class = 'Smarty_Compiler'; + + /** + * The class used to load config vars. + * + * @var string + */ + var $config_class = 'Config_File'; + +/**#@+ + * END Smarty Configuration Section + * There should be no need to touch anything below this line. + * @access private + */ + /** + * error messages. true/false + * + * @var boolean + */ + var $_error_msg = false; + + /** + * where assigned template vars are kept + * + * @var array + */ + var $_tpl_vars = array(); + + /** + * stores run-time $smarty.* vars + * + * @var null|array + */ + var $_smarty_vars = null; + + /** + * keeps track of sections + * + * @var array + */ + var $_sections = array(); + + /** + * keeps track of foreach blocks + * + * @var array + */ + var $_foreach = array(); + + /** + * keeps track of tag hierarchy + * + * @var array + */ + var $_tag_stack = array(); + + /** + * configuration object + * + * @var Config_file + */ + var $_conf_obj = null; + + /** + * loaded configuration settings + * + * @var array + */ + var $_config = array(array('vars' => array(), 'files' => array())); + + /** + * md5 checksum of the string 'Smarty' + * + * @var string + */ + var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; + + /** + * Smarty version number + * + * @var string + */ + var $_version = '2.6.2'; + + /** + * current template inclusion depth + * + * @var integer + */ + var $_inclusion_depth = 0; + + /** + * for different compiled templates + * + * @var string + */ + var $_compile_id = null; + + /** + * text in URL to enable debug mode + * + * @var string + */ + var $_smarty_debug_id = 'SMARTY_DEBUG'; + + /** + * debugging information for debug console + * + * @var array + */ + var $_smarty_debug_info = array(); + + /** + * info that makes up a cache file + * + * @var array + */ + var $_cache_info = array(); + + /** + * default file permissions + * + * @var integer + */ + var $_file_perms = 0644; + + /** + * default dir permissions + * + * @var integer + */ + var $_dir_perms = 0771; + + /** + * registered objects + * + * @var array + */ + var $_reg_objects = array(); + + /** + * table keeping track of plugins + * + * @var array + */ + var $_plugins = array( + 'modifier' => array(), + 'function' => array(), + 'block' => array(), + 'compiler' => array(), + 'prefilter' => array(), + 'postfilter' => array(), + 'outputfilter' => array(), + 'resource' => array(), + 'insert' => array()); + + + /** + * cache serials + * + * @var array + */ + var $_cache_serials = array(); + + /** + * name of optional cache include file + * + * @var string + */ + var $_cache_include = null; + + /** + * indicate if the current code is used in a compiled + * include + * + * @var string + */ + var $_cache_including = false; + + /**#@-*/ + /** + * The class constructor. + */ + function Smarty() + { + $this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] + : @$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']); + } + + /** + * assigns values to template variables + * + * @param array|string $tpl_var the template variable name(s) + * @param mixed $value the value to assign + */ + function assign($tpl_var, $value = null) + { + if (is_array($tpl_var)){ + foreach ($tpl_var as $key => $val) { + if ($key != '') { + $this->_tpl_vars[$key] = $val; + } + } + } else { + if ($tpl_var != '') + $this->_tpl_vars[$tpl_var] = $value; + } + } + + /** + * assigns values to template variables by reference + * + * @param string $tpl_var the template variable name + * @param mixed $value the referenced value to assign + */ + function assign_by_ref($tpl_var, &$value) + { + if ($tpl_var != '') + $this->_tpl_vars[$tpl_var] = &$value; + } + + /** + * appends values to template variables + * + * @param array|string $tpl_var the template variable name(s) + * @param mixed $value the value to append + */ + function append($tpl_var, $value=null, $merge=false) + { + if (is_array($tpl_var)) { + // $tpl_var is an array, ignore $value + foreach ($tpl_var as $_key => $_val) { + if ($_key != '') { + if(!@is_array($this->_tpl_vars[$_key])) { + settype($this->_tpl_vars[$_key],'array'); + } + if($merge && is_array($_val)) { + foreach($_val as $_mkey => $_mval) { + $this->_tpl_vars[$_key][$_mkey] = $_mval; + } + } else { + $this->_tpl_vars[$_key][] = $_val; + } + } + } + } else { + if ($tpl_var != '' && isset($value)) { + if(!@is_array($this->_tpl_vars[$tpl_var])) { + settype($this->_tpl_vars[$tpl_var],'array'); + } + if($merge && is_array($value)) { + foreach($value as $_mkey => $_mval) { + $this->_tpl_vars[$tpl_var][$_mkey] = $_mval; + } + } else { + $this->_tpl_vars[$tpl_var][] = $value; + } + } + } + } + + /** + * appends values to template variables by reference + * + * @param string $tpl_var the template variable name + * @param mixed $value the referenced value to append + */ + function append_by_ref($tpl_var, &$value, $merge=false) + { + if ($tpl_var != '' && isset($value)) { + if(!@is_array($this->_tpl_vars[$tpl_var])) { + settype($this->_tpl_vars[$tpl_var],'array'); + } + if ($merge && is_array($value)) { + foreach($value as $_key => $_val) { + $this->_tpl_vars[$tpl_var][$_key] = &$value[$_key]; + } + } else { + $this->_tpl_vars[$tpl_var][] = &$value; + } + } + } + + + /** + * clear the given assigned template variable. + * + * @param string $tpl_var the template variable to clear + */ + function clear_assign($tpl_var) + { + if (is_array($tpl_var)) + foreach ($tpl_var as $curr_var) + unset($this->_tpl_vars[$curr_var]); + else + unset($this->_tpl_vars[$tpl_var]); + } + + + /** + * Registers custom function to be used in templates + * + * @param string $function the name of the template function + * @param string $function_impl the name of the PHP function to register + */ + function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null) + { + $this->_plugins['function'][$function] = + array($function_impl, null, null, false, $cacheable, $cache_attrs); + + } + + /** + * Unregisters custom function + * + * @param string $function name of template function + */ + function unregister_function($function) + { + unset($this->_plugins['function'][$function]); + } + + /** + * Registers object to be used in templates + * + * @param string $object name of template object + * @param object &$object_impl the referenced PHP object to register + * @param null|array $allowed list of allowed methods (empty = all) + * @param boolean $smarty_args smarty argument format, else traditional + * @param null|array $block_functs list of methods that are block format + */ + function register_object($object, &$object_impl, $allowed = array(), $smarty_args = true, $block_methods = array()) + { + settype($allowed, 'array'); + settype($smarty_args, 'boolean'); + $this->_reg_objects[$object] = + array(&$object_impl, $allowed, $smarty_args, $block_methods); + } + + /** + * Unregisters object + * + * @param string $object name of template object + */ + function unregister_object($object) + { + unset($this->_reg_objects[$object]); + } + + + /** + * Registers block function to be used in templates + * + * @param string $block name of template block + * @param string $block_impl PHP function to register + */ + function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null) + { + $this->_plugins['block'][$block] = + array($block_impl, null, null, false, $cacheable, $cache_attrs); + } + + /** + * Unregisters block function + * + * @param string $block name of template function + */ + function unregister_block($block) + { + unset($this->_plugins['block'][$block]); + } + + /** + * Registers compiler function + * + * @param string $function name of template function + * @param string $function_impl name of PHP function to register + */ + function register_compiler_function($function, $function_impl, $cacheable=true) + { + $this->_plugins['compiler'][$function] = + array($function_impl, null, null, false, $cacheable); + } + + /** + * Unregisters compiler function + * + * @param string $function name of template function + */ + function unregister_compiler_function($function) + { + unset($this->_plugins['compiler'][$function]); + } + + /** + * Registers modifier to be used in templates + * + * @param string $modifier name of template modifier + * @param string $modifier_impl name of PHP function to register + */ + function register_modifier($modifier, $modifier_impl) + { + $this->_plugins['modifier'][$modifier] = + array($modifier_impl, null, null, false); + } + + /** + * Unregisters modifier + * + * @param string $modifier name of template modifier + */ + function unregister_modifier($modifier) + { + unset($this->_plugins['modifier'][$modifier]); + } + + /** + * Registers a resource to fetch a template + * + * @param string $type name of resource + * @param array $functions array of functions to handle resource + */ + function register_resource($type, $functions) + { + if (count($functions)==4) { + $this->_plugins['resource'][$type] = + array($functions, false); + + } elseif (count($functions)==5) { + $this->_plugins['resource'][$type] = + array(array(array(&$functions[0], $functions[1]) + ,array(&$functions[0], $functions[2]) + ,array(&$functions[0], $functions[3]) + ,array(&$functions[0], $functions[4])) + ,false); + + } else { + $this->trigger_error("malformed function-list for '$type' in register_resource"); + + } + } + + /** + * Unregisters a resource + * + * @param string $type name of resource + */ + function unregister_resource($type) + { + unset($this->_plugins['resource'][$type]); + } + + /** + * Registers a prefilter function to apply + * to a template before compiling + * + * @param string $function name of PHP function to register + */ + function register_prefilter($function) + { + $_name = (is_array($function)) ? $function[1] : $function; + $this->_plugins['prefilter'][$_name] + = array($function, null, null, false); + } + + /** + * Unregisters a prefilter function + * + * @param string $function name of PHP function + */ + function unregister_prefilter($function) + { + unset($this->_plugins['prefilter'][$function]); + } + + /** + * Registers a postfilter function to apply + * to a compiled template after compilation + * + * @param string $function name of PHP function to register + */ + function register_postfilter($function) + { + $_name = (is_array($function)) ? $function[1] : $function; + $this->_plugins['postfilter'][$_name] + = array($function, null, null, false); + } + + /** + * Unregisters a postfilter function + * + * @param string $function name of PHP function + */ + function unregister_postfilter($function) + { + unset($this->_plugins['postfilter'][$function]); + } + + /** + * Registers an output filter function to apply + * to a template output + * + * @param string $function name of PHP function + */ + function register_outputfilter($function) + { + $_name = (is_array($function)) ? $function[1] : $function; + $this->_plugins['outputfilter'][$_name] + = array($function, null, null, false); + } + + /** + * Unregisters an outputfilter function + * + * @param string $function name of PHP function + */ + function unregister_outputfilter($function) + { + unset($this->_plugins['outputfilter'][$function]); + } + + /** + * load a filter of specified type and name + * + * @param string $type filter type + * @param string $name filter name + */ + function load_filter($type, $name) + { + switch ($type) { + case 'output': + $_params = array('plugins' => array(array($type . 'filter', $name, null, null, false))); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php'); + smarty_core_load_plugins($_params, $this); + break; + + case 'pre': + case 'post': + if (!isset($this->_plugins[$type . 'filter'][$name])) + $this->_plugins[$type . 'filter'][$name] = false; + break; + } + } + + /** + * clear cached content for the given template and cache id + * + * @param string $tpl_file name of template file + * @param string $cache_id name of cache_id + * @param string $compile_id name of compile_id + * @param string $exp_time expiration time + * @return boolean + */ + function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null) + { + + if (!isset($compile_id)) + $compile_id = $this->compile_id; + + if (!isset($tpl_file)) + $compile_id = null; + + $_auto_id = $this->_get_auto_id($cache_id, $compile_id); + + if (!empty($this->cache_handler_func)) { + return call_user_func_array($this->cache_handler_func, + array('clear', &$this, &$dummy, $tpl_file, $cache_id, $compile_id, $exp_time)); + } else { + $_params = array('auto_base' => $this->cache_dir, + 'auto_source' => $tpl_file, + 'auto_id' => $_auto_id, + 'exp_time' => $exp_time); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rm_auto.php'); + return smarty_core_rm_auto($_params, $this); + } + + } + + + /** + * clear the entire contents of cache (all templates) + * + * @param string $exp_time expire time + * @return boolean results of {@link smarty_core_rm_auto()} + */ + function clear_all_cache($exp_time = null) + { + if (!empty($this->cache_handler_func)) { + $dummy = null; + call_user_func_array($this->cache_handler_func, + array('clear', &$this, &$dummy, null, null, null, $exp_time)); + } else { + $_params = array('auto_base' => $this->cache_dir, + 'auto_source' => null, + 'auto_id' => null, + 'exp_time' => $exp_time); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rm_auto.php'); + return smarty_core_rm_auto($_params, $this); + } + } + + + /** + * test to see if valid cache exists for this template + * + * @param string $tpl_file name of template file + * @param string $cache_id + * @param string $compile_id + * @return string|false results of {@link _read_cache_file()} + */ + function is_cached($tpl_file, $cache_id = null, $compile_id = null) + { + if (!$this->caching) + return false; + + if (!isset($compile_id)) + $compile_id = $this->compile_id; + + $_params = array( + 'tpl_file' => $tpl_file, + 'cache_id' => $cache_id, + 'compile_id' => $compile_id + ); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.read_cache_file.php'); + return smarty_core_read_cache_file($_params, $this); + } + + + /** + * clear all the assigned template variables. + * + */ + function clear_all_assign() + { + $this->_tpl_vars = array(); + } + + /** + * clears compiled version of specified template resource, + * or all compiled template files if one is not specified. + * This function is for advanced use only, not normally needed. + * + * @param string $tpl_file + * @param string $compile_id + * @param string $exp_time + * @return boolean results of {@link smarty_core_rm_auto()} + */ + function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null) + { + if (!isset($compile_id)) { + $compile_id = $this->compile_id; + } + $_params = array('auto_base' => $this->compile_dir, + 'auto_source' => $tpl_file, + 'auto_id' => $compile_id, + 'exp_time' => $exp_time, + 'extensions' => array('.inc', '.php')); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rm_auto.php'); + return smarty_core_rm_auto($_params, $this); + } + + /** + * Checks whether requested template exists. + * + * @param string $tpl_file + * @return boolean + */ + function template_exists($tpl_file) + { + $_params = array('resource_name' => $tpl_file, 'quiet'=>true, 'get_source'=>false); + return $this->_fetch_resource_info($_params); + } + + /** + * Returns an array containing template variables + * + * @param string $name + * @param string $type + * @return array + */ + function &get_template_vars($name=null) + { + if(!isset($name)) { + return $this->_tpl_vars; + } + if(isset($this->_tpl_vars[$name])) { + return $this->_tpl_vars[$name]; + } + } + + /** + * Returns an array containing config variables + * + * @param string $name + * @param string $type + * @return array + */ + function &get_config_vars($name=null) + { + if(!isset($name) && is_array($this->_config[0])) { + return $this->_config[0]['vars']; + } else if(isset($this->_config[0]['vars'][$name])) { + return $this->_config[0]['vars'][$name]; + } + } + + /** + * trigger Smarty error + * + * @param string $error_msg + * @param integer $error_type + */ + function trigger_error($error_msg, $error_type = E_USER_WARNING) + { + trigger_error("Smarty error: $error_msg", $error_type); + } + + + /** + * executes & displays the template results + * + * @param string $resource_name + * @param string $cache_id + * @param string $compile_id + */ + function display($resource_name, $cache_id = null, $compile_id = null) + { + $this->fetch($resource_name, $cache_id, $compile_id, true); + } + + /** + * executes & returns or displays the template results + * + * @param string $resource_name + * @param string $cache_id + * @param string $compile_id + * @param boolean $display + */ + function fetch($resource_name, $cache_id = null, $compile_id = null, $display = false) + { + static $_cache_info = array(); + + $_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting) + ? $this->error_reporting : error_reporting() & ~E_NOTICE); + + if (!$this->debugging && $this->debugging_ctrl == 'URL') { + $_query_string = $this->request_use_auto_globals ? $_SERVER['QUERY_STRING'] : $GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING']; + if (@strstr($_query_string, $this->_smarty_debug_id)) { + if (@strstr($_query_string, $this->_smarty_debug_id . '=on')) { + // enable debugging for this browser session + @setcookie('SMARTY_DEBUG', true); + $this->debugging = true; + } elseif (@strstr($_query_string, $this->_smarty_debug_id . '=off')) { + // disable debugging for this browser session + @setcookie('SMARTY_DEBUG', false); + $this->debugging = false; + } else { + // enable debugging for this page + $this->debugging = true; + } + } else { + $_cookie_var = $this->request_use_auto_globals ? $_COOKIE['SMARTY_DEBUG'] : $GLOBALS['HTTP_COOKIE_VARS']['SMARTY_DEBUG']; + $this->debugging = $_cookie_var ? true : false; + } + } + + if ($this->debugging) { + // capture time for debugging info + $_params = array(); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); + $_debug_start_time = smarty_core_get_microtime($_params, $this); + $this->_smarty_debug_info[] = array('type' => 'template', + 'filename' => $resource_name, + 'depth' => 0); + $_included_tpls_idx = count($this->_smarty_debug_info) - 1; + } + + if (!isset($compile_id)) { + $compile_id = $this->compile_id; + } + + $this->_compile_id = $compile_id; + $this->_inclusion_depth = 0; + + if ($this->caching) { + // save old cache_info, initialize cache_info + array_push($_cache_info, $this->_cache_info); + $this->_cache_info = array(); + $_params = array( + 'tpl_file' => $resource_name, + 'cache_id' => $cache_id, + 'compile_id' => $compile_id, + 'results' => null + ); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.read_cache_file.php'); + if (smarty_core_read_cache_file($_params, $this)) { + $_smarty_results = $_params['results']; + if (@count($this->_cache_info['insert_tags'])) { + $_params = array('plugins' => $this->_cache_info['insert_tags']); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php'); + smarty_core_load_plugins($_params, $this); + $_params = array('results' => $_smarty_results); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.process_cached_inserts.php'); + $_smarty_results = smarty_core_process_cached_inserts($_params, $this); + } + if (@count($this->_cache_info['cache_serials'])) { + $_params = array('results' => $_smarty_results); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.process_compiled_include.php'); + $_smarty_results = smarty_core_process_compiled_include($_params, $this); + } + + + if ($display) { + if ($this->debugging) + { + // capture time for debugging info + $_params = array(); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); + $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $_debug_start_time; + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.display_debug_console.php'); + $_smarty_results .= smarty_core_display_debug_console($_params, $this); + } + if ($this->cache_modified_check) { + $_server_vars = ($this->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS']; + $_last_modified_date = @substr($_server_vars['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_server_vars['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3); + $_gmt_mtime = gmdate('D, d M Y H:i:s', $this->_cache_info['timestamp']).' GMT'; + if (@count($this->_cache_info['insert_tags']) == 0 + && !$this->_cache_serials + && $_gmt_mtime == $_last_modified_date) { + if (php_sapi_name()=='cgi') + header("Status: 304 Not Modified"); + else + header("HTTP/1.1 304 Not Modified"); + + } else { + header("Last-Modified: ".$_gmt_mtime); + echo $_smarty_results; + } + } else { + echo $_smarty_results; + } + error_reporting($_smarty_old_error_level); + // restore initial cache_info + $this->_cache_info = array_pop($_cache_info); + return true; + } else { + error_reporting($_smarty_old_error_level); + // restore initial cache_info + $this->_cache_info = array_pop($_cache_info); + return $_smarty_results; + } + } else { + $this->_cache_info['template'][$resource_name] = true; + if ($this->cache_modified_check && $display) { + header("Last-Modified: ".gmdate('D, d M Y H:i:s', time()).' GMT'); + } + } + } + + // load filters that are marked as autoload + if (count($this->autoload_filters)) { + foreach ($this->autoload_filters as $_filter_type => $_filters) { + foreach ($_filters as $_filter) { + $this->load_filter($_filter_type, $_filter); + } + } + } + + $_smarty_compile_path = $this->_get_compile_path($resource_name); + + // if we just need to display the results, don't perform output + // buffering - for speed + $_cache_including = $this->_cache_including; + $this->_cache_including = false; + if ($display && !$this->caching && count($this->_plugins['outputfilter']) == 0) { + if ($this->_is_compiled($resource_name, $_smarty_compile_path) + || $this->_compile_resource($resource_name, $_smarty_compile_path)) + { + include($_smarty_compile_path); + } + } else { + ob_start(); + if ($this->_is_compiled($resource_name, $_smarty_compile_path) + || $this->_compile_resource($resource_name, $_smarty_compile_path)) + { + include($_smarty_compile_path); + } + $_smarty_results = ob_get_contents(); + ob_end_clean(); + + foreach ((array)$this->_plugins['outputfilter'] as $_output_filter) { + $_smarty_results = call_user_func_array($_output_filter[0], array($_smarty_results, &$this)); + } + } + + if ($this->caching) { + $_params = array('tpl_file' => $resource_name, + 'cache_id' => $cache_id, + 'compile_id' => $compile_id, + 'results' => $_smarty_results); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_cache_file.php'); + smarty_core_write_cache_file($_params, $this); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.process_cached_inserts.php'); + $_smarty_results = smarty_core_process_cached_inserts($_params, $this); + + if ($this->_cache_serials) { + // strip nocache-tags from output + $_smarty_results = preg_replace('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!s' + ,'' + ,$_smarty_results); + } + // restore initial cache_info + $this->_cache_info = array_pop($_cache_info); + } + $this->_cache_including = $_cache_including; + + if ($display) { + if (isset($_smarty_results)) { echo $_smarty_results; } + if ($this->debugging) { + // capture time for debugging info + $_params = array(); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); + $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = (smarty_core_get_microtime($_params, $this) - $_debug_start_time); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.display_debug_console.php'); + echo smarty_core_display_debug_console($_params, $this); + } + error_reporting($_smarty_old_error_level); + return; + } else { + error_reporting($_smarty_old_error_level); + if (isset($_smarty_results)) { return $_smarty_results; } + } + } + + /** + * load configuration values + * + * @param string $file + * @param string $section + * @param string $scope + */ + function config_load($file, $section = null, $scope = 'global') + { + require_once($this->_get_plugin_filepath('function', 'config_load')); + smarty_function_config_load(array('file' => $file, 'section' => $section, 'scope' => $scope), $this); + } + + /** + * return a reference to a registered object + * + * @param string $name + * @return object + */ + function &get_registered_object($name) { + if (!isset($this->_reg_objects[$name])) + $this->_trigger_fatal_error("'$name' is not a registered object"); + + if (!is_object($this->_reg_objects[$name][0])) + $this->_trigger_fatal_error("registered '$name' is not an object"); + + return $this->_reg_objects[$name][0]; + } + + /** + * clear configuration values + * + * @param string $var + */ + function clear_config($var = null) + { + if(!isset($var)) { + // clear all values + $this->_config = array(array('vars' => array(), + 'files' => array())); + } else { + unset($this->_config[0]['vars'][$var]); + } + } + + /** + * get filepath of requested plugin + * + * @param string $type + * @param string $name + * @return string|false + */ + function _get_plugin_filepath($type, $name) + { + $_params = array('type' => $type, 'name' => $name); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.assemble_plugin_filepath.php'); + return smarty_core_assemble_plugin_filepath($_params, $this); + } + + /** + * test if resource needs compiling + * + * @param string $resource_name + * @param string $compile_path + * @return boolean + */ + function _is_compiled($resource_name, $compile_path) + { + if (!$this->force_compile && file_exists($compile_path)) { + if (!$this->compile_check) { + // no need to check compiled file + return true; + } else { + // get file source and timestamp + $_params = array('resource_name' => $resource_name, 'get_source'=>false); + if (!$this->_fetch_resource_info($_params)) { + return false; + } + if ($_params['resource_timestamp'] <= filemtime($compile_path)) { + // template not expired, no recompile + return true; + } else { + // compile template + return false; + } + } + } else { + // compiled template does not exist, or forced compile + return false; + } + } + + /** + * compile the template + * + * @param string $resource_name + * @param string $compile_path + * @return boolean + */ + function _compile_resource($resource_name, $compile_path) + { + + $_params = array('resource_name' => $resource_name); + if (!$this->_fetch_resource_info($_params)) { + return false; + } + + $_source_content = $_params['source_content']; + $_resource_timestamp = $_params['resource_timestamp']; + $_cache_include = substr($compile_path, 0, -4).'.inc'; + + if ($this->_compile_source($resource_name, $_source_content, $_compiled_content, $_cache_include)) { + // if a _cache_serial was set, we also have to write an include-file: + if ($this->_cache_include_info) { + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_compiled_include.php'); + smarty_core_write_compiled_include(array_merge($this->_cache_include_info, array('compiled_content'=>$_compiled_content)), $this); + } + + $_params = array('compile_path'=>$compile_path, 'compiled_content' => $_compiled_content, 'resource_timestamp' => $_resource_timestamp); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_compiled_resource.php'); + smarty_core_write_compiled_resource($_params, $this); + + return true; + } else { + $this->trigger_error($smarty_compiler->_error_msg); + return false; + } + + } + + /** + * compile the given source + * + * @param string $resource_name + * @param string $source_content + * @param string $compiled_content + * @return boolean + */ + function _compile_source($resource_name, &$source_content, &$compiled_content, $cache_include_path=null) + { + if (file_exists(SMARTY_DIR . $this->compiler_file)) { + require_once(SMARTY_DIR . $this->compiler_file); + } else { + // use include_path + require_once($this->compiler_file); + } + + + $smarty_compiler = new $this->compiler_class; + + $smarty_compiler->template_dir = $this->template_dir; + $smarty_compiler->compile_dir = $this->compile_dir; + $smarty_compiler->plugins_dir = $this->plugins_dir; + $smarty_compiler->config_dir = $this->config_dir; + $smarty_compiler->force_compile = $this->force_compile; + $smarty_compiler->caching = $this->caching; + $smarty_compiler->php_handling = $this->php_handling; + $smarty_compiler->left_delimiter = $this->left_delimiter; + $smarty_compiler->right_delimiter = $this->right_delimiter; + $smarty_compiler->_version = $this->_version; + $smarty_compiler->security = $this->security; + $smarty_compiler->secure_dir = $this->secure_dir; + $smarty_compiler->security_settings = $this->security_settings; + $smarty_compiler->trusted_dir = $this->trusted_dir; + $smarty_compiler->_reg_objects = &$this->_reg_objects; + $smarty_compiler->_plugins = &$this->_plugins; + $smarty_compiler->_tpl_vars = &$this->_tpl_vars; + $smarty_compiler->default_modifiers = $this->default_modifiers; + $smarty_compiler->compile_id = $this->_compile_id; + $smarty_compiler->_config = $this->_config; + $smarty_compiler->request_use_auto_globals = $this->request_use_auto_globals; + + $smarty_compiler->_cache_serial = null; + $smarty_compiler->_cache_include = $cache_include_path; + + + $_results = $smarty_compiler->_compile_file($resource_name, $source_content, $compiled_content); + + if ($smarty_compiler->_cache_serial) { + $this->_cache_include_info = array( + 'cache_serial'=>$smarty_compiler->_cache_serial + ,'plugins_code'=>$smarty_compiler->_plugins_code + ,'include_file_path' => $cache_include_path); + + } else { + $this->_cache_include_info = null; + + } + + return $_results; + } + + /** + * Get the compile path for this resource + * + * @param string $resource_name + * @return string results of {@link _get_auto_filename()} + */ + function _get_compile_path($resource_name) + { + return $this->_get_auto_filename($this->compile_dir, $resource_name, + $this->_compile_id) . '.php'; + } + + /** + * fetch the template info. Gets timestamp, and source + * if get_source is true + * + * sets $source_content to the source of the template, and + * $resource_timestamp to its time stamp + * @param string $resource_name + * @param string $source_content + * @param integer $resource_timestamp + * @param boolean $get_source + * @param boolean $quiet + * @return boolean + */ + + function _fetch_resource_info(&$params) + { + if(!isset($params['get_source'])) { $params['get_source'] = true; } + if(!isset($params['quiet'])) { $params['quiet'] = false; } + + $_return = false; + $_params = array('resource_name' => $params['resource_name']) ; + if (isset($params['resource_base_path'])) + $_params['resource_base_path'] = $params['resource_base_path']; + + if ($this->_parse_resource_name($_params)) { + $_resource_type = $_params['resource_type']; + $_resource_name = $_params['resource_name']; + switch ($_resource_type) { + case 'file': + if ($params['get_source']) { + $params['source_content'] = $this->_read_file($_resource_name); + } + $params['resource_timestamp'] = filemtime($_resource_name); + $_return = is_file($_resource_name); + break; + + default: + // call resource functions to fetch the template source and timestamp + if ($params['get_source']) { + $_source_return = isset($this->_plugins['resource'][$_resource_type]) && + call_user_func_array($this->_plugins['resource'][$_resource_type][0][0], + array($_resource_name, &$params['source_content'], &$this)); + } else { + $_source_return = true; + } + + $_timestamp_return = isset($this->_plugins['resource'][$_resource_type]) && + call_user_func_array($this->_plugins['resource'][$_resource_type][0][1], + array($_resource_name, &$params['resource_timestamp'], &$this)); + + $_return = $_source_return && $_timestamp_return; + break; + } + } + + if (!$_return) { + // see if we can get a template with the default template handler + if (!empty($this->default_template_handler_func)) { + if (!is_callable($this->default_template_handler_func)) { + $this->trigger_error("default template handler function \"$this->default_template_handler_func\" doesn't exist."); + } else { + $_return = call_user_func_array( + $this->default_template_handler_func, + array($_params['resource_type'], $_params['resource_name'], &$params['source_content'], &$params['resource_timestamp'], &$this)); + } + } + } + + if (!$_return) { + if (!$params['quiet']) { + $this->trigger_error('unable to read resource: "' . $params['resource_name'] . '"'); + } + } else if ($_return && $this->security) { + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.is_secure.php'); + if (!smarty_core_is_secure($_params, $this)) { + if (!$params['quiet']) + $this->trigger_error('(secure mode) accessing "' . $params['resource_name'] . '" is not allowed'); + $params['source_content'] = null; + $params['resource_timestamp'] = null; + return false; + } + } + return $_return; + } + + + /** + * parse out the type and name from the resource + * + * @param string $resource_base_path + * @param string $resource_name + * @param string $resource_type + * @param string $resource_name + * @return boolean + */ + + function _parse_resource_name(&$params) + { + + // split tpl_path by the first colon + $_resource_name_parts = explode(':', $params['resource_name'], 2); + + if (count($_resource_name_parts) == 1) { + // no resource type given + $params['resource_type'] = $this->default_resource_type; + $params['resource_name'] = $_resource_name_parts[0]; + } else { + if(strlen($_resource_name_parts[0]) == 1) { + // 1 char is not resource type, but part of filepath + $params['resource_type'] = $this->default_resource_type; + $params['resource_name'] = $params['resource_name']; + } else { + $params['resource_type'] = $_resource_name_parts[0]; + $params['resource_name'] = $_resource_name_parts[1]; + } + } + + if ($params['resource_type'] == 'file') { + if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $params['resource_name'])) { + // relative pathname to $params['resource_base_path'] + // use the first directory where the file is found + if (isset($params['resource_base_path'])) { + $_resource_base_path = (array)$params['resource_base_path']; + } else { + $_resource_base_path = (array)$this->template_dir; + $_resource_base_path[] = '.'; + } + foreach ($_resource_base_path as $_curr_path) { + $_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name']; + if (file_exists($_fullpath) && is_file($_fullpath)) { + $params['resource_name'] = $_fullpath; + return true; + } + // didn't find the file, try include_path + $_params = array('file_path' => $_fullpath); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php'); + if(smarty_core_get_include_path($_params, $this)) { + $params['resource_name'] = $_params['new_file_path']; + return true; + } + } + return false; + } + } elseif (empty($this->_plugins['resource'][$params['resource_type']])) { + $_params = array('type' => $params['resource_type']); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_resource_plugin.php'); + smarty_core_load_resource_plugin($_params, $this); + } + + return true; + } + + + /** + * Handle modifiers + * + * @param string|null $modifier_name + * @param array|null $map_array + * @return string result of modifiers + */ + function _run_mod_handler() + { + $_args = func_get_args(); + list($_modifier_name, $_map_array) = array_splice($_args, 0, 2); + list($_func_name, $_tpl_file, $_tpl_line) = + $this->_plugins['modifier'][$_modifier_name]; + + $_var = $_args[0]; + foreach ($_var as $_key => $_val) { + $_args[0] = $_val; + $_var[$_key] = call_user_func_array($_func_name, $_args); + } + return $_var; + } + + /** + * Remove starting and ending quotes from the string + * + * @param string $string + * @return string + */ + function _dequote($string) + { + if (($string{0} == "'" || $string{0} == '"') && + $string{strlen($string)-1} == $string{0}) + return substr($string, 1, -1); + else + return $string; + } + + + /** + * read in a file from line $start for $lines. + * read the entire file if $start and $lines are null. + * + * @param string $filename + * @param integer $start + * @param integer $lines + * @return string + */ + function _read_file($filename, $start=null, $lines=null) + { + if (!($fd = @fopen($filename, 'r'))) { + return false; + } + flock($fd, LOCK_SH); + if ($start == null && $lines == null) { + // read the entire file + $contents = fread($fd, filesize($filename)); + } else { + if ( $start > 1 ) { + // skip the first lines before $start + for ($loop=1; $loop < $start; $loop++) { + fgets($fd, 65536); + } + } + if ( $lines == null ) { + // read the rest of the file + while (!feof($fd)) { + $contents .= fgets($fd, 65536); + } + } else { + // read up to $lines lines + for ($loop=0; $loop < $lines; $loop++) { + $contents .= fgets($fd, 65536); + if (feof($fd)) { + break; + } + } + } + } + fclose($fd); + return $contents; + } + + /** + * get a concrete filename for automagically created content + * + * @param string $auto_base + * @param string $auto_source + * @param string $auto_id + * @return string + * @staticvar string|null + * @staticvar string|null + */ + function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null) + { + $_compile_dir_sep = $this->use_sub_dirs ? DIRECTORY_SEPARATOR : '^'; + + if(@is_dir($auto_base)) { + $_return = $auto_base . DIRECTORY_SEPARATOR; + } else { + // auto_base not found, try include_path + $_params = array('file_path' => $auto_base); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php'); + smarty_core_get_include_path($_params, $this); + $_return = isset($_params['new_file_path']) ? $_params['new_file_path'] . DIRECTORY_SEPARATOR : null; + } + + if(isset($auto_id)) { + // make auto_id safe for directory names + $auto_id = str_replace('%7C',$_compile_dir_sep,(urlencode($auto_id))); + // split into separate directories + $_return .= $auto_id . $_compile_dir_sep; + } + + if(isset($auto_source)) { + // make source name safe for filename + $_filename = urlencode(basename($auto_source)); + $_crc32 = crc32($auto_source) . $_compile_dir_sep; + // prepend %% to avoid name conflicts with + // with $params['auto_id'] names + $_crc32 = '%%' . substr($_crc32,0,3) . $_compile_dir_sep . '%%' . $_crc32; + $_return .= $_crc32 . $_filename; + } + + return $_return; + } + + /** + * unlink a file, possibly using expiration time + * + * @param string $resource + * @param integer $exp_time + */ + function _unlink($resource, $exp_time = null) + { + if(isset($exp_time)) { + if(time() - @filemtime($resource) >= $exp_time) { + return @unlink($resource); + } + } else { + return @unlink($resource); + } + } + + /** + * returns an auto_id for auto-file-functions + * + * @param string $cache_id + * @param string $compile_id + * @return string|null + */ + function _get_auto_id($cache_id=null, $compile_id=null) { + if (isset($cache_id)) + return (isset($compile_id)) ? $cache_id . '|' . $compile_id : $cache_id; + elseif(isset($compile_id)) + return $compile_id; + else + return null; + } + + /** + * trigger Smarty plugin error + * + * @param string $error_msg + * @param string $tpl_file + * @param integer $tpl_line + * @param string $file + * @param integer $line + * @param integer $error_type + */ + function _trigger_fatal_error($error_msg, $tpl_file = null, $tpl_line = null, + $file = null, $line = null, $error_type = E_USER_ERROR) + { + if(isset($file) && isset($line)) { + $info = ' ('.basename($file).", line $line)"; + } else { + $info = ''; + } + if (isset($tpl_line) && isset($tpl_file)) { + $this->trigger_error('[in ' . $tpl_file . ' line ' . $tpl_line . "]: $error_msg$info", $error_type); + } else { + $this->trigger_error($error_msg . $info, $error_type); + } + } + + + /** + * callback function for preg_replace, to call a non-cacheable block + * @return string + */ + function _process_compiled_include_callback($match) { + $_func = '_smarty_tplfunc_'.$match[2].'_'.$match[3]; + ob_start(); + $_func($this); + $_ret = ob_get_contents(); + ob_end_clean(); + return $_ret; + } + + + /** + * called for included templates + * + * @param string $_smarty_include_tpl_file + * @param string $_smarty_include_vars + */ + + // $_smarty_include_tpl_file, $_smarty_include_vars + + function _smarty_include($params) + { + if ($this->debugging) { + $_params = array(); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); + $debug_start_time = smarty_core_get_microtime($_params, $this); + $this->_smarty_debug_info[] = array('type' => 'template', + 'filename' => $params['smarty_include_tpl_file'], + 'depth' => ++$this->_inclusion_depth); + $included_tpls_idx = count($this->_smarty_debug_info) - 1; + } + + $this->_tpl_vars = array_merge($this->_tpl_vars, $params['smarty_include_vars']); + + // config vars are treated as local, so push a copy of the + // current ones onto the front of the stack + array_unshift($this->_config, $this->_config[0]); + + $_smarty_compile_path = $this->_get_compile_path($params['smarty_include_tpl_file']); + + + if ($this->_is_compiled($params['smarty_include_tpl_file'], $_smarty_compile_path) + || $this->_compile_resource($params['smarty_include_tpl_file'], $_smarty_compile_path)) + { + include($_smarty_compile_path); + } + + // pop the local vars off the front of the stack + array_shift($this->_config); + + $this->_inclusion_depth--; + + if ($this->debugging) { + // capture time for debugging info + $_params = array(); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); + $this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $debug_start_time; + } + + if ($this->caching) { + $this->_cache_info['template'][$params['smarty_include_tpl_file']] = true; + } + } + + + /** + * get or set an array of cached attributes for function that is + * not cacheable + * @return array + */ + function &_smarty_cache_attrs($cache_serial, $count) { + $_cache_attrs =& $this->_cache_info['cache_attrs'][$cache_serial][$count]; + + if ($this->_cache_including) { + /* return next set of cache_attrs */ + $_return =& current($_cache_attrs); + next($_cache_attrs); + return $_return; + + } else { + /* add a reference to a new set of cache_attrs */ + $_cache_attrs[] = array(); + return $_cache_attrs[count($_cache_attrs)-1]; + + } + + } + + + /** + * wrapper for include() retaining $this + * @return mixed + */ + function _include($filename, $once=false, $params=null) + { + if ($once) { + return include_once($filename); + } else { + return include($filename); + } + } + + + /** + * wrapper for eval() retaining $this + * @return mixed + */ + function _eval($code, $params=null) + { + return eval($code); + } + /**#@-*/ + +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/Smarty_Compiler.class.php b/google/smarty/Smarty_Compiler.class.php new file mode 100755 index 0000000..a306fdb --- /dev/null +++ b/google/smarty/Smarty_Compiler.class.php @@ -0,0 +1,2225 @@ + + * @author Andrei Zmievski + * @version 2.6.2 + * @copyright 2001-2004 ispi of Lincoln, Inc. + * @package Smarty + */ + +/* $Id: Smarty_Compiler.class.php,v 1.1.1.1 2006/03/27 14:44:14 cscott Exp $ */ + +/** + * Template compiling class + * @package Smarty + */ +class Smarty_Compiler extends Smarty { + + // internal vars + /**#@+ + * @access private + */ + var $_folded_blocks = array(); // keeps folded template blocks + var $_current_file = null; // the current template being compiled + var $_current_line_no = 1; // line number for error messages + var $_capture_stack = array(); // keeps track of nested capture buffers + var $_plugin_info = array(); // keeps track of plugins to load + var $_init_smarty_vars = false; + var $_permitted_tokens = array('true','false','yes','no','on','off','null'); + var $_db_qstr_regexp = null; // regexps are setup in the constructor + var $_si_qstr_regexp = null; + var $_qstr_regexp = null; + var $_func_regexp = null; + var $_var_bracket_regexp = null; + var $_dvar_guts_regexp = null; + var $_dvar_regexp = null; + var $_cvar_regexp = null; + var $_svar_regexp = null; + var $_avar_regexp = null; + var $_mod_regexp = null; + var $_var_regexp = null; + var $_parenth_param_regexp = null; + var $_func_call_regexp = null; + var $_obj_ext_regexp = null; + var $_obj_start_regexp = null; + var $_obj_params_regexp = null; + var $_obj_call_regexp = null; + var $_cacheable_state = 0; + var $_cache_attrs_count = 0; + var $_nocache_count = 0; + var $_cache_serial = null; + var $_cache_include = null; + + var $_strip_depth = 0; + var $_additional_newline = "\n"; + + /**#@-*/ + /** + * The class constructor. + */ + function Smarty_Compiler() + { + // matches double quoted strings: + // "foobar" + // "foo\"bar" + $this->_db_qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"'; + + // matches single quoted strings: + // 'foobar' + // 'foo\'bar' + $this->_si_qstr_regexp = '\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\''; + + // matches single or double quoted strings + $this->_qstr_regexp = '(?:' . $this->_db_qstr_regexp . '|' . $this->_si_qstr_regexp . ')'; + + // matches bracket portion of vars + // [0] + // [foo] + // [$bar] + $this->_var_bracket_regexp = '\[\$?[\w\.]+\]'; + + // matches $ vars (not objects): + // $foo + // $foo.bar + // $foo.bar.foobar + // $foo[0] + // $foo[$bar] + // $foo[5][blah] + // $foo[5].bar[$foobar][4] + $this->_dvar_math_regexp = '[\+\-\*\/\%]'; + $this->_dvar_math_var_regexp = '[\$\w\.\+\-\*\/\%\d\>\[\]]'; + $this->_dvar_num_var_regexp = '\-?\d+(?:\.\d+)?' . $this->_dvar_math_var_regexp; + $this->_dvar_guts_regexp = '\w+(?:' . $this->_var_bracket_regexp + . ')*(?:\.\$?\w+(?:' . $this->_var_bracket_regexp . ')*)*(?:' . $this->_dvar_math_regexp . '(?:\-?\d+(?:\.\d+)?|' . $this->_dvar_math_var_regexp . ')*)?'; + $this->_dvar_regexp = '\$' . $this->_dvar_guts_regexp; + + // matches config vars: + // #foo# + // #foobar123_foo# + $this->_cvar_regexp = '\#\w+\#'; + + // matches section vars: + // %foo.bar% + $this->_svar_regexp = '\%\w+\.\w+\%'; + + // matches all valid variables (no quotes, no modifiers) + $this->_avar_regexp = '(?:' . $this->_dvar_regexp . '|' + . $this->_cvar_regexp . '|' . $this->_svar_regexp . ')'; + + // matches valid variable syntax: + // $foo + // $foo + // #foo# + // #foo# + // "text" + // "text" + $this->_var_regexp = '(?:' . $this->_avar_regexp . '|' . $this->_qstr_regexp . ')'; + + // matches valid object call (no objects allowed in parameters): + // $foo->bar + // $foo->bar() + // $foo->bar("text") + // $foo->bar($foo, $bar, "text") + // $foo->bar($foo, "foo") + // $foo->bar->foo() + // $foo->bar->foo->bar() + $this->_obj_ext_regexp = '\->(?:\$?' . $this->_dvar_guts_regexp . ')'; + $this->_obj_params_regexp = '\((?:\w+|' + . $this->_var_regexp . '(?:\s*,\s*(?:(?:\w+|' + . $this->_var_regexp . ')))*)?\)'; + $this->_obj_start_regexp = '(?:' . $this->_dvar_regexp . '(?:' . $this->_obj_ext_regexp . ')+)'; + $this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp . '(?:' . $this->_obj_params_regexp . ')?)'; + + // matches valid modifier syntax: + // |foo + // |@foo + // |foo:"bar" + // |foo:$bar + // |foo:"bar":$foobar + // |foo|bar + // |foo:$foo->bar + $this->_mod_regexp = '(?:\|@?\w+(?::(?>-?\w+|' + . $this->_obj_call_regexp . '|' . $this->_avar_regexp . '|' . $this->_qstr_regexp .'))*)'; + + // matches valid function name: + // foo123 + // _foo_bar + $this->_func_regexp = '[a-zA-Z_]\w*'; + + // matches valid registered object: + // foo->bar + $this->_reg_obj_regexp = '[a-zA-Z_]\w*->[a-zA-Z_]\w*'; + + // matches valid parameter values: + // true + // $foo + // $foo|bar + // #foo# + // #foo#|bar + // "text" + // "text"|bar + // $foo->bar + $this->_param_regexp = '(?:\s*(?:' . $this->_obj_call_regexp . '|' + . $this->_var_regexp . '|\w+)(?>' . $this->_mod_regexp . '*)\s*)'; + + // matches valid parenthesised function parameters: + // + // "text" + // $foo, $bar, "text" + // $foo|bar, "foo"|bar, $foo->bar($foo)|bar + $this->_parenth_param_regexp = '(?:\((?:\w+|' + . $this->_param_regexp . '(?:\s*,\s*(?:(?:\w+|' + . $this->_param_regexp . ')))*)?\))'; + + // matches valid function call: + // foo() + // foo_bar($foo) + // _foo_bar($foo,"bar") + // foo123($foo,$foo->bar(),"foo") + $this->_func_call_regexp = '(?:' . $this->_func_regexp . '\s*(?:' + . $this->_parenth_param_regexp . '))'; + } + + /** + * compile a resource + * + * sets $compiled_content to the compiled source + * @param string $resource_name + * @param string $source_content + * @param string $compiled_content + * @return true + */ + function _compile_file($resource_name, $source_content, &$compiled_content) + { + + if ($this->security) { + // do not allow php syntax to be executed unless specified + if ($this->php_handling == SMARTY_PHP_ALLOW && + !$this->security_settings['PHP_HANDLING']) { + $this->php_handling = SMARTY_PHP_PASSTHRU; + } + } + + $this->_load_filters(); + + $this->_current_file = $resource_name; + $this->_current_line_no = 1; + $ldq = preg_quote($this->left_delimiter, '!'); + $rdq = preg_quote($this->right_delimiter, '!'); + + // run template source through prefilter functions + if (count($this->_plugins['prefilter']) > 0) { + foreach ($this->_plugins['prefilter'] as $filter_name => $prefilter) { + if ($prefilter === false) continue; + if ($prefilter[3] || is_callable($prefilter[0])) { + $source_content = call_user_func_array($prefilter[0], + array($source_content, &$this)); + $this->_plugins['prefilter'][$filter_name][3] = true; + } else { + $this->_trigger_fatal_error("[plugin] prefilter '$filter_name' is not implemented"); + } + } + } + + /* fetch all special blocks */ + $search = "!{$ldq}\*(.*?)\*{$rdq}|{$ldq}\s*literal\s*{$rdq}(.*?){$ldq}\s*/literal\s*{$rdq}|{$ldq}\s*php\s*{$rdq}(.*?){$ldq}\s*/php\s*{$rdq}!s"; + + preg_match_all($search, $source_content, $match, PREG_SET_ORDER); + $this->_folded_blocks = $match; + reset($this->_folded_blocks); + + /* replace special blocks by "{php}" */ + $source_content = preg_replace($search.'e', "'" + . $this->_quote_replace($this->left_delimiter) . 'php' + . "' . str_repeat(\"\n\", substr_count('\\0', \"\n\")) .'" + . $this->_quote_replace($this->right_delimiter) + . "'" + , $source_content); + + /* Gather all template tags. */ + preg_match_all("!{$ldq}\s*(.*?)\s*{$rdq}!s", $source_content, $_match); + $template_tags = $_match[1]; + /* Split content by template tags to obtain non-template content. */ + $text_blocks = preg_split("!{$ldq}.*?{$rdq}!s", $source_content); + + /* loop through text blocks */ + for ($curr_tb = 0, $for_max = count($text_blocks); $curr_tb < $for_max; $curr_tb++) { + /* match anything resembling php tags */ + if (preg_match_all('!(<\?(?:\w+|=)?|\?>|language\s*=\s*[\"\']?php[\"\']?)!is', $text_blocks[$curr_tb], $sp_match)) { + /* replace tags with placeholders to prevent recursive replacements */ + $sp_match[1] = array_unique($sp_match[1]); + usort($sp_match[1], '_smarty_sort_length'); + for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) { + $text_blocks[$curr_tb] = str_replace($sp_match[1][$curr_sp],'%%%SMARTYSP'.$curr_sp.'%%%',$text_blocks[$curr_tb]); + } + /* process each one */ + for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) { + if ($this->php_handling == SMARTY_PHP_PASSTHRU) { + /* echo php contents */ + $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', ''."\n", $text_blocks[$curr_tb]); + } else if ($this->php_handling == SMARTY_PHP_QUOTE) { + /* quote php tags */ + $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', htmlspecialchars($sp_match[1][$curr_sp]), $text_blocks[$curr_tb]); + } else if ($this->php_handling == SMARTY_PHP_REMOVE) { + /* remove php tags */ + $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', '', $text_blocks[$curr_tb]); + } else { + /* SMARTY_PHP_ALLOW, but echo non php starting tags */ + $sp_match[1][$curr_sp] = preg_replace('%(<\?(?!php|=|$))%i', ''."\n", $sp_match[1][$curr_sp]); + $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', $sp_match[1][$curr_sp], $text_blocks[$curr_tb]); + } + } + } + } + + /* Compile the template tags into PHP code. */ + $compiled_tags = array(); + for ($i = 0, $for_max = count($template_tags); $i < $for_max; $i++) { + $this->_current_line_no += substr_count($text_blocks[$i], "\n"); + $compiled_tags[] = $this->_compile_tag($template_tags[$i]); + $this->_current_line_no += substr_count($template_tags[$i], "\n"); + } + if (count($this->_tag_stack)>0) { + list($_open_tag, $_line_no) = end($this->_tag_stack); + $this->_syntax_error("unclosed tag \{$_open_tag} (opened line $_line_no).", E_USER_ERROR, __FILE__, __LINE__); + return; + } + + $compiled_content = ''; + + /* Interleave the compiled contents and text blocks to get the final result. */ + for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) { + if ($compiled_tags[$i] == '') { + // tag result empty, remove first newline from following text block + $text_blocks[$i+1] = preg_replace('!^(\r\n|\r|\n)!', '', $text_blocks[$i+1]); + } + $compiled_content .= $text_blocks[$i].$compiled_tags[$i]; + } + $compiled_content .= $text_blocks[$i]; + + /* Reformat data between 'strip' and '/strip' tags, removing spaces, tabs and newlines. */ + if (preg_match_all("!{$ldq}strip{$rdq}.*?{$ldq}/strip{$rdq}!s", $compiled_content, $_match)) { + $strip_tags = $_match[0]; + $strip_tags_modified = preg_replace("!{$ldq}/?strip{$rdq}|[\t ]+$|^[\t ]+!m", '', $strip_tags); + $strip_tags_modified = preg_replace('![\r\n]+!m', '', $strip_tags_modified); + for ($i = 0, $for_max = count($strip_tags); $i < $for_max; $i++) + $compiled_content = preg_replace("!{$ldq}strip{$rdq}.*?{$ldq}/strip{$rdq}!s", + $this->_quote_replace($strip_tags_modified[$i]), + $compiled_content, 1); + } + + // remove \n from the end of the file, if any + if (($_len=strlen($compiled_content)) && ($compiled_content{$_len - 1} == "\n" )) { + $compiled_content = substr($compiled_content, 0, -1); + } + + if (!empty($this->_cache_serial)) { + $compiled_content = "_cache_serials['".$this->_cache_include."'] = '".$this->_cache_serial."'; ?>" . $compiled_content; + } + + // remove unnecessary close/open tags + $compiled_content = preg_replace('!\?>\n?<\?php!', '', $compiled_content); + + // run compiled template through postfilter functions + if (count($this->_plugins['postfilter']) > 0) { + foreach ($this->_plugins['postfilter'] as $filter_name => $postfilter) { + if ($postfilter === false) continue; + if ($postfilter[3] || is_callable($postfilter[0])) { + $compiled_content = call_user_func_array($postfilter[0], + array($compiled_content, &$this)); + $this->_plugins['postfilter'][$filter_name][3] = true; + } else { + $this->_trigger_fatal_error("Smarty plugin error: postfilter '$filter_name' is not implemented"); + } + } + } + + // put header at the top of the compiled template + $template_header = "_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n"; + $template_header .= " compiled from ".strtr(urlencode($resource_name), array('%2F'=>'/', '%3A'=>':'))." */ ?>\n"; + + /* Emit code to load needed plugins. */ + $this->_plugins_code = ''; + if (count($this->_plugin_info)) { + $_plugins_params = "array('plugins' => array("; + foreach ($this->_plugin_info as $plugin_type => $plugins) { + foreach ($plugins as $plugin_name => $plugin_info) { + $_plugins_params .= "array('$plugin_type', '$plugin_name', '$plugin_info[0]', $plugin_info[1], "; + $_plugins_params .= $plugin_info[2] ? 'true),' : 'false),'; + } + } + $_plugins_params .= '))'; + $plugins_code = "\n"; + $template_header .= $plugins_code; + $this->_plugin_info = array(); + $this->_plugins_code = $plugins_code; + } + + if ($this->_init_smarty_vars) { + $template_header .= "\n"; + $this->_init_smarty_vars = false; + } + + $compiled_content = $template_header . $compiled_content; + return true; + } + + /** + * Compile a template tag + * + * @param string $template_tag + * @return string + */ + function _compile_tag($template_tag) + { + /* Matched comment. */ + if ($template_tag{0} == '*' && $template_tag{strlen($template_tag) - 1} == '*') + return ''; + + /* Split tag into two three parts: command, command modifiers and the arguments. */ + if(! preg_match('/^(?:(' . $this->_obj_call_regexp . '|' . $this->_var_regexp + . '|\/?' . $this->_reg_obj_regexp . '|\/?' . $this->_func_regexp . ')(' . $this->_mod_regexp . '*)) + (?:\s+(.*))?$ + /xs', $template_tag, $match)) { + $this->_syntax_error("unrecognized tag: $template_tag", E_USER_ERROR, __FILE__, __LINE__); + } + + $tag_command = $match[1]; + $tag_modifier = isset($match[2]) ? $match[2] : null; + $tag_args = isset($match[3]) ? $match[3] : null; + + if (preg_match('!^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '$!', $tag_command)) { + /* tag name is a variable or object */ + $_return = $this->_parse_var_props($tag_command . $tag_modifier, $this->_parse_attrs($tag_args)); + if(isset($_tag_attrs['assign'])) { + return "assign('" . $this->_dequote($_tag_attrs['assign']) . "', $_return ); ?>\n"; + } else { + return "" . $this->_additional_newline; + } + } + + /* If the tag name is a registered object, we process it. */ + if (preg_match('!^\/?' . $this->_reg_obj_regexp . '$!', $tag_command)) { + return $this->_compile_registered_object_tag($tag_command, $this->_parse_attrs($tag_args), $tag_modifier); + } + + switch ($tag_command) { + case 'include': + return $this->_compile_include_tag($tag_args); + + case 'include_php': + return $this->_compile_include_php_tag($tag_args); + + case 'if': + $this->_push_tag('if'); + return $this->_compile_if_tag($tag_args); + + case 'else': + list($_open_tag) = end($this->_tag_stack); + if ($_open_tag != 'if' && $_open_tag != 'elseif') + $this->_syntax_error('unxepected {else}', E_USER_ERROR, __FILE__, __LINE__); + else + $this->_push_tag('else'); + return ''; + + case 'elseif': + list($_open_tag) = end($this->_tag_stack); + if ($_open_tag != 'if' && $_open_tag != 'elseif') + $this->_syntax_error('unxepected {elseif}', E_USER_ERROR, __FILE__, __LINE__); + if ($_open_tag == 'if') + $this->_push_tag('elseif'); + return $this->_compile_if_tag($tag_args, true); + + case '/if': + $this->_pop_tag('if'); + return ''; + + case 'capture': + return $this->_compile_capture_tag(true, $tag_args); + + case '/capture': + return $this->_compile_capture_tag(false); + + case 'ldelim': + return $this->left_delimiter; + + case 'rdelim': + return $this->right_delimiter; + + case 'section': + $this->_push_tag('section'); + return $this->_compile_section_start($tag_args); + + case 'sectionelse': + $this->_push_tag('sectionelse'); + return ""; + break; + + case '/section': + $_open_tag = $this->_pop_tag('section'); + if ($_open_tag == 'sectionelse') + return ""; + else + return ""; + + case 'foreach': + $this->_push_tag('foreach'); + return $this->_compile_foreach_start($tag_args); + break; + + case 'foreachelse': + $this->_push_tag('foreachelse'); + return ""; + + case '/foreach': + $_open_tag = $this->_pop_tag('foreach'); + if ($_open_tag == 'foreachelse') + return ""; + else + return ""; + break; + + case 'strip': + case '/strip': + if ($tag_command{0}=='/') { + $this->_pop_tag('strip'); + if (--$this->_strip_depth==0) { /* outermost closing {/strip} */ + $this->_additional_newline = "\n"; + return $this->left_delimiter.$tag_command.$this->right_delimiter; + } + } else { + $this->_push_tag('strip'); + if ($this->_strip_depth++==0) { /* outermost opening {strip} */ + $this->_additional_newline = ""; + return $this->left_delimiter.$tag_command.$this->right_delimiter; + } + } + return ''; + + case 'php': + /* handle folded tags replaced by {php} */ + list(, $block) = each($this->_folded_blocks); + $this->_current_line_no += substr_count($block[0], "\n"); + /* the number of matched elements in the regexp in _compile_file() + determins the type of folded tag that was found */ + switch (count($block)) { + case 2: /* comment */ + return ''; + + case 3: /* literal */ + return ""\'", "\\"=>"\\\\")) . "'; ?>" . $this->_additional_newline; + + case 4: /* php */ + if ($this->security && !$this->security_settings['PHP_TAGS']) { + $this->_syntax_error("(secure mode) php tags not permitted", E_USER_WARNING, __FILE__, __LINE__); + return; + } + return ''; + } + break; + + case 'insert': + return $this->_compile_insert_tag($tag_args); + + default: + if ($this->_compile_compiler_tag($tag_command, $tag_args, $output)) { + return $output; + } else if ($this->_compile_block_tag($tag_command, $tag_args, $tag_modifier, $output)) { + return $output; + } else if ($this->_compile_custom_tag($tag_command, $tag_args, $tag_modifier, $output)) { + return $output; + } else { + $this->_syntax_error("unrecognized tag '$tag_command'", E_USER_ERROR, __FILE__, __LINE__); + } + + } + } + + + /** + * compile the custom compiler tag + * + * sets $output to the compiled custom compiler tag + * @param string $tag_command + * @param string $tag_args + * @param string $output + * @return boolean + */ + function _compile_compiler_tag($tag_command, $tag_args, &$output) + { + $found = false; + $have_function = true; + + /* + * First we check if the compiler function has already been registered + * or loaded from a plugin file. + */ + if (isset($this->_plugins['compiler'][$tag_command])) { + $found = true; + $plugin_func = $this->_plugins['compiler'][$tag_command][0]; + if (!is_callable($plugin_func)) { + $message = "compiler function '$tag_command' is not implemented"; + $have_function = false; + } + } + /* + * Otherwise we need to load plugin file and look for the function + * inside it. + */ + else if ($plugin_file = $this->_get_plugin_filepath('compiler', $tag_command)) { + $found = true; + + include_once $plugin_file; + + $plugin_func = 'smarty_compiler_' . $tag_command; + if (!is_callable($plugin_func)) { + $message = "plugin function $plugin_func() not found in $plugin_file\n"; + $have_function = false; + } else { + $this->_plugins['compiler'][$tag_command] = array($plugin_func, null, null, null, true); + } + } + + /* + * True return value means that we either found a plugin or a + * dynamically registered function. False means that we didn't and the + * compiler should now emit code to load custom function plugin for this + * tag. + */ + if ($found) { + if ($have_function) { + $output = call_user_func_array($plugin_func, array($tag_args, &$this)); + if($output != '') { + $output = '_push_cacheable_state('compiler', $tag_command) + . $output + . $this->_pop_cacheable_state('compiler', $tag_command) . ' ?>'; + } + } else { + $this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__); + } + return true; + } else { + return false; + } + } + + + /** + * compile block function tag + * + * sets $output to compiled block function tag + * @param string $tag_command + * @param string $tag_args + * @param string $tag_modifier + * @param string $output + * @return boolean + */ + function _compile_block_tag($tag_command, $tag_args, $tag_modifier, &$output) + { + if ($tag_command{0} == '/') { + $start_tag = false; + $tag_command = substr($tag_command, 1); + } else + $start_tag = true; + + $found = false; + $have_function = true; + + /* + * First we check if the block function has already been registered + * or loaded from a plugin file. + */ + if (isset($this->_plugins['block'][$tag_command])) { + $found = true; + $plugin_func = $this->_plugins['block'][$tag_command][0]; + if (!is_callable($plugin_func)) { + $message = "block function '$tag_command' is not implemented"; + $have_function = false; + } + } + /* + * Otherwise we need to load plugin file and look for the function + * inside it. + */ + else if ($plugin_file = $this->_get_plugin_filepath('block', $tag_command)) { + $found = true; + + include_once $plugin_file; + + $plugin_func = 'smarty_block_' . $tag_command; + if (!function_exists($plugin_func)) { + $message = "plugin function $plugin_func() not found in $plugin_file\n"; + $have_function = false; + } else { + $this->_plugins['block'][$tag_command] = array($plugin_func, null, null, null, true); + + } + } + + if (!$found) { + return false; + } else if (!$have_function) { + $this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__); + return true; + } + + /* + * Even though we've located the plugin function, compilation + * happens only once, so the plugin will still need to be loaded + * at runtime for future requests. + */ + $this->_add_plugin('block', $tag_command); + + if ($start_tag) + $this->_push_tag($tag_command); + else + $this->_pop_tag($tag_command); + + if ($start_tag) { + $output = '_push_cacheable_state('block', $tag_command); + $attrs = $this->_parse_attrs($tag_args); + $arg_list = $this->_compile_arg_list('block', $tag_command, $attrs, $_cache_attrs=''); + $output .= "$_cache_attrs\$this->_tag_stack[] = array('$tag_command', array(".implode(',', $arg_list).')); '; + $output .= $this->_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat=true);'; + $output .= 'while ($_block_repeat) { ob_start(); ?>'; + } else { + $output = '_block_content = ob_get_contents(); ob_end_clean(); '; + $_out_tag_text = $this->_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], $this->_block_content, $this, $_block_repeat=false)'; + if ($tag_modifier != '') { + $this->_parse_modifiers($_out_tag_text, $tag_modifier); + } + $output .= 'echo '.$_out_tag_text.'; } '; + $output .= " array_pop(\$this->_tag_stack); " . $this->_pop_cacheable_state('block', $tag_command) . '?>'; + } + + return true; + } + + + /** + * compile custom function tag + * + * @param string $tag_command + * @param string $tag_args + * @param string $tag_modifier + * @return string + */ + function _compile_custom_tag($tag_command, $tag_args, $tag_modifier, &$output) + { + $found = false; + $have_function = true; + + /* + * First we check if the custom function has already been registered + * or loaded from a plugin file. + */ + if (isset($this->_plugins['function'][$tag_command])) { + $found = true; + $plugin_func = $this->_plugins['function'][$tag_command][0]; + if (!is_callable($plugin_func)) { + $message = "custom function '$tag_command' is not implemented"; + $have_function = false; + } + } + /* + * Otherwise we need to load plugin file and look for the function + * inside it. + */ + else if ($plugin_file = $this->_get_plugin_filepath('function', $tag_command)) { + $found = true; + + include_once $plugin_file; + + $plugin_func = 'smarty_function_' . $tag_command; + if (!function_exists($plugin_func)) { + $message = "plugin function $plugin_func() not found in $plugin_file\n"; + $have_function = false; + } else { + $this->_plugins['function'][$tag_command] = array($plugin_func, null, null, null, true); + + } + } + + if (!$found) { + return false; + } else if (!$have_function) { + $this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__); + return true; + } + + /* declare plugin to be loaded on display of the template that + we compile right now */ + $this->_add_plugin('function', $tag_command); + + $_cacheable_state = $this->_push_cacheable_state('function', $tag_command); + $attrs = $this->_parse_attrs($tag_args); + $arg_list = $this->_compile_arg_list('function', $tag_command, $attrs, $_cache_attrs=''); + + $output = $this->_compile_plugin_call('function', $tag_command).'(array('.implode(',', $arg_list)."), \$this)"; + if($tag_modifier != '') { + $this->_parse_modifiers($output, $tag_modifier); + } + + if($output != '') { + $output = '_pop_cacheable_state('function', $tag_command) . "?>" . $this->_additional_newline; + } + + return true; + } + + /** + * compile a registered object tag + * + * @param string $tag_command + * @param array $attrs + * @param string $tag_modifier + * @return string + */ + function _compile_registered_object_tag($tag_command, $attrs, $tag_modifier) + { + if ($tag_command{0} == '/') { + $start_tag = false; + $tag_command = substr($tag_command, 1); + } else { + $start_tag = true; + } + + list($object, $obj_comp) = explode('->', $tag_command); + + $arg_list = array(); + if(count($attrs)) { + $_assign_var = false; + foreach ($attrs as $arg_name => $arg_value) { + if($arg_name == 'assign') { + $_assign_var = $arg_value; + unset($attrs['assign']); + continue; + } + if (is_bool($arg_value)) + $arg_value = $arg_value ? 'true' : 'false'; + $arg_list[] = "'$arg_name' => $arg_value"; + } + } + + if($this->_reg_objects[$object][2]) { + // smarty object argument format + $args = "array(".implode(',', (array)$arg_list)."), \$this"; + } else { + // traditional argument format + $args = implode(',', array_values($attrs)); + if (empty($args)) { + $args = 'null'; + } + } + + $prefix = ''; + $postfix = ''; + $newline = ''; + if(!is_object($this->_reg_objects[$object][0])) { + $this->_trigger_fatal_error("registered '$object' is not an object" , $this->_current_file, $this->_current_line_no, __FILE__, __LINE__); + } elseif(!empty($this->_reg_objects[$object][1]) && !in_array($obj_comp, $this->_reg_objects[$object][1])) { + $this->_trigger_fatal_error("'$obj_comp' is not a registered component of object '$object'", $this->_current_file, $this->_current_line_no, __FILE__, __LINE__); + } elseif(method_exists($this->_reg_objects[$object][0], $obj_comp)) { + // method + if(in_array($obj_comp, $this->_reg_objects[$object][3])) { + // block method + if ($start_tag) { + $prefix = "\$this->_tag_stack[] = array('$obj_comp', $args); "; + $prefix .= "\$this->_reg_objects['$object'][0]->$obj_comp(\$this->_tag_stack[count(\$this->_tag_stack)-1][1], null, \$this, \$_block_repeat=true); "; + $prefix .= "while (\$_block_repeat) { ob_start();"; + $return = null; + $postfix = ''; + } else { + $prefix = "\$this->_obj_block_content = ob_get_contents(); ob_end_clean(); "; + $return = "\$this->_reg_objects['$object'][0]->$obj_comp(\$this->_tag_stack[count(\$this->_tag_stack)-1][1], \$this->_obj_block_content, \$this, \$_block_repeat=false)"; + $postfix = "} array_pop(\$this->_tag_stack);"; + } + } else { + // non-block method + $return = "\$this->_reg_objects['$object'][0]->$obj_comp($args)"; + } + } else { + // property + $return = "\$this->_reg_objects['$object'][0]->$obj_comp"; + } + + if($return != null) { + if($tag_modifier != '') { + $this->_parse_modifiers($return, $tag_modifier); + } + + if(!empty($_assign_var)) { + $output = "\$this->assign('" . $this->_dequote($_assign_var) ."', $return);"; + } else { + $output = 'echo ' . $return . ';'; + $newline = $this->_additional_newline; + } + } else { + $output = ''; + } + + return '" . $newline; + } + + /** + * Compile {insert ...} tag + * + * @param string $tag_args + * @return string + */ + function _compile_insert_tag($tag_args) + { + $attrs = $this->_parse_attrs($tag_args); + $name = $this->_dequote($attrs['name']); + + if (empty($name)) { + $this->_syntax_error("missing insert name", E_USER_ERROR, __FILE__, __LINE__); + } + + if (!empty($attrs['script'])) { + $delayed_loading = true; + } else { + $delayed_loading = false; + } + + foreach ($attrs as $arg_name => $arg_value) { + if (is_bool($arg_value)) + $arg_value = $arg_value ? 'true' : 'false'; + $arg_list[] = "'$arg_name' => $arg_value"; + } + + $this->_add_plugin('insert', $name, $delayed_loading); + + $_params = "array('args' => array(".implode(', ', (array)$arg_list)."))"; + + return "" . $this->_additional_newline; + } + + /** + * Compile {include ...} tag + * + * @param string $tag_args + * @return string + */ + function _compile_include_tag($tag_args) + { + $attrs = $this->_parse_attrs($tag_args); + $arg_list = array(); + + if (empty($attrs['file'])) { + $this->_syntax_error("missing 'file' attribute in include tag", E_USER_ERROR, __FILE__, __LINE__); + } + + foreach ($attrs as $arg_name => $arg_value) { + if ($arg_name == 'file') { + $include_file = $arg_value; + continue; + } else if ($arg_name == 'assign') { + $assign_var = $arg_value; + continue; + } + if (is_bool($arg_value)) + $arg_value = $arg_value ? 'true' : 'false'; + $arg_list[] = "'$arg_name' => $arg_value"; + } + + $output = '_tpl_vars;\n"; + + + $_params = "array('smarty_include_tpl_file' => " . $include_file . ", 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))"; + $output .= "\$this->_smarty_include($_params);\n" . + "\$this->_tpl_vars = \$_smarty_tpl_vars;\n" . + "unset(\$_smarty_tpl_vars);\n"; + + if (isset($assign_var)) { + $output .= "\$this->assign(" . $assign_var . ", ob_get_contents()); ob_end_clean();\n"; + } + + $output .= ' ?>'; + + return $output; + + } + + /** + * Compile {include ...} tag + * + * @param string $tag_args + * @return string + */ + function _compile_include_php_tag($tag_args) + { + $attrs = $this->_parse_attrs($tag_args); + + if (empty($attrs['file'])) { + $this->_syntax_error("missing 'file' attribute in include_php tag", E_USER_ERROR, __FILE__, __LINE__); + } + + $assign_var = (empty($attrs['assign'])) ? '' : $this->_dequote($attrs['assign']); + $once_var = (empty($attrs['once']) || $attrs['once']=='false') ? 'false' : 'true'; + + $arg_list = array(); + foreach($attrs as $arg_name => $arg_value) { + if($arg_name != 'file' AND $arg_name != 'once' AND $arg_name != 'assign') { + if(is_bool($arg_value)) + $arg_value = $arg_value ? 'true' : 'false'; + $arg_list[] = "'$arg_name' => $arg_value"; + } + } + + $_params = "array('smarty_file' => " . $attrs['file'] . ", 'smarty_assign' => '$assign_var', 'smarty_once' => $once_var, 'smarty_include_vars' => array(".implode(',', $arg_list)."))"; + + return "" . $this->_additional_newline; + } + + + /** + * Compile {section ...} tag + * + * @param string $tag_args + * @return string + */ + function _compile_section_start($tag_args) + { + $attrs = $this->_parse_attrs($tag_args); + $arg_list = array(); + + $output = '_syntax_error("missing section name", E_USER_ERROR, __FILE__, __LINE__); + } + + $output .= "if (isset(\$this->_sections[$section_name])) unset(\$this->_sections[$section_name]);\n"; + $section_props = "\$this->_sections[$section_name]"; + + foreach ($attrs as $attr_name => $attr_value) { + switch ($attr_name) { + case 'loop': + $output .= "{$section_props}['loop'] = is_array(\$_loop=$attr_value) ? count(\$_loop) : max(0, (int)\$_loop); unset(\$_loop);\n"; + break; + + case 'show': + if (is_bool($attr_value)) + $show_attr_value = $attr_value ? 'true' : 'false'; + else + $show_attr_value = "(bool)$attr_value"; + $output .= "{$section_props}['show'] = $show_attr_value;\n"; + break; + + case 'name': + $output .= "{$section_props}['$attr_name'] = $attr_value;\n"; + break; + + case 'max': + case 'start': + $output .= "{$section_props}['$attr_name'] = (int)$attr_value;\n"; + break; + + case 'step': + $output .= "{$section_props}['$attr_name'] = ((int)$attr_value) == 0 ? 1 : (int)$attr_value;\n"; + break; + + default: + $this->_syntax_error("unknown section attribute - '$attr_name'", E_USER_ERROR, __FILE__, __LINE__); + break; + } + } + + if (!isset($attrs['show'])) + $output .= "{$section_props}['show'] = true;\n"; + + if (!isset($attrs['loop'])) + $output .= "{$section_props}['loop'] = 1;\n"; + + if (!isset($attrs['max'])) + $output .= "{$section_props}['max'] = {$section_props}['loop'];\n"; + else + $output .= "if ({$section_props}['max'] < 0)\n" . + " {$section_props}['max'] = {$section_props}['loop'];\n"; + + if (!isset($attrs['step'])) + $output .= "{$section_props}['step'] = 1;\n"; + + if (!isset($attrs['start'])) + $output .= "{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n"; + else { + $output .= "if ({$section_props}['start'] < 0)\n" . + " {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n" . + "else\n" . + " {$section_props}['start'] = min({$section_props}['start'], {$section_props}['step'] > 0 ? {$section_props}['loop'] : {$section_props}['loop']-1);\n"; + } + + $output .= "if ({$section_props}['show']) {\n"; + if (!isset($attrs['start']) && !isset($attrs['step']) && !isset($attrs['max'])) { + $output .= " {$section_props}['total'] = {$section_props}['loop'];\n"; + } else { + $output .= " {$section_props}['total'] = min(ceil(({$section_props}['step'] > 0 ? {$section_props}['loop'] - {$section_props}['start'] : {$section_props}['start']+1)/abs({$section_props}['step'])), {$section_props}['max']);\n"; + } + $output .= " if ({$section_props}['total'] == 0)\n" . + " {$section_props}['show'] = false;\n" . + "} else\n" . + " {$section_props}['total'] = 0;\n"; + + $output .= "if ({$section_props}['show']):\n"; + $output .= " + for ({$section_props}['index'] = {$section_props}['start'], {$section_props}['iteration'] = 1; + {$section_props}['iteration'] <= {$section_props}['total']; + {$section_props}['index'] += {$section_props}['step'], {$section_props}['iteration']++):\n"; + $output .= "{$section_props}['rownum'] = {$section_props}['iteration'];\n"; + $output .= "{$section_props}['index_prev'] = {$section_props}['index'] - {$section_props}['step'];\n"; + $output .= "{$section_props}['index_next'] = {$section_props}['index'] + {$section_props}['step'];\n"; + $output .= "{$section_props}['first'] = ({$section_props}['iteration'] == 1);\n"; + $output .= "{$section_props}['last'] = ({$section_props}['iteration'] == {$section_props}['total']);\n"; + + $output .= "?>"; + + return $output; + } + + + /** + * Compile {foreach ...} tag. + * + * @param string $tag_args + * @return string + */ + function _compile_foreach_start($tag_args) + { + $attrs = $this->_parse_attrs($tag_args); + $arg_list = array(); + + if (empty($attrs['from'])) { + $this->_syntax_error("missing 'from' attribute", E_USER_ERROR, __FILE__, __LINE__); + } + + if (empty($attrs['item'])) { + $this->_syntax_error("missing 'item' attribute", E_USER_ERROR, __FILE__, __LINE__); + } + + $from = $attrs['from']; + $item = $this->_dequote($attrs['item']); + if (isset($attrs['name'])) + $name = $attrs['name']; + + $output = '_foreach[$name])) unset(\$this->_foreach[$name]);\n"; + $foreach_props = "\$this->_foreach[$name]"; + } + + $key_part = ''; + + foreach ($attrs as $attr_name => $attr_value) { + switch ($attr_name) { + case 'key': + $key = $this->_dequote($attrs['key']); + $key_part = "\$this->_tpl_vars['$key'] => "; + break; + + case 'name': + $output .= "{$foreach_props}['$attr_name'] = $attr_value;\n"; + break; + } + } + + if (isset($name)) { + $output .= "{$foreach_props}['total'] = count(\$_from = (array)$from);\n"; + $output .= "{$foreach_props}['show'] = {$foreach_props}['total'] > 0;\n"; + $output .= "if ({$foreach_props}['show']):\n"; + $output .= "{$foreach_props}['iteration'] = 0;\n"; + $output .= " foreach (\$_from as $key_part\$this->_tpl_vars['$item']):\n"; + $output .= " {$foreach_props}['iteration']++;\n"; + $output .= " {$foreach_props}['first'] = ({$foreach_props}['iteration'] == 1);\n"; + $output .= " {$foreach_props}['last'] = ({$foreach_props}['iteration'] == {$foreach_props}['total']);\n"; + } else { + $output .= "if (count(\$_from = (array)$from)):\n"; + $output .= " foreach (\$_from as $key_part\$this->_tpl_vars['$item']):\n"; + } + $output .= '?>'; + + return $output; + } + + + /** + * Compile {capture} .. {/capture} tags + * + * @param boolean $start true if this is the {capture} tag + * @param string $tag_args + * @return string + */ + + function _compile_capture_tag($start, $tag_args = '') + { + $attrs = $this->_parse_attrs($tag_args); + + if ($start) { + if (isset($attrs['name'])) + $buffer = $attrs['name']; + else + $buffer = "'default'"; + + if (isset($attrs['assign'])) + $assign = $attrs['assign']; + else + $assign = null; + $output = ""; + $this->_capture_stack[] = array($buffer, $assign); + } else { + list($buffer, $assign) = array_pop($this->_capture_stack); + $output = "_smarty_vars['capture'][$buffer] = ob_get_contents(); "; + if (isset($assign)) { + $output .= " \$this->assign($assign, ob_get_contents());"; + } + $output .= "ob_end_clean(); ?>"; + } + + return $output; + } + + /** + * Compile {if ...} tag + * + * @param string $tag_args + * @param boolean $elseif if true, uses elseif instead of if + * @return string + */ + function _compile_if_tag($tag_args, $elseif = false) + { + + /* Tokenize args for 'if' tag. */ + preg_match_all('/(?> + ' . $this->_obj_call_regexp . '(?:' . $this->_mod_regexp . '*)? | # valid object call + ' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*)? | # var or quoted string + \-?0[xX][0-9a-fA-F]+|\-?\d+(?:\.\d+)?|\.\d+|!==|===|==|!=|<>|<<|>>|<=|>=|\&\&|\|\||\(|\)|,|\!|\^|=|\&|\~|<|>|\||\%|\+|\-|\/|\*|\@ | # valid non-word token + \b\w+\b | # valid word token + \S+ # anything else + )/x', $tag_args, $match); + + $tokens = $match[0]; + + // make sure we have balanced parenthesis + $token_count = array_count_values($tokens); + if(isset($token_count['(']) && $token_count['('] != $token_count[')']) { + $this->_syntax_error("unbalanced parenthesis in if statement", E_USER_ERROR, __FILE__, __LINE__); + } + + $is_arg_stack = array(); + + for ($i = 0; $i < count($tokens); $i++) { + + $token = &$tokens[$i]; + + switch (strtolower($token)) { + case '!': + case '%': + case '!==': + case '==': + case '===': + case '>': + case '<': + case '!=': + case '<>': + case '<<': + case '>>': + case '<=': + case '>=': + case '&&': + case '||': + case '|': + case '^': + case '&': + case '~': + case ')': + case ',': + case '+': + case '-': + case '*': + case '/': + case '@': + break; + + case 'eq': + $token = '=='; + break; + + case 'ne': + case 'neq': + $token = '!='; + break; + + case 'lt': + $token = '<'; + break; + + case 'le': + case 'lte': + $token = '<='; + break; + + case 'gt': + $token = '>'; + break; + + case 'ge': + case 'gte': + $token = '>='; + break; + + case 'and': + $token = '&&'; + break; + + case 'or': + $token = '||'; + break; + + case 'not': + $token = '!'; + break; + + case 'mod': + $token = '%'; + break; + + case '(': + array_push($is_arg_stack, $i); + break; + + case 'is': + /* If last token was a ')', we operate on the parenthesized + expression. The start of the expression is on the stack. + Otherwise, we operate on the last encountered token. */ + if ($tokens[$i-1] == ')') + $is_arg_start = array_pop($is_arg_stack); + else + $is_arg_start = $i-1; + /* Construct the argument for 'is' expression, so it knows + what to operate on. */ + $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start)); + + /* Pass all tokens from next one until the end to the + 'is' expression parsing function. The function will + return modified tokens, where the first one is the result + of the 'is' expression and the rest are the tokens it + didn't touch. */ + $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1)); + + /* Replace the old tokens with the new ones. */ + array_splice($tokens, $is_arg_start, count($tokens), $new_tokens); + + /* Adjust argument start so that it won't change from the + current position for the next iteration. */ + $i = $is_arg_start; + break; + + default: + if(preg_match('!^' . $this->_func_regexp . '$!', $token) ) { + // function call + if($this->security && + !in_array($token, $this->security_settings['IF_FUNCS'])) { + $this->_syntax_error("(secure mode) '$token' not allowed in if statement", E_USER_ERROR, __FILE__, __LINE__); + } + } elseif(preg_match('!^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*)$!', $token)) { + // object or variable + $token = $this->_parse_var_props($token); + } elseif(is_numeric($token)) { + // number, skip it + } else { + $this->_syntax_error("unidentified token '$token'", E_USER_ERROR, __FILE__, __LINE__); + } + break; + } + } + + if ($elseif) + return ''; + else + return ''; + } + + + function _compile_arg_list($type, $name, $attrs, &$cache_code) { + $arg_list = array(); + + if (isset($type) && isset($name) + && isset($this->_plugins[$type]) + && isset($this->_plugins[$type][$name]) + && empty($this->_plugins[$type][$name][4]) + && is_array($this->_plugins[$type][$name][5]) + ) { + /* we have a list of parameters that should be cached */ + $_cache_attrs = $this->_plugins[$type][$name][5]; + $_count = $this->_cache_attrs_count++; + $cache_code = "\$_cache_attrs =& \$this->_smarty_cache_attrs('$this->_cache_serial','$_count');"; + + } else { + /* no parameters are cached */ + $_cache_attrs = null; + } + + foreach ($attrs as $arg_name => $arg_value) { + if (is_bool($arg_value)) + $arg_value = $arg_value ? 'true' : 'false'; + if (is_null($arg_value)) + $arg_value = 'null'; + if ($_cache_attrs && in_array($arg_name, $_cache_attrs)) { + $arg_list[] = "'$arg_name' => (\$this->_cache_including) ? \$_cache_attrs['$arg_name'] : (\$_cache_attrs['$arg_name']=$arg_value)"; + } else { + $arg_list[] = "'$arg_name' => $arg_value"; + } + } + return $arg_list; + } + + /** + * Parse is expression + * + * @param string $is_arg + * @param array $tokens + * @return array + */ + function _parse_is_expr($is_arg, $tokens) + { + $expr_end = 0; + $negate_expr = false; + + if (($first_token = array_shift($tokens)) == 'not') { + $negate_expr = true; + $expr_type = array_shift($tokens); + } else + $expr_type = $first_token; + + switch ($expr_type) { + case 'even': + if (isset($tokens[$expr_end]) && $tokens[$expr_end] == 'by') { + $expr_end++; + $expr_arg = $tokens[$expr_end++]; + $expr = "!(1 & ($is_arg / " . $this->_parse_var_props($expr_arg) . "))"; + } else + $expr = "!(1 & $is_arg)"; + break; + + case 'odd': + if (isset($tokens[$expr_end]) && $tokens[$expr_end] == 'by') { + $expr_end++; + $expr_arg = $tokens[$expr_end++]; + $expr = "(1 & ($is_arg / " . $this->_parse_var_props($expr_arg) . "))"; + } else + $expr = "(1 & $is_arg)"; + break; + + case 'div': + if (@$tokens[$expr_end] == 'by') { + $expr_end++; + $expr_arg = $tokens[$expr_end++]; + $expr = "!($is_arg % " . $this->_parse_var_props($expr_arg) . ")"; + } else { + $this->_syntax_error("expecting 'by' after 'div'", E_USER_ERROR, __FILE__, __LINE__); + } + break; + + default: + $this->_syntax_error("unknown 'is' expression - '$expr_type'", E_USER_ERROR, __FILE__, __LINE__); + break; + } + + if ($negate_expr) { + $expr = "!($expr)"; + } + + array_splice($tokens, 0, $expr_end, $expr); + + return $tokens; + } + + + /** + * Parse attribute string + * + * @param string $tag_args + * @return array + */ + function _parse_attrs($tag_args) + { + + /* Tokenize tag attributes. */ + preg_match_all('/(?:' . $this->_obj_call_regexp . '|' . $this->_qstr_regexp . ' | (?>[^"\'=\s]+) + )+ | + [=] + /x', $tag_args, $match); + $tokens = $match[0]; + + $attrs = array(); + /* Parse state: + 0 - expecting attribute name + 1 - expecting '=' + 2 - expecting attribute value (not '=') */ + $state = 0; + + foreach ($tokens as $token) { + switch ($state) { + case 0: + /* If the token is a valid identifier, we set attribute name + and go to state 1. */ + if (preg_match('!^\w+$!', $token)) { + $attr_name = $token; + $state = 1; + } else + $this->_syntax_error("invalid attribute name: '$token'", E_USER_ERROR, __FILE__, __LINE__); + break; + + case 1: + /* If the token is '=', then we go to state 2. */ + if ($token == '=') { + $state = 2; + } else + $this->_syntax_error("expecting '=' after attribute name '$last_token'", E_USER_ERROR, __FILE__, __LINE__); + break; + + case 2: + /* If token is not '=', we set the attribute value and go to + state 0. */ + if ($token != '=') { + /* We booleanize the token if it's a non-quoted possible + boolean value. */ + if (preg_match('!^(on|yes|true)$!', $token)) { + $token = 'true'; + } else if (preg_match('!^(off|no|false)$!', $token)) { + $token = 'false'; + } else if ($token == 'null') { + $token = 'null'; + } else if (preg_match('!^-?([0-9]+|0[xX][0-9a-fA-F]+)$!', $token)) { + /* treat integer literally */ + } else if (!preg_match('!^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . ')*$!', $token)) { + /* treat as a string, double-quote it escaping quotes */ + $token = '"'.addslashes($token).'"'; + } + + $attrs[$attr_name] = $token; + $state = 0; + } else + $this->_syntax_error("'=' cannot be an attribute value", E_USER_ERROR, __FILE__, __LINE__); + break; + } + $last_token = $token; + } + + if($state != 0) { + if($state == 1) { + $this->_syntax_error("expecting '=' after attribute name '$last_token'", E_USER_ERROR, __FILE__, __LINE__); + } else { + $this->_syntax_error("missing attribute value", E_USER_ERROR, __FILE__, __LINE__); + } + } + + $this->_parse_vars_props($attrs); + + return $attrs; + } + + /** + * compile multiple variables and section properties tokens into + * PHP code + * + * @param array $tokens + */ + function _parse_vars_props(&$tokens) + { + foreach($tokens as $key => $val) { + $tokens[$key] = $this->_parse_var_props($val); + } + } + + /** + * compile single variable and section properties token into + * PHP code + * + * @param string $val + * @param string $tag_attrs + * @return string + */ + function _parse_var_props($val) + { + $val = trim($val); + + if(preg_match('!^(' . $this->_obj_call_regexp . '|' . $this->_dvar_regexp . ')(' . $this->_mod_regexp . '*)$!', $val, $match)) { + // $ variable or object + $return = $this->_parse_var($match[1]); + $modifiers = $match[2]; + if (!empty($this->default_modifiers) && !preg_match('!(^|\|)smarty:nodefaults($|\|)!',$modifiers)) { + $_default_mod_string = implode('|',(array)$this->default_modifiers); + $modifiers = empty($modifiers) ? $_default_mod_string : $_default_mod_string . '|' . $modifiers; + } + $this->_parse_modifiers($return, $modifiers); + return $return; + } elseif (preg_match('!^' . $this->_db_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) { + // double quoted text + preg_match('!^(' . $this->_db_qstr_regexp . ')('. $this->_mod_regexp . '*)$!', $val, $match); + $return = $this->_expand_quoted_text($match[1]); + if($match[2] != '') { + $this->_parse_modifiers($return, $match[2]); + } + return $return; + } + elseif(preg_match('!^' . $this->_si_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) { + // single quoted text + preg_match('!^(' . $this->_si_qstr_regexp . ')('. $this->_mod_regexp . '*)$!', $val, $match); + if($match[2] != '') { + $this->_parse_modifiers($match[1], $match[2]); + return $match[1]; + } + } + elseif(preg_match('!^' . $this->_cvar_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) { + // config var + return $this->_parse_conf_var($val); + } + elseif(preg_match('!^' . $this->_svar_regexp . '(?:' . $this->_mod_regexp . '*)$!', $val)) { + // section var + return $this->_parse_section_prop($val); + } + elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) { + // literal string + return $this->_expand_quoted_text('"' . $val .'"'); + } + return $val; + } + + /** + * expand quoted text with embedded variables + * + * @param string $var_expr + * @return string + */ + function _expand_quoted_text($var_expr) + { + // if contains unescaped $, expand it + if(preg_match_all('%(?:\`(?_dvar_guts_regexp . '\`)|(?:(?_parse_var(str_replace('`','',$_var)) . ')."', $var_expr); + } + $_return = preg_replace('%\.""|(?_dvar_math_regexp.'|'.$this->_qstr_regexp.')!', $var_expr, -1, PREG_SPLIT_DELIM_CAPTURE); + + if(count($_math_vars) > 1) { + $_first_var = ""; + $_complete_var = ""; + $_output = ""; + // simple check if there is any math, to stop recursion (due to modifiers with "xx % yy" as parameter) + foreach($_math_vars as $_k => $_math_var) { + $_math_var = $_math_vars[$_k]; + + if(!empty($_math_var) || is_numeric($_math_var)) { + // hit a math operator, so process the stuff which came before it + if(preg_match('!^' . $this->_dvar_math_regexp . '$!', $_math_var)) { + $_has_math = true; + if(!empty($_complete_var) || is_numeric($_complete_var)) { + $_output .= $this->_parse_var($_complete_var); + } + + // just output the math operator to php + $_output .= $_math_var; + + if(empty($_first_var)) + $_first_var = $_complete_var; + + $_complete_var = ""; + } else { + // fetch multiple -> (like $foo->bar->baz ) which wouldn't get fetched else, because it would only get $foo->bar and treat the ->baz as "-" ">baz" then + for($_i = $_k + 1; $_i <= count($_math_vars); $_i += 2) { + // fetch -> because it gets splitted at - and move it back together + if( /* prevent notice */ (isset($_math_vars[$_i]) && isset($_math_vars[$_i+1])) && ($_math_vars[$_i] === '-' && $_math_vars[$_i+1]{0} === '>')) { + $_math_var .= $_math_vars[$_i].$_math_vars[$_i+1]; + $_math_vars[$_i] = $_math_vars[$_i+1] = ''; + } else { + break; + } + } + $_complete_var .= $_math_var; + } + } + } + if($_has_math) { + if(!empty($_complete_var) || is_numeric($_complete_var)) + $_output .= $this->_parse_var($_complete_var, true); + + // get the modifiers working (only the last var from math + modifier is left) + $var_expr = $_complete_var; + } + } + + // prevent cutting of first digit in the number (we _definitly_ got a number if the first char is a digit) + if(is_numeric($var_expr{0})) + $_var_ref = $var_expr; + else + $_var_ref = substr($var_expr, 1); + + if(!$_has_math) { + // get [foo] and .foo and ->foo and (...) pieces + preg_match_all('!(?:^\w+)|' . $this->_obj_params_regexp . '|(?:' . $this->_var_bracket_regexp . ')|->\$?\w+|\.\$?\w+|\S+!', $_var_ref, $match); + + $_indexes = $match[0]; + $_var_name = array_shift($_indexes); + + /* Handle $smarty.* variable references as a special case. */ + if ($_var_name == 'smarty') { + /* + * If the reference could be compiled, use the compiled output; + * otherwise, fall back on the $smarty variable generated at + * run-time. + */ + if (($smarty_ref = $this->_compile_smarty_ref($_indexes)) !== null) { + $_output = $smarty_ref; + } else { + $_var_name = substr(array_shift($_indexes), 1); + $_output = "\$this->_smarty_vars['$_var_name']"; + } + } elseif(is_numeric($_var_name) && is_numeric($var_expr{0})) { + // because . is the operator for accessing arrays thru inidizes we need to put it together again for floating point numbers + if(count($_indexes) > 0) + { + $_var_name .= implode("", $_indexes); + $_indexes = array(); + } + $_output = $_var_name; + } else { + $_output = "\$this->_tpl_vars['$_var_name']"; + } + + foreach ($_indexes as $_index) { + if ($_index{0} == '[') { + $_index = substr($_index, 1, -1); + if (is_numeric($_index)) { + $_output .= "[$_index]"; + } elseif ($_index{0} == '$') { + if (strpos($_index, '.') !== false) { + $_output .= '[' . $this->_parse_var($_index) . ']'; + } else { + $_output .= "[\$this->_tpl_vars['" . substr($_index, 1) . "']]"; + } + } else { + $_var_parts = explode('.', $_index); + $_var_section = $_var_parts[0]; + $_var_section_prop = isset($_var_parts[1]) ? $_var_parts[1] : 'index'; + $_output .= "[\$this->_sections['$_var_section']['$_var_section_prop']]"; + } + } else if ($_index{0} == '.') { + if ($_index{1} == '$') + $_output .= "[\$this->_tpl_vars['" . substr($_index, 2) . "']]"; + else + $_output .= "['" . substr($_index, 1) . "']"; + } else if (substr($_index,0,2) == '->') { + if(substr($_index,2,2) == '__') { + $this->_syntax_error('call to internal object members is not allowed', E_USER_ERROR, __FILE__, __LINE__); + } elseif($this->security && substr($_index, 2, 1) == '_') { + $this->_syntax_error('(secure) call to private object member is not allowed', E_USER_ERROR, __FILE__, __LINE__); + } elseif ($_index{2} == '$') { + if ($this->security) { + $this->_syntax_error('(secure) call to dynamic object member is not allowed', E_USER_ERROR, __FILE__, __LINE__); + } else { + $_output .= '->{(($_var=$this->_tpl_vars[\''.substr($_index,3).'\']) && substr($_var,0,2)!=\'__\') ? $_var : $this->trigger_error("cannot access property \\"$_var\\"")}'; + } + } else { + $_output .= $_index; + } + } elseif ($_index{0} == '(') { + $_index = $this->_parse_parenth_args($_index); + $_output .= $_index; + } else { + $_output .= $_index; + } + } + } + + return $_output; + } + + /** + * parse arguments in function call parenthesis + * + * @param string $parenth_args + * @return string + */ + function _parse_parenth_args($parenth_args) + { + preg_match_all('!' . $this->_param_regexp . '!',$parenth_args, $match); + $match = $match[0]; + rsort($match); + reset($match); + $orig_vals = $match; + $this->_parse_vars_props($match); + return str_replace($orig_vals, $match, $parenth_args); + } + + /** + * parse configuration variable expression into PHP code + * + * @param string $conf_var_expr + */ + function _parse_conf_var($conf_var_expr) + { + $parts = explode('|', $conf_var_expr, 2); + $var_ref = $parts[0]; + $modifiers = isset($parts[1]) ? $parts[1] : ''; + + $var_name = substr($var_ref, 1, -1); + + $output = "\$this->_config[0]['vars']['$var_name']"; + + $this->_parse_modifiers($output, $modifiers); + + return $output; + } + + /** + * parse section property expression into PHP code + * + * @param string $section_prop_expr + * @return string + */ + function _parse_section_prop($section_prop_expr) + { + $parts = explode('|', $section_prop_expr, 2); + $var_ref = $parts[0]; + $modifiers = isset($parts[1]) ? $parts[1] : ''; + + preg_match('!%(\w+)\.(\w+)%!', $var_ref, $match); + $section_name = $match[1]; + $prop_name = $match[2]; + + $output = "\$this->_sections['$section_name']['$prop_name']"; + + $this->_parse_modifiers($output, $modifiers); + + return $output; + } + + + /** + * parse modifier chain into PHP code + * + * sets $output to parsed modified chain + * @param string $output + * @param string $modifier_string + */ + function _parse_modifiers(&$output, $modifier_string) + { + preg_match_all('!\|(@?\w+)((?>:(?:'. $this->_qstr_regexp . '|[^|]+))*)!', '|' . $modifier_string, $_match); + list(, $_modifiers, $modifier_arg_strings) = $_match; + + for ($_i = 0, $_for_max = count($_modifiers); $_i < $_for_max; $_i++) { + $_modifier_name = $_modifiers[$_i]; + + if($_modifier_name == 'smarty') { + // skip smarty modifier + continue; + } + + preg_match_all('!:(' . $this->_qstr_regexp . '|[^:]+)!', $modifier_arg_strings[$_i], $_match); + $_modifier_args = $_match[1]; + + if ($_modifier_name{0} == '@') { + $_map_array = false; + $_modifier_name = substr($_modifier_name, 1); + } else { + $_map_array = true; + } + + if (empty($this->_plugins['modifier'][$_modifier_name]) + && !$this->_get_plugin_filepath('modifier', $_modifier_name) + && function_exists($_modifier_name)) { + if ($this->security && !in_array($_modifier_name, $this->security_settings['MODIFIER_FUNCS'])) { + $this->_trigger_fatal_error("[plugin] (secure mode) modifier '$_modifier_name' is not allowed" , $this->_current_file, $this->_current_line_no, __FILE__, __LINE__); + } else { + $this->_plugins['modifier'][$_modifier_name] = array($_modifier_name, null, null, false); + } + } + $this->_add_plugin('modifier', $_modifier_name); + + $this->_parse_vars_props($_modifier_args); + + if($_modifier_name == 'default') { + // supress notifications of default modifier vars and args + if($output{0} == '$') { + $output = '@' . $output; + } + if(isset($_modifier_args[0]) && $_modifier_args[0]{0} == '$') { + $_modifier_args[0] = '@' . $_modifier_args[0]; + } + } + if (count($_modifier_args) > 0) + $_modifier_args = ', '.implode(', ', $_modifier_args); + else + $_modifier_args = ''; + + if ($_map_array) { + $output = "((is_array(\$_tmp=$output)) ? \$this->_run_mod_handler('$_modifier_name', true, \$_tmp$_modifier_args) : " . $this->_compile_plugin_call('modifier', $_modifier_name) . "(\$_tmp$_modifier_args))"; + + } else { + + $output = $this->_compile_plugin_call('modifier', $_modifier_name)."($output$_modifier_args)"; + + } + } + } + + + /** + * add plugin + * + * @param string $type + * @param string $name + * @param boolean? $delayed_loading + */ + function _add_plugin($type, $name, $delayed_loading = null) + { + if (!isset($this->_plugin_info[$type])) { + $this->_plugin_info[$type] = array(); + } + if (!isset($this->_plugin_info[$type][$name])) { + $this->_plugin_info[$type][$name] = array($this->_current_file, + $this->_current_line_no, + $delayed_loading); + } + } + + + /** + * Compiles references of type $smarty.foo + * + * @param string $indexes + * @return string + */ + function _compile_smarty_ref(&$indexes) + { + /* Extract the reference name. */ + $_ref = substr($indexes[0], 1); + foreach($indexes as $_index_no=>$_index) { + if ($_index{0} != '.' && $_index_no<2 || !preg_match('!^(\.|\[|->)!', $_index)) { + $this->_syntax_error('$smarty' . implode('', array_slice($indexes, 0, 2)) . ' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__); + } + } + + switch ($_ref) { + case 'now': + $compiled_ref = 'time()'; + $_max_index = 1; + break; + + case 'foreach': + case 'section': + array_shift($indexes); + $_var = $this->_parse_var_props(substr($indexes[0], 1)); + if ($_ref == 'foreach') + $compiled_ref = "\$this->_foreach[$_var]"; + else + $compiled_ref = "\$this->_sections[$_var]"; + break; + + case 'get': + $compiled_ref = ($this->request_use_auto_globals) ? '$_GET' : "\$GLOBALS['HTTP_GET_VARS']"; + break; + + case 'post': + $compiled_ref = ($this->request_use_auto_globals) ? '$_POST' : "\$GLOBALS['HTTP_POST_VARS']"; + break; + + case 'cookies': + $compiled_ref = ($this->request_use_auto_globals) ? '$_COOKIE' : "\$GLOBALS['HTTP_COOKIE_VARS']"; + break; + + case 'env': + $compiled_ref = ($this->request_use_auto_globals) ? '$_ENV' : "\$GLOBALS['HTTP_ENV_VARS']"; + break; + + case 'server': + $compiled_ref = ($this->request_use_auto_globals) ? '$_SERVER' : "\$GLOBALS['HTTP_SERVER_VARS']"; + break; + + case 'session': + $compiled_ref = ($this->request_use_auto_globals) ? '$_SESSION' : "\$GLOBALS['HTTP_SESSION_VARS']"; + break; + + /* + * These cases are handled either at run-time or elsewhere in the + * compiler. + */ + case 'request': + if ($this->request_use_auto_globals) { + $compiled_ref = '$_REQUEST'; + break; + } else { + $this->_init_smarty_vars = true; + } + return null; + + case 'capture': + return null; + + case 'template': + $compiled_ref = "'$this->_current_file'"; + $_max_index = 1; + break; + + case 'version': + $compiled_ref = "'$this->_version'"; + $_max_index = 1; + break; + + case 'const': + array_shift($indexes); + $_val = $this->_parse_var_props(substr($indexes[0],1)); + $compiled_ref = '@constant(' . $_val . ')'; + $_max_index = 1; + break; + + case 'config': + $compiled_ref = "\$this->_config[0]['vars']"; + $_max_index = 3; + break; + + default: + $this->_syntax_error('$smarty.' . $_ref . ' is an unknown reference', E_USER_ERROR, __FILE__, __LINE__); + break; + } + + if (isset($_max_index) && count($indexes) > $_max_index) { + $this->_syntax_error('$smarty' . implode('', $indexes) .' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__); + } + + array_shift($indexes); + return $compiled_ref; + } + + /** + * compiles call to plugin of type $type with name $name + * returns a string containing the function-name or method call + * without the paramter-list that would have follow to make the + * call valid php-syntax + * + * @param string $type + * @param string $name + * @return string + */ + function _compile_plugin_call($type, $name) { + if (isset($this->_plugins[$type][$name])) { + /* plugin loaded */ + if (is_array($this->_plugins[$type][$name][0])) { + return ((is_object($this->_plugins[$type][$name][0][0])) ? + "\$this->_plugins['$type']['$name'][0][0]->" /* method callback */ + : (string)($this->_plugins[$type][$name][0][0]).'::' /* class callback */ + ). $this->_plugins[$type][$name][0][1]; + + } else { + /* function callback */ + return $this->_plugins[$type][$name][0]; + + } + } else { + /* plugin not loaded -> auto-loadable-plugin */ + return 'smarty_'.$type.'_'.$name; + + } + } + + /** + * load pre- and post-filters + */ + function _load_filters() + { + if (count($this->_plugins['prefilter']) > 0) { + foreach ($this->_plugins['prefilter'] as $filter_name => $prefilter) { + if ($prefilter === false) { + unset($this->_plugins['prefilter'][$filter_name]); + $_params = array('plugins' => array(array('prefilter', $filter_name, null, null, false))); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php'); + smarty_core_load_plugins($_params, $this); + } + } + } + if (count($this->_plugins['postfilter']) > 0) { + foreach ($this->_plugins['postfilter'] as $filter_name => $postfilter) { + if ($postfilter === false) { + unset($this->_plugins['postfilter'][$filter_name]); + $_params = array('plugins' => array(array('postfilter', $filter_name, null, null, false))); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php'); + smarty_core_load_plugins($_params, $this); + } + } + } + } + + + /** + * Quote subpattern references + * + * @param string $string + * @return string + */ + function _quote_replace($string) + { + return preg_replace('![\\$]\d!', '\\\\\\0', $string); + } + + /** + * display Smarty syntax error + * + * @param string $error_msg + * @param integer $error_type + * @param string $file + * @param integer $line + */ + function _syntax_error($error_msg, $error_type = E_USER_ERROR, $file=null, $line=null) + { + $this->_trigger_fatal_error("syntax error: $error_msg", $this->_current_file, $this->_current_line_no, $file, $line, $error_type); + } + + + /** + * check if the compilation changes from cacheable to + * non-cacheable state with the beginning of the current + * plugin. return php-code to reflect the transition. + * @return string + */ + function _push_cacheable_state($type, $name) { + $_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4]; + if ($_cacheable + || 0<$this->_cacheable_state++) return ''; + if (!isset($this->_cache_serial)) $this->_cache_serial = md5(uniqid('Smarty')); + $_ret = 'if ($this->caching) { echo \'{nocache:' + . $this->_cache_serial . '#' . $this->_nocache_count + . '}\';}'; + return $_ret; + } + + + /** + * check if the compilation changes from non-cacheable to + * cacheable state with the end of the current plugin return + * php-code to reflect the transition. + * @return string + */ + function _pop_cacheable_state($type, $name) { + $_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4]; + if ($_cacheable + || --$this->_cacheable_state>0) return ''; + return 'if ($this->caching) { echo \'{/nocache:' + . $this->_cache_serial . '#' . ($this->_nocache_count++) + . '}\';}'; + } + + + /** + * push opening tag-name, file-name and line-number on the tag-stack + * @param: string the opening tag's name + */ + function _push_tag($open_tag) + { + array_push($this->_tag_stack, array($open_tag, $this->_current_line_no)); + } + + /** + * pop closing tag-name + * raise an error if this stack-top doesn't match with the closing tag + * @param: string the closing tag's name + * @return: string the opening tag's name + */ + function _pop_tag($close_tag) + { + $message = ''; + if (count($this->_tag_stack)>0) { + list($_open_tag, $_line_no) = array_pop($this->_tag_stack); + if ($close_tag == $_open_tag) { + return $_open_tag; + } + if ($close_tag == 'if' && ($_open_tag == 'else' || $_open_tag == 'elseif' )) { + return $this->_pop_tag($close_tag); + } + if ($close_tag == 'section' && $_open_tag == 'sectionelse') { + $this->_pop_tag($close_tag); + return $_open_tag; + } + if ($close_tag == 'foreach' && $_open_tag == 'foreachelse') { + $this->_pop_tag($close_tag); + return $_open_tag; + } + $message = " expected {/$_open_tag} (opened line $_line_no)."; + } + $this->_syntax_error("mismatched tag {/$close_tag}.$message", + E_USER_ERROR, __FILE__, __LINE__); + } + +} + +/** + * compare to values by their string length + * + * @access private + * @param string $a + * @param string $b + * @return 0|-1|1 + */ +function _smarty_sort_length($a, $b) +{ + if($a == $b) + return 0; + + if(strlen($a) == strlen($b)) + return ($a > $b) ? -1 : 1; + + return (strlen($a) > strlen($b)) ? -1 : 1; +} + + +/* vim: set et: */ + +?> diff --git a/google/smarty/core/core.assemble_plugin_filepath.php b/google/smarty/core/core.assemble_plugin_filepath.php new file mode 100755 index 0000000..c0d9d86 --- /dev/null +++ b/google/smarty/core/core.assemble_plugin_filepath.php @@ -0,0 +1,66 @@ +plugins_dir as $_plugin_dir) { + + $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename; + + // see if path is relative + if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $_plugin_dir)) { + $_relative_paths[] = $_plugin_dir; + // relative path, see if it is in the SMARTY_DIR + if (@is_readable(SMARTY_DIR . $_plugin_filepath)) { + $_return = SMARTY_DIR . $_plugin_filepath; + break; + } + } + // try relative to cwd (or absolute) + if (@is_readable($_plugin_filepath)) { + $_return = $_plugin_filepath; + break; + } + } + + if($_return === false) { + // still not found, try PHP include_path + if(isset($_relative_paths)) { + foreach ((array)$_relative_paths as $_plugin_dir) { + + $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename; + + $_params = array('file_path' => $_plugin_filepath); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php'); + if(smarty_core_get_include_path($_params, $smarty)) { + return $_params['new_file_path']; + } + } + } + } + $_filepaths_cache[$_plugin_filename] = $_return; + return $_return; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/core/core.assign_smarty_interface.php b/google/smarty/core/core.assign_smarty_interface.php new file mode 100755 index 0000000..7e65a73 --- /dev/null +++ b/google/smarty/core/core.assign_smarty_interface.php @@ -0,0 +1,43 @@ + + * Name: assign_smarty_interface
    + * Purpose: assign the $smarty interface variable + * @param array Format: null + * @param Smarty + */ +function smarty_core_assign_smarty_interface($params, &$smarty) +{ + if (isset($smarty->_smarty_vars) && isset($smarty->_smarty_vars['request'])) { + return; + } + + $_globals_map = array('g' => 'HTTP_GET_VARS', + 'p' => 'HTTP_POST_VARS', + 'c' => 'HTTP_COOKIE_VARS', + 's' => 'HTTP_SERVER_VARS', + 'e' => 'HTTP_ENV_VARS'); + + $_smarty_vars_request = array(); + + foreach (preg_split('!!', strtolower($smarty->request_vars_order)) as $_c) { + if (isset($_globals_map[$_c])) { + $_smarty_vars_request = array_merge($_smarty_vars_request, $GLOBALS[$_globals_map[$_c]]); + } + } + $_smarty_vars_request = @array_merge($_smarty_vars_request, $GLOBALS['HTTP_SESSION_VARS']); + + $smarty->_smarty_vars['request'] = $_smarty_vars_request; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/core/core.create_dir_structure.php b/google/smarty/core/core.create_dir_structure.php new file mode 100755 index 0000000..b898ada --- /dev/null +++ b/google/smarty/core/core.create_dir_structure.php @@ -0,0 +1,80 @@ +_dir_perms) && !is_dir($_new_dir)) { + $smarty->trigger_error("problem creating directory '" . $_new_dir . "'"); + return false; + } + $_new_dir .= '/'; + } + } +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/core/core.display_debug_console.php b/google/smarty/core/core.display_debug_console.php new file mode 100755 index 0000000..c509ff7 --- /dev/null +++ b/google/smarty/core/core.display_debug_console.php @@ -0,0 +1,60 @@ + + * Name: display_debug_console
    + * Purpose: display the javascript debug console window + * @param array Format: null + * @param Smarty + */ +function smarty_core_display_debug_console($params, &$smarty) +{ + // we must force compile the debug template in case the environment + // changed between separate applications. + + if(empty($smarty->debug_tpl)) { + // set path to debug template from SMARTY_DIR + $smarty->debug_tpl = SMARTY_DIR . 'debug.tpl'; + if($smarty->security && is_file($smarty->debug_tpl)) { + $smarty->secure_dir[] = dirname(realpath($smarty->debug_tpl)); + } + } + + $_ldelim_orig = $smarty->left_delimiter; + $_rdelim_orig = $smarty->right_delimiter; + + $smarty->left_delimiter = '{'; + $smarty->right_delimiter = '}'; + + $_compile_id_orig = $smarty->_compile_id; + $smarty->_compile_id = null; + + $_compile_path = $smarty->_get_compile_path($smarty->debug_tpl); + if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path)) + { + ob_start(); + $smarty->_include($_compile_path); + $_results = ob_get_contents(); + ob_end_clean(); + } else { + $_results = ''; + } + + $smarty->_compile_id = $_compile_id_orig; + + $smarty->left_delimiter = $_ldelim_orig; + $smarty->right_delimiter = $_rdelim_orig; + + return $_results; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/core/core.get_include_path.php b/google/smarty/core/core.get_include_path.php new file mode 100755 index 0000000..4343241 --- /dev/null +++ b/google/smarty/core/core.get_include_path.php @@ -0,0 +1,44 @@ + diff --git a/google/smarty/core/core.get_microtime.php b/google/smarty/core/core.get_microtime.php new file mode 100755 index 0000000..f1a28e0 --- /dev/null +++ b/google/smarty/core/core.get_microtime.php @@ -0,0 +1,23 @@ + diff --git a/google/smarty/core/core.get_php_resource.php b/google/smarty/core/core.get_php_resource.php new file mode 100755 index 0000000..8121acf --- /dev/null +++ b/google/smarty/core/core.get_php_resource.php @@ -0,0 +1,80 @@ +trusted_dir; + $smarty->_parse_resource_name($params, $smarty); + + /* + * Find out if the resource exists. + */ + + if ($params['resource_type'] == 'file') { + $_readable = false; + if(file_exists($params['resource_name']) && is_readable($params['resource_name'])) { + $_readable = true; + } else { + // test for file in include_path + $_params = array('file_path' => $params['resource_name']); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php'); + if(smarty_core_get_include_path($_params, $smarty)) { + $_include_path = $_params['new_file_path']; + $_readable = true; + } + } + } else if ($params['resource_type'] != 'file') { + $_template_source = null; + $_readable = is_callable($smarty->_plugins['resource'][$params['resource_type']][0][0]) + && call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][0], + array($params['resource_name'], &$_template_source, &$smarty)); + } + + /* + * Set the error function, depending on which class calls us. + */ + if (method_exists($smarty, '_syntax_error')) { + $_error_funcc = '_syntax_error'; + } else { + $_error_funcc = 'trigger_error'; + } + + if ($_readable) { + if ($smarty->security) { + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.is_trusted.php'); + if (!smarty_core_is_trusted($params, $smarty)) { + $smarty->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted'); + return false; + } + } + } else { + $smarty->$_error_funcc($params['resource_type'] . ':' . $params['resource_name'] . ' is not readable'); + return false; + } + + if ($params['resource_type'] == 'file') { + $params['php_resource'] = $params['resource_name']; + } else { + $params['php_resource'] = $_template_source; + } + return true; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/core/core.is_secure.php b/google/smarty/core/core.is_secure.php new file mode 100755 index 0000000..877886b --- /dev/null +++ b/google/smarty/core/core.is_secure.php @@ -0,0 +1,59 @@ +security || $smarty->security_settings['INCLUDE_ANY']) { + return true; + } + + $_smarty_secure = false; + if ($params['resource_type'] == 'file') { + if($check_template_dir) { + if (!in_array($smarty->template_dir, $smarty->secure_dir)) + // add template_dir to secure_dir array + array_unshift($smarty->secure_dir, $smarty->template_dir); + $check_template_dir = false; + } + if (!empty($smarty->secure_dir)) { + $_rp = realpath($params['resource_name']); + foreach ((array)$smarty->secure_dir as $curr_dir) { + if ( !empty($curr_dir) && is_readable ($curr_dir)) { + $_cd = realpath($curr_dir); + if (strncmp($_rp, $_cd, strlen($_cd)) == 0 + && $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) { + $_smarty_secure = true; + break; + } + } + } + } + } else { + // resource is not on local file system + $_smarty_secure = call_user_func_array( + $smarty->_plugins['resource'][$params['resource_type']][0][2], + array($params['resource_name'], &$_smarty_secure, &$smarty)); + } + + return $_smarty_secure; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/core/core.is_trusted.php b/google/smarty/core/core.is_trusted.php new file mode 100755 index 0000000..c90e3ef --- /dev/null +++ b/google/smarty/core/core.is_trusted.php @@ -0,0 +1,50 @@ +trusted_dir)) { + $_rp = realpath($params['resource_name']); + foreach ((array)$smarty->trusted_dir as $curr_dir) { + if (!empty($curr_dir) && is_readable ($curr_dir)) { + $_cd = realpath($curr_dir); + if (strncmp($_rp, $_cd, strlen($_cd)) == 0 + && $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) { + $_smarty_trusted = true; + break; + } + } + } + } + + } else { + // resource is not on local file system + $_smarty_trusted = call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][3], + array($params['resource_name'], $smarty)); + } + + return $_smarty_trusted; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/core/core.load_plugins.php b/google/smarty/core/core.load_plugins.php new file mode 100755 index 0000000..6db1dc5 --- /dev/null +++ b/google/smarty/core/core.load_plugins.php @@ -0,0 +1,125 @@ +_plugins[$_type][$_name]; + + /* + * We do not load plugin more than once for each instance of Smarty. + * The following code checks for that. The plugin can also be + * registered dynamically at runtime, in which case template file + * and line number will be unknown, so we fill them in. + * + * The final element of the info array is a flag that indicates + * whether the dynamically registered plugin function has been + * checked for existence yet or not. + */ + if (isset($_plugin)) { + if (empty($_plugin[3])) { + if (!is_callable($_plugin[0])) { + $smarty->_trigger_fatal_error("[plugin] $_type '$_name' is not implemented", $_tpl_file, $_tpl_line, __FILE__, __LINE__); + } else { + $_plugin[1] = $_tpl_file; + $_plugin[2] = $_tpl_line; + $_plugin[3] = true; + if (!isset($_plugin[4])) $_plugin[4] = true; /* cacheable */ + } + } + continue; + } else if ($_type == 'insert') { + /* + * For backwards compatibility, we check for insert functions in + * the symbol table before trying to load them as a plugin. + */ + $_plugin_func = 'insert_' . $_name; + if (function_exists($_plugin_func)) { + $_plugin = array($_plugin_func, $_tpl_file, $_tpl_line, true, false); + continue; + } + } + + $_plugin_file = $smarty->_get_plugin_filepath($_type, $_name); + + if (! $_found = ($_plugin_file != false)) { + $_message = "could not load plugin file '$_type.$_name.php'\n"; + } + + /* + * If plugin file is found, it -must- provide the properly named + * plugin function. In case it doesn't, simply output the error and + * do not fall back on any other method. + */ + if ($_found) { + include_once $_plugin_file; + + $_plugin_func = 'smarty_' . $_type . '_' . $_name; + if (!function_exists($_plugin_func)) { + $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", $_tpl_file, $_tpl_line, __FILE__, __LINE__); + continue; + } + } + /* + * In case of insert plugins, their code may be loaded later via + * 'script' attribute. + */ + else if ($_type == 'insert' && $_delayed_loading) { + $_plugin_func = 'smarty_' . $_type . '_' . $_name; + $_found = true; + } + + /* + * Plugin specific processing and error checking. + */ + if (!$_found) { + if ($_type == 'modifier') { + /* + * In case modifier falls back on using PHP functions + * directly, we only allow those specified in the security + * context. + */ + if ($smarty->security && !in_array($_name, $smarty->security_settings['MODIFIER_FUNCS'])) { + $_message = "(secure mode) modifier '$_name' is not allowed"; + } else { + if (!function_exists($_name)) { + $_message = "modifier '$_name' is not implemented"; + } else { + $_plugin_func = $_name; + $_found = true; + } + } + } else if ($_type == 'function') { + /* + * This is a catch-all situation. + */ + $_message = "unknown tag - '$_name'"; + } + } + + if ($_found) { + $smarty->_plugins[$_type][$_name] = array($_plugin_func, $_tpl_file, $_tpl_line, true, true); + } else { + // output error + $smarty->_trigger_fatal_error('[plugin] ' . $_message, $_tpl_file, $_tpl_line, __FILE__, __LINE__); + } + } +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/core/core.load_resource_plugin.php b/google/smarty/core/core.load_resource_plugin.php new file mode 100755 index 0000000..a7d37d1 --- /dev/null +++ b/google/smarty/core/core.load_resource_plugin.php @@ -0,0 +1,74 @@ +_plugins['resource'][$params['type']]; + if (isset($_plugin)) { + if (!$_plugin[1] && count($_plugin[0])) { + $_plugin[1] = true; + foreach ($_plugin[0] as $_plugin_func) { + if (!is_callable($_plugin_func)) { + $_plugin[1] = false; + break; + } + } + } + + if (!$_plugin[1]) { + $smarty->_trigger_fatal_error("[plugin] resource '" . $params['type'] . "' is not implemented", null, null, __FILE__, __LINE__); + } + + return; + } + + $_plugin_file = $smarty->_get_plugin_filepath('resource', $params['type']); + $_found = ($_plugin_file != false); + + if ($_found) { /* + * If the plugin file is found, it -must- provide the properly named + * plugin functions. + */ + include_once($_plugin_file); + + /* + * Locate functions that we require the plugin to provide. + */ + $_resource_ops = array('source', 'timestamp', 'secure', 'trusted'); + $_resource_funcs = array(); + foreach ($_resource_ops as $_op) { + $_plugin_func = 'smarty_resource_' . $params['type'] . '_' . $_op; + if (!function_exists($_plugin_func)) { + $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", null, null, __FILE__, __LINE__); + return; + } else { + $_resource_funcs[] = $_plugin_func; + } + } + + $smarty->_plugins['resource'][$params['type']] = array($_resource_funcs, true); + } +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/core/core.process_cached_inserts.php b/google/smarty/core/core.process_cached_inserts.php new file mode 100755 index 0000000..0e368fd --- /dev/null +++ b/google/smarty/core/core.process_cached_inserts.php @@ -0,0 +1,71 @@ +_smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis', + $params['results'], $match); + list($cached_inserts, $insert_args) = $match; + + for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) { + if ($smarty->debugging) { + $_params = array(); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); + $debug_start_time = smarty_core_get_microtime($_params, $smarty); + } + + $args = unserialize($insert_args[$i]); + $name = $args['name']; + + if (isset($args['script'])) { + $_params = array('resource_name' => $smarty->_dequote($args['script'])); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php'); + if(!smarty_core_get_php_resource($_params, $smarty)) { + return false; + } + $resource_type = $_params['resource_type']; + $php_resource = $_params['php_resource']; + + + if ($resource_type == 'file') { + $smarty->_include($php_resource, true); + } else { + $smarty->_eval($php_resource); + } + } + + $function_name = $smarty->_plugins['insert'][$name][0]; + if (empty($args['assign'])) { + $replace = $function_name($args, $smarty); + } else { + $smarty->assign($args['assign'], $function_name($args, $smarty)); + $replace = ''; + } + + $params['results'] = str_replace($cached_inserts[$i], $replace, $params['results']); + if ($smarty->debugging) { + $_params = array(); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); + $smarty->_smarty_debug_info[] = array('type' => 'insert', + 'filename' => 'insert_'.$name, + 'depth' => $smarty->_inclusion_depth, + 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $debug_start_time); + } + } + + return $params['results']; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/core/core.process_compiled_include.php b/google/smarty/core/core.process_compiled_include.php new file mode 100755 index 0000000..3e1d4c1 --- /dev/null +++ b/google/smarty/core/core.process_compiled_include.php @@ -0,0 +1,32 @@ +_cache_including; + $smarty->_cache_including = true; + + $_return = $params['results']; + foreach ($smarty->_cache_serials as $_include_file_path=>$_cache_serial) { + $_return = preg_replace_callback('!(\{nocache\:('.$_cache_serial.')#(\d+)\})!s', + array(&$smarty, '_process_compiled_include_callback'), + $_return); + } + $smarty->_cache_including = $_cache_including; + return $_return; +} + +?> diff --git a/google/smarty/core/core.read_cache_file.php b/google/smarty/core/core.read_cache_file.php new file mode 100755 index 0000000..2ab4281 --- /dev/null +++ b/google/smarty/core/core.read_cache_file.php @@ -0,0 +1,111 @@ +force_compile) { + // force compile enabled, always regenerate + return false; + } + + if (isset($content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']])) { + list($params['results'], $smarty->_cache_info) = $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']]; + return true; + } + + if (!empty($smarty->cache_handler_func)) { + // use cache_handler function + call_user_func_array($smarty->cache_handler_func, + array('read', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], null)); + } else { + // use local cache file + $_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']); + $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id); + $params['results'] = $smarty->_read_file($_cache_file); + } + + if (empty($params['results'])) { + // nothing to parse (error?), regenerate cache + return false; + } + + $cache_split = explode("\n", $params['results'], 2); + $cache_header = $cache_split[0]; + + $_cache_info = unserialize($cache_header); + + if ($smarty->caching == 2 && isset ($_cache_info['expires'])){ + // caching by expiration time + if ($_cache_info['expires'] > -1 && (time() > $_cache_info['expires'])) { + // cache expired, regenerate + return false; + } + } else { + // caching by lifetime + if ($smarty->cache_lifetime > -1 && (time() - $_cache_info['timestamp'] > $smarty->cache_lifetime)) { + // cache expired, regenerate + return false; + } + } + + if ($smarty->compile_check) { + $_params = array('get_source' => false, 'quiet'=>true); + foreach (array_keys($_cache_info['template']) as $_template_dep) { + $_params['resource_name'] = $_template_dep; + if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) { + // template file has changed, regenerate cache + return false; + } + } + + if (isset($_cache_info['config'])) { + $_params = array('resource_base_path' => $smarty->config_dir, 'get_source' => false, 'quiet'=>true); + foreach (array_keys($_cache_info['config']) as $_config_dep) { + $_params['resource_name'] = $_config_dep; + if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) { + // config file has changed, regenerate cache + return false; + } + } + } + } + + foreach ($_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) { + if (empty($smarty->_cache_serials[$_include_file_path])) { + $smarty->_include($_include_file_path, true); + } + + if ($smarty->_cache_serials[$_include_file_path] != $_cache_serial) { + /* regenerate */ + return false; + } + } + $params['results'] = $cache_split[1]; + $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $_cache_info); + + $smarty->_cache_info = $_cache_info; + return true; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/core/core.rm_auto.php b/google/smarty/core/core.rm_auto.php new file mode 100755 index 0000000..b7cdaf8 --- /dev/null +++ b/google/smarty/core/core.rm_auto.php @@ -0,0 +1,71 @@ + $params['auto_base'], + 'level' => 0, + 'exp_time' => $params['exp_time'] + ); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php'); + $_res = smarty_core_rmdir($_params, $smarty); + } else { + $_tname = $smarty->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']); + + if(isset($params['auto_source'])) { + if (isset($params['extensions'])) { + $_res = false; + foreach ((array)$params['extensions'] as $_extension) + $_res |= $smarty->_unlink($_tname.$_extension, $params['exp_time']); + } else { + $_res = $smarty->_unlink($_tname, $params['exp_time']); + } + } elseif ($smarty->use_sub_dirs) { + $_params = array( + 'dirname' => $_tname, + 'level' => 1, + 'exp_time' => $params['exp_time'] + ); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php'); + $_res = smarty_core_rmdir($_params, $smarty); + } else { + // remove matching file names + $_handle = opendir($params['auto_base']); + $_res = true; + while (false !== ($_filename = readdir($_handle))) { + if($_filename == '.' || $_filename == '..') { + continue; + } elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) { + $_res &= (bool)$smarty->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']); + } + } + } + } + + return $_res; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/core/core.rmdir.php b/google/smarty/core/core.rmdir.php new file mode 100755 index 0000000..38df822 --- /dev/null +++ b/google/smarty/core/core.rmdir.php @@ -0,0 +1,55 @@ + keep root) + * WARNING: no tests, it will try to remove what you tell it! + * + * @param string $dirname + * @param integer $level + * @param integer $exp_time + * @return boolean + */ + +// $dirname, $level = 1, $exp_time = null + +function smarty_core_rmdir($params, &$smarty) +{ + if(!isset($params['level'])) { $params['level'] = 1; } + if(!isset($params['exp_time'])) { $params['exp_time'] = null; } + + if($_handle = @opendir($params['dirname'])) { + + while (false !== ($_entry = readdir($_handle))) { + if ($_entry != '.' && $_entry != '..') { + if (@is_dir($params['dirname'] . DIRECTORY_SEPARATOR . $_entry)) { + $_params = array( + 'dirname' => $params['dirname'] . DIRECTORY_SEPARATOR . $_entry, + 'level' => $params['level'] + 1, + 'exp_time' => $params['exp_time'] + ); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php'); + smarty_core_rmdir($_params, $smarty); + } + else { + $smarty->_unlink($params['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params['exp_time']); + } + } + } + closedir($_handle); + } + + if ($params['level']) { + return @rmdir($params['dirname']); + } + return (bool)$_handle; + +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/core/core.run_insert_handler.php b/google/smarty/core/core.run_insert_handler.php new file mode 100755 index 0000000..aa391ab --- /dev/null +++ b/google/smarty/core/core.run_insert_handler.php @@ -0,0 +1,71 @@ +debugging) { + $_params = array(); + $_debug_start_time = smarty_core_get_microtime($_params, $smarty); + } + + if ($smarty->caching) { + $_arg_string = serialize($params['args']); + $_name = $params['args']['name']; + if (!isset($smarty->_cache_info['insert_tags'][$_name])) { + $smarty->_cache_info['insert_tags'][$_name] = array('insert', + $_name, + $smarty->_plugins['insert'][$_name][1], + $smarty->_plugins['insert'][$_name][2], + !empty($params['args']['script']) ? true : false); + } + return $smarty->_smarty_md5."{insert_cache $_arg_string}".$smarty->_smarty_md5; + } else { + if (isset($params['args']['script'])) { + $_params = array('resource_name' => $smarty->_dequote($params['args']['script'])); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php'); + if(!smarty_core_get_php_resource($_params, $smarty)) { + return false; + } + + if ($_params['resource_type'] == 'file') { + $smarty->_include($_params['php_resource'], true); + } else { + $smarty->_eval($_params['php_resource']); + } + unset($params['args']['script']); + } + + $_funcname = $smarty->_plugins['insert'][$params['args']['name']][0]; + $_content = $_funcname($params['args'], $smarty); + if ($smarty->debugging) { + $_params = array(); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); + $smarty->_smarty_debug_info[] = array('type' => 'insert', + 'filename' => 'insert_'.$params['args']['name'], + 'depth' => $smarty->_inclusion_depth, + 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time); + } + + if (!empty($params['args']["assign"])) { + $smarty->assign($params['args']["assign"], $_content); + } else { + return $_content; + } + } +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/core/core.smarty_include_php.php b/google/smarty/core/core.smarty_include_php.php new file mode 100755 index 0000000..4b31648 --- /dev/null +++ b/google/smarty/core/core.smarty_include_php.php @@ -0,0 +1,50 @@ + $params['smarty_file']); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php'); + smarty_core_get_php_resource($_params, $smarty); + $_smarty_resource_type = $_params['resource_type']; + $_smarty_php_resource = $_params['php_resource']; + + if (!empty($params['smarty_assign'])) { + ob_start(); + if ($_smarty_resource_type == 'file') { + $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']); + } else { + $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']); + } + $smarty->assign($params['smarty_assign'], ob_get_contents()); + ob_end_clean(); + } else { + if ($_smarty_resource_type == 'file') { + $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']); + } else { + $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']); + } + } +} + + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/core/core.write_cache_file.php b/google/smarty/core/core.write_cache_file.php new file mode 100755 index 0000000..7429ad9 --- /dev/null +++ b/google/smarty/core/core.write_cache_file.php @@ -0,0 +1,73 @@ +_cache_info['timestamp'] = time(); + if ($smarty->cache_lifetime > -1){ + // expiration set + $smarty->_cache_info['expires'] = $smarty->_cache_info['timestamp'] + $smarty->cache_lifetime; + } else { + // cache will never expire + $smarty->_cache_info['expires'] = -1; + } + + // collapse {nocache...}-tags + $params['results'] = preg_replace('!((\{nocache\:([0-9a-f]{32})#(\d+)\})' + .'.*' + .'{/nocache\:\\3#\\4\})!Us' + ,'\\2' + ,$params['results']); + $smarty->_cache_info['cache_serials'] = $smarty->_cache_serials; + + // prepend the cache header info into cache file + $params['results'] = serialize($smarty->_cache_info)."\n".$params['results']; + + if (!empty($smarty->cache_handler_func)) { + // use cache_handler function + call_user_func_array($smarty->cache_handler_func, + array('write', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], null)); + } else { + // use local cache file + + if(!@is_writable($smarty->cache_dir)) { + // cache_dir not writable, see if it exists + if(!@is_dir($smarty->cache_dir)) { + $smarty->trigger_error('the $cache_dir \'' . $smarty->cache_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); + return false; + } + $smarty->trigger_error('unable to write to $cache_dir \'' . realpath($smarty->cache_dir) . '\'. Be sure $cache_dir is writable by the web server user.', E_USER_ERROR); + return false; + } + + $_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']); + $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id); + $_params = array('filename' => $_cache_file, 'contents' => $params['results'], 'create_dirs' => true); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php'); + smarty_core_write_file($_params, $smarty); + return true; + } +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/core/core.write_compiled_include.php b/google/smarty/core/core.write_compiled_include.php new file mode 100755 index 0000000..9c6a491 --- /dev/null +++ b/google/smarty/core/core.write_compiled_include.php @@ -0,0 +1,59 @@ +caching\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\';\}'; + $_tag_end = 'if \(\$this->caching\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\';\}'; + + preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us', + $params['compiled_content'], $_match_source, PREG_SET_ORDER); + + // no nocache-parts found: done + if (count($_match_source)==0) return; + + // convert the matched php-code to functions + $_include_compiled = "_cache_serials[$_compile_path] = $params['cache_serial']; + $_include_compiled .= "\$this->_cache_serials['".$_compile_path."'] = '".$params['cache_serial']."';\n\n?>"; + + $_include_compiled .= $params['plugins_code']; + $_include_compiled .= "\n"; + + $_params = array('filename' => $_compile_path, + 'contents' => $_include_compiled, 'create_dirs' => true); + + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php'); + smarty_core_write_file($_params, $smarty); + return true; +} + + +?> diff --git a/google/smarty/core/core.write_compiled_resource.php b/google/smarty/core/core.write_compiled_resource.php new file mode 100755 index 0000000..c701448 --- /dev/null +++ b/google/smarty/core/core.write_compiled_resource.php @@ -0,0 +1,36 @@ +compile_dir)) { + // compile_dir not writable, see if it exists + if(!@is_dir($smarty->compile_dir)) { + $smarty->trigger_error('the $compile_dir \'' . $smarty->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); + return false; + } + $smarty->trigger_error('unable to write to $compile_dir \'' . realpath($smarty->compile_dir) . '\'. Be sure $compile_dir is writable by the web server user.', E_USER_ERROR); + return false; + } + + $_params = array('filename' => $params['compile_path'], 'timestamp'=>$params['resource_timestamp'], 'contents' => $params['compiled_content'], 'create_dirs' => true); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php'); + smarty_core_write_file($_params, $smarty); + return true; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/core/core.write_file.php b/google/smarty/core/core.write_file.php new file mode 100755 index 0000000..b4fa92e --- /dev/null +++ b/google/smarty/core/core.write_file.php @@ -0,0 +1,51 @@ + $_dirname); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.create_dir_structure.php'); + smarty_core_create_dir_structure($_params, $smarty); + } + + // write to tmp file, then rename it to avoid + // file locking race condition + $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid(''); + + if (!($fd = @fopen($_tmp_file, 'w'))) { + $smarty->trigger_error("problem writing temporary file '$_tmp_file'"); + return false; + } + + fwrite($fd, $params['contents']); + if (isset($params['timestamp'])) { + touch($_tmp_file, $params['timestamp']); + } + fclose($fd); + if(file_exists($params['filename'])) { + @unlink($params['filename']); + } + @rename($_tmp_file, $params['filename']); + @chmod($params['filename'], $smarty->_file_perms); + + return true; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/debug.tpl b/google/smarty/debug.tpl new file mode 100755 index 0000000..01265fb --- /dev/null +++ b/google/smarty/debug.tpl @@ -0,0 +1,64 @@ +{* Smarty *} + +{* debug.tpl, last updated version 2.0.1 *} + +{assign_debug_info} + +{if isset($_smarty_debug_output) and $_smarty_debug_output eq "html"} + + + + {section name=templates loop=$_debug_tpls} + + {sectionelse} + + {/section} + + {section name=vars loop=$_debug_keys} + + {sectionelse} + + {/section} + + {section name=config_vars loop=$_debug_config_keys} + + {sectionelse} + + {/section} +
    Smarty Debug Console
    included templates & config files (load time in seconds):
    {section name=indent loop=$_debug_tpls[templates].depth}   {/section}{$_debug_tpls[templates].filename|escape:html}{if isset($_debug_tpls[templates].exec_time)} ({$_debug_tpls[templates].exec_time|string_format:"%.5f"}){if %templates.index% eq 0} (total){/if}{/if}
    no templates included
    assigned template variables:
    {ldelim}${$_debug_keys[vars]}{rdelim}{$_debug_vals[vars]|@debug_print_var}
    no template variables assigned
    assigned config file variables (outer template scope):
    {ldelim}#{$_debug_config_keys[config_vars]}#{rdelim}{$_debug_config_vals[config_vars]|@debug_print_var}
    no config vars assigned
    + +{else} + +{/if} diff --git a/google/smarty/plugins/block.textformat.php b/google/smarty/plugins/block.textformat.php new file mode 100755 index 0000000..760b313 --- /dev/null +++ b/google/smarty/plugins/block.textformat.php @@ -0,0 +1,105 @@ + + * Name: textformat
    + * Purpose: format text a certain way with preset styles + * or custom wrap/indent settings
    + * @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat} + * (Smarty online manual) + * @param array + *
    + * Params:   style: string (email)
    + *           indent: integer (0)
    + *           wrap: integer (80)
    + *           wrap_char string ("\n")
    + *           indent_char: string (" ")
    + *           wrap_boundary: boolean (true)
    + * 
    + * @param string contents of the block + * @param Smarty clever simulation of a method + * @return string string $content re-formatted + */ +function smarty_block_textformat($params, $content, &$smarty) +{ + if (is_null($content)) { + return; + } + + $style = null; + $indent = 0; + $indent_first = 0; + $indent_char = ' '; + $wrap = 80; + $wrap_char = "\n"; + $wrap_cut = false; + $assign = null; + + foreach ($params as $_key => $_val) { + switch ($_key) { + case 'style': + case 'indent_char': + case 'wrap_char': + case 'assign': + $$_key = (string)$_val; + break; + + case 'indent': + case 'indent_first': + case 'wrap': + $$_key = (int)$_val; + break; + + case 'wrap_cut': + $$_key = (bool)$_val; + break; + + default: + $smarty->trigger_error("textformat: unknown attribute '$_key'"); + } + } + + if ($style == 'email') { + $wrap = 72; + } + + // split into paragraphs + $paragraphs = preg_split('![\r\n][\r\n]!',$content); + $output = ''; + + foreach ($paragraphs as $paragraph) { + if ($paragraph == '') { + continue; + } + // convert mult. spaces & special chars to single space + $paragraph = preg_replace(array('!\s+!','!(^\s+)|(\s+$)!'),array(' ',''),$paragraph); + // indent first line + if($indent_first > 0) { + $paragraph = str_repeat($indent_char,$indent_first) . $paragraph; + } + // wordwrap sentences + $paragraph = wordwrap($paragraph, $wrap - $indent, $wrap_char, $wrap_cut); + // indent lines + if($indent > 0) { + $paragraph = preg_replace('!^!m',str_repeat($indent_char,$indent),$paragraph); + } + $output .= $paragraph . $wrap_char . $wrap_char; + } + + if ($assign) { + $smarty->assign($assign,$output); + } else { + return $output; + } +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/compiler.assign.php b/google/smarty/plugins/compiler.assign.php new file mode 100755 index 0000000..506083c --- /dev/null +++ b/google/smarty/plugins/compiler.assign.php @@ -0,0 +1,33 @@ + + * Name: assign
    + * Purpose: assign a value to a template variable + * @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign} + * (Smarty online manual) + * @param string containing var-attribute and value-attribute + * @param Smarty_Compiler + */ +function smarty_compiler_assign($tag_attrs, &$compiler) +{ + $_params = $compiler->_parse_attrs($tag_attrs); + + if (!isset($_params['var'])) { + $compiler->_syntax_error("assign: missing 'var' parameter", E_USER_WARNING); + return; + } + + if (!isset($_params['value'])) { + $compiler->_syntax_error("assign: missing 'value' parameter", E_USER_WARNING); + return; + } + + return "\$this->assign({$_params['var']}, {$_params['value']});"; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/function.assign_debug_info.php b/google/smarty/plugins/function.assign_debug_info.php new file mode 100755 index 0000000..c281ce8 --- /dev/null +++ b/google/smarty/plugins/function.assign_debug_info.php @@ -0,0 +1,39 @@ + + * Name: assign_debug_info
    + * Purpose: assign debug info to the template
    + * @param array unused in this plugin, this plugin uses {@link Smarty::$_config}, + * {@link Smarty::$_tpl_vars} and {@link Smarty::$_smarty_debug_info} + * @param Smarty + */ +function smarty_function_assign_debug_info($params, &$smarty) +{ + $assigned_vars = $smarty->_tpl_vars; + ksort($assigned_vars); + if (@is_array($smarty->_config[0])) { + $config_vars = $smarty->_config[0]; + ksort($config_vars); + $smarty->assign("_debug_config_keys", array_keys($config_vars)); + $smarty->assign("_debug_config_vals", array_values($config_vars)); + } + + $included_templates = $smarty->_smarty_debug_info; + + $smarty->assign("_debug_keys", array_keys($assigned_vars)); + $smarty->assign("_debug_vals", array_values($assigned_vars)); + + $smarty->assign("_debug_tpls", $included_templates); +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/function.config_load.php b/google/smarty/plugins/function.config_load.php new file mode 100755 index 0000000..f0b8edd --- /dev/null +++ b/google/smarty/plugins/function.config_load.php @@ -0,0 +1,126 @@ + + * Name: config_load
    + * Purpose: load config file vars + * @link http://smarty.php.net/manual/en/language.function.config.load.php {config_load} + * (Smarty online manual) + * @param array Format: + *
    + * array('file' => required config file name,
    + *       'section' => optional config file section to load
    + *       'scope' => local/parent/global
    + *       'global' => overrides scope, setting to parent if true)
    + * 
    + * @param Smarty + */ +function smarty_function_config_load($params, &$smarty) +{ + if ($smarty->debugging) { + $_params = array(); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); + $_debug_start_time = smarty_core_get_microtime($_params, $smarty); + } + + $_file = isset($params['file']) ? $smarty->_dequote($params['file']) : null; + $_section = isset($params['section']) ? $smarty->_dequote($params['section']) : null; + $_scope = isset($params['scope']) ? $smarty->_dequote($params['scope']) : 'global'; + $_global = isset($params['global']) ? $smarty->_dequote($params['global']) : false; + + if (!isset($_file) || strlen($_file) == 0) { + $smarty->trigger_error("missing 'file' attribute in config_load tag", E_USER_ERROR, __FILE__, __LINE__); + } + + if (isset($_scope)) { + if ($_scope != 'local' && + $_scope != 'parent' && + $_scope != 'global') { + $smarty->trigger_error("invalid 'scope' attribute value", E_USER_ERROR, __FILE__, __LINE__); + } + } else { + if ($_global) { + $_scope = 'parent'; + } else { + $_scope = 'local'; + } + } + + $_params = array('resource_name' => $_file, 'resource_base_path' => $smarty->config_dir); + $smarty->_parse_resource_name($_params); + $_file_path = $_params['resource_type'] . ':' . $_params['resource_name']; + if (isset($_section)) + $_compile_file = $smarty->_get_compile_path($_file_path.'|'.$_section); + else + $_compile_file = $smarty->_get_compile_path($_file_path); + + if($smarty->force_compile + || !file_exists($_compile_file) + || ($smarty->compile_check + && !$smarty->_is_compiled($_file_path, $_compile_file))) { + // compile config file + if(!is_object($smarty->_conf_obj)) { + require_once SMARTY_DIR . $smarty->config_class . '.class.php'; + $smarty->_conf_obj = new $smarty->config_class(); + $smarty->_conf_obj->overwrite = $smarty->config_overwrite; + $smarty->_conf_obj->booleanize = $smarty->config_booleanize; + $smarty->_conf_obj->read_hidden = $smarty->config_read_hidden; + $smarty->_conf_obj->fix_newlines = $smarty->config_fix_newlines; + } + $_params = array('resource_name' => $_file, 'resource_base_path' => $smarty->config_dir); + if (!$smarty->_fetch_resource_info($_params)) { + return; + } + $smarty->_conf_obj->set_file_contents($_file, $_params['source_content']); + $_config_vars = array_merge($smarty->_conf_obj->get($_file), + $smarty->_conf_obj->get($_file, $_section)); + if(function_exists('var_export')) { + $_output = ''; + } else { + $_output = ''\\\'', '\\'=>'\\\\')) . '\'); ?>'; + } + $_params = (array('compile_path' => $_compile_file, 'compiled_content' => $_output, 'resource_timestamp' => $_params['resource_timestamp'])); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_compiled_resource.php'); + smarty_core_write_compiled_resource($_params, $smarty); + } else { + include($_compile_file); + } + + if ($smarty->caching) { + $smarty->_cache_info['config'][$_file] = true; + } + + $smarty->_config[0]['vars'] = @array_merge($smarty->_config[0]['vars'], $_config_vars); + $smarty->_config[0]['files'][$_file] = true; + + if ($_scope == 'parent') { + $smarty->_config[1]['vars'] = @array_merge($smarty->_config[1]['vars'], $_config_vars); + $smarty->_config[1]['files'][$_file] = true; + } else if ($_scope == 'global') { + for ($i = 1, $for_max = count($smarty->_config); $i < $for_max; $i++) { + $smarty->_config[$i]['vars'] = @array_merge($smarty->_config[$i]['vars'], $_config_vars); + $smarty->_config[$i]['files'][$_file] = true; + } + } + + if ($smarty->debugging) { + $_params = array(); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); + $smarty->_smarty_debug_info[] = array('type' => 'config', + 'filename' => $_file.' ['.$_section.'] '.$_scope, + 'depth' => $smarty->_inclusion_depth, + 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time); + } + +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/function.counter.php b/google/smarty/plugins/function.counter.php new file mode 100755 index 0000000..cfe5dd8 --- /dev/null +++ b/google/smarty/plugins/function.counter.php @@ -0,0 +1,79 @@ + + * Name: counter
    + * Purpose: print out a counter value + * @link http://smarty.php.net/manual/en/language.function.counter.php {counter} + * (Smarty online manual) + * @param array parameters + * @param Smarty + * @return string|null + */ +function smarty_function_counter($params, &$smarty) +{ + static $counters = array(); + + $name = (isset($params['name'])) ? $params['name'] : 'default'; + if (!isset($counters[$name])) { + $counters[$name] = array( + 'start'=>1, + 'skip'=>1, + 'direction'=>'up', + 'count'=>1 + ); + } + $counter =& $counters[$name]; + + if (isset($params['start'])) { + $counter['start'] = $counter['count'] = (int)$params['start']; + } + + if (!empty($params['assign'])) { + $counter['assign'] = $params['assign']; + } + + if (isset($counter['assign'])) { + $smarty->assign($counter['assign'], $counter['count']); + } + + if (isset($params['print'])) { + $print = (bool)$params['print']; + } else { + $print = empty($counter['assign']); + } + + if ($print) { + $retval = $counter['count']; + } else { + $retval = null; + } + + if (isset($params['skip'])) { + $counter['skip'] = $params['skip']; + } + + if (isset($params['direction'])) { + $counter['direction'] = $params['direction']; + } + + if ($counter['direction'] == "down") + $counter['count'] -= $counter['skip']; + else + $counter['count'] += $counter['skip']; + + return $retval; + +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/function.cycle.php b/google/smarty/plugins/function.cycle.php new file mode 100755 index 0000000..1f4ec9e --- /dev/null +++ b/google/smarty/plugins/function.cycle.php @@ -0,0 +1,102 @@ + + * Name: cycle
    + * Date: May 3, 2002
    + * Purpose: cycle through given values
    + * Input: + * - name = name of cycle (optional) + * - values = comma separated list of values to cycle, + * or an array of values to cycle + * (this can be left out for subsequent calls) + * - reset = boolean - resets given var to true + * - print = boolean - print var or not. default is true + * - advance = boolean - whether or not to advance the cycle + * - delimiter = the value delimiter, default is "," + * - assign = boolean, assigns to template var instead of + * printed. + * + * Examples:
    + *
    + * {cycle values="#eeeeee,#d0d0d0d"}
    + * {cycle name=row values="one,two,three" reset=true}
    + * {cycle name=row}
    + * 
    + * @link http://smarty.php.net/manual/en/language.function.cycle.php {cycle} + * (Smarty online manual) + * @author Monte Ohrt + * @author credit to Mark Priatel + * @author credit to Gerard + * @author credit to Jason Sweat + * @version 1.3 + * @param array + * @param Smarty + * @return string|null + */ +function smarty_function_cycle($params, &$smarty) +{ + static $cycle_vars; + + $name = (empty($params['name'])) ? 'default' : $params['name']; + $print = (isset($params['print'])) ? (bool)$params['print'] : true; + $advance = (isset($params['advance'])) ? (bool)$params['advance'] : true; + $reset = (isset($params['reset'])) ? (bool)$params['reset'] : false; + + if (!in_array('values', array_keys($params))) { + if(!isset($cycle_vars[$name]['values'])) { + $smarty->trigger_error("cycle: missing 'values' parameter"); + return; + } + } else { + if(isset($cycle_vars[$name]['values']) + && $cycle_vars[$name]['values'] != $params['values'] ) { + $cycle_vars[$name]['index'] = 0; + } + $cycle_vars[$name]['values'] = $params['values']; + } + + $cycle_vars[$name]['delimiter'] = (isset($params['delimiter'])) ? $params['delimiter'] : ','; + + if(is_array($cycle_vars[$name]['values'])) { + $cycle_array = $cycle_vars[$name]['values']; + } else { + $cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']); + } + + if(!isset($cycle_vars[$name]['index']) || $reset ) { + $cycle_vars[$name]['index'] = 0; + } + + if (isset($params['assign'])) { + $print = false; + $smarty->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]); + } + + if($print) { + $retval = $cycle_array[$cycle_vars[$name]['index']]; + } else { + $retval = null; + } + + if($advance) { + if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) { + $cycle_vars[$name]['index'] = 0; + } else { + $cycle_vars[$name]['index']++; + } + } + + return $retval; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/function.debug.php b/google/smarty/plugins/function.debug.php new file mode 100755 index 0000000..2452d62 --- /dev/null +++ b/google/smarty/plugins/function.debug.php @@ -0,0 +1,35 @@ + + * Name: debug
    + * Date: July 1, 2002
    + * Purpose: popup debug window + * @link http://smarty.php.net/manual/en/language.function.debug.php {debug} + * (Smarty online manual) + * @author Monte Ohrt + * @version 1.0 + * @param array + * @param Smarty + * @return string output from {@link Smarty::_generate_debug_output()} + */ +function smarty_function_debug($params, &$smarty) +{ + if($params['output']) { + $smarty->assign('_smarty_debug_output',$params['output']); + } + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.display_debug_console.php'); + return smarty_core_display_debug_console(null, $smarty); +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/function.eval.php b/google/smarty/plugins/function.eval.php new file mode 100755 index 0000000..3a4b8b2 --- /dev/null +++ b/google/smarty/plugins/function.eval.php @@ -0,0 +1,48 @@ + + * Name: eval
    + * Purpose: evaluate a template variable as a template
    + * @link http://smarty.php.net/manual/en/language.function.eval.php {eval} + * (Smarty online manual) + * @param array + * @param Smarty + */ +function smarty_function_eval($params, &$smarty) +{ + + if (!isset($params['var'])) { + $smarty->trigger_error("eval: missing 'var' parameter"); + return; + } + + if($params['var'] == '') { + return; + } + + $smarty->_compile_source('evaluated template', $params['var'], $_var_compiled); + + ob_start(); + $smarty->_eval('?>' . $_var_compiled); + $_contents = ob_get_contents(); + ob_end_clean(); + + if (!empty($params['assign'])) { + $smarty->assign($params['assign'], $_contents); + } else { + return $_contents; + } +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/function.fetch.php b/google/smarty/plugins/function.fetch.php new file mode 100755 index 0000000..a3273a1 --- /dev/null +++ b/google/smarty/plugins/function.fetch.php @@ -0,0 +1,217 @@ + + * Name: fetch
    + * Purpose: fetch file, web or ftp data and display results + * @link http://smarty.php.net/manual/en/language.function.fetch.php {fetch} + * (Smarty online manual) + * @param array + * @param Smarty + * @return string|null if the assign parameter is passed, Smarty assigns the + * result to a template variable + */ +function smarty_function_fetch($params, &$smarty) +{ + if (empty($params['file'])) { + $smarty->_trigger_fatal_error("[plugin] parameter 'file' cannot be empty"); + return; + } + + if ($smarty->security && !preg_match('!^(http|ftp)://!i', $params['file'])) { + $_params = array('resource_type' => 'file', 'resource_name' => $params['file']); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.is_secure.php'); + if(!smarty_core_is_secure($_params, $smarty)) { + $smarty->_trigger_fatal_error('[plugin] (secure mode) fetch \'' . $params['file'] . '\' is not allowed'); + return; + } + + // fetch the file + if($fp = @fopen($params['file'],'r')) { + while(!feof($fp)) { + $content .= fgets ($fp,4096); + } + fclose($fp); + } else { + $smarty->_trigger_fatal_error('[plugin] fetch cannot read file \'' . $params['file'] . '\''); + return; + } + } else { + // not a local file + if(preg_match('!^http://!i',$params['file'])) { + // http fetch + if($uri_parts = parse_url($params['file'])) { + // set defaults + $host = $server_name = $uri_parts['host']; + $timeout = 30; + $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; + $agent = "Smarty Template Engine ".$smarty->_version; + $referer = ""; + $uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/'; + $uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : ''; + $_is_proxy = false; + if(empty($uri_parts['port'])) { + $port = 80; + } else { + $port = $uri_parts['port']; + } + if(empty($uri_parts['user'])) { + $user = ''; + } + // loop through parameters, setup headers + foreach($params as $param_key => $param_value) { + switch($param_key) { + case "file": + case "assign": + case "assign_headers": + break; + case "user": + if(!empty($param_value)) { + $user = $param_value; + } + break; + case "pass": + if(!empty($param_value)) { + $pass = $param_value; + } + break; + case "accept": + if(!empty($param_value)) { + $accept = $param_value; + } + break; + case "header": + if(!empty($param_value)) { + if(!preg_match('![\w\d-]+: .+!',$param_value)) { + $smarty->_trigger_fatal_error("[plugin] invalid header format '".$param_value."'"); + return; + } else { + $extra_headers[] = $param_value; + } + } + break; + case "proxy_host": + if(!empty($param_value)) { + $proxy_host = $param_value; + } + break; + case "proxy_port": + if(!preg_match('!\D!', $param_value)) { + $proxy_port = (int) $param_value; + } else { + $smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'"); + return; + } + break; + case "agent": + if(!empty($param_value)) { + $agent = $param_value; + } + break; + case "referer": + if(!empty($param_value)) { + $referer = $param_value; + } + break; + case "timeout": + if(!preg_match('!\D!', $param_value)) { + $timeout = (int) $param_value; + } else { + $smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'"); + return; + } + break; + default: + $smarty->_trigger_fatal_error("[plugin] unrecognized attribute '".$param_key."'"); + return; + } + } + if(!empty($proxy_host) && !empty($proxy_port)) { + $_is_proxy = true; + $fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout); + } else { + $fp = fsockopen($server_name,$port,$errno,$errstr,$timeout); + } + + if(!$fp) { + $smarty->_trigger_fatal_error("[plugin] unable to fetch: $errstr ($errno)"); + return; + } else { + if($_is_proxy) { + fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n"); + } else { + fputs($fp, "GET $uri HTTP/1.0\r\n"); + } + if(!empty($host)) { + fputs($fp, "Host: $host\r\n"); + } + if(!empty($accept)) { + fputs($fp, "Accept: $accept\r\n"); + } + if(!empty($agent)) { + fputs($fp, "User-Agent: $agent\r\n"); + } + if(!empty($referer)) { + fputs($fp, "Referer: $referer\r\n"); + } + if(isset($extra_headers) && is_array($extra_headers)) { + foreach($extra_headers as $curr_header) { + fputs($fp, $curr_header."\r\n"); + } + } + if(!empty($user) && !empty($pass)) { + fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n"); + } + + $content = ''; + fputs($fp, "\r\n"); + while(!feof($fp)) { + $content .= fgets($fp,4096); + } + fclose($fp); + $csplit = split("\r\n\r\n",$content,2); + + $content = $csplit[1]; + + if(!empty($params['assign_headers'])) { + $smarty->assign($params['assign_headers'],split("\r\n",$csplit[0])); + } + } + } else { + $smarty->_trigger_fatal_error("[plugin] unable to parse URL, check syntax"); + return; + } + } else { + // ftp fetch + if($fp = @fopen($params['file'],'r')) { + while(!feof($fp)) { + $content .= fgets ($fp,4096); + } + fclose($fp); + } else { + $smarty->_trigger_fatal_error('[plugin] fetch cannot read file \'' . $params['file'] .'\''); + return; + } + } + + } + + + if (!empty($params['assign'])) { + $smarty->assign($params['assign'],$content); + } else { + return $content; + } +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/function.html_checkboxes.php b/google/smarty/plugins/function.html_checkboxes.php new file mode 100755 index 0000000..6fd272a --- /dev/null +++ b/google/smarty/plugins/function.html_checkboxes.php @@ -0,0 +1,135 @@ + + * Type: function
    + * Name: html_checkboxes
    + * Date: 24.Feb.2003
    + * Purpose: Prints out a list of checkbox input types
    + * Input:
    + * - name (optional) - string default "checkbox" + * - values (required) - array + * - options (optional) - associative array + * - checked (optional) - array default not set + * - separator (optional) - ie
    or   + * - output (optional) - without this one the buttons don't have names + * Examples: + *
    + * {html_checkboxes values=$ids output=$names}
    + * {html_checkboxes values=$ids name='box' separator='
    ' output=$names} + * {html_checkboxes values=$ids checked=$checked separator='
    ' output=$names} + *
    + * @link http://smarty.php.net/manual/en/language.function.html.checkboxes.php {html_checkboxes} + * (Smarty online manual) + * @author Christopher Kvarme + * @author credits to Monte Ohrt + * @version 1.0 + * @param array + * @param Smarty + * @return string + * @uses smarty_function_escape_special_chars() + */ +function smarty_function_html_checkboxes($params, &$smarty) +{ + require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); + + $name = 'checkbox'; + $values = null; + $options = null; + $selected = null; + $separator = ''; + $labels = true; + $output = null; + + $extra = ''; + + foreach($params as $_key => $_val) { + switch($_key) { + case 'name': + case 'separator': + $$_key = $_val; + break; + + case 'labels': + $$_key = (bool)$_val; + break; + + case 'options': + $$_key = (array)$_val; + break; + + case 'values': + case 'output': + $$_key = array_values((array)$_val); + break; + + case 'checked': + case 'selected': + $selected = array_map('strval', array_values((array)$_val)); + break; + + case 'checkboxes': + $smarty->trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', E_USER_WARNING); + $options = (array)$_val; + break; + + default: + if(!is_array($_val)) { + $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; + } else { + $smarty->trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE); + } + break; + } + } + + if (!isset($options) && !isset($values)) + return ''; /* raise error here? */ + + settype($selected, 'array'); + $_html_result = ''; + + if (is_array($options)) { + + foreach ($options as $_key=>$_val) + $_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels); + + + } else { + foreach ($values as $_i=>$_key) { + $_val = isset($output[$_i]) ? $output[$_i] : ''; + $_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels); + } + + } + + return $_html_result; + +} + +function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels) { + $_output = ''; + if ($labels) $_output .= ''; + $_output .= $separator . "\n"; + + return $_output; +} + +?> diff --git a/google/smarty/plugins/function.html_image.php b/google/smarty/plugins/function.html_image.php new file mode 100755 index 0000000..2654b03 --- /dev/null +++ b/google/smarty/plugins/function.html_image.php @@ -0,0 +1,142 @@ + + * Name: html_image
    + * Date: Feb 24, 2003
    + * Purpose: format HTML tags for the image
    + * Input:
    + * - file = file (and path) of image (required) + * - border = border width (optional, default 0) + * - height = image height (optional, default actual height) + * - image =image width (optional, default actual width) + * - basedir = base directory for absolute paths, default + * is environment variable DOCUMENT_ROOT + * + * Examples: {html_image file="images/masthead.gif"} + * Output: + * @link http://smarty.php.net/manual/en/language.function.html.image.php {html_image} + * (Smarty online manual) + * @author Monte Ohrt + * @author credits to Duda - wrote first image function + * in repository, helped with lots of functionality + * @version 1.0 + * @param array + * @param Smarty + * @return string + * @uses smarty_function_escape_special_chars() + */ +function smarty_function_html_image($params, &$smarty) +{ + require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); + + $alt = ''; + $file = ''; + $border = 0; + $height = ''; + $width = ''; + $extra = ''; + $prefix = ''; + $suffix = ''; + $server_vars = ($smarty->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS']; + $basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : ''; + foreach($params as $_key => $_val) { + switch($_key) { + case 'file': + case 'border': + case 'height': + case 'width': + case 'dpi': + case 'basedir': + $$_key = $_val; + break; + + case 'alt': + if(!is_array($_val)) { + $$_key = smarty_function_escape_special_chars($_val); + } else { + $smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); + } + break; + + case 'link': + case 'href': + $prefix = ''; + $suffix = ''; + break; + + default: + if(!is_array($_val)) { + $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; + } else { + $smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); + } + break; + } + } + + if (empty($file)) { + $smarty->trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE); + return; + } + + if (substr($file,0,1) == '/') { + $_image_path = $basedir . $file; + } else { + $_image_path = $file; + } + + if(!isset($params['width']) || !isset($params['height'])) { + if ($smarty->security && + ($_params = array('resource_type' => 'file', 'resource_name' => $_image_path)) && + (require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.is_secure.php')) && + (!smarty_core_is_secure($_params, $smarty)) ) { + $smarty->trigger_error("html_image: (secure) '$_image_path' not in secure directory", E_USER_NOTICE); + + } elseif (!$_image_data = @getimagesize($_image_path)) { + if(!file_exists($_image_path)) { + $smarty->trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE); + return; + } else if(!is_readable($_image_path)) { + $smarty->trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE); + return; + } else { + $smarty->trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE); + return; + } + } + + if(!isset($params['width'])) { + $width = $_image_data[0]; + } + if(!isset($params['height'])) { + $height = $_image_data[1]; + } + + } + + if(isset($params['dpi'])) { + if(strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) { + $dpi_default = 72; + } else { + $dpi_default = 96; + } + $_resize = $dpi_default/$params['dpi']; + $width = round($width * $_resize); + $height = round($height * $_resize); + } + + return $prefix . ''.$alt.'' . $suffix; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/function.html_options.php b/google/smarty/plugins/function.html_options.php new file mode 100755 index 0000000..da5571c --- /dev/null +++ b/google/smarty/plugins/function.html_options.php @@ -0,0 +1,121 @@ + + * Name: html_options
    + * Input:
    + * - name (optional) - string default "select" + * - values (required if no options supplied) - array + * - options (required if no values supplied) - associative array + * - selected (optional) - string default not set + * - output (required if not options supplied) - array + * Purpose: Prints the list of ' . "\n"; + foreach ($values as $key => $value) { + $optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected); + } + $optgroup_html .= "\n"; + return $optgroup_html; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/function.html_radios.php b/google/smarty/plugins/function.html_radios.php new file mode 100755 index 0000000..f74688f --- /dev/null +++ b/google/smarty/plugins/function.html_radios.php @@ -0,0 +1,138 @@ + + * Type: function
    + * Name: html_radios
    + * Date: 24.Feb.2003
    + * Purpose: Prints out a list of radio input types
    + * Input:
    + * - name (optional) - string default "radio" + * - values (required) - array + * - options (optional) - associative array + * - checked (optional) - array default not set + * - separator (optional) - ie
    or   + * - output (optional) - without this one the buttons don't have names + * Examples: + *
    + * {html_radios values=$ids output=$names}
    + * {html_radios values=$ids name='box' separator='
    ' output=$names} + * {html_radios values=$ids checked=$checked separator='
    ' output=$names} + *
    + * @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios} + * (Smarty online manual) + * @author Christopher Kvarme + * @author credits to Monte Ohrt + * @version 1.0 + * @param array + * @param Smarty + * @return string + * @uses smarty_function_escape_special_chars() + */ +function smarty_function_html_radios($params, &$smarty) +{ + require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); + + $name = 'radio'; + $values = null; + $options = null; + $selected = null; + $separator = ''; + $labels = true; + $output = null; + $extra = ''; + + foreach($params as $_key => $_val) { + switch($_key) { + case 'name': + case 'separator': + $$_key = (string)$_val; + break; + + case 'checked': + case 'selected': + if(is_array($_val)) { + $smarty->trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING); + } else { + $selected = (string)$_val; + } + break; + + case 'labels': + $$_key = (bool)$_val; + break; + + case 'options': + $$_key = (array)$_val; + break; + + case 'values': + case 'output': + $$_key = array_values((array)$_val); + break; + + case 'radios': + $smarty->trigger_error('html_radios: the use of the "radios" attribute is deprecated, use "options" instead', E_USER_WARNING); + $options = (array)$_val; + break; + + + default: + if(!is_array($_val)) { + $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; + } else { + $smarty->trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE); + } + break; + } + } + + if (!isset($options) && !isset($values)) + return ''; /* raise error here? */ + + $_html_result = ''; + + if (isset($options) && is_array($options)) { + + foreach ((array)$options as $_key=>$_val) + $_html_result .= smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels); + + } else { + + foreach ((array)$values as $_i=>$_key) { + $_val = isset($output[$_i]) ? $output[$_i] : ''; + $_html_result .= smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels); + } + + } + + return $_html_result; + +} + +function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels) { + $_output = ''; + if ($labels) $_output .= ''; + $_output .= $separator . "\n"; + + return $_output; +} + +?> diff --git a/google/smarty/plugins/function.html_select_date.php b/google/smarty/plugins/function.html_select_date.php new file mode 100755 index 0000000..ac4f2a1 --- /dev/null +++ b/google/smarty/plugins/function.html_select_date.php @@ -0,0 +1,300 @@ + + * Name: html_select_date
    + * Purpose: Prints the dropdowns for date selection. + * + * ChangeLog:
    + * - 1.0 initial release + * - 1.1 added support for +/- N syntax for begin + * and end year values. (Monte) + * - 1.2 added support for yyyy-mm-dd syntax for + * time value. (Jan Rosier) + * - 1.3 added support for choosing format for + * month values (Gary Loescher) + * - 1.3.1 added support for choosing format for + * day values (Marcus Bointon) + * @link http://smarty.php.net/manual/en/language.function.html.select.date.php {html_select_date} + * (Smarty online manual) + * @version 1.3.1 + * @author Andrei Zmievski + * @param array + * @param Smarty + * @return string + */ +function smarty_function_html_select_date($params, &$smarty) +{ + require_once $smarty->_get_plugin_filepath('shared','make_timestamp'); + require_once $smarty->_get_plugin_filepath('function','html_options'); + /* Default values. */ + $prefix = "Date_"; + $start_year = strftime("%Y"); + $end_year = $start_year; + $display_days = true; + $display_months = true; + $display_years = true; + $month_format = "%B"; + /* Write months as numbers by default GL */ + $month_value_format = "%m"; + $day_format = "%02d"; + /* Write day values using this format MB */ + $day_value_format = "%d"; + $year_as_text = false; + /* Display years in reverse order? Ie. 2000,1999,.... */ + $reverse_years = false; + /* Should the select boxes be part of an array when returned from PHP? + e.g. setting it to "birthday", would create "birthday[Day]", + "birthday[Month]" & "birthday[Year]". Can be combined with prefix */ + $field_array = null; + /* tags. + If not set, uses default dropdown. */ + $day_size = null; + $month_size = null; + $year_size = null; + /* Unparsed attributes common to *ALL* the tags. + An example might be in the template: all_extra ='class ="foo"'. */ + $all_extra = null; + /* Separate attributes for the tags. */ + $day_extra = null; + $month_extra = null; + $year_extra = null; + /* Order in which to display the fields. + "D" -> day, "M" -> month, "Y" -> year. */ + $field_order = 'MDY'; + /* String printed between the different fields. */ + $field_separator = "\n"; + $time = time(); + $all_empty = null; + $day_empty = null; + $month_empty = null; + $year_empty = null; + + foreach ($params as $_key=>$_value) { + switch ($_key) { + case 'prefix': + case 'time': + case 'start_year': + case 'end_year': + case 'month_format': + case 'day_format': + case 'day_value_format': + case 'field_array': + case 'day_size': + case 'month_size': + case 'year_size': + case 'all_extra': + case 'day_extra': + case 'month_extra': + case 'year_extra': + case 'field_order': + case 'field_separator': + case 'month_value_format': + case 'month_empty': + case 'day_empty': + case 'year_empty': + $$_key = (string)$_value; + break; + + case 'all_empty': + $$_key = (string)$_value; + $day_empty = $month_empty = $year_empty = $all_empty; + break; + + case 'display_days': + case 'display_months': + case 'display_years': + case 'year_as_text': + case 'reverse_years': + $$_key = (bool)$_value; + break; + + default: + $smarty->trigger_error("[html_select_date] unknown parameter $_key", E_USER_WARNING); + + } + } + + // If $time is not in format yyyy-mm-dd + if (!preg_match('/^\d{0,4}-\d{0,2}-\d{0,2}$/', $time)) { + // then $time is empty or unix timestamp or mysql timestamp + // using smarty_make_timestamp to get an unix timestamp and + // strftime to make yyyy-mm-dd + $time = strftime('%Y-%m-%d', smarty_make_timestamp($time)); + } + // Now split this in pieces, which later can be used to set the select + $time = explode("-", $time); + + // make syntax "+N" or "-N" work with start_year and end_year + if (preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match)) { + if ($match[1] == '+') { + $end_year = strftime('%Y') + $match[2]; + } else { + $end_year = strftime('%Y') - $match[2]; + } + } + if (preg_match('!^(\+|\-)\s*(\d+)$!', $start_year, $match)) { + if ($match[1] == '+') { + $start_year = strftime('%Y') + $match[2]; + } else { + $start_year = strftime('%Y') - $match[2]; + } + } + + $field_order = strtoupper($field_order); + + $html_result = $month_result = $day_result = $year_result = ""; + + if ($display_months) { + $month_names = array(); + $month_values = array(); + if(isset($month_empty)) { + $month_names[''] = $month_empty; + $month_values[''] = ''; + } + for ($i = 1; $i <= 12; $i++) { + $month_names[$i] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000)); + $month_values[$i] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000)); + } + + $month_result .= ''; + } + + if ($display_days) { + $days = array(); + if (isset($day_empty)) { + $days[''] = $day_empty; + $day_values[''] = ''; + } + for ($i = 1; $i <= 31; $i++) { + $days[] = sprintf($day_format, $i); + $day_values[] = sprintf($day_value_format, $i); + } + + $day_result .= ''; + } + + if ($display_years) { + if (null !== $field_array){ + $year_name = $field_array . '[' . $prefix . 'Year]'; + } else { + $year_name = $prefix . 'Year'; + } + if ($year_as_text) { + $year_result .= ' $years, + 'values' => $yearvals, + 'selected' => $time[0], + 'print_result' => false), + $smarty); + $year_result .= ''; + } + } + + // Loop thru the field_order field + for ($i = 0; $i <= 2; $i++){ + $c = substr($field_order, $i, 1); + switch ($c){ + case 'D': + $html_result .= $day_result; + break; + + case 'M': + $html_result .= $month_result; + break; + + case 'Y': + $html_result .= $year_result; + break; + } + // Add the field seperator + if($i != 2) { + $html_result .= $field_separator; + } + } + + return $html_result; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/function.html_select_time.php b/google/smarty/plugins/function.html_select_time.php new file mode 100755 index 0000000..00cd1ae --- /dev/null +++ b/google/smarty/plugins/function.html_select_time.php @@ -0,0 +1,192 @@ + + * Name: html_select_time
    + * Purpose: Prints the dropdowns for time selection + * @link http://smarty.php.net/manual/en/language.function.html.select.time.php {html_select_time} + * (Smarty online manual) + * @param array + * @param Smarty + * @return string + * @uses smarty_make_timestamp() + */ +function smarty_function_html_select_time($params, &$smarty) +{ + require_once $smarty->_get_plugin_filepath('shared','make_timestamp'); + require_once $smarty->_get_plugin_filepath('function','html_options'); + /* Default values. */ + $prefix = "Time_"; + $time = time(); + $display_hours = true; + $display_minutes = true; + $display_seconds = true; + $display_meridian = true; + $use_24_hours = true; + $minute_interval = 1; + $second_interval = 1; + /* Should the select boxes be part of an array when returned from PHP? + e.g. setting it to "birthday", would create "birthday[Hour]", + "birthday[Minute]", "birthday[Seconds]" & "birthday[Meridian]". + Can be combined with prefix. */ + $field_array = null; + $all_extra = null; + $hour_extra = null; + $minute_extra = null; + $second_extra = null; + $meridian_extra = null; + + foreach ($params as $_key=>$_value) { + switch ($_key) { + case 'prefix': + case 'time': + case 'field_array': + case 'all_extra': + case 'hour_extra': + case 'minute_extra': + case 'second_extra': + case 'meridian_extra': + $$_key = (string)$_value; + break; + + case 'display_hours': + case 'display_minutes': + case 'display_seconds': + case 'display_meridian': + case 'use_24_hours': + $$_key = (bool)$_value; + break; + + case 'minute_interval': + case 'second_interval': + $$_key = (int)$_value; + break; + + default: + $smarty->trigger_error("[html_select_time] unknown parameter $_key", E_USER_WARNING); + } + } + + $time = smarty_make_timestamp($time); + + $html_result = ''; + + if ($display_hours) { + $hours = $use_24_hours ? range(0, 23) : range(1, 12); + $hour_fmt = $use_24_hours ? '%H' : '%I'; + for ($i = 0, $for_max = count($hours); $i < $for_max; $i++) + $hours[$i] = sprintf('%02d', $hours[$i]); + $html_result .= '\n"; + } + + if ($display_minutes) { + $all_minutes = range(0, 59); + for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i+= $minute_interval) + $minutes[] = sprintf('%02d', $all_minutes[$i]); + $selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval); + $html_result .= '\n"; + } + + if ($display_seconds) { + $all_seconds = range(0, 59); + for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i+= $second_interval) + $seconds[] = sprintf('%02d', $all_seconds[$i]); + $selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval); + $html_result .= '\n"; + } + + if ($display_meridian && !$use_24_hours) { + $html_result .= '\n"; + } + + return $html_result; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/function.html_table.php b/google/smarty/plugins/function.html_table.php new file mode 100755 index 0000000..c6693d8 --- /dev/null +++ b/google/smarty/plugins/function.html_table.php @@ -0,0 +1,136 @@ + + * Name: html_table
    + * Date: Feb 17, 2003
    + * Purpose: make an html table from an array of data
    + * Input:
    + * - loop = array to loop through + * - cols = number of columns + * - rows = number of rows + * - table_attr = table attributes + * - tr_attr = table row attributes (arrays are cycled) + * - td_attr = table cell attributes (arrays are cycled) + * - trailpad = value to pad trailing cells with + * - vdir = vertical direction (default: "down", means top-to-bottom) + * - hdir = horizontal direction (default: "right", means left-to-right) + * - inner = inner loop (default "cols": print $loop line by line, + * $loop will be printed column by column otherwise) + * + * + * Examples: + *
    + * {table loop=$data}
    + * {table loop=$data cols=4 tr_attr='"bgcolor=red"'}
    + * {table loop=$data cols=4 tr_attr=$colors}
    + * 
    + * @author Monte Ohrt + * @version 1.0 + * @link http://smarty.php.net/manual/en/language.function.html.table.php {html_table} + * (Smarty online manual) + * @param array + * @param Smarty + * @return string + */ +function smarty_function_html_table($params, &$smarty) +{ + $table_attr = 'border="1"'; + $tr_attr = ''; + $td_attr = ''; + $cols = 3; + $rows = 3; + $trailpad = ' '; + $vdir = 'down'; + $hdir = 'right'; + $inner = 'cols'; + + if (!isset($params['loop'])) { + $smarty->trigger_error("html_table: missing 'loop' parameter"); + return; + } + + foreach ($params as $_key=>$_value) { + switch ($_key) { + case 'loop': + $$_key = (array)$_value; + break; + + case 'cols': + case 'rows': + $$_key = (int)$_value; + break; + + case 'table_attr': + case 'trailpad': + case 'hdir': + case 'vdir': + $$_key = (string)$_value; + break; + + case 'tr_attr': + case 'td_attr': + $$_key = $_value; + break; + } + } + + $loop_count = count($loop); + if (empty($params['rows'])) { + /* no rows specified */ + $rows = ceil($loop_count/$cols); + } elseif (empty($params['cols'])) { + if (!empty($params['rows'])) { + /* no cols specified, but rows */ + $cols = ceil($loop_count/$rows); + } + } + + $output = "\n"; + + for ($r=0; $r<$rows; $r++) { + $output .= "\n"; + $rx = ($vdir == 'down') ? $r*$cols : ($rows-1-$r)*$cols; + + for ($c=0; $c<$cols; $c++) { + $x = ($hdir == 'right') ? $rx+$c : $rx+$cols-1-$c; + if ($inner!='cols') { + /* shuffle x to loop over rows*/ + $x = floor($x/$cols) + ($x%$cols)*$rows; + } + + if ($x<$loop_count) { + $output .= "" . $loop[$x] . "\n"; + } else { + $output .= "$trailpad\n"; + } + } + $output .= "\n"; + } + $output .= "
    \n"; + + return $output; +} + +function smarty_function_html_table_cycle($name, $var, $no) { + if(!is_array($var)) { + $ret = $var; + } else { + $ret = $var[$no % count($var)]; + } + + return ($ret) ? ' '.$ret : ''; +} + + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/function.mailto.php b/google/smarty/plugins/function.mailto.php new file mode 100755 index 0000000..92bb9d3 --- /dev/null +++ b/google/smarty/plugins/function.mailto.php @@ -0,0 +1,140 @@ + + * Name: mailto
    + * Date: May 21, 2002 + * Purpose: automate mailto address link creation, and optionally + * encode them.
    + * Input:
    + * - address = e-mail address + * - text = (optional) text to display, default is address + * - encode = (optional) can be one of: + * * none : no encoding (default) + * * javascript : encode with javascript + * * hex : encode with hexidecimal (no javascript) + * - cc = (optional) address(es) to carbon copy + * - bcc = (optional) address(es) to blind carbon copy + * - subject = (optional) e-mail subject + * - newsgroups = (optional) newsgroup(s) to post to + * - followupto = (optional) address(es) to follow up to + * - extra = (optional) extra tags for the href link + * + * Examples: + *
    + * {mailto address="me@domain.com"}
    + * {mailto address="me@domain.com" encode="javascript"}
    + * {mailto address="me@domain.com" encode="hex"}
    + * {mailto address="me@domain.com" subject="Hello to you!"}
    + * {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
    + * {mailto address="me@domain.com" extra='class="mailto"'}
    + * 
    + * @link http://smarty.php.net/manual/en/language.function.mailto.php {mailto} + * (Smarty online manual) + * @version 1.2 + * @author Monte Ohrt + * @author credits to Jason Sweat (added cc, bcc and subject functionality) + * @param array + * @param Smarty + * @return string + */ +function smarty_function_mailto($params, &$smarty) +{ + $extra = ''; + + if (empty($params['address'])) { + $smarty->trigger_error("mailto: missing 'address' parameter"); + return; + } else { + $address = $params['address']; + } + + $text = $address; + + // netscape and mozilla do not decode %40 (@) in BCC field (bug?) + // so, don't encode it. + $mail_parms = array(); + foreach ($params as $var=>$value) { + switch ($var) { + case 'cc': + case 'bcc': + case 'followupto': + if (!empty($value)) + $mail_parms[] = $var.'='.str_replace('%40','@',rawurlencode($value)); + break; + + case 'subject': + case 'newsgroups': + $mail_parms[] = $var.'='.rawurlencode($value); + break; + + case 'extra': + case 'text': + $$var = $value; + + default: + } + } + + $mail_parm_vals = ''; + for ($i=0; $itrigger_error("mailto: 'encode' parameter must be none, javascript or hex"); + return; + } + + if ($encode == 'javascript' ) { + $string = 'document.write(\''.$text.'\');'; + + $js_encode = ''; + for ($x=0; $x < strlen($string); $x++) { + $js_encode .= '%' . bin2hex($string[$x]); + } + + return ''; + + } elseif ($encode == 'hex') { + + preg_match('!^(.*)(\?.*)$!',$address,$match); + if(!empty($match[2])) { + $smarty->trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript."); + return; + } + for ($x=0; $x < strlen($address); $x++) { + if(preg_match('!\w!',$address[$x])) { + $address_encode .= '%' . bin2hex($address[$x]); + } else { + $address_encode .= $address[$x]; + } + } + for ($x=0; $x < strlen($text); $x++) { + $text_encode .= '&#x' . bin2hex($text[$x]).';'; + } + + return ''.$text_encode.''; + + } else { + // no encoding + return ''.$text.''; + + } + +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/function.math.php b/google/smarty/plugins/function.math.php new file mode 100755 index 0000000..c080d4d --- /dev/null +++ b/google/smarty/plugins/function.math.php @@ -0,0 +1,82 @@ + + * Name: math
    + * Purpose: handle math computations in template
    + * @link http://smarty.php.net/manual/en/language.function.math.php {math} + * (Smarty online manual) + * @param array + * @param Smarty + * @return string + */ +function smarty_function_math($params, &$smarty) +{ + // be sure equation parameter is present + if (empty($params['equation'])) { + $smarty->trigger_error("math: missing equation parameter"); + return; + } + + $equation = $params['equation']; + + // make sure parenthesis are balanced + if (substr_count($equation,"(") != substr_count($equation,")")) { + $smarty->trigger_error("math: unbalanced parenthesis"); + return; + } + + // match all vars in equation, make sure all are passed + preg_match_all("!\!(0x)([a-zA-Z][a-zA-Z0-9_]*)!",$equation, $match); + $allowed_funcs = array('int','abs','ceil','cos','exp','floor','log','log10', + 'max','min','pi','pow','rand','round','sin','sqrt','srand','tan'); + foreach($match[2] as $curr_var) { + if (!in_array($curr_var,array_keys($params)) && !in_array($curr_var, $allowed_funcs)) { + $smarty->trigger_error("math: parameter $curr_var not passed as argument"); + return; + } + } + + foreach($params as $key => $val) { + if ($key != "equation" && $key != "format" && $key != "assign") { + // make sure value is not empty + if (strlen($val)==0) { + $smarty->trigger_error("math: parameter $key is empty"); + return; + } + if (!is_numeric($val)) { + $smarty->trigger_error("math: parameter $key: is not numeric"); + return; + } + $equation = preg_replace("/\b$key\b/",$val, $equation); + } + } + + eval("\$smarty_math_result = ".$equation.";"); + + if (empty($params['format'])) { + if (empty($params['assign'])) { + return $smarty_math_result; + } else { + $smarty->assign($params['assign'],$smarty_math_result); + } + } else { + if (empty($params['assign'])){ + printf($params['format'],$smarty_math_result); + } else { + $smarty->assign($params['assign'],sprintf($params['format'],$smarty_math_result)); + } + } +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/function.popup.php b/google/smarty/plugins/function.popup.php new file mode 100755 index 0000000..90323ce --- /dev/null +++ b/google/smarty/plugins/function.popup.php @@ -0,0 +1,107 @@ + + * Name: popup
    + * Purpose: make text pop up in windows via overlib + * @link http://smarty.php.net/manual/en/language.function.popup.php {popup} + * (Smarty online manual) + * @param array + * @param Smarty + * @return string + */ +function smarty_function_popup($params, &$smarty) +{ + $append = ''; + foreach ($params as $_key=>$_value) { + switch ($_key) { + case 'text': + case 'trigger': + $$_key = (string)$_value; + break; + + case 'caption': + case 'closetext': + case 'status': + $append .= ',' . strtoupper($_key) . ",'" . str_replace("'","\'",$_value) . "'"; + break; + + case 'fgcolor': + case 'bgcolor': + case 'textcolor': + case 'capcolor': + case 'closecolor': + case 'textfont': + case 'captionfont': + case 'closefont': + case 'textsize': + case 'captionsize': + case 'closesize': + case 'width': + case 'height': + case 'border': + case 'offsetx': + case 'offsety': + case 'fgbackground': + case 'bgbackground': + case 'inarray': + case 'caparray': + case 'capicon': + case 'snapx': + case 'snapy': + case 'fixx': + case 'fixy': + case 'background': + case 'padx': + case 'pady': + case 'frame': + case 'timeout': + case 'delay': + case 'function': + $append .= ',' . strtoupper($_key) . ",'$_value'"; + break; + + case 'sticky': + case 'left': + case 'right': + case 'center': + case 'above': + case 'below': + case 'noclose': + case 'autostatus': + case 'autostatuscap': + case 'fullhtml': + case 'hauto': + case 'vauto': + if ($_value) $append .= ',' . strtoupper($_key); + break; + + default: + $smarty->trigger_error("[popup] unknown parameter $_key", E_USER_WARNING); + } + } + + if (empty($text) && !isset($inarray) && empty($function)) { + $smarty->trigger_error("overlib: attribute 'text' or 'inarray' or 'function' required"); + return false; + } + + if (empty($trigger)) { $trigger = "onmouseover"; } + + $retval = $trigger . '="return overlib(\''.preg_replace(array("!'!","![\r\n]!"),array("\'",'\r'),$text).'\''; + $retval .= $append . ');" onmouseout="nd();"'; + + return $retval; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/function.popup_init.php b/google/smarty/plugins/function.popup_init.php new file mode 100755 index 0000000..f62c33c --- /dev/null +++ b/google/smarty/plugins/function.popup_init.php @@ -0,0 +1,39 @@ + + * Name: popup_init
    + * Purpose: initialize overlib + * @link http://smarty.php.net/manual/en/language.function.popup.init.php {popup_init} + * (Smarty online manual) + * @param array + * @param Smarty + * @return string + */ +function smarty_function_popup_init($params, &$smarty) +{ + $zindex = 1000; + + if (!empty($params['zindex'])) { + $zindex = $params['zindex']; + } + + if (!empty($params['src'])) { + return '' . "\n" + . '' . "\n"; + } else { + $smarty->trigger_error("popup_init: missing src parameter"); + } +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/modifier.capitalize.php b/google/smarty/plugins/modifier.capitalize.php new file mode 100755 index 0000000..adf862b --- /dev/null +++ b/google/smarty/plugins/modifier.capitalize.php @@ -0,0 +1,25 @@ + + * Name: capitalize
    + * Purpose: capitalize words in the string + * @link http://smarty.php.net/manual/en/language.modifiers.php#LANGUAGE.MODIFIER.CAPITALIZE + * capitalize (Smarty online manual) + * @param string + * @return string + */ +function smarty_modifier_capitalize($string) +{ + return ucwords($string); +} + +?> diff --git a/google/smarty/plugins/modifier.cat.php b/google/smarty/plugins/modifier.cat.php new file mode 100755 index 0000000..f5dc3d6 --- /dev/null +++ b/google/smarty/plugins/modifier.cat.php @@ -0,0 +1,33 @@ + + * Name: cat
    + * Date: Feb 24, 2003 + * Purpose: catenate a value to a variable + * Input: string to catenate + * Example: {$var|cat:"foo"} + * @link http://smarty.php.net/manual/en/language.modifier.cat.php cat + * (Smarty online manual) + * @author Monte Ohrt + * @version 1.0 + * @param string + * @param string + * @return string + */ +function smarty_modifier_cat($string, $cat) +{ + return $string . $cat; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/modifier.count_characters.php b/google/smarty/plugins/modifier.count_characters.php new file mode 100755 index 0000000..49ce655 --- /dev/null +++ b/google/smarty/plugins/modifier.count_characters.php @@ -0,0 +1,31 @@ + + * Name: count_characteres
    + * Purpose: count the number of characters in a text + * @link http://smarty.php.net/manual/en/language.modifier.count.characters.php + * count_characters (Smarty online manual) + * @param string + * @param boolean include whitespace in the character count + * @return integer + */ +function smarty_modifier_count_characters($string, $include_spaces = false) +{ + if ($include_spaces) + return(strlen($string)); + + return preg_match_all("/[^\s]/",$string, $match); +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/modifier.count_paragraphs.php b/google/smarty/plugins/modifier.count_paragraphs.php new file mode 100755 index 0000000..6a9833c --- /dev/null +++ b/google/smarty/plugins/modifier.count_paragraphs.php @@ -0,0 +1,28 @@ + + * Name: count_paragraphs
    + * Purpose: count the number of paragraphs in a text + * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php + * count_paragraphs (Smarty online manual) + * @param string + * @return integer + */ +function smarty_modifier_count_paragraphs($string) +{ + // count \r or \n characters + return count(preg_split('/[\r\n]+/', $string)); +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/modifier.count_sentences.php b/google/smarty/plugins/modifier.count_sentences.php new file mode 100755 index 0000000..0c210f0 --- /dev/null +++ b/google/smarty/plugins/modifier.count_sentences.php @@ -0,0 +1,28 @@ + + * Name: count_sentences + * Purpose: count the number of sentences in a text + * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php + * count_sentences (Smarty online manual) + * @param string + * @return integer + */ +function smarty_modifier_count_sentences($string) +{ + // find periods with a word before but not after. + return preg_match_all('/[^\s]\.(?!\w)/', $string, $match); +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/modifier.count_words.php b/google/smarty/plugins/modifier.count_words.php new file mode 100755 index 0000000..42c8a74 --- /dev/null +++ b/google/smarty/plugins/modifier.count_words.php @@ -0,0 +1,32 @@ + + * Name: count_words
    + * Purpose: count the number of words in a text + * @link http://smarty.php.net/manual/en/language.modifier.count.words.php + * count_words (Smarty online manual) + * @param string + * @return integer + */ +function smarty_modifier_count_words($string) +{ + // split text by ' ',\r,\n,\f,\t + $split_array = preg_split('/\s+/',$string); + // count matches that contain alphanumerics + $word_count = preg_grep('/[a-zA-Z0-9\\x80-\\xff]/', $split_array); + + return count($word_count); +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/modifier.date_format.php b/google/smarty/plugins/modifier.date_format.php new file mode 100755 index 0000000..351a4b6 --- /dev/null +++ b/google/smarty/plugins/modifier.date_format.php @@ -0,0 +1,43 @@ +_get_plugin_filepath('shared','make_timestamp'); +/** + * Smarty date_format modifier plugin + * + * Type: modifier
    + * Name: date_format
    + * Purpose: format datestamps via strftime
    + * Input:
    + * - string: input date string + * - format: strftime format for output + * - default_date: default date if $string is empty + * @link http://smarty.php.net/manual/en/language.modifier.date.format.php + * date_format (Smarty online manual) + * @param string + * @param string + * @param string + * @return string|void + * @uses smarty_make_timestamp() + */ +function smarty_modifier_date_format($string, $format="%b %e, %Y", $default_date=null) +{ + if($string != '') { + return strftime($format, smarty_make_timestamp($string)); + } elseif (isset($default_date) && $default_date != '') { + return strftime($format, smarty_make_timestamp($default_date)); + } else { + return; + } +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/modifier.debug_print_var.php b/google/smarty/plugins/modifier.debug_print_var.php new file mode 100755 index 0000000..b9bb184 --- /dev/null +++ b/google/smarty/plugins/modifier.debug_print_var.php @@ -0,0 +1,56 @@ + + * Name: debug_print_var
    + * Purpose: formats variable contents for display in the console + * @link http://smarty.php.net/manual/en/language.modifier.debug.print.var.php + * debug_print_var (Smarty online manual) + * @param array|object + * @param integer + * @param integer + * @return string + */ +function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40) +{ + $_replace = array("\n"=>'\n', "\r"=>'\r', "\t"=>'\t'); + if (is_array($var)) { + $results = "Array (".count($var).")"; + foreach ($var as $curr_key => $curr_val) { + $return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length); + $results .= "
    ".str_repeat(' ', $depth*2)."".strtr($curr_key, $_replace)." => $return"; + } + } else if (is_object($var)) { + $object_vars = get_object_vars($var); + $results = "".get_class($var)." Object (".count($object_vars).")"; + foreach ($object_vars as $curr_key => $curr_val) { + $return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length); + $results .= "
    ".str_repeat(' ', $depth*2)."$curr_key => $return"; + } + } else if (is_resource($var)) { + $results = ''.(string)$var.''; + } else if (empty($var) && $var != "0") { + $results = 'empty'; + } else { + if (strlen($var) > $length ) { + $results = substr($var, 0, $length-3).'...'; + } else { + $results = $var; + } + $results = htmlspecialchars($results); + $results = strtr($results, $_replace); + } + return $results; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/modifier.default.php b/google/smarty/plugins/modifier.default.php new file mode 100755 index 0000000..8268e39 --- /dev/null +++ b/google/smarty/plugins/modifier.default.php @@ -0,0 +1,31 @@ + + * Name: default
    + * Purpose: designate default value for empty variables + * @link http://smarty.php.net/manual/en/language.modifier.default.php + * default (Smarty online manual) + * @param string + * @param string + * @return string + */ +function smarty_modifier_default($string, $default = '') +{ + if (!isset($string) || $string === '') + return $default; + else + return $string; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/modifier.escape.php b/google/smarty/plugins/modifier.escape.php new file mode 100755 index 0000000..b497955 --- /dev/null +++ b/google/smarty/plugins/modifier.escape.php @@ -0,0 +1,63 @@ + + * Name: escape
    + * Purpose: Escape the string according to escapement type + * @link http://smarty.php.net/manual/en/language.modifier.escape.php + * escape (Smarty online manual) + * @param string + * @param html|htmlall|url|quotes|hex|hexentity|javascript + * @return string + */ +function smarty_modifier_escape($string, $esc_type = 'html') +{ + switch ($esc_type) { + case 'html': + return htmlspecialchars($string, ENT_QUOTES); + + case 'htmlall': + return htmlentities($string, ENT_QUOTES); + + case 'url': + return urlencode($string); + + case 'quotes': + // escape unescaped single quotes + return preg_replace("%(?'\\\\',"'"=>"\\'",'"'=>'\\"',"\r"=>'\\r',"\n"=>'\\n')); + + default: + return $string; + } +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/modifier.indent.php b/google/smarty/plugins/modifier.indent.php new file mode 100755 index 0000000..1642bac --- /dev/null +++ b/google/smarty/plugins/modifier.indent.php @@ -0,0 +1,27 @@ + + * Name: indent
    + * Purpose: indent lines of text + * @link http://smarty.php.net/manual/en/language.modifier.indent.php + * indent (Smarty online manual) + * @param string + * @param integer + * @param string + * @return string + */ +function smarty_modifier_indent($string,$chars=4,$char=" ") +{ + return preg_replace('!^!m',str_repeat($char,$chars),$string); +} + +?> diff --git a/google/smarty/plugins/modifier.lower.php b/google/smarty/plugins/modifier.lower.php new file mode 100755 index 0000000..0b4d151 --- /dev/null +++ b/google/smarty/plugins/modifier.lower.php @@ -0,0 +1,25 @@ + + * Name: lower
    + * Purpose: convert string to lowercase + * @link http://smarty.php.net/manual/en/language.modifier.lower.php + * lower (Smarty online manual) + * @param string + * @return string + */ +function smarty_modifier_lower($string) +{ + return strtolower($string); +} + +?> diff --git a/google/smarty/plugins/modifier.nl2br.php b/google/smarty/plugins/modifier.nl2br.php new file mode 100755 index 0000000..72e2622 --- /dev/null +++ b/google/smarty/plugins/modifier.nl2br.php @@ -0,0 +1,36 @@ + + * Name: nl2br
    + * Date: Feb 26, 2003 + * Purpose: convert \r\n, \r or \n to <
    > + * Input:
    + * - contents = contents to replace + * - preceed_test = if true, includes preceeding break tags + * in replacement + * Example: {$text|nl2br} + * @link http://smarty.php.net/manual/en/language.modifier.nl2br.php + * nl2br (Smarty online manual) + * @version 1.0 + * @author Monte Ohrt + * @param string + * @return string + */ +function smarty_modifier_nl2br($string) +{ + return nl2br($string); +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/modifier.regex_replace.php b/google/smarty/plugins/modifier.regex_replace.php new file mode 100755 index 0000000..b9cc865 --- /dev/null +++ b/google/smarty/plugins/modifier.regex_replace.php @@ -0,0 +1,29 @@ + + * Name: regex_replace
    + * Purpose: regular epxression search/replace + * @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php + * regex_replace (Smarty online manual) + * @param string + * @param string|array + * @param string|array + * @return string + */ +function smarty_modifier_regex_replace($string, $search, $replace) +{ + return preg_replace($search, $replace, $string); +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/modifier.replace.php b/google/smarty/plugins/modifier.replace.php new file mode 100755 index 0000000..2a43515 --- /dev/null +++ b/google/smarty/plugins/modifier.replace.php @@ -0,0 +1,29 @@ + + * Name: replace
    + * Purpose: simple search/replace + * @link http://smarty.php.net/manual/en/language.modifier.replace.php + * replace (Smarty online manual) + * @param string + * @param string + * @param string + * @return string + */ +function smarty_modifier_replace($string, $search, $replace) +{ + return str_replace($search, $replace, $string); +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/modifier.spacify.php b/google/smarty/plugins/modifier.spacify.php new file mode 100755 index 0000000..dad057f --- /dev/null +++ b/google/smarty/plugins/modifier.spacify.php @@ -0,0 +1,29 @@ + + * Name: spacify
    + * Purpose: add spaces between characters in a string + * @link http://smarty.php.net/manual/en/language.modifier.spacify.php + * spacify (Smarty online manual) + * @param string + * @param string + * @return string + */ +function smarty_modifier_spacify($string, $spacify_char = ' ') +{ + return implode($spacify_char, + preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY)); +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/modifier.string_format.php b/google/smarty/plugins/modifier.string_format.php new file mode 100755 index 0000000..efd6215 --- /dev/null +++ b/google/smarty/plugins/modifier.string_format.php @@ -0,0 +1,28 @@ + + * Name: string_format
    + * Purpose: format strings via sprintf + * @link http://smarty.php.net/manual/en/language.modifier.string.format.php + * string_format (Smarty online manual) + * @param string + * @param string + * @return string + */ +function smarty_modifier_string_format($string, $format) +{ + return sprintf($format, $string); +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/modifier.strip.php b/google/smarty/plugins/modifier.strip.php new file mode 100755 index 0000000..738c640 --- /dev/null +++ b/google/smarty/plugins/modifier.strip.php @@ -0,0 +1,33 @@ + + * Name: strip
    + * Purpose: Replace all repeated spaces, newlines, tabs + * with a single space or supplied replacement string.
    + * Example: {$var|strip} {$var|strip:" "} + * Date: September 25th, 2002 + * @link http://smarty.php.net/manual/en/language.modifier.strip.php + * strip (Smarty online manual) + * @author Monte Ohrt + * @version 1.0 + * @param string + * @param string + * @return string + */ +function smarty_modifier_strip($text, $replace = ' ') +{ + return preg_replace('!\s+!', $replace, $text); +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/modifier.strip_tags.php b/google/smarty/plugins/modifier.strip_tags.php new file mode 100755 index 0000000..45f1ec1 --- /dev/null +++ b/google/smarty/plugins/modifier.strip_tags.php @@ -0,0 +1,31 @@ + + * Name: strip_tags
    + * Purpose: strip html tags from text + * @link http://smarty.php.net/manual/en/language.modifier.strip.tags.php + * strip_tags (Smarty online manual) + * @param string + * @param boolean + * @return string + */ +function smarty_modifier_strip_tags($string, $replace_with_space = true) +{ + if ($replace_with_space) + return preg_replace('!<[^>]*?>!', ' ', $string); + else + return strip_tags($string); +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/modifier.truncate.php b/google/smarty/plugins/modifier.truncate.php new file mode 100755 index 0000000..15a26ba --- /dev/null +++ b/google/smarty/plugins/modifier.truncate.php @@ -0,0 +1,43 @@ + + * Name: truncate
    + * Purpose: Truncate a string to a certain length if necessary, + * optionally splitting in the middle of a word, and + * appending the $etc string. + * @link http://smarty.php.net/manual/en/language.modifier.truncate.php + * truncate (Smarty online manual) + * @param string + * @param integer + * @param string + * @param boolean + * @return string + */ +function smarty_modifier_truncate($string, $length = 80, $etc = '...', + $break_words = false) +{ + if ($length == 0) + return ''; + + if (strlen($string) > $length) { + $length -= strlen($etc); + if (!$break_words) + $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1)); + + return substr($string, 0, $length).$etc; + } else + return $string; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/modifier.upper.php b/google/smarty/plugins/modifier.upper.php new file mode 100755 index 0000000..69960ae --- /dev/null +++ b/google/smarty/plugins/modifier.upper.php @@ -0,0 +1,25 @@ + + * Name: upper
    + * Purpose: convert string to uppercase + * @link http://smarty.php.net/manual/en/language.modifier.upper.php + * upper (Smarty online manual) + * @param string + * @return string + */ +function smarty_modifier_upper($string) +{ + return strtoupper($string); +} + +?> diff --git a/google/smarty/plugins/modifier.wordwrap.php b/google/smarty/plugins/modifier.wordwrap.php new file mode 100755 index 0000000..b9a9fe9 --- /dev/null +++ b/google/smarty/plugins/modifier.wordwrap.php @@ -0,0 +1,28 @@ + + * Name: wordwrap
    + * Purpose: wrap a string of text at a given length + * @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php + * wordwrap (Smarty online manual) + * @param string + * @param integer + * @param string + * @param boolean + * @return string + */ +function smarty_modifier_wordwrap($string,$length=80,$break="\n",$cut=false) +{ + return wordwrap($string,$length,$break,$cut); +} + +?> diff --git a/google/smarty/plugins/outputfilter.trimwhitespace.php b/google/smarty/plugins/outputfilter.trimwhitespace.php new file mode 100755 index 0000000..9979e85 --- /dev/null +++ b/google/smarty/plugins/outputfilter.trimwhitespace.php @@ -0,0 +1,75 @@ + + * Type: outputfilter
    + * Name: trimwhitespace
    + * Date: Jan 25, 2003
    + * Purpose: trim leading white space and blank lines from + * template source after it gets interpreted, cleaning + * up code and saving bandwidth. Does not affect + * <
    >
    and blocks.
    + * Install: Drop into the plugin directory, call + * $smarty->load_filter('output','trimwhitespace'); + * from application. + * @author Monte Ohrt + * @author Contributions from Lars Noschinski + * @version 1.3 + * @param string + * @param Smarty + */ +function smarty_outputfilter_trimwhitespace($source, &$smarty) +{ + // Pull out the script blocks + preg_match_all("!]+>.*?!is", $source, $match); + $_script_blocks = $match[0]; + $source = preg_replace("!]+>.*?!is", + '@@@SMARTY:TRIM:SCRIPT@@@', $source); + + // Pull out the pre blocks + preg_match_all("!
    .*?
    !is", $source, $match); + $_pre_blocks = $match[0]; + $source = preg_replace("!
    .*?
    !is", + '@@@SMARTY:TRIM:PRE@@@', $source); + + // Pull out the textarea blocks + preg_match_all("!]+>.*?!is", $source, $match); + $_textarea_blocks = $match[0]; + $source = preg_replace("!]+>.*?!is", + '@@@SMARTY:TRIM:TEXTAREA@@@', $source); + + // remove all leading spaces, tabs and carriage returns NOT + // preceeded by a php close tag. + $source = trim(preg_replace('/((?)\n)[\s]+/m', '\1', $source)); + + // replace script blocks + smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source); + + // replace pre blocks + smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks, $source); + + // replace textarea blocks + smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source); + + return $source; +} + +function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$subject) { + $_len = strlen($search_str); + $_pos = 0; + for ($_i=0, $_count=count($replace); $_i<$_count; $_i++) + if (($_pos=strpos($subject, $search_str, $_pos))!==false) + $subject = substr_replace($subject, $replace[$_i], $_pos, $_len); + else + break; + +} + +?> diff --git a/google/smarty/plugins/shared.escape_special_chars.php b/google/smarty/plugins/shared.escape_special_chars.php new file mode 100755 index 0000000..11404aa --- /dev/null +++ b/google/smarty/plugins/shared.escape_special_chars.php @@ -0,0 +1,31 @@ + + * Purpose: used by other smarty functions to escape + * special chars except for already escaped ones + * @param string + * @return string + */ +function smarty_function_escape_special_chars($string) +{ + if(!is_array($string)) { + $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); + $string = htmlspecialchars($string); + $string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string); + } + return $string; +} + +/* vim: set expandtab: */ + +?> diff --git a/google/smarty/plugins/shared.make_timestamp.php b/google/smarty/plugins/shared.make_timestamp.php new file mode 100755 index 0000000..2d05b23 --- /dev/null +++ b/google/smarty/plugins/shared.make_timestamp.php @@ -0,0 +1,44 @@ + + * Purpose: used by other smarty functions to make a timestamp + * from a string. + * @param string + * @return string + */ +function smarty_make_timestamp($string) +{ + if(empty($string)) { + $string = "now"; + } + $time = strtotime($string); + if (is_numeric($time) && $time != -1) + return $time; + + // is mysql timestamp format of YYYYMMDDHHMMSS? + if (preg_match('/^\d{14}$/', $string)) { + $time = mktime(substr($string,8,2),substr($string,10,2),substr($string,12,2), + substr($string,4,2),substr($string,6,2),substr($string,0,4)); + + return $time; + } + + // couldn't recognize it, try to return a time + $time = (int) $string; + if ($time > 0) + return $time; + else + return time(); +} + +/* vim: set expandtab: */ + +?> diff --git a/images/IC7000/IMAGE_020.jpg b/images/IC7000/IMAGE_020.jpg new file mode 100644 index 0000000..bad4a7d Binary files /dev/null and b/images/IC7000/IMAGE_020.jpg differ diff --git a/images/IC7000/IMAGE_020.php b/images/IC7000/IMAGE_020.php new file mode 100644 index 0000000..004dbaf --- /dev/null +++ b/images/IC7000/IMAGE_020.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/IC7000/IMAGE_228.jpg b/images/IC7000/IMAGE_228.jpg new file mode 100644 index 0000000..053b376 Binary files /dev/null and b/images/IC7000/IMAGE_228.jpg differ diff --git a/images/IC7000/IMAGE_230.jpg b/images/IC7000/IMAGE_230.jpg new file mode 100644 index 0000000..0ae2dcb Binary files /dev/null and b/images/IC7000/IMAGE_230.jpg differ diff --git a/images/IC7000/IMAGE_234.jpg b/images/IC7000/IMAGE_234.jpg new file mode 100644 index 0000000..1145ded Binary files /dev/null and b/images/IC7000/IMAGE_234.jpg differ diff --git a/images/IC7000/IMAGE_236.jpg b/images/IC7000/IMAGE_236.jpg new file mode 100644 index 0000000..7742f0e Binary files /dev/null and b/images/IC7000/IMAGE_236.jpg differ diff --git a/images/IC7000/IMAGE_237.jpg b/images/IC7000/IMAGE_237.jpg new file mode 100644 index 0000000..8ca4d4d Binary files /dev/null and b/images/IC7000/IMAGE_237.jpg differ diff --git a/images/IC7000/IMAGE_238.jpg b/images/IC7000/IMAGE_238.jpg new file mode 100644 index 0000000..42b3234 Binary files /dev/null and b/images/IC7000/IMAGE_238.jpg differ diff --git a/images/grnball.gif b/images/grnball.gif new file mode 100755 index 0000000..5f7740b Binary files /dev/null and b/images/grnball.gif differ diff --git a/images/help.gif b/images/help.gif new file mode 100755 index 0000000..4915678 Binary files /dev/null and b/images/help.gif differ diff --git a/images/html.gif b/images/html.gif new file mode 100755 index 0000000..21e8e85 Binary files /dev/null and b/images/html.gif differ diff --git a/images/html.php b/images/html.php new file mode 100644 index 0000000..f83d084 --- /dev/null +++ b/images/html.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/redball.gif b/images/redball.gif new file mode 100755 index 0000000..7005133 Binary files /dev/null and b/images/redball.gif differ diff --git a/images/size.sh b/images/size.sh new file mode 100755 index 0000000..2471ec3 --- /dev/null +++ b/images/size.sh @@ -0,0 +1,13 @@ +#! /bin/bash +convert='/usr/bin/convert' +composite='/usr/bin/composite' + +for file in original/* +do + temp=`basename $file` + $convert -scale '287>' $file resized/$temp + $convert -scale '210>' $file midsized/$temp + $convert -scale '120>' $file thumb/$temp + + echo $temp +done diff --git a/index.help.phtml b/index.help.phtml new file mode 100755 index 0000000..395006e --- /dev/null +++ b/index.help.phtml @@ -0,0 +1,74 @@ +get_id_from_name( $page, "bus_category", &$DB ); +$toolbox->set_catid( $catid ); +$catid=1; +//error_reporting(15); +?> + + + + +N8DNX and the Stutsmanville Repeater Complex + + + +get_menu_string(); +//echo ''; + $GLMmenu = new LayersMenu( 6, 7, 2, 20 ); + $GLMmenu->setMenuStructureString($string); + $GLMmenu->parseStructureForMenu('vermenu'); + $GLMmenu->newVerticalMenu('vermenu'); + $GLMmenu->printHeader(); +?> + + + + + + + + + + +HELLO!!! +
    + + + + + + "; + } + + /** + * text_box :Creates a input box for text with 35 as default size + * @param $name: string name of text box + * @param $value: string value of text box + * @param $$size = 35 : string size of text box + * + * @return void + * @access + **/ + function text_box($name, $value, $size = 35) + { + echo ""; + } + + /** + * form_footer :Closes up the form tag, and includes the submit button + * @param $name: string form action string + * @param $$suppress = 0: string Method of form + * @param $$cs : int colspan for td + * + * @return void + * @access + **/ + function form_footer($name, $suppress = 0, $cs) + { + echo ""; + } + + /* Graphics Libraries */ + + /** + * process_image :Main function for image processing + * NOTES: + * This function does the following: + * + * 1) places image into original folder + * + * 2) makes three images from original size and places them + * into the RESIZED, MIDSIZED, and THUMB folders + * @param $image: The variable of the image being post from the form + * @param $$image_name : The variable_name of the image being post + * + * @return string - Returns $image_name + * @access + **/ + function process_image ($image,$image_name) + { + /* LOOK for these as defined in the top of this page + $ITEM_ORIGINAL = "'600>' -quality 60"; + $ITEM_RESIZED = "'287>' -quality 60"; + $ITEM_MIDSIZED = "'210>' -quality 60"; + $ITEM_THUMB = "'120>' -quality 50"; + */ + if(!defined("ORIGINAL_PATH")) + { + html_error("this not defined original_path",1); + } + if(!defined("RESIZED_PATH")) + { + html_error("this not defined resized_path",1); + } + if(!defined("MIDSIZED_PATH")) + { + html_error("this not defined midsized_path",1); + } + if(!defined("THUMB_PATH")) + { + html_error("this not defined thumb_path",1); + } + $image_upload_array = img_upload($image,$image_name,ORIGINAL_PATH); + //img_resize($image_upload_array[1],ORIGINAL_PATH.$image_upload_array[0],ITEM_ORIGINAL); + img_resize($image_upload_array[1],RESIZED_PATH.$image_upload_array[0],ITEM_RESIZED); + img_resize($image_upload_array[1],MIDSIZED_PATH.$image_upload_array[0],ITEM_MIDSIZED); + img_resize($image_upload_array[1],THUMB_PATH.$image_upload_array[0],ITEM_THUMB); + $image_name = $image_upload_array[0]; + return($image_name); + } + + /** + * img_resize :Resizes an image based on a full scale jpeg or gif + * @param $image: path to image which needs to be resized + * @param $thumb: path where resized image will live + * @param $$size : using axis size of new image + * + * @return array $img_resize_array + * @access + **/ + function img_resize($path2image,$path2thumb,$size) + { + exec( "type convert", $output, $return ); + if( $return == 0 ) + { + $command = substr( $output[0],11);// + $pos = strpos($command,"convert"); + $Path2GraphicsTools = substr( $command, 0, $pos - 1 ); + } + else + { + $Path2GraphicsTools = "/usr/X11R6/bin"; + } + $imageName = basename($path2image); + $thumbName = basename($path2thumb); + + $Path2GraphicsTools = "/usr/X11R6/bin"; + + exec("$Path2GraphicsTools/convert -scale $size $path2image $path2thumb"); + + $img_resize_array = array("$imageName","$path2image","$thumbName","$path2thumb"); + return($img_resize_array); + } + + /** + * img_upload :Function moves the image to the destination directory + Checking to make sure that it does not have same named file in dicectory. + Image must be either jpg ,png or gif format file to be uploaded. + * @param $form_field: $form_field of image + * @param $img_name: $form_field of image with _name + * @param $$destination_path : path to store uploaded image + * + * @return array $img_upload_array + * @access + **/ + function img_upload($form_field,$img_name,$destination_path) + { + if (ereg("[!@#$%^&()+={};:\'\" ]",$img_name)) + { + $img_name = ereg_replace("[!@#$%^&()+={};:\'\" ]","-",$img_name); + } + + $size = getImageSize($form_field); + + if( $size[2] == 1 || $size[2] == 2 || $size[2] == 3 ) + { + $i = "0"; + $d = dir($destination_path); + $img_name_in_use = "FALSE"; + while($entry=$d->read()) + { + if ($entry == $img_name) + { + $img_name_in_use = "TRUE"; + } + ++$i; + } + $d->close(); + + if ($img_name_in_use == "TRUE") + { + $new_img_name = mktime().$img_name; + $new_img_location = $destination_path.'/'.$new_img_name; + + copy($form_field,$new_img_location); + + chmod($new_img_location, 0666); + + $img_upload_array = array("$new_img_name","$new_img_location"); + } + else + { + $new_img_name = $img_name; + $new_img_location = $destination_path.'/'.$new_img_name; + + copy($form_field,$new_img_location); + + chmod($new_img_location, 0666); + + $img_upload_array = array("$new_img_name","$new_img_location"); + } + } + else + { + echo '

    ' + .'The file you uploaded was of an incorect type, please only upload .gif,.png or .jpg files' + .'
    ' + .'

    ' + ."Hit your browser's back button to continue" + .'

    '; + $error[0] = "ERROR"; + return($error); + } + + return($img_upload_array); + } + + /** + * file_upload :Uploads a file same way as image_uploads does + * @param $form_field: $form_field of image + * @param $file_name: $form_field of image with _name + * @param $$destination_path : path to store uploaded image + * + * @return string $file_upload + * @access + **/ + function file_upload($form_field,$file_name,$destination_path) + { + if (ereg("[!@#$%^&()+={};:\'\" ]",$file_name)) + { + $file_name = ereg_replace("[!@#$%^&()+={};:\'\" ]","_",$file_name); + } + + $i = "0"; + $d = dir($destination_path); + $file_name_in_use = "FALSE"; + while($entry=$d->read()) + { + if ($entry == $file_name) + { + $file_name_in_use = "TRUE"; + } + ++$i; + } + $d->close(); + + if ($file_name_in_use == "TRUE") + { + $new_file_name = mktime().$file_name; + $new_file_location = $destination_path.'/'.$new_file_name; + + copy($form_field,$new_file_location); + + chmod($new_file_location, 0666); + + $file_upload = $new_file_name; + } + else + { + $new_file_name = $file_name; + $new_file_location = $destination_path.'/'.$new_file_name; + + copy($form_field,$new_file_location); + + chmod($new_file_location, 0666); + + $file_upload = $new_file_name; + } + return($file_upload); + } + + /* Misc. Functions */ + + /** + * http_strip :Strips the http:// part from start of string + * @param $&$string : $string + * + * @return string $stirng minus http:// in front + * @access + **/ + function http_strip(&$string) + { + $test_string = strtolower($string); + if(substr($test_string,0,7) == "http://") + { + $string = substr($string,7); + } + } + + /** + * footer : used for admin page footer to close out the top function + * + * @return void + * @access + **/ + function footer() + { + ?> + +

    +
    HELLO
    +sub_nav( $toolbox->catid ); +?> + + + + + +

    HELLO!

    + printMenu('vermenu'); ?> +
    +printFooter();?> + + + + + diff --git a/index.phtml b/index.phtml new file mode 100755 index 0000000..3ed248d --- /dev/null +++ b/index.phtml @@ -0,0 +1,93 @@ +meta_tags(); +$title = ( $catid == 1 ) ? 'N8DNX and the Stutsmanville Repeater Complex - ' : $toolbox->title(); +?> + + + + +<?php echo $title;?> - N8DNX and the Stutsmanville Repeater Complex + + + + + + + + + +
    + +
    + + + +
    +getStaffDetail(5,$id); + } + else + { + echo $toolbox->get_category(); + echo $Support->getStaff($catid); + } + } +elseif( $catid == 6 ) + { + require_once(BASE.'classes/class_photos.inc'); + $Photo =& new GLM_PHOTOS(); + echo $Photo->getPhotoCats(6); + } +elseif( $toolbox->is_sub_id( $catid, 6, $toolbox->DB ) ) + { + require_once(BASE.'classes/class_photos.inc'); + $Photo =& new GLM_PHOTOS(); + echo $Photo->getPhotos( $catid ); + } +else + { + echo $toolbox->get_page(); + } + ?> +
    + + +
    + + diff --git a/inside.phtml b/inside.phtml new file mode 100755 index 0000000..39c0648 --- /dev/null +++ b/inside.phtml @@ -0,0 +1,105 @@ +get_id_from_name( $page, "bus_category", &$DB ); +$toolbox->set_catid( $catid ); +?> + + + + +<?echo $toolbox->title();?>Mackinac State Historic Parks + + + + +get_menu_string(); + $GLMmenu = new LayersMenu( 6, 7, 2, 20 ); + $GLMmenu->setMenuStructureString($string); + $GLMmenu->parseStructureForMenu('hormenu'); + $GLMmenu->newHorizontalMenu('hormenu'); + $GLMmenu->printHeader(); +?> + + + + + + + +
    + + +printMenu('hormenu'); ?> + + + + + +
    +sub_nav( $toolbox->catid ); +?> + + + + +get_parks_page(); + require_once(BASE."classes/class_events.inc"); + $Events =& new GLM_EVENTS( $catid ); + $Events->get_events(); + } + elseif( $catid == 113 ) + { + echo $toolbox->get_parks_page(); + require_once(BASE."classes/class_books.inc"); + $Books =& new GLM_BOOKS( $catid ); + echo $Books->search_books(); + } + elseif( $thank == 1) + { + echo '

    Thank You

    '; + } + elseif( in_array( $catid, array(500,502,503,504) ) ) + { + echo $toolbox->get_page(1); + echo $toolbox->getPhotoCats(500); + } + else + { + echo $toolbox->get_page(); + } + + echo ''; +?> +
    +printFooter();?> + + +
    + + diff --git a/js/awstats_misc_tracker.js b/js/awstats_misc_tracker.js new file mode 100755 index 0000000..0ffd5b3 --- /dev/null +++ b/js/awstats_misc_tracker.js @@ -0,0 +1,161 @@ +// awstats_misc_tracker.js +//------------------------------------------------------------------- +// You can add this file onto some of your web pages (main home page can +// be enough) by adding the following HTML code to your page body: +// +// +// + +// +// * This must be added after the tag, not placed within the +// tags, or the resulting tracking tag will not be handled +// correctly by all browsers. Internet explorer will also not report +// screen height and width attributes until it begins to render the +// body. +// +// This allows AWStats to be enhanced with some miscellanous features: +// - Screen size detection (TRKscreen) +// - Browser size detection (TRKwinsize) +// - Screen color depth detection (TRKcdi) +// - Java enabled detection (TRKjava) +// - Macromedia Director plugin detection (TRKshk) +// - Macromedia Shockwave plugin detection (TRKfla) +// - Realplayer G2 plugin detection (TRKrp) +// - QuickTime plugin detection (TRKmov) +// - Mediaplayer plugin detection (TRKwma) +// - Acrobat PDF plugin detection (TRKpdf) +//------------------------------------------------------------------- + +// If you use pslogger.php to generate your log, you can change this line with +// var awstatsmisctrackerurl="pslogger.php?loc=/js/awstats_misc_tracker.js"; +var awstatsmisctrackerurl="/js/awstats_misc_tracker.js"; + +var TRKresult; +var TRKscreen, TRKwinsize, TRKcdi, TRKjava, TRKshk, TRKsvg, TRKfla; +var TRKrp, TRKmov, TRKwma, TRKpdf, TRKpdfver, TRKuserid, TRKsessionid; +var TRKnow, TRKbegin, TRKend; +var TRKnse, TRKn; + +function awstats_setCookie(TRKNameOfCookie, TRKvalue, TRKexpirehours) { + TRKExpireDate = new Date (); + TRKExpireDate.setTime(TRKExpireDate.getTime() + (TRKexpirehours * 3600 * 1000)); + document.cookie = TRKNameOfCookie + "=" + escape(TRKvalue) + "; path=/" + ((TRKexpirehours == null) ? "" : "; expires=" + TRKExpireDate.toGMTString()); +} + +//function awstats_runvbscript() { +// TRKresult = false; +// p=false; +// document.write('\n'); +// alert(p); +// if (TRKresult) return 'y'; +// else return 'n'; +//} + +function awstats_detectIE(TRKClassID) { + TRKresult = false; // !!! Adding var in front of TRKresult break detection !!! + document.write('\n on error resume next \n TRKresult = IsObject(CreateObject("' + TRKClassID + '")) \n \n'); + if (TRKresult) return 'y'; + else return 'n'; +} + +function awstats_detectNS(TRKClassID) { + TRKn = "n"; + if (TRKnse.indexOf(TRKClassID) != -1) if (navigator.mimeTypes[TRKClassID].enabledPlugin != null) TRKn = "y"; + return TRKn; +} + +function awstats_getCookie(TRKNameOfCookie){ + if (document.cookie.length > 0){ + TRKbegin = document.cookie.indexOf(TRKNameOfCookie+"="); + if (TRKbegin != -1) { + TRKbegin += TRKNameOfCookie.length+1; + TRKend = document.cookie.indexOf(";", TRKbegin); + if (TRKend == -1) TRKend = document.cookie.length; + return unescape(document.cookie.substring(TRKbegin, TRKend)); + } + return null; + } + return null; +} + +if (window.location.search == "" || window.location.search == "?") { + // If no query string + TRKnow = new Date(); + TRKscreen=screen.width+"x"+screen.height; + if (navigator.appName != "Netscape") { TRKcdi=screen.colorDepth; } + else {TRKcdi=screen.pixelDepth}; + TRKjava=navigator.javaEnabled(); + TRKuserid=awstats_getCookie("AWSUSER_ID"); + TRKsessionid=awstats_getCookie("AWSSESSION_ID"); + var TRKrandomnumber=Math.floor(Math.random()*10000); + if (TRKuserid == null || (TRKuserid=="")) { TRKuserid = "awsuser_id" + TRKnow.getTime() +"r"+ TRKrandomnumber; } + if (TRKsessionid == null || (TRKsessionid=="")) { TRKsessionid = "awssession_id" + TRKnow.getTime() +"r"+ TRKrandomnumber; } + awstats_setCookie("AWSUSER_ID", TRKuserid, 10000); + awstats_setCookie("AWSSESSION_ID", TRKsessionid, 1); + TRKuserid=""; TRKuserid=awstats_getCookie("AWSUSER_ID"); + TRKsessionid=""; TRKsessionid=awstats_getCookie("AWSSESSION_ID"); + + var TRKnav=navigator.appName.toLowerCase(); // "internet explorer" or "netscape" + var TRKagt=navigator.userAgent.toLowerCase(); // "msie...", "mozilla...", "firefox..." + //alert(TRKnav); alert(TRKagt); + + var TRKwin = ((TRKagt.indexOf("win")!=-1) || (TRKagt.indexOf("32bit")!=-1)); + var TRKmac = (TRKagt.indexOf("mac")!=-1); + + var TRKns = (TRKnav.indexOf("netscape") != -1); + var TRKopera= (TRKnav.indexOf("opera") != -1); + var TRKie = (TRKagt.indexOf("msie") != -1); + + // Detect the browser internal width and height + var TRKwinsize; + if (document.documentElement && document.documentElement.clientWidth) + TRKwinsize = document.documentElement.clientWidth + 'x' + document.documentElement.clientHeight; + else if (document.body && document.body.clientWidth) + TRKwinsize = document.body.clientWidth + 'x' + document.body.clientHeight; + else + TRKwinsize = window.innerWidth + 'x' + window.innerHeight; + + if (TRKie && TRKwin) { + TRKshk = awstats_detectIE("SWCtl.SWCtl.1"); + TRKsvg = awstats_detectIE("Adobe.SVGCtl"); + TRKfla = awstats_detectIE("ShockwaveFlash.ShockwaveFlash.1"); + TRKrp = awstats_detectIE("rmocx.RealPlayer G2 Control.1"); + TRKmov = awstats_detectIE("Quicktime.Quicktime"); + TRKwma = awstats_detectIE("wmplayer.ocx"); + TRKpdf = 'n'; TRKpdfver=''; + if (awstats_detectIE("PDF.PdfCtrl.1") == 'y') { TRKpdf = 'y'; TRKpdfver='4'; } // Acrobat 4 + if (awstats_detectIE('PDF.PdfCtrl.5') == 'y') { TRKpdf = 'y'; TRKpdfver='5'; } // Acrobat 5 + if (awstats_detectIE('PDF.PdfCtrl.6') == 'y') { TRKpdf = 'y'; TRKpdfver='6'; } // Acrobat 6 + if (awstats_detectIE('AcroPDF.PDF.1') == 'y') { TRKpdf = 'y'; TRKpdfver='7'; } // Acrobat 7 + } + if (TRKns || !TRKwin) { + TRKnse = ""; + for (var TRKi=0;TRKi') + } + +} diff --git a/menuimages/down-arrow.png b/menuimages/down-arrow.png new file mode 100755 index 0000000..f0fb47d Binary files /dev/null and b/menuimages/down-arrow.png differ diff --git a/menuimages/down-galaxy.png b/menuimages/down-galaxy.png new file mode 100755 index 0000000..8301a91 Binary files /dev/null and b/menuimages/down-galaxy.png differ diff --git a/menuimages/down-gnome.png b/menuimages/down-gnome.png new file mode 100755 index 0000000..7bc1103 Binary files /dev/null and b/menuimages/down-gnome.png differ diff --git a/menuimages/down-gtk2.png b/menuimages/down-gtk2.png new file mode 100755 index 0000000..f0fb47d Binary files /dev/null and b/menuimages/down-gtk2.png differ diff --git a/menuimages/down-keramik.png b/menuimages/down-keramik.png new file mode 100755 index 0000000..bbd433b Binary files /dev/null and b/menuimages/down-keramik.png differ diff --git a/menuimages/down-nautilus.png b/menuimages/down-nautilus.png new file mode 100755 index 0000000..e9286c9 Binary files /dev/null and b/menuimages/down-nautilus.png differ diff --git a/menuimages/forward-arrow.png b/menuimages/forward-arrow.png new file mode 100755 index 0000000..4f3189a Binary files /dev/null and b/menuimages/forward-arrow.png differ diff --git a/menuimages/forward-galaxy.png b/menuimages/forward-galaxy.png new file mode 100755 index 0000000..4f3189a Binary files /dev/null and b/menuimages/forward-galaxy.png differ diff --git a/menuimages/forward-gnome.png b/menuimages/forward-gnome.png new file mode 100755 index 0000000..12f80da Binary files /dev/null and b/menuimages/forward-gnome.png differ diff --git a/menuimages/forward-gtk2.png b/menuimages/forward-gtk2.png new file mode 100755 index 0000000..4f3189a Binary files /dev/null and b/menuimages/forward-gtk2.png differ diff --git a/menuimages/forward-keramik.png b/menuimages/forward-keramik.png new file mode 100755 index 0000000..8c53e10 Binary files /dev/null and b/menuimages/forward-keramik.png differ diff --git a/menuimages/forward-nautilus.png b/menuimages/forward-nautilus.png new file mode 100755 index 0000000..35995d1 Binary files /dev/null and b/menuimages/forward-nautilus.png differ diff --git a/menuimages/kde_tree_collapse.png b/menuimages/kde_tree_collapse.png new file mode 100755 index 0000000..02a1437 Binary files /dev/null and b/menuimages/kde_tree_collapse.png differ diff --git a/menuimages/kde_tree_collapse_corner.png b/menuimages/kde_tree_collapse_corner.png new file mode 100755 index 0000000..7d38f98 Binary files /dev/null and b/menuimages/kde_tree_collapse_corner.png differ diff --git a/menuimages/kde_tree_collapse_corner_first.png b/menuimages/kde_tree_collapse_corner_first.png new file mode 100755 index 0000000..3729fe7 Binary files /dev/null and b/menuimages/kde_tree_collapse_corner_first.png differ diff --git a/menuimages/kde_tree_collapse_first.png b/menuimages/kde_tree_collapse_first.png new file mode 100755 index 0000000..18cfff6 Binary files /dev/null and b/menuimages/kde_tree_collapse_first.png differ diff --git a/menuimages/kde_tree_corner.png b/menuimages/kde_tree_corner.png new file mode 100755 index 0000000..11b5240 Binary files /dev/null and b/menuimages/kde_tree_corner.png differ diff --git a/menuimages/kde_tree_expand.png b/menuimages/kde_tree_expand.png new file mode 100755 index 0000000..fb1a654 Binary files /dev/null and b/menuimages/kde_tree_expand.png differ diff --git a/menuimages/kde_tree_expand_corner.png b/menuimages/kde_tree_expand_corner.png new file mode 100755 index 0000000..35aded3 Binary files /dev/null and b/menuimages/kde_tree_expand_corner.png differ diff --git a/menuimages/kde_tree_expand_corner_first.png b/menuimages/kde_tree_expand_corner_first.png new file mode 100755 index 0000000..2ba2d86 Binary files /dev/null and b/menuimages/kde_tree_expand_corner_first.png differ diff --git a/menuimages/kde_tree_expand_first.png b/menuimages/kde_tree_expand_first.png new file mode 100755 index 0000000..c1f487a Binary files /dev/null and b/menuimages/kde_tree_expand_first.png differ diff --git a/menuimages/kde_tree_folder_closed.png b/menuimages/kde_tree_folder_closed.png new file mode 100755 index 0000000..2ef2bed Binary files /dev/null and b/menuimages/kde_tree_folder_closed.png differ diff --git a/menuimages/kde_tree_folder_open.png b/menuimages/kde_tree_folder_open.png new file mode 100755 index 0000000..50eea81 Binary files /dev/null and b/menuimages/kde_tree_folder_open.png differ diff --git a/menuimages/kde_tree_leaf.png b/menuimages/kde_tree_leaf.png new file mode 100755 index 0000000..b34fae5 Binary files /dev/null and b/menuimages/kde_tree_leaf.png differ diff --git a/menuimages/kde_tree_space.png b/menuimages/kde_tree_space.png new file mode 100755 index 0000000..fbdfa6a Binary files /dev/null and b/menuimages/kde_tree_space.png differ diff --git a/menuimages/kde_tree_split.png b/menuimages/kde_tree_split.png new file mode 100755 index 0000000..1f60f4e Binary files /dev/null and b/menuimages/kde_tree_split.png differ diff --git a/menuimages/kde_tree_split_first.png b/menuimages/kde_tree_split_first.png new file mode 100755 index 0000000..88c2eff Binary files /dev/null and b/menuimages/kde_tree_split_first.png differ diff --git a/menuimages/kde_tree_vertline.png b/menuimages/kde_tree_vertline.png new file mode 100755 index 0000000..34319c2 Binary files /dev/null and b/menuimages/kde_tree_vertline.png differ diff --git a/menuimages/nautilus_tree_collapse.png b/menuimages/nautilus_tree_collapse.png new file mode 100755 index 0000000..d10e051 Binary files /dev/null and b/menuimages/nautilus_tree_collapse.png differ diff --git a/menuimages/nautilus_tree_collapse_corner.png b/menuimages/nautilus_tree_collapse_corner.png new file mode 100755 index 0000000..d10e051 Binary files /dev/null and b/menuimages/nautilus_tree_collapse_corner.png differ diff --git a/menuimages/nautilus_tree_collapse_corner_first.png b/menuimages/nautilus_tree_collapse_corner_first.png new file mode 100755 index 0000000..d10e051 Binary files /dev/null and b/menuimages/nautilus_tree_collapse_corner_first.png differ diff --git a/menuimages/nautilus_tree_collapse_first.png b/menuimages/nautilus_tree_collapse_first.png new file mode 100755 index 0000000..d10e051 Binary files /dev/null and b/menuimages/nautilus_tree_collapse_first.png differ diff --git a/menuimages/nautilus_tree_corner.png b/menuimages/nautilus_tree_corner.png new file mode 100755 index 0000000..fbdfa6a Binary files /dev/null and b/menuimages/nautilus_tree_corner.png differ diff --git a/menuimages/nautilus_tree_expand.png b/menuimages/nautilus_tree_expand.png new file mode 100755 index 0000000..38dcfc0 Binary files /dev/null and b/menuimages/nautilus_tree_expand.png differ diff --git a/menuimages/nautilus_tree_expand_corner.png b/menuimages/nautilus_tree_expand_corner.png new file mode 100755 index 0000000..38dcfc0 Binary files /dev/null and b/menuimages/nautilus_tree_expand_corner.png differ diff --git a/menuimages/nautilus_tree_expand_corner_first.png b/menuimages/nautilus_tree_expand_corner_first.png new file mode 100755 index 0000000..38dcfc0 Binary files /dev/null and b/menuimages/nautilus_tree_expand_corner_first.png differ diff --git a/menuimages/nautilus_tree_expand_first.png b/menuimages/nautilus_tree_expand_first.png new file mode 100755 index 0000000..38dcfc0 Binary files /dev/null and b/menuimages/nautilus_tree_expand_first.png differ diff --git a/menuimages/nautilus_tree_folder_closed.png b/menuimages/nautilus_tree_folder_closed.png new file mode 100755 index 0000000..fbeb3a0 Binary files /dev/null and b/menuimages/nautilus_tree_folder_closed.png differ diff --git a/menuimages/nautilus_tree_folder_open.png b/menuimages/nautilus_tree_folder_open.png new file mode 100755 index 0000000..167770d Binary files /dev/null and b/menuimages/nautilus_tree_folder_open.png differ diff --git a/menuimages/nautilus_tree_leaf.png b/menuimages/nautilus_tree_leaf.png new file mode 100755 index 0000000..f865071 Binary files /dev/null and b/menuimages/nautilus_tree_leaf.png differ diff --git a/menuimages/nautilus_tree_space.png b/menuimages/nautilus_tree_space.png new file mode 100755 index 0000000..fbdfa6a Binary files /dev/null and b/menuimages/nautilus_tree_space.png differ diff --git a/menuimages/nautilus_tree_split.png b/menuimages/nautilus_tree_split.png new file mode 100755 index 0000000..fbdfa6a Binary files /dev/null and b/menuimages/nautilus_tree_split.png differ diff --git a/menuimages/nautilus_tree_split_first.png b/menuimages/nautilus_tree_split_first.png new file mode 100755 index 0000000..fbdfa6a Binary files /dev/null and b/menuimages/nautilus_tree_split_first.png differ diff --git a/menuimages/nautilus_tree_vertline.png b/menuimages/nautilus_tree_vertline.png new file mode 100755 index 0000000..fbdfa6a Binary files /dev/null and b/menuimages/nautilus_tree_vertline.png differ diff --git a/menuimages/transparent.png b/menuimages/transparent.png new file mode 100755 index 0000000..793f790 Binary files /dev/null and b/menuimages/transparent.png differ diff --git a/menuimages/tree_collapse.png b/menuimages/tree_collapse.png new file mode 100755 index 0000000..1c9be75 Binary files /dev/null and b/menuimages/tree_collapse.png differ diff --git a/menuimages/tree_collapse_corner.png b/menuimages/tree_collapse_corner.png new file mode 100755 index 0000000..b3328ad Binary files /dev/null and b/menuimages/tree_collapse_corner.png differ diff --git a/menuimages/tree_collapse_corner_first.png b/menuimages/tree_collapse_corner_first.png new file mode 100755 index 0000000..122b980 Binary files /dev/null and b/menuimages/tree_collapse_corner_first.png differ diff --git a/menuimages/tree_collapse_first.png b/menuimages/tree_collapse_first.png new file mode 100755 index 0000000..5c43876 Binary files /dev/null and b/menuimages/tree_collapse_first.png differ diff --git a/menuimages/tree_corner.png b/menuimages/tree_corner.png new file mode 100755 index 0000000..541c5b3 Binary files /dev/null and b/menuimages/tree_corner.png differ diff --git a/menuimages/tree_expand.png b/menuimages/tree_expand.png new file mode 100755 index 0000000..e94aecf Binary files /dev/null and b/menuimages/tree_expand.png differ diff --git a/menuimages/tree_expand_corner.png b/menuimages/tree_expand_corner.png new file mode 100755 index 0000000..4293f76 Binary files /dev/null and b/menuimages/tree_expand_corner.png differ diff --git a/menuimages/tree_expand_corner_first.png b/menuimages/tree_expand_corner_first.png new file mode 100755 index 0000000..5de11a6 Binary files /dev/null and b/menuimages/tree_expand_corner_first.png differ diff --git a/menuimages/tree_expand_first.png b/menuimages/tree_expand_first.png new file mode 100755 index 0000000..034b88e Binary files /dev/null and b/menuimages/tree_expand_first.png differ diff --git a/menuimages/tree_folder_closed.png b/menuimages/tree_folder_closed.png new file mode 100755 index 0000000..f1bfd01 Binary files /dev/null and b/menuimages/tree_folder_closed.png differ diff --git a/menuimages/tree_folder_open.png b/menuimages/tree_folder_open.png new file mode 100755 index 0000000..4190b96 Binary files /dev/null and b/menuimages/tree_folder_open.png differ diff --git a/menuimages/tree_leaf.png b/menuimages/tree_leaf.png new file mode 100755 index 0000000..6f999fb Binary files /dev/null and b/menuimages/tree_leaf.png differ diff --git a/menuimages/tree_space.png b/menuimages/tree_space.png new file mode 100755 index 0000000..fbdfa6a Binary files /dev/null and b/menuimages/tree_space.png differ diff --git a/menuimages/tree_split.png b/menuimages/tree_split.png new file mode 100755 index 0000000..1a49fab Binary files /dev/null and b/menuimages/tree_split.png differ diff --git a/menuimages/tree_split_first.png b/menuimages/tree_split_first.png new file mode 100755 index 0000000..e915d03 Binary files /dev/null and b/menuimages/tree_split_first.png differ diff --git a/menuimages/tree_vertline.png b/menuimages/tree_vertline.png new file mode 100755 index 0000000..261ff13 Binary files /dev/null and b/menuimages/tree_vertline.png differ diff --git a/menuimages/tri.gif b/menuimages/tri.gif new file mode 100755 index 0000000..bda1602 Binary files /dev/null and b/menuimages/tri.gif differ diff --git a/remoteSearch.inc b/remoteSearch.inc new file mode 100644 index 0000000..3e86c74 --- /dev/null +++ b/remoteSearch.inc @@ -0,0 +1,52 @@ + 'Index_1', + 'website' => $glmsThisSite, + 'query' => $_REQUEST['query'], + 'returnUrl' => $glmsPageURL, + 'start' => $glmsStart, + 'rows' => $glmsRows, + 'matchAll' => $_REQUEST['matchAll'] +); + +// Create curl instance - and set to return response +$glmsCurl = curl_init(); +curl_setopt($glmsCurl, CURLOPT_RETURNTRANSFER, TRUE); +curl_setopt($glmsCurl, CURLOPT_URL, $glmsUrl); +curl_setopt($glmsCurl, CURLOPT_POST, true); +curl_setopt($glmsCurl, CURLOPT_POSTFIELDS, $glmsRequest); + + $glmsResults = curl_exec($glmsCurl); +?> diff --git a/setup.phtml b/setup.phtml new file mode 100755 index 0000000..8c2fee7 --- /dev/null +++ b/setup.phtml @@ -0,0 +1,1813 @@ + 0 ) + $base_url = $HTTP_HOST.substr( dirname($SCRIPT_NAME), 0, -strlen($CALLED_FROM_DIR) ); + else + { + $script_name_dir = dirname($SCRIPT_NAME); + if( $script_name_dir == "/" ) + $script_name_dir = ""; + $base_url = $HTTP_HOST.$script_name_dir; + } + + $BASE_URL = "HTTP://".$base_url; + $BASE_SECURE_URL = "HTTPS://".$base_url; + + // Indicate that this file has been referenced + + $SITEINFO = TRUE; + + + /* + * + * Dynamic Configuration - Parameters that DO change based on location + * + */ + + switch( $GLM_SERVER_ID ) + { + + case "devsys.gaslightmedia.com": + error_reporting(E_ERROR); + ini_set("display_errors","1"); + // Use the $BASE_URL for secure URL on Devsys + $BASE_SECURE_URL = $BASE_URL; + define("CONN_STR","host=devsys dbname=n8dnx"); + define("OWNER_EMAIL", "cscott@gaslightmedia.com"); // site owner's email address + define("REPLY_TO", "info@n8dnx.org"); // the reply-to field for email's + break; + + case "ws1.gaslightmedia.com": + error_reporting(0); + ini_set("display_errors","0"); + $BASE_SECURE_URL = "HTTPS://".$base_url; + define("CONN_STR","host=ds4 dbname=n8dnx"); + define("OWNER_EMAIL", "cscott@gaslightmedia.com"); // site owner's email address + define("REPLY_TO", "info@n8dnx.org"); // the reply-to field for email's + break; + + default: // There should be no need for any settings here + break; + + } + define("BASE_URL", $BASE_URL."/"); // url used for the root of site + define("URL_BASE", $BASE_URL."/"); // same as BASE_URL + define("BASE_PATH", $BASE_PATH."/"); // root directory path of site + define("BASE", $BASE_PATH."/"); // same as BASE_PATH + define("HELP_BASE", "help/"); // help guide base (depreciated) + define("UP_BASE", BASE."uploads/"); // uploads directory path + define("IMG_BASE", URL_BASE."images/"); // the images url path + define("POSTCARD_URL",URL."postcard.phtml"); // postcard url (used for postcard app) + define("LOGO_IMG",URL_BASE."images/logoicon.gif"); // used in admin area as the path to image logo + define("HELP_IMG",URL_BASE."images/help.gif"); // help image url (depriated) + define("ORIGINAL_PATH", BASE."images/original/"); // path of original images + define("RESIZED_PATH", BASE."images/resized/"); // path of first resized image + define("MIDSIZED_PATH", BASE."images/midsized/"); // path of half sized of resized + define("THUMB_PATH", BASE."images/thumb/"); // path of thumbnail directory + if( $_SERVER['HTTPS'] == "on" ) + { + define("ORIGINAL", $BASE_SECURE_URL."/images/original/"); // url of original images + define("RESIZED", $BASE_SECURE_URL."/images/resized/"); // url of resized + define("MIDSIZED", $BASE_SECURE_URL."/images/midsized/"); // url of midsized + define("THUMB", $BASE_SECURE_URL."/images/thumb/"); // url of thumbnail + } + else + { + define("ORIGINAL", URL_BASE."images/original/"); // url of original images + define("RESIZED", URL_BASE."images/resized/"); // url of resized + define("MIDSIZED", URL_BASE."images/midsized/"); // url of midsized + define("THUMB", URL_BASE."images/thumb/"); // url of thumbnail + } + + /** these are the image sizing defines USE THESE ONLY + only allowed string of 'WxH[<>]' [-quality Percentage] + */ + define("ITEM_RESIZED", "'287>' -quality 60"); // used in convert call to resize images + define("ITEM_MIDSIZED", "'220>' -quality 60"); + define("ITEM_THUMB","'140>' -quality 50"); + + define("FOOTER_IMG", URL_BASE."images/logosmall.gif"); + define("FOOTER_URL", URL_BASE); + define("STYLE","main.css"); + + require_once('classes/class_db.inc'); + require_once('classes/class_template.inc'); + $DB =& new GLM_DB(); + + + // [status_US] array of states and their abbr. + $states_US[""] = ""; + $states_US["AL"]= "Alabama"; + $states_US["AK"]= "Alaska"; + $states_US["AZ"]= "Arizona"; + $states_US["AR"]= "Arkansas"; + $states_US["CA"]= "California"; + $states_US["CO"]= "Colorado"; + $states_US["CT"]= "Connecticut"; + $states_US["DE"]= "Delaware"; + $states_US["DC"]= "District of Columbia"; + $states_US["FL"]= "Florida"; + $states_US["GA"]= "Georgia"; + $states_US["HI"]= "Hawaii"; + $states_US["ID"]= "Idaho"; + $states_US["IL"]= "Illinois"; + $states_US["IN"]= "Indiana"; + $states_US["IA"]= "Iowa"; + $states_US["KS"]= "Kansas"; + $states_US["KY"]= "Kentucky"; + $states_US["LA"]= "Louisiana"; + $states_US["ME"]= "Maine"; + $states_US["MD"]= "Maryland"; + $states_US["MA"]= "Massachusetts"; + $states_US["MI"]= "Michigan"; + $states_US["MN"]= "Minnesota"; + $states_US["MS"]= "Mississppi"; + $states_US["MO"]= "Missouri"; + $states_US["MT"]= "Montana"; + $states_US["NE"]= "Nebraska"; + $states_US["NV"]= "Nevada"; + $states_US["NH"]= "New Hampshire"; + $states_US["NJ"]= "New Jersey"; + $states_US["NM"]= "New Mexico"; + $states_US["NY"]= "New York"; + $states_US["NC"]= "North Carolina"; + $states_US["ND"]= "North Dakota"; + $states_US["OH"]= "Ohio"; + $states_US["OK"]= "Oklahoma"; + $states_US["OR"]= "Oregon"; + $states_US["PA"]= "Pennsylvania"; + $states_US["RI"]= "Rhode Island"; + $states_US["SC"]= "South Carolina"; + $states_US["SD"]= "South Dakota"; + $states_US["TN"]= "Tennessee"; + $states_US["TX"]= "Texas"; + $states_US["UT"]= "Utah"; + $states_US["VT"]= "Vermont"; + $states_US["VA"]= "Virginia"; + $states_US["WA"]= "Washington"; + $states_US["WV"]= "West Virginia"; + $states_US["WI"]= "Wisconsin"; + $states_US["WY"]= "Wyoming"; + + // [states] extended states array + $states["AL"] = "Alabama"; + $states["AK"] = "Alaska"; + $states["AB"] = "Alberta"; + $states["AS"] = "American Samoa"; + $states["AZ"] = "Arizona"; + $states["AR"] = "Arkansas"; + $states["BC"] = "British Columbia"; + $states["CA"] = "California"; + $states["CO"] = "Colorado"; + $states["CT"] = "Connecticut"; + $states["DE"] = "Delaware"; + $states["DC"] = "District of Columbia"; + $states["FM"] = "Federated States of Micronesia"; + $states["FL"] = "Florida"; + $states["GA"] = "Georgia"; + $states["GU"] = "Guam"; + $states["HI"] = "Hawaii"; + $states["ID"] = "Idaho"; + $states["IL"] = "Illinois"; + $states["IN"] = "Indiana"; + $states["IA"] = "Iowa"; + $states["KS"] = "Kansas"; + $states["KY"] = "Kentucky"; + $states["LA"] = "Louisiana"; + $states["ME"] = "Maine"; + $states["MB"] = "Manitoba"; + $states["MH"] = "Marshall Islands"; + $states["MD"] = "Maryland"; + $states["MA"] = "Massachusetts"; + $states["MI"] = "Michigan"; + $states["MN"] = "Minnesota"; + $states["MS"] = "Mississppi"; + $states["MO"] = "Missouri"; + $states["MT"] = "Montana"; + $states["NE"] = "Nebraska"; + $states["NV"] = "Nevada"; + $states["NB"] = "New Brunswick"; + $states["NF"] = "Newfoundland"; + $states["NH"] = "New Hampshire"; + $states["NJ"] = "New Jersey"; + $states["NM"] = "New Mexico"; + $states["NY"] = "New York"; + $states["NC"] = "North Carolina"; + $states["ND"] = "North Dakota"; + $states["MP"] = "Northern Mariana Islands"; + $states["NT"] = "Northwest Territories"; + $states["NS"] = "Nova Scotia"; + $states["OH"] = "Ohio"; + $states["OK"] = "Oklahoma"; + $states["ON"] = "Ontario"; + $states["OR"] = "Oregon"; + $states["PW"] = "Palau"; + $states["PA"] = "Pennsylvania"; + $states["PE"] = "Prince Edward Island"; + $states["PR"] = "Puerto Rico"; + $states["QC"] = "Quebec"; + $states["RI"] = "Rhode Island"; + $states["SK"] = "Saskatchewan"; + $states["SC"] = "South Carolina"; + $states["SD"] = "South Dakota"; + $states["TN"] = "Tennessee"; + $states["TX"] = "Texas"; + $states["UT"] = "Utah"; + $states["VT"] = "Vermont"; + $states["VI"] = "Virgin Islands"; + $states["VA"] = "Virginia"; + $states["WA"] = "Washington"; + $states["WV"] = "West Virginia"; + $states["WI"] = "Wisconsin"; + $states["WY"] = "Wyoming"; + $states["YT"] = "Yukon"; + $states["Asia"] = "Asia"; + $states["Australia"] = "Australia"; + $states["Bahamas"] = "Bahamas"; + $states["Caribbean"] = "Caribbean"; + $states["Costa Rica"] = "Costa Rica"; + $states["South America"] = "South America"; + $states["South Africa"] = "South Africa"; + $states["Europe"] = "Europe"; + $states["Mexico"] = "Mexico"; + /* Libraries */ + /* Replaced with the actual functions instead of includes (2001-12-14) */ + + + + /** + * CreditVal : CreditVal Checks for a valid credit card number doing Luhn check, if no + card type is given, attempts to guess. Then, if a list of + accepted types is given, determines whether or not we'll + accept it + * @param $Num: Credit Card Number + * @param $Name = '': Type of Card + * @param $Accepted='' : Accepted array + * + * @return bool + * @access + **/ + function CreditVal($Num, $Name = '', $Accepted='') + { + $Name = strtolower( $Name ); + $Accepted = strtolower( $Accepted ); + $GoodCard = 1; + $Num = ereg_replace("[^[:digit:]]", "", $Num); + switch ($Name) + { + + case "mastercard" : + $GoodCard = ereg("^5[1-5].{14}$", $Num); + break; + + case "visa" : + $GoodCard = ereg("^4.{15}$|^4.{12}$", $Num); + break; + + case "americanexpress" : + $GoodCard = ereg("^3[47].{13}$", $Num); + break; + + case "discover" : + $GoodCard = ereg("^6011.{12}$", $Num); + break; + + case "dinerscard" : + $GoodCard = ereg("^30[0-5].{11}$|^3[68].{12}$", $Num); + break; + + default: + if( ereg("^5[1-5].{14}$", $Num) ) $Name = "mastercard"; + if( ereg("^4.{15}$|^4.{12}$", $Num) ) $Name = "visa"; + if( ereg("^3[47].{13}$", $Num) ) $Name = "americanexpress"; + if( ereg("^6011.{12}$", $Num) ) $Name = "discover"; + if( ereg("^30[0-5].{11}$|^3[68].{12}$", $Num) ) $Name="dinerscard"; + break; + } + + // If there's a limit on card types we accept, check for it here. + if( $Accepted ) + { + $type_verified = FALSE; + $brands = explode_trim( ",", $Accepted ); + foreach( $brands as $brand ) + if( $Name == $brand ) + $type_verified = TRUE; + + if( !$type_verified ) return(FALSE); + } + + $Num = strrev($Num); + + $Total = 0; + + for ($x=0; $x +
    + + + + + +
    + + + + FOOTER_IMG +
    + + + + + + + +
    +
    $msg"?>
    +
    + + + + + + + \n\t\n"; + if($i == count($nav)) + { + print"\n"; + } + } + ?> + + + + + + <?echo $title?> + + + + + + + + + + +
    + + <?echo HEAD?> + +
    +
    +
    + $value) + * + * @return void + * @access + **/ + function form_header($action, $method, $hidden = "") + { + echo "
    "; + if($hidden != "" && is_array($hidden)) + { + foreach($hidden as $key=>$value) + { + echo ""; + } + } + } + + /** + * text_area :Creates textarea with good default values for rows cols and wrap. + * @param $name: string form action string + * @param $value: string Method of form + * @param $$rows = 15: int4 number of rows in textarea box + * @param $$cols = 50: int4 number of cols in textarea box + * @param $$wrap = "virtual" : string the wrap value for the textarea box + * + * @return void + * @access + **/ + function text_area($name, $value, $rows = 15, $cols = 50, $wrap = "virtual" ) + { + echo "
    + "; + if($suppress == 1) + { + echo ""; + } + /* echo "";*/ + echo "
    + +
    + + + + + + + + admin/main.css> + + + _editor_url = "'.URL_BASE.'admin/htmlarea/"; + '; + + echo ''; + echo ''; + echo ''; + echo ''; + ?> + + + + + + + +
    + + + + + +
    + + + + +
     
    +    +
    +
    +
    + + + + +
    + Online Help Guide '; + echo 'Printable Help Guide'; + } + else + { + ?> + + + " BORDER=0> + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Portable Site Data - setup.phtml

    CVS Version Id:$Id: setup.phtml,v 1.2 2010/08/22 14:36:27 cscott Exp $
    SITENAME'.SITENAME.'
    BASE'.BASE.'
    UP_BASE'.UP_BASE.'
    HELP_BASE'.HELP_BASE.'
    IMG_BASE'.IMG_BASE.'
    URL_BASE'.URL_BASE.'
    CONN_STR'.CONN_STR.'
    STYLE'.STYLE.'
    ORIGINAL_PATH'.ORIGINAL_PATH.'
    RESIZED_PATH'.RESIZED_PATH.'
    MIDSIZED_PATH'.MIDSIZED_PATH.'
    THUMB_PATH'.THUMB_PATH.'
    ORIGINAL'.ORIGINAL.'
    RESIZED'.RESIZED.'
    MIDSIZED'.MIDSIZED.'
    THUMB'.THUMB.'
    $CALLED_FROM_DIR'.$CALLED_FROM_DIR.' 
    $BASE_PATH'.$BASE_PATH.'
    $BASE_URL'.$BASE_URL.'
    $BASE_SECURE_URL'.$BASE_SECURE_URL.'
    +   +

    +


    +

    + + '; + + } + + /** + * htmlcode: Output code to enable htmlarea for the page + * MUST BE CALLED AFTER TEXTAREAS ON PAGE + * @param $$w = 570: width of htmlarea in px + * @param $$h = 400: height of htmlarea in px + * + * @return void + * @access + **/ + function htmlcode($w = 570,$h = 400) + { + echo ' + + + +'; + echo ' + + '; + } + + /** + * date_entry : Generate the select boxes for date entry + * month-day-year as drop down select + * @param $month: + * @param $day: + * @param $year: + * @param $month_name: name of select month + * @param $day_name: name of select day + * @param $$year_name : name of select year + * + * @return + * @access + **/ + function date_entry($month,$day,$year,$month_name,$day_name,$year_name) + { + $cur_date = getdate(); + + if($month == "") + { + $month = $cur_date['mon']; + } + if($day == "") + { + $day = $cur_date['mday']; + } + if($year == "") + { + $year = $cur_date['year']; + } + $date = '"; + for($i=1;$i<=12;$i++) + { + $time .= "

    Listings Displayed: '.$starting.' to '.$last_c.' + of '.$totalnum.'
    '.$prev. '   '.$next.'
    '; + return($links); + } + } +?> diff --git a/siteinfo.inc b/siteinfo.inc new file mode 100644 index 0000000..3ca86e3 --- /dev/null +++ b/siteinfo.inc @@ -0,0 +1,794 @@ + 0 ) + $si_base_url = $HTTP_HOST.substr( dirname($SCRIPT_NAME), 0, -strlen($si_called_from_dir) ); + else + { + $si_script_name_dir = dirname($SCRIPT_NAME); + if( $si_script_name_dir == "/" ) + $si_script_name_dir = ""; + $si_base_url = $HTTP_HOST.$si_script_name_dir; + } + +$si_base_secure_url = "https://".$si_base_url; +$si_base_insecure_url = "http://".$si_base_url; + +if( $HTTPS == "on" ) + $si_base_url = "https://".$si_base_url; + else + $si_base_url = "http://".$si_base_url; + + +/******************************************************************************** + * + * Dynamic Configuration - Parameters that DO change based on location + * + ********************************************************************************/ + +switch( $GLM_SERVER_ID ) + { + + case "ChuckAtHome.gaslightmedia.com": + case "chuckweb.gaslightmedia.com": + $si_base_secure_url = $si_base_url; + define( "SI_DB_HOST", "" ); + define( "SI_DB_NAME", "n8dnx" ); + define( "SI_CUSTOMER_EMAIL", "cscott@localhost" ); + define( "SI_CUSTOMER_INTERNAL_EMAIL", "cscott@localhost" ); + define( "SI_DEBUG", 0 ); + define( "SI_DEBUG_VIEW", TRUE ); + define( "SI_DEBUG_MAIL", TRUE ); + define( 'SI_PATH_TO_GRAPHICS_TOOLS', '/usr/bin' ); + define( 'GPG_HOME', '/var/www/.gnupg' ); // Path to home directory for gpg to use + define( 'GPG_KEY_ID', '2B06862A87605EAE' ); // Key ID for public key to use + break; + + case "devsys.gaslightmedia.com": + $si_base_secure_url = $si_base_url; + define( "SI_DB_HOST", "devsys.gaslightmedia.com" ); + define( "SI_DB_NAME", "n8dnx" ); + define( "SI_CUSTOMER_EMAIL", "info@n8dnx.org" ); + define( "SI_CUSTOMER_INTERNAL_EMAIL", "cscott@n8dnx.org" ); + define( "SI_DEBUG", 0 ); + define( "SI_DEBUG_VIEW", FALSE ); + define( "SI_DEBUG_MAIL", TRUE ); + define( 'SI_PATH_TO_GRAPHICS_TOOLS', '/usr/bin' ); + define( 'GPG_HOME', '/var/www/.gnupg' ); // Path to home directory for gpg to use + define( 'GPG_KEY_ID', '2B06862A87605EAE' ); // Key ID for public key to use + break; + + case "ws1.gaslightmedia.com": + $si_base_secure_url = "(none)"; + $si_base_insecure_url = "http://www.n8dnx.org"; + define( "SI_DB_HOST", "ds4.gaslightmedia.com" ); + define( "SI_DB_NAME", "n8dnx" ); + define( "SI_CUSTOMER_EMAIL", "info@n8dnx.org" ); + define( "SI_CUSTOMER_INTERNAL_EMAIL", "cscott@n8dnx.org,dscott@upnorth.net" ); + define( "SI_DEBUG", 0 ); + define( "SI_DEBUG_VIEW", FALSE ); + define( "SI_DEBUG_MAIL", FALSE ); + define( 'SI_PATH_TO_GRAPHICS_TOOLS', '/usr/X11R6/bin' ); + define( 'GPG_HOME', '/var/www/.gnupg' ); // Path to home directory for gpg to use + define( 'GPG_KEY_ID', '2B06862A87605EAE' ); // Key ID for public key to use + break; + + default: // There should be no need for any settings here + break; + + } + +/******************************************************************************** + * + * General Definitions + * + ********************************************************************************/ + + +define( "SI_SERVER", $HTTP_HOST ); // Host name of server +define( "SI_BASE_PATH", $si_base_path ); // Path to root of site +define( "SI_CALLED_FROM_DIR", $si_called_from_dir ); // Directory where current executing file exists +define( "SI_BASE_URL", $si_base_url ); // URL to root of Web site +define( "SI_BASE_SECURE_URL", $si_base_secure_url ); // URL to root of Secure Web site +define( "SI_BASE_INSECURE_URL", $si_base_insecure_url ); // URL to root of Insecure Web site +define( "SI_GLM_APPS", $si_base_url."/glm_apps" ); // GLM misc application modules URL +define( "SI_GLM_SECURE_APPS", $si_base_secure_url."/glm_apps" ); // GLM misc application modules URL - Secure +define( "SI_THIS_SCRIPT", $si_calling_script_name ); // The name of the calling script + +define( "SI_DB_USER", "nobody" ); +define( "SI_DB_TYPE", "postgres" ); +define( "SI_CONN_STR", "host='".SI_DB_HOST."' dbname='".SI_DB_NAME."' user='".SI_DB_USER."'" ); +define( "SI_DB_DATE_STYLE", "SQL" ); + // ISO - use ISO 8601-style dates and times, "1997-12-17 07:37:16-08" + // SQL - use Oracle/Ingres-style dates and times, "12/17/1997 07:37:16.00 PST" + // Postgres - use traditional Postgres format, "Wed Dec 17 07:37:16 1997 PST" + // European - use dd/mm/yyyy for numeric date representations., "17/12/1997 15:37:16.00 MET" + // US - use mm/dd/yyyy for numeric date representations., "12/17/1997 07:37:16.00 PST" + // German - use dd.mm.yyyy for numeric date representations., "17.12.1997 07:37:16.00 PST" +define( 'SI_DB_STATIC', TRUE ); // If true database functions don't automatically close a connection and will re-use if possible +define( "SI_DB_SET_DATE_STYLE_STRING", "SET DATESTYLE TO '".SI_DB_DATE_STYLE."';\n" ); + + + // Graphics support + +define( "SI_GRPH_CONVERT", "/usr/bin/convert" ); +define( "SI_GRPH_DJPEG", "/usr/bin/djpeg "); +define( "SI_GRPH_CJPEG", "/usr/bin/cjpeg "); +define( "SI_GRPH_PNMSCALE", "/usr/bin/pnmscale "); +define( "SI_GRPH_GIFTOPNM", "/usr/bin/giftopnm "); +define( "SI_GRPH_PPMTOGIF", "/usr/bin/ppmtogif "); +define( "SI_GRPH_PPMQUANT", "/usr/bin/ppmquant "); + +define( "SI_IMAGE_DIR", "images" ); +define( "SI_BASE_IMAGE_URL", SI_BASE_URL."/".SI_IMAGE_DIR ); +define( "SI_BASE_IMAGE_PATH", SI_BASE_PATH."/".SI_IMAGE_DIR ); + +define( "SI_IMG_ORIGINAL_URL", SI_BASE_IMAGE_URL."/original" ); +define( "SI_IMG_RESIZED_URL", SI_BASE_IMAGE_URL."/resized" ); +define( "SI_IMG_MIDSIZED_URL", SI_BASE_IMAGE_URL."/midsized" ); +define( "SI_IMG_THUMB_URL", SI_BASE_IMAGE_URL."/thumb" ); + +define( "SI_IMG_ORIGINAL_PATH", SI_BASE_IMAGE_PATH."/original" ); +define( "SI_IMG_RESIZED_PATH", SI_BASE_IMAGE_PATH."/resized" ); +define( "SI_IMG_MIDSIZED_PATH", SI_BASE_IMAGE_PATH."/midsized" ); +define( "SI_IMG_THUMB_PATH", SI_BASE_IMAGE_PATH."/thumb" ); +define( "SI_POSTCARD_URL", SI_BASE_URL."/index.phtml" ); + +$si_today = date( 'n/d/Y' ); // Today's date +$si_timestamp = time(); // Current Timestamp + +define( "SI_COPYRIGHT_YEARS", "2002-".date("Y") ); // Years for copyright statement in footer + + +/******************************************************************************** + * + * Customer Related Configuration + * + ********************************************************************************/ + + // Information about the customer + +define( "SI_CUSTOMER_NAME", "N8DNX" ); +define( "SI_CUSTOMER_LONG_NAME", "Chuck Scott - N8DNX" ); +define( "SI_CUSTOMER_PHONE", "PHONE_NO_NOT_SET" ); +define( "SI_CUSTOMER_FAX", "FAX_NO_NOT_SET" ); +define( "SI_CUSTOMER_TOLL_FREE", "231-347-9941" ); +define( "SI_CUSTOMER_ADDRESS", "1105 Tall Pines Ct." ); +define( "SI_CUSTOMER_CITY", "Petoskey" ); +define( "SI_CUSTOMER_STATE", "Michigan" ); +define( "SI_CUSTOMER_ZIP", "49770" ); +define( "SI_CUSTOMER_FROM_EMAIL", "CUST_EMAIL_NOT_SET" ); +define( "SI_CUSTOMER_LETTER_CLOSING", "Sincerely," ); + + // Strings for TITLE tags + +define( "SI_CUSTOMER_META_KEYWORDS", // Meta Keywords for search engines +"Functions Library Development" ); + +define( "SI_CUSTOMER_META_DESCR", // Meta description for search engines +"Gaslight Media Standard Functions Library Development." ); + +define( "SI_CUSTOMER_ASSETS", SI_BASE_URL."/assets" ); + +define( "SI_CUST_LOGO", "assets/logo.gif" ); +define( "SI_CUST_LOGO_MEDIUM", "assets/logo_medium.gif" ); +define( "SI_CUST_LOGO_SMALL", "assets/logo_small.gif" ); + +define( "SI_CUST_LOGO_URL", $si_base_url."/".SI_CUST_LOGO ); +define( "SI_CUST_LOGO_MEDIUM_URL", $si_base_url."/".SI_CUST_LOGO_MEDIUM ); +define( "SI_CUST_LOGO_SMALL_URL", $si_base_url."/".SI_CUST_LOGO_SMALL ); + + +// ----------------------------------- +// Application Specific Configurations +// ----------------------------------- + + // File Exchange + +$TOOLS_TITLE = "N8DNX File Exchange"; +$TOOLS_NAME = "FileExchange"; +$SERVER_URL = SI_BASE_URL.'/admin'; +$SERVER_PATH = SI_BASE_PATH.'/admin'; +$DATA_PATH = SI_BASE_PATH.'/FileExchange/data'; +$CUST_URL = SI_BASE_URL.'/FileExchange'; +$DATA_URL = "$CUST_URL/data"; +$TOOLS_HELP_PATH = SI_BASE_URL.'/FileExchange/help_files'; + + // Look and Feel section + +$LF_BG_CLR = "#C6EFF7"; // Background color +$LF_LINK_CLR = "#BLUE"; // Link color +$LF_VLINK_CLR = "#BLUE"; // Visited link color +$LF_ALINK_CLR = "#CYAN"; // Active link Color +$LF_NOLINK_CLR = "#A1A1A1"; // Unavailable link color + +$LF_TABLE_CLR = "#FFFFFF"; // Table color (working area background) +$LF_HEADER_CLR = "#00A5C6"; // Table header background color +$LF_FOOTER_CLR = "#00A5C6"; // Table footer background color +$LF_TITLE_CLR = "#005263"; // Admin page title color +$LF_TITLE_2_CLR = "#FFFF10"; // Admin page title line #2 color +$LF_REQ_FIELD_CLR = "BLUE"; // Color of required fields in forms +#LF_COPYWRIGHT_CLR = "#005263"; // Copywright line color + +$LF_HELP_BG_CLR = "#FFFFFF"; // Help system background color +$LF_HELP_TEXT_CLR = "#000000"; // Help system text color + +$LF_ERROR_CLR = "red"; // Error message color + +$LF_HEAD1 = ''; + + // Misc Definitions + +$ENTRIES_PER_PAGE = 10; +$GM_COPYWRIGHT = "Copyright © 1998-2000 Gaslight Media - All rights reserved."; + +$header_sent = FALSE; + + +// ------------------------------- +// Other misc. configuration items +// ------------------------------- + + // Image related configuration + +define( "SI_THEIGHT", "60" ); +define( "SI_RESIZED_SIZE", "287" ); +define( "SI_MIDSIZED_SIZE", "178" ); +define( "SI_THUMB_SIZE", "80" ); + + // Calender applet configuration + +define( "SI_CAL_BKND", "#EFEFEF"); // Window Background color +define( "SI_CAL_TABLE", "#FFFFFF"); // Table background color +define( "SI_CAL_HEAD", "#FFFFFF"); // Table Header Color (days) +define( "SI_CAL_DATE", "#FFFFFF"); // Background color of days +define( "SI_CAL_TODAY", "yellow"); // Background color of todays date +define( "SI_CAL_NODATE", "#E0E0E0"); // Background color of non-dates + +define( "SI_SES_TIMEOUT", "86400" ); // Session timeout - 1 Hour + + // Defaults for things in functions.inc + +define( "SI_DEFAULT_TEXTBOX_COLS", 60 ); +define( "SI_DEFAULT_TEXTBOX_ROWS", 6 ); + + + + +// ---------------------------------------------- +// Other misc. things you don't need to mess with +// ---------------------------------------------- + +$si_month_array = array + ( + 1 => "January", + 2 => "February", + 3 => "March", + 4 => "April", + 5 => "May", + 6 => "June", + 7 => "July", + 8 => "August", + 9 => "September", + 10 => "October", + 11 => "November", + 12 => "December" + ); + + // Countries list + // For the "out of sequence" countries there is no need to remove them from the full list + // For update see....http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/index.html + +$si_countries_array = array + ( + // Out of sequence for convenience + 'US' => 'United States', + 'CA' => 'Canada', + + "AF" => "Afghanistan", + "AX" => "Land Islands", + "AL" => "Albania", + "DZ" => "Algeria", + "AS" => "American Samoa", + "AD" => "Andorra", + "AO" => "Angola", + "AI" => "Anguilla", + "AQ" => "Antarctica", + "AG" => "Antigua and Barbuda", + "AR" => "Argentina", + "AM" => "Armenia", + "AW" => "Aruba", + "AU" => "Australia", + "AT" => "Austria", + "AZ" => "Azerbaijan", + "BS" => "Bahamas", + "BH" => "Bahrain", + "BD" => "Bangladesh", + "BB" => "Barbados", + "BY" => "Belarus", + "BE" => "Belgium", + "BZ" => "Belize", + "BJ" => "Benin", + "BM" => "Bermuda", + "BT" => "Bhutan", + "BO" => "Bolivia", + "BA" => "Bosnia and Herzegovina", + "BW" => "Botswana", + "BV" => "Bouvet Island", + "BR" => "Brazil", + "IO" => "British Indian Ocean Territory", + "BN" => "Brunei Darussalam", + "BG" => "Bulgaria", + "BF" => "Burkina Faso", + "BI" => "Burundi", + "KH" => "Cambodia", + "CM" => "Cameroon", + "CA" => "Canada", + "CV" => "Cape Verde", + "KY" => "Cayman Islands", + "CF" => "Central African Republic", + "TD" => "Chad", + "CL" => "Chile", + "CN" => "China", + "CX" => "Christmas Island", + "CC" => "Cocos (Keeling) Islands", + "CO" => "Colombia", + "KM" => "Comoros", + "CG" => "Congo", + "CD" => "Congo, the Democratic Rep. of", + "CK" => "Cook Islands", + "CR" => "Costa Rica", + "CI" => "Cote D'Ivoire", + "HR" => "Croatia", + "CU" => "Cuba", + "CY" => "Cyprus", + "CZ" => "Czech Republic", + "DK" => "Denmark", + "DJ" => "Djibouti", + "DM" => "Dominica", + "DO" => "Dominican Republic", + "EC" => "Ecuador", + "EG" => "Egypt", + "SV" => "El Salvador", + "GQ" => "Equatorial Guinea", + "ER" => "Eritrea", + "EE" => "Estonia", + "ET" => "Ethiopia", + "FK" => "Falkland Islands (Malvinas)", + "FO" => "Faroe Islands", + "FJ" => "Fiji", + "FI" => "Finland", + "FR" => "France", + "GF" => "French Guiana", + "PF" => "French Polynesia", + "TF" => "French Southern Territories", + "GA" => "Gabon", + "GM" => "Gambia", + "GE" => "Georgia", + "DE" => "Germany", + "GH" => "Ghana", + "GI" => "Gibraltar", + "GR" => "Greece", + "GL" => "Greenland", + "GD" => "Grenada", + "GP" => "Guadeloupe", + "GU" => "Guam", + "GT" => "Guatemala", + "GN" => "Guinea", + "GW" => "Guinea-Bissau", + "GY" => "Guyana", + "HT" => "Haiti", + "HM" => "Heard Island, McDonald Islands", + "VA" => "Holy see (Vatican City State)", + "HN" => "Honduras", + "HK" => "Hong Kong", + "HU" => "Hungary", + "IS" => "Iceland", + "IN" => "India", + "ID" => "Indonesia", + "IR" => "Iran, Islamic Republic of", + "IQ" => "Iraq", + "IE" => "Ireland", + "IL" => "Israel", + "IT" => "Italy", + "JM" => "Jamaica", + "JP" => "Japan", + "JO" => "Jordan", + "KZ" => "Kazakhstan", + "KE" => "Kenya", + "KI" => "Kiribati", + "KP" => "Korea, Democratic People's Rep. of", + "KR" => "Korea, Republic of", + "KW" => "Kuwait", + "KG" => "Kyrgyzstan", + "LA" => "Lao People's Democratic Republic", + "LV" => "Latvia", + "LB" => "Lebanon", + "LS" => "Lesotho", + "LR" => "Liberia", + "LY" => "Libyan Arab Jamahiriya", + "LI" => "Liechtenstein", + "LT" => "Lithuania", + "LU" => "Luxembourg", + "MO" => "Macao", + "MK" => "Macedonia, the Former Yugoslav Rep.", + "MG" => "Madagascar", + "MW" => "Malawi", + "MY" => "Malaysia", + "MV" => "Maldives", + "ML" => "Mali", + "MT" => "Malta", + "MH" => "Marshall Islands", + "MQ" => "Martinique", + "MR" => "Mauritania", + "MU" => "Mauritius", + "YT" => "Mayotte", + "MX" => "Mexico", + "FM" => "Micronesia, Federated States of", + "MD" => "Moldova, Republic of", + "MC" => "Monaco", + "MN" => "Mongolia", + "MS" => "Montserrat", + "MA" => "Morocco", + "MZ" => "Mozambique", + "MM" => "Myanmar", + "NA" => "Namibia", + "NR" => "Nauru", + "NP" => "Nepal", + "NL" => "Netherlands", + "AN" => "Netherlands Antilles", + "NC" => "New Caledonia", + "NZ" => "New Zealand", + "NI" => "Nicaragua", + "NE" => "Niger", + "NG" => "Nigeria", + "NU" => "Niue", + "NF" => "Norfolk Island", + "MP" => "Northern Mariana Islands", + "NO" => "Norway", + "OM" => "Oman", + "PK" => "Pakistan", + "PW" => "Palau", + "PS" => "Palestinian Territory, Occupied", + "PA" => "Panama", + "PG" => "Papua New Guinea", + "PY" => "Paraguay", + "PE" => "Peru", + "PH" => "Philippines", + "PN" => "Pitcairn", + "PL" => "Poland", + "PT" => "Portugal", + "PR" => "Puerto Rico", + "QA" => "Qatar", + "RE" => "Reunion", + "RO" => "Romania", + "RU" => "Russian Federation", + "RW" => "Rwanda", + "SH" => "Saint Helena", + "KN" => "Saint Kitts and Nevis", + "LC" => "Saint Lucia", + "PM" => "Saint Pierre and Miquelon", + "VC" => "Saint Vincent and the Grenadines", + "WS" => "Samoa", + "SM" => "San Marino", + "ST" => "Sao Tome and Principe", + "SA" => "Saudi Arabia", + "SN" => "Senegal", + "CS" => "Serbia and Montenegro", + "SC" => "Seychelles", + "SL" => "Sierra Leone", + "SG" => "Singapore", + "SK" => "Slovakia", + "SI" => "Slovenia", + "SB" => "Solomon Islands", + "SO" => "Somalia", + "ZA" => "South Africa", + "GS" => "South Georgia, South Sandwich Islands", + "ES" => "Spain", + "LK" => "Sri Lanka", + "SD" => "Sudan", + "SR" => "Suriname", + "SJ" => "Svalbard and Jan Mayen", + "SZ" => "Swaziland", + "SE" => "Sweden", + "CH" => "Switzerland", + "SY" => "Syrian Arab Republic", + "TW" => "Taiwan, Province of China", + "TJ" => "Tajikistan", + "TZ" => "Tanzania, United Republic of", + "TH" => "Thailand", + "TL" => "Timor-Leste", + "TG" => "Togo", + "TK" => "Tokelau", + "TO" => "Tonga", + "TT" => "Trinidad and Tobago", + "TN" => "Tunisia", + "TR" => "Turkey", + "TM" => "Turkmenistan", + "TC" => "Turks and Caicos Islands", + "TV" => "Tuvalu", + "UG" => "Uganda", + "UA" => "Ukraine", + "AE" => "United Arab Emirates", + "GB" => "United Kingdom", + "US" => "United States", + "UM" => "United States minor outlying islands", + "UY" => "Uruguay", + "UZ" => "Uzbekistan", + "VU" => "Vanuatu", + "VE" => "Venezuela", + "VN" => "Viet Nam", + "VG" => "Virgin Islands, British", + "VI" => "Virgin Islands, U.S.", + "WF" => "Wallis and Futuna", + "EH" => "Western Sahara", + "YE" => "Yemen", + "ZM" => "Zambia", + "ZW" => "Zimbabwe" + ); + +$si_countries_list = $s = ""; +while( list($k, $v) = each($si_countries_array) ) + { + $si_countries_list .= "$s$k^$v"; + $s = "~"; + } + +$si_states_array = array + ( + "AL" => "Alabama", + "AK" => "Alaska", + "AB" => "Alberta", + "AZ" => "Arizona", + "AR" => "Arkansas", + "BC" => "British Columbia", + "CA" => "California", + "CO" => "Colorado", + "CT" => "Connecticut", + "DE" => "Delaware", + "DC" => "District of Columbia", + "FL" => "Florida", + "GA" => "Georgia", + "GU" => "Guam", + "HI" => "Hawaii", + "ID" => "Idaho", + "IL" => "Illinois", + "IN" => "Indiana", + "IA" => "Iowa", + "KS" => "Kansas", + "KY" => "Kentucky", + "LA" => "Louisiana", + "ME" => "Maine", + "MB" => "Manitoba", + "MD" => "Maryland", + "MA" => "Massachusetts", + "MI" => "Michigan", + "MN" => "Minnesota", + "MS" => "Mississppi", + "MO" => "Missouri", + "MT" => "Montana", + "NE" => "Nebraska", + "NV" => "Nevada", + "NB" => "New Brunswick", + "NF" => "Newfoundland", + "NH" => "New Hampshire", + "NJ" => "New Jersey", + "NM" => "New Mexico", + "NY" => "New York", + "NC" => "North Carolina", + "ND" => "North Dakota", + "NT" => "Northwest Territories", + "NS" => "Nova Scotia", + "OH" => "Ohio", + "OK" => "Oklahoma", + "ON" => "Ontario", + "OR" => "Oregon", + "PA" => "Pennsylvania", + "PE" => "Prince Edward Island", + "PR" => "Puerto Rico", + "QC" => "Quebec", + "RI" => "Rhode Island", + "SK" => "Saskatchewan", + "SC" => "South Carolina", + "SD" => "South Dakota", + "TN" => "Tennessee", + "TX" => "Texas", + "UT" => "Utah", + "VT" => "Vermont", + "VI" => "Virgin Islands", + "VA" => "Virginia", + "WA" => "Washington", + "WV" => "West Virginia", + "WI" => "Wisconsin", + "WY" => "Wyoming", + "YT" => "Yukon" + ); + +$si_states_list = $s = ""; +while( list($k, $v) = each($si_states_array) ) + { + $si_states_list .= "$s$k^$v"; + $s = "~"; + } + + // Websafe colors - Not including Black and White + +$si_websafe_colors = array + ( + "Beige" => "#F6D89F", + "Light Purple" => "#8F9ABF", + "Gold" => "#EDBC49", + "Light Blus" => "#4FC9F5", + "Pink" => "#F8C1D9", + "Tan" => "#C5B49A", + "Mint" => "#7DF2CA", + "Light Orange" => "#FFCC99", + "Dark Blue" => "#0099CC", + "Antique White" => "#FAEBD7", + "Lavendar" => "#E6E6FA", + "Tomato" => "#FF6347", + "Light Salmon" => "#FFA07A" + ); + + // Build Websafe color list for use in standard function calls + +$si_websafe_color_list = $s = ""; +while( list($k, $v) = each($si_websafe_colors) ) + { + $si_websafe_color_list .= "$s$v^$k"; + $s = "~"; + } + + // Other useable colors + +$si_std_colors = array + ( + "#006400", + "#00CED1", + "#00FA9A", + "#191970", + "#20B2AA", + "#228B22", + "#2F4F4F", + "#32CD32", + "#388E8E", + "#3CB371", + "#40E0D0", + "#4169E1", + "#4682B4", + "#483D8B", + "#48D1CC", + "#4B0082", + "#555555", + "#556B2F", + "#5F9EA0", + "#6495ED", + "#6A5ACD", + "#6B8E23", + "#708090", + "#7171C6", + "#71C671", + "#778899", + "#7B68EE", + "#7CFC00", + "#7D9EC0", + "#8470FF", + "#87CEEB", + "#87CEFA", + "#8A2BE2", + "#8E388E", + "#8E8E38", + "#8FBC8F", + "#9370DB", + "#9400D3", +// "#98FB98", + "#9932CC", + "#A020F0", + "#A0522D", + "#A52A2A", + "#A9A9A9", + "#AAAAAA", +// "#ADD8E6", + "#ADFF2F", + "#B03060", + "#B0C4DE", +// "#B0E0E6", + "#B22222", + "#B8860B", + "#BA55D3", + "#BC8F8F", + "#BDB76B", + "#BEBEBE", + "#C5C1AA", + "#C67171", + "#C71585", + "#CD5C5C", + "#D02090", + "#D2691E", + "#D2B48C", +// "#D3D3D3", + "#D8BFD8", + "#DA70D6", + "#DAA520", + "#DB7093", + "#DC143C", +// "#DCDCDC", + "#DDA0DD", + "#DEB887", +// "#E6E6FA", + "#E9967A", + "#EE82EE", +// "#EEE8AA", + "#F08080", +// "#F0E68C", +// "#F0F8FF", + "#F4A460", +// "#F5DEB3", +// "#F5F5DC", +// "#F5FFFA", +// "#F8F8FF", + "#FA8072", +// "#FAEBD7", +// "#FAF0E6", +// "#FAFAD2", +// "#FDF5E6", + "#FF69B4", + "#FF7F50", + "#FF8C00", + "#FFB6C1", + "#FFC0CB", + "#FFD700" +// "#FFE4B5", +// "#FFEBCD", +// "#FFEFD5", +// "#FFFAF0" + ); + + // Determine number of bits in an integer useable for a bitmap - PHP doesn't have sizeof() + +settype( $test_int, "integer" ); +$test_int = 1; +for( $i=1 ; $i<100 ; $i++ ) + { + $t = $test_int * 2; + $test_int = $test_int << 1; + if( $test_int != $t ) + break; + } +define( 'SI_INT_SIZE', $i ); + + +} // if( !isset($siteinfo) ) + +?> diff --git a/static/53.phtml b/static/53.phtml new file mode 100755 index 0000000..93e7b74 --- /dev/null +++ b/static/53.phtml @@ -0,0 +1,1957 @@ + + + + + +

    Stutsmanvill Repeater Complex - User's Manual

    +
    +

    +  +

    +

    Table of Contents

    +

    +

    + +

    +  +

    + +

    System Overview

    +The W8GQN/N8DNX/KO8P Repeater system, located on a hill just west of Stutsmanville Michigan, consists of the +Straits Area Amateur Radio Club (SAARC) VHF repeater and the N8DNX/KO8P privately owned UHF repeaters and +remote base. Both systems cover much of the Northern part of the Lower Peninsula, and Eastern part of +the Upper Peninsula of Michigan. These systems share a common controller, power systems and ancillary equipment. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
     

    W8GQN Repeater

    Output Frequency: 146.680 MHz
    Input Frequency: 146.080 MHz
    Offset: -600 KHz
    PL Frequency: 110.9 Hz (normally required)
    Repeater: GE Receiver
    + Quintron Transmitter
    Final Power: 100W
    Duplexer: 6 Can Custom
    + 1.5 db loss (aprox)
    Transmission Line: 450' 7/8" Heliax
    + 1.98 db loss (.44 db/ft)
    Line sharing: TX/RX Crossband Couplers (for sharing line with UHF Rptr)
    + .15 db loss each - total .3 db
    Antenna: Sinclair 4 Bay Dipole?
    + 6 db gain
    Power to Antenna: 41.9 W
    ERP: 166.7 W
    Height on Tower: 405'
    HAAT: 784'
    Height above Sea Level: 1655'
     

    N8DNX Repeater

    Output Frequency: 442.375 MHz
    Input Frequency: 447.375 Mhz
    Offset: +5.00 MHz
    PL Frequency: 107.2 Hz (normally not required)
    Repeater: Vertex VXR-5000
    Amplifier: TPL
    Final Power: 250W
    Duplexer: (none)
    Transmission Line: Transmit - 450' 7/8" Heliax (shared with W8GQN repeater)
    + Receive - 550' LMR-400
    Tranmission Line Loss: Transmit - 3.7 db
    + Receive - 14.85 (overcome by preamp gain)
    Line Sharing: TX/RX Crossband Couplers (for sharing line with VHF Rptr)
    + .15 db loss each - total .3 db
    Antenna: Transmit - Sinclair 8 Bay Dipole
    + Receive - Sinclair 8 Bay Dipole
    Power to Antenna: 55.9 W
    ERP: 444.2 W
    Height on Tower: Transmit 405', Receive 477'
    HAAT: Transmit 784', Receive 856'
    Height above Sea Level: Transmit 1655', Receive 1727'
    Preamp: Angle Linear High Level Preamp - Gain ~ 20db (mounted at antenna)
     

    KO8P Repeater

    Output Frequency: 443.375 MHz
    Input Frequency: 448.375 MHz
    Offset: +5.00 MHz
    PL Frequency: 107.2 Hz (normally not required)
    Repeater: Vertex VXR-5000
    Final Power: 25W
    Power to Antenna: 7.5 W
    ERP: 59.5 W
    (all other stats same as N8DNX Repeater)
     

    Remote Base

    HF Radio: Kenwood TS-450S
    + Transmit: 160-10 Meter Ham Bands
    + Receive: .1 - 30 MHz continuous
    HF Antenna: Hy-Gain 18HT vertical, currently with 17M kit and 30 60' radials
    VHF/UHF Radio: Yaesu FT-736
    + Transmit & Receive: 50, 144, 220, & 440 MHz All Modes
    VHF/UHF Antennas: Single 6 Meter folded dipole and Diamond X3200A for 144, 220, & 440 MHz
     

    Controller

    Model: Link Communications RLC-3
    Radio Cards: 8
    Audio Delay: Aprox. 200 ms on W8GQN and N8DNX repeaters
    Digital Voice Recorder: DVR-1 with 16 MB memory - 35 Min. total record time
     

    Power

    Primary Power: 110v AC
    Backup Power: Heart Interface 1KW Power Inverter
    Batteries: 4 200 AH Sealed
    +

    +All systems are open for general use. A PL tone of 110.9 Hz is generally required on the W8GQN VHF repeater +to avoid interference with another nearby repeater. There is, however, a bypass code (*00) that will +temporarily remove the PL tone requirement and permit access by users who don't have PL tone capability. +Users are encouraged to use this code and distribute it freely. +

    +Many features of these repeaters are available for use by anyone within range of the repeater and there is +on-line help available to assist users with those features. Other features are available only to registered users. +Registration is not intended to restrict use of those features, but rather to enable use of those features. +Registered users are encouraged to demonstrate those features for others and may activate and operate them +for non-registered and transient users. +

    +The system has been designed and programmed to be as easy to use as possible. It is, however, still a +work-in-progress and users are encouraged to ask questions and suggest changes and improvements. Questions and +suggestions should be submitted to Chuck Scott N8DNX via E-Mail at info@n8dnx.org. +

    + +

    Repeater Operation and Etiquette

    +

    +Users should keep in mind the following items when using these repeaters. +

    +

      +
    • Keep transmissions relatively short. The repeater will timeout after 3 minutes.
    • +
    • Wait for the "courtesy beep" before starting your transmission.
    • +
    • Users who want to break into a conversation should simply say "Break" prior to the courtesy beep.
    • +
    • Users who want to break into a conversation with priority or emergency traffic should say + "Break, Break, Break" prior to the courtesy beep, then wait to make sure their priority transmission + doesn't "double" with another users transmission.
    • +
    • Emergency and health and welfare traffic always have priority over other communications.
    • +
    • It is common courtesy to permit other users to join a conversation.
    • +
    • It is impolite to break into an ongoing conversation for the purpose of initiating a separate conversation with another station.
    • +
    • It is impolite (and frankly illegal) to "kerchunk" (key up) the repeater without ID'ing.
    • +
    • Users should not acknowledge, intimidate or otherwise argue with any user who intentionally interferes + with or attempts to disrupt repeater operations. Please report all such offenses to a system operator + or club officer via telephone or on another frequency.
    • +
    • Always be polite, courteous and helpful to all other users of the repeater.
    • +
    +

    + +

    Registered User Security

    +

    +Registered users are issued a "User Number" and a "Pass Code". Your user number is public information. It +enables other users to send you private voice mail over the repeater. Your pass code is not public information +and you should not share it with other users of the repeater. If you believe that someone else has decoded your +pass code and may be using it, the system operator can issue you a more secure type of pass code that can't be +determined by monitoring your transmissions on the input frequency. +

    + +

    On-Line Help System

    +

    +The repeater system has an "on-line" help system that lists many of the more common commands user may need. +The help system is divided into a number of sections including system description and general help, and individual +descriptions for each logical group of commands. User may enter "999" to access the main system information and help +overview message. All system information and help messages are "polite announcements" in that they stop when the +repeater receives a transmission. This permits a user to stop the transmission as soon as they've heard the information +of interest by briefly keying their transmitter. +

    + +

    User Command Descriptions

    +

    +All user commands are entered using the numeric keypad on your radio while you're transmitting into the repeater. Not +all commands are can be used by all users. The "User Level Required" field in the command descriptions below indicates +the user level required to execute each command. +

    +Before you can execute any command that requires user level 1 or higher, you must first log into the repeater using +your user number and pass code (see command 71). You do not need to log into the repeater to use any level 0 command. +

    +Each registered user is assigned a "User Level". The user level you are assigned depends on whether or not you are a +Remote Base user or if you are a control or system operator. If you are a Remote Base user, your user level is +determined by the class of your Ham Radio license. +

    +

    + + + + + + + + + +
    User Level Description
    0 All users, no user registration or user number/pass code are required.
    1 Registered user
    2 Technician Class Remote Base users
    3 General Class Remote Base users
    4 Advanced Class Remote Base users
    5 Extra Class Remote Base users
    6 Control Operators
    7 System programming
    +

    +The curly braces "{" and "}" in a Command Code indicate that the user is to include other variable digits along +with the command. For example, the command ... +

    +
    * {PhoneNumber}
    +
    +...indicates that the user should press "*" followed by the desired phone number. +

    +Entering an incorrect command code, attempting to enter a command from a repeater port on which the command is +not available, or entering a command you are not authorized to use, may result in either no response from the +repeater or an error message. While some error messages are given by voice announcement, most error messages are +given by number. The following table lists possible numeric error messages and their meaning. +

    +

    + + + + + + + + + + + + + +
    Error Number Description
    Error 200 Command not found
    Error 201 Too few data digits entered
    Error 202 Too many data digits entered
    Error 203 ncorrect number of digits entered
    Error 204 Command not allowed from this repeater input
    Error 205 You do not have permission to use this command
    Error 210 Incorrect digits entered for this command
    Error 212 Bad Autopatch Number
    Error 213 General Autopatch error
    Error 214 User log-in is disabled
    Error 215 Digital Voice Recorder is busy
    Error 217 Bad command entered in Remote Base mode
    +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +  

    System Information and Help Messages 

    Command: Announce system description and help system overview
    Command Code: 999
    User Level Required: 0 - All Users
    Description: + Main system description and help system overview voice announcement. This is a "polite" command. +

    + Additional help announcements are available using the following codes. +

    +

    +
    29 Voice mail and bulletin announcement commands +
    39 Intra-System linking commands +
    49 Inter-System linking commands +
    59 Remote Base commands +
    69 Weather Radio commands +
    79 User Access commands +
    89 Test commands +
    99 System Status commands +
    +

      +

    +  

    PL Access Commands 

    Command: Bypass PL Decode requirement on VHF repeater for 15 minutes
    Codes to execute: *00
    User Level Required: 0 - All Users
    Description: + This command turns off the PL tone access requirement for the VHF repeater and + permits access by stations that can't transmit the 110.9 Hz PL tone normally required + to access the VHF repeater. After 15 minutes, PL access is automatically reinstated. + You do not need to transmit the 110.9 Hz PL tone to enter this command, thus stations + without PL can issue this command and access the repeater without assistance. +

      +

    +  

    Voice Mail and Bulletin Commands 

    Command: Check for public voice mail
    Codes to execute: 20
    User Level Required: 0 - All Users
    Description: + Instructs the repeater to announce if there are any public voice mail messages available + to be read. If there are, the repeater will announce who those messages are for. If + there is more than one message, the sequence the repeater announces who they are for will + determine the number you will need to use to play a particular message using command code 21. + After listening to your message, you can delete that message using command code 22. +

    + For example... +

      +
    • You enter command code 20 +
    • The repeater responds with "There is mail for, N8DNX, N8JBO" +
    • Since it announced N8JBO second, you use command code "21 2" to listen to the message. +
    • You then enter command code "22" to erase the message you just heard. +
    + Since the public voice mail commands do not require a user level above 0, + they can be used by any repeater user without any need to be "registered" or to log into the repeater. +

      +

    Command: Retrieve a Publc mail message
    Codes to execute: 21 {MessageNumber}
    User Level Required: 0 - All Users
    Description: + Use this command to play a particular public mail message. +

    + See command code 20 for an example of using this command. +

      +

    Command: Erase a Public mail message
    Codes to execute: 22
    User Level Required: 0 - All Users
    Description: + Erase the public mail message that has just been played. For this command to work, + you must enter it immediately after listening to the message using command code 21. +

    + See command code 20 for an example of using this command. +

      +

    Command: Record a Public mail message
    Codes to execute: 23
    User Level Required: 0 - All Users
    Description: + Record a public mail message for another repeater user. After you enter this command, + the repeater will ask you who the message is for and then to record your message. +

    + For example... +

      +
    • You enter command 23 +
    • The repeater says "Who is your message for?" +
    • You key your transmitter and say only "N8JBO" +
    • The repeater comes back and says "Please record your message." +
    • You key your transmitter and state your message for the other repeater user. +
    • The repeater comes back and says "Your message is stored." +
    + Note: There is a limited amount of time available for all recorded messages in + the repeater. Please keep your message short. +

      +

    Command: Play Private Mail Messages
    Codes to execute: 24 {User #}
    User Level Required: 1 - Registered users
    Description: + Use this command code to play any private mail that has been left for you. Don't forget + to include your user number after the command code 24. Your user number is the three digit + number you used to log into the system. +

      +

    Command: Erase Private Mail Messages
    Codes to execute: 25
    User Level Required: 1 - Registered users
    Description: + Use this command code after listening to your private voice mail to erase it. +

      +

    Command: Record a Private Voice Mail Message
    Codes to execute: 26 {User #}
    User Level Required: 1 - Registered users
    Description: + Use this command code to record private voice mail for another user. Using this command + is similar to command code 23. Enter command code 26 followed by the user number of the + user for whom you wish to leave voice mail, wait for a courtesy tone, then key up and say your message. +

      +

    Command: Play any available SAARC club bulletins
    Codes to execute: 27
    User Level Required: 0 - All Users
    Description: + Use this command code to play a recorded SAARC club bulletin. The W8GQN VHF repeater will + announce when such bulletins are available. +

      +

    Command: Play any available N8DNX repeater bulletin
    Codes to execute: 28
    User Level Required: 0 - All Users
    Description: + Use this command code to play a recorded N8DNX repeater bulletin. The N8DNX UHF repeater + will announce when such bulletins are available. +

      +

    Command: On-Line help for Voice Mail and Bulletin commands
    Codes to execute: 29
    User Level Required: 0 - All Users
    Description: + This command plays a brief polite voice message describing Voice Mail and Bulletin commands. +

      +

    +  

    Intra-System Linking Commands 

    Command: Turn off current link
    Codes to execute: 30
    User Level Required: 0 - All Users (set to permit turning links off after login timeout)
    Description: + This command code will turn off linking initiated using command codes 31 through 36. +

    + Complex Intra-System Linking +

    + An interesting aspect of the Intra-System linking commands is that they are "cumulative". In + other words, you can choose to monitor or link to more than one other part of the system at the + same time from the repeater you're currently using. Also, command code 30 will turn off any and + all linking to other parts of the system from the current repeater. As a result, an advanced user + can link several parts of the system together at one time. (Note that the tail message will only + repeat the last link established.) +

    + One curious thing is that linking to one part of the system that is linked to another part does + not mean that all 3 parts are linked together. For example, if the N8DNX repeater is currently + linked to KO8P and you, as a user of the VHF repeater, link the W8GQN repeater to the N8DNX repeater, + you will not be linked to the KO8P repeater. In essence, you could talk to people on the N8DNX repeater and people on the N8DNX + could talk to people on the KO8P repeater, but you couldn't talk to people on the KO8P repeater. +

    + Assuming the situation where you wanted the W8GQN and N8DNX repeaters linked together and both + of them also linked to KO8P, how would you do this? +

      +
    1. Enter 32 from the W8GQN repeater to link to N8DNX +
    2. Enter 36 from the W8GQN repeater to link to KO8P +
    3. Enter 36 from the N8DNX repeater to link to KO8P +
    + To drop all of the links simply enter 30 from both the W8GQN and N8DNX repeaters. Note that + entering 30 on the N8DNX repeater will drop the links to both KO8P and the W8GQN repeater at the same time. +

      +

    Command: Monitor W8GQN VHF repeater from current repeater
    Codes to execute: 31
    User Level Required: 1 - Login Required
    Description: + Entering this command code will cause any transmissions received by the on the W8GQN VHF + repeater to be transmitted on the repeater you are currently using. The W8GQN repeater will + not transmit any transmissions received on the repeater you are currently using. Use this command + to monitor activity on the W8GQN repeater without interfering with a conversation on that repeater. + An occasional tail message will indicate that this is active. +

    + Note: This command is makes no sense for, and is not available from the W8GQN repeater. +

    + Use command code 32 to establish a two-way link to the VHF repeater. +

      +

    Command: Link to the VHF W8GQN repeater from the current repeater
    Codes to execute: 32
    User Level Required: 1 - Login Required
    Description: + Entering this command code establishes a two-way link to the W8GQN repeater. Use this command + to effectively link both repeaters together so that users of both the W8GQN VHF repeater and + the repeater your are currently using can engage in a conversation together. An occasional tail + message will indicate that this is active. +

    + Note: This command is makes no sense for, and is not available from the W8GQN repeater. +

    + Use command code 31 to monitor the W8GQN repeater's activity before using this command. +

      +

    Command: Monitor N8DNX (442.375) from current repeater
    Codes to execute: 33
    User Level Required: 1 - Login Required
    Description: + Entering this command code will cause any transmissions received by the on the N8DNX repeater + to be transmitted on the repeater you are currently using. The N8DNX repeater will not + transmit any transmissions received on the repeater you are currently using. Use this command + to monitor activity on the N8DNX repeater without interfering with a conversation on that + repeater. An occasional tail message will indicate that this is active. +

    + Note: This command is makes no sense for, and is not available from the N8DNX repeater. +

    + Use command code 34 to establish a two-way link to the N8DNX repeater. +

      +

    Command: Link to the N8DNX repeater (442.375) from the current repeater
    Codes to execute: 34
    User Level Required: 1 - Login Required
    Description: + Entering this command code establishes a two-way link to the N8DNX repeater. Use this + command to effectively link both repeaters together so that users of both the N8DNX repeater + and the repeater your are currently using can engage in a conversation together. An occasional + tail message will indicate that this is active. + Note: This command is makes no sense for, and is not available from the N8DNX repeater. +

    + Use command code 33 to monitor the N8DNX repeater activity before using this command. +

      +

    Command: Monitor KO8P reater (443.375) from current repeater
    Codes to execute: 35
    User Level Required: 1 - Login Required
    Description: + Entering this command code will cause any transmissions received by the on the KO8P repeater + to be transmitted on the repeater you are currently using. The KO8P repeater will not + transmit any transmissions received on the repeater you are currently using. Use this command + to monitor activity on the KO8P repeater without interfering with a conversation on that + repeater. An occasional tail message will indicate that this is active. +

    + Note: This command is makes no sense for, and is not available from the KO8P repeater. +

    + Use command code 36 to establish a two-way link to the KO8P repeater. +

      +

    Command: Link to the KO8P repeater from the current repeater
    Codes to execute: 36
    User Level Required: 1 - Login Required
    Description: + Entering this command code establishes a two-way link to the KO8P repeater. Use this + command to effectively link both repeaters together so that users of both the KO8P repeater + and the repeater your are currently using can engage in a conversation together. An occasional + tail message will indicate that this is active. +

    + Note: This command is makes no sense for, and is not available from the KO8P repeater. +

    + Use command code 35 to monitor the KO8P repeater activity before using this command. +

      +

    Command: Send Command to IRLP
    Codes to execute: 38 {Node#}
    + 38 73
    + 38 {Command}
    User Level Required: 0 - All Users
    Description: + This command is unusual in that it has several uses. Since you can't send + commands to the node computer without first linking to it, and since once you've linked to the + node computer there's no sense in linking to it again, there is no practical confusion between + these two uses. An occasional tail message will indicate that this is active (sends "I T" in + morse code for "IRLP Transmit"). +

    + Use 1: Connect to another IRLP node +

    + Enter this command followed by a 4 digit command to the IRLP node computer to control the + IRLP system. (Note that all IRLP node numbers are now 4 digits. Use the "38 73" command to + disconnect from any IRLP node.) +

    +
    38 4460 - Connect to the Southfield node +
    38 73 - Disconnect from the Southfield node +
    + Use "38 73" to disconnect from a node (see below). +

    + Note: Access to the IRLP node is now allowed by all users-login is no longer required. +

    + Use 2: Disconnect from any currently connected IRLP node +

    + Simply enter "38 73" to disconnect from any IRLP node. (73...get it?) +

    + Use 3: Special IRLP Node Commands +

    + Below are some special commands available using the IRLP node computer. These do not connect + to other IRLP nodes. Instead the perform functions local to the IRLP computer, such as playing + an ARRL News recording. +

    +
    38 73 - Disconnect from any IRLP node or stop playing messages listed below +
    38 0001 - Play most recent ARRL News +
    38 0002 - Play most recent Amateur Radio Newsline +
    38 0003 - Play This Week in Amateur Radio +
    38 0101 - Play Pelston Airport Weather (updated hourly) +
    38 0102 - Play stats from most receint IRLP connection +
    38 0103 - Play current propagation report +
    38 0113 - Play Solar X-Ray flux report for GEOS satellites +
    38 0104 - Play list of nearby APRS stations +
    38 0105 - Play status of 5.8 GHz wireless network feed +
    38 0199 - Play a silly message +
    +

      +

    Command: On-Line help for Intra-System Linking commands
    Codes to execute: 39
    User Level Required: 0 - All Users
    Description: + This command plays a brief polite voice message describing Intra-System Linking commands. +

      +

    +  

    Preset Remote Base Linking Commands 

    Command: Turn off link to remote base
    Codes to execute: 40
    User Level Required: 0 - All Users
    Description: + This command is used to disconnect from a preset remote base link. +

    + Preset links are those for which the operating parameters (such as frequency, mode, offset, and + PL), are predefined. Preset remote base links permit quick access to those frequencies without + having to go through the process of setting all necessary parameters. A list of these presets + is included below. (See commands starting at 400.) +

      +

    Command: Toggle preset remote base link between Receive and Transmit/Receive
    Codes to execute: 41
    User Level Required: 0 - All Users
    Description: + Use this command to switch from receive-only mode to transmit and receive mode while using + one of the preset remote base links. +

    + The default mode when you first enable a preset remote base link is receive only. You will need to + use this command before you can talk to another station using the remote base preset. +

    + Always listen on the remote base before selecting transmit/receive mode. If you are experiencing + interference on the local repeater, disconnect from the remote base to avoid causing interference + to stations on the frequency to which the remote base is tuned. +

      +

    Command: Preset Remote Base Links
    Codes to execute: 400 through 499
    User Level Required: 1 - Login Required
    Description: + The following is a list of preset remote base configuration commands. Enter one of these + commands to configure the remote base to the listed frequency and mode and to monitor traffic + on that frequency. Use command code 41 to switch to transmit/receive mode after first monitoring + the selected frequency. +

    + Note: Transmitting on the remote base is, in general, restricted to users who are + licensed for the remote base frequency being used. +

    + Command Preset Configuration +

    +
    400 - 146.740 Repeater (Cheboygan) +
    410 - 29.6 FM Simplex +
    450 - WWV on 10 MHz +
    +

      +

    Command: On-Line help for Preset Remote Base Linking Commands
    Codes to execute: 49
    User Level Required: 0 - All Users
    Description: + This command plays a brief polite voice message describing Preset Remote Base Linking Commands. +

      +

    +  

    General Remote Base Operation 

    Command: Turn on the Remote Base system
    Codes to execute: 50
    User Level Required: 2 through 5 (depending on class of license)
    Description: + This command turns on the remote base system. A full explanation of the remote base system and + its operation is included in a separate document titled "Remote Base Operation Manual" (issued + to authorized users at the time they sign up for use of the remote base). +

    + You must use this command to turn on the remote base before entering any remote base commands. + Once the remote base has been turned on, you will only be able to use the remote base commands + and will have to turn off the remote base system before running any normal repeater commands. +

      +

    Command: On-Line help for enabling the Remote Base
    Codes to execute: 59
    User Level Required: 0 - All Users
    Description: + This command plays a brief polite voice message describing enabling the Remote Base system. + No on-line help is available for operation of the remote base. Please be sure to carry with you + at least the "Short Form Remote Base Operation Guide" when operating the remote base. +

      +

    +  

    Weather Alert and Monitoring Commands 

    Command: Monitor Weather Receiver for 2 Minutes
    Codes to execute: 60
    User Level Required: 0 - All Users
    Description: + This command plays the weather receiver over the current repeater for up to 2 minutes. The + weather receiver is pre-tuned to a local NOAA weather transmitter and will automatically switch + to a backup channel should the local weather transmitter fail. +

      +

    Command: Turn off Weather Receiver
    Codes to execute: 61
    User Level Required: 0 - All Users
    Description: + Use this command to stop monitoring the weather receiver. You may use this command if you + don't want to wait for the entire 2 minutes provided by command code 60. +

    + Note: Do not use this command to interrupt an automatically triggered weather alert transmission. +

      +

    Command: Replay last weather alert message
    Codes to execute: 62
    User Level Required: 0 - All Users
    Description: + This command replays the last automatically transmitted weather alert message. +

    + Each time a weather alert is broadcast by the local NOAA weather station, the repeater will play the + message live on both the W8GQN and N8DNX repeaters while recording the message for replay. If a + weather alert has been triggered, the repeater will announce this by periodically stating "Weather + Alert". Use this command to listen to the most recent message. +

    + Note: Only control operators can clear a weather alert message and discontinue the alert announcements. +

    + The weather receiver is only triggered by significant local weather broadcasts from NOAA that will + affect Emmet and surrounding counties and is not triggered by test messages. +

      +

    Command: On-Line help for Weather Alert and Monitoring Commands
    Codes to execute: 69
    User Level Required: 0 - All Users
    Description: + This command plays a brief polite voice message describing the weather alert system and + monitoring of NOAA weather broadcasts. +

      +

    +  

    Security and Access Commands 

    Command: List Users Who are Currently Logged In
    Codes to execute: 70
    User Level Required: 0 - All Users
    Description: + This command will list any users who used command code 71 and are currently logged in (have + a user level greater than 0). Logging into the system permits a user to use restricted + commands (commands which require a user level greater than 0). A user will remain "logged in" + as long as they keep entering commands. If a logged-in user doesn't enter a command for some + period of time, the system will automatically log that user out of the system and return them + to user level 0. +

      +

    Command: Log Into the System
    Codes to execute: 71 {user ID}
    + 71 {user ID} {Pass Code}
    User Level Required: 0 - All Users
    Description: + Use this command to log into the repeater system and permit access to commands that require + a user level greater than 0. +

    + Note: The system will log you out automatically if you do not enter any command codes + for a few minutes. When this happens, you will hear the message "{your call} Control Down". +

    + WARNING: Any user on the repeater you used to log-into the system may issue restricted + commands permitted to your user level while you are logged in. In essence, once you log in, + the system can't tell if someone sending it command codes is the one who logged-in or someone + else. You are responsible for the use of your user ID. Be sure to log out using command code + 72 as soon as you are done. +

    + WARNING: You are responsible for the use of your user ID. Do not share your Pass Code + or Pass Phrase with others. If you believe for some reason that your ID and Pass Code or Pass + Phrase is being used by someone else, contact a control or system operator immediately and + have them disable your ID or issue you new access codes. +

    + A user with a specific user level may use any commands available to that user level and all + commands available to lower user levels. For example, a General class remote base user can use + any command available to Tech class remote base users, club members or any user who has not + logged-in, but not those available only to level 4 (Advanced) and greater. +

    + + + + + + + + + + +
    IDLevelUser Type
    (none)0Any repeater user
    100-1991Club members without access to the Remote Base System
    200-2992Remote Base users with a Tech class license
    300-3993Remote Base users with a General class license
    400-4994Remote Base users with an Advanced class license
    500-5995Remote Base users with an Extra class license
    600-6996Repeater Control operators and Officers
    700-9997System operators and programmers
    +

    + Note: The remote base system knows on which frequencies each class of licensee is permitted + to transmit. Operators need not worry about transmitting outside frequencies permitted for their + license class-the system will not let them do so. This is the only reason for separating access + levels by license class. +

    + There are two forms of this command. Which one you use will depend on whether you have been + assigned a "Pass Code" or a "Pass Phrase". A "Pass Code" is a specific sequence of from 3 to + 5 digits that you will always enter exactly. A "Pass Phrase" is a longer sequence of up to 8 + digits that provide a "cross reference" of sorts and is used as part of a "challenge/response" + process. The practical difference is that someone monitoring the input channel with a Touch + Tone decoder can decode your "Pass Code" and use your ID, while the proper use of "Pass Phrase" + makes it very difficult for someone monitoring with a decoder to correctly determine your entire + Pass Phrase and thus to use your ID. +

    + Note: Use of a "Pass Phrase" is beyond the scope of this manual and will be explained to + users who for some reason require higher security. +

    + Most users will be assigned a Pass Code and will log-in the same way each time. For example, + a user with the ID 167 and a Pass Code of 526 would log into the system as follows: +

    +
    71 167 526 +
    +

      +

    Command: Log Out of the System
    Codes to execute: 72
    User Level Required: 1 - All Logged-In Users
    Description: + Use this command to log out of the system and return to user level 0. You are required to use + this command when you are done entering restricted commands to prevent other unprivileged users + from entering restricted commands. +

      +

    Command: On-Line help for Security and Access Commands
    Codes to execute: 79
    User Level Required: 0 - All Users
    Description: + This command plays a brief polite voice message describing the Security and Access command codes. +

      +

    +  

    Test and Diagnostic Commands 

    Command: Touch Tone Pad Test
    Codes to execute: 80 {digits}
    User Level Required: 0 - All Users
    Description: + Use this command to test the Touch Tone pad on your radio. Any digits included after command code + 80 will be repeated by the system in the order in which they were entered. Do not un-key between + the command code and the digits you want to test. +

    + Use may use this command to test all keys on your Touch Tone pad, including A, B, C, D, * and #. +

    + Note: If the system doesn't properly reply, you may not be strong enough into the repeater + to reliably enter codes or may have some problem with your radio. The most common problems other + than a weak signal are under or over deviation and "twist". Twist is a situation where there is + a significant difference in level between the low tones and high tones that are produced as you + press each key. +

    + You can use this command to determine if you have a good enough signal prior to executing other commands. +

      +

    Command: Test Received Audio
    Codes to execute: 81
    User Level Required: 0 - All Users
    Description: + Using this command you can hear a short recording of your signal as the repeater received it to evaluate + how well you're being heard by the repeater. This can be helpful to ensure that your signal is adequate + for a reliable autopatch or to help evaluate issues with your signal. +
      +
    1. Key your transmitter and enter command code 81 +
    2. Unkey your transmitter and wait for the courtesy beep +
    3. Key your transmitter and make a short transmission +
    4. Unkey your transmitter +
    + The system will then replay a recording of your last transmission. +

      +

    Command: Report Your Signal Level on one of the UHF Repeaters
    Codes to execute: 82
    User Level Required: 0 - All Users
    Description: + This command reports the average of your signal level over the last several seconds of your + transmission and the high (maximum) value during your entire transmission. The command only + functions on the N8DNX and KO8P repeaters. +

    + At this point a short description of the UHF receiver systems is in order to help you understand + the signal levels reported by this command code. Briefly, both UHF repeaters use the same antenna, + preamplifier, transmission line and distribution amplifier. The following table lists, in order, + various parts of the receive system with gains and losses. +

    + + + + + + + + + + + + +
    Antenna +9 db
    Preamp Front-end Filter -.4 db
    Preamp +20 db (noise figure aprox .5 db)
    Protector, DC pickoff -.3 db
    Transmission line -14.9 db
    Protector -.3 db
    DC Power Injector -.3 db
    Distribution Amplifier +12 db
    Signal Splitter -3 db
     
    Net gain after front-end filter+13.2 db
    +

    + Since there is adequate gain in the system to overcome any loss after the preamplifier, the + system noise figure (sensitivity) is effectively set at the preamplifier. The signal delivered to + the receiver, where the signal level is measured, has a net gain of +13.2 db over the level of + signals at the input to the preamplifier. As a result, the reported signal levels may seem a bit + higher than you would normally expect for the quality of signal received since I did not compensate + for this when I calibrated it. (Perhaps I will some time in the future.) +

    + The following table can be used to convert the dbm readings to uv (microvolts) at the receiver and + preamplifier inputs, and to gain an understanding of what these numbers mean in practical terms. +

    + + + + + + + + + +
    dbmAt receiverAt preampComment
    -113 .5 uv .1 uv Lowest possible reading
    -110 .7 uv .15 uv Weak signal, copyable
    -100 2.2 uv .48 uv Some noise, good signal
    -90 7.1 uv 1.5 uv Little noise, solid signal
    -80 22 uv 4.8 uv Near full quieting
    -70 71 uv 15 uv Excellent signal
    -66 112 uv 25 uv Highest possible reading
    +

    + Note: Due to limitations in the signal level reporting of the repeater, -113 is the weakest + reading, and -66 is the strongest reading that can be reported. Signals stronger than -66 dbm will + still read approximately that value. Also, due to a slight increase in loss at the front-end filter + on the input frequency of the KO8P repeater, readings on that repeater will be slightly worse than the N8DNX repeater. +

      +

    Command: On-Line help for Test and Diagnostic Commands
    Codes to execute: 89
    User Level Required: 0 - All Users
    Description: + This command plays a brief polite voice message describing the test and diagnostic command codes. +

      +

    +  

    System Status Commands 

    Command: System Status Summary
    Codes to execute: 90
    User Level Required: 0 - All Users
    Description: + Use this command to produce a report of all system status values. The values reported are: +
    +
    Date and time +
    Backup battery current +
    Backup battery voltage +
    DC Supply voltage +
    UHF #1 (N8DNX) "Squelch Low" status +
    UHF preamp current +
    + For an explanation of these values see the appropriate individual command below. +

      +

    Command: Backup Battery Current
    Codes to execute: 91
    User Level Required: 0 - All Users
    Description: + Report the present averaged value of current through the backup battery bank. This command + reports the "absolute value" of the battery current (only the amount of current, not + whether it's into or out of the batteries). +

    + Normally, the battery backup system charges the backup batteries as they are being used. + The amount of current being reported is actually the net current between the charge and + load currents. During a power failure, you are likely to see current values up to, or + exceeding, 100 amps. Also, since the N8DNX power amplifier is tied directly to the backup + batteries, you may see values exceeding 50 amps at times when AC power is present. +

    + Note: At this time there is a problem with obtaining a reliable value of current from + the backup battery current shunt amplifier. Values may not be correct or even close. + (I hope to fix that sometime next spring.) +

      +

    Command: Backup Battery Voltage
    Codes to execute: 92
    User Level Required: 0 - All Users
    Description: + This command reports the voltage present on the backup batteries. When AC power is present, + a voltage or 13 volts or greater is normal. Lower voltages indicate that there is currently + an AC power failure, or the has been and the batteries are still being charged. +

    + Note: When the backup battery voltage is less than 12.8 volts, but greater than 11.5 + volts, the repeater courtesy beeps on the W8GQN and N8DNX repeaters will change to a CW "B". + This indicates that the system is on, or recovering from an AC power failure. A CW "BL" + indicates that the battery voltage is less than 11.5 volts (battery low). The power inverter + will automatically shut off, and the repeaters will cease to function, when the voltage reaches + about 10.5 volts. This is necessary to protect the batteries. +

      +

    Command: DC Supply Voltage
    Codes to execute: 93
    User Level Required: 0 - All Users
    Description: + This command reports the voltage present at the DC input of the RLC-3 repeater controller + and roughly represents the voltage of the DC power supply used to power the controller and + various other devices in the repeater system. This value should always be roughly 13.8 volts. +

    + Note: The DC power supply is used to power devices that require 12V DC, but that + won't operate properly with the reduced or varying voltage available on the backup batteries. + During an AC power failure, the backup system will automatically switch in and produce AC power + from a 1 KW power inverter to all devices that require AC power, including the DC power supply. + This permits these devices to continue operate during an AC power failure as they normally would + when AC is present. +

      +

    Command: Date and Time
    Codes to execute: 94
    User Level Required: 0 - All Users
    Description: + Report the current Date and Time as known by the internal clock in the repeater controller. +

      +

    Command: Room Temperature
    Codes to execute: 95
    User Level Required: 0 - All Users
    Description: + This command reports the temperature inside the repeater room. During the winter, the repeater + room is normally kept warm by heat passing through the wall from the broadcast transmitters + in the next room. In extreme conditions, an AC heater in the room will provide additional heat to + keep the room above about 55 degrees. +

      +

    Command: UHF #1 (N8DNX) SQ (Squelch) Low Status
    Codes to execute: 96
    User Level Required: 0 - All Users
    Description: + Enter this command to report the status of the "Squelch Low" control line to the N8DNX repeater. + When "Squelch Low" is on, the squelch on the repeater is set to be slightly more sensitive. + When "Squelch Low" is off, the squelch on the repeater is set a bit tighter-which can be helpful + for eliminating low-level interference. +

      +

    Command: UHF Preamp Current
    Codes to execute: 98
    User Level Required: 0 - All Users
    Description: + This command reports the DC supply current to the tower-mounted UHF preamplifier. A normal value + is approximately 220 ma. Any value significantly different from that may indicate a problem with + the UHF preamplifier. +

    + Note: The UHF preamplifier is actually a redundant pair of individual preamplifier stages. + Either of the two preamplifier circuits can fail and the system will continue to function, although + with a slightly worse system noise figure and about 3 db less gain. The failure of one of these + two redundant pairs may cause a decrease or increase in the current reported by this command. +

      +

    Command: On-Line help for Test and Diagnostic Commands
    Codes to execute: 99
    User Level Required: 0 - All Users
    Description: + This command plays a brief polite voice message describing the system status functions. +

      +

    +

    +  +

    + +

    IRLP - Internet Radio Linking Project

    +

    +The "Internet Radio Linking Project" (IRLP) is a cooperative project to link distant Amateur Radio stations and +repeaters (nodes) over the Internet. IRLP permits the operator at one node to select, and connect to, any other +available distant node by entering specific commands. Once connected, radio users within range of either connected +node can enter into a QSO as if they are all using the same local repeater. IRLP nodes are located all over the +world and as such provide an opportunity for DX, of sorts, for local users. Currently, there are more than 275 nodes, +many in North America, but a number scattered across the world. +

    +Note: You do not need a higher-class license to use the IRLP system. If your license permits you to use a +repeater, then you are permitted to use IRLP. +

    +A status page with a list of nodes and status of each is available over the Internet at http://status.irlp.net. +

    +A four-digit number designates each node. The on-line status page lists the node number, call letters, location, +last status update and present status of each node. The preset status will be one of the following values. +

    +

    + + + + +
    DOWN Node is currently out of operation or unreachable
    IDLE Node is operational and available for a connection
    REF# Node is connected to an IRLP reflector. Connect to that reflector + to contact users of the node.
    {anything else} The call sign or name of another node to which it is connected-the + node is unavailable.
    +

    +Reflectors are central servers that permit more than 2 IRLP nodes to connect to each other at one time. These +reflectors permit a "round table" of sorts between users of 2 or more nodes. You may connect to a reflector just +as you would to any specific node. The only difference is that you never know where you may reach or whom you may contact! +

    +You connect to a remote node or reflector by entering a command prefix (38) followed by the number of the node. To disconnect +from any IRLP node, use "38 73". +

    +

    + + +
    38 {nnn} Connect to node number {nnn}
    38 73 Disconnect from any node
    +When you connect to a distant IRLP node, you will hear a message indicating that you are connected to their node. +Similarly, when you connect to the distant node, that node will transmit a message indicating which node has connected to +it. Below are examples for connecting to, and disconnecting from, WB8NXP's IRLP node on his repeater in Southfield MI. +

    +

    + + +
    38 4460 Connect to node 446 in Southfield (talk to stations in Southfield)
    38 73 Disconnect from node 446 in Southfield
    +

    +Users of other IRLP nodes may also connect to our IRLP node. If any call from another node comes in while IRLP is not +connected to one of the repeaters, the IRLP system will automatically connect to the W8GQN VHF repeater and the incomming call +will be heard there. +

    +Note: The following are special commands to the IRLP node. These commands are unique to the IRLP node on our system and +will not function on other IRLP nodes. These do not connect to other IRLP nodes. Instead they perform functions local to +the IRLP computer, such as playing an ARRL News recording. + +

    +

    + + + + + + + + + +
    38 73 Stop playing recorded audio news
    38 0001 Play the most recent ARRL Audio News Bulletin (Updated late Saturday night)
    38 0002 Play the most recent Amateur Radio Newsline (Updated late Saturday night)
    38 0003 Play the most recent This Week in Amateur Radio (Updated early Sunday morning)
    38 0101 Play Pelston Airport weather (Updated hourly - on the hour)
    38 0102 Play statistics report from most receint IRLP connection
    38 0103 Play Propagation report (Updated hourly - :05 after the hour)
    38 0104 Play list of nearby APRS stations
    38 0199 Play a silly message
    +

    +Operation on the IRLP network is very similar to operation on the local repeater, with a few exceptions. +

    + +

    General IRLP node use guidelines:

    +
      +
    • Be considerate and patient with other IRLP users. There are new IRLP nodes being added all the time and inexperienced users trying the system every day-try to make them welcome. Remember, you are Northern Michigan's "ambassadors" to the world. +
    • Do not tie up the W8GQN SAARC club repeater for extended times with IRLP operation during peak use hours for the repeater. The KO8P repeater is preferred for long-term remote base and IRLP operations. +
    • Assist traveling Hams with use of the IRLP system. If they've used IRLP elsewhere, they may be familiar with needing a prefix before the IRLP Node nuimber. There is no problem with informing them on how to use our IRLP Node. +
    +When connected to another IRLP node: +
      +
    • Wait 10-15 seconds after connecting to a distant IRLP node to account for transmission of the voice message on the distant IRLP node. +
    • Allow an extra second or two between transmissions to account for network delays. +
    • Include your city and state when you ID. Users of the distant IRLP node may not know you are not a local user. +
    • Immediately after connecting to a distant IRLP node, identify with your call, city and state. +
    • Identify and state that you are disconnecting before disconnecting from a distant IRLP node. +
    +When connected to an IRLP Reflector (in addition to the above): +
      +
    • Always permit extra time between transmissions to account for network delays and for other stations to join or leave a discussion. (Some nodes cannot disconnect when someone is talking.) +
    • Identify before sending any DTMF commands, such as to disconnect from a node. +
    • Hold your microphone PTT for about 1 second before talking to allow for network delays. +
    • To break into a QSO, state your call sign once during a pause in traffic. +
    • Don't break into a QSO simply to "work" one of the stations. Do break into a QSO to join a conversation. +
    • When more than 2 people are in a QSO on a reflector, try to maintain an organized "round table" format. +
    • Do not start a "Net" on a reflector without the permission of the reflector owner. +
    • If you are experiencing interference to the local repeater, disconnect from the reflector to avoid interfering with other user's transmissions. +
    • Keep in mind that there may at times be many users on the same reflector. Always be courteous and patient! +
    +For a detailed description of IRLP, additional operating guidelines, and how you can participate, go to +http://www.irlp.net. +

    +  +

    + + +

    User Command Reference

    + +User Levels: 0 = Public user, 1 = Club member + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Command Function Min User Level
    *00 VHF Repeater PL By-Pass for 15 Minutes 0
     
    * {phone#} Dial {phone#} on autopatch 0
    # Hang up autopatch 0
     
    19 Help with Autopatch commands 0
     
    20 Check for public mail - Announces who mail is for. 0
    21 {message#} Retrieve public mail message. 0
    22 Erase the public mail message just retrieved
    + (May only be used after command 21.)
    0
    23 Record a public mail message 0
    24 {user #} Retrieve private mail 1
    25 Erase private mail 1
    26 {user #} Record private mail for {user#} 1
    27 Play club bulletins 0
    270 Play expanded club bulletin 0
    28 Play N8DNX repeater bulletins 0
    280 Play expanded N8DNX bulletin 0
    29 Help with message commands 0
     
    30 Intra-system linking off 1
    31 Monitor W8GQN repeater from current repeater 1
    32 Link to W8GQN repeater from current repeater 1
    33 Monitor N8DNX repeater from current repeater 1
    34 Link to N8DNX repeater from current repeater 1
    35 Monitor KO8P repeater from current repeater 1
    36 Link to KO8P repeater from current repeater 1
    38 {node#} Connect to IRLP node {node#} 0
    38 73 Disconnect or stop playing audio news program 0
    38 0001 Play ARRL Audio News (must be linked to IRLP) 0
    38 0002 Play Amateur Radio Newsline (must be linked to IRLP) 0
    38 0003 Play This Week in Amateur Radio (must be linked to IRLP) 0
    38 0101 Play Pelston Airport Weather (must be linked to IRLP) 0
    38 0102 Play stats on last IRLP connection (must be linked to IRLP) 0
    38 0103 Play Propagation report (must be linked to IRLP) 0
    38 0104 Play list of nearby APRS stations (must be linked to IRLP) 0
    38 0199 Play a silly message (must be linked to IRLP) 0
    39 Help with intra-system linking Messages 0
     
    40 Link Off 0
    41 Toggle link Transmit On/Off 0
    400 Link to 146.74 repeater (from current repeater) 1
    401 Link to IRLP (from current repeater) 1
    410 Link to 29.6 FM (from current repeater) 1
    49 Help with inter-system linking commands 0
     
    50 External linking / Remote Base off 1
    51 Enter remote base mode (UHF repeater only per Part 97) 1
    52 Toggle TX/RX for current link (pending) 1
    500 Link to 146.740 repeater (pending) ??????? 1
    59 Help with remote base commands 0
     
    60 Listen to weather radio - 2 minutes 0
    61 Stop listening to weather radio 0
    62 Replay last recorder weather alert 0
    63 Outside temperature (pending) 0
    64 Wind speed (pending) 0
    69 Help with weather related commands 0
     
    70 List who is currently logged in 0
    71 {user#} {pass} Log into system as user {user#} with passcode {pass} 0
    72 Log out of system 1
    79 Help with user access commands 0
     
    80 {digits} Touch tone pad test - repeat {digits} 0
    81 Audio test - replay next transmission
    + Enter command 81, wait for the courtesy tone, key up and speak
    0
    89 Help with test commands 0
     
    90 Total system status report 0
    91 Backup battery current 0
    92 Backup battery voltage 0
    93 DC supply voltage 0
    94 Date and Time
    95 Room Temperature 0
    97 Report received signal strength - (UHF Repeaters Only)
    + Reported in dbm.
    0
    98 UHF receive preamp current (should be about 220ma). 0
    99 Help with system status commands 0
     
    999 System information and help overview 0
    +

    +  +

    + +

    Remote Base User's Manual

    +

    +The remote base system is capable of receiving from .1 to 30 MHz, transmitting on the HF Ham bands, and receiving and +transmitting on the 50 MHz, 144 MHz, 220 MHz, and 440 MHz Ham bands using LSB, USB, AM, and FM modes. There is also +a CW mode, but as there is no way to remotely key the transmitter, it's of little practical use other than receiving. +

    +Note: There may be transmitting limitations due to the antennas connected to the remote base. As of this time, +the HF transmit antenna is only useable on 20 Meters and above and there is not yet a 50 MHz antenna on the system. +Expanded antenna systems are in the works and will be installed in the Spring of 2002. Please contact N8DNX for current +information. +

    +Operation of the remote base system will seem daunting at first, but you'll soon find that commonly used functions will +be easy to remember and start to make sense. It's however suggested that you cut out the "Remote Base Quick Reference +Guide" and have it available whenever operating the remote base. +

    +

    The Remote Base and the Law

    +

    +According to 97.3 (38) of the FCC rules, operation of the Remote Base is considered "Remote Control" of an amateur radio +station. A remotely controlled station must be controlled using certain frequencies above 220 MHz. As such, operation +of the Remote Base system is not permitted on the W8GQN VHF repeater. Remote base operation is therefore only permitted +on the N8DNX UHF repeaters. +

    +A station operating under remote control may not be "automatically controlled". When you use the remote base system, +you are the control operator of that remotely controlled station. As such, you should identify the remote base using your +own call letters. The proper way to identify would be "This is {your call} remote base". If you wish to be more precise, +you may identify with "This is {your call} operating the N8DNX remote base". Please follow all requirements for +identification when operating the remote base system. +

    +Since you are the control operator when you operate the remote base system, you are fully responsible for its operation. +Do not leave the remote base system enabled when you are not available to monitor or control its operation. +

    +You may allow others users on the repeater to operate through the remote base while you are in control, even if their +license class does not permit them to operate on the frequency or mode you have set. This is analogous to permitting +someone else to talk into the microphone of your home station while you are at the controls. You are, however, fully +responsible for their use of the remote base and you must properly identify the remote base operation with your call letters +as mentioned above. +

    +

    Turning on the Remote Base System

    +

    +You will need to log into the system before turning on the remote base system. Your user ID is assigned according to your +license class. When you log into the system with your ID and Pass Code, the system will know what license class you have +and will limit the frequencies on which you can transmit accordingly. Once you're logged in, enter command code 50 to turn +on the remote base. You cannot enter commands to the remote base system if you are not logged in! +

    +When you turn on the remote base system, you will only be able to enter commands to the remote base system and will not +be able to use the set of normal control codes. To enter normal control codes, you must first turn off the remote base. +

    + +

    Remote Base Command Codes

    +

    +All remote base commands begin with a "7". This access digit prevents accidentally entering a short, single digit, command. +The next digits of the command designate specific function and any additional digits that need to be specified. +

    +You will note that there is some logic to how these commands are laid out on a normal Touch Tone pad. For example, +all of the commands to bump the frequency down are located on the left column while all of the commands to bump the +frequency up are located on the right column (with the exception of "7 A" and "7 B", isn't there always an exception). +As you learn these commands, think more about their location on the keypad and less about the actual command numbers and +you may find them easier to remember. +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Command: Receive Only
    Codes to execute: 7 1
    Description: + Use this command to switch the remote base from receive/transmit to receive only mode. + (Transmitting into the repeater will not cause the remote base to transmit.) The remote base + will always start in receive only mode, so this command is not necessary to begin receiving + after turning on the remote base system. +

      +

    Command: Set Radio Mode
    Codes to execute: 7 1 {mode}
    Description: + This command sets the mode of operation for the radio. +

    + Where {mode} is: 1 = USB, 2 = LSB, 3 = AM, 4 = FM, 5 = CW +

      +

    Command: Receive/Transmit
    Codes to execute: 7 2
    Description: + This command places the remote base in receive/transmit mode. When in receive/transmit mode, + transmitting into the repeater will cause the remote base to transmit. To return to receive + only mode, use command 7 1. +

    + Note: You can only select frequencies on which you are allowed to transmit when in + receive/transmit mode. +

      +

    Command: Toggle PL Receive
    Codes to execute: 7 2 1
    Description: + This command toggles PL receive on and off. When this PL receive mode is selected, the + receiver squelch will not open unless the correct PL tone is being received. +

    + Note: This will only work on the 50 MHz, 144 MHz, 220 MHz and 440 MHz bands when in + FM mode and with PL transmit enabled (7 2 2). +

      +

    Command: Toggle PL Transmit
    Codes to execute: 7 2 2
    Description: + This command toggles PL transmit on and off. When PL transmit mode is selected, the remote + base will transmit the selected PL tone. +

    + Note: This will only work on the 50 MHz, 144 MHz, 220 MHz and 440 MHz bands when in FM mode. +

      +

    Command: Turn Off PL Receive and Transmit
    Codes to execute: 7 2 3
    Description: + This command turns off both receive and transmit PL modes. +

      +

    Command: Announce Receive and Transmit PL Settings
    Codes to execute: 7 2 8
    Description: + When you enter this command, the remote base system will announce the current PL receive and + transmit settings. +

      +

    Command: Set PL Frequency
    Codes to execute: 7 2 {Hz}
    Description: + This command sets the PL frequency. The value {Hz} is the four digits of the PL frequency. + For example "7 2 1072" will set the PL frequency to 107.2 Hz. Only standard PL tone frequencies may be used. +

    + Note: DO NOT include a "*" for decimal point as is the case when setting the radio frequency. +

      +

    Command: Turn Off the Remote Base System
    Codes to execute: 7 3
    Description: + Enter this command to turn off and exit the remote base system. This will return to you normal + repeater operation and the normal set of repeater control commands. The remote base will not + transmit when off, so there is no need to turn off receive/transmit mode (using 7 1) prior to + turning off the remote base system. +

      +

    Command: Bump Frequency Down 100 Hz
    Codes to execute: 7 4
    Description: + Entering this command will change the current VFO setting down 100 Hz. Use this command to make + small adjustments to the remote base frequency. If you are in receive/transmit mode, you will + not be allowed to go beyond the edge of the permitted transmit frequency range on the current band. +

      +

    Command: Select VFO "A"
    Codes to execute: 7 5
    Description: + This command selects VFO "A". The remote base system has two VFO's "A" and "B". Switching VFOs + will restore the remote base to the frequency and mode it was on when that VFO was last used. +

    + Note: The remote base system uses separate radios for HF and VHF/UHF operation. When + switching VFO's results in the remote base having to switch radios, the system will automatically + turn off the remote base, reconfigure it for the correct radio, and ask you to turn it back on. + (For reasons beyond the scope of this document, it was not possible to make this process fully automatic.) +

      +

    Command: Recall Memory
    Codes to execute: 7 5 {memory #} (Memory numbers 1 or 2 digits 0 through 99)
    Description: + Use this command to recall the contents of the specified memory into the current VFO and set + the frequency, mode, offset and other data that was stored in that memory. +

      +

    Command: Bump Frequency Up 100 Hz
    Codes to execute: 7 6
    Description: + Entering this command will change the current VFO setting up 100 Hz. Use this command to make + small adjustments to the remote base frequency. +

      +

    Command: Bump Frequency Up 100 Hz
    Codes to execute: 7 6
    Description: + Entering this command will change the current VFO setting up 100 Hz. Use this command to make + small adjustments to the remote base frequency. If you are in receive/transmit mode, you will not be + allowed to go beyond the edge of the permitted transmit frequency range on the current band. +

      +

    Command: Bump Frequency Down 500 Hz
    Codes to execute: 7 7
    Description: + Entering this command will change the current VFO setting down 500 Hz. Use this command to make + small adjustments to the remote base frequency. If you are in receive/transmit mode, you will + not be allowed to go beyond the edge of the permitted transmit frequency range on the current band. +

      +

    Command: Scan Up or Down in Frequency
    Codes to execute: 7 7 {speed}
    Description: + Entering this command with the desired speed will cause the remote base to scan up or + down at various speeds. The remote base will continue to scan, stopping periodically to + announce the frequency. You can stop scanning by transmitting briefly into the repeater. +

    + Where {speed} is: + + + + +
    1 = Down Slow 3 = Up Slow
    4 = Down Medium 6 = Up Medium
    7 = Down Fast 9 = Up Fast
    +

      +

    Command: Announce Current Settings
    Codes to execute: 7 8
    Description: + This command causes the remote base to announce the current frequency, offset (if not zero), + and the selected VFO. +

      +

    Command: Turn Off Transmit Offset
    Codes to execute: 7 8 0
    Description: + This command will turn off any current transmit offset setting (such as a repeater offset). + After entering this command, the remote base will transmit on the same frequency as it receives. +

      +

    Command: Turn On Transmit Offset
    Codes to execute: 7 8 1
    Description: + This command will turn on transmit off set and use the offset frequency that was last set. + After entering this command, the remote base will transmit on a frequency that is different + from the receive frequency by the amount of the frequency offset set with command "7 8 1 x x". +

      +

    Command: Turn On Transmit Offset and Set Offset Direction
    Codes to execute: 7 8 1 {direction}
    Description: + This command is similar to "7 8 1" except that it specifies the offset direction, either + plus or minus, from the receive frequency. +

    + Where {direction} is: 0 = Positive Offset, 1 = Negative Offset +

      +

    Command: Turn On Transmit Offset and Set Direction and Size
    Codes to execute: 7 8 1 {direction} {size}
    Description: + Entering this command will change the current VFO setting down 100 Hz. Use this command + to make small adjustments to the remote base frequency. If you are in receive/transmit mode, + you will not be allowed to go beyond the edge of the permitted transmit frequency range on the current band. +

    + Where {size} is: + + + + + + +
    0 = 0 KHz 5 = 1.6 MHz
    1 = 100 KHz 6 = 1.7 MHz
    2 = 500 KHz 7 = 5 MHz
    3 = 600 KHz 8 = 12 MHz
    4 = 1 MHz 9 = 20 MHz
    +

      +

    Command: Bump Frequency Up 500 Hz
    Codes to execute: 7 9
    Description: + Entering this command will change the current VFO setting up 500 Hz. Use this command to + make small adjustments to the remote base frequency. If you are in receive/transmit mode, + you will not be allowed to go beyond the edge of the permitted transmit frequency range + on the current band. +

      +

    Command: Select VFO "B"
    Codes to execute: 7 0
    Description: + This command selects VFO "B". The remote base system has two VFO's "A" and "B". + Switching VFOs will restore the remote base to the frequency and mode it was on when + that VFO was last used. +

    + Note: The remote base system uses separate radios for HF and VHF/UHF operation. + When switching VFO's results in the remote base having to switch radios, the + system will automatically turn off the remote base, reconfigure it for the correct + radio, and ask you to turn it back on. (For reasons beyond the scope of this document, + it was not possible to make this process fully automatic.) +

      +

    Command: Write Memory
    Codes to execute: 7 5 {memory #} (Memory numbers are 1 or 2 digit 0 through 99)
    Description: + Use this command to write the contents of the specified memory into the current VFO + and set the frequency, mode, offset and other data that was stored in that memory. +

      +

    Command: Bump Frequency Up 20 Hz
    Codes to execute: 7 A
    Description: + Entering this command will change the current VFO setting up 20 Hz. Use this + command to make small adjustments to the remote base frequency. If you are in + receive/transmit mode, you will not be allowed to go beyond the edge of the + permitted transmit frequency range on the current band. +

      +

    Command: Bump Frequency Down 20 Hz
    Codes to execute: 7 B
    Description: + Entering this command will change the current VFO setting down 20 Hz. Use this + command to make small adjustments to the remote base frequency. If you are in + receive/transmit mode, you will not be allowed to go beyond the edge of the permitted + transmit frequency range on the current band. +

      +

    Command: Enter Frequency
    Codes to execute: 7 {frequency}
    Description: + Use this command to set the frequency of the remote base. Use the "*" key to specify + the decimal point between MHz and KHz. If you do not use the "*" key, it will not be + interpreted as a frequency. +

    + Where {frequency} is: MHz followed by "*" followed by KHz +

    + Examples: + + + + +
    7 14*292 14.292 MHz
    7 146*68 146.680 MHz
    7 0*100 100 KHz (Loran)
    +

    + Note: The remote base system uses separate radios for HF and VHF/UHF operation. + When the frequency change results in the remote base having to switch radios, the + system will automatically turn off the remote base, reconfigure it for the correct + radio, and ask you to turn it back on. (For reasons beyond the scope of this document, + it was not possible to make this process fully automatic.) +

    + Note: If the remote base is in receive/transmit mode, it will not permit you to + select a frequency on which you are not permitted to transmit. To select such a frequency, + use "7 1" to return to receive only mode, then select the desired frequency. +

      +

    +

    +  +

    + + +

    Remote Base Quick Reference Guide

    +

    +The following guide is a quick reference for Remote Base commands. It is arranged to be similar to the +layout of a normal Touch Tone keypad. This reference chart should make sense if you are familiar with the +Remote Base commands listed above. Please use this only as a quick reference, and not as a guide to +Remote Base operation. +

    + + + + + + + + + + +
    + + + + +
    71 RX Only
    71 {Mode} HF Mode
    + (Mode = 1 USB, 2 LSB, 3 AM, 4 FM, 5 CW)
    771 Scan Down Slow
    +
    + + + + + + + +
    72 RX and TX
    72 {Hz} Set PL Frequency
    721 RX PL On/Off
    722 TX PL On/Off
    723 PL Off
    728 Recall PL
    +
    + + + +
    73 Exit HF Mode
    773 Scan Up Slow
    +
    + + +
    7A Bump Up 20 Hz
    +
    + + + + +
    74 Bump Down 100Hz
    74 {cmd} Execute Command
    774 Scan Down Medium
    +
    + + + +
    75 Select VFO A
    75 {mem} Recall Memory
    +
    + + + +
    76 Bump Up 100 Hz
    776 Scan Up Medium
    +
    + + +
    7B Bump Down 20 Hz
    +
    + + + +
    77 Bump Down 500 Hz
    777 Scan Down Fast
    +
    + + + + + + + + + + + +
    78 Recall Current VFO
    780 TX Offset Off
    781 TX Offset On
    781{x} [{y}] TX Offset Setting
    + (x = 0 Plus, 1 Minus)
    0 = 0 KHz 1 = 100 KHz
    2 = 500 KHz3 = 600 KHz
    4 = 1 MHz 5 = 1.6 MHz
    6 = 1.7 MHz7 = 5 MHz
    8 = 12 MHz 9 = 20 MHz
    +
    + + +
    79 Bump Up 500 Hz
    +
    +   +
    + + +
    * Use as decimal point
    +
    + + + +
    70 Recall VFO B
    70 {mem} Write Memory
    +
    + + +
    # Force Execution
    +
    +   +
    + + + + diff --git a/static/60.phtml b/static/60.phtml new file mode 100644 index 0000000..b26f2d6 --- /dev/null +++ b/static/60.phtml @@ -0,0 +1,18 @@ + + + + + + +
    + + + + diff --git a/static/62.phtml b/static/62.phtml new file mode 100644 index 0000000..fa583ea --- /dev/null +++ b/static/62.phtml @@ -0,0 +1,21 @@ +

    + + +
    +

    +We would like to cover additional areas of the Great Lakes. If you have a high-profile +antenna site and would like to participate, contact me at shiptracking@n8dnx.org or see +THIS PAGE. diff --git a/static/logo_real.gif b/static/logo_real.gif new file mode 100755 index 0000000..083532a Binary files /dev/null and b/static/logo_real.gif differ diff --git a/static/player.swf b/static/player.swf new file mode 100644 index 0000000..d333d13 Binary files /dev/null and b/static/player.swf differ diff --git a/static/qt_icon.gif b/static/qt_icon.gif new file mode 100755 index 0000000..da692e6 Binary files /dev/null and b/static/qt_icon.gif differ diff --git a/static/swfobject.js b/static/swfobject.js new file mode 100644 index 0000000..e7edd42 --- /dev/null +++ b/static/swfobject.js @@ -0,0 +1,8 @@ +/** + * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/ + * + * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + * + */ +if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="";_19+="";var _1d=this.getParams();for(var key in _1d){_19+="";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="";}_19+="";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.majorfv.major){return true;}if(this.minorfv.minor){return true;}if(this.rev=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject; \ No newline at end of file diff --git a/styles.css b/styles.css new file mode 100755 index 0000000..b936740 --- /dev/null +++ b/styles.css @@ -0,0 +1,117 @@ +/*font*/ +body, table, td {font-family: arial, helvetica, sans-serif; font-size: 13px;} +/*links*/ +a {font-weight: bold;} +a:link {color: #0A328C;} +a:visited {color: #0A328C;} +a:active {color: #0A328C;} +a:hover {color: #000;} + +body {margin: 0; padding: 0;} +#wrap {} + +/*main header */ +#top { + background-color: #0A328C; + background-image: url(assets/bg.jpg); + background-repeat: no-repeat; + border-bottom: 8px solid #D1C9BE; + height: 96px; + } + +#top h1 { + color: #fff; + padding: 20px 10px; + margin: 0; + text-align: left; + } +#top h1 img {float: right; margin-top: -15px; margin-right: -10px;} +* html #top h1 img { margin-right: -13px; } +div#tagline {font-size: 16px;} +#content { + float: left; + width: 600px; + background-color: white; + border-left: 1px solid #0A328C; + padding-bottom: 10px;} +/*toolbox */ +#category {margin-left: 10px; } +#category h1 { + background-color: transparent; + color: #000; + background-image: none; + font-size: 18px; + padding: 1em 0 0 0; + border-bottom: 1px solid #D1C9BE; + text-align: left; + } +h2 {font-size: 16px; margin:1em 0 0.5em 0; } +p {margin: 0 0 1em 0;} +.listing {margin-left: 10px;clear:both; } +.imageright {float: right; clear: right; position: relative; margin: 0 0 10px 10px;} +.imageleft {float: left; clear: left; position: relative; margin: 0 10px 10px 0;} + +#staff {margin-left: 10px; margin-top: 10px; } +/* copyright*/ +#copyright { + font-size: 12px; + font-weight: bold; + background-color: #0A328C; + color: #fff; + padding: 10px; + margin: 0; + background-image: url(assets/bg.jpg); + background-repeat: no-repeat; + clear: both; + } + +/* nav */ + +#navleftcontainer {float: left; position: relative;} + +#navleftcontainer ul +{ +margin: 0; +padding: 0; +list-style-type: none; +font-family: verdana, arial, Helvetica, sans-serif; +width: 150px; +} + +#navleftcontainer li { margin: 0 0 1px 0; padding: 0;} + +#navleftcontainer a +{ +display: block; +padding: 5px 10px; +/*width: 140px;*/ +color: #0A328C; +background-color: #0A328C; +background-color: #fff; + +text-decoration: none; +font-size: 12px; +font-weight: bold; +} + +#navleftcontainer a:hover +{ +color: #000; +text-decoration: none; +} + +#navleftcontainer ul ul li { margin: 1px 0 0 0; padding: 0;} + +#navleftcontainer ul ul a +{ +display: block; +padding: 5px 5px 5px 20px; +/*width: 125px;*/ +/*background-color: #4B68B8; */ +text-decoration: none; +} +#navleftcontainer ul ul ul a {padding: 5px 5px 5px 40px;} +#navleftcontainer ul ul a:hover +{ +text-decoration: none; +} diff --git a/test.phtml b/test.phtml new file mode 100644 index 0000000..f7373fb --- /dev/null +++ b/test.phtml @@ -0,0 +1,12 @@ + diff --git a/tophome.php b/tophome.php new file mode 100755 index 0000000..047037e --- /dev/null +++ b/tophome.php @@ -0,0 +1,32 @@ +

    + +

    Welcome to Petoskey and Ham Radio in Northern Michigan + + + +
    +
    + +

    + +Chuck Scott   +webfeedback@n8dnx.org +

    + +
    + diff --git a/video/letitsnow_xmas_greeting_generic.flv b/video/letitsnow_xmas_greeting_generic.flv new file mode 100644 index 0000000..797418a Binary files /dev/null and b/video/letitsnow_xmas_greeting_generic.flv differ diff --git a/view.phtml b/view.phtml new file mode 100755 index 0000000..4342a1a --- /dev/null +++ b/view.phtml @@ -0,0 +1,30 @@ + + + + <?php echo SITENAME?> + + + + + +
    + > +'.stripslashes(strip_tags($title)).'':''?> +
    + +