GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   anything wrong with my code.. php (https://gfy.com/showthread.php?t=959454)

Fucksakes 03-20-2010 11:41 PM

anything wrong with my code.. php
 
PHP Code:


    
if( file_exists$url.'/video.mp4') )
    {
        
$filename $url.'/video.mp4';
    } else {
        
$filename $url.'/video.flv';
    } 


fatfoo 03-20-2010 11:51 PM

Run...

http://www.x2d.org/pixels/zombiechopper-2x.png

Fucksakes 03-20-2010 11:53 PM

are you ok?

fatfoo 03-20-2010 11:56 PM

Are you a bot?

k0nr4d 03-20-2010 11:58 PM

looks ok.

k0nr4d 03-21-2010 12:13 AM

no wait. You cant do file_exists on a url, only a linux path. I knew it was a trick question!

munki 03-21-2010 12:18 AM

Quote:

Originally Posted by k0nr4d (Post 16964300)
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.

AlCapone 03-21-2010 12:44 AM

Looks like the beginnings of a tube script.

AlCapone 03-21-2010 12:53 AM

Code:

$url="http://www.site.com/video.flv";

$fp = fopen('$url', 'r');
if($fp) {
        $filename="$url";
        fclose($fp);
}


fris 03-21-2010 08:05 AM

Quote:

Originally Posted by AlCapone (Post 16964318)
Code:

$url="http://www.site.com/video.flv";

$fp = fopen('$url', 'r');
if($fp) {
        $filename="$url";
        fclose($fp);
}


thats really bad code

cyco_cc 03-21-2010 08:20 AM

Quote:

Originally Posted by fris (Post 16964648)
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.

k0nr4d 03-21-2010 08:23 AM

Quote:

Originally Posted by AlCapone (Post 16964318)
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.

MichaelP 03-21-2010 08:41 AM

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';
}

Brujah 03-21-2010 09:15 AM

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);


CaptainHowdy 03-21-2010 09:27 AM

Quote:

Originally Posted by AlCapone (Post 16964315)
Looks like the beginnings of a tube script.

http://bavatuesdays.com/files/2006/07/toomuch.jpg

fris 03-21-2010 06:25 PM

use file_exists works for local and url

rowan 03-21-2010 06:52 PM

Quote:

Originally Posted by k0nr4d (Post 16964662)
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.

Overload 03-21-2010 07:36 PM

Quote:

Originally Posted by CaptainHowdy (Post 16964758)

edgar wallace?

SomeCreep 03-21-2010 09:52 PM

Quote:

Originally Posted by Fucksakes (Post 16964272)
PHP Code:


    
if( file_exists$url.'/video.mp4') )
    {
        
$filename $url.'/video.mp4';
    } else {
        
$filename $url.'/video.flv';
    } 


Too much chinese, ching chang kling kong.


All times are GMT -7. The time now is 03:07 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc