F
feldon23

  • Dec 22, 2003
  • Joined Jan 23, 2003
  • $_FILES['userfile']['name']
    The original name of the file on the client machine.

    $_FILES['userfile']['tmp_name']
    The temporary filename of the file in which the uploaded file was stored on the server.

    from PHP manual.

    • <?php
      if ($_POST['submit']) {
        foreach ($_POST as $key => $value) {
          if ($key != 'submit') {
            echo "$key = $value <br>\n";
          }
        }
      } else {
        echo "<form method=\"post\" action=\"$_SERVER['PHP_SELF']\">\n";
        for($i=0;$i<5;$i++) {
          echo "Input #$i: <input type=\"text\" name=\"input$i\"><br>\n";
        }
        echo "<input type=\"submit\" value=\"OK\"></form>";
      }
      ?>
      • Wrappers do introduce a random element to PHP programming.

        Access privileges, IP address blocking and filtering, various other configuration options and just plain dumb luck can lock you out from accessing another website in this manner.

        Can you tell us what task you are trying to accomplish so we can recommend the best possible code?

        • If you don't want it copied, don't display it or make it available in any form. Period! Simple!!

          • The solution is HEREDOC notation or external templates.

            $pagetitle = "The Importance of Being Earnest";
            $files['logo'] = "importance.gif";
            $files['link'] = "test.html";
            
            $html=<<<HEREDOC
            <html>
            <body>
            This is a cool topic that she's brought up about "$pagetitle".
            <a href="$files['link']">
            <img src="$files['logo']" width="400" height="127" alt="$pagetitle" border="0">
            </a>
            </body>
            </html>
            HEREDOC;
            
            echo $html;
            • Ok, you have several choices.

              You can:

              index.php

              <html>
              <body>
              blah blah
              <table>
              <?php TABLE CONTENTS GENERATED BY PHP ?>
              </table>
              </body>
              </html>

              and then point people to index.php.

              Or you can do templates:

              template.html

              <html>
              <body>
              blah blah
              <table>
              %%tablecontents%%
              </table>
              </body>
              </html>

              index.php

              <?php
              $file=file('template.html');
              $file = str_replace('%%tablecontents%%', $whatgoesinthetable, $file);
              echo $file;
              ?>

              Or you could change your apache settings with an .htaccess file so that all HTML files are run through the PHP parser. Of course if you have just a few HTML files with PHP, then this slows things down significantly for no reason.

              • PHP is typically an Apache module, which means it has the access privileges of a walnut.

                If you need to chmod a directory to 0777, then you need to login with FTP or Shell and do so.

                • furious5 = smoking something

                  You want array_search().

                  • "name" is processed for escape sequences and variables.

                    name is a constant which, if not present, is changed to 'name' by PHP

                    'name' is the correct way

                    • Because you aren't storing username or password from page to page.

                      if (($_POST['username'] == 'username') && ($_POST['password'] == 'password')) {
                        $_SESSION['authorized'] = true;
                      }
                      if (($_POST['username'] == 'username2') && ($_POST['password'] == 'password2')) {
                        $_SESSION['authorized'] = true;
                      }
                      
                      if ($_SESSION['authorized']) {
                        $_SESSION['username'] = $_POST['username'];
                        $_SESSION['password'] = $_POST['password'];
                        require('loggedin.html');
                      } else {
                        require('login.html');
                      }
                      • Looks ok to me. Have you tried manually setting $P_email to your own address?

                        • $packageoptions = array(
                            'hostingbronze' => 'HOSTING: Bronze',
                            'hostingsilver' => 'HOSTING: Silver',
                            'hostinggold' => 'HOSTING: Gold',
                            'hostingplatinum' => 'HOSTING: Platinum',
                            'resellerstartup' => 'RESELLER: Startup',
                            'resellerpro' => 'RESELLER: Professional',
                            'resellerenterprise' => 'RESELLER: Enterprise',
                            'resellerenterpriseplus' => 'RESELLER: Enterprise+');
                          
                          $package = $_GET['package'];
                          
                          echo "<select name=\"package\" style=\"FONT-FAMILY: Verdana; FONT-SIZE: 11px\">\n";
                          
                          foreach($packageoptions as $key => $value) {
                            $tmp = "";
                            if ($package == $key) {
                              $tmp = " SELECTED";
                            }  
                          echo "<option value=\"$key\"$tmp>$value</option>\n"; } echo "</select>\n";
                          • I still think most of these standards are just to give someone a job instead of actually improving compatibility.

                            All-caps HTML jumps out at you, doesn't it? Good!

                            • Damnit this thing is useless. Lemme post a picture. Fortunately this bug is fixed in vB3.

                              Well I guess you are going to have to htmlspecialchars and then
                              to undo the damage on &nbsp: and to revert &lt: and &gt: to < and >, see attachment below:

                              • I meticulously indent my HTML and standardize on capitalized HTML tags <BODY> <HTML> etc. and lowercase CSS

                                <DIV style="font-family: Helvetica, Arial, san-serif;" class="elvis">
                                <B>Hello there!</B></DIV>

                                I find more bugs that way. By having my code written like that, then the errors jump right out at me.

                                • And of course it's not really sexy until it does an Unsharp Mask. 🙂

                                  • I could be wrong but it doesn't sound to me like you want anything translated.

                                    You want & left alone, &nb sp; left alone, and <br> left alone.

                                    I think the only thing you need to do is, if magicquotes are on, stripslashes...

                                     if (get_magic_quotes_gpc() == TRUE) {
                                      $data = stripslashes($data);
                                    }