<?php/* ******************************************************************* * * upload.php -- version 0.9.1 beta -- 02 Apr 2002                     * * Copyright (c) 2002 -- Yiorgos Halkiadakis -- geo@roptron.gr         * *                                                                     * * Based on a php upload script of                                     * *    Viktor "PRiSCO" Bezdek -- prisco@prisco.cz  (c) 2001,            * *    modified by James E. Robinson, III - james@robinsonhouse.com     * *                                                                     * * Totaly reconstructed, configured,                                   * *    upgraded and enhanced by Yiorgos Halkiadakis - geo@roptron.gr    * *                                                                     * * This program is free software; you can redistribute it and/or       * * modify it under the terms of the GNU General Public License         * * as published by the Free Software Foundation; either version 2      * * of the License, or (at your option) any later version.              * *                                                                     * * This program is distributed WITHOUT ANY WARRANTY; without even      * * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * * PURPOSE.  See the GNU General Public License for more details.      * *                                                                     * * ******************************************************************* *//* ******************************************************************* * * I N C L U D E S - AND - R E Q U I R E M E N T S                     * * ******************************************************************* */require('auth.inc.php');			// Authenticate the userinclude("../../../../base/adodb/adodb.inc.php");	// adodb Libraryinclude("../../../../base/adodb/neosos-cfg.inc.php");/* ******************************************************************* * * C O N F I G U R A T I O N   P A R A M E T R E S                     * * *****************************************************************35 */$num = 5;  			// number of files to send$filesize_limit_use = 1;	// turns on/off size check$filesize_limit = 70;		// file size limit (in kB)$extval_use = 1;		// turns on/off extension validation// forbidden extensions$extval = array("php", "php3", "asp", "bat", "exe", "com", "jsp", "cfml", "shtml", "dtcl", "html", "htm", "swf");// Base directory hosts all chapter/user/group subdirectories.// Direct http access is forbidden by an .htaccess file... BUT// php can access it's contents. So, that's the ideal place to// put user's data (texts, images, etc.)$base_dir = "../../base/";	// base directory// common language customization$message["fileisbig"] = "Το αρχείο είναι μεγαλύτερο από το προκαθορισμένο όριο (" . $filesize_limit . "kB)";$message["invext"] = "Δεν επιτρέπεται αποστολή αρχείων αυτού του τύπου.";$message["incomplete"] = "Η αποστολή του αρχείου απέτυχε.";$message["complete"] = "Η αποστολή του αρχείου πραγματοποιήθηκε με επιτυχία.";$message["uploadbutton"] = "Αποστολή";$message["uploadtxt"] = "Αρχείο προς μεταφορά";$message["fileexists"] = "Υπάρχει αρχείο με αυτό το όνομα.";$message["targetpath"] = "Προορισμός";$message["overwrite"] = "αντ/ση";$message["pageTITLE"] = "Μεταφορά αρχείων στο server";$rc = 0;	// Return Code (~errorLevel)/* ******************************************************************* * *                             M A I N                                 * * ******************************************************************* *//* Brake user's working directory field --> find the initial elements   ------------------------------------------------------------------ */$trimed_wgroups = trim($iek_member_wgroups);	// delete spaces from start/end of the string$every_dir = split("-", $trimed_wgroups);$dirs_num = count($every_dir);$dir_c = &ADONewConnection("postgres");		// create a postgreSQL connection$dir_c->PConnect($neososHost,$neososUser,$neososPass,$neososDB);/* For EVERY directory-code found on the user's working directory field   - which is certified twice: (Member Login and Page Authentication) -   extract the directory's/chapter's description  from  the appropriate   db-table   -------------------------------------------------------------------- */for ($i=0 ; $i<$dirs_num ; $i++) {	$dir_sql = "SELECT dirinfo FROM iek_dirs WHERE dirid='" . $every_dir[$i] ."'";	$dir_rs = &$dir_c->Execute($dir_sql);	if ( ($dir_rs->RecordCount()) == 1 )		$every_dirinfo[$i] = $dir_rs->fields[0];}$dir_rs->Close();$dir_c->Close();$pageARXIS = "<html><head><title>". $message["pageTITLE"] ."</title>	<LINK REL='StyleSheet' HREF='projects.css' TYPE='text/css'>	</head>	<body bgcolor='#FFFFFF' background='images/body_bg.gif'>	<table border='0' cellspacing='0' cellpadding='0' width='751'>	<tr>";$pageTELOS = "</tr></table></body></html>";/* ******************************************************** page layout   +- HEADER ---->   +-----+-------+   |  A  |  (B)  |	A = Working List	B = upload log (if any)   |     |   C   | 				C = UPLOAD FORM   +-----+-------+   +- FOOTER ---->   ******************************************************************** */echo($pageARXIS);	// send page HEADER	echo("<td width='300'>&nbsp;<br>	<a href='logout.php'>[*] Logout / Αποσύνδεση </a><br>&nbsp;<br>	<a href='account.php'>[*] Διαχείριση Λογαριασμού</a><br>&nbsp;<br>	<a href='upload.php'>[*] Μεταφορά αρχείων</a></td>");	// send page-section Aecho("<td width='450'>");	// start cell for section B and Cif ( isset($HTTP_POST_VARS["upload"]) ) {for ($i=0; $i<$num ; $i++)	// ---> START_F_O_R_ LOOP{$ii = $i +1;$orig_name =  $HTTP_POST_FILES['file'.$i]['name'];if ($orig_name != "") {		// ---> CHECK_I_F_ SOME FILE WAS SUBMITED	$upload_path = $HTTP_POST_VARS['select'.$i];	//	$overwrite = $HTTP_POST_VARS['overw'.$i];	$filename = ereg_replace("[^a-z0-9._]", "", 		ereg_replace (" ", "_", 		ereg_replace("%20", "_", 		strtolower($orig_name))));	/* -------------------- */	/* Checking file-size   */	/* -------------------- */	if($filesize_limit_use=1) {		$filesize = $HTTP_POST_FILES['file'.$i]['name'] / 1024; //filesize in kB		if($filesize_limit < $filesize) {			echo "<p class='gMainText'><font color='red'>" . $ii . ". " . $message["fileisbig"]."</font></p>";			$rc = 1;		}   	}	if ( $rc == 0 ) {	/* -------------------------------- */	/* file type (extension) validation */	/* -------------------------------- */	if($extval_use=1) {		$extget = substr( strrchr($filename, "."), 1);		$found = in_array($extget, $extval);		if ( $found ) {			echo "<p class='gMainText'><font color='red'>" . $ii . ". " . $upload_path.$filename . " --> " . $message["invext"]."</font></p>";			$rc = 2;		}	}	}	if ( $rc == 0 ) {	/* ------------------------- */	/* file exists verification  */	/* ------------------------- */	echo "<p class='gMainText'>"  . $ii . ". " . $upload_path . $filename . " ";	if ( file_exists($upload_path.$filename) ) {		echo "<font color='red'>" . $message["fileexists"]. "</font></p>";	} else {		if( move_uploaded_file($HTTP_POST_FILES['file'.$i]['tmp_name'], $upload_path.$filename) ) {			echo ("--> " . $message["complete"]."</p>");		} else {			echo ("<font color='red'>" . $message["incomplete"]."</font></p>");		}	}	}	}	// ---> END_I_F_ SOME FILE WAS SUBMITED}		// ---> END_F_O_R_ LOOPecho("<br>&nbsp;<br>");} // </if isset($HTTP_POST...)>/* ******************************************************************* * *                             F O R M                                 * * ******************************************************************* */echo ("<!-- START FILE(s) SUBMITION FORM --><form enctype='multipart/form-data' method='post' action=''>	<input type='hidden' name='action' value='upload'>	<table border=0 cellpadding=0 cellspacing=0 align='center' width='475'>		<tr><!-- name the columns -->		<td width='300' valign='bottom' class='gMainText'>" . $message["uploadtxt"] . "</td>		<td width='150' valign='bottom' class='gMainText'>" . $message["targetpath"] . "</td>		<td width='25' valign='bottom' class='gMainText'>" . $message["overwrite"] . "</td>		</tr>");for ($i=0; $i<$num ; $i++){echo ("<tr><!-- put 3 user-input fields -->	<td width='300' valign='bottom'><input type='file' name='file".$i."' size='28' class='gMiniBox'></td>	<td width='150' valign='bottom'><select name='select".$i."' class='gMiniBox'>");	for ($j=0; $j<$dirs_num; $j++)		echo ("<option value='". $base_dir . $every_dir[$j] ."/'>". $every_dirinfo[$j] ."</option>");	echo ("</select></td>	<td width='25' valign='bottom'><input type='checkbox' name='check".$i."' value='checkbox' class='gMiniBox'></td>	</tr>");}echo ("<tr><!-- put a submit button -->	<td valign='bottom' colspan='3'> 	<input type='submit' name ='upload' value='".$message["uploadbutton"]."' class='gLabelBtn'>	</td></tr> </table></form><!-- END FILE(s) SUBMITION FORM -->");echo ($page_TELOS);?>