Category Archives: Syntax

php script that picks quotes from

Random PHP Quote is a simple php script that picks quotes from a text file and displays on a webpage. It provides a password protected admin panel to add, edit the quotes.Layout can be easily changed and the script is very easy to install, use and customize.

<!-- Random PHP Quote Copyright Scriptsez.net Get it free at http://www.scriptsez.net -->
<?php
extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
if($action==""){
?>
<style>
TABLE {
 BORDER-RIGHT: #345487 1px solid; BORDER-TOP: #345487 1px solid; BORDER-LEFT: #345487 1px solid;
 BORDER-BOTTOM: #345487 1px solid; FONT-SIZE: 11px; COLOR: #000; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif
}
TD {
 BORDER-RIGHT: #345487 1px solid; BORDER-TOP: #345487 1px solid; BORDER-LEFT: #345487 1px solid; BORDER-BOTTOM: #345487 1px solid; BACKGROUND-COLOR: #f5f9fd
}</style>
<?php
$text_file = 'file.txt';   //file that contains all the quotations
$content = file ($text_file);
$size_of_file = (count($content))-1;
$line_to_choose = rand (0, ($size_of_file));
$line = $content[$line_to_choose];
$display=explode ("|~~|",$line);
if(strlen($display[2])>="1"){
$aut="<hr color=#345486  noshade size=1 width=95%>By: $display[2]";
}else{
$aut="";
}
echo "<table width=25% border=1><tr><td>Random Quote</td><tr><td>$display[1] $aut</td></tr></table>";
}
if($action == "admin"){
?><center><table align=middle><td align=left width=20%>
<tr><td height="27" colspan="2"><FONT SIZE="4" COLOR="#000000">:: Random PHP Quote ::</FONT></td><tr><td>Password Required (Default is: administrator)</td></tr><tr><form method=post action="?action=login"><td>Password:</td><td><input type=password name=pass>&amp;nbsp;<input type=submit value=Submit></td></tr></form></table></center>
<?php
}
$mo=  "pwd.txt";
$bd = fopen ($mo, "r");
$psord = fread ($bd, filesize ($mo));
fclose ($bd);
$rop=base64_decode($psord);
$vup=explode("vylkp!-1/\*||&amp;@23||*~`.*%/|//\%@!||&amp;~||a",$rop);
$password=base64_decode($vup[0]);
if ($action=="login"){
if(strlen($m)>="1"){
$n=base64_decode($m);
$pass=$n;
}
if ($pass==$password){
echo "Successfully Loged In<br><hr>";
$m=base64_encode($password);
echo"<table align=left width=80%><tr><td><A HREF=?action=add_q&amp;m=$m>Add a Quote</A></td></tr><tr><td><A HREF=?action=edit_q&amp;m=$m>Edit Quotes</A></td></tr><tr><td><A HREF=?action=change_password&amp;m=$m>Change Password</A></td></tr><tr><td><A HREF=?action=admin>Logout</A></td></tr></table>";
}else {
echo "Invalid Passsword";
}
}
if($action=="change_password"){
$l=base64_decode($m);
if ($l==$password){
echo "<form method=post action=?action=do_change_password><table><tr><td>Enter new password</td><td><input type=password size=18 name=pwd></td><tr><td>Confirm new password</td><td><input type=password size=18 name=qwd><input type=hidden name=m value=$m><td><tr><td></td><td><input type=submit value=Change></td></tr></table></form>";
}else{echo "Please Login Again"; }
}
if ($action=="do_change_password"){
$l=base64_decode($m);
if($l==$password){
if($pwd==$qwd){
$po="pwd.txt";
$fgh=base64_encode($pwd);
$asd=base64_encode("$fgh"."vylkp!-1/\*||&amp;@23||*~`.*%/|//\%@!||&amp;~||a");
$vp = fopen ($po, "w");
fwrite ($vp, "$asd");
fclose($vp);
echo "Password has been successfully changed. <BR><a href=?action=admin>Login Again</a>";
}else{
echo "Please go back, change password and confirm new password donot match";
}
}else{ echo "Please Login Again"; }
}
if ($action=="add_q"){
$l=base64_decode($m);
if ($l==$password){
echo "<form method=post action=?action=do_add_q>Add a quote<table><tr><td><FONT COLOR=red>*</FONT> Quote:</td><td> <textarea rows=8 cols=28 name=quote></textarea></td></tr><tr><td><input type=hidden name=m value=$m>Author:</td><td><input type=text name=author size=28></td></tr><tr><td></td><td><input type=submit value=' Add '></td></tr></table></form><BR><FONT COLOR=red>*</FONT> = Required<BR><a href=?action=login&amp;m=$m>Back To main Menu</a>";
}else{
echo "Please Login Again";
}
}
if ($action=="do_add_q"){
$quote = stripslashes ($quote);
$author = stripslashes ($author);
$quote = str_replace ("\n","<br>", $quote);
$quote = str_replace ("|~~|","|~|", $quote);
$author = str_replace ("|~~|","|~|", $author);
$l=base64_decode($m);
if ($l==$password){
$io="file.txt";
$vd = fopen ($io, "a+");
fwrite ($vd, "[quote]|~~|");
fwrite ($vd, "$quote");
fwrite ($vd, "|~~|");
fwrite ($vd, "$author");
fwrite ($vd, "|~~|");
fwrite ($vd, "\n");
fclose($vd);
echo "Quote has been added successfully. <BR><a href=?action=login&amp;m=$m>Back To main Menu</a>";
}else{
echo "Please Login Again";
}
}
if($action=="edit_q"){
$l=base64_decode($m);
if ($l==$password){
$fd = fopen ("file.txt", "r");
$stuff = fread ($fd, filesize ("file.txt"));
fclose ($fd);
php?>
<body bgcolor="#ffffff">
<td height="399" width="100%" valign="top">
<form method="post" action="?action=temp3">
<input type=hidden name=m value="<?php echo $m; ?>">
<table width="100%" border="0" cellpadding="5" cellspacing="0">
<tr>
<td><font size="2" face=arial>Edit Quotes: (New Quote start from line starting with [quote])</font></td>
</tr>
<tr>
<td width="100%">
<textarea name="cont" cols="70" rows="20"><?php  echo $stuff ?></textarea>
</td>
</tr>
<tr>
<td width="86%">&amp;nbsp;
<input type="submit" name="Submit" value="Save"><input type="button" name="Cancel" value="Cancel" onclick="javascript: history.back(1)">
</td>
</tr>
<tr>
</tr>
</table>
</form>
<?php
}else{
echo "<FONT SIZE=2 COLOR=red>Please Login</FONT>";
}
}
if ($action=="temp3") {
$l=base64_decode($m);
if ($l==$password){
$cont=$HTTP_POST_VARS['cont'];
$cont=stripslashes($cont);
$fp = fopen("file.txt", "w");
fputs($fp, $cont);
fputs($fp, "\n");
fclose($fp);
php?>
<body bgcolor="#ffffff">
<BR><BR><font size="2" face=arial>Quotes Edited Successfully<BR></font><BR><a href="?action=login&amp;m=<?php echo $m; ?>">Back To main Menu</a><BR>
<?php
}else{ echo "Please Login"; }
}
?>

Oracle Editor php Scripts for Syntax

OracleEditor.php is a standalone PHP script which allows you to browse your Oracle database tables and insert, update, and delete rows in any table. It requires no installation and no configuration. Features: – Connects to any Oracle database (local databases, aliases from tnsnames.ora, or complete connection strings) – Lists all tables and views owned by the user, and those owned by other users where access has been granted – Simply select a table or view to display (SELECT) its records Modify the list of fields to select (optional) – Add a WHERE clause (optional)

<?php
/*
 OracleEditor.php
 $Revision: 1.20 $
 by Tim Strehle <tim@strehle.de>

 http://oracleeditor.sourceforge.net/

 OracleEditor.php is a standalone PHP script which allows you to browse
 your Oracle database tables and insert, update and delete rows in any
 table. It requires no installation and no configuration.

 I wrote it for situations where you quickly need to do some small data
 manipulation and don't have a better tool available. OracleEditor.php is
 free and Open Source.
 Feel free to contact me at tim@strehle.de with questions/comments.

 Disclaimer:
 Use this software at your own risk. I won't guarantee that it works, and
 I won't be held liable for any damage caused by it!

 Please make sure to protect this script with a .htaccess password or the
 like - never ever allow public access to it. Anyone capable of guessing
 your database login will be able to cause severe damage to your database.

 $Id: OracleEditor.php,v 1.20 2006/05/12 21:30:40 tim Exp $

 $Log: OracleEditor.php,v $
 Revision 1.20  2006/05/12 21:30:40  tim
 Allow slash and colon in service name for Oracle Instant Client connection
 syntax. Allow dollar sign in user name.
 Now works with php.ini setting "short_open_tag = Off".

 Revision 1.19  2005/06/28 09:11:54  tim
 For UTF-8 detection, use getenv('NLS_LANG') instead of $_SERVER[ 'NLS_LANG' ].

 Revision 1.18  2005/06/10 14:49:09  tim
 Added PHP version and required module check.
 Added "online help" via the HTML title attribute.
 Selecting a new table or modifying the SQL statement now cancels export mode.
 Make the browser scroll to the row to insert/update/delete row.
 When switching from popup to manual SQL entry mode, the current SELECT
 statement is used to pre-fill the SQL statement textarea.

 Revision 1.17  2004/11/17 11:04:22  tim
 Now working with the php.ini setting "magic_quotes_gpc = On" as well.
 Added accesskeys to buttons and links and automatically focusing form
 fields on page load for fast keyboard navigation.
 Added set size "1000".
 Displaying some Oracle-related environment variables at the bottom.

 Revision 1.16  2004/04/27 12:33:02  tim
 Beautified the displayed version string.

 Revision 1.15  2004/04/27 12:19:31  tim
 Added export format "HTML table".
 The table popup now shows other Oracle user's tables if the current user
 is allowed to access them.
 Use CVS revision number for the version number.

 Revision 1.14  2004/01/07 09:59:00  tim
 Allow dollar sign in table names.

 Revision 1.13  2003/11/28 13:40:39  tim
 Fixed empty columns not being exported in CSV format.

 Revision 1.12  2003/11/28 13:07:44  tim
 Added XML and CSV export.
 Session ID is now passed along with GET/POST requests, allowing you to
 run OracleEditor in multiple browser windows (which wasn't possible with
 the cookie-based session ID).
 Fixed password validation bug, which filtered special characters from the
 password entered (you couldn't log in if your password was "$pecial").
 Added ocisetprefetch(), which might improve performance.

 Revision 1.11  2003/10/20 11:10:01  tim
 Set HTML character set to UTF-8 when the Oracle connection runs in UTF-8
 mode (as defined in the NLS_LANG environment variable).

 Revision 1.10  2003/10/10 09:24:39  tim
 Cosmetics - fixed "Insert new row" line missing one column.

 Revision 1.9  2003/09/26 11:31:02  tim
 Fixed rownumber INSERT bug.

 Revision 1.8  2003/09/24 08:38:30  tim
 Added row number display.

 Revision 1.7  2003/08/21 06:45:47  tim
 Added "Switch to manual SQL entry" option, allowing you to run arbitrary
 SQL including DML/DDL statements.

 Revision 1.6  2003/08/05 10:31:00  tim
 Display views as well.

 Revision 1.5  2003/05/26 09:45:17  tim
 Now rows from all tables can be edited, not only from tables which have a primary
 key defined. And the primary key need not be in the SELECT clause anymore to
 be able to edit rows.
 Debug mode logs all SQL statements in the PHP error_log.
 Fixed not moving to the first set after changes to the WHERE clause.

 Requirements:
 PHP 4 (version 4.1 or greater) with Session and OCI8 support.
 Works fine with the php.ini setting "register_globals = off",
 and regardless of the "magic_quotes_gpc" setting.
*/


// Don't write PHP warnings into HTML. Watch your PHP error_log file!

ini_set('display_errors', 0);

// Format version string

$version = trim(substr('$Revision: 1.20 $', 10, -1));

// Fix magic_quotes_gpc garbage

if (get_magic_quotes_gpc())
 { function stripslashes_deep($value)
 { return (is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value));
 }

 $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
 }

// To allow multiple independent OracleEditor sessions,
// propagate session ID in the URL instead of a cookie.

ini_set('session.use_cookies', '0');

// We'll add the session ID to URLs ourselves - disable trans_sid

ini_set('url_rewriter.tags', '');

// Initialize session ID

$sid = '';

if (isset($_REQUEST[ 'sid' ]))
 $sid = substr(trim(preg_replace('/[^a-f0-9]/', '', $_REQUEST[ 'sid' ])), 0, 13);

if ($sid == '')
 $sid = uniqid('');

// Start PHP session

session_id($sid);
session_name('OracleEditor');
session_start();

$setsizes = array( 10, 25, 50, 100, 1000 );

$exportformats = array(
 'xml'  => array( 'XML', 'text/xml' ),
 'csv'  => array( 'CSV', 'text/comma-separated-values' ),
 'html' => array( 'HTML table', 'text/html' ),
 );

if (! isset($_SESSION[ 'exportformat' ]))
 $_SESSION[ 'exportformat' ] = 'xml';

// Initialize database connection parameters

if ((! isset($_SESSION[ 'connection' ])) || isset($_REQUEST[ 'disconnect' ]))
 pof_blanksession();

if (isset($_REQUEST[ 'connection' ]))
 if (is_array($_REQUEST[ 'connection' ]))
 { pof_blanksession();

 if (isset($_REQUEST[ 'connection' ][ 'user' ]))
 $_SESSION[ 'connection' ][ 'user' ] = substr(trim(preg_replace('/[^a-zA-Z0-9$_-]/', '', $_REQUEST[ 'connection' ][ 'user' ])), 0, 30);

 if (isset($_REQUEST[ 'connection' ][ 'password' ]))
 $_SESSION[ 'connection' ][ 'password' ] = substr(trim($_REQUEST[ 'connection' ][ 'password' ]), 0, 30);

 if (isset($_REQUEST[ 'connection' ][ 'service' ]))
 $_SESSION[ 'connection' ][ 'service' ] = substr(trim(preg_replace('|[^a-zA-Z0-9:.() =/_-]|', '', $_REQUEST[ 'connection' ][ 'service' ])), 0, 2000);
 }

// Rather dumb character set detection:
// Try switching to UTF-8 automagically on stuff like "NLS_LANG=american_america.UTF8"

$charset = 'ISO-8859-1';

if (getenv('NLS_LANG'))
 if (strtoupper(substr(getenv('NLS_LANG'), -5)) == '.UTF8')
 $charset = 'UTF-8';

// Initialize debug mode

if (! isset($_SESSION[ 'debug' ])) $_SESSION[ 'debug' ] = false;
if (isset($_REQUEST[ 'debug' ])) $_SESSION[ 'debug' ] = ($_REQUEST[ 'debug' ] == 1);

// Initialize / drop DDL cache

if (! isset($_SESSION[ 'cache' ])) $_SESSION[ 'cache' ] = array();
if (isset($_REQUEST[ 'dropcache' ])) $_SESSION[ 'cache' ] = array();

// Initialize entry mode

if (! isset($_SESSION[ 'entrymode' ])) $_SESSION[ 'entrymode' ] = 'popups';

// Initialize SQL filter fields

if (! isset($_SESSION[ 'sql'     ])) $_SESSION[ 'sql'     ] = '';
if (! isset($_SESSION[ 'table'   ])) $_SESSION[ 'table'   ] = '';
if (! isset($_SESSION[ 'select'  ])) $_SESSION[ 'select'  ] = '*';
if (! isset($_SESSION[ 'where'   ])) $_SESSION[ 'where'   ] = '';
if (! isset($_SESSION[ 'set'     ])) $_SESSION[ 'set'     ] = 1;
if (! isset($_SESSION[ 'setsize' ])) $_SESSION[ 'setsize' ] = $setsizes[ 0 ];

if (isset($_REQUEST[ 'select' ])) $_SESSION[ 'select' ] = trim($_REQUEST[ 'select' ]);

// Initialize export mode

$exportmode = false;

if (isset($_REQUEST[ 'export' ]))
 $exportmode = true;

// Switch back from export mode

if ($exportmode)
 { // SQL input fields changed?

 $check_fields = array( 'sql', 'table', 'select', 'where' );

 foreach ($check_fields as $field)
 if (isset($_REQUEST[ $field ]))
 if ($_REQUEST[ $field ] != $_SESSION[ $field ])
 { $exportmode = false;
 break;
 }

 // History item selected?

 if (isset($_REQUEST[ 'history' ]))
 if ($_REQUEST[ 'history' ] != '')
 $exportmode = false;
 }

// Action + record set?

$action = '';

if (isset($_REQUEST[ 'action' ]))
 if (($_REQUEST[ 'action' ] == 'edit') || ($_REQUEST[ 'action' ] == 'delete'))
 $action = $_REQUEST[ 'action' ];

$actionrecord = false;

if ($action != '')
 if (isset($_REQUEST[ 'record' ]))
 if (is_array($_REQUEST[ 'record' ]))
 if (isset($_REQUEST[ 'record' ][ 'table' ]) &amp;&amp; isset($_REQUEST[ 'record' ][ 'rowid' ]))
 $actionrecord = $_REQUEST[ 'record' ];

if (! is_array($actionrecord))
 $action = '';

// edit or delete cancelled?

if (isset($_REQUEST[ 'editcancel' ]) || isset($_REQUEST[ 'deletecancel' ]))
 { $action = '';
 $actionrecord = false;
 }

// set changed?

if (isset($_REQUEST[ 'set' ]))
 if ($_REQUEST[ 'set' ] != $_SESSION[ 'set' ])
 { $val = intval($_REQUEST[ 'set' ]);
 if ($val > 0)
 $_SESSION[ 'set' ] = $val;
 }

// setsize changed?

if (isset($_REQUEST[ 'setsize' ]))
 if ($_REQUEST[ 'setsize' ] != $_SESSION[ 'setsize' ])
 if (in_array($_REQUEST[ 'setsize' ], $setsizes))
 { $_SESSION[ 'setsize' ] = $_REQUEST[ 'setsize' ];
 $_SESSION[ 'set'     ] = 1;
 }

// empty column list means *

if ($_SESSION[ 'select' ] == '') $_SESSION[ 'select' ] = '*';

// entry mode changed?

if (isset($_REQUEST[ 'entrymode' ]))
 if (($_REQUEST[ 'entrymode' ] == 'popups') || ($_REQUEST[ 'entrymode' ] == 'manual'))
 { $_SESSION[ 'sql'    ] = '';

 // Switch from "popups" to "manual"? Prefill SQL statement...
 if (($_SESSION[ 'entrymode' ] == 'popups') &amp;&amp; ($_REQUEST[ 'entrymode' ] == 'manual') &amp;&amp; ($_SESSION[ 'table' ] != '') &amp;&amp; ($_SESSION[ 'select' ] != ''))
 $_SESSION[ 'sql' ] = 'SELECT ' . $_SESSION[ 'select' ] . ' from ' . $_SESSION[ 'table' ] . ' ' . $_SESSION[ 'where' ];

 $_SESSION[ 'table'  ] = '';
 $_SESSION[ 'select' ] = '*';
 $_SESSION[ 'where'  ] = '';
 $_SESSION[ 'set'    ] = 1;

 $_SESSION[ 'entrymode' ] = $_REQUEST[ 'entrymode' ];
 }

