Sign in to follow this  
Followers 0
Skitty

Help with PHP

15 posts in this topic

#1 ·  Posted (edited)

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

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

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

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

Ok, so this is strange, I just tested this on another computer on my local area network and I successfully uploaded 110mb of data..


Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Can it be some firewall settings?

Or maybe moving between partitions?

Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

Btw, I lol'd at your avatar.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

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

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

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

1 person likes this

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

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
1 person likes this

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

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

So you changed cool avatar with boring one and kept your nick name.

I hope you weren't making any important RL decisions yesterday.

1 person likes this

♡♡♡

.

eMyvnE

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • Jefrey
      By Jefrey
      I've made this HTTP lib to simplify HTTP requests, mainly when dealing about POST data or file uploads.
      Three functions are available:
      string _HTTP_Get ( string $sURL ) string _HTTP_Post ( string $sURL , string $sPostData ) string _HTTP_Upload ( string $sURL , string $sFilePath , string $sFileField , string $sPostData = '' , string $sFilename = Default) Additionaly, two helper functions are also available:
      URLEncode($sStr) URLDecode($sStr) Full documentation: https://github.com/jesobreira/HTTP.au3/blob/master/README.md
      Fork me on Github: https://github.com/jesobreira/HTTP.au3
      Download lib + docs: https://github.com/jesobreira/HTTP.au3/archive/master.zip
    • MrTheDzam
      By MrTheDzam
      Hello guys!

      I changed my website's login page yesterday. In that file, i used header() function to redirect user from login page to error page.
      But now my script (use WinHttpObj library) can't work. But if i change the login page to old page (without redirect) then my script works

      How can i fix that? 
    • James
      By James
      Hey all,
      I've been away for a while, working on one thing or another... Recently it's been StyleCI, The PHP Coding Style Service.
      StyleCI connects to your GitHub repositories and watches for commits or pull requests, with the ability of automatically fixing the code standards if it hasn't matched your settings.
      The likes of Laravel and Graze are using StyleCI now, among many other projects. Yesterday we hit a massive milestone, we analysed the 100,000 commit!
      I'd love to hear your feedback
      Cheers,
      James
    • MrTheDzam
      By MrTheDzam
      Hey guys!
      I have a register page. when i click register, it's will insert information to database.
      But if i refresh the page, the script just continues and insert the information to database again
       
      How can i fix it? 
       
    • Skysnake
      By Skysnake
      Hi everyone
      This is not a request for sample code.
      I was looking at one of my AutoIt projects, and my browser was open on a WordPress site we use and a thought occurred: Has anyone tried to use AutoIt as a front end (GUI), with the data read to/from WordPress and the result displayed in the AutoIt GUI?
      Simple example would be a kind of online calendar.  Would require a WordPress plugin. Kind of thing Outlook has.  Except, all the calendaring is done in the background by WordPress, and the result read/modified/written by AutoIt using PHP to the WordPress database (MySQL).
      I suspect in addition to AutoIt, one needs substantial HTML, SQL and PHP skills. 
      Has anyone perhaps attempted this? Am I wasting my time?  If I can get the calendar working, I have the simplicity and speed of AutoIt available immediately, with the online database/calendar capabilities of WordPress.
      All thoughts and comments very welcome.