Jump to content

Help with PHP


Skitty
 Share

Recommended Posts

I don't know where to post this...

I'm trying to get autoit to be able to uploade files larger than 20 mb, if I use my sites default upload script~

if (isset($_POST['_submit'])) {
   for ($i = 0; $i < $num_files; $i++) {
       if ($_FILES['_file']['name'][$i] == '')
          continue;
       $File = strtr(stripslashes($_FILES['_file']['name'][$i]), ''" |/?!*#', '__________');
       $dotpos = strrpos($File, '.');
       $length = strlen($File);
       $ext = strtolower(substr($File, -($length - $dotpos - 1)));
       $noext  = substr($File, 0, -($length - $dotpos - 1));
        if (!in_array($ext, $flat_allowed)) {
           LogErrors("{$txt['extension']} <b>$ext</b> {$txt['not_allowed']}");
           continue;
        }
        switch($_FILES['_file']['error'][$i]) {
            case 0:
               break;
            case 1:
               LogErrors($txt['PHP_file_size']);
               continue 2;
               break;
            case 2:
               LogErrors("$txt[file_size] $txt[exceded_limit]");
               continue 2;
               break;
            case 3:
               LogErrors($txt['partial_upload']);
               continue 2;
               break;
            case 4:
               LogErrors($txt['no_file']);
               continue 2;
               break;
        }
        if ($_FILES['_file']['size'][$i] > (_MAXSIZE * 1024)) {
           LogErrors($txt['file_size'].' ('.round($_FILES['_file']['size'][$i]/1024, 2)." $txt[KB]) {$txt['not_allowed']}");
           continue;
        }
        $fullname = _REALPATH.$File;
        if (!isset($content))
           $content = '';
        if (_OVERWRITE == false or !isset($_POST['_overwrite'])) {
           if (file_exists($fullname)) {
              LogErrors($txt['file_exists']);
              continue;
           }
           if (isset($allowed['exec']) and in_array($ext, $allowed['exec'])) {
              if ($ext == 'php' and $highlight_php == true and file_exists(_REALPATH.$noext.'html')) {
                 LogErrors($txt['exec_file_exists']);
                 continue;
              } elseif (file_exists(_REALPATH.$noext.'txt')) {
                 LogErrors($txt['exec_file_exists']);
                 continue;
              }
           }
        }
        if(@move_uploaded_file($_FILES['_file']['tmp_name'][$i], $fullname)) {
            if (isset($allowed['image']) and in_array($ext, $allowed['image']))
               is_image();
            elseif (isset($allowed['text']) and in_array($ext, $allowed['text']))
               is_text();
            elseif (isset($allowed['exec']) and in_array($ext, $allowed['exec']))
               is_exec();
            elseif (isset($allowed['package']) and in_array($ext, $allowed['package']))
               $uploaded[] = $File;
            if ($change_mode == true)
               @chmod($fullname, $mode)or
               LogErrors($txt['chmod_fail']);
        } else {
            LogErrors($txt['move_failiur'].'<br />'.$txt['try_again']);
            if (!file_exists(_REALPATH))
               echo '<span style="color:red; font-size: 12pt;"><b>'.$txt['doesnot_exist'].'</b></span><br />';
            elseif (!is_writable(_REALPATH))
               echo '<span style="color:red; font-size: 12pt;"><b>'.$txt['unwritable'].'</b></span><br />';
        }
   }
   if ($show_error_log == true and isset($errors) and count($errors) > 0)
      ShowErrorLog($errors);
   if ($show_uploaded_list == true and isset($uploaded) and count($uploaded) > 0)
      ShowUploaded($uploaded);
   if (isset($content))
      echo $content;
   if ($show_upload_form == true)
      PrintForm();
   if ($notify_admin == true)
      MailUploaded();
   if ($log_upload == true)
      FilesLogging();
} else
  PrintForm();
clearstatcache();

I can uploade files up to 130+ mb from anywhere.

But using this code~

<html><body><form action="" method="post" enctype="multipart/form-data"><input type="hidden"  type="file" name="file" multiple="multiple" /><input type="hidden"  type="submit" /></form><?PHP if($_FILES){move_uploaded_file($_FILES['file']['tmp_name'],'C:/place/'.basename($_FILES['file']['name']));} ?></body></html>[/HTML]

I can't upload anything past 10+ mb except if I'm on the actual machine that hosts the server, what is going on?

I was making an app that archive music and uploads it to my server but as I discovered, it wont let me upload anything past 10mb from any of my friends places and I have to make a bunch of smaller archives in order to do it, which is not cool at all..

Edit: Got it too work..

Edited by THAT1ANONYMOUSEDUDE
Link to comment
Share on other sites

In "php.ini" set:

upload_max_filesize

To a bigger value. I assume you've got it set to a maximum of 10MB. I've had issues where I could upload files larger than the limit locally before.

Thanks for the info but I already have both the upload variables set to 150mb in php.ini, it's weird because the first larger script lets me upload large file both locally and remotely where the smaller script only lets me upload large files locally and not remotely.

memory_limit = 128M
post_max_size = 150M
file_uploads = On
upload_tmp_dir = C:/UniServer/tmp
upload_max_filesize = 150M
Edited by THAT1ANONYMOUSEDUDE
Link to comment
Share on other sites

And how does AutoIt code look like? Are you sure the problem is/was not here?

I'm actually using the udf you co created, winhttp.au3, latest version unless someone updated it about a month ago.

#include "WinHttp.au3"
MsgBox(0,"",HTTPSend(@ScriptDir&"file.rar"))
Func HTTPSend($File)
Local $hOpen, $hConnect, $sRead, $hOpen = _WinHttpOpen(), $hConnect = _WinHttpConnect($hOpen, "site.com"), _
$sRead = _WinHttpSimpleFormFill($hConnect, "test.php", "index:0", "name:file", $File)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)
Return $sRead
EndFunc
Edited by THAT1ANONYMOUSEDUDE
Link to comment
Share on other sites

