Results 1 to 6 of 6

Thread: PHP to check/test text-content on another site.

Threaded View

  1. #1
    Join Date
    Oct 2008
    Location
    Sweden
    Beans
    85
    Distro
    Ubuntu 13.04 Raring Ringtail

    PHP to check/test text-content on another site.

    I'm new to PHP, I'm creating a page where people can upload zip/rar-files, and I'd be happy to receive some help. And I hope it will be a fun challange to someone who knows the ins and out's of php. For this, I have a form with 3 text fields, 1 button for file browsing, and one send/submit button.

    What I want is, for these 3 text fields to hold the send/submit-button hostage (preferably grayed out until the fields are filled out).

    One of the fields is an input for youtube-account name, so, I'd like the page to check "http://www.youtube.com/user/$USERINPUT" if the page contains the text "404 Not Found".
    This check should be performed "live".

    So far, the code looks like this.

    Code:
    <?php include("head.php"); ?>
    
    <div id='cssfield1'>
    
    <?php
    if($_FILES["zip_file"]["name"]) {
            $filename = $_FILES["zip_file"]["name"];
            $source = $_FILES["zip_file"]["tmp_name"];
            $type = $_FILES["zip_file"]["type"];
            $map = $_POST["map"];
            $youtube = $_POST["youtube"];
            $email = $_POST["email"];
    
            $name = explode(".", $filename);
            $accepted_types = array('application/x-rar-compressed', 'application/octet-stream', 'application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed');
            foreach($accepted_types as $mime_type) {
                    if($mime_type == $type) {
                            $okay = true;
                            break;
                    }
            }
    
            $continue = strtolower($name[1]) == 'zip' ? true : false;
            if(!$continue) {
                    $message = "Filen du försöker ladda upp är inte en zip eller rar-fil. Försök igen.";
            }
    
            $target_path = "/home/valpskott.se/CUSTOM/".$filename;
            if($okay == true) {
                    if(move_uploaded_file($source, $target_path)) {
                            $map = preg_replace("/[\s_]/", "ZPACE", $map);
                            $map = preg_replace("/[^a-öA-Ö0-9\s.]/", "", $map);
                            $youtube = preg_replace("/[\s_]/", "ZPACE", $youtube);
                            $youtube = preg_replace("/[^a-öA-Ö0-9\s.]/", "", $youtube);
                            $filename = preg_replace("/[\s_]/", "ZPACE", $filename);
                            $filename = preg_replace("/[^a-öA-Ö0-9\s.]/", "", $filename);
                            exec ("CUSTOM/unpack.sh $map $youtube $filename $email");
                            $message = "Din fil har laddats upp och processats.";
                    } else {
                            $message = "Det uppstod problem med din uppladdning. Försök igen.";
                    }
            }
    }
    ?>
    
    <form enctype="multipart/form-data" method="post" action="">
    <label for="map">Mappens namn:</label><br>
    <input type="text" name="map" id="map"><br>
    
    <label for="youtube">Ditt användarnamn på Youtube:</label><br>
    <input type="text" name="youtube" id="youtube"><br>
    
    <label for="email">E-post:</label><br>
    <input type="text" name="email" id="email"><br>
    
    <label>Fil:</label><br> <input type="file" name="zip_file" />
    <br />
    <input type="submit" name="submit" value="Skicka" />
    </form>
    
    <?php if($message) echo "<p>$message</p>"; ?>
    
    </div>
    
    </center>
    </body>
    </html>
    Any help or pointers is much appreciated.
    Last edited by Valpskott; May 3rd, 2013 at 02:51 PM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •