Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Advanced PHP Help  (Read 7661 times)

0 Members and 1 Guest are viewing this topic.

Jacob

    Topic Starter


    Hopeful

    Thanked: 1
    • Experience: Expert
    • OS: Windows XP
    Advanced PHP Help
    « on: December 02, 2008, 10:30:50 AM »
    Okay, I need a text box and a submit button. You enter a youtube link into the text box lets call this link 'A'. You then click submit.

    'A' Will look something like this: http://uk.youtube.com/watch?v=dxUXilGDzk8

    When you click submit, the webpage needs to find "'/watch_fullscreen?fs=" within 'A'.
    And then get the rest after that for instance it needs to turn:
    Code: [Select]
    var fullscreenUrl = '/watch_fullscreen?fs=1&BASE_YT_URL=http%3A%2F%2Fuk.youtube.com%2F&vq=None&video_id=dxUXilGDzk8&l=194&sk=UipVJyQjldAVAUTftMXy7t5W_5dt_karC&fmt_map=34%2F0%2F9%2F0%2F115&t=OEgsToPDskJBx5h73eh0V0KNAiBqz_RF&hl=en&plid=AARdE3Ki_Rpaxi-sAAACgAA4AAA&title=Wiley - She Glows';
    into:
    Code: [Select]
    =1&BASE_YT_URL=http%3A%2F%2Fuk.youtube.com%2F&vq=None&video_id=dxUXilGDzk8&l=194&sk=UipVJyQjldAVAUTftMXy7t5W_5dt_karC&fmt_map=34%2F0%2F9%2F0%2F115&t=OEgsToPDskJBx5h73eh0V0KNAiBqz_RF&hl=en&plid=AARdE3Ki_Rpaxi-sAAACgAA4AAA&title=Wiley - She Glows';

    Now lets say the link it now has is called 'B'.

    It now needs to take 'B' and add "http://www.youtube.com/get_video?" to the start.

    Once it has done all of this it should give a hyperlink to something like this:
    Code: [Select]
    http://www.youtube.com/get_video?=1&BASE_YT_URL=http%3A%2F%2Fuk.youtube.com%2F&vq=None&video_id=dxUXilGDzk8&l=194&sk=UipVJyQjldAVAUTftMXy7t5W_5dt_karC&fmt_map=34%2F0%2F9%2F0%2F115&t=OEgsToPDskJBx5h73eh0V0KNAiBqz_RF&hl=en&plid=AARdE3Ki_Rpaxi-sAAACgAA4AAA&title=Wiley - She Glows'

    I will appreciate anybody who could make this for me, as I have no experience in PHP AT ALL!
    Thank You Very Much.

    Jacob

      Topic Starter


      Hopeful

      Thanked: 1
      • Experience: Expert
      • OS: Windows XP
      Re: Advanced PHP Help
      « Reply #1 on: December 02, 2008, 10:50:05 AM »
      I may have found a solution:
      http://www.virtuosomaster.com/tutorials/youtube-flv-grabber-script/
      How would I set the php up, for exaple do i put it in the same webpage as the form, do I save it as html or php?

      Jacob

        Topic Starter


        Hopeful

        Thanked: 1
        • Experience: Expert
        • OS: Windows XP
        Re: Advanced PHP Help
        « Reply #2 on: December 02, 2008, 11:08:42 AM »
        I have uploaded this file with an extension of .php to my web host but nothing happens, could anybody help please.
        Code: [Select]
        <?php

        function GrabVideo($url)
        {
            $ch curl_init($url);
        curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue);
            curl_setopt($chCURLOPT_USERAGENT'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2');
            curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
            $page curl_exec($ch);
            if (!curl_errno($ch))
                curl_close($ch);
              else
                $page false;
            return $page;
        }

        if (isset(
        $_GET['url'])){
        $url=$_GET['url'];
        $url=trim($url);

        if (strstr($_GET['url'],"youtube.com")){
         $youtube_page =GrabVideo($_GET['url']);
        preg_match('/watch_fullscreen\?fs=(.*?)&vq=(.*?)&video_id=(.*?)&l=(.*?)&sk=(.*?)&fmt_map=(.*?)&t=(.*?)&hl=(.*?)&plid=(.*?)&/'$youtube_page$matches);
        if ($matches && isset($matches[1]) && isset($matches[3])) {
        Header("Location: http://www.youtube.com/get_video?video_id=$matches[3]&l=$matches[4]&t=$matches[7]");

        }
        }

        ?>


        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <title>Youtube Grabber Script</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

        <style type="text/css">
        <!--
        body {
        font-family: sans-serif;
        font-size: 12px;
        }
        form{ margin:0; padding:0;}
        #url {
        font-size: 1em;
        color: #222222;
        background-color: #F8F8F8;
        width: 295px;
        margin: 0px 0px 4px 0px;
        padding: 3px;
        border-color: #333333 #CCCCCC #CCCCCC #333333;
        border-style: solid;
        border-width: 1px;
        }
        .submit
        { background-color: #000000;
         height:22px;
        border:1px solid #666666;
        color:#FFF; font-size:12px;
        font-weight:bold;
        }
        p{ margin:0; padding:2px 0}

        -->
        </style>
        </head>

        <body>

        <form method="get" action="" name="form">
        <input type="text" id="url" name="url" /><br>
              <p>  example: <a href="http://www.youtube.com/watch?v=QFrqKYwmhMc" target="_blank">http://www.youtube.com/watch?v=QFrqKYwmhMc</a></p>
        <input type="submit" class="submit" value="Grab Video" />
        </form>
        </body>
        </html>

        ChrisXPPro



          Adviser

        • Forever Learning
        • Thanked: 4
          • ACB Systems
        • Computer: Specs
        • Experience: Experienced
        • OS: Windows XP
        Re: Advanced PHP Help
        « Reply #3 on: December 02, 2008, 11:11:26 AM »
        If you click on the http://www.virtuosomaster.com/tutorials/samples/youtube-flv-grabber.php.txt link it will take you to the complete page.  I did note there was a line of space between the php closing tag  and the following doctype line - I'd remove that space.

        If any file has <?php ?> tags then it will take the extension .php even if there is html mixed in.  It is not at all uncommon to have both mixed in together.

        ~~~~~~~~~~~~~~~~~~~~

        Ahhh - see you tried it.  I haven't time to check this out right now but hopefully a php guru can have a look.  Remove that line space I mentioned and - make sure file is .php
        Ain't technology great - until it goes wrong!

        Jacob

          Topic Starter


          Hopeful

          Thanked: 1
          • Experience: Expert
          • OS: Windows XP
          Re: Advanced PHP Help
          « Reply #4 on: December 02, 2008, 11:17:06 AM »
          I took away that line, but it's very weird.
          I just get, for example:
          www.flvyoutube.com/youtube-flv.php
          turns into
          www.flvyoutube.com/youtube-flv.php?url=http%3A%2F%2Fuk.youtube.com%2Fwatch%3Fv%3D-T_SryRAXuw
          and nothing happens.

          ChrisXPPro



            Adviser

          • Forever Learning
          • Thanked: 4
            • ACB Systems
          • Computer: Specs
          • Experience: Experienced
          • OS: Windows XP
          Re: Advanced PHP Help
          « Reply #5 on: December 02, 2008, 11:19:22 AM »
          Outa my depth for now ... hope for other input.
          Ain't technology great - until it goes wrong!

          Jacob

            Topic Starter


            Hopeful

            Thanked: 1
            • Experience: Expert
            • OS: Windows XP
            Re: Advanced PHP Help
            « Reply #6 on: December 02, 2008, 11:24:59 AM »
            Thanks so far anyway.  ;) For your help on both topics.

            Jacob

              Topic Starter


              Hopeful

              Thanked: 1
              • Experience: Expert
              • OS: Windows XP
              Re: Advanced PHP Help
              « Reply #7 on: December 02, 2008, 11:40:31 AM »
              It is fixed, never mind it was just my crappy free host, thanks everyone.  ;)

              ChrisXPPro



                Adviser

              • Forever Learning
              • Thanked: 4
                • ACB Systems
              • Computer: Specs
              • Experience: Experienced
              • OS: Windows XP
              Re: Advanced PHP Help
              « Reply #8 on: December 02, 2008, 11:47:51 AM »
              So - curiosity here - can you give a report on its function sequence - end result etc ... interesting to know the details.
              Ain't technology great - until it goes wrong!

              Jacob

                Topic Starter


                Hopeful

                Thanked: 1
                • Experience: Expert
                • OS: Windows XP
                Re: Advanced PHP Help
                « Reply #9 on: December 02, 2008, 12:02:15 PM »
                Sorry, I'm not sure how to do that, but please, take a look at this, I'm very pleased with what I have created, (with alot of help)
                http://ytflv.110mb.com/youtube-flv.php

                ChrisXPPro



                  Adviser

                • Forever Learning
                • Thanked: 4
                  • ACB Systems
                • Computer: Specs
                • Experience: Experienced
                • OS: Windows XP
                Re: Advanced PHP Help
                « Reply #10 on: December 02, 2008, 12:18:41 PM »
                Looks good  :) 

                One thing I'd change is that rather faint red text in the form field -- #FFD728 - might be better a bit darker.

                So - I assume this does the job as you want now?
                Ain't technology great - until it goes wrong!

                Jacob

                  Topic Starter


                  Hopeful

                  Thanked: 1
                  • Experience: Expert
                  • OS: Windows XP
                  Re: Advanced PHP Help
                  « Reply #11 on: December 02, 2008, 12:21:35 PM »
                  Thank you, and yes it works perfectly, thanks.
                  Does this display properly in IE7, as I am using firefox, and just by chance I thought you might be using IE?
                  Thank you.

                  ChrisXPPro



                    Adviser

                  • Forever Learning
                  • Thanked: 4
                    • ACB Systems
                  • Computer: Specs
                  • Experience: Experienced
                  • OS: Windows XP
                  Re: Advanced PHP Help
                  « Reply #12 on: December 02, 2008, 02:03:18 PM »
                  Just checked IE vs FF - pretty much same and main difference is text size - as is usual FF shows a bit larger but essentially they match well.  I don't have Opera set up on this puter so couldn't check that.

                  Field text looks way better.  :)
                  Ain't technology great - until it goes wrong!

                  Jacob

                    Topic Starter


                    Hopeful

                    Thanked: 1
                    • Experience: Expert
                    • OS: Windows XP
                    Re: Advanced PHP Help
                    « Reply #13 on: December 02, 2008, 02:31:57 PM »
                    Thank you.  ;) and thanks for your help once again.