Can it be some firewall settings?

That may be what is happening, seeing as this only happens at different locations, that may very well be what is happening, or a slow connection, but in reality, I have no idea really, but if it was due to a firewall, it would be strange that the first php script lets me upload very large files from a browser universally and the second smaller php script seems to only work on PC's that are fast using autoit and when I'm on a laptop, it rarely works when the laptop is slow (i.e., an acer d250).

Edited by THAT1ANONYMOUSEDUDE
Link to comment
Share on other sites

  • 4 weeks later...

Btw, I lol'd at your avatar.

Well, I changed my avatar, so people aren't going to know what you lol'd about ...


Anyway, I don't want to pollute the forum with my posts so I'll use this old thread...

I'm having trouble with PHP again, this time it involves javascript being injected from a php function into the main page, why does js not work when you write it to the page via php?

It looks something like this..

$Var .= '<head>' .  <<<EOF
<script type="text/javascript">
  //<![CDATA[
  ~Some js here & there~
  //]]>
</script>
</head>
EOF;
Edited by THAT1ANONYMOUSEDUDE
Link to comment
Share on other sites

The old avatar said: "The best thing about censorship is ████████" :)

Close, it was actually "The worst thing about censorship is ████████"


Anyway, I figured I'd just include the javascript code by obtaining it from an external source which works, but being able to change things in it with php would still be good..

Edited by THAT1ANONYMOUSEDUDE
Link to comment
Share on other sites

Anyway, I figured I'd just include the javascript code by obtaining it from an external source which works, but being able to change things in it with php would still be good..

It works just fine. Shouldn't be any problems if you do it in most obvious way. Probably some mistake with quotes or escaping. Check the resulting HTML and if it matches your expectations. If it doesn't, then that's your problem. If it does, then your expectations need to be adjusted and you can find the correct way of putting Javascript in HTML. In second case, PHP is not the problem.
Link to comment
Share on other sites

$Var = <<<EOF
<head>
<script type="text/javascript">
//<![CDATA[
~Some js here & there~
//]]>
</script>
</head>
EOF;

Why would you concatenate a literal string with a heredoc?

A heredoc will only break if the EOF; is not on its own line with no indentation! You can copy whatever the fuck you want in there otherwise.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...