// sql changed? (entrymode=manual)

if (isset($_REQUEST[ 'sql' ]))
 if ($_REQUEST[ 'sql' ] != $_SESSION[ 'sql' ])
 { $_SESSION[ 'sql' ] = trim($_REQUEST[ 'sql' ]);
 $_SESSION[ 'set' ] = 1;
 }

// where changed? (entrymode=popups)

if (isset($_REQUEST[ 'where' ]))
 if ($_REQUEST[ 'where' ] != $_SESSION[ 'where' ])
 { $_SESSION[ 'where' ] = trim($_REQUEST[ 'where' ]);
 $_SESSION[ 'set'   ] = 1;
 }

// table changed? (entrymode=popups)

if (isset($_REQUEST[ 'table' ]))
 if ($_REQUEST[ 'table' ] != $_SESSION[ 'table' ])
 { $newtable = substr(trim(preg_replace('/[^a-zA-Z0-9$#_.-]/', '', $_REQUEST[ 'table' ])), 0, 61);

 if ($newtable != $_SESSION[ 'table' ])
 { $_SESSION[ 'table'  ] = $newtable;
 $_SESSION[ 'select' ] = '*';
 $_SESSION[ 'where'  ] = '';
 $_SESSION[ 'set'    ] = 1;
 }

 // We need a way to set both table + where in HREFs
 if (isset($_REQUEST[ 'keepwhere' ]))
 $_SESSION[ 'where' ] = $_REQUEST[ 'keepwhere' ];
 }

// history item selected?

if (! isset($_SESSION[ 'history' ])) $_SESSION[ 'history' ] = array();

$dont_execute = false;

if (isset($_REQUEST[ 'history' ]))
 if ($_REQUEST[ 'history' ] != '')
 { $tmp = intval($_REQUEST[ 'history' ]);
 if ($tmp >= 0)
 if (isset($_SESSION[ 'history' ][ $tmp ]))
 { $_SESSION[ 'entrymode' ] = $_SESSION[ 'history' ][ $tmp ][ 'entrymode' ];
 $_SESSION[ 'set'       ] = $_SESSION[ 'history' ][ $tmp ][ 'set'     ];
 $_SESSION[ 'setsize'   ] = $_SESSION[ 'history' ][ $tmp ][ 'setsize' ];

 if ($_SESSION[ 'history' ][ $tmp ][ 'entrymode' ] == 'popups')
 { $_SESSION[ 'table'   ] = $_SESSION[ 'history' ][ $tmp ][ 'table'   ];
 $_SESSION[ 'select'  ] = $_SESSION[ 'history' ][ $tmp ][ 'select'  ];
 $_SESSION[ 'where'   ] = $_SESSION[ 'history' ][ $tmp ][ 'where'   ];
 $_SESSION[ 'sql'     ] = '';
 }
 else
 { $_SESSION[ 'sql'     ] = $_SESSION[ 'history' ][ $tmp ][ 'sql' ];
 $_SESSION[ 'table'   ] = '';
 $_SESSION[ 'select'  ] = '';
 $_SESSION[ 'where'   ] = '';
 }

 // Non-SELECT statements should only be shown, not automatically executed
 // when switching to them (to avoid unwanted DELETEs etc.)

 if ($_SESSION[ 'history' ][ $tmp ][ 'type' ] != 'SELECT')
 $dont_execute = true;
 }
 }

// Build main SQL statement

$main_sql = '';

if ((($_SESSION[ 'table' ] != '') || ($_SESSION[ 'sql' ] != '')) &amp;&amp; (! $dont_execute))
 {    if ($_SESSION[ 'entrymode' ] == 'popups')
 { // Always select the ROWID - we're using this for "Actions" support instead of the primary key

 $main_sql = 'select ';

 // Prevent "ORA-00936: missing expression":
 //   "select *, ROWID" is incorrect, we have to use "select tablename.*, ROWID" instead

 if (trim($_SESSION[ 'select' ]) == '*')
 $main_sql .= $_SESSION[ 'table' ] . '.';

 $rowidsql = ', rowidtochar(ROWID) as ROWID_';

 $main_sql .= trim($_SESSION[ 'select' ] . $rowidsql . ' from ' . $_SESSION[ 'table' ] . ' ' . $_SESSION[ 'where' ]);
 }
 else
 $main_sql = $_SESSION[ 'sql' ];
 }

// Initialize connection

$conn = false;

if (($_SESSION[ 'connection' ][ 'user' ] != '') &amp;&amp; ($_SESSION[ 'connection' ][ 'password' ] != ''))
 pof_connect();

// Do export?

$doexport = false;
$export_errormsg = '';

if (isset($_REQUEST[ 'export' ]))
 if (is_array($_REQUEST[ 'export' ]))
 if (isset($_REQUEST[ 'export' ][ 'doit' ]) &amp;&amp; isset($_REQUEST[ 'export' ][ 'format' ]) &amp;&amp; isset($_REQUEST[ 'export' ][ 'limit' ]))
 $doexport = true;

if ($doexport)
 { // Do the export
 // Exporting may take a while

 set_time_limit(0);

 // Initialize export settings

 $exportlimit = abs(intval($_REQUEST[ 'export' ][ 'limit' ]));

 $_SESSION[ 'exportformat' ] = $_REQUEST[ 'export' ][ 'format' ];

 if (! isset($exportformats[ $_SESSION[ 'exportformat' ] ]))
 $_SESSION[ 'exportformat' ] = 'xml';

 // Send Content-type header

 header(sprintf('Content-Type: %s; name="dbexport.%s"', $exportformats[ $_SESSION[ 'exportformat' ] ][ 1 ], $_SESSION[ 'exportformat' ]));
 header(sprintf('Content-disposition: attachment; filename="dbexport.%s"', $_SESSION[ 'exportformat' ]));

 // Loop through results

 $ok = false;

 $cursor = pof_opencursor($main_sql);

 if ($cursor)
 if (ocistatementtype($cursor) == 'SELECT')
 $ok = true;

 if ($ok)
 { // Get column list

 $columns = array();
 $numcols = ocinumcols($cursor);

 for ($j = 1; $j <= $numcols; $j++)
 if (ocicolumnname($cursor, $j) != 'ROWID_')
 $columns[ (ocicolumnname($cursor, $j)) ] = array(
 'type' => ocicolumntype($cursor, $j),
 'size' => ocicolumnsize($cursor, $j)
 );

 // Header

 if ($_SESSION[ 'exportformat' ] == 'xml')
 { echo sprintf('<' . '?xml version="1.0" encoding="%s"?' . '>', $charset) . "\n";
 echo "<!-- Generated by OracleEditor.php (http://oracleeditor.sourceforge.net/) -->\n";

 $userstr = $_SESSION[ 'connection' ][ 'user' ];
 if ($_SESSION[ 'connection' ][ 'service' ] != '')
 $userstr .= '@' . $_SESSION[ 'connection' ][ 'service' ];

 echo sprintf('<rowset exported="%s" user="%s" server="%s">', date('Y-m-d\TH:i:s'), $userstr, $_SERVER[ 'SERVER_NAME' ]) . "\n";
 echo sprintf("\t<sql>%s</sql>\n", htmlspecialchars($main_sql));

 // Column aliases: We can use column names as tag names only if
 // they're valid XML names - <count(MYFIELD)> won't work.

 $i = 0;
 foreach ($columns as $name => $column)
 { $i++;

 if (preg_match('/^[a-zA-Z][a-zA-Z0-9_-]*$/', $name) == 0)
 $columns[ $name ][ 'alias' ] = 'ALIAS' . $i;
 }

 echo "\t<columns>\n";
 foreach ($columns as $name => $column)
 echo sprintf("\t\t" . '<column name="%s" type="%s" size="%s"%s/>' . "\n",
 htmlspecialchars($name),
 $column[ 'type' ],
 $column[ 'size' ],
 (isset($column[ 'alias' ]) ? ' alias="' . $column[ 'alias' ] . '"' : '')
 );
 echo "\t</columns>\n";
 }
 elseif ($_SESSION[ 'exportformat' ] == 'csv')
 { $first = true;

 foreach ($columns as $name => $column)
 if ($name != 'ROWID_')
 { if (! $first) echo ', ';
 echo sprintf('"%s"', str_replace('"', '""', $name));
 $first = false;
 }

 echo "\n";
 }
 elseif ($_SESSION[ 'exportformat' ] == 'html')
 { ?>

 <html>
 <head>
 <meta http-equiv="content-type" content="text/html; charset=<?php echo $charset; ?>">
 <meta name="date" content="<?php echo date('Y-m-d\TH:i:s'); ?>">
 <meta name="generator" content="OracleEditor.php (http://oracleeditor.sourceforge.net/)">
 <title>Exported Oracle data (by OracleEditor.php)</title>
 </head>
 <body>

 <h1>Exported Oracle data</h1>

 <?php
 $userstr = $_SESSION[ 'connection' ][ 'user' ];
 if ($_SESSION[ 'connection' ][ 'service' ] != '')
 $userstr .= '@' . $_SESSION[ 'connection' ][ 'service' ];
 ?>

 <p>The Oracle user <em><?php echo htmlspecialchars($userstr); ?></em> exported this data on <em><?php echo date('r'); ?></em>
 by running the following SQL statement in <a href="http://<?php echo $_SERVER[ 'HTTP_HOST' ]; ?><?php echo $_SERVER[ 'PHP_SELF' ]; ?>">a local copy of OracleEditor.php</a> on <em><?php echo $_SERVER[ 'SERVER_NAME' ]; ?></em>:<br />
 <pre><?php echo htmlspecialchars($main_sql); ?></pre></p>

 <table border="1">
 <tr>

 <?php

 foreach ($columns as $name => $column)
 echo sprintf('<th>%s<br />(%s, %s)</th>' . "\n",
 htmlspecialchars($name),
 $column[ 'type' ],
 $column[ 'size' ]
 );

 ?>

 </tr>

 <?php
 }

 // Rows

 $i = 1;

 while (true)
 { if (! ocifetchinto($cursor, $row, OCI_ASSOC | OCI_RETURN_LOBS))
 break;

 if ($_SESSION[ 'exportformat' ] == 'xml')
 { echo sprintf("\t<row%s>\n", (isset($row[ 'ROWID_' ]) ? (' id="' . htmlspecialchars($row[ 'ROWID_' ]) . '"') : ''));

 foreach ($row as $fieldname => $value)
 if ($fieldname != 'ROWID_')
 echo sprintf("\t\t<%1\$s>%2\$s</%1\$s>\n",
 (isset($columns[ $fieldname ][ 'alias' ]) ? $columns[ $fieldname ][ 'alias' ] : $fieldname ),
 htmlspecialchars($value));

 echo "\t</row>\n";
 }
 elseif ($_SESSION[ 'exportformat' ] == 'csv')
 { $first = true;

 foreach ($columns as $fieldname => $column)
 if ($fieldname != 'ROWID_')
 { if (! $first) echo ', ';
 if (isset($row[ $fieldname ]))
 echo sprintf('"%s"', str_replace('"', '""', $row[ $fieldname ]));
 else
 echo '""';
 $first = false;
 }

 echo "\n";
 }
 elseif ($_SESSION[ 'exportformat' ] == 'html')
 { echo "<tr>\n";

 foreach ($columns as $fieldname => $column)
 if ($fieldname != 'ROWID_')
 { echo "\t<td>";
 if (isset($row[ $fieldname ]))
 echo htmlspecialchars($row[ $fieldname ]);
 echo "</td>\n";
 }

 echo "</tr>\n";
 }

 if (($exportlimit > 0) &amp;&amp; ($exportlimit <= ++$i))
 break;
 }

 // Footer

 if ($_SESSION[ 'exportformat' ] == 'xml')
 { echo "</rowset>\n";
 }
 elseif ($_SESSION[ 'exportformat' ] == 'html')
 { ?>

 </table>
 <p>HTML generated by <a href="http://oracleeditor.sourceforge.net/">OracleEditor.php</a> <?php echo $version; ?> &amp;copy; 2006 by <a href="http://tim.digicol.de/">Tim Strehle</a> &amp;lt;<a href="mailto:tim@strehle.de">tim@strehle.de</a>&amp;gt;</p>
 </body>
 </html>

 <?php
 }

 pof_closecursor($cursor);

 session_write_close();
 exit;
 }
 else
 $export_errormsg = 'Unable to export';
 }

function pof_blanksession()
{ global $setsizes;

 $_SESSION[ 'connection' ] = array(
 'user'     => '',
 'password' => '',
 'service'  => ''
 );

 $_SESSION[ 'cache'   ] = array();
 $_SESSION[ 'debug'   ] = false;
 $_SESSION[ 'sql'     ] = '';
 $_SESSION[ 'table'   ] = '';
 $_SESSION[ 'select'  ] = '*';
 $_SESSION[ 'where'   ] = '';
 $_SESSION[ 'set'     ] = 1;
 $_SESSION[ 'setsize' ] = $setsizes[ 0 ];
 $_SESSION[ 'history' ] = array();
}

function pof_sqlline($msg, $error = false)
{ if ($error)
 $class = 'sqllineerr';
 else
 $class = 'sqlline';

 $html = '<table><tr><td>' . htmlspecialchars($msg) . '</td></tr></table>' . "\n";

 return $html;
}

function pof_connect()
{ global $conn;

 $conn = ocilogon($_SESSION[ 'connection' ][ 'user' ], $_SESSION[ 'connection' ][ 'password' ], $_SESSION[ 'connection' ][ 'service' ]);

 $err = ocierror();

 if (is_array($err))
 echo htmlspecialchars('Logon failed: ' . $err[ 'message' ]) . '<br />' . "\n";
}

function pof_disconnect()
{ global $conn;

 if ($conn)
 ocilogoff($conn);
}

function pof_opencursor($sql, $bind = false)
{ global $conn;

 $cursor = ociparse($conn, $sql);

 if (! $cursor)
 { $err = ocierror($conn);
 if (is_array($err))
 echo pof_sqlline('Parse failed: ' . $err[ 'message' ], true);
 }
 else
 { // This might improve performance?
 ocisetprefetch($cursor, $_SESSION[ 'setsize' ]);

 if (is_array($bind))
 foreach ($bind as $fieldname => $value)
 ocibindbyname($cursor, ':' . $fieldname, $bind[ $fieldname ], -1);

 $ok = ociexecute($cursor);

 if (! $ok)
 { $err = ocierror($cursor);

 if (is_array($err))
 echo pof_sqlline('Execute failed: ' . $err[ 'message' ], true);

 pof_closecursor($cursor);

 $cursor = false;
 }
 }

 return $cursor;
}

function pof_closecursor($cursor)
{ if ($cursor)
 ocifreestatement($cursor);
}

function pof_gettables()
{ if (! isset($_SESSION[ 'cache' ][ '_alltables' ]))
 { $_SESSION[ 'cache' ][ '_alltables' ] = array();

 $sql = sprintf(
 "select ' ' as OWNER, TABLE_NAME from USER_TABLES " .
 "union " .
 "select OWNER, TABLE_NAME from USER_TAB_PRIVS where PRIVILEGE = 'SELECT' and GRANTEE = '%1\$s' " .
 "order by OWNER, TABLE_NAME",
 strtoupper($_SESSION[ 'connection' ][ 'user' ])
 );

 if ($_SESSION[ 'debug' ]) error_log($sql);

 $cursor = pof_opencursor($sql);

 if ($cursor)
 { while (true)
 { if (! ocifetchinto($cursor, $row, OCI_ASSOC | OCI_RETURN_LOBS))
 break;

 if (trim($row[ 'OWNER' ]) == '')
 $_SESSION[ 'cache' ][ '_alltables' ][ ] = $row[ 'TABLE_NAME' ];
 else
 $_SESSION[ 'cache' ][ '_alltables' ][ ] = $row[ 'OWNER' ] . '.' . $row[ 'TABLE_NAME' ];
 }

 pof_closecursor($cursor);
 }
 }

 return $_SESSION[ 'cache' ][ '_alltables' ];
}

function pof_getviews()
{ if (! isset($_SESSION[ 'cache' ][ '_allviews' ]))
 { $_SESSION[ 'cache' ][ '_allviews' ] = array();
 $sql = 'select VIEW_NAME from USER_VIEWS order by VIEW_NAME';
 if ($_SESSION[ 'debug' ]) error_log($sql);

 $cursor = pof_opencursor($sql);

 if ($cursor)
 { while (true)
 { if (! ocifetchinto($cursor, $row, OCI_ASSOC | OCI_RETURN_LOBS))
 break;

 $_SESSION[ 'cache' ][ '_allviews' ][ ] = $row[ 'VIEW_NAME' ];
 }

 pof_closecursor($cursor);
 }
 }

 return $_SESSION[ 'cache' ][ '_allviews' ];
}

function pof_getpk($table)
{ if (! isset($_SESSION[ 'cache' ][ $table ])) $_SESSION[ 'cache' ][ $table ] = array();

 if (! isset($_SESSION[ 'cache' ][ $table ][ 'pk' ]))
 { $_SESSION[ 'cache' ][ $table ][ 'pk' ] = '';

 $sql = "select COLUMN_NAME from USER_CONS_COLUMNS col, USER_CONSTRAINTS con where con.TABLE_NAME=:TABLE_NAME and con.CONSTRAINT_TYPE='P' and col.CONSTRAINT_NAME=con.CONSTRAINT_NAME";
 $bind = array( 'TABLE_NAME' => $table );
 if ($_SESSION[ 'debug' ]) error_log($sql);

 $cursor = pof_opencursor($sql, $bind);

 if ($cursor)
 { if (ocifetchinto($cursor, $row, OCI_NUM))
 $_SESSION[ 'cache' ][ $table ][ 'pk' ] = $row[ 0 ];
 pof_closecursor($cursor);
 }
 }

 return $_SESSION[ 'cache' ][ $table ][ 'pk' ];
}

