Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 05-03-2009, 02:50 AM   #1
Jakez
Confirmed User
 
Jakez's Avatar
 
Industry Role:
Join Date: Jan 2004
Location: oddfuturewolfgangkillthemall!!!!!!!
Posts: 5,656
Can someone help me get the info from this array real quick lol (PHP)

idk having a brain fart or something, it's a class that uploads to rapidshare and then returns an array with the download link and other info, but I'm having trouble getting the info.

I'm running this:
Quote:
$upload=new rapidphp;
$upload->sendfile("file.rar");
Here's the class for it, it explains right here in the comments that it's returning an array:
Quote:
class rapidphp
{
//////////////////////////////////////////////////////////////////
#
# usage for free-users:
#
# $upload=new rapidphp;
# $upload->sendfile("myfile.rar");
#
#
# usage for premium-zone:
#
# $upload=new rapidphp;
# $upload->config("prem","username","password");
# $upload->sendfile("myfile.zip");
#
#
# usage for collector's zone:
#
# $upload=new rapidphp;
# $upload->config("col","username","password");
# $upload->sendfile("myfile.tar.gz2");
#
#
# you can upload several files if you want:
#
# $upload=new rapidphp;
# $upload->config("prem","username","password");
# $upload->sendfile("myfile.part1.rar");
# $upload->sendfile("myfile.part2.rar");
# // and so on
#
# sendfile() returns an array with data of the upload
# [0]=Download-Link
# [1]=Delete-Link
# [2]=Size of the sent file in bytes
# [3]=md5 hash (hex)
#
//////////////////////////////////////////////////////////////////

var $maxbuf=64000; // max bytes/packet
var $uploadpath="l3";
var $zone,$login,$passwort;

function hashfile($filename) { // md5 hash of files
return strtoupper(md5_file($filename));
}
function getserver() { // gets server for upload
while(empty($server)) {
$server=file_get_contents("http://rapidshare.com/cgi-bin/rsapi.cgi?sub=nextuploadserver_v1");
}
return sprintf("rs%s%s.rapidshare.com",$server,$this->uploadpath);
}
function config($zone,$login="",$passwort="") { // configuration
$this->zone=$zone;
$this->login=$login;
$this->passwort=$passwort;
}
function sendfile($file) { // upload a file
if(empty($this->zone)) {
$this->zone="free";
}
if($this->zone=="prem" OR $this->zone=="col") {
if(empty($this->login) OR empty($this->passwort)) {
$this->zone="free";
}
}
if(!file_exists($file)) {
die("File not found!");
}
$hash=$this->hashfile($file); // hash of the file
$size=filesize($file); // filesize (bytes) of the file
$cursize=0; // later needed
$server=$this->getserver(); // get server for uploading
$sock= fsockopen($server,80,$errorno,$errormsg,30) or die("Unable to open connection to rapidshare\nError $errorno ($errormsg)");
stream_set_timeout($sock,3600); // anti timeout
$fp= fopen($file,"r");
$boundary = "---------------------632865735RS4EVER5675864";
$contentheader="\r\nContent-Disposition: form-data; name=\"rsapi_v1\"\r\n\r\n1\r\n";
if($this->zone=="prem") { // premium
$contentheader .= sprintf("%s\r\nContent-Disposition: form-data; name=\"login\"\r\n\r\n%s\r\n",$boundary,$this->login);
$contentheader .= sprintf("%s\r\nContent-Disposition: form-data; name=\"password\"\r\n\r\n%s\r\n",$boundary,$this->passwort);
}
if($this->zone=="col") { // collector
$contentheader .= sprintf("%s\r\nContent-Disposition: form-data; name=\"freeaccountid\"\r\n\r\n%s\r\n",$boundary,$t his->login);
$contentheader .= sprintf("%s\r\nContent-Disposition: form-data; name=\"password\"\r\n\r\n%s\r\n",$boundary,$this->passwort);
}
$contentheader .= sprintf("%s\r\nContent-Disposition: form-data; name=\"filecontent\"; filename=\"%s\"\r\n\r\n",$boundary,$file);
$contenttail = "\r\n".$boundary."--\r\n";
$contentlength = strlen($contentheader) + $size + strlen($contenttail);
$header = "POST /cgi-bin/upload.cgi HTTP/1.0\r\nContent-Type: multipart/form-data; boundary=".$boundary."\r\nContent-Length: ".$contentlength."\r\n\r\n";
fwrite($sock,$header.$contentheader);
while($cursize < $size) { // If we didn't upload everything, repeat!
$buf=fread($fp,$this->maxbuf) or die("Unable to read file"); // read max bytes from the file
$cursize=$cursize+strlen($buf);
if(fwrite($sock,$buf)) { // send data
}
}
fwrite($sock,$contenttail); // finished
$ret=fread($sock,10000); // receive data (links, hash, bytes)
preg_match("/\r\n\r\n(.+)/s",$ret,$match); // we don't need the http-header
$ret=explode("\n",$match[1]); // every line gets an entry in an array
fclose($sock);
fclose($fp);
foreach($ret as $id => $cont) {
if($id!=0) { // very boring stuff!
if($id>4) break; // break foreach
$key_val[]=substr($cont,8); // throw away the first eight chars
}
}
if($hash==$key_val[3]) { // if the hash is == hash of the local file
return $key_val;
} else { // omg! upload failed!
printf("Upload FAILED! Your hash is %s, while the uploaded file has the hash %s",$hash,$key_val[3]);
return FALSE;
}
}
}
__________________
[email protected] - jakezdumb - 573689400

Killuminati
Jakez is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-03-2009, 05:49 AM   #2
darksoul
Confirmed User
 
darksoul's Avatar
 
Join Date: Apr 2002
Location: /root/
Posts: 4,997
Code:
$result = $upload->sendfile("filthy.rar");
echo "Download link is ". $result[0];
__________________
1337 5y54|)m1n: 157717888
BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
Cambooth
darksoul is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-03-2009, 06:00 AM   #3
nation-x
Confirmed User
 
nation-x's Avatar
 
Industry Role:
Join Date: Mar 2004
Location: Rock Hill, SC
Posts: 5,370
lol Jakez... how could you be selling scripts all of this time and not know something like that? I am not insulting you at all... I am just in awe of the success you have seen with your script with the limited php knowledge you demonstrate.
nation-x is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-03-2009, 02:40 PM   #4
raymor
Confirmed User
 
Join Date: Oct 2002
Posts: 3,745
Quote:
Originally Posted by nation-x View Post
lol Jakez... how could you be selling scripts all of this time and not know something like that? I am not insulting you at all... I am just in awe of the success you have seen with your script with the limited php knowledge you demonstrate.
It does surprise me at all. In twelve years, I've met exactly one knowledgeable
programmer who does much work in PHP. The rest have been more or less clueless.
You'd have been amazed to see the ICQ conversation I had the other day with a
certain well known "PHP programmer". They are selling a lot to adult webmasters.
We're looking to hire someone to do some work for us and some partners, so I've
been kind of interviewing some people. Speaking to one of the better known PHP
"programmers" in adult, they didn't know the answer to ANY of my questions about
either practical day to day PHP coding, software design, or basic PHP security to
avoid creating large security holes through your script. That didn't surprise me.
How many "PHP programmers" have ever taken a single course in programming,
computer science, etc.? Virtually none. Most have never read a single book on
the subject. They learned all that they know by copying and pasting code from
some other clueless PHP script kiddie.

I'd estimate that 95% of all PHP code being sold has serious programming errors
like putting 30 times as much load on the server as it should and taking 30 times
too long to run, and that 98% of PHP scripts have serious security issues. The only
PHP code I can think of right now that doesn't pretty much completely suck is Wordpress,
and it too has a real security hole where any user can easily get admin access on
most installations. I'll be writing a fix for that and get it integrated into future versions.
(In the meantime, the Strongbox plugin for Wordpress includes the fix).
__________________
For historical display only. This information is not current:
support&#64;bettercgi.com ICQ 7208627
Strongbox - The next generation in site security
Throttlebox - The next generation in bandwidth control
Clonebox - Backup and disaster recovery on steroids
raymor is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-03-2009, 02:47 PM   #5
Jakez
Confirmed User
 
Jakez's Avatar
 
Industry Role:
Join Date: Jan 2004
Location: oddfuturewolfgangkillthemall!!!!!!!
Posts: 5,656
Quote:
Originally Posted by nation-x View Post
lol Jakez... how could you be selling scripts all of this time and not know something like that? I am not insulting you at all... I am just in awe of the success you have seen with your script with the limited php knowledge you demonstrate.
Hahaha. I know I know.. well basically it's the arrow shit in the "$upload->sendfile()", it's just always confused me and I don't know why people use it. I don't claim to be a good programmer but if the job gets done then well..

Quote:
Originally Posted by raymor View Post
It does surprise me at all. In twelve years, I've met exactly one knowledgeable
programmer who does much work in PHP. The rest have been more or less clueless.
You'd have been amazed to see the ICQ conversation I had the other day with a
certain well known "PHP programmer". They are selling a lot to adult webmasters.
We're looking to hire someone to do some work for us and some partners, so I've
been kind of interviewing some people. Speaking to one of the better known PHP
"programmers" in adult, they didn't know the answer to ANY of my questions about
either practical day to day PHP coding, software design, or basic PHP security to
avoid creating large security holes through your script. That didn't surprise me.
How many "PHP programmers" have ever taken a single course in programming,
computer science, etc.? Virtually none. Most have never read a single book on
the subject. They learned all that they know by copying and pasting code from
some other clueless PHP script kiddie.

I'd estimate that 95% of all PHP code being sold has serious programming errors
like putting 30 times as much load on the server as it should and taking 30 times
too long to run, and that 98% of PHP scripts have serious security issues. The only
PHP code I can think of right now that doesn't pretty much completely suck is Wordpress,
and it too has a real security hole where any user can easily get admin access on
most installations. I'll be writing a fix for that and get it integrated into future versions.
(In the meantime, the Strongbox plugin for Wordpress includes the fix).
I think you answered yourself there.. one of the most popular scripts on the internet has a security flaw.. nothing is flawless no matter who is developing it.
__________________
[email protected] - jakezdumb - 573689400

Killuminati

Last edited by Jakez; 05-03-2009 at 02:51 PM..
Jakez is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-03-2009, 02:55 PM   #6
Jakez
Confirmed User
 
Jakez's Avatar
 
Industry Role:
Join Date: Jan 2004
Location: oddfuturewolfgangkillthemall!!!!!!!
Posts: 5,656
And I wouldn't sell a script if people weren't extremely satisfied and it wasn't secure for the most part. I also don't go around looking for work in programming or design or anything because I know I'm not a great programmer.

Anyways.. thanks darksoul, I know it was a stupid question I was just having a brain fart or something (was pretty drunk also) lol.
__________________
[email protected] - jakezdumb - 573689400

Killuminati
Jakez is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-03-2009, 04:21 PM   #7
Killswitch - BANNED FOR LIFE
Guest
 
Posts: n/a
Quote:
Originally Posted by nation-x View Post
lol Jakez... how could you be selling scripts all of this time and not know something like that? I am not insulting you at all... I am just in awe of the success you have seen with your script with the limited php knowledge you demonstrate.
I have always wondered the same thing, and sadly, a lot of his questions are very basic stuff too, heh...

No offense Jakez.
  Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.