Jump to content

Functions File


peterw

Recommended Posts

<?php

 

function remove_directory($directory)

{

if (is_dir($directory)) {

$handle = opendir($directory);

while ($file = readdir($handle) ) {

if ($file != "." && $file != "..") {

unlink ("$directory/$file") ;

}

}

closedir($handle);

rmdir($directory);

}

}

 

 

function read_directory($directory, $files)

{

$handle = opendir($directory);

while ($file = readdir($handle) ) {

if ($file != "." && $file != ".." && $file == $files) {

return "$directory/$file";

}

}

closedir($handle);

}

 

function remove_files($directory)

{

unlink ("$directory") ;

}

 

 

function get_file_ext($filename)

{

$photo_ext = explode(".", $filename);

return strtolower($photo_ext[sizeof($photo_ext) - 1]);

 

}

 

?>

Link to comment
Share on other sites

It won't run the first function

 

Just the first one?

 

Can you post whatever code your using it in (where you're calling it from)?

 

Why do you have your own function to get the extension of a file when there is a built-in function. See pathinfo.

 

Ken

 

Good point

Link to comment
Share on other sites

<?


include("setting.php");
include("system_function_files.php");

if ($setup_demo	== "N") {

	$db_connect = mysql_connect($db_host, $db_username, $db_password);
	mysql_select_db($db_name, $db_connect) || die(mysql_error());

	remove_directory("$dir_files/$area");

	$sql_query = "DELETE FROM area WHERE area_id = '$area'";
	mysql_query($sql_query) or die(mysql_error());

	$sql_query = "DELETE FROM area_file WHERE file_area = '$area'";
	mysql_query($sql_query) or die(mysql_error());

	mysql_close($db_connect);

} 
else { setcookie("warning", $setup_demo_sorry);}

$destination = "filecenter.php?";
header("location:$destination");	


?>

Link to comment
Share on other sites

Are you getting any errors?

 

No. It just doesn't redirect.

It completely ignores the rest of the code after the include

 

That doesn't mean there's no errors. It's actually likely that there are, but you have them turned off. Just including a file shouldn't cause the script to breal unless the file you're including is broken (that might be where the problem is). Try to see if you can output an error

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.