function pof_getcoldefs($table)
{ if (! isset($_SESSION[ 'cache' ][ $table ])) $_SESSION[ 'cache' ][ $table ] = array();

 if (! isset($_SESSION[ 'cache' ][ $table ][ 'coldefs' ]))
 { $_SESSION[ 'cache' ][ $table ][ 'coldefs' ] = array();

 $sql = "select COLUMN_NAME, NULLABLE, DATA_DEFAULT from USER_TAB_COLUMNS where TABLE_NAME=:TABLE_NAME";
 $bind = array( 'TABLE_NAME' => $table );
 if ($_SESSION[ 'debug' ]) error_log($sql);

 $cursor = pof_opencursor($sql, $bind);

 if ($cursor)
 { while (true)
 { if (! ocifetchinto($cursor, $row, OCI_ASSOC))
 break;

 $_SESSION[ 'cache' ][ $table ][ 'coldefs' ][ $row[ 'COLUMN_NAME' ] ] = array(
 'nullable' => true,
 'default'  => ''
 );

 if (isset($row[ 'NULLABLE' ]))
 if ($row[ 'NULLABLE' ] == 'N')
 $_SESSION[ 'cache' ][ $table ][ 'coldefs' ][ $row[ 'COLUMN_NAME' ] ][ 'nullable' ] = false;

 if (isset($row[ 'DATA_DEFAULT' ]))
 $_SESSION[ 'cache' ][ $table ][ 'coldefs' ][ $row[ 'COLUMN_NAME' ] ][ 'default' ] = trim(strtr($row[ 'DATA_DEFAULT' ], '()', '  '));
 }

 pof_closecursor($cursor);
 }
 }

 return $_SESSION[ 'cache' ][ $table ][ 'coldefs' ];
}

function pof_getforeignkeys($table)
{ if (! isset($_SESSION[ 'cache' ][ $table ])) $_SESSION[ 'cache' ][ $table ] = array();

 if (! isset($_SESSION[ 'cache' ][ $table ][ 'constraints' ]))
 { $_SESSION[ 'cache' ][ $table ][ 'constraints' ] = array( 'from' => array(), 'to' => array() );

 // Find own + remote foreign key constraint names
 // XXX foreign tables might belong to a different user! take R_OWNER into account!

 $sql =
 "select CONSTRAINT_NAME, R_CONSTRAINT_NAME from USER_CONSTRAINTS where TABLE_NAME=:TABLE_NAME and CONSTRAINT_TYPE='R' and STATUS='ENABLED' " .
 "union " .
 "select CONSTRAINT_NAME, R_CONSTRAINT_NAME from USER_CONSTRAINTS where R_CONSTRAINT_NAME in " .
 "(select CONSTRAINT_NAME from USER_CONSTRAINTS where TABLE_NAME=:TABLE_NAME) ".
 "and CONSTRAINT_TYPE='R' and STATUS='ENABLED'";
 $bind = array( 'TABLE_NAME' => $table );
 if ($_SESSION[ 'debug' ]) error_log($sql);

 $cursor = pof_opencursor($sql, $bind);

 $names = array();
 $constraints = array();

 if ($cursor)
 { while (true)
 { if (! ocifetchinto($cursor, $row, OCI_ASSOC))
 break;

 $names[ ] = $row[ 'CONSTRAINT_NAME'   ];

 if (isset($row[ 'R_CONSTRAINT_NAME' ]))
 if ($row[ 'R_CONSTRAINT_NAME' ] != '')
 $names[ ] = $row[ 'R_CONSTRAINT_NAME' ];
 }

 pof_closecursor($cursor);
 }

 if (count($names) > 0)
 { $sql = "select CONSTRAINT_NAME, TABLE_NAME, R_CONSTRAINT_NAME from USER_CONSTRAINTS where CONSTRAINT_NAME in ('" . implode("','", $names) . "')";
 if ($_SESSION[ 'debug' ]) error_log($sql);

 $cursor = pof_opencursor($sql);

 if ($cursor)
 { while (true)
 { if (! ocifetchinto($cursor, $row, OCI_ASSOC))
 break;

 $constraints[ $row[ 'CONSTRAINT_NAME' ] ] = $row;
 }

 pof_closecursor($cursor);
 }

 $sql = "select CONSTRAINT_NAME, COLUMN_NAME from USER_CONS_COLUMNS where CONSTRAINT_NAME in ('" . implode("','", $names) . "')";
 if ($_SESSION[ 'debug' ]) error_log($sql);

 $cursor = pof_opencursor($sql);

 if ($cursor)
 { while (true)
 { if (! ocifetchinto($cursor, $row, OCI_ASSOC))
 break;

 $constraints[ $row[ 'CONSTRAINT_NAME' ] ][ 'COLUMN_NAME'  ] = $row[ 'COLUMN_NAME' ];
 }

 pof_closecursor($cursor);
 }
 }

 if (count($constraints) > 0)
 { foreach ($constraints as $key => $item)
 { if (! isset($item[ 'R_CONSTRAINT_NAME' ]))
 continue;

 if ($item[ 'TABLE_NAME' ] == $table)
 $_SESSION[ 'cache' ][ $table ][ 'constraints' ][ 'to' ][ $item[ 'COLUMN_NAME' ] ] = array(
 'table'  => $constraints[ $item[ 'R_CONSTRAINT_NAME' ] ][ 'TABLE_NAME'  ],
 'column' => $constraints[ $item[ 'R_CONSTRAINT_NAME' ] ][ 'COLUMN_NAME' ]
 );
 else
 { $col = $constraints[ $item[ 'R_CONSTRAINT_NAME' ] ][ 'COLUMN_NAME' ];

 if (! isset($_SESSION[ 'cache' ][ $table ][ 'constraints' ][ 'from' ][ $col ]))
 $_SESSION[ 'cache' ][ $table ][ 'constraints' ][ 'from' ][ $col ] = array();

 $_SESSION[ 'cache' ][ $table ][ 'constraints' ][ 'from' ][ $col ][ ] = array(
 'table'  => $item[ 'TABLE_NAME'  ],
 'column' => $item[ 'COLUMN_NAME' ]
 );
 }
 }
 }
 }

 return $_SESSION[ 'cache' ][ $table ][ 'constraints' ];
}

// Charset header

header('Content-Type: text/html; charset=' . $charset);

?>
<html>
<head>
<title>OracleEditor.php<?php
if ($_SESSION[ 'connection' ][ 'user' ] != '')
 { if ($_SESSION[ 'table' ] != '')
 echo ': ' . $_SESSION[ 'table' ];

 echo ' (' . $_SESSION[ 'connection' ][ 'user' ];
 if ($_SESSION[ 'connection' ][ 'service' ] != '')
 echo '@' . $_SESSION[ 'connection' ][ 'service' ];
 echo ')';
 }
?></title>
<style type="text/css">

body,a,p,span,td,th,input,select,textarea {
 font-family:verdana,arial,helvetica,geneva,sans-serif,serif;
 font-size:12px;
}

a:link,a:visited,a:active {
 color:darkgray;
}

.logo {
 color:yellow;
 background:black;
 font-weight:bold;
 font-size:14px;
}

.headerline {
 border-style:none;
 padding:5px;
 background:black;
 color:white;
 width:100%;
}

.selectform {
 border-width:1px;
 border-color:#FF9999;
 border-style:dashed;
 padding:5px;
 width:100%;
}

.sqlline {
 font-family:courier;
 border-style:none;
 padding:5px;
 width:100%;
 color:yellow;
 background:black;
}

.sqllineerr {
 font-family:courier;
 border-style:none;
 padding:5px;
 width:100%;
 color:red;
 background:black;
}

.resultgrid {
 border-width:1px;
 border-color:#FF9999;
 border-style:dashed;
 padding:5px;
}

.gridheader {
 background:#EEEEEE;
 color:darkgray;
}

.gridline {
 background:white;
}

.gridlinealt {
 background:#EEEEEE;
}

.gridfooter {
 border-style:none;
 background:black;
 color:white;
 width:100%;
}

</style>
</head>
<body>
<form name="form1" method="post" action="<?php echo $_SERVER[ 'PHP_SELF' ]; ?>">

<input type="hidden" name="sid" value="<?php echo $sid; ?>" />

<?php

if ($conn == false)
 { ?>

 <table>
 <tr>
 <td colspan="2"><span>OracleEditor.php</span> Browse and edit your Oracle database records ...</td>
 </tr>
 </table>

 <?php

 // Check requirements

 $requirements_ok = true;
 $required_version = '4.1.0';

 if (version_compare(phpversion(), $required_version) < 0)
 { printf("<strong>PHP too old</strong>: You're running PHP %s, but <strong>PHP %s is required</strong> to run OracleEditor.php!<br />\n", phpversion(), $required_version);
 $requirements_ok = false;
 }

 if (! function_exists('ocilogon'))
 { echo "<strong>PHP has no Oracle OCI support</strong>: Your PHP installation doesn't have the <a href=\"http://www.php.net/manual/en/ref.oci8.php\">OCI8 module</a> installed which is required to run OracleEditor.php!<br />\n";
 $requirements_ok = false;
 }

 if (! function_exists('session_start'))
 { echo "<strong>PHP has no session support</strong>: Your PHP installation doesn't have the <a href=\"http://www.php.net/manual/en/ref.session.php\">Session module</a> installed which is required to run OracleEditor.php!<br />\n";
 $requirements_ok = false;
 }

 // Login form

 if ($requirements_ok)
 {    ?>

 <table>
 <tr>
 <td>User: </td>
 <td><input type="text" name="connection[user]" value="<?php echo $_SESSION[ 'connection' ][ 'user' ]; ?>" title="Enter the Oracle user name" /></td>

 <script type="text/javascript">
 document.forms[ 'form1' ].elements[ 'connection[user]' ].focus();
 </script>

 </tr>
 <tr>
 <td>Password: </td>
 <td><input type="password" name="connection[password]" value="" title="Enter the Oracle user's password" /></td>
 </tr>
 <tr>
 <td>Service name: </td>
 <td><input type="text" name="connection[service]" value="<?php echo htmlspecialchars($_SESSION[ 'connection' ][ 'service' ]); ?>" title="Enter a tnsnames.ora identifier, or leave blank for local databases" /></td>
 </tr>
 <tr>
 <td colspan="2" align="center"><input type="submit" value="Connect to Oracle" accesskey="c" title="Click to log in [c]" /></td>
 </tr>
 </table>

 <?php
 }
 }
