Jump to content

[SOLVED] Strange


Stephen

Recommended Posts

set_time_limit(0);
$_vew["config"]["letters"] = intval(htmlentities($_POST["letters"], ENT_QUOTES));
function vew_strlen_allow($str)
{
	if (strlen($str) <= $_vew["config"]["letters"])
	{
		return true;
	}
	else
	{
		return false;
	}
}
$_vew["file"]["data"] = file_get_contents($_FILES["file"]["tmp_name"]);
echo($_vew["file"]["data"]);
$_vew["file"]["array"] = explode("\n", $_vew["file"]["data"]);
print_r($_vew["file"]["array"]);
$_vew["file"]["array_filter"] = array_filter($_vew["file"]["array"], "vew_strlen_allow");
print_r($_vew["file"]["array_filter"]);
echo(implode("\n", $_vew["file"]["array_filter"]));

 

Everything echos/prints correctly up to

print_r($_vew["file"]["array_filter"]);
echo(implode("\n", $_vew["file"]["array_filter"]));

 

It just returns blank. I don't know what's wrong with it.

EDIT:

By the way, it returned this:

1
22
333
4444
55555
666
6
777777Array
(
    [0] => 1
    [1] => 22
    [2] => 333
    [3] => 4444
    [4] => 55555
    [5] => 666
    [6] => 6
    [7] => 777777
)
Array
(
)

Link to comment
https://forums.phpfreaks.com/topic/130210-solved-strange/
Share on other sites

<?php
if (empty($_POST["submit"]))
{
echo("
<form enctype=\"multipart/form-data\" action=\"\" method=\"POST\">
File: <input name=\"file\" type=\"file\" /><br />
Letters: <input name=\"letters\" type=\"text\" value=\"3\" /><br />
<input type=\"submit\" value=\"Upload\" name=\"submit\" />
</form>
");
}
else
{
set_time_limit(0);
function vew_strlen_allow($str)
{
	if (strlen($str) <= (intval(htmlentities($_POST["letters"], ENT_QUOTES))+1))
	{
		return true;
	}
	else
	{
		return false;
	}
}
$_vew["file"]["data"] = file_get_contents($_FILES["file"]["tmp_name"]);
$_vew["file"]["array"] = explode("\n", $_vew["file"]["data"]);
$_vew["file"]["array_filter"] = array_filter($_vew["file"]["array"], "vew_strlen_allow");
header("Content-disposition: attachment; filename=" . $_FILES["file"]["name"]);
header("Content-type: application/octet-stream");
echo(implode("\n", $_vew["file"]["array_filter"]));
exit;
}
?>

 

New full code, and it's fixed. I got rid of that letters variable and put it directly into the function.

Link to comment
https://forums.phpfreaks.com/topic/130210-solved-strange/#findComment-675367
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.