Viewing file: linkbucks.php (5.62 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
error_reporting(E_ALL);
echo " ejecutar solo desde consola";
include "/home/wwwroot/frames/conn.php";
/*$sql="select count(0) AS `contador`,`estadistica`.`id_book` AS `id_book`,`libros`.`titulo` AS `titulo`,`libros`.`autor` AS `autor`,`libros`.`id` AS `id`,`libros`.`inftp` AS `inftp`,
`libros`.`ruta`,
`libros`.`ruta_epub`,
`libros`.`ruta_mobi`,
`libros`.`ruta_linkbucks`,
`libros`.`ruta_linkbucks_epub`,
`libros`.`ruta_linkbucks_mobi`
from (`estadistica` join `libros`)
where ((`estadistica`.`id_book` = `libros`.`id`)
and
(`estadistica`.`id_book` > 9)
and
(`libros`.`inftp` = 1))
group by `estadistica`.`id_book` order by count(0) desc limit 300;";
*/
$sql="select * from libros where `id` > 9
and
`libros`.`inftp` = 1
and
(`libros`.`ruta_linkbucks` is null or char_length(`libros`.`ruta_linkbucks`)<11 or
`libros`.`ruta_linkbucks_epub` is null or char_length(`libros`.`ruta_linkbucks_epub`)<11 or
`libros`.`ruta_linkbucks_mobi` is null or char_length(`libros`.`ruta_linkbucks_mobi`)<11
)
order by id desc
";
$res=mysql_query($sql,$conn);
echo mysql_error();
while ($row=mysql_fetch_array($res)){
echo $row['id'].chr(10);
//usleep(100000);
if ((!$row['ruta_linkbucks'] or strlen(trim($row['ruta_linkbucks']))<11) and strlen($row['ruta'])>10){
echo "linkbucks del fb2".chr(10);
$linkGenerator = new LinkbucksGenerator('papyrefb2', 'ilvm1rg1');
$result = $linkGenerator->generateLink($row['ruta']);
$json=json_decode($result) ;
foreach ($json->value as $item) {
};
flush();
echo chr(10)."enlace fb2 del libro {$row['id']} : $item".chr(10); // este es el inclito enlace
echo $sql2="update papyr225_papyre.libros set ruta_linkbucks='$item' where id={$row['id']}";
mysql_query($sql2,$conn);
echo mysql_error();
}
if ((!$row['ruta_linkbucks_epub'] or strlen(trim($row['ruta_linkbucks_epub']))<11) and strlen($row['ruta_epub'])>10){
echo "linkbucks del epub".chr(10);
$linkGenerator = new LinkbucksGenerator('papyrefb2', 'ilvm1rg1');
$result = $linkGenerator->generateLink($row['ruta_epub']);
$json=json_decode($result) ;
foreach ($json->value as $item) {
};
flush();
echo chr(10)."enlace epub del libro {$row['id']} : $item".chr(10); // este es el inclito enlace
echo $sql2="update papyr225_papyre.libros set ruta_linkbucks_epub='$item' where id={$row['id']}";
mysql_query($sql2,$conn);
echo mysql_error();
}
if ((!$row['ruta_linkbucks_mobi'] or strlen(trim($row['ruta_linkbucks_mobi']))<11) and strlen($row['ruta_mobi'])>10){
echo "linkbucks del mobi".chr(10);
$linkGenerator = new LinkbucksGenerator('papyrefb2', 'ilvm1rg1');
$result = $linkGenerator->generateLink($row['ruta_mobi']);
$json=json_decode($result) ;
foreach ($json->value as $item) {
};
flush();
echo chr(10)."enlace mobi del libro {$row['id']} : $item".chr(10); // este es el inclito enlace
echo $sql2="update papyr225_papyre.libros set ruta_linkbucks_mobi='$item' where id={$row['id']}";
mysql_query($sql2,$conn);
echo mysql_error();
}
}
class LinkbucksGenerator
{
public $username;
public $password;
public function __construct($username, $password)
{
$this->username=$username;
$this->password=$password;
$res = $this->sendRequest('http://www.linkbucks.com',
'__VIEWSTATE=%2FwEPDwUKMTgyODE4OTcxNA9kFgJmD2QWAgIBDxYCHgZhY3Rpb24FAS8WAgIDDxYCHgdWaXNpYmxlZ2QYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFI2N0bDAwJExlZnRNZW51QmFyJGN0bDAwJExvZ2luSW1nQnRuS8hakOPTjCRlsWTaAs%2Bzra8AOq62iJvb2b1%2BaYjQ3bA%3D&__EVENTVALIDATION=%2FwEWBAL%2Bzvj%2BBQK7qsuzDQL4%2Fd%2FXBwKsntP%2FCzjrmm0uzhVnRRESgrufVC4zwhIpeKxQ1DE28b0Xa30%2B&ctl00%24LeftMenuBar%24ctl00%24Username=' . $username . '&ctl00%24LeftMenuBar%24ctl00%24Password=' . $password . '&ctl00%24LeftMenuBar%24ctl00%24LoginImgBtn.x=73&ctl00%24LeftMenuBar%24ctl00%24LoginImgBtn.y=17');
return($this);
}
public function generateLink($url, $adTypeID = 2)
{
$posting='{"user" : "'.$this->username.'",
"apiPassword" : "'.$this->password.'",
"originalLink" : "'.$url.'",
"adType" : '.$adTypeID.',
"contentType" : 1,
"domain" : "linkbucks.com"';
$posting='{"OrigLink":"'.$url.'","AdTypeID":"2","ContentTypeID":"1","LinkTypeID":1,"LinkGroupID":0,"exclusionsList":"","TargetOptionID":0,"LinkAliasID":"1","FrequencyCap":0}';
$res = $this->sendRequest('http://www.linkbucks.com/ajaxpro/LinkGenLib,Linkbucks.ashx',$posting,1);
return($res);
}
private function sendRequest($url, $post, $type = 0)
{
$ch = curl_init();
if($type == 1)
{
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-AjaxPro-Method: SingleLinkParse',
'Content-Type: application/json',
'Content-Length: ' . strlen($post)
));
}
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookieslinkb');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookieslinkb');
curl_setopt($ch,CURLOPT_URL, $url);
//curl_setopt($ch,CURLOPT_POST, count($post));
curl_setopt($ch,CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
}
?>
|