else
 { // Display connection header

 echo '<table><tr><td>';
 echo '<span>OracleEditor.php</span> ';
 echo 'Connected to Oracle as ' . $_SESSION[ 'connection' ][ 'user' ];
 if ($_SESSION[ 'connection' ][ 'service' ] != '')
 echo '@' . $_SESSION[ 'connection' ][ 'service' ];

 echo ' - <a href="' . $_SERVER[ 'PHP_SELF' ] . '?sid=' . $sid . '&amp;disconnect=1" accesskey="d" title="Click here to log out [d]">Disconnect</a>';
 echo '</table>' . "\n";

 echo '<table><tr><td>' . "\n";

 if ($_SESSION[ 'entrymode' ] == 'popups')
 { // Popup-aided SQL query entry

 echo 'SELECT ';

 // "select" (column list) input field

 echo '<input type="text" name="select" value="' . htmlspecialchars($_SESSION[ 'select' ]) . '" size="20" title="Enter column names (comma-separated), or * for all columns" />';

 // "table" selection popup

 $alltables = pof_gettables();
 $allviews = pof_getviews();

 echo ' FROM <select name="table" onChange="javascript:document.forms[0].submit()" title="Select a table/view to display or edit">' . "\n";

 $found = false;

 echo '<option value="">[Select a table]</option>' . "\n";

 foreach ($alltables as $tablename)
 { echo '<option value="' . $tablename . '"';

 if (! $found)
 if ($tablename == $_SESSION[ 'table' ])
 { echo ' selected="selected"';
 $found = true;
 }

 echo '>' . $tablename . '</option>' . "\n";
 }

 echo '<option value=""></option>' . "\n";
 echo '<option value="">[Select a view]</option>' . "\n";

 foreach ($allviews as $viewname)
 { echo '<option value="' . $viewname . '"';

 if (! $found)
 if ($viewname == $_SESSION[ 'table' ])
 { echo ' selected="selected"';
 $found = true;
 }

 echo '>' . $viewname . '</option>' . "\n";
 }

 if (! $found)
 echo '<option value="" selected="selected">[Select a table/view]</option>' . "\n";

 echo '</select>' . "\n";

 // "where" input field for WHERE, ORDER BY, GROUP BY, ...

 echo ' <input type="text" name="where" value="' . htmlspecialchars($_SESSION[ 'where' ]) . '" size="40" title="Enter GROUP BY or ORDER BY clauses here" />;';
 }
 else
 { // Manual SQL query/command entry

 ?>

 SQL: [Warning: Be careful with UPDATE, DELETE, DROP etc. - there's no chance to rollback!]<br />

 <textarea name="sql" rows="5" cols="80" title="Enter any SQL statement here: SELECT, INSERT, UPDATE, DELETE, ALTER, DROP..."><?php echo htmlspecialchars($_SESSION[ 'sql' ]); ?></textarea>

 <script type="text/javascript">
 document.forms[ 'form1' ].elements[ 'sql' ].focus();
 </script>

 <?php
 }

 // "setsize" selection popup

 echo '<br /> Display <select name="setsize" onChange="javascript:document.forms[0].submit()" title="Select the number of rows to display per page">' . "\n";

 foreach ($setsizes as $size)
 { echo '<option value="' . $size . '"';
 if ($size == $_SESSION[ 'setsize' ])
 echo ' selected="selected"';
 echo '>' . $size . '</option>' . "\n";
 }

 echo '</select> records per page.' . "\n";

 // Submit button

 echo '<input type="submit" accesskey="e" value="' . ($_SESSION[ 'entrymode' ] == 'popups' ? 'Refresh' : 'Execute') . '" title="Click here to execute the SQL statement [e]" />' . "\n";
 echo '<input type="submit" accesskey="x" name="export" value="Export" title="Click here to export rows as text, XML or CSV [x]" />' . "\n";

 echo str_repeat('&amp;nbsp;', 6);
 echo '<a href="' . $_SERVER[ 'PHP_SELF' ] . '?sid=' . $sid . '&amp;entrymode=' . ($_SESSION[ 'entrymode' ] == 'popups' ? 'manual' : 'popups') . '" accesskey="s" title="Click here to switch between manual SQL entry and the table/view popup [s]">';
 echo ($_SESSION[ 'entrymode' ] == 'popups' ? 'Switch to manual SQL entry' : 'Switch to popup-aided SQL entry') . '</a>' . "\n";

 echo '</td></tr></table>' . "\n";

 // Update record if requested

 if (($action == 'edit') &amp;&amp; isset($_REQUEST[ 'editsave' ]) &amp;&amp; is_array($actionrecord) &amp;&amp; isset($_REQUEST[ 'edit' ]))
 if (is_array($_REQUEST[ 'edit' ]))
 if (count($_REQUEST[ 'edit' ]) > 0)
 { $sql = 'update ' . $actionrecord[ 'table' ] . ' set ';
 $i = 0;
 $bind = array();

 foreach ($_REQUEST[ 'edit' ] as $fieldname => $field)
 { if (! (isset($field[ 'mode' ]) &amp;&amp; isset($field[ 'value' ]) &amp;&amp; isset($field[ 'function' ])))
 continue;

 if ($i > 0)
 $sql .= ', ';

 $sql .= $fieldname . '=';

 if ($field[ 'mode' ] == 'function')
 $sql .= $field[ 'function' ];
 else
 { $sql .= ':' . $fieldname;
 $bind[ $fieldname ] = $field[ 'value' ];
 }

 $i++;
 }

 $sql .= ' where ROWID=chartorowid(:rowid_)';
 if ($_SESSION[ 'debug' ]) error_log($sql);

 $bind[ 'rowid_' ] = $actionrecord[ 'rowid' ];

 echo pof_sqlline($sql . ';');

 $updcursor = ociparse($conn, $sql);

 if (! $updcursor)
 { $err = ocierror($conn);
 if (is_array($err))
 echo pof_sqlline('Parse failed: ' . $err[ 'message' ], true);
 }
 else
 { foreach ($bind as $fieldname => $value)
 ocibindbyname($updcursor, ':' . $fieldname, $bind[ $fieldname ], -1);

 $ok = ociexecute($updcursor);

 if (! $ok)
 { $err = ocierror($updcursor);
 if (is_array($err))
 echo pof_sqlline('Execute failed: ' . $err[ 'message' ], true);
 }

 ocifreestatement($updcursor);
 }
 }

 // Delete record if requested

 if (($action == 'delete') &amp;&amp; isset($_REQUEST[ 'deleteconfirm' ]) &amp;&amp; is_array($actionrecord))
 { $sql = 'delete from ' . $actionrecord[ 'table' ] . ' where ROWID=chartorowid(:rowid_)';
 if ($_SESSION[ 'debug' ]) error_log($sql);

 echo pof_sqlline($sql . ';');

 $delcursor = ociparse($conn, $sql);

 if (! $delcursor)
 { $err = ocierror($conn);
 if (is_array($err))
 echo pof_sqlline('Parse failed: ' . $err[ 'message' ], true);
 }
 else
 { ocibindbyname($delcursor, ':rowid_', $actionrecord[ 'rowid' ], -1);

 $ok = ociexecute($delcursor);

 if (! $ok)
 { $err = ocierror($delcursor);
 if (is_array($err))
 echo pof_sqlline('Execute failed: ' . $err[ 'message' ], true);
 }

 ocifreestatement($delcursor);
 }

 $action = '';
 $actionrecord = false;
 }

 // Insert record if requested

 if (isset($_REQUEST[ 'insertsave' ]) &amp;&amp; isset($_REQUEST[ 'insert' ]))
 if (is_array($_REQUEST[ 'insert' ]))
 if (count($_REQUEST[ 'insert' ]) > 0)
 { $fieldnames = array();
 $fieldvalues = array();
 $bind = array();

 foreach ($_REQUEST[ 'insert' ] as $fieldname => $field)
 { if (! (isset($field[ 'mode' ]) &amp;&amp; isset($field[ 'value' ]) &amp;&amp; isset($field[ 'function' ])))
 continue;

 $fieldnames[ ] = $fieldname;

 if ($field[ 'mode' ] == 'function')
 $fieldvalues[ ] = $field[ 'function' ];
 else
 { $fieldvalues[ ] = ':' . $fieldname;
 $bind[ $fieldname ] = $field[ 'value' ];
 }
 }

 $sql = 'insert into ' . $_SESSION[ 'table' ] . ' (' . implode(', ', $fieldnames) . ') values (' . implode(', ', $fieldvalues) . ')';
 if ($_SESSION[ 'debug' ]) error_log($sql);

 echo pof_sqlline($sql . ';');

 $inscursor = ociparse($conn, $sql);

 if (! $inscursor)
 { $err = ocierror($conn);
 if (is_array($err))
 echo pof_sqlline('Parse failed: ' . $err[ 'message' ], true);
 }
 else
 { foreach ($bind as $fieldname => $value)
 ocibindbyname($inscursor, ':' . $fieldname, $bind[ $fieldname ], -1);

 $ok = ociexecute($inscursor);

 if (! $ok)
 { $err = ocierror($inscursor);
 if (is_array($err))
 echo pof_sqlline('Execute failed: ' . $err[ 'message' ], true);
 }

 ocifreestatement($inscursor);
 }
 }

 // Run SELECT statement, display results

 if ((($_SESSION[ 'table' ] != '') || ($_SESSION[ 'sql' ] != '')) &amp;&amp; (! $dont_execute))
 {    echo pof_sqlline($main_sql . ';');
 if ($_SESSION[ 'debug' ]) error_log($main_sql);

 if ($_SESSION[ 'entrymode' ] == 'popups')
 $pk = pof_getpk($_SESSION[ 'table' ]);
 else
 $pk = '';

 $cursor = pof_opencursor($main_sql);
 $statementtype = '';

 if ($cursor)
 { // Add to history
 // Remove ROWID select string from the SQL string displayed in the history - it's just ugly

 if ($_SESSION[ 'entrymode' ] == 'popups')
 $histsql = str_replace($rowidsql, '', $main_sql);
 else
 $histsql = $main_sql;

 foreach ($_SESSION[ 'history' ] as $key => $item)
 if ($item[ 'sql' ] == $histsql)
 unset($_SESSION[ 'history' ][ $key ]);

 $statementtype = ocistatementtype($cursor);

 $historyitem = array(
 'sql'       => $histsql,
 'set'       => $_SESSION[ 'set'       ],
 'setsize'   => $_SESSION[ 'setsize'   ],
 'entrymode' => $_SESSION[ 'entrymode' ],
 'type'      => $statementtype
 );

 if ($_SESSION[ 'entrymode' ] == 'popups')
 { $historyitem[ 'table'   ] = $_SESSION[ 'table'   ];
 $historyitem[ 'select'  ] = $_SESSION[ 'select'  ];
 $historyitem[ 'where'   ] = $_SESSION[ 'where'   ];
 }

 array_unshift($_SESSION[ 'history' ], $historyitem);

 if (count($_SESSION[ 'history' ]) > 25)
 array_pop($_SESSION[ 'history' ]);
 }

 if ($statementtype == 'SELECT')
 {    // Get column list

 $columns = array();
 $numcols = ocinumcols($cursor);

 for ($j = 1; $j <= $numcols; $j++)
 if (ocicolumnname($cursor, $j) != 'ROWID_')
 $columns[ (ocicolumnname($cursor, $j)) ] = array(
 'type' => ocicolumntype($cursor, $j),
 'size' => ocicolumnsize($cursor, $j)
 );

 // Display main table

 if ($exportmode)
 { // Display export settings form

 ?>

 <table>
 <tr>
 <td align="left">
 Export format:
 <?php $i = 0; foreach ($exportformats as $value => $config) { $i++; ?>
 <label><input type="radio" name="export[format]" value="<?php echo $value; ?>" <?php echo ($value == $_SESSION[ 'exportformat' ] ? 'checked="checked" ' : ''); ?>/><?php echo htmlspecialchars($config[ 0 ]); ?></label>
 <?php } ?>
 </td>
 </tr>
 <tr>
 <td align="left">
 Record limit:
 <select name="export[limit]" title="Select the maximum number of rows to be exported">
 <option value="100" selected="selected">100</option>
 <option value="1000">1000</option>
 <option value="0">Unlimited (Are you sure?)</option>
 </select>
 </td>
 </tr>
 <tr>
 <td align="left">
 <input type="submit" name="export[doit]" value="Export now" accesskey="n" title="Click here to download the export file now [n]" />
 <input type="button" value="Cancel" accesskey="c" onClick="location.href='<?php echo $_SERVER[ 'PHP_SELF' ] . '?sid=' . $sid; ?>'" title="Click here to go back, cancel exporting [c]" />
 <?php echo htmlspecialchars($export_errormsg); ?>
 </td>
 </tr>
 </table>

 <?php
 }
 else
 {    // Display table header

 echo '<table>' . "\n";
 echo '<tr>' . "\n";
 echo '<th>Row</th>' . "\n";

 if ($_SESSION[ 'entrymode' ] == 'popups')
 echo '<th>Actions</th>' . "\n";

 foreach ($columns as $columnname => $column)
 echo '<th>' . $columnname . '<br />(' . $column[ 'type' ] . ', ' . $column[ 'size' ] . ')</th>' . "\n";

 echo '</tr>' . "\n";

 // Skip previous sets

 $offset = 0;

 if ($_SESSION[ 'set' ] > 1)
 { $offset = ($_SESSION[ 'set' ] - 1) * $_SESSION[ 'setsize' ];
 for ($j = 1; $j <= $offset; $j++)
 if (! ocifetch($cursor))
 break;
 }

 $morerows = false;
 $foundactionrecord = false;

 $foreign = pof_getforeignkeys($_SESSION[ 'table' ]);

 // Display records

 $i = 0;

 while (true)
 { if (! ocifetchinto($cursor, $row, OCI_ASSOC | OCI_RETURN_LOBS))
 break;

 $i++;

 echo '<tr>' . "\n";
 echo '<td>' . ($i + $offset) . '</td>' . "\n";

 // Is this record to be edited?

 $mode = 'show';

 if ($action != '')
 if (($actionrecord[ 'table' ] == $_SESSION[ 'table' ]) &amp;&amp; ($actionrecord[ 'rowid' ] == $row[ 'ROWID_' ]))
 { $mode = $action;
 $foundactionrecord = true;
 }

 // Display Actions column (entrymode=popups)

 if ($_SESSION[ 'entrymode' ] == 'popups')
 { echo '<td>';

 if ($mode == 'edit')
 { echo '<a name="actionrecord"></a>';
 echo '<input type="submit" value="Update" name="editsave" title="Click here to save your changes now" /><br />';
 echo '<input type="submit" value="Cancel" name="editcancel" title="Click here to dismiss your changes and go back" />';
 }
 elseif ($mode == 'delete')
 { echo '<a name="actionrecord"></a>';
 echo '<input type="submit" value="Delete" name="deleteconfirm" title="Click here to delete this record now" /><br />';
 echo '<input type="submit" value="Cancel" name="deletecancel" title="Click here to go back" />';
 }
 else
 {    $qs = 'record[table]=' . urlencode($_SESSION[ 'table' ]) . '&amp;' .
 'record[rowid]=' . urlencode($row[ 'ROWID_' ]);

 echo '<a href="' . $_SERVER[ 'PHP_SELF' ] . '?sid=' . $sid . '&amp;action=edit&amp;' . $qs . '#actionrecord" title="Click here to change this record">Update</a><br />';
 echo '<a href="' . $_SERVER[ 'PHP_SELF' ] . '?sid=' . $sid . '&amp;action=delete&amp;' . $qs . '#actionrecord" title="Click here to delete this record">Delete</a>';
 }

 echo '</td>' . "\n";
 }

 // Display values

 if ($mode == 'edit')
 { foreach ($columns as $columnname => $column)
 { $value = '';
 $nul = false;

 if (isset($row[ $columnname ]))
 $value = $row[ $columnname ];
 else
 $nul = true;

 echo '<td>';

 if ($columnname == $pk)
 echo '<pre>' . htmlspecialchars($value) . '</pre>';
 else
 { echo '<nobr>Original value: <nobr>' . htmlspecialchars(substr($value, 0, 50)) . (strlen($value) > 50 ? '...' : '') . '</nobr><br />';

 $inputsize = $column[ 'size' ];
 if ($inputsize < 4)
 $inputsize = 4;
 elseif ($inputsize > 48)
 $inputsize = 48;

 echo '<nobr><input type="radio" name="edit[' . $columnname . '][mode]" value="value" ' . ($nul ? '' : 'checked="checked" ') . '/>' . "\n";

 if (($column[ 'type' ] == 'LONG') || ($column[ 'type' ] == 'CLOB'))
 echo '<textarea name="edit[' . $columnname . '][value]" rows="10" cols="48" wrap="virtual">' . htmlspecialchars($value) . '</textarea>' . "\n";
 else
 { echo '<input type="text" name="edit[' . $columnname . '][value]" value="' . htmlspecialchars($value) .'" size="' . $inputsize . '" ';
 if (($column[ 'size' ] <= 256) &amp;&amp; (($column[ 'type' ] == 'VARCHAR') || ($column[ 'type' ] == 'VARCHAR2')))
 echo 'maxlength="' . $column[ 'size' ] . '" ';
 echo '/>';
 }

 echo '</nobr><br />' . "\n";

 echo '<nobr><input type="radio" name="edit[' . $columnname . '][mode]" value="function" ' . ($nul ? 'checked="checked" ' : '') . '/> ' . "\n";
 echo 'Function: <input type="text" name="edit[' . $columnname . '][function]" value="' . ($nul ? 'NULL' : '') .'" size="10" /></nobr>' . "\n";
 }

 echo '</td>' . "\n";
 }
 }
 else
 foreach ($columns as $columnname => $column)
 { echo '<td>';

 if (isset($row[ $columnname ]))
 { echo '<pre>';

 if (isset($foreign[ 'to' ][ $columnname ]))
 echo
 '<a href="' . $_SERVER[ 'PHP_SELF' ] . '?sid=' . $sid .
 '&amp;table=' . urlencode($foreign[ 'to' ][ $columnname ][ 'table' ]) .
 '&amp;keepwhere=' . urlencode("where " . $foreign[ 'to' ][ $columnname ][ 'column' ] . "='" . ereg_replace("'", "''", $row[ $columnname ]) . "'") .
 '" title="Click here to display the referenced ' . htmlspecialchars($foreign[ 'to' ][ $columnname ][ 'table' ]) . ' record">';

 echo htmlspecialchars($row[ $columnname ]);

 if (isset($foreign[ 'to' ][ $columnname ]))
 echo '</a>';

 echo '</pre>';

 if (isset($foreign[ 'from' ][ $columnname ]))
 foreach ($foreign[ 'from' ][ $columnname ] as $key => $item)
 { if ($key > 0)
 echo '<br />';
 echo
 '<nobr><a href="' . $_SERVER[ 'PHP_SELF' ] . '?sid=' . $sid .
 '&amp;table=' . urlencode($item[ 'table' ]) .
 '&amp;keepwhere=' . urlencode("where " . $item[ 'column' ] . "='" . ereg_replace("'", "''", $row[ $columnname ]) . "'") .
 '" title="Click here to display references to this record in ' . htmlspecialchars($item[ 'table' ] . '.' . $item[ 'column' ]) . '">-&amp;gt; ' .
 nl2br(htmlspecialchars(wordwrap($item[ 'table' ] . '.' . $item[ 'column' ], 30, "-\n", true))) . '</a></nobr>' . "\n";
 }
 }

 echo '</td>' . "\n";
 }

 echo '</tr>' . "\n";

 // Check whether there's a next result set

 if ($i >= $_SESSION[ 'setsize' ])
 { if (ocifetch($cursor))
 $morerows = true;
 break;
 }
 }

 if (! $foundactionrecord)
 { $action = '';
 $actionrecord = false;
 }

 // New record row

 if ($action == '')
 { echo '<tr>' . "\n";

 if (isset($_REQUEST[ 'showinsert' ]))
 { // Find default values + NOT NULL restrictions

 $coldefs = pof_getcoldefs($_SESSION[ 'table' ]);

 // Paint cells

 echo '<td><a name="insertrow"></a>&amp;nbsp;</td>' . "\n";
 echo '<td><input type="submit" value="Insert" name="insertsave" /></td>' . "\n";

 foreach ($columns as $columnname => $column)
 { $value = '';
 $nul   = false;

 if (isset($coldefs[ $columnname ]))
 { $value = $coldefs[ $columnname ][ 'default'  ];
 $nul   = $coldefs[ $columnname ][ 'nullable' ];
 }

 echo '<td>';

 $inputsize = $column[ 'size' ];
 if ($inputsize < 4)
 $inputsize = 4;
 elseif ($inputsize > 48)
 $inputsize = 48;

 echo '<nobr><input type="radio" name="insert[' . $columnname . '][mode]" value="value" ' . ($nul ? '' : 'checked="checked" ') . '/>' . "\n";
 echo '<input type="text" name="insert[' . $columnname . '][value]" value="' . htmlspecialchars($value) .'" size="' . $inputsize . '" ';
 if (($column[ 'size' ] <= 256) &amp;&amp; (($column[ 'type' ] == 'VARCHAR') || ($column[ 'type' ] == 'VARCHAR2')))
 echo 'maxlength="' . $column[ 'size' ] . '" ';
 echo '/></nobr><br />' . "\n";

 echo '<nobr><input type="radio" name="insert[' . $columnname . '][mode]" value="function" ' . ($nul ? 'checked="checked" ' : '') . '/> ' . "\n";
 echo 'Function: <input type="text" name="insert[' . $columnname . '][function]" value="' . ($nul ? 'NULL' : '') .'" size="10" /></nobr>' . "\n";

 echo '</td>' . "\n";
 }
 }
 elseif ($_SESSION[ 'entrymode' ] == 'popups')
 echo '<td colspan="' . (count($columns) + 2) . '"><a href="' . $_SERVER[ 'PHP_SELF' ] . '?sid=' . $sid . '&amp;showinsert=1#insertrow" title="Click here to create a new record in ' . htmlspecialchars($_SESSION[ 'table' ]) . '">Insert new row</a></td>';

 echo '</tr>' . "\n";
 }

 echo '</table>' . "\n";

 echo '<table><tr><td>' . "\n";

 if ($_SESSION[ 'set' ] > 1)
 { echo '<a href="' . $_SERVER[ 'PHP_SELF' ] . '?sid=' . $sid . '&amp;set=1" accesskey="f" title="Click here to go to the first page [f]">|&amp;lt;</a> ';
 echo '<a href="' . $_SERVER[ 'PHP_SELF' ] . '?sid=' . $sid . '&amp;set=' . ($_SESSION[ 'set' ] - 1) . '" accesskey="p" title="Click here to go to the previous page [p]">&amp;lt;&amp;lt;</a> ';
 }

 echo 'Page ' . $_SESSION[ 'set' ];

 if ($morerows)
 echo ' <a href="' . $_SERVER[ 'PHP_SELF' ] . '?sid=' . $sid . '&amp;set=' . ($_SESSION[ 'set' ] + 1) . '" accesskey="n" title="Click here to go to the next page [n]">&amp;gt;&amp;gt;</a>';

 echo '</td></tr></table>' . "\n";
 }
 }
 elseif ($statementtype != '')
 { // Non-SELECT statements

 $rowcount = ocirowcount($cursor);

 $words = array(
 'UPDATE' => 'updated',
 'DELETE' => 'deleted',
 'INSERT' => 'inserted'
 );

 $msg = $rowcount . ' row' . ($rowcount == 1 ? '' : 's') . ' ';

 if (isset($words[ $statementtype ]))
 $msg .= $words[ $statementtype ] . '.';
 else
 $msg = $statementtype . ' affected ' . $msg . '.';

 echo pof_sqlline($msg);
 }

 pof_closecursor($cursor);
 }

 // History popup

 echo '<table><tr><td>' . "\n";
 echo 'History: <select name="history" onChange="javascript:document.forms[0].submit()" title="Select a previous SQL statement">' . "\n";
 echo '<option value="" selected="selected"> </option>' . "\n";
 foreach ($_SESSION[ 'history' ] as $key => $item)
 echo '<option value="' . $key . '">' . htmlspecialchars(substr($item[ 'sql' ], 0, 100)) . '</option>' . "\n";
 echo '</select>' . "\n";
 echo '</td></tr></table>' . "\n";

 // Hidden fields for the currently edited record

 if (is_array($actionrecord))
 { echo '<input type="hidden" name="record[table]" value="' . htmlspecialchars($actionrecord[ 'table' ]) . '" />' . "\n";
 echo '<input type="hidden" name="record[rowid]" value="' . htmlspecialchars($actionrecord[ 'rowid' ]) . '" />' . "\n";
 if ($action != '')
 echo '<input type="hidden" name="action" value="' . $action . '" />' . "\n";
 }

 // Footer

 echo '<table><tr>' . "\n";

 // "Drop cache" link

 echo '<td valign="top"><a href="' . $_SERVER[ 'PHP_SELF' ] . '?sid=' . $sid . '&amp;dropcache=1" title="After altering tables, click here to force a re-read of table definitions">Drop DDL cache</a></td>' . "\n";

 // "Debug" link

 echo '<td valign="top"><a title="Click here to switch SQL statement logging on or off" href="' . $_SERVER[ 'PHP_SELF' ] . '?sid=' . $sid . '&amp;debug=';

 if ($_SESSION[ 'debug' ])
 echo '0">Turn debug mode off';
 else
 echo '1">Turn debug mode on';

 echo '</a><br />(Logs all SQL statements in ' . ini_get('error_log') . ')</td>' . "\n";

 // Oracle environment variables display

 echo '<td valign="top">Oracle environment variables:<br />';

 $env_vars = array( 'ORACLE_SID', 'NLS_LANG', 'NLS_DATE_FORMAT' );

 $first = true;

 foreach ($env_vars as $env_var)
 { $val = getenv($env_var);

 if ($val === false)
 continue;

 if (! $first) echo '<br />';
 echo sprintf("%s=%s\n", $env_var, $val);
 $first = false;
 }

 echo '</td>';

 echo '</tr></table>';
 }

pof_disconnect();

?>

</form>

<a href="http://oracleeditor.sourceforge.net/" title="OracleEditor.php homepage">OracleEditor.php</a> <?php echo $version; ?> &amp;copy; 2006 by <a href="http://tim.digicol.de/" title="Tim Strehle's homepage on tim.digicol.de">Tim Strehle</a> &amp;lt;<a href="mailto:tim@strehle.de" title="Send e-mail to Tim Strehle">tim@strehle.de</a>&amp;gt;

</body>
</html>

&amp;nbsp;

PHP Event Calendar Scripts for Syntax

PHP Event Calendar is reusable PHP script extending the web site’s functionality with event scheduler or news archive.Every aspect of the script is configurable. With the intuitive control panel, minimum efforts are required to set up and maintain the script.Features – Multiple calendars can be created, configured and maintained with the included control panel – Event calendar appearance and features are configured visually – Events or news items are managed visually.

 

 

<?php
// Title: PHP Event Calendar
// URL: http://www.softcomplex.com/products/php_event_calendar/
// Version: 1.5.1
// Date: 03/04/2005 (mm/dd/yyyy)
// Tech. support: http://www.softcomplex.com/forum/forumdisplay.php?fid=55
// Notes: Script is free for non commercial use. Visit official site for details.

?>
<html>
<head>
 <title>PHP Event Calendar - Installer</title>
 <meta name="description" content="PHP Event Calendar is reusable PHP script extending the web site's functilality with event scheduler or news archive. Nice looking calendar is dynamically created on the user's page.">
 <meta name="keywords" content="PHP Event Calendar, scheduler, news archive, server side calendar, netscape, explorer, IE, opera, calendar, date, timestamp">
 <meta name="robots" content="index,follow">
<style>
 a
 {color: #0000aa; text-decoration: none; font-family: Tahoma, Verdana; font-size: 11px}
 a:hover
 {color: #ff0000;}
 p, tr, td, ul, li
 {color: #000000; font-family: Tahoma, Verdana; font-size: 11px}
 .header1, h1
 {color: #ffffff; background: #4682B4; font-weight: bold; font-family: Tahoma, Verdana; font-size: 13px; margin: 0px; padding: 2px;}
 .header2, h2
 {color: #000000; background: #DBEAF5; font-weight: bold; font-family: Tahoma, Verdana; font-size: 12px;}
 .intd
 {color: #000000; font-family: Tahoma, Verdana; font-size: 11px; padding-left: 15px;}
 .inpt
 {color: #000000; font-family: Tahoma, Verdana; font-size: 11px; width: 100%}

</style>
</head>
<body bottommargin="15" topmargin="15" leftmargin="15" rightmargin="15" marginheight="15" marginwidth="15" bgcolor="white">

<!-- Header -->
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tr>
 <td width="350" rowspan="2"><img src="cl_files/img/php_ec.gif" width="350" height="80" border="0" alt="PHP event calendar"></td>
 <td align="right" valign="top"><img src="cl_files/img/logo.gif" width="178" height="30" border="0" alt="Softcomplex logo"></td>
</tr>
<tr>
 <td align="right" valign="bottom" nowrap>
 <b>
 |&amp;nbsp;<a href="http://www.softcomplex.com/about.html">About&amp;nbsp;Us</a>&amp;nbsp;
 |&amp;nbsp;<a href="http://www.softcomplex.com/services.html">Services</a>&amp;nbsp;
 |&amp;nbsp;<a href="http://www.softcomplex.com/download.html">Download</a>&amp;nbsp;
 |&amp;nbsp;<a href="http://www.softcomplex.com/order.html">Order</a>&amp;nbsp;
 |&amp;nbsp;<a href="http://www.softcomplex.com/support.html">Support</a>&amp;nbsp;
 |
 </b>
 </td>
</tr>
<tr><td><img src="cl_files/img/pixel.gif" width="1" height="5" border="0"></td></tr>
</table>
<!-- /Header -->
<table cellpadding="0" cellspacing="0" border="0" bgcolor="#4682B4" width="100%"><tr><td>
<table cellpadding="0" cellspacing="1" width="100%" border="0">
<tr>
 <td valign="top" nowrap>PHP Event Calendar v1.5 Installer</td>
 <td valign="top" width="100%">&amp;nbsp;</td>
</tr>
<tr>
 <td valign="top" bgcolor="#FFFFFF">
 <table cellspacing="1" cellpadding="3" border="0" width="100%">
 <tr>
 <td>Notes</td></tr>
 <tr>
 <td>
 <p><b>Welcome to PHP Event Calendar Installer!</b></p>
 This page will help you to install the event calendar on your server with minimum effords.
 We hope you'll endjoy the product. Don't hesitate to <a href="http://www.softcomplex.com/support.html">contact us</a> if you have any comments or suggestions.
 Our staff and other users of the product will be glad to answer your technical questions in <a href="http://www.softcomplex.com/forum/forumdisplay.php?fid=55">support forum</a>.
 <hr size="1">
 <div align="right"><i>softcomplex team</i></div>
 </td>
 </tr>
 <tr>
 <td><img src="cl_files/img/pixel.gif" width="250" height="1" border="0"></td></tr>
 <tr>
 <td>Advantages</td></tr>
 <tr>
 <td>
 <p><b>Easy maintenance</b> -  Application is fully configurable via convenient control panel. No more need to edit any HTML when you want to publish new event on your site.
 <p><b>Cost Saving Component</b> -It takes only minutes to install PHP Event Calendar on your site. Minimal requirements to server features. Improve the way you manage event and news on your site instantly
 <p><b>Professional Look</b> - Simple great looking improvement to the user interface of your web application. Appearance of the calendar and event pages are easily tuned to conform feel and look of your site.</p>
 </td></tr>
 <tr>
 <td><img height=1 src="cl_files/img/pixel.gif" width="1" border="0"></td></tr>
 <tr>
 <td>Links</td></tr>
 <tr>
 <td><b>
 <ul>
 <li><a href="http://www.softcomplex.com/products/php_event_calendar/">Product page</a>
 <li><a href="http://www.softcomplex.com/forum/forumdisplay.php?fid=55">Product forum</a>
 <li><a href="http://www.softcomplex.com/products/php_event_calendar/docs/">Documentation</a>
 <li><a href="http://www.softcomplex.com/products/php_event_calendar/order.html">Order NOW!</a>
 </ul></b></td></tr>
 <tr><td><img height=1 src="cl_files/img/pixel.gif" width="1" border="0"></td></tr>
 </table>
 </td>
 <td valign="top" bgcolor="#FFFFFF">
 <img src="cl_files/img/pixel.gif" width="1" height="15" border="0"><br>
 <table border="0" cellpadding="0" cellspacing="0" align="center" width="100%">
 <tr>
 <td>
 <table cellspacing="0" cellpadding="0" align="center" width="80%" border="0">
 <tr>
 <td align="center" valign="top">
 <?php
 error_reporting (e_all ^ e_notice);
 function install(){
 global $_SERVER,$_POST,$real_paths,$mess;
 extract($_POST);
 $files_path=$real_paths['files'];
 $img_path=$real_paths['img'];
 $data_path=$real_paths['data'];
 $path_translated = str_replace("\\","/",$_SERVER['PATH_TRANSLATED']);
 $path_translated = str_replace("//","/",$path_translated);
 $path_info = str_replace("\\","/",$_SERVER["SCRIPT_NAME"]);
 $document_root = str_replace($path_info,"",$path_translated);

 $img_web_path='http://'.$_SERVER["HTTP_HOST"].str_replace($document_root,'',str_replace("//","/",str_replace("\\","/",$real_paths['img'])));
 if($fp=@fopen('./calendar.dat','r')){
 while (!feof($fp)) {
 $c .= fgets($fp, 4096);
 }
 $cont='
$PATHS=array(
"path_to_calendar" => "'
.str_replace("\\","\\\\",$files_path).'",
"path_to_calendar_img" => "'
.str_replace("\\","\\\\",$img_path).'",
"WEB_path_to_calendar_img" => "'
.$img_web_path.'",
"path_to_data" => "'
.str_replace("\\","\\\\",$data_path).'"
);'
;
 $c=str_replace("<--path-->",$cont,$c);
 fclose($fp);
 $fp=fopen($files_path.'/calendar.php','w+');
 fwrite($fp,$c);
 fclose($fp);
 chmod(realpath($files_path.'/calendar.php'),0664);
 echo "<h2>Paths to files have been updated.</h2>";
 }else{
 echo '<h2><font color="red">Can not create calendar.php file please check permission and try again.</font></h2>';
 return false;
 }
 $c = '';
 if($fp=@fopen('./global.php','r')){
 while (!feof($fp)) {
 $c .= fgets($fp, 4096);
 }
 $cont='
$PATHS=array(
"path_to_calendar" => "'
.str_replace("\\","\\\\",$files_path).'",
"path_to_calendar_img" => "'
.str_replace("\\","\\\\",$img_path).'",
"WEB_path_to_calendar_img" => "'
.$img_web_path.'",
"path_to_data" => "'
.str_replace("\\","\\\\",$data_path).'"
);'
;
 $c=str_replace("<--path-->",$cont,$c);
 fclose($fp);
 $fp=fopen($data_path.'/global.php','w+');
 fwrite($fp,$c);
 fclose($fp);
 chmod(realpath($data_path.'/global.php'),0664);
 echo "<h2>Paths to files have been updated.</h2>";
 }else{
 echo '<h2><font color="red">Can not create config file please check permission and try again.</font></h2>';
 return false;
 }
 if($mess['img']){
 echo "<h2>Upload new arrow images is impossible, because image folder is not writable.</h2>";
 }
 if(!$error){
 if(is_file('./install_dat.php')){
 include './install_dat.php';
 }else{
 echo '<h2><font color="red">Can not find install_dat.php file.</font></h2>';
 return false;
 }
 echo '<form><textarea cols="100" rows="10">';
 foreach($data as $k=>$v){
 if(is_array($v)){
 if($k=='groups.php' || $k=='users.php') $content='<?php '.serialize($v).'?>';
 else $content = serialize($v);
 @unlink($data_path.'/'.$k);
 $fp=@fopen($data_path.'/'.$k,'w+');
 fwrite($fp,$content);
 fclose($fp);
 echo $data_path.'/'.$k." file has been created \n";
 }
 }
 }
 echo '</textarea><h2>Installation files removal.</h2><textarea cols="100" rows="5">';

 if(@unlink('./install_dat.php')){
 echo "installer.dat file has been removed.\n";
 }else{
 echo "Please remove install_dat.php file manually.\n";
 }
 if(@unlink('./install.php')){
 echo "install.php file has been removed.\n";
 }else{
 echo "Please remove install.php file manually.\n";
 }
 if(@unlink('./global.php')){
 echo "global.php file has been removed.\n";
 }else{
 echo "Please remove global.php file manually.\n";
 }
 if(@unlink('./calendar.dat')){
 echo "calendar.dat file has been removed.\n";
 }else{
 echo "Please remove calendar.dat file manually.\n";
 }
 echo "</textarea></form><h2>Installation is complete</h2><a href=index.php>Calendar demo page</a>";
 }
 function My_is_writable($name){
 if(is_dir($name)){
 if($fp = @fopen($name.'/dfashdfjdshfsjdfhjks.tst','w+')){
 fclose($fp);
 unlink($name.'/dfashdfjdshfsjdfhjks.tst');
 return true;
 }
 return false;
 }else{

 }
 }
 function copy_folder($from,$to){
 if ($handle = opendir($from)) {
 while (false !== ($file = readdir($handle))) {
 if ($file != "." &amp;&amp; $file != ".."){
 copy($from.'/'.$file,$to.'/'.$file);
 }
 }
 closedir($handle);
 }
 }
 function check_install(){
 global $_POST,$error,$real_paths,$mess;
 extract($_POST);
 $error = array();
 if(function_exists('posix_geteuid')){
 $my_uid = posix_geteuid();
 $my_gid = posix_getegid();
 }else{
 $my_uid = getmyuid();
 $my_gid = getmygid();
 }
 if(!$install){
 return false;
 }
 if(!$files_path){
 $error['files']="Please set Files directory path.";
 }
 if(!is_dir($files_path)){
 $error['files']="Please set correct Files directory path.<br>
 Folder "
.$files_path." does not exists.";
 }
 if(!$data_path){
 $error['data']="Please set Data directory path.";
 }
 if(!is_dir($data_path)){
 $error['data']="Please set correct Data directory path.<br>
 Folder "
.$data_path." does not exists.";
 }
 if(!$img_path){
 $error['img']="Please set Image directory path.";
 }
 if(!is_dir($img_path)){
 $error['img']="Please set correct Image directory path.<br>
 Folder "
.$data_path." does not exists.";
 }
 if(!$error['files'])
 if(!My_is_writable($real_paths['files'])){
 $stat=stat ($real_paths['files']);
 $dir_gid = $stat['gid'];
 $dir_uid = $stat['uid'];
 $dir_perm = substr(decoct($stat['mode']),-4);
 if($dir_gid==$my_gid) $dir_perm[2]=7;
 else $dir_perm[3]=7;
 $error['files']="Can not create any files in ".$real_paths['files']." directory. Please set ". $dir_perm." permission on ".$real_paths['files']." directory. Please check permission and try again.";
 }
 if(!$error['data'])
 if(!My_is_writable($real_paths['data'])){
 $stat=stat ($real_paths['data']);
 $dir_gid = $stat['gid'];
 $dir_uid = $stat['uid'];
 $dir_perm = substr(decoct($stat['mode']),-4);
 if($dir_gid==$my_gid) $dir_perm[2]=7;
 else $dir_perm[3]=7;
 $error['data']="Can not create any files in ".$real_paths['data']." directory. Please set ". $dir_perm." permission on ".$real_paths['data']." directory. Please check permission and try again.";
 }else{
 copy_folder('./tmp/data/',$real_paths['data']);
 }
 if(!$error['img'])
 if(!My_is_writable($real_paths['img'])){
 $stat=stat ($real_paths['img']);
 $dir_gid = $stat['gid'];
 $dir_uid = $stat['uid'];
 $dir_perm = substr(decoct($stat['mode']),-4);
 if($dir_gid==$my_gid) $dir_perm[2]=7;
 else $dir_perm[3]=7;
 $mess['img']="Can not create any files in ".$real_paths['img']." directory. Please set ". $dir_perm." permission on ".$real_paths['img']." directory. Please check permission and try again.";
 }
 if(count($error)){
 return false;
 }
 return true;
 }
 function is_windows(){
 global $_SERVER;
 if(stristr($_SERVER['OS'],'wind') || stristr($_SERVER['SERVER_SOFTWARE'],'microsoft')) return true;
 return false;
 }
 extract($_POST);
 $root_path=str_replace("install.php",'',$_SERVER['PATH_TRANSLATED']);
 if(is_windows()){
 $real_paths=array(
 'data'=>$data_path?stripslashes($data_path):$root_path."cl_files\\\\data\\\\",
 'img'=>$img_path?stripslashes($img_path):$root_path."cl_files\\\\img\\\\",
 'files'=>$files_path?stripslashes($files_path):$root_path."cl_files\\\\"
 );
 }else{
 $real_paths=array(
 'data'=>$data_path?$data_path:$root_path."cl_files/data/",
 'img'=>$img_path?$img_path:$root_path."cl_files/img/",
 'files'=>$files_path?$files_path:$root_path."cl_files/"
 );
 }
 if(check_install()){
 install();
 }else{
 ?>

 <form action="install.php" method="post">
 <table border="0" cellspacing="0" cellpadding="6" width="80%">
 <tr><th style="color: white; background: #4682B4; padding: 3px 5px 3px 5px;">Calendar Installation Paths</th></tr>
 <tr>
 <td bgcolor="#DBEAF5">
 <table border="0" cellspacing="0" cellpadding="1" width="100%">
 <tr><td colspan="2">
 <?php  if ($error['files'] || $error['data'] || $error['img']) { ?>
 <!-- error message -->
 <table border="0" cellspacing="1" cellpadding="5" align="center" bgcolor="#cc9999" width="100%" style="margin-bottom:10px">
 <tr><td bgcolor="#FFEEEE">
 <ul>
 <?php if($error['files']) echo "<li>".$error['files']."</li>";?>
 <?php if($error['data'])  echo "<li>".$error['data']."</li>";?>
 <?php if($error['img'])   echo "<li>".$error['img']."</li>";?>
 </ul>
 </td></tr>
 </table>
 <!-- /error message -->
 <?php  } ?>
 </td></tr>
 <tr>
 <td width="105" nowrap<?php if($error['files'])echo " style=\"color:red;\"";?>>Script files directory:</td>
 <td><input type="Text" name="files_path" value="<?php echo $real_paths['files']?>"></td>
 </tr>
 <tr>
 <td width="105" nowrap<?php if($error['data'])echo " style=\"color:red;\"";?>>Data files directory:</td>
 <td><input type="Text" name="data_path" value="<?php echo $real_paths['data']?>"></td>
 </tr>
 <tr>
 <td width="105" nowrap<?php if($error['img'])echo " style=\"color:red;\"";?>>Images directory:</td>
 <td><input type="Text" name="img_path" value="<?php echo $real_paths['img']?>"></td>
 </tr>
 <tr>
 <td colspan="2" align="right" valign="bottom" height="28">
 <input type="submit" name="install" value="Install" style="width: 100px;font-size: 11px;">
 </td>
 </tr>
 </table>
 </td>
 </table>
 </form>
 <?php }?>
 </td>
 </tr>
 </table>
 </td>
 </tr>
 </table>
 <img src="cl_files/img/pixel.gif" width="1" height="15" border="0"><br>
 </td>
</tr>
</table>
</td></tr></table>
<!-- /Body -->

<!-- Footer -->
<table cellpadding="3" cellspacing="0" width="100%" border="0" height="20">
<tr bgcolor="#4682B4">
 <td nowrap style="padding-left: 10px;"><font color="white">Copyright &amp;copy;2004 SoftComplex Inc. All rights reserved.</font></td>
 <td align="right">
 | <a href="http://www.softcomplex.com/"><font color="white">company info</font></a>
 | <a href="http://www.softcomplex.com/site_agreement.html"><font color="white">terms of service</font></a>
 | <a href="http://www.softcomplex.com/privacy_policy.html"><font color="white">privacy policy</font></a>
 |
 </td>
</tr>
</table>
<!-- /Footer -->

</body>
</html>

&amp;nbsp;

&amp;nbsp;

PHP Profession Script for Syntax

Need employees? phprofession is a php script for companies to post jobs available on the web, allowing potential employees to browse – much like Monster.com. It’s all contained in one source, resulting in very fast speeds and makes modifying source …

 

 

<?
/////////////////////////////
#############################
#       phProfession        #
# The Resume Posting Script #
# Source by Mykel Nahorniak #
#############################
/////////////////////////////

/*
This is the config file for phProfession.
Edit it to suit your computer's needs before
using the script for maximum performance.
*/


$Version = "1.05 Beta";

### Put the Administrator's e-mail here ###

$Admin_Email = "mhn@mitre.org";

##############################
# MySQL Database Connections #
##############################

$database="jobs";
$user = "root";
$pass = "";
$hostname = "localhost";

### Connect to Database ###
$connection = mysql_pconnect($hostname, $user, $pass) or die ("Unable to connect to MySQL!");

//////////////////////////////////////
######################################
# Functions included in phProfession #
######################################
//////////////////////////////////////

 ############################
# Format MySQL Date Values #
############################

 function fixDate($val)
 {
 ### Split date up into components ###

 $arr = explode(" ", $val);
 $datearr = explode("-", $arr[0]);

 ### Creating timestamp ###

 return date("d M Y", mktime(0, 0, 0, $datearr[1], $datearr[2], $datearr[0]));
 }

 #########################
# E-Mail Validity Check #
#########################

 function isEmailInvalid($val)
 {
 ### Regex for e-mail validation ###

 $pattern = "/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/";

 ### Match? ###

 if(preg_match($pattern, $val))
 {
 return 0;
 }
 else
 {
 return 1;
 }
 }

 ############################################
# List of errors after validating the form #
############################################

 function listErrors()
 {
 ### Read the errorList array ###

 global $errorList;

 ### Print as list ###

 echo "The following errors were encountered: <br>";
 echo "<ul>";
 for ($x=0; $x<sizeof($errorList); $x++)
 {
 echo "<li>$errorList[$x]";
 }
 echo "</ul>";

 ### Link to return to previous page ###

 echo "Click <a href=javascript:history.back();>here</a> to go back to the previous page and correct the errors";
 }

?>

&amp;nbsp;

PHP eBay Clone Script for Syntax

eBay Clone Script 2010. If you are looking for the best auction software anywhere on the web, here’s an amazing opportunity to get a professional software package and start your own professional online auction with no programming skills. eBay Clone software is the latest and most advanced Auction Script to set up an online auction site with excellent navigation features. We will help you build your own online Auction with custom programming. Our Auction Script can be easily customized

http://www.v-eva.com/products/eBay-Clone-Script-2010.html

If you are looking for the best auction software anywhere on the web,
here's an amazing opportunity to get a professional
software package and start your own professional online
auction with no programming skills.
eBay Clone software is the latest and most advanced
Auction Script to set up an online auction
site with excellent navigation features.
We will help you build your own online Auction with
custom programming.
Our Auction Script can be easily customized to your needs
with a potential way to generate heavy revenues.
Our eBay Clone software is simple to use with a single
administrative interface.
You can control every aspect of the website through
this all inclusive user friendly Admin
Panel with minimum server requirements.
eBay Clone Script offers flexibility and feature rich
options that are simple to deploy and easy to manage.
Its features include HTML templates for easy design changes,
the ability to create an unlimited number of categories
and sub-categories, Multiple Payment Gateways,
Extended Search Options, Full bidding and buy it now options,
Versatile User Management options and so on.
Its features are updated frequently and freely distributed.

http://www.v-eva.com/products/eBay-Clone-Script-2010.html

&amp;nbsp;

&amp;nbsp;

Stimulsoft Reports Fx for PHP Syntax

Stimulsoft Reports.Fx for PHP is a reporting tool designed for creating reports in the Internet using a client-server technology. In this product we have combined two technologies. The PHP script works on the server-side. This technology controls the report generation. The Adobe Flash technology works on the client side. This technology provides a universal mechanism for reports generation almost on any client. Due to this, it is very easy to use Stimulsoft Reports.Fx and at the same time, the product offers a modern, cost-effective way to provide reports on Web sites.

 

 

<?php

//--------------------------------------
//  Methods
//--------------------------------------

 function getXmlKeyValue($value, $key)
 {
 if (strpos($value, "<".$key.">") < 0 || strpos($value, "</".$key.">") < 0) return "";
 return substr(substr($value, 0, strpos($value, "</".$key.">")), strpos($value, "<".$key.">") + strlen($key) + 2);
 }

//--------------------------------------
//  MSSQL Database
//--------------------------------------

 function parseSqlConnectionString($connectionString)
 {
 class connectionInfo {
 var $host;
 var $database;
 var $userId;
 var $password;
 }

 $object = new connectionInfo;
 $parameters = split(";", $connectionString);
 foreach($parameters as $parameter)
 {
 $parts = split("=", $parameter);
 $name = $parts[0];
 $value = $parts[1];

 if (isset($value))
 {
 switch (strtolower($name))
 {
 case "data source":
 case "server":
 $object->host = $value;
 break;

 case "database":
 case "initial catalog":
 $object->database = $value;
 break;

 case "user id":
 $object->userId = $value;
 break;

 case "password":
 $object->password = $value;
 break;
 }
 }
 }

 return $object;
 }

 function convertSqlType($type)
 {
 switch (strtolower($type))
 {
 case "numeric":
 case "int":
 return "System.Int64";

 case "blob":
 case "bit":
 case "char":
 case "image":
 case "text":
 return "System.String";

 case "datetime":
 return "System.DateTime";

 case "real":
 case "money":
 return "System.Decimal";
 }

 return $type;
 }

 function testSqlConnection($host, $database, $userId, $password)
 {
 $link = mssql_connect($host, $userId, $password) or die("ServerError:Could not connect to host.");
 mssql_close($link);

 return "Successfull";
 }

 function getSqlDatabaseColumns($host, $database, $userId, $password, $query)
 {
 $link = mssql_connect($host, $userId, $password) or die("ServerError:Could not connect to host.");
 mssql_select_db($database, $link) or die("ServerError:Could not find database.");

 $result = mssql_query($query, $link) or die("ServerError:Data not found.");

 $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 $xml_output .= "<Tables>\n";

 $i = 0;
 while ($column = mssql_fetch_field($result))
 {
 if ($i == 0) $xml_output .= "  <Table name='".$column->table."'>\n";
 $xml_output .= "    <Column name='".$column->name."' type='".convertSqlType($column->type)."' />\n";
 $i++;
 }
 $xml_output .= "  </Table>\n";
 $xml_output .= "</Tables>";

 mssql_free_result($result);
 mssql_close($link);

 return $xml_output;
 }

 function getDataFromSqlDatabase($host, $database, $userId, $password, $query)
 {
 $link = mssql_connect($host, $userId, $password) or die("ServerError:Could not connect to host.");
 mssql_select_db($database, $link) or die("ServerError:Could not find database.");

 $result = mssql_query($query, $link) or die("ServerError:Data not found.");

 $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 $xml_output .= "<Database>\n";

 $i = 0;
 while ($column = mssql_fetch_field($result))
 {
 $columns[$i] = $column->name;
 $i++;
 }

 while ($row = mssql_fetch_assoc($result))
 {
 $xml_output .= "  <TableName>\n";
 foreach($columns as $column)
 {
 $value = $row[$column];
 $value = str_replace("&amp;", "&amp;amp;", $value);
 $value = str_replace("<", "&amp;lt;", $value);
 $value = str_replace(">", "&amp;gt;", $value);

 $xml_output .= "    <".$column.">".$value."</".$column.">\n";
 }
 $xml_output .= "  </TableName>\n";
 }

 mssql_free_result($result);
 mssql_close($link);

 $xml_output .= "</Database>\n";
 return $xml_output;
 }

//--------------------------------------
//  MySql Database
//--------------------------------------

 function parseMySqlConnectionString($connectionString)
 {
 class connectionInfo {
 var $host;
 var $port = "3306";
 var $database;
 var $userId;
 var $password;
 }

 $object = new connectionInfo;
 $parameters = split(";", $connectionString);
 foreach($parameters as $parameter)
 {
 $parts = split("=", $parameter);
 $name = $parts[0];
 $value = $parts[1];

 if (isset($value))
 {
 switch (strtolower($name))
 {
 case "server":
 case "host":
 case "location":
 $object->host = $value;
 break;

 case "port":
 $object->port = $value;
 break;

 case "database":
 case "datasource":
 case "data source":
 $object->database = $value;
 break;

 case "uid":
 case "user":
 case "userid":
 case "user id":
 $object->userId = $value;
 break;

 case "pwd":
 case "password":
 $object->password = $value;
 break;
 }
 }
 }

 return $object;
 }

 function convertMySqlType($type)
 {
 switch (strtolower($type))
 {
 case "string":
 case "blob":
 return "System.String";

 case "int":
 return "System.Int32";

 case "real":
 return "System.Decimal";

 case "date":
 case "time":
 case "datetime":
 return "System.DateTime";
 }

 return $type;
 }

 function testMySqlConnection($host, $port, $database, $userId, $password)
 {
 $link = mysql_connect($host.":".$port, $userId, $password) or die("ServerError:Could not connect to host.");
 mysql_close($link);

 return "Successfull";
 }

 function getMySqlDatabaseColumns($host, $port, $database, $userId, $password, $query)
 {
 $link = mysql_connect($host.":".$port, $userId, $password) or die("ServerError:Could not connect to host.");
 mysql_select_db($database, $link) or die("ServerError:Could not find database.");

 $result = mysql_query($query, $link) or die("ServerError:Data not found.");

 $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 $xml_output .= "<Tables>\n";

 $i = 0;
 while ($column = mysql_fetch_field($result))
 {
 $columns[$i] = $column->name;

 if ($i == 0) $xml_output .= "  <Table name='".$column->table."'>\n";
 $xml_output .= "    <Column name='".$column->name."' type='".convertMySqlType($column->type)."' />\n";
 $i++;
 }
 $xml_output .= "  </Table>\n";
 $xml_output .= "</Tables>";

 mysql_free_result($result);
 mysql_close($link);

 return $xml_output;
 }

 function getDataFromMySqlDatabase($host, $port, $database, $userId, $password, $query)
 {
 $link = mysql_connect($host.":".$port, $userId, $password) or die("ServerError:Could not connect to host.");
 mysql_select_db($database, $link) or die("ServerError:Could not find database.");

 $result = mysql_query($query, $link) or die("ServerError:Data not found.");

 $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 $xml_output .= "<Database>\n";

 $i = 0;
 while ($column = mysql_fetch_field($result))
 {
 $columns[$i] = $column->name;
 $i++;
 }

 while ($row = mysql_fetch_assoc($result))
 {
 $xml_output .= "  <TableName>\n";
 foreach($columns as $column)
 {
 $value = $row[$column];
 $value = str_replace("&amp;", "&amp;amp;", $value);
 $value = str_replace("<", "&amp;lt;", $value);
 $value = str_replace(">", "&amp;gt;", $value);

 $xml_output .= "    <".$column.">".$value."</".$column.">\n";
 }
 $xml_output .= "  </TableName>\n";
 }

 mysql_free_result($result);
 mysql_close($link);

 $xml_output .= "</Database>\n";
 return $xml_output;
 }

//--------------------------------------
//  PostgreSQL Database
//--------------------------------------

 function parsePgSqlConnectionString($connectionString)
 {
 class connectionInfo
 {
 var $host;
 var $port = "5432";
 var $database;
 var $userId;
 var $password;
 }

 $object = new connectionInfo;
 $parameters = split(";", $connectionString);
 foreach($parameters as $parameter)
 {
 $parts = split("=", $parameter);
 $name = $parts[0];
 $value = $parts[1];

 if (isset($value))
 {
 switch (strtolower($name))
 {
 case "server":
 case "host":
 case "location":
 $object->host = $value;
 break;

 case "port":
 $object->port = $value;
 break;

 case "database":
 case "datasource":
 case "data source":
 $object->database = $value;
 break;

 case "uid":
 case "user":
 case "userid":
 case "user id":
 $object->userId = $value;
 break;

 case "pwd":
 case "password":
 $object->password = $value;
 break;
 }
 }
 }

 return $object;
 }

 function convertPgSqlType($type)
 {
 switch (strtolower($type))
 {
 case "varchar":
 case "bpchar":
 case "macaddr":
 case "inet":
 case "money":
 case "text":
 case "interval":
 case "bit":
 case "varbit":
 case "bytea":
 return "System.String";

 case "bool":
 return "System.Boolean";

 case "int8":
 case "int4":
 case "int2":
 return "System.Int32";

 case "date":
 case "time":
 case "timetz":
 case "timestamp":
 case "timestamptz":
 return "System.DateTime";
 default:
 return "System.Decimal";
 }

 return $type;
 }

 function testPostgreSQLConnection($host, $port, $database, $userId, $password)
 {
 $link = pg_connect("host=$host port=$port dbname=$database user=$userId password=$password") or die("ServerError:Could not connect to host.");
 pg_close($link);

 return "Successfull";
 }

 function getPostgreSQLDatabaseColumns($host, $port, $database, $userId, $password, $query)
 {
 $link = pg_connect("host=$host port=$port dbname=$database user=$userId password=$password") or die("ServerError:Could not connect to host.");

 $result = pg_query($link, $query) or die("ServerError:Data not found.");

 $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 $xml_output .= "<Tables>\n";

 $i = pg_num_fields($result);
 for ($j = 0; $j < $i; $j++)
 {
 if ($j == 0) $xml_output .= "  <Table name='".""."'>\n";
 $xml_output .= "    <Column name='".pg_field_name($result, $j)."' type='".convertPgSqlType(pg_field_type($result, $j))."' />\n";
 }

 $xml_output .= "  </Table>\n";
 $xml_output .= "</Tables>";

 pg_free_result($result);
 pg_close($link);

 return $xml_output;
 }

 function getDataFromPostgreSQLDatabase($host, $port, $database, $userId, $password, $query)
 {
 $link = pg_connect("host=$host port=$port dbname=$database user=$userId password=$password") or die("ServerError:Could not connect to host.");

 //$query=str_replace('{idkp}', isset($_SESSION['idkp']) ? $_SESSION['idkp'] : 0, $query);
 $result = pg_query($link, $query) or die("ServerError:Data not found.");

 $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 $xml_output .= "<Database>\n";

 $i = pg_num_fields($result);
 for ($j = 0; $j < $i; $j++)
 {
 $columns[$j] = pg_field_name($result, $j);
 }

 while ($row = pg_fetch_assoc($result))
 {
 $xml_output .= "  <TableName>\n";
 foreach($columns as $column)
 {
 $value = $row[$column];
 $value = str_replace("&amp;", "&amp;amp;", $value);
 $value = str_replace("<", "&amp;lt;", $value);
 $value = str_replace(">", "&amp;gt;", $value);

 $xml_output .= "    <".$column.">".$value."</".$column.">\n";
 }
 $xml_output .= "  </TableName>\n";
 }

 pg_free_result($result);
 pg_close($link);

 $xml_output .= "</Database>\n";
 return $xml_output;
 }

//--------------------------------------
//  ODBC Database
//--------------------------------------

 function parseOdbcConnectionString($connectionString)
 {
 class connectionInfo {
 var $dsn;
 var $userId;
 var $password;
 }

 $object = new connectionInfo;
 $object->dsn = "";
 $parameters = split(";", $connectionString);
 foreach($parameters as $parameter)
 {
 $parts = split("=", $parameter);
 $name = $parts[0];
 $value = $parts[1];

 if (isset($value))
 {
 switch (strtolower($name))
 {
 case "uid":
 case "user id":
 case "user":
 $object->userId = $value;
 break;

 case "pwd":
 case "password":
 $object->password = $value;
 break;

 default:
 if ($object->dsn != "") $object->dsn .= ";";
 $object->dsn .= $parameter;
 break;
 }
 }
 }

 return $object;
 }

 function convertOdbcType($type)
 {
 switch (strtolower($type))
 {
 case "varchar":
 case "longchar":
 return "System.String";

 case "counter":
 case "integer":
 case "byte":
 return "System.Int32";

 case "currency":
 case "double":
 return "System.Decimal";

 case "bit":
 return "System.Boolean";

 case "longbinary":
 return "System.Byte[]";

 case "datetime":
 return "System.DateTime";
 }

 return $type;
 }

 function testOdbcConnection($dsn, $userId, $password)
 {
 $link = odbc_connect($dsn, $userId, $password) or die("ServerError:Could not connect to host.");
 odbc_close($link);

 return "Successfull";
 }

 function getOdbcDatabaseColumns($dsn, $userId, $password, $query)
 {
 $link = odbc_connect($dsn, $userId, $password) or die("ServerError:Could not connect to host.");
 $result = odbc_exec($link, $query) or die("ServerError:Data not found.");

 odbc_fetch_row($result);
 $num = odbc_num_fields($result);

 $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 $xml_output .= "<Tables>\n";
 $xml_output .= "  <Table name='TableName'>\n";

 for($i = 1; $i <= $num; $i++)
 {
 $xml_output .= "    <Column name='".odbc_field_name($result, $i)."' type='".convertOdbcType(odbc_field_type($result, $i))."' />\n";
 }

 $xml_output .= "  </Table>\n";
 $xml_output .= "</Tables>";

 odbc_free_result($result);
 odbc_close($link);

 return $xml_output;
 }

 function getDataFromOdbcDatabase($dsn, $userId, $password, $query)
 {
 $link = odbc_connect($dsn, $userId, $password) or die("ServerError:Could not connect to host.");
 $result = odbc_exec($link, $query) or die("ServerError:Data not found.");

 $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 $xml_output .= "<Database>\n";

 odbc_fetch_row($result, 0);
 $num = odbc_num_fields($result);

 for($i = 1; $i <= $num; $i++)
 {
 $columns[$i] = odbc_field_name($result, $i);
 }

 while (odbc_fetch_row($result))
 {
 $xml_output .= "  <TableName>\n";
 for($i = 1; $i <= $num; $i++)
 {
 $type = convertOdbcType(odbc_field_type($result, $i));
 $column = $columns[$i];
 $value = odbc_result($result, $column);

 if ($type == "System.Byte[]") $value = base64_encode($value);
 else
 {
 $value = str_replace("&amp;", "&amp;amp;", $value);
 $value = str_replace("<", "&amp;lt;", $value);
 $value = str_replace(">", "&amp;gt;", $value);
 }

 $xml_output .= "    <".$column.">".$value."</".$column.">\n";
 }
 $xml_output .= "  </TableName>\n";
 }

 odbc_free_result($result);
 odbc_close($link);

 $xml_output .= "</Database>\n";

 return $xml_output;
 }
?>

&amp;nbsp;

PHP Shell Tools Scripts for Syntax

PHP Shell Tools is a PHP script that acts as a unix shell console. It basically lets the user execute shell commands and other related features via PHP. For security reasons, all users must login to be able to use PHP Shell Tools, for this reason, PHP Shell Tools must use a MySQL database to be able to store the users and their passwords. All user passwords are encrypted using SHA1 encryption.

 

 

<?php

/******************************************************************************************************
*
* shell.php        Author: Aaron Keier
*
* This file is used to execute shell commands.
*
* Please note that this software is released under the GNU General Public License. This means that
* this software is open source; this means it is free for anyone to use, and free for anyone to look
* at the code that is contained in this software.
*
* Please be aware that this software is released WITHOUT WARRANTY; while this software was tested
* for any problems, it may be vulnerable to several bugs/exploits. The author of this software is NOT
* responsible for any damage that results from the use of this software: the user of this software
* assumes FULL RESPONSIBILITY of any use of this code.
*
* If you have any questions regarding this software, you may ask them at the following location:
*
* http://turkeybot.info/boards/topics.php?board=18
*
******************************************************************************************************/


ob_start('ob_gzhandler');

require_once 'inc/definitions.php';
require_once 'inc/connect.php';
require_once 'inc/functions.php';
require_once 'inc/xhtml.php';

auth_kill($auth_check);                                            //Kill script for unauthorized users

$cmd=isset($_POST['cmd']) ? trim($_POST['cmd']):'';                //Fetch the command
$cgi=isset($_POST['cgi']) ? 1:0;                                //Check to see if form is used
$dir=isset($_GET['dir']) ? $_GET['dir'] :'';                    //Fetch directory from URL

//Check to see if directory contents should be auto-listed
if (isset($_POST['listcheck']))

{

 $listcheck=1;

} else if (isset($_GET['listcheck']))

{

 $listcheck=(int)$_GET['listcheck'];

} else

{

 $listcheck=0;

}


//If $dir is a directory, run a command to switch to that directory.
if (is_dir($dir))

{

 $cmd='cd ' .urldecode($dir). ';';

}

//-----------------------------------------------------------------------------------------------------
// Add 'ls -lart;' command if auto-list is enabled, and is allowed
//-----------------------------------------------------------------------------------------------------

if (($listcheck) &amp;&amp; (stristr($cmd,'cd')) &amp;&amp; (!stristr($cmd,'ls')))

{

 $cmd.=' ls -lart;';

}

//Check for an error, and get the output of the command

if ($cmd)

{

 $output=shell_exec($cmd);
 $error=0;

} else

{

 $output='';

}

//-----------------------------------------------------------------------------------------------------
// Fetch the current working directory: if impossible, then the 'pwd' command is executed to fetch the
// working shell directory.
//-----------------------------------------------------------------------------------------------------

if (stristr($cmd,'cd') &amp;&amp; (!$error))

{

 $pos=str_last_occurrence($cmd,'cd ')+5;
 $string=substr($cmd,$pos);
 $dir=trim(substr($string,0,strpos($string,';')));

} else

{

 $dir=shell_exec('pwd');

}

//-----------------------------------------------------------------------------------------------------
// Set cookie for initial directory to assist in resetting shell
//-----------------------------------------------------------------------------------------------------

if (!isset($_COOKIE['initial_dir']))

{

 setcookie('initial_dir',$dir,0);

}

//-----------------------------------------------------------------------------------------------------
// Do several replace functions on the $output to provide an easier interface.
//-----------------------------------------------------------------------------------------------------

$output=htmlentities($output);                        //Go ahead and htmlentitity the output

//If the output is a directory listing, we are going to turn the directories into links!

if (stristr($output,"..\n"))

{

 $output_array=explode("\n",$output);
 $before_replace_array=array();
 $after_replace_array=array();

 unset($output_array[0]);

 foreach ($output_array as $output_key=>$output_value)

 {

 $output_value.=NL;

 $pos=strrpos($output_value,' ');
 $string=substr($output_value,$pos);
 $link=substr($string,0,strpos($string,"\n"));

 $link=trim($link);

 $fixed_dir=str_replace('//','/',$dir.'/'.$link);        //Remove double slashes

 $before_replace_array[]=$string;
 $after_replace_array[]=' <a onclick="cmdwrite(\'cd ' .$fixed_dir. ';\'); return false;" ' .
 'href="shell.php?dir=' .$fixed_dir. '&amp;amp;listcheck=' .$listcheck. '">' .
 trim($link). '</a>' .NL. '';

 }

 $output=str_replace($before_replace_array,$after_replace_array,$output);

}

$error_message='Command failed: Invalid syntax or permission denied.';    //Create error message

//-----------------------------------------------------------------------------------------------------
// Handle form submittal
//-----------------------------------------------------------------------------------------------------

if ($output)

{

 //-------------------------------------------------------------------------------------------------
 // If the command works, then we will output the results of the command; else, an error message is
 // returned.
 //-------------------------------------------------------------------------------------------------

 $newoutput=!$error ? $output:$error_message;

} else

{

 $newoutput=false;

}

//If the page title will vary depending on whether or not a command was executed

$pagetitle=((!$cmd) &amp;&amp; (!$output)) ? 'Welcome to <em>PHP Shell Tools</em>':'Command Results';

echo '<div>' .$pagetitle. '</div>


'
;

//If there is output, and data was submitted, we are going to output the output
if ($newoutput)

{

 echo '
 <div>'
.$newoutput. '</div>' .NL. '';

}

//-----------------------------------------------------------------------------------------------------
// Output the command form
//-----------------------------------------------------------------------------------------------------

echo '
<form id="command" action="shell.php" method="post">

<div><strong>Command Options</strong></div>
<div>
<ul>
<li>
<span onclick="cmdwrite(\'cd /; \'); auto_list_set();">
Go to &amp;quot;/&amp;quot; directory
</span>
</li>
<li>
<span onclick="cmdwrite(dirCookie); auto_list_set();">
Reset working directory
</span>
</li>
</ul>
</div>

<div><strong>Command Prompt</strong></div>

<div><br />
<input type="text" name="cmd" value="" size="60" /><br />
</div>

<div>
<em>Current Working Directory</em>: <strong>'
.$dir. '</strong><p />
</div>

<div>
Automatically List Directory Contents When Allowed: <input type="checkbox" name="listcheck" value="1" '
;

if ($listcheck)

{

 echo 'checked="checked" ';

}

echo '/><p />
</div>

<div>
<input type="submit" name="cgi" value="Execute Command" /> <input type="reset" name="reset" value="Clear Command" /><p />
</div>

</form>
'
;

require_once 'inc/footer.php';
ob_end_flush();
?>

&amp;nbsp;

&amp;nbsp;

PHP-AGTC Graphical Hits Counter Syntax

Very easy to integrate into any PHP script and you have the option of 4 different types of graphics for your display.

 

 

<?php
 // *************************************************************************************************
// Title:             PHP AGTC-Graphical Hits Counter v3.1
// Developed by:     Andy Greenhalgh
// Email:            andy@agtc.co.uk
// Website:            agtc.co.uk
// Copyright:        2005-2006(C)Andy Greenhalgh - (AGTC)
// Licence:            GPL, You may distribute this software under the terms of this General Public License
//                     You must retain the AGTC link on the hits counter to use without purchasing a full licence
// *************************************************************************************************
// Read the data.dat file for count check
$file="../hitscounter/data.dat";
if (!$handle = fopen($file, 'r')) {
 echo"Cannot read file ";
 exit;  }
$data = fread($handle, 8192);
$count=$data;
$length=strlen($count); //This checks the length of $string and saves the value as $length
if ($length=="1") { $zeros="000000000"; }
if ($length=="2") { $zeros="00000000"; }
if ($length=="3") { $zeros="0000000"; }
if ($length=="4") { $zeros="000000"; }
if ($length=="5") { $zeros="00000"; }
if ($length=="6") { $zeros="0000"; }
if ($length=="7") { $zeros="000"; }
if ($length=="8") { $zeros="00"; }
if ($length=="9") { $zeros="0"; }
$count=$zeros.$count;     // $zeros is added to $count to give 000025


$string = $count;

$digit1=$string{0};
$digit2=$string{1};
$digit3=$string{2};
$digit4=$string{3};
$digit5=$string{4};
$digit6=$string{5};
$digit7=$string{6};
$digit8=$string{7};
$digit9=$string{8};
$digit10=$string{9};


echo "<table border='4' bgcolor='#000000' cellpadding='5'><tr><td align='center' valign='middle' height='10'>
<p style='font-family:Arial; font-size:9px; color:#0066FF; text-decoration:none;'><img src='"
.$images."/".$digit1.".jpg'><img src='".$images."/".$digit2.".jpg'><img src='".$images."/".$digit3.".jpg'><img src='".$images."/".$digit4.".jpg'><img src='".$images."/".$digit5.".jpg'><img src='".$images."/".$digit6.".jpg'><img src='".$images."/".$digit7.".jpg'><img src='".$images."/".$digit8.".jpg'><img src='".$images."/".$digit9.".jpg'><img src='".$images."/".$digit10.".jpg'>
<br><a href='http://www.agtc.co.uk' style='text-decoration:none; color:#0066FF;'>AGTC HITS COUNTER v3.1</a></p></td></tr></table>"
;
?>

&amp;nbsp;

Todolist php Scripts for Syntax

Todolist is a set of PHP scripts that create a web-based list of things to do. Items can be added and removed, and are sorted by an assigned priority. Also it is possible to assign special tasks to another person and for example to specify a due date. ToDoList is multilingual (although some languages are still under development). Lots of unmentioned features. Features – Assign due-dates, responsible users.

 

 

<?php
/*  main page - switch routines etc */
//error_reporting(E_ALL);

include_once 'include/constants.php';
include_once 'include/history.inc.php';
include_once 'include/config.php';
include_once 'include/user.inc.php';
include_once 'include/functions.inc.php';

if ($GLOBALS['DB_SESSIONS']) {
 ini_set('session.save_handler', 'user');
 include_once ('include/session_handler_db.php'); // Handle session-data in DB-Table
} else {
 ini_set('session.save_handler', 'files');
}

ini_set('register_globals', 'true');
session_start();

// Use output-compression if Browser supports this. (Requires PHP 4.0.4!)
// Session-stuff must be handled _before_ output-buffering. Otherwise it confuses PHP... :(
if ($GLOBALS['USE_OUTPUT_COMPRESSION']) {
 ob_start("ob_gzhandler");
}

if (isset($HTTP_GET_VARS['my_tasks'])) {
 $HTTP_SESSION_VARS['usr']->my_tasks = $HTTP_GET_VARS['my_tasks'];
}
if (isset($HTTP_GET_VARS['show_done'])) {
 $HTTP_SESSION_VARS['usr']->show_done = $HTTP_GET_VARS['show_done'];
}

include ('include/header.inc.php'); // set up database connection and authenticate user

// We had a value from the form? Tell it the user.
if (isset($HTTP_GET_VARS['selected_project']))
 $HTTP_SESSION_VARS['usr']->selected_project = $HTTP_GET_VARS['selected_project'];

include ("include/pages.inc.php");  // contains most of the "output"
include ("include/admin.inc.php");

if (isset ($HTTP_POST_VARS['route'])){
 $route = $HTTP_POST_VARS['route'];
} else if (isset ($HTTP_GET_VARS['route'])){
 $route = $HTTP_GET_VARS['route'];
} else {
 $route = FRONTPAGE;
}

if (isset ($HTTP_GET_VARS['order_by'])) {
 $order_by = $HTTP_GET_VARS['order_by'];
} else {
 $order_by = '';
}

// main switch - what are we trying to do?
switch($route){

 // front page
 case FRONTPAGE:
 $HTTP_SESSION_VARS['history']->addPage(THELIST);
 echo page_top("$TODO_HEADING",THELIST);
 $query = makeFrontQuery($order_by, $HTTP_SESSION_VARS['usr']->selected_project);
 echo printToDoTable($query,$order_by,$route);
 if (isset($HTTP_GET_VARS['printlayout']))  { // Drucklayout. Ohne Formulare.
 page_foot(THELIST);
 exit;
 } else {
 echo add_box();
 echo search_box($priority,$search_status, $search_project,$responsible_person,$HTTP_GET_VARS['date_min'],$HTTP_GET_VARS['date_max']);
 echo page_foot(THELIST);
 }
 break;

 // viewing a record's details
 case DETAILS:
 $HTTP_SESSION_VARS['history']->addPage(DETPAGE);
 if (isset($HTTP_GET_VARS['feedback'])){
 $GLOBALS['feedback'] = $HTTP_GET_VARS['feedback'];
 }
 echo page_top($TODO_HEADING,DETPAGE);
 echo details_page($HTTP_GET_VARS['id']);
 echo page_foot(DETPAGE);
 break;


 // searching
 case SEARCH:
 $HTTP_SESSION_VARS['history']->addPage(SEARCHPAGE);
 echo page_top("$TODO_HEADING",$HTTP_GET_VARS['page']);
 if (isset ($HTTP_GET_VARS['responsible_person'])) {
 if (!is_array($HTTP_GET_VARS['responsible_person'])){
 $HTTP_GET_VARS['responsible_person'] = array($HTTP_GET_VARS['responsible_person']);
 }
 } else {
 $HTTP_GET_VARS['responsible_person'] = array('');
 }
 $query = makeSearchQuery($HTTP_GET_VARS['wildcards'],$HTTP_GET_VARS['priority'],
 $HTTP_GET_VARS['search_status'],$HTTP_GET_VARS['search_project'], $HTTP_GET_VARS['responsible_person'],
 $order_by,$HTTP_GET_VARS['date_min'],$HTTP_GET_VARS['date_max']);
 if (isset($HTTP_GET_VARS['printlayout']))  { // Drucklayout. Ohne Formulare.
 echo printToDoTable($query,$order_by,$route);
 echo page_foot($HTTP_GET_VARS['page']);
 exit;
 } else {
 echo search_box($HTTP_GET_VARS['priority'], $HTTP_GET_VARS['search_status'],
 $HTTP_GET_VARS['search_project'],$HTTP_GET_VARS['responsible_person'],$HTTP_GET_VARS['date_min'],
 $HTTP_GET_VARS['date_max']);
 echo printToDoTable($query,$order_by,$route);
 echo page_foot(SEARCHPAGE);
 }
 break;

 // we're the admin.
 case ADMIN:
 //$HTTP_SESSION_VARS['history']->addPage($HTTP_GET_VARS['page']);
 echo page_top("$TODO_HEADING<br/>$TEXT_ADMIN",ADMINPAGE);
 if (isset ($HTTP_GET_VARS['adm'])) {
 if (!isset($HTTP_GET_VARS['adminmodule'])) {
 $HTTP_GET_VARS['adminmodule'] = null;
 }
 if (!isset($HTTP_GET_VARS['module'])) {
 $HTTP_GET_VARS['module'] = null;
 }
 if (!isset($HTTP_GET_VARS['user'])) {
 $HTTP_GET_VARS['user'] = null;
 }
 if (!isset($HTTP_GET_VARS['project'])) {
 $HTTP_GET_VARS['project'] = null;
 }
 echo admin_page($HTTP_GET_VARS['adm']);
 if ($HTTP_GET_VARS['adm'] == ADMIN_GROUPS){
 echo groupAdministration($HTTP_GET_VARS['adm'],$HTTP_GET_VARS['adminmodule'], $HTTP_GET_VARS['group']);
 } elseif ($HTTP_GET_VARS['adm'] == ADMIN_USERS){
 $HTTP_SESSION_VARS['history']->addPage(ADMIN_USERS_MAIN_PAGE);
 echo userAdministration($HTTP_GET_VARS['module'],$HTTP_GET_VARS['user'],ADMINPAGE);
 } elseif ($HTTP_GET_VARS['adm'] == ADMIN_PROJECTS){
 $HTTP_SESSION_VARS['history']->addPage(ADMIN_PROJECTS_MAIN_PAGE);
 echo projectAdministration($HTTP_GET_VARS['adm'],$HTTP_GET_VARS['adminmodule'],$HTTP_GET_VARS['project']);
 }
 } else    {
 $HTTP_SESSION_VARS['history']->addPage(ADMINPAGE);
 echo admin_page(null);
 echo '<br /><font>'.$TEXT_CHOOSE_MODULE.'</font>';
 echo "<ul>";
 echo '<li><a href="'.$HTTP_SERVER_VARS['PHP_SELF'].'?route='.ADMIN.'&amp;page='.ADMINPAGE.'&amp;adm='.ADMIN_USERS.'">'.$TEXT_USERS.'</a></li>';
 //echo '<li><a href="'.$PHP_SELF.'?route='.ADMIN.'&amp;page='.ADMINPAGE.'&amp;adm='.ADMIN_GROUPS.'">'.$TEXT_GROUPS.'</a></li>';
 echo '<li><a href="'.$HTTP_SERVER_VARS['PHP_SELF'].'?route='.ADMIN.'&amp;page='.ADMINPAGE.'&amp;adm='.ADMIN_PROJECTS.'">'.$TEXT_PROJECTS.'</a></li>';
 echo "</ul>";
 }
 echo page_foot(ADMINPAGE);
 break;

 case PREFERENCES:
 $HTTP_SESSION_VARS['history']->addPage(PREFPAGE);
 echo page_top("$TODO_HEADING<br/>$TEXT_PREFERENCES", PREFPAGE);
 echo userAdministration(null,$HTTP_SESSION_VARS['usr']->userid,PREFPAGE);
 echo page_foot(PREFPAGE);
 break;

 case ADDFORM:
 $HTTP_SESSION_VARS['history']->addPage(ADDFORM);
 echo page_top("$TODO_HEADING<br/>$TEXT_NEW", ADDFORM);
 echo add_box();
 echo page_foot(ADDFORM);
 break;

 // actually making some change
 case ACTIONS: // actually do stuff

 // switch on action to see what precisely that is
 switch ($HTTP_POST_VARS['action']){

 // deleting a task
 case "todo_delete":
 if( delete_todo($HTTP_POST_VARS['id'])) {
 $feedback = $TEXT_DATASET_DELETED;
 } else {
 $feedback = $TEXT_DATASET_NOT_DELETED;
 }
 echo page_top($TODO_HEADING,THELIST);
 $query = makeFrontQuery(null, $HTTP_SESSION_VARS['usr']->selected_project);
 echo printToDoTable($query,null,$HTTP_POST_VARS['route']);
 echo add_box();
 echo search_box();
 echo page_foot(THELIST);
 break;

 // update a task
 case "todo_change":
 update_todo($HTTP_POST_VARS['due_date'], $HTTP_POST_VARS['priority'], $HTTP_POST_VARS['status'],
 $HTTP_POST_VARS['percentage_completed'], $HTTP_POST_VARS['text'], $HTTP_POST_VARS['responsible_persons'],
 $HTTP_POST_VARS['id'], $HTTP_POST_VARS['note_text'], $HTTP_POST_VARS['project']);
 $feedback = $TEXT_DATASET_CHANGED;
 echo page_top($TODO_HEADING,THELIST);
 $query = makeFrontQuery(null, $HTTP_SESSION_VARS['usr']->selected_project);
 echo printToDoTable($query,null,$HTTP_POST_VARS['route']);
 echo add_box();
 echo search_box();
 echo page_foot(THELIST);
 break;

 // add a new task
 case "todo-add":
 add_todo($HTTP_POST_VARS['due_date'],$HTTP_POST_VARS['priority'],$HTTP_POST_VARS['project'],
 $HTTP_POST_VARS['text'],$HTTP_POST_VARS['responsible_person']);
 $feedback = stripslashes($TEXT_TODO_ADDED);
 if ($HTTP_POST_VARS['page']==ADDTASK_SINGLE_PAGE) {
 echo page_top($TODO_HEADING,ADDFORM);
 echo add_box();
 echo page_foot(ADDFORM);
 } else {
 echo page_top($TODO_HEADING,THELIST);
 $query = makeFrontQuery(null, $HTTP_SESSION_VARS['usr']->selected_project);
 echo printToDoTable($query,null,$HTTP_POST_VARS['route']);
 echo add_box();
 echo search_box();
 echo page_foot(THELIST);
 }
 break;

 // add a new subtask
 case "subtodo-add":
 add_todo($HTTP_POST_VARS['due_date'],$HTTP_POST_VARS['priority'],$HTTP_POST_VARS['project'],
 $HTTP_POST_VARS['text'],$HTTP_POST_VARS['responsible_person'],
 $HTTP_POST_VARS['parent_task'], $HTTP_POST_VARS['level']);
 $feedback = stripslashes($TEXT_TODO_ADDED);
 echo page_top($TODO_HEADING,DETPAGE);
 echo details_page($HTTP_POST_VARS['parent_task']);
 echo page_foot(DETPAGE);
 break;

 // make a new user
 case "newuser":
 if ($HTTP_POST_VARS['new_password'] == $HTTP_POST_VARS['new_password_retyped']) {
 if (!isset($HTTP_POST_VARS['new_email_notify'])) {
 //HTML-Forms submit nothing if a checkbox isn't checked... :-(
 $HTTP_POST_VARS['new_email_notify']=0;
 }
 if (!isset($HTTP_POST_VARS['new_my_tasks'])) {
 //HTML-Forms submit nothing if a checkbox isn't checked... :-(
 $HTTP_POST_VARS['new_my_tasks']=0;
 }
 if (!isset($HTTP_POST_VARS['new_primary_project'])) {
 //HTML-Forms submit nothing if a checkbox isn't checked... :-(
 $HTTP_POST_VARS['new_primary_project']=0;
 }
 if (!isset($HTTP_POST_VARS['new_my_tasks'])) {
 //HTML-Forms submit nothing if a checkbox isn't checked... :-(
 $HTTP_POST_VARS['new_my_tasks']=0;
 }
 if (!isset($HTTP_POST_VARS['showicons'])) {
 //HTML-Forms submit nothing if a checkbox isn't checked... :-(
 $HTTP_POST_VARS['showicons']=0;
 }
 if (!isset($HTTP_POST_VARS['isadmin'])) {
 //HTML-Forms submit nothing if a checkbox isn't checked... :-(
 $HTTP_POST_VARS['isadmin']=0;
 }

 $db->query('SELECT login_name FROM todo_users
 where login_name=\''
. $HTTP_POST_VARS['new_login_name']."'");
 if ($db->num_rows() > 0 ) {
 $feedback = $TEXT_USER_EXISTS;
 } else {
 $db->query("INSERT INTO
 todo_users (login_name, first_name, last_name, email, email_notify, password,
 language, primary_project, my_tasks, show_icons, admin)
 VALUES ('"
.$HTTP_POST_VARS['new_login_name']."','".addslashes($HTTP_POST_VARS['new_first_name'])."','".
 addslashes($HTTP_POST_VARS['new_last_name'])."', '".$HTTP_POST_VARS['new_email']."',".
 $HTTP_POST_VARS['new_email_notify'].",'".md5($HTTP_POST_VARS['new_password'])."','".
 $HTTP_POST_VARS['new_language']."', ".$HTTP_POST_VARS['new_primary_project'].','.
 $HTTP_POST_VARS['new_my_tasks'].','. $HTTP_POST_VARS['showicons'].','. $HTTP_POST_VARS['isadmin'].')');
 // Every user is member of project 1...
 // FIXME: What if project 1 is deleted?!?!?
 $db->query('INSERT INTO todo_project_members VALUES ('.$HTTP_POST_VARS['new_primary_project'].',LAST_INSERT_ID())');
 $feedback = $TEXT_USER_CREATED;
 }
 echo page_top($TODO_HEADING,ADMINPAGE);
 echo admin_page(ADMIN_USERS);
 } else {
 // Passwords don't match! Back to where we came from!
 // FIXME formdata lost this way!
 $feedback = $TEXT_PASSWORDS_DONT_MATCH;
 echo page_top("$TODO_HEADING<br/>$TEXT_ADMIN",ADMINPAGE);
 echo admin_page(ADMIN_USERS);
 }
 echo userAdministration("newuser","", ADMINPAGE);
 echo page_foot(ADMINPAGE);
 break;

 // alter a user
 case "updateuser":
 // Put the POST-Variables in local variables
 if (isset($HTTP_POST_VARS['new_columns'])) {
 $columns =$HTTP_POST_VARS['new_columns'];
 }
 $email            = $HTTP_POST_VARS['new_email'];
 $email_notify    = isset($HTTP_POST_VARS['new_email_notify']) ? 1 : 0;
 $first_name        = $HTTP_POST_VARS['new_first_name'];
 if ( isset ($HTTP_POST_VARS['isadmin']) ) {
 $isadmin    = $HTTP_POST_VARS['isadmin'];
 }
 $language        = $HTTP_POST_VARS['new_language'];
 $my_tasks        = $HTTP_POST_VARS['new_my_tasks'];
 $last_name        = $HTTP_POST_VARS['new_last_name'];
 $password        = $HTTP_POST_VARS['new_password'];
 $password_retyped= $HTTP_POST_VARS['new_password_retyped'];
 $primary_project= $HTTP_POST_VARS['new_primary_project'];
 $showicons        = $HTTP_POST_VARS['showicons'];
 $usernr            = $HTTP_POST_VARS['usernr'];

 if ($password == $password_retyped) {
 if (!isset($email_notify)) {
 //HTML-Forms submit nothing if a checkbox isn't checked... :-(
 $email_notify=0;
 }
 if (!isset($primary_project)) {
 //HTML-Forms submit nothing if a checkbox isn't checked... :-(
 $primary_project=0;
 }
 if (!isset($my_tasks)) {
 //HTML-Forms submit nothing if a checkbox isn't checked... :-(
 $my_tasks=0;
 }
 if (!isset($showicons)) {
 //HTML-Forms submit nothing if a checkbox isn't checked... :-(
 $showicons=0;
 }


 if (!isset($isadmin)) {
 if (($usernr==$HTTP_SESSION_VARS['usr']->userid) &amp;&amp; $HTTP_SESSION_VARS['usr']->isAdmin())
 $isadmin=1;
 else
 $isadmin=0;
 }
 $query="UPDATE todo_users
 SET first_name='"
.addslashes($first_name)."', last_name='".addslashes($last_name)."',
 email='"
.$email."', email_notify=$email_notify, language='".$language."',
 primary_project='"
.    $primary_project."', my_tasks=".$my_tasks.',
 show_icons='
.$showicons.',admin='.$isadmin;

 if ($password != '')
 $query .=", password='".md5($password)."'";

 if (!isset($account_disabled)) {
 $query .=", wrong_logins=0";
 } else {
 $query .=", wrong_logins=$MAX_LOGIN_TRIES";
 }

 if (isset($columns)) {
 $query .= ", visible_columns='".implode(',', $columns)."'";
 }

 /* update the current user-session */
 if ($usernr == $HTTP_SESSION_VARS['usr']->userid) {
 $HTTP_SESSION_VARS['usr']->show_icons=$showicons;
 $HTTP_SESSION_VARS['usr']->setColumns($columns);
 $HTTP_SESSION_VARS['usr']->my_tasks=$my_tasks;
 }

 $query .= " WHERE usernr=$usernr";
 $db->query("$query");
 $feedback = $TEXT_USER_UPDATED;
 if ($HTTP_SESSION_VARS['history']->getPage(1) == ADMINPAGE) {
 echo page_top("$TODO_HEADING<br/>$TEXT_ADMIN",ADMINPAGE);
 echo admin_page(ADMIN_USERS);
 echo userAdministration(ADMIN_USERS,$HTTP_POST_VARS['user'], ADMINPAGE);
 } else {
 echo page_top("$TODO_HEADING",THELIST);
 $query = makeFrontQuery($order_by, $HTTP_SESSION_VARS['usr']->selected_project);
 echo printToDoTable($query,$order_by,$route);
 echo add_box();
 echo search_box();
 }
 } else {
 // Passwords don't match! Back to where we came from!
 $feedback = $TEXT_PASSWORDS_DONT_MATCH;
 if ($page == ADMINPAGE) {
 echo page_top("$TODO_HEADING<br/>$TEXT_ADMIN",ADMINPAGE);
 echo admin_page(ADMIN_USERS);
 echo userAdministration(ADMIN_USERS,$usernr, ADMINPAGE);
 } elseif ($page == PREFPAGE) {
 echo page_top("$TODO_HEADING<br/>$TEXT_PREFERENCES", PREFPAGE);
 echo userAdministration($module,$HTTP_SESSION_VARS['usr']->userid,PREFPAGE);
 }
 }
 page_foot();
 break;

 // delete a user
 case "deleteuser":
 delete_user($HTTP_POST_VARS['usernr']);
 $feedback = $TEXT_USER_DELETED;
 echo page_top("$TODO_HEADING",ADMINPAGE);
 echo admin_page(ADMIN_USERS);
 echo userAdministration(ADMIN_USERS,$HTTP_POST_VARS['user'], ADMINPAGE);
 echo page_foot(ADMINPAGE);
 break;

 // create a new project
 case "newproject":
 $db->query("INSERT INTO todo_projects
 VALUES
 (NULL,'"
.addslashes($HTTP_POST_VARS['project_name'])."','".addslashes($HTTP_POST_VARS['project_description'])."',".
 $HTTP_POST_VARS['project_leader'].")");
 $db->query('INSERT INTO todo_project_members
 VALUES
 (LAST_INSERT_ID(),'
.$HTTP_POST_VARS['project_leader'].')');
 $feedback = $TEXT_PROJECT_CREATED;
 echo page_top($TODO_HEADING,$HTTP_POST_VARS['page']);
 echo admin_page(ADMIN_PROJECTS);
 // FIXME open project-details now!!!
 echo projectAdministration($HTTP_POST_VARS['adm'],$HTTP_POST_VARS['adminmodule'],"LAST_INSERT_ID()");
 echo page_foot($HTTP_POST_VARS['page']);
 break;

 // update a project
 case "updateproject":
 $db->query("UPDATE todo_projects SET
 project_name='"
.addslashes($HTTP_POST_VARS['new_project_name'])."',
 description='"
.addslashes($HTTP_POST_VARS['new_project_description'])."',
 project_leader="
.$HTTP_POST_VARS['new_project_leader']."
 WHERE id="
.$HTTP_POST_VARS['project_id']);
 // update project-members... Is there a more elegant way to do this?
 // do we have to delete the tasks where someone is assigned who is no longer
 // member of the project?
 $db->query('DELETE from todo_project_members
 WHERE project_id='
.$HTTP_POST_VARS['project_id']);
 if (sizeof($HTTP_POST_VARS['new_project_members']) > 0) {
 $query='INSERT INTO todo_project_members VALUES ';

 while ($member_id=array_pop($HTTP_POST_VARS['new_project_members'])){
 $query .= '('.$HTTP_POST_VARS['project_id'].", $member_id)";
 if (sizeof($HTTP_POST_VARS['new_project_members']) > 0)
 $query .= ',';
 }
 }
 $db->query("$query");

 $feedback = $TEXT_PROJECT_UPDATED;
 echo page_top($TODO_HEADING,ADMINPAGE);
 echo admin_page(ADMIN_PROJECTS);
 // FIXME open project-details now!!!
 echo projectAdministration(ADMIN_PROJECTS,$adminmodule,null);
 echo page_foot(ADMINPAGE);
 break;

 // delete a project
 case "deleteproject":
 // It would be better to ask before doing this...
 delete_project($HTTP_POST_VARS['project_id']);
 $feedback = $TEXT_PROJECT_DELETED;
 echo page_top($TODO_HEADING,ADMINPAGE);
 echo admin_page(ADMIN_PROJECTS);
 // FIXME open project-details now!!!
 echo projectAdministration(ADMIN_PROJECTS,null,null);
 echo page_foot(ADMINPAGE);
 break;

 // create a new group
 case "newgroup":
 $db->query("INSERT INTO todo_groups
 VALUES
 (NULL,'$group_name','"
. $group_description ."',".$group_leader.")");
 $db->query("INSERT INTO todo_group_members
 VALUES
 (LAST_INSERT_ID(),$group_leader)"
);
 $feedback = $TEXT_GROUP_CREATED;
 echo page_top("$TODO_HEADING",$page);
 echo admin_page(ADMIN_GROUPS);
 echo groupAdministration($HTTP_GET_VARS['adm'],$adminmodule, "LAST_INSERT_ID()");
 echo page_foot($page);
 break;

/*
 // update a group
 case "updategroup":
 $db->query("UPDATE todo_groups SET
 group_name='$new_group_name',
 description='$new_group_description',
 group_leader=$new_group_leader
 WHERE id=$group_id");
 // update group-members... Is there a more elegant way to do this?
 // do we have to delete the tasks where someone is assigned who is no longer
 // member of the group?
 $db->query("DELETE from todo_group_members
 WHERE group_id=$group_id");
 if (sizeof($new_group_members) > 0) {
 $query='INSERT INTO todo_group_members VALUES ';

 while ($member_id=array_pop($new_group_members)){
 $query .= "($group_id, $member_id)";
 if (sizeof($new_group_members) > 0)
 $query .= ',';
 }
 }
 $db->query("$query");

 $feedback = $TEXT_GROUP_UPDATED;
 echo page_top("$TODO_HEADING",ADMINPAGE);
 echo admin_page(ADMIN_GROUPS);
 echo groupAdministration(ADMIN_GROUPS,$adminmodule, $group);
 echo page_foot(ADMINPAGE);
 break;

 // delete a group
 case "deletegroup":
 // It would be better to ask before doing this...
 delete_group($group_id);
 $feedback = $TEXT_GROUP_DELETED;
 echo page_top("$TODO_HEADING",ADMINPAGE);
 echo admin_page(ADMIN_GROUPS);
 // FIXME open group-details now!!!
 echo groupAdministration(ADMIN_GROUPS,$adminmodule, null);
 echo page_foot(ADMINPAGE);
 break;

*/

 }


 break;


}

?>

&amp;nbsp;

Random PHP Quote Scripts for Syntax

Random PHP Quote is a simple php script that picks quotes from a text file and displays on a webpage. It provides a password protected admin panel to add, edit the quotes.Layout can be easily changed and the script is very easy to install, use and customize.

 

 

 

<!-- Random PHP Quote Copyright Scriptsez.net Get it free at http://www.scriptsez.net -->
<?php
extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
if($action==""){
?>
<style>
TABLE {
 BORDER-RIGHT: #345487 1px solid; BORDER-TOP: #345487 1px solid; BORDER-LEFT: #345487 1px solid;
 BORDER-BOTTOM: #345487 1px solid; FONT-SIZE: 11px; COLOR: #000; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif
}
TD {
 BORDER-RIGHT: #345487 1px solid; BORDER-TOP: #345487 1px solid; BORDER-LEFT: #345487 1px solid; BORDER-BOTTOM: #345487 1px solid; BACKGROUND-COLOR: #f5f9fd
}</style>
<?php
$text_file = 'file.txt';   //file that contains all the quotations
$content = file ($text_file);
$size_of_file = (count($content))-1;
$line_to_choose = rand (0, ($size_of_file));
$line = $content[$line_to_choose];
$display=explode ("|~~|",$line);
if(strlen($display[2])>="1"){
$aut="<hr color=#345486  noshade size=1 width=95%>By: $display[2]";
}else{
$aut="";
}
echo "<table width=25% border=1><tr><td>Random Quote</td><tr><td>$display[1] $aut</td></tr></table>";
}
if($action == "admin"){
?><center><table align=middle><td align=left width=20%>
<tr><td height="27" colspan="2"><FONT SIZE="4" COLOR="#000000">:: Random PHP Quote ::</FONT></td><tr><td>Password Required (Default is: administrator)</td></tr><tr><form method=post action="?action=login"><td>Password:</td><td><input type=password name=pass>&amp;nbsp;<input type=submit value=Submit></td></tr></form></table></center>
<?php
}
$mo=  "pwd.txt";
$bd = fopen ($mo, "r");
$psord = fread ($bd, filesize ($mo));
fclose ($bd);
$rop=base64_decode($psord);
$vup=explode("vylkp!-1/\*||&amp;@23||*~`.*%/|//\%@!||&amp;~||a",$rop);
$password=base64_decode($vup[0]);
if ($action=="login"){
if(strlen($m)>="1"){
$n=base64_decode($m);
$pass=$n;
}
if ($pass==$password){
echo "Successfully Loged In<br><hr>";
$m=base64_encode($password);
echo"<table align=left width=80%><tr><td><A HREF=?action=add_q&amp;m=$m>Add a Quote</A></td></tr><tr><td><A HREF=?action=edit_q&amp;m=$m>Edit Quotes</A></td></tr><tr><td><A HREF=?action=change_password&amp;m=$m>Change Password</A></td></tr><tr><td><A HREF=?action=admin>Logout</A></td></tr></table>";
}else {
echo "Invalid Passsword";
}
}
if($action=="change_password"){
$l=base64_decode($m);
if ($l==$password){
echo "<form method=post action=?action=do_change_password><table><tr><td>Enter new password</td><td><input type=password size=18 name=pwd></td><tr><td>Confirm new password</td><td><input type=password size=18 name=qwd><input type=hidden name=m value=$m><td><tr><td></td><td><input type=submit value=Change></td></tr></table></form>";
}else{echo "Please Login Again"; }
}
if ($action=="do_change_password"){
$l=base64_decode($m);
if($l==$password){
if($pwd==$qwd){
$po="pwd.txt";
$fgh=base64_encode($pwd);
$asd=base64_encode("$fgh"."vylkp!-1/\*||&amp;@23||*~`.*%/|//\%@!||&amp;~||a");
$vp = fopen ($po, "w");
fwrite ($vp, "$asd");
fclose($vp);
echo "Password has been successfully changed. <BR><a href=?action=admin>Login Again</a>";
}else{
echo "Please go back, change password and confirm new password donot match";
}
}else{ echo "Please Login Again"; }
}
if ($action=="add_q"){
$l=base64_decode($m);
if ($l==$password){
echo "<form method=post action=?action=do_add_q>Add a quote<table><tr><td><FONT COLOR=red>*</FONT> Quote:</td><td> <textarea rows=8 cols=28 name=quote></textarea></td></tr><tr><td><input type=hidden name=m value=$m>Author:</td><td><input type=text name=author size=28></td></tr><tr><td></td><td><input type=submit value=' Add '></td></tr></table></form><BR><FONT COLOR=red>*</FONT> = Required<BR><a href=?action=login&amp;m=$m>Back To main Menu</a>";
}else{
echo "Please Login Again";
}
}
if ($action=="do_add_q"){
$quote = stripslashes ($quote);
$author = stripslashes ($author);
$quote = str_replace ("\n","<br>", $quote);
$quote = str_replace ("|~~|","|~|", $quote);
$author = str_replace ("|~~|","|~|", $author);
$l=base64_decode($m);
if ($l==$password){
$io="file.txt";
$vd = fopen ($io, "a+");
fwrite ($vd, "[quote]|~~|");
fwrite ($vd, "$quote");
fwrite ($vd, "|~~|");
fwrite ($vd, "$author");
fwrite ($vd, "|~~|");
fwrite ($vd, "\n");
fclose($vd);
echo "Quote has been added successfully. <BR><a href=?action=login&amp;m=$m>Back To main Menu</a>";
}else{
echo "Please Login Again";
}
}
if($action=="edit_q"){
$l=base64_decode($m);
if ($l==$password){
$fd = fopen ("file.txt", "r");
$stuff = fread ($fd, filesize ("file.txt"));
fclose ($fd);
php?>
<body bgcolor="#ffffff">
<td height="399" width="100%" valign="top">
<form method="post" action="?action=temp3">
<input type=hidden name=m value="<?php echo $m; ?>">
<table width="100%" border="0" cellpadding="5" cellspacing="0">
<tr>
<td><font size="2" face=arial>Edit Quotes: (New Quote start from line starting with [quote])</font></td>
</tr>
<tr>
<td width="100%">
<textarea name="cont" cols="70" rows="20"><?php  echo $stuff ?></textarea>
</td>
</tr>
<tr>
<td width="86%">&amp;nbsp;
<input type="submit" name="Submit" value="Save"><input type="button" name="Cancel" value="Cancel" onclick="javascript: history.back(1)">
</td>
</tr>
<tr>
</tr>
</table>
</form>
<?php
}else{
echo "<FONT SIZE=2 COLOR=red>Please Login</FONT>";
}
}
if ($action=="temp3") {
$l=base64_decode($m);
if ($l==$password){
$cont=$HTTP_POST_VARS['cont'];
$cont=stripslashes($cont);
$fp = fopen("file.txt", "w");
fputs($fp, $cont);
fputs($fp, "\n");
fclose($fp);
php?>
<body bgcolor="#ffffff">
<BR><BR><font size="2" face=arial>Quotes Edited Successfully<BR></font><BR><a href="?action=login&amp;m=<?php echo $m; ?>">Back To main Menu</a><BR>
<?php
}else{ echo "Please Login"; }
}
?>

&amp;nbsp;