Location: PHPKode > projects > Mummi (Multi-user MOD_MP3 Interface) > mummi.0.6/htroot/move.php
<?

// Setting the title of the page
$GLOBALS[page_title] = "Folder/File Mover";

// Include files
include "common.php";
include "$lib_path/filesys.inc";
include "$lib_path/design.inc";

// Set the user navbars.
if(!$HTTP_COOKIE_VARS[login_active]) $nav_array = array(main);
elseif($os->num_rows("SELECT user_name FROM users WHERE user_name='$session_array[user_name]' AND user_type='1'")) $nav_array = array_merge($GLOBALS[admin_navbox_array], $os->get_navbox_array($session_array[user_name]));
else $nav_array = array_merge($GLOBALS[basic_navbox_array], $os->get_navbox_array($session_array[user_name]));


$fs = new FILESYS;


// url decoded string for path
$rr_path = stripslashes(rawurldecode($r_path));

// url encoded string for path
$ss_path = rawurlencode($rr_path);

//// allowed file extensions
//$ext=array(mp3,mp2,mp1,ogg);

// The hidden part of the path
$p_path = "$GLOBALS[audio_folder]/$session_array[user_name]";

// Combine the hidden path with the relitive path.
$w_path = $fs->create_path($p_path, $rr_path);

// the parent folder.
$back_path = rawurlencode($fs->up_dir($rr_path));



// Read this folder, non-recurisvly.
$fc = $fs->rdir($w_path,f);

// sort the array
$fc[0] = FILESYS::sorty($fc[0]);


// all the action buttons
$GLOBALS[contents] .= <<<ENDcontents

	Please select a destination folder:<br>

	<table cellpadding="1" cellspacing="1" border="0"><tr>
		<td><form method="get" action="$GLOBALS[url_path]$PHP_SELF">
		<input type="hidden" name="op" value="up">
		<input type="hidden" name="id" value="$id">
		<input type="hidden" name="r_path" value="$back_path">
		<input type="submit" value="up"></form></td>

		<td><form method="post" action="$GLOBALS[url_path]/mkdir.php">
		<input type="hidden" name="op" value="mkdir">
		<input type="hidden" name="id" value="$id">
		<input type="hidden" name="r_path" value="$ss_path">
		<input type="hidden" name="redirect" value="$PHP_SELF">
		<input type="submit" value="mkdir"></form></td>

		<td><form method="post" action="$GLOBALS[url_path]/folders.php">
		<input type="hidden" name="op" value="undomv">
		<input type="hidden" name="id" value="$id">
		<input type="hidden" name="r_path" value="$ss_path">
		<input type="submit" value="cancel"></form></td>

		<td><form method="post" action="$GLOBALS[url_path]/folders.php">
		<input type="hidden" name="op" value="dest">
		<input type="hidden" name="id" value="$id">
		<input type="hidden" name="r_path" value="$ss_path">
		<input type="submit" value="select"><br><br>
		</td>
	</tr></table>


ENDcontents;



// Top title for the displaying of the folders and files
$GLOBALS[contents] .= <<<ENDcontents

	<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>
		<td><B>NAME</B></td>
		<td align=right>&nbsp;</td>
		<td align=right>&nbsp;</td>
		<td align=right>&nbsp;</td>
		<td align=right>&nbsp;</td>
	</tr>

ENDcontents;



if($HTTP_GET_VARS[id] xor $HTTP_POST_VARS[id]){

	if($HTTP_GET_VARS[id]) $ss_id = $HTTP_GET_VARS[id];
	else $ss_id = $HTTP_POST_VARS[id];


	$query = "SELECT id FROM tmp_movefile where user_name='$session_array[user_name]'";
	if($os->num_rows($query)){

		$query = "SELECT move_array FROM tmp_movefile WHERE id='$ss_id'";
		$result_array = $os->fetch_numeric($query);
		$real_array = OVERSEER::decipher($result_array[0][0],$GLOBALS[secret_key]);


		// a function to help NOT display the src folder when choosing a dest path.
		// Reason: you cannot move a folder to its own sub folders.

		function chk_move($a, $b){
			while(list(, $valr) = each($b)){
				$c = $GLOBALS[p_path].rawurldecode($valr);
				if($a == $c) return false;
			}
			return true;
		}

		$GLOBALS[contents] .= "<tr bgcolor=\"#cccccc\">\n";
		$GLOBALS[contents] .= "\t<td colspan=\"100%\"><input type=\"radio\" name=\"dest\" value=\"$ss_path\">&nbsp;<a href=\"$GLOBALS[url_path]$PHP_SELF?id=$ss_id&r_path=$ss_path\"><img src=\"$GLOBALS[img_path]/folder.gif\" border=\"0\"><i>(this folder)</i></a></td>\n";
		$GLOBALS[contents] .= "</tr>";

		while(list($key, $val) = each($fc[0])){
			if(is_array($real_array[0])){
				reset($real_array[0]);
				if(!chk_move($val, $real_array[0])) continue;
			}

			//create the multi-colored rows
			if(($clr & 1)==1) $bgc = "#cccccc";
			elseif(($clr & 1)!=1) $bgc = "#eeeeee";

			// url clean path for the folder
			$dir_val = rawurlencode("$rr_path" . "/$key");

			$GLOBALS[contents] .= "<tr bgcolor=\"$bgc\">\n";
			$GLOBALS[contents] .= "\t<td colspan=\"100%\"><input type=\"radio\" name=\"dest\" value=\"$dir_val\">&nbsp;<a href=\"$GLOBALS[url_path]$PHP_SELF?id=$ss_id&r_path=$dir_val\"><img src=\"$GLOBALS[img_path]/folder.gif\" border=\"0\">$key</a></td>\n";
			$GLOBALS[contents] .= "</tr>";

			$clr++;
		}//eo while

		// Cleaning up the end of the page
		$GLOBALS[contents] .= "</table>\n";
		$GLOBALS[contents] .= "</form>\n";


	}else $GLOBALS[contents] = "error: nothing to move.<br>\n";

}


// an array for the draw_page function.
$page_table = array("$GLOBALS[page_title]"=>"$GLOBALS[contents]");

draw_header("$GLOBALS[page_title]");
draw_nav($nav_array);
draw_sect($page_table);
draw_footer();
ob_end_flush();
?>
Return current item: Mummi (Multi-user MOD_MP3 Interface)