anything wrong with my code.. php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Fucksakes
    Shit... Fuck! What the Hell?
    • Dec 2003
    • 7567

    #1

    anything wrong with my code.. php

    PHP Code:
    
        if( file_exists( $url.'/video.mp4') )
        {
            $filename = $url.'/video.mp4';
        } else {
            $filename = $url.'/video.flv';
        } 
    
  • fatfoo
    ICQ:649699063
    • Mar 2003
    • 27763

    #2
    Run...

    Send me an email: [email protected]

    Comment

    • Fucksakes
      Shit... Fuck! What the Hell?
      • Dec 2003
      • 7567

      #3
      are you ok?

      Comment

      • fatfoo
        ICQ:649699063
        • Mar 2003
        • 27763

        #4
        Are you a bot?
        Send me an email: [email protected]

        Comment

        • k0nr4d
          Confirmed User
          • Aug 2006
          • 9231

          #5
          looks ok.
          Mechanical Bunny Media
          Mechbunny Tube Script | Mechbunny Webcam Aggregator Script | Custom Web Development

          Comment

          • k0nr4d
            Confirmed User
            • Aug 2006
            • 9231

            #6
            no wait. You cant do file_exists on a url, only a linux path. I knew it was a trick question!
            Mechanical Bunny Media
            Mechbunny Tube Script | Mechbunny Webcam Aggregator Script | Custom Web Development

            Comment

            • munki
              Do Fun Shit.
              • Dec 2004
              • 13393

              #7
              Originally posted by k0nr4d
              no wait. You cant do file_exists on a url, only a linux path. I knew it was a trick question!
              I've run into a few issues on file_exists not working on big movie files also... I believe approaching 2-3 gb limits.

              I have the simplest tastes. I am always satisfied with the best.” -Oscar Wilde

              Comment

              • AlCapone
                Confirmed User
                • Sep 2003
                • 708

                #8
                Looks like the beginnings of a tube script.
                "You can get more with a kind word and a gun than you can with a kind word alone.”

                Comment

                • AlCapone
                  Confirmed User
                  • Sep 2003
                  • 708

                  #9
                  Code:
                  $url="http://www.site.com/video.flv";
                  
                  $fp = fopen('$url', 'r');
                  if($fp) {
                  	$filename="$url";
                  	fclose($fp);
                  }
                  "You can get more with a kind word and a gun than you can with a kind word alone.”

                  Comment

                  • fris
                    Too lazy to set a custom title
                    • Aug 2002
                    • 55679

                    #10
                    Originally posted by AlCapone
                    Code:
                    $url="http://www.site.com/video.flv";
                    
                    $fp = fopen('$url', 'r');
                    if($fp) {
                    	$filename="$url";
                    	fclose($fp);
                    }
                    thats really bad code
                    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

                    Comment

                    • cyco_cc
                      Confirmed User
                      • Oct 2008
                      • 344

                      #11
                      Originally posted by fris
                      thats really bad code
                      Yeah, there's no sense in using the resources to open the file just to check for its existence and also (I haven't done anything in PHP for years so I may be wrong) I think fopen() by default doesn't allow you to open up URLs for security reasons.

                      To the OP, as konrad said, replace the $url with the local FS path and it should be fine.

                      Comment

                      • k0nr4d
                        Confirmed User
                        • Aug 2006
                        • 9231

                        #12
                        Originally posted by AlCapone
                        Code:
                        $url="http://www.site.com/video.flv";
                        
                        $fp = fopen('$url', 'r');
                        if($fp) {
                        	$filename="$url";
                        	fclose($fp);
                        }
                        Don't do this. Not only will this use a whole lot of ram, it will download the file over http first.
                        Mechanical Bunny Media
                        Mechbunny Tube Script | Mechbunny Webcam Aggregator Script | Custom Web Development

                        Comment

                        • MichaelP
                          Registered User
                          • Aug 2003
                          • 7124

                          #13
                          TRY :

                          $file = "full/server/path/to/file/video.mp4" ;
                          $url = "http://somedomain.com/" ;

                          IF (file_exists( $file)) {
                          $filename = $url/video.mp4';
                          } ELSE {
                          $filename = $url/video.flv';
                          }

                          Comment

                          • Brujah
                            Beer Money Baron
                            • Jan 2001
                            • 22157

                            #14
                            Code:
                            $filename = $url.'video.mp4';
                            $ch = curl_init($filename);
                            
                            curl_setopt($ch, CURLOPT_NOBODY, TRUE);
                            curl_exec($ch);
                            
                            $ret = curl_getinfo($ch, CURLINFO_HTTP_CODE);
                            if ($ret >= '400')
                            {
                            	$filename = $url.'video.flv';
                            }
                            
                            curl_close($ch);

                            Comment

                            • CaptainHowdy
                              Too lazy to set a custom title
                              • Dec 2004
                              • 94731

                              #15
                              Originally posted by AlCapone
                              Looks like the beginnings of a tube script.

                              Comment

                              • fris
                                Too lazy to set a custom title
                                • Aug 2002
                                • 55679

                                #16
                                use file_exists works for local and url
                                Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

                                Comment

                                • rowan
                                  Too lazy to set a custom title
                                  • Mar 2002
                                  • 17393

                                  #17
                                  Originally posted by k0nr4d
                                  Don't do this. Not only will this use a whole lot of ram, it will download the file over http first.
                                  It's a strange way to do things, but I don't think it would download the entire file. At most it would read the response and a few K of data until the buffer becomes full.

                                  Comment

                                  • Overload
                                    Confirmed User
                                    • Jul 2005
                                    • 3185

                                    #18
                                    Originally posted by CaptainHowdy
                                    edgar wallace?
                                    There aren't enough faces and palms on this planet for an appropriate reaction to religion.

                                    Comment

                                    • SomeCreep
                                      :glugglug
                                      • Mar 2003
                                      • 26118

                                      #19
                                      Originally posted by Fucksakes
                                      PHP Code:
                                      
                                          if( file_exists( $url.'/video.mp4') )
                                          {
                                              $filename = $url.'/video.mp4';
                                          } else {
                                              $filename = $url.'/video.flv';
                                          } 
                                      
                                      Too much chinese, ching chang kling kong.

                                      Webair Hosting

                                      I use and recommend Webair for hosting.

                                      Comment

                                      Working...