Delete All Files From Folder and Table Then delet folder
Hi,
can someone please take a look. The code works but I am not so sure if the code is coorect :-)
<?php require_once('Connections/MyDB.php'); ?>
<?php require_once("WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php require_once("webassist/file_manipulation/helperphp.php"); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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_myDB, $myDB);
$query_allImages = "SELECT galleryid, image FROM gallery";
$allImages = mysql_query($query_allImages, $myDB) or die(mysql_error());
$row_allImages = mysql_fetch_assoc($allImages);
$totalRows_allImages = mysql_num_rows($allImages);
?>
<?php do { ?>
<?php
$WA_DeleteFileResult1 = false;
if(!($totalRows_allImages == 0)){
$WA_DeleteFileResult1 = WA_FileAssist_DeleteFile("test/", "".$row_allImages['image'] ."");
}
?>
<?php
// WA Application Builder Delete
if ($WA_DeleteFileResult1) // Trigger
{
$WA_connection = $IchBinMusiker;
$WA_table = "gallery";
$WA_redirectURL = "";
$WA_keepQueryString = false;
$WA_fieldNamesStr = "galleryid";
$WA_columnTypesStr = "none,none,NULL";
$WA_fieldValuesStr = "".$row_allImages['galleryid'] ."";
$WA_comparisonStr = "=";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_comparisions = explode("|", $WA_comparisonStr);
$WA_connectionDB = $database_IchBinMusiker;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$deleteParamsObj = WA_AB_generateWhereClause($WA_fieldNames, $WA_columns, $WA_fieldValues, $WA_comparisions);
$WA_Sql = "DELETE FROM `" . $WA_table . "` WHERE " . $deleteParamsObj->sqlWhereClause;
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
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);
}
}
?>
<?php } while ($row_allImages = mysql_fetch_assoc($allImages)); ?>
<?php
if ($WA_DeleteFileResult1) // Trigger
{
rmdir('test');
}
?>
Cheers
Denis