<?php require_once("../webassist/file_manipulation/helperphp.php"); ?>
<?php require_once('../Connections/downloads.php'); ?>
<?php require_once("../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_downloads, $downloads);
$query_uploads = "SELECT DISTINCT * FROM downloads";
$uploads = mysql_query($query_uploads, $downloads) or die(mysql_error());
$row_uploads = mysql_fetch_assoc($uploads);
$totalRows_uploads = mysql_num_rows($uploads);
mysql_select_db($database_downloads, $downloads);
$query_uploadUsers = "SELECT DISTINCT * FROM login";
$uploadUsers = mysql_query($query_uploadUsers, $downloads) or die(mysql_error());
$row_uploadUsers = mysql_fetch_assoc($uploadUsers);
$totalRows_uploadUsers = mysql_num_rows($uploadUsers);?>
<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "../downloads/",
'FileName' => "".((isset($_FILES["path"]))? preg_replace('/.[^.]*$/', '', $_FILES["path"]["name"]) :"") ."",
'DefaultFileName' => "",
'ResizeType' => "0",
'ResizeWidth' => "0",
'ResizeHeight' => "0",
'ResizeFillColor' => "" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if(isset($_POST["submit"])){
WA_DFP_UploadFiles("WA_UploadResult1", "path", "0", "", "false", $WA_UploadResult1_Params);
}?>
<?php
// WA Application Builder Insert
if (isset($_POST["submit"])) // Trigger
{
$WA_connection = $downloads;
$WA_table = "downloads";
$WA_sessionName = "downloads_uid";
$WA_redirectURL = "";
$WA_keepQueryString = false;
$WA_indexField = "uid";
$WA_fieldNamesStr = "username|path|filename";
$WA_fieldValuesStr = "".((isset($_POST["username"]))?$_POST["username"]:"") ."" . "|" . "".((isset($_FILES["path"]))? preg_replace('/.[^.]*$/', '', $_FILES["path"]["name"]) :"") ."" . "|" . "".((isset($_POST["filename"]))?$_POST["filename"]:"") ."";
$WA_columnTypesStr = "',none,''|',none,''|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_downloads;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
form:
<form action="" method="post" enctype="multipart/form-data" name="upload" id="upload1">
<table cellpadding="2" cellspacing="4">
<tr>
<td>username:</td>
<td>
<select name="username">
<option selected="selected">- - - Select a User - - -</option>
<?php
do {
?>
<option value="<?php echo $row_uploadUsers['username']; ?>" ><?php echo $row_uploadUsers['username']; ?></option>
<?php
} while ($row_uploadUsers = mysql_fetch_assoc($uploadUsers));
?>
</select>
</td>
</tr>
<tr>
<td>file to upload:</td><td><input type="file" name="path" id="path" /></td>
</tr>
<tr>
<td>filename:</td><td><input type="text" name="filename" id="filename" size="50" /></td>
</tr>
<tr>
<td colspan="2" style="padding:10px;">
<input type="submit" name="submit" id="submit" value="Add Download" />
</td>
</tr>
</table>
</form>
Progress Bar:
<div id="upload1_ProgressMessageWrapper" class="blockUIOverlay" style="display:none;">
<script type="text/javascript">
WADFP_SetProgressToForm('upload1', 'upload1_ProgressMessageWrapper', WADFP_Theme_Options['Bar:Slate']);
</script>
<div id="upload1_ProgressMessage" >
<p style="margin:10px; padding:5px;" ><img src="../webassist/progress_bar/images/slate-bar.gif" alt="" title="" style="vertical-align:middle;" /> Please wait</p>
</div>
</div>