Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
File Upload sessions: pass file index for deletion instead of file na…
…mes [Work in Progress] git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@9490 b72ed6b6-b9f8-46b5-92b4-906544132732
- Loading branch information
Amit Shanker
committed
Nov 17, 2010
1 parent
8bc9a42
commit 788f37f
Showing
6 changed files
with
157 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,74 @@ | ||
<?php | ||
|
||
require_once(dirname(__FILE__).'/classes/core/startup.php'); | ||
require_once(dirname(__FILE__).'/config-defaults.php'); | ||
require_once(dirname(__FILE__).'/common.php'); | ||
require_once($homedir.'/classes/core/class.progressbar.php'); | ||
require_once(dirname(__FILE__).'/classes/core/language.php'); | ||
|
||
$filename = "upload/tmp/".$_GET['file']; | ||
if (!isset($surveyid)) | ||
{ | ||
$surveyid=returnglobal('sid'); | ||
} | ||
else | ||
{ | ||
//This next line ensures that the $surveyid value is never anything but a number. | ||
$surveyid=sanitize_int($surveyid); | ||
} | ||
|
||
$fh = fopen($filename, 'w') or die("can't open file"); | ||
|
||
// Compute the Session name | ||
// Session name is based: | ||
// * on this specific limesurvey installation (Value SessionName in DB) | ||
// * on the surveyid (from Get or Post param). If no surveyid is given we are on the public surveys portal | ||
$usquery = "SELECT stg_value FROM ".db_table_name("settings_global")." where stg_name='SessionName'"; | ||
$usresult = db_execute_assoc($usquery,'',true); //Checked | ||
if ($usresult) | ||
{ | ||
$usrow = $usresult->FetchRow(); | ||
$stg_SessionName=$usrow['stg_value']; | ||
if ($surveyid) | ||
{ | ||
@session_name($stg_SessionName.'-runtime-'.$surveyid); | ||
} | ||
else | ||
{ | ||
@session_name($stg_SessionName.'-runtime-publicportal'); | ||
} | ||
} | ||
else | ||
{ | ||
session_name("LimeSurveyRuntime-$surveyid"); | ||
} | ||
session_set_cookie_params(0,$relativeurl.'/admin/'); | ||
@session_start(); | ||
|
||
if (empty($_SESSION) || !isset($_SESSION['fieldname'])) | ||
{ | ||
die("You don't have a valid session !"); | ||
} | ||
|
||
$file_index = $_GET['file_index']; | ||
|
||
$fileid = "upload/tmp/".$_SESSION['files'][$file_index]['id']; | ||
$filename = $_SESSION['files'][$file_index]['name']; | ||
$fh = fopen($fileid, 'w') or die("can't open file"); | ||
fclose($fh); | ||
|
||
if (unlink($filename)) | ||
echo 'File '.basename($filename).' deleted'; | ||
if (unlink($fileid)) | ||
{ | ||
echo 'File '.rawurldecode($filename).' deleted'; | ||
for ($i = $file_index; $i < $_SESSION['filecount']; $i++) | ||
{ | ||
$_SESSION['files'][$i]['name'] = $_SESSION['files'][$i + 1]['name']; | ||
$_SESSION['files'][$i]['size'] = $_SESSION['files'][$i + 1]['size']; | ||
$_SESSION['files'][$i]['ext'] = $_SESSION['files'][$i + 1]['ext']; | ||
$_SESSION['files'][$i]['id'] = $_SESSION['files'][$i + 1]['id']; | ||
} | ||
$_SESSION['files'][$_SESSION['filecount']] = NULL; | ||
$_SESSION['filecount'] -= 1; | ||
} | ||
else | ||
echo 'Oops, There was an error deleting the file'; | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters