| [ PHPXref.com ] | [ Generated: Sun Jul 20 16:25:17 2008 ] | [ ActionApps 2.8.1b ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Allows to POST data to a PHP script SSI-included in a .shtml page. 4 * 5 * You can't use the POST method directly for .shtml pages, you must always use GET, 6 * which has several disadvantages: the length of all parameters is limited by 7 * a small size and the parameters appear in the URL. 8 * 9 * But post2shtml helps you. Instead of using 10 * <form action="some_page.shtml" method="get"> 11 * you write 12 * <form action="/aa/post2shtml.php3?shtml_page=some_page.shtml" method="post"> 13 * 14 * The script works in these steps: 15 * 16 * 1. All the data coming in POST, GET, COOKIES and FILES is serialized and stored 17 * into the database, table post2shtml, with a new unique ID post2shtml_id 18 * 2. The web server is redirected to "some_page.shtml?post2sthml_id=aa45db3d345de..." 19 * 3. The web server parses the page "some_page.shtml" and comes to some 20 * SSI include like <!--#include virtual="/aa/some_script.php3"-->. It calls 21 * the PHP script some_script.php3. 22 * 4. some_script.php3 knows it may be called this way and thus uses the post2shtml_id 23 * to find the right row in the post2shtml table and thus 24 * retrieve the form data with the function add_post2shtml_vars() 25 * from include/util.php3. 26 * 27 * One additional feature: 28 * You can send passwords, which are stored encrypted by MD5: all members of 29 * a md5[] array will be encrypted and stored outside the array. For example if you 30 * add <INPUT TYPE=password NAME="md5[password]"> then after calling 31 * add_post2shtml_vars() a global variable $password contains the encrypted password. 32 * (CHANGE: 06/19/2003 Honza - we no longer call md5() function on passwords - 33 * we call crypt($password,'xx') function instead. crypt() is used for storing 34 * passwords to database (@see /include/itemfunct.php3 insert_fnc_pwd()) - it 35 * uses MD5 on some systems (but on other systems it uses DES?, ...)) 36 * 37 * Parameters: <br> 38 * URL $shtml_page = complete URL of the requested .shtml page 39 * 40 * If you do not send $shtml_page, no HTTP headers are sent and the post2shtml_id 41 * is set as a global variable. 42 * 43 * @package UserInput 44 * @version $Id: post2shtml.php3,v 1.14 2005/04/24 21:48:11 honzam Exp $ 45 * @author Jakub Adámek, Econnect, December 2002 46 * @copyright Copyright (C) 1999-2002 Association for Progressive Communications 47 */ 48 /* 49 Copyright (C) 1999, 2000 Association for Progressive Communications 50 http://www.apc.org/ 51 52 This program is free software; you can redistribute it and/or modify 53 it under the terms of the GNU General Public License as published by 54 the Free Software Foundation; either version 2 of the License, or 55 (at your option) any later version. 56 57 This program is distributed in the hope that it will be useful, 58 but WITHOUT ANY WARRANTY; without even the implied warranty of 59 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 60 GNU General Public License for more details. 61 62 You should have received a copy of the GNU General Public License 63 along with this program (LICENSE); if not, write to the Free Software 64 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 65 */ 66 67 // post2shtml could be include from other files, where config.php3 is already 68 // required (and probably is on another path) 69 if ( !defined('DB_NAME') ) { 70 require_once "./include/config.php3"; 71 } 72 require_once $GLOBALS['AA_INC_PATH']."locsess.php3"; 73 require_once $GLOBALS['AA_INC_PATH']."util.php3"; 74 75 store_vars (); 76 77 // Store variables, set $GLOBALS[post2shtml_id] or generate Location header 78 function store_vars () 79 { 80 global $shtml_page; 81 if ($GLOBALS[debugfill]) huhl("post2html:store_vars:$shtml_page:"); 82 83 $vars = array ( 84 "post" => &$GLOBALS["HTTP_POST_VARS"], 85 "get" => &$GLOBALS["HTTP_GET_VARS"], 86 "files" => &$GLOBALS["HTTP_POST_FILES"], 87 "cookie" => &$GLOBALS["HTTP_COOKIE_VARS"]); 88 89 reset ($vars); 90 while (list ($key) = each ($vars)) { 91 $var = &$vars[$key]; 92 if (is_array($var["md5"])) { 93 md5_array ($var["md5"]); 94 add_var2 ($var["md5"], $var); 95 unset ($var["md5"]); 96 } 97 } 98 99 $vars = addslashes (serialize ($vars)); 100 101 $id = new_id(); 102 $db = getDB(); 103 $db->query(" 104 INSERT INTO post2shtml (id, vars, time) 105 VALUES ('$id', '$vars', ".time().")"); 106 freeDB($db); 107 if ($shtml_page) { 108 header("Status: 302 Moved Temporarily"); 109 $shtml_page = stripslashes ($shtml_page); 110 $shtml_page .= (strchr ($shtml_page,"?") ? "&" : "?") . "post2shtml_id=$id"; 111 if ($debugfill) huhl("post2shtml:Location=$shtml_page"); 112 header("Location: $shtml_page"); 113 } 114 else $GLOBALS["post2shtml_id"] = $id; 115 } 116 117 function md5_array (&$array) { 118 // uses crypt() instead of md5() - Change by honza 06/19/2003 (see top) 119 if (is_array($array)) { 120 reset ($array); 121 while (list ($key) = each ($array)) 122 md5_array ($array[$key]); 123 } 124 else if ($array) 125 $array = crypt( $array, 'xx'); 126 } 127 128 /** Adds all values from the $source array to the $dest array. Follows all paths 129 * in order that all values present in $dest and not in $source are kept. 130 */ 131 function add_var2 (&$source, &$dest) { 132 if (is_array($source)) { 133 reset ($source); 134 while (list ($key) = each ($source)) 135 add_var3 ($key, $source[$key], $dest); 136 } 137 } 138 139 /** Recursively adds all values from the $source array to the $dest array. Follows all paths 140 * in order that all values present in $dest and not in $source are kept. 141 */ 142 function add_var3 ($varname, &$source, &$dest) { 143 if (is_array($source)) { 144 reset ($source); 145 while (list ($key) = each ($source)) 146 add_var3 ($key, $source[$key], $dest[$varname]); 147 } 148 else if (isset ($source)) 149 $dest[$varname] = $source; 150 } 151 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |