Jump to content

problem with generator megaupload links

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
13 replies to this topic

#1
yamaguchi

yamaguchi

    Newbie

  • Members
  • PipPip
  • 12 posts
Hello everyone!
I would like to ask for help from you to the following script:

<?php

# get infos

error_reporting(0);

$link = $_POST['link']; //link for generate

$mu_login = "LOGIN_MEGAUPLOAD";

$mu_pass = "PASSWORD_MEGAUPLOAD";



if($link == "") {

header("Location: index.php?generate=erro&msg=".urlencode('Enter the link you want to generate.'));

exit;

} else {

if(!(strpos($link,"megaupload.com")) OR strpos($link,"megaupload.com") !=strrpos($link,"megaupload.com")) {

header("Location: index.php?generate=erro&msg=".urlencode('The link is not inserted a link megaupload.com.'));

exit;

} else {

}

}


# premium link megaupload

$ch = curl_init();

curl_setopt( $ch, CURLOPT_URL, $link );

curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );

curl_setopt( $ch, CURLOPT_USERAGENT, "Googlebot/2.1");

curl_setopt( $ch, CURLOPT_POSTFIELDS, "login=1&redir=1&username=$mu_login&password=$mu_pass");

    

$out = curl_exec($ch);

    

$dom = new DOMDocument;

@$dom->loadHTML( $out );

    

$xpath = new DOMXPath( $dom );

$echo_link = $xpath->query( "//div[@id='downloadlink']//a" )->item(0)->getAttribute( 'href' );

header("Location: index.php?generate=link&link=$echo_link");

exit;

}

}

?>

It generates links megaupload Premium, but he could not get through to generate megaupload links that have passwords. And also if the link is broken, even if completed in one page all white. Would like for an error message? Does anyone know how to do this? Can you help me?
Thanks guys!

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
You had turned error reporting off, you may wish to turn that on:
error_reporting(E_ALL);
ini_set('display_errors', 1);

What sort of problems do you get when you turn error reporting on?
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
yamaguchi

yamaguchi

    Newbie

  • Members
  • PipPip
  • 12 posts
So, suppose that the link is broken that will be generated. When it runs the script, just shows the PHP error. How do I display a message defined? For example: "Error generating link."

#4
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
"$echo_link" should be a link if it is successfully generated, you could check if that variable is not an url (is broken)
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#5
yamaguchi

yamaguchi

    Newbie

  • Members
  • PipPip
  • 12 posts
But the error occurs at line "$ ch = curl_init ();". There no way to create a check in the "$ echo_link" because it does not generate anything! The error just this line.

#6
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
Are you sure it is at that line and not "$out = curl_exec();" ?
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#7
yamaguchi

yamaguchi

    Newbie

  • Members
  • PipPip
  • 12 posts
oh no!! sorry, is on line of the "$echo_link". Error is: "Fatal error: Call to a member function getAttribute() on a non-object in". But how do I correct this bug? With if? Is to give a brief example? Thanks!!!

#8
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
$out most likely is empty, or $dom/$xpath returns an error. You can try something like this:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);  

$link = $_POST['link']; //link for generate
$mu_login = "LOGIN_MEGAUPLOAD";
$mu_pass = "PASSWORD_MEGAUPLOAD";


if($link == "") {
header("Location: index.php?generate=erro&msg=".urlencode('Enter the link you want to generate.'));
exit;
} else {
if(!(strpos($link,"megaupload.com")) OR strpos($link,"megaupload.com") !=strrpos($link,"megaupload.com")) {
header("Location: index.php?generate=erro&msg=".urlencode('The link is not inserted a link megaupload.com.'));
exit;
} else {
}
}

# premium link megaupload
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $link );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_USERAGENT, "Googlebot/2.1");
curl_setopt( $ch, CURLOPT_POSTFIELDS, "login=1&redir=1&username=$mu_login&password=$mu_pass");
    
$out = curl_exec($ch);
    
if(!empty($out)) {
$dom = new DOMDocument;
$dom->loadHTML( $out );
    
$xpath = new DOMXPath( $dom );
$echo_link = $xpath->query( "//div[@id='downloadlink']//a" )->item(0)->getAttribute( 'href' );
header("Location: index.php?generate=link&link=$echo_link");

} else {
header("Location: index.php?generate=erro&msg=".urlencode('There was an error getting the link.'));
exit;
}
}
} 

Note I turned on error reporting and had removed the "@" suppression operator, they both should display a real error to tell you why it did not work. You should always leave error reporting on while you build the script.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#9
yamaguchi

yamaguchi

    Newbie

  • Members
  • PipPip
  • 12 posts
Ok I made some modifications to the script and include the end to give the if the error, but it kinda confused ... so, again the error appears. Take a look at the script below. How to fix it?


<?php

error_reporting(E_ALL);

ini_set('display_errors', 1); 


$link = $_GET['link'];

$mu_login = "LOGIN_MEGAUPLOAD";

$mu_pass = "PASSWORD_MEGAUPLOAD";


if($link == "") {

echo "Enter the link you want to generate.";

exit;

} else {

if(!(strpos($link,"megaupload.com")) OR strpos($link,"megaupload.com") !=strrpos($link,"megaupload.com")) {

echo "The link is not inserted a link megaupload.com.";

exit;

} else {

}

}


//get link

$ch = curl_init();

curl_setopt( $ch, CURLOPT_URL, $link );

curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );

curl_setopt( $ch, CURLOPT_USERAGENT, "Googlebot/2.1");

curl_setopt( $ch, CURLOPT_POSTFIELDS, "login=1&redir=1&username=$mu_login&password=$mu_pass");

    

$out = curl_exec($ch);

    

$dom = new DOMDocument;

$dom->loadHTML( $out );

    

$xpath = new DOMXPath( $dom );


if(!empty($xpatch)) {

echo "There was an error getting the link.";

} else {

echo $xpath->query( "//div[@id='downloadlink']//a" )->item(0)->getAttribute( 'href' );

}

?>


#10
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
Try this, $dom->load should return false on error so I added a check for it. It should correct the problem:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1); 

$link = $_GET['link'];
$mu_login = "LOGIN_MEGAUPLOAD";
$mu_pass = "PASSWORD_MEGAUPLOAD";

if($link == "") {
echo "Enter the link you want to generate.";
exit;
} else {
if(!(strpos($link,"megaupload.com")) OR strpos($link,"megaupload.com") !=strrpos($link,"megaupload.com")) {
echo "The link is not inserted a link megaupload.com.";
exit;
} else {
}
}

//get link
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $link );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_USERAGENT, "Googlebot/2.1");
curl_setopt( $ch, CURLOPT_POSTFIELDS, "login=1&redir=1&username=$mu_login&password=$mu_pass");
    
$out = curl_exec($ch);
    
$dom = new DOMDocument;
if($dom->loadHTML( $out ) == false) {
    echo "There was an error getting the link.";
} else {
    $xpath = new DOMXPath( $dom );
    echo $xpath->query( "//div[@id='downloadlink']//a" )->item(0)->getAttribute( 'href' );
}
?> 

Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#11
yamaguchi

yamaguchi

    Newbie

  • Members
  • PipPip
  • 12 posts
Man, thanks for the help, but still not working ...
Take a look at the error below.

Fatal error: Call to a member function getAttribute() on a non-object in /home/test/public_html/megaupload.php on line 34
echo $xpath->query( "//div[@id='downloadlink']//a" )->item(0)->getAttribute( 'href' );

Apparently it's almost the same as the previous script. The error when the link is invalid.

#12
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
Maybe you can't access it like that. $xpath->query( "//div[@id='downloadlink']//a" )->item(0) may return an array and ->getAttribute can't run on a non-object. Try seeing what this returns instead:
print_r($xpath->query( "//div[@id='downloadlink']//a" )->item(0));

Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.