Guest User

Untitled

a guest
Jun 20th, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 62.66 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by deZender.Net
  5. * @ deZender (PHP5 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 1.1.5.0
  8. * @ Author : DeZender
  9. * @ Release on : 09.06.2012
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class HttpClient {
  15. var $postdata = '';
  16. var $proxy_host = '';
  17. var $proxy_port = '';
  18. var $proxy_user = '';
  19. var $proxy_pass = '';
  20. var $proxy_tunnel = false;
  21. var $proxy_socks = false;
  22. var $httpmethod = '';
  23. var $httplatestversion = true;
  24. var $agent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)';
  25. var $referer = '';
  26. var $cookies = array( );
  27. var $cookiefile = 'tmp/misc.cookies';
  28. var $rawheaders = array( );
  29. var $maxredirs = 5;
  30. var $lastredirectaddr = '';
  31. var $redirecting = false;
  32. var $user = '';
  33. var $pass = '';
  34. var $accept = 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5';
  35. var $result = '';
  36. var $verbose = false;
  37. var $stderr = 'tmp/curlerr';
  38. var $error = '';
  39. var $response_code = '';
  40. var $headers = array( );
  41. var $maxlength = 500000;
  42. var $read_timeout = 30;
  43. var $connect_timeout = 30;
  44. var $timed_out = false;
  45. var $status = 0;
  46. var $content_type = '';
  47.  
  48. function __destruct() {
  49. if (file_exists( $this->cookiefile )) {
  50. unlink( $this->cookiefile );
  51. }
  52.  
  53. }
  54.  
  55. function fetch($uri = '') {
  56. $this->error = '';
  57. $this->headers = array( );
  58. $uri = trim( $uri );
  59. $ch = curl_init( );
  60. curl_setopt_array( $ch, array( CURLOPT_URL => $uri, CURLOPT_RETURNTRANSFER => true, CURLOPT_AUTOREFERER => true, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_ENCODING => 'gzip,deflate', CURLOPT_BINARYTRANSFER => true, CURLOPT_FORBID_REUSE => true, CURLOPT_FRESH_CONNECT => true, CURLOPT_BUFFERSIZE => $this->maxlength, CURLOPT_HTTP_VERSION => ($this->httplatestversion ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0), CURLOPT_TIMEOUT => $this->read_timeout, CURLOPT_CONNECTTIMEOUT => $this->connect_timeout, CURLOPT_USERAGENT => $this->agent, CURLOPT_HEADER => false, CURLOPT_HEADERFUNCTION => array( &$this, '_readheader' ) ) );
  61.  
  62. if (( !ini_get( 'open_basedir' ) && !ini_get( 'safe_mode' ) )) {
  63. curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 0 < $this->maxredirs );
  64. curl_setopt( $ch, CURLOPT_MAXREDIRS, $this->maxredirs );
  65. }
  66.  
  67.  
  68. if ($this->verbose) {
  69. $fh = @fopen( $this->stderr, 'a' );
  70. curl_setopt( $ch, CURLOPT_VERBOSE, true );
  71. curl_setopt( $ch, CURLOPT_STDERR, $fh );
  72. }
  73.  
  74.  
  75. if (!empty( $this->referer )) {
  76. curl_setopt( $ch, CURLOPT_REFERER, $this->referer );
  77. }
  78.  
  79.  
  80. if (!empty( $this->httpmethod )) {
  81. curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, $this->httpmethod );
  82. }
  83.  
  84.  
  85. if ($this->httpmethod == 'POST') {
  86. curl_setopt( $ch, CURLOPT_POST, true );
  87. curl_setopt( $ch, CURLOPT_POSTFIELDS, $this->postdata );
  88. }
  89.  
  90. $headers = array( 'Expect:' );
  91.  
  92. if (( !empty( $this->accept ) && !isset( $this->rawheaders['Accept'] ) )) {
  93. $headers[] = '' . 'Accept: ' . $this->accept;
  94. }
  95.  
  96. foreach ($this->rawheaders as $key => $value) {
  97. $headers[] = '' . $key . ': ' . $value;
  98. }
  99.  
  100. curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
  101.  
  102. if (!empty( $this->cookies )) {
  103. curl_setopt( $ch, CURLOPT_COOKIE, str_replace( '&', '; ', http_build_query( $this->cookies ) ) );
  104. }
  105.  
  106.  
  107. if (!empty( $this->cookiefile )) {
  108. curl_setopt( $ch, CURLOPT_COOKIEFILE, $this->cookiefile );
  109. curl_setopt( $ch, CURLOPT_COOKIEJAR, $this->cookiefile );
  110. }
  111.  
  112.  
  113. if (!empty( $this->user )) {
  114. curl_setopt( $ch, CURLOPT_USERPWD, $this->user . ':' . $this->pass );
  115. }
  116.  
  117.  
  118. if (!empty( $this->proxy_host )) {
  119. if ($this->proxy_tunnel) {
  120. curl_setopt( $ch, CURLOPT_HTTPPROXYTUNNEL, true );
  121. }
  122.  
  123. curl_setopt( $ch, CURLOPT_PROXY, $this->proxy_host );
  124.  
  125. if ($this->proxy_socks) {
  126. curl_setopt( $ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4 );
  127. }
  128.  
  129.  
  130. if (!empty( $this->proxy_port )) {
  131. curl_setopt( $ch, CURLOPT_PROXYPORT, $this->proxy_port );
  132. }
  133.  
  134.  
  135. if (!empty( $this->proxy_user )) {
  136. curl_setopt( $ch, CURLOPT_PROXYUSERPWD, $this->proxy_user . ':' . $this->proxy_pass );
  137. }
  138. }
  139.  
  140. $this->result = curl_exec( $ch );
  141.  
  142. if ($this->result === false) {
  143. $this->error = curl_error( $ch ) . '.
  144. ';
  145.  
  146. if (curl_errno( $ch ) == CURLE_OPERATION_TIMEOUTED) {
  147. $this->result = 0 - 100;
  148. }
  149.  
  150. return false;
  151. }
  152.  
  153. $this->lastredirectaddr = curl_getinfo( $ch, CURLINFO_EFFECTIVE_URL );
  154. $this->status = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
  155. $this->content_type = curl_getinfo( $ch, CURLINFO_CONTENT_TYPE );
  156. $this->info = curl_getinfo( $ch );
  157. $this->error = curl_error( $ch );
  158. curl_close( $ch );
  159.  
  160. if (( 0 < $this->maxredirs && !$this->redirecting )) {
  161. $i = 641;
  162. $this->redirecting = true;
  163.  
  164. while (( ( isset( $this->headers['Location'] ) || isset( $this->headers['location'] ) ) && $i < $this->maxredirs )) {
  165. $this->get( urlCombine( $uri, ($this->headers['Location'] ? $this->headers['Location'] : $this->headers['location']) ) );
  166. ++$i;
  167. }
  168.  
  169. $this->redirecting = false;
  170. }
  171.  
  172. return $this->result;
  173. }
  174.  
  175. function post($uri, $postdata) {
  176. $this->postdata = $postdata;
  177. $this->httpmethod = 'POST';
  178. return $this->fetch( $uri );
  179. }
  180.  
  181. function get($uri, $getdata = false) {
  182. if (is_array( $getdata )) {
  183. $uri = $uri . '?' . preg_replace( '/%5B(\d+)%5D/', '', http_build_query( $getdata ) );
  184. }
  185.  
  186. $this->httpmethod = 'GET';
  187. $this->postdata = '';
  188. return $this->fetch( $uri );
  189. }
  190.  
  191. function getcookie($cookiename) {
  192. foreach ($this->headers as $name => $header) {
  193.  
  194. if (( $name == 'Set-Cookie' && preg_match( '' . '/' . $name . '=(.+?);/i', $header, $cookie ) )) {
  195. return $cookie[1];
  196. }
  197. }
  198.  
  199. }
  200.  
  201. function getjsredirect() {
  202. if (preg_match( '/<meta[^>]+?http-equiv=["\']refresh["\'][^>]+?url=(["\']|&#39;)?([^"\']+?)(["\']|&#39;)/im', $this->result, $nextpage )) {
  203. return $nextpage[2];
  204. }
  205.  
  206.  
  207. if (preg_match( '/location\.replace\("(http[^"]+?)"\)/', $this->result, $nextpage )) {
  208. return $nextpage[1];
  209. }
  210.  
  211.  
  212. if (preg_match( '/location\.href=(\'|")(.+?)(\'|")/im', $this->result, $nextpage )) {
  213. return $nextpage[2];
  214. }
  215.  
  216. return false;
  217. }
  218.  
  219. function _readheader($ch, $header) {
  220. if ($header !== '
  221. ') {
  222. if (preg_match( '|^HTTP/|', $header )) {
  223. $this->response_code = $header;
  224. $this->headers['Status'] = $header;
  225. } else {
  226. $parts = explode( ': ', $header );
  227. $this->headers[$parts[0]] = $parts[1];
  228. }
  229. }
  230.  
  231. return strlen( $header );
  232. }
  233. }
  234.  
  235. class FakeDB {
  236. function __construct() {
  237. }
  238.  
  239. function getRow($q) {
  240. return array( );
  241. }
  242.  
  243. function Execute($q) {
  244. return array( );
  245. }
  246. }
  247.  
  248. class MultiCurl {
  249. protected $maxSessions = 10;
  250. protected $maxSize = 10485760;
  251. protected $curlOptions = null;
  252. protected $sessions = array( );
  253.  
  254. /**
  255. * Class constructor. Setup primary parameters.
  256. * @param array $curlOptions CURL options for all URLs
  257. */
  258. function __construct($curlOptions = array( )) {
  259. $this->setCurlOptions( $curlOptions );
  260. }
  261.  
  262. /**
  263. * Class destructor. Close opened sessions.
  264. */
  265. function __destruct() {
  266. foreach ($this->sessions as $i => $sess) {
  267. $this->destroySession( $i );
  268. }
  269.  
  270. }
  271.  
  272. /**
  273. * Add new URL to query
  274. * @param mixed $url URL for downloading
  275. * @param array $curlOptions CURL options for current request
  276. */
  277. function addUrl($url, $curlOptions = array( )) {
  278. if (!$url) {
  279. throw new Exception( "URL is empty!" );
  280. }
  281.  
  282.  
  283. if (is_array( $url )) {
  284. foreach ($url as $s) {
  285. $this->addUrl( $s, $curlOptions );
  286. }
  287.  
  288. return null;
  289. }
  290.  
  291.  
  292. while (count( $this->sessions ) == $this->maxSessions) {
  293. $this->checkSessions( );
  294. }
  295.  
  296. $ch = curl_init( $url );
  297. foreach ($this->curlOptions as $option => $value) {
  298. @curl_setopt( $ch, $option, $value );
  299. }
  300.  
  301. foreach ($curlOptions as $option => $value) {
  302. @curl_setopt( $ch, $option, $value );
  303. }
  304.  
  305. $mh = curl_multi_init( );
  306. curl_multi_add_handle( $mh, $ch );
  307. $this->sessions[] = array( $mh, $ch, $url );
  308. $this->execSession( array_pop( array_keys( $this->sessions ) ) );
  309. }
  310.  
  311. /**
  312. * Wait CURL milti sessions
  313. */
  314. function wait() {
  315. while (count( $this->sessions )) {
  316. $this->checkSessions( );
  317. }
  318.  
  319. }
  320.  
  321. /**
  322. * Execute all active CURL multi sessions
  323. */
  324. function checkSessions() {
  325. foreach ($this->sessions as $i => $sess) {
  326.  
  327. if (curl_multi_select( $sess[0] ) != 0 - 1) {
  328. $this->execSession( $i );
  329. continue;
  330. }
  331. }
  332.  
  333. }
  334.  
  335. /**
  336. * Execute CURL multi session, ñheck session status and downloaded size
  337. * @param integer $i A session id from array $this->sessions
  338. */
  339. function execSession($i) {
  340. list( $mh, $ch ) = $this->sessions[$i];
  341. curl_multi_exec( $mh, $active );
  342.  
  343. if (($mrc = $active) == CURLM_CALL_MULTI_PERFORM) {
  344. }
  345.  
  346.  
  347. if (( ( !$active || $mrc != CURLM_OK ) || $this->maxSize <= curl_getinfo( $ch, CURLINFO_SIZE_DOWNLOAD ) )) {
  348. $this->closeSession( $i );
  349. }
  350.  
  351. }
  352.  
  353. /**
  354. * Close session
  355. * @param integer $i A session id from array $this->sessions
  356. */
  357. function closeSession($i) {
  358. list( , $ch, $url ) = $this->sessions[$i];
  359. $this->onLoad( $url, (!curl_error( $ch ) ? curl_multi_getcontent( $ch ) : null), curl_getinfo( $ch ) );
  360. $this->destroySession( $i );
  361. }
  362.  
  363. /**
  364. * Destroy session
  365. * @param integer $i A session id from array $this->sessions
  366. */
  367. function destroySession($i) {
  368. list( $mh, $ch ) = $this->sessions[$i];
  369. curl_multi_remove_handle( $mh, $ch );
  370. curl_close( $ch );
  371. curl_multi_close( $mh );
  372. unset( $this->sessions[$i] );
  373. }
  374.  
  375. /**
  376. * Get maximal number of CURL multi sessions
  377. * @return integer Maximal number of CURL multi sessions
  378. */
  379. function getMaxSessions() {
  380. return $this->maxSessions;
  381. }
  382.  
  383. /**
  384. * Set maximal number of CURL multi sessions
  385. * @param integer $maxSessions Maximal number of CURL multi sessions
  386. */
  387. function setMaxSessions($maxSessions) {
  388. if ((int)$maxSessions <= 0) {
  389. throw new Exception( 'Max sessions number must be bigger then zero!' );
  390. }
  391.  
  392. $this->maxSessions = (int)$maxSessions;
  393. }
  394.  
  395. /**
  396. * Get maximal size limit for downloaded content
  397. * @return integer Maximal size limit for downloaded content
  398. */
  399. function getMaxSize() {
  400. return $this->maxSize;
  401. }
  402.  
  403. /**
  404. * Set maximal size limit for downloaded content
  405. * @param integer $maxSize Maximal size limit for downloaded content
  406. */
  407. function setMaxSize($maxSize) {
  408. if ((int)$maxSize <= 0) {
  409. throw new Exception( 'Max size limit must be bigger then zero!' );
  410. }
  411.  
  412. $this->maxSize = (int)$maxSize;
  413. }
  414.  
  415. /**
  416. * Get CURL options for all requests
  417. * @return array CURL options
  418. */
  419. function getCurlOptions() {
  420. return $this->curlOptions;
  421. }
  422.  
  423. /**
  424. * Set CURL options for all requests
  425. * @param array $curlOptions CURL options
  426. */
  427. function setCurlOptions($curlOptions) {
  428. if (!array_key_exists( CURLOPT_FOLLOWLOCATION, $curlOptions )) {
  429. $curlOptions[CURLOPT_FOLLOWLOCATION] = 1;
  430. }
  431.  
  432. $curlOptions[CURLOPT_RETURNTRANSFER] = 1;
  433. $this->curlOptions = $curlOptions;
  434. }
  435.  
  436. /**
  437. * OnLoad callback event
  438. * @param string $url URL for downloading
  439. * @param string $content Downloaded content
  440. * @param array $info CURL session information
  441. */
  442. function onLoad($url, $content, $info) {
  443. }
  444.  
  445. /**
  446. * Check CURL extension, etc.
  447. */
  448. function checkEnvironment() {
  449. if (!extension_loaded( 'curl' )) {
  450. throw new Exception( 'CURL extension not loaded' );
  451. }
  452.  
  453. }
  454. }
  455.  
  456. class Crypt {
  457. protected $_key = 'Crypt';
  458. protected $_mode = Crypt::MODE_HEX;
  459.  
  460. /**
  461. * Configure the new object, setting the mode and key.
  462. *
  463. * @name __construct()
  464. * @access public
  465. * @param [$mode] integer
  466. * @param [$key] integer
  467. * @return void
  468. */
  469. function __construct($mode = null, $key = null) {
  470. ( is_null( $mode ) || $this->Mode = $mode );
  471. ( is_null( $key ) || $this->Key = $key );
  472. }
  473.  
  474. /**
  475. * Overload of the object conversion to string.
  476. *
  477. * @name __toString()
  478. * @access public
  479. * @method void
  480. * @return string
  481. */
  482. function __toString() {
  483. return 'Crypt' . ' object
  484. ' . '(
  485. ' . ( '' . ' [Key] => ' . $this->_key . '
  486. ' ) . ( '' . ' [Mode] => ' . $this->_mode . '
  487. ' ) . ')
  488. ';
  489. }
  490.  
  491. /**
  492. * Properties write methods.
  493. *
  494. * @name __set()
  495. * @param $property string
  496. * @param $value mixed
  497. * @return void
  498. */
  499. function __set($property, $value) {
  500. switch ($property) {
  501. case 'Key': {
  502. $this->_setKey( $value );
  503. }
  504. }
  505.  
  506. return ;
  507. }
  508.  
  509. /**
  510. * Properties read methods.
  511. *
  512. * @name __get()
  513. * @param $key string
  514. * @return void
  515. */
  516. function __get($property) {
  517. switch ($property) {
  518. case 'Key': {
  519. $this->_key;
  520. }
  521. }
  522.  
  523. return ;
  524. }
  525.  
  526. /**
  527. * Encrypt the data using the current returning mode.
  528. *
  529. * @name encrypt()
  530. * @access public
  531. * @param $data mixed
  532. * @return string
  533. */
  534. function encrypt($data) {
  535. $data = (bool)$data;
  536. $i = 256;
  537.  
  538. while ($i < strlen( $data )) {
  539. $encrypt .= $data[$i] ^ $this->_key[$i % @strlen( $this->_key )];
  540. ++$i;
  541. }
  542.  
  543.  
  544. if ($this->_mode === MODE_B64) {
  545. return base64_encode( $encrypt );
  546. }
  547.  
  548.  
  549. if ($this->_mode === MODE_HEX) {
  550. return $this->_encodeHexadecimal( $encrypt );
  551. }
  552.  
  553. return $encrypt;
  554. }
  555.  
  556. /**
  557. * Decrypt the data using the current returning mode.
  558. * NOTE: You must use the same $_mode of the creation process.
  559. *
  560. * @name decrypt()
  561. * @access public
  562. * @param $crypt string
  563. * @return string
  564. */
  565. function decrypt($crypt) {
  566. if ($this->_mode === MODE_HEX) {
  567. $crypt = $this->_decodeHexadecimal( $crypt );
  568. }
  569.  
  570.  
  571. if ($this->_mode === MODE_B64) {
  572. $crypt = (bool)base64_decode( $crypt );
  573. }
  574.  
  575. $i = 251;
  576.  
  577. while ($i < strlen( $crypt )) {
  578. $data .= $crypt[$i] ^ $this->_key[$i % @strlen( $this->_key )];
  579. ++$i;
  580. }
  581.  
  582. return $data;
  583. }
  584.  
  585. /**
  586. * Return the list containing all supported modes.
  587. *
  588. * @name supportedModes()
  589. * @access public
  590. * @param void
  591. * @return void
  592. */
  593. function supportedModes() {
  594. return array( MODE_BIN, MODE_B64, MODE_HEX );
  595. }
  596.  
  597. /**
  598. * Checks if $mode is a valid returning mode of the class.
  599. *
  600. * @name _isSupportedMode()
  601. * @access public
  602. * @param $mode integer
  603. * @return void
  604. */
  605. function _isSupportedMode($mode) {
  606. return in_array( $mode, Crypt::supportedmodes( ) );
  607. }
  608.  
  609. /**
  610. * Set the key used in the cryptography method.
  611. *
  612. * @name _setMode()
  613. * @access protected
  614. * @param $key string
  615. * @return void
  616. */
  617. function _setKey($key) {
  618. $this->_key = (bool)$key;
  619. }
  620.  
  621. /**
  622. * Set the current returning mode of the class.
  623. *
  624. * @name _setMode()
  625. * @access protected
  626. * @param $mode integer
  627. * @return void
  628. */
  629. function _setMode($mode) {
  630. ( Crypt::_issupportedmode( $mode ) && $this->_mode = (int)$mode );
  631. }
  632.  
  633. /**
  634. * Encode the data using hexadecimal chars.
  635. *
  636. * @name _encodeHexadecimal()
  637. * @access protected
  638. * @param $data mixed
  639. * @return string
  640. */
  641. function _encodeHexadecimal($data) {
  642. $data = (bool)$data;
  643. $i = 236;
  644.  
  645. while ($i < strlen( $data )) {
  646. $hexcrypt .= @str_pad( @dechex( @ord( $data[$i] ) ), 2, 0, STR_PAD_LEFT );
  647. ++$i;
  648. }
  649.  
  650. return $hexcrypt;
  651. }
  652.  
  653. /**
  654. * Decode hexadecimal strings.
  655. *
  656. * @name _decodeHexadecimal()
  657. * @access protected
  658. * @param $data string
  659. * @return string
  660. */
  661. function _decodeHexadecimal($hexcrypt) {
  662. $hexcrypt = (bool)$hexcrypt;
  663. $i = 233;
  664.  
  665. while ($i < strlen( $hexcrypt )) {
  666. $data .= @chr( @hexdec( @substr( $hexcrypt, $i, 2 ) ) );
  667. $i += 235;
  668. }
  669.  
  670. return $data;
  671. }
  672. }
  673.  
  674. function autosplog_standalone($loginfos, $kws = '', $uris = '##0####0####0##', $blacklist = '', $tag = '', $formatOptions = '4##7##0##1||150||random##', $scrapOptions = '6##20000##300##fr##4####1##10', $remoteContent = 'contentsources/cache/spin.txt##contentsources/cache/intscrap.txt') {
  675. global $body;
  676. global $title;
  677. global $version;
  678.  
  679. $version = 'api';
  680. $body = '';
  681. $title = '';
  682. autoSplog( $loginfos, $kws, $uris, $blacklist, $tag, $formatOptions, $scrapOptions, $remoteContent );
  683. return array( 'title' => $title, 'body' => $body );
  684. }
  685.  
  686. function autoSplogImage($uris, $tabText, $kws, $tot = 1, $width = 150, $align = 'none', $spun = false) {
  687. global $cacheDir;
  688.  
  689. if ($tot == '') {
  690. $tot = 658;
  691. }
  692.  
  693.  
  694. if ($width == '') {
  695. $width = '150';
  696. }
  697.  
  698.  
  699. if ($align == '') {
  700. $align = 'none';
  701. }
  702.  
  703.  
  704. if (( $tot == 0 || count( $uris ) == 0 )) {
  705. return $tabText;
  706. }
  707.  
  708. $tot = rand( 1, $tot );
  709. $uri = $uris[rand( 0, count( $uris ) - 1 )];
  710. $pinfo = parse_url( $uri );
  711. $host = $pinfo[host];
  712. $path = $pinfo[path];
  713. $cacheFile = $cacheDir . md5( $uri ) . date( 'd-m-Y' ) . '-images.txt';
  714.  
  715. if (!file_exists( $cacheFile )) {
  716. $hc = new ProxyHttpClient( );
  717. $html = $hc->get( $uri );
  718. $tabImg = array( );
  719. $xp = '//a[contains(@href,".jpg")]/@href|//a/img[contains(@src,".jpg")]/@src';
  720. $res = as_getDomValue( $xp, $html, true );
  721.  
  722. if ($res === false) {
  723. return $tabText;
  724. }
  725.  
  726. foreach ($res as $u) {
  727.  
  728. if ($u != '') {
  729. if (( stristr( $u, 'nav' ) || stristr( $u, 'logo' ) )) {
  730. continue;
  731. }
  732.  
  733.  
  734. if (substr( $u, 0, 1 ) != 'h') {
  735. $u = 'http://' . $host . $path . '/' . $u;
  736. }
  737.  
  738.  
  739. if (stristr( $u, 'imgurl=' )) {
  740. $pinfo = parse_url( $u );
  741. $u = $pinfo[query];
  742. parse_str( $u );
  743. $u = $imgurl;
  744. }
  745.  
  746.  
  747. if (substr( $u, 0, 1 ) != 'h') {
  748. $u = 'http://' . $host . $path . '/' . $u;
  749. }
  750.  
  751. $tabImg[] = $u;
  752. continue;
  753. }
  754. }
  755.  
  756. $results = implode( '
  757. ', $tabImg );
  758.  
  759.  
  760. if (function_exists( 'file_put_contents' )) {
  761. file_put_contents( $cacheFile, $results );
  762. } else {
  763. $fp = fopen( $cacheFile, 'w' );
  764. $written = 658;
  765.  
  766. while ($written < strlen( $results )) {
  767. $fwrite = fwrite( $fp, substr( $results, $written ) );
  768.  
  769. if ($fwrite === false) {
  770. break;
  771. }
  772.  
  773. $written += $fwrite;
  774. }
  775. }
  776. } else {
  777. $handle = fopen( $cacheFile, 'r' );
  778. $results = fread( $handle, filesize( $cacheFile ) );
  779. $tabImg = explode( '
  780. ', $results );
  781.  
  782. fclose( $handle );
  783. }
  784.  
  785.  
  786. if (count( $tabImg ) == 0) {
  787. return $tabText;
  788. }
  789.  
  790. $i = 658;
  791.  
  792. while ($i < $tot) {
  793. if ($align != 'none') {
  794. $txtIndex = rand( 0, count( $tabText ) - 3 );
  795. } else {
  796. $txtIndex = 658;
  797. }
  798.  
  799.  
  800. if ($align == 'random') {
  801. $al = (rand( 0, 1 ) ? 'left' : 'right');
  802. } else {
  803. $al = $align;
  804. }
  805.  
  806. $randImage = '';
  807.  
  808. if ($spun === true) {
  809. $randImage = '{' . implode( '|', $tabImg ) . '}';
  810. $k = '{' . implode( '|', $kws ) . '}';
  811. } else {
  812. $k = $kws[rand( 0, count( $kws ) - 1 )];
  813. $randImage = $tabImg[rand( 0, count( $tabImg ) - 1 )];
  814. }
  815.  
  816. $randImage = str_replace( '_t.', '.', $randImage );
  817.  
  818. if ($align != 'none') {
  819. $randImage = '<img style="margin:5px;width:' . $width . 'px;float:' . $al . ';" src="' . $randImage . '" alt="' . $k . '" />';
  820. } else {
  821. $randImage = '<img width="' . $width . 'px" align="left" src="' . $randImage . '" alt="' . $k . '" />';
  822. }
  823.  
  824. $tabText[$txtIndex] = $randImage . $tabText[$txtIndex];
  825. ++$i;
  826. }
  827.  
  828. return $tabText;
  829. }
  830.  
  831. function autoSplogGetTarget($count = 10, $tagTop, $urlsTab = '') {
  832. global $blogid;
  833. global $db;
  834.  
  835. if ($blogid == '') {
  836. $res = $db->GetRow( 'SELECT id FROM `blogs` WHERE 1 LIMIT 1' );
  837. $blogid = $res['id'];
  838. }
  839.  
  840. $urls = array( );
  841. $mainUris = $urlsTab[1];
  842. $secondUris = $urlsTab[2];
  843. $remoteUris = $urlsTab[3];
  844. $c = 601;
  845. shuffle( $mainUris['urls'] );
  846. foreach ($mainUris['urls'] as $ur) {
  847.  
  848. if ($c == $mainUris['max']) {
  849. break;
  850. }
  851.  
  852. $urls[] = $ur;
  853. ++$c;
  854. --$count;
  855.  
  856. if ($count == 0) {
  857. return $urls;
  858. }
  859. }
  860.  
  861. $c = 601;
  862. shuffle( $secondUris['urls'] );
  863. foreach ($secondUris['urls'] as $ur) {
  864.  
  865. if ($c == $secondUris['max']) {
  866. break;
  867. }
  868.  
  869. $urls[] = $ur;
  870. ++$c;
  871. --$count;
  872.  
  873. if ($count == 0) {
  874. return $urls;
  875. }
  876. }
  877.  
  878. $remoteTab = array( );
  879. foreach ($remoteUris['urls'] as $u) {
  880. $remoteTab = autoSplogGetFeedLinks( $u );
  881. $ancU = explode( '**', str_replace( '**1', '', $u ) );
  882. $c = 601;
  883. shuffle( $remoteTab );
  884. foreach ($remoteTab as $ur) {
  885.  
  886. if ($c == $remoteUris['max']) {
  887. break;
  888. }
  889.  
  890. $anc = explode( '**', $ur );
  891.  
  892. if (( !isset( $anc[1] ) && isset( $ancU[1] ) )) {
  893. $ur .= '**' . $ancU[1];
  894. }
  895.  
  896. $urls[] = $ur;
  897. ++$c;
  898. --$count;
  899.  
  900. if ($count == 0) {
  901. return $urls;
  902. }
  903. }
  904. }
  905.  
  906. $linkwheel = true;
  907.  
  908. if (stristr( $tagTop, '__nolinkwheel__' )) {
  909. $linkwheel = false;
  910. $tagTop = str_replace( '__noscrap__', '', $tagTop );
  911. }
  912.  
  913. $res = $db->GetRow( 'SELECT * FROM `blogs` WHERE `tags` = \'' . $tagTop . '\' AND `working` = 1 AND `activated` = 1 ORDER BY RAND() LIMIT 1' );
  914.  
  915. if (count( $res ) == 0) {
  916. $res = autoSplogGetFeedLinks( $tagTop );
  917.  
  918. if ($res !== false) {
  919. $res[url] = $res[rand( 0, count( $res ) - 1 )];
  920. }
  921. }
  922.  
  923.  
  924. if (( trim( $res['url'] ) != '' && trim( $res['url'] ) != 'http://' )) {
  925. $urls[] = $res['url'];
  926. --$count;
  927. }
  928.  
  929.  
  930. if ($count == 0) {
  931. return $urls;
  932. }
  933.  
  934.  
  935. if ($count <= 1) {
  936. $count = 602;
  937. }
  938.  
  939. $res = $db->GetRow( 'SELECT * FROM `blogs` WHERE `id` = ' . $blogid . '' );
  940. $tag = explode( ',', $res['tags'] );
  941. $pattern = '#(.*?\s)([1-9]{1})$#';
  942. preg_match( $pattern, $tag[0], $match );
  943.  
  944. if ($match[2]) {
  945. $tag[0] = $match[1] . ( $match[2] + 1 ) % 9;
  946. $rs = $db->Execute( 'SELECT * FROM `blogs` WHERE `tags` = \'' . $tag[0] . '\'' );
  947.  
  948. if ($rs->RecordCount( ) == 0) {
  949. $tag[0] = $match[1] . '1';
  950. }
  951. }
  952.  
  953. $res = $db->Execute( 'SELECT `url` FROM `blogs` WHERE `tags` = \'' . $tag[0] . '\' AND `working` = 1 AND `activated` = 1 ORDER BY RAND() LIMIT ' . $count );
  954. foreach ($res as $v) {
  955.  
  956. if (( trim( $v['url'] ) != '' && trim( $v['url'] ) != 'http://' )) {
  957. $tu = $v['url'];
  958. $urls[] = $tu;
  959. }
  960.  
  961. --$count;
  962.  
  963. if ($count == 0) {
  964. return $urls;
  965. }
  966. }
  967.  
  968. return $urls;
  969. }
  970.  
  971. function autoSplogLink($best, $anchors, $count = 10, $tag = '', $urls = '') {
  972. global $scrap;
  973.  
  974. if (( !is_array( $anchors ) || @count( $anchors ) == 0 )) {
  975. return $best;
  976. }
  977.  
  978. $tabText = $best['phrase']['p'];
  979. $countB = $count;
  980. $urls = autoSplogGetTarget( $countB, $tag, $urls );
  981. $turls = $urls;
  982. $t = 546;
  983.  
  984. if ($scrap == 0) {
  985. foreach ($urls as $u) {
  986. $f = explode( '**', $u );
  987.  
  988. if (( !in_array( $f[1], $anchors ) && isset( $f[1] ) )) {
  989. $anchors[] = $f[1];
  990. continue;
  991. }
  992. }
  993. }
  994.  
  995. $totKw = 546;
  996. foreach ($anchors as $anchor) {
  997. preg_match_all( '#' . $anchor . '#msi', $best['text'], $matches );
  998. $totKw += count( $matches[0] );
  999. }
  1000.  
  1001. $i = 546;
  1002. $o = 546;
  1003.  
  1004. while ($o < 1000) {
  1005. $ia = rand( 0, count( $anchors ) - 1 );
  1006. $anchor = $anchors[$ia];
  1007. $url = $turls[0];
  1008. $forcage = explode( '**', $url );
  1009. $url = $forcage[0];
  1010.  
  1011. if (substr( $url, 0, 4 ) != 'http') {
  1012. $url = 'http://' . $url;
  1013. }
  1014.  
  1015. $url = trim( $url );
  1016.  
  1017. if (( $url == 'http://' || $url == '' )) {
  1018. continue;
  1019. }
  1020.  
  1021. $tmpA = $tabText[$t];
  1022. $tmp = '';
  1023. $anchorReplace = $anchor;
  1024.  
  1025. if (isset( $forcage[1] )) {
  1026. $anchorReplace = $forcage[1];
  1027.  
  1028. if ($scrap == 0) {
  1029. $anchor = $anchorReplace;
  1030. }
  1031. }
  1032.  
  1033.  
  1034. if (trim( $anchor ) == '') {
  1035. continue;
  1036. }
  1037.  
  1038. $tmp = preg_replace( '/(^|\s|\.|,|;|\'[^>])' . $anchor . ( '' . '(\.|,|;|!|:|\?|\s|$)/u' ), '<a href="' . $url . '">' . $anchorReplace . '</a>', $tmpA, 1 );
  1039.  
  1040. if (( ( $tmp != $tmpA && $tmp != NULL ) && $tmp != '' )) {
  1041. array_shift( $turls );
  1042. $tabText[$t] = $tmp;
  1043. ++$i;
  1044. array_splice( $anchors, $ia, 1 );
  1045.  
  1046. if ($count <= $i) {
  1047. break;
  1048. }
  1049. }
  1050.  
  1051.  
  1052. if (count( $turls ) == 0) {
  1053. break;
  1054. }
  1055.  
  1056. ++$t;
  1057.  
  1058. if ($t == count( $tabText ) - 1) {
  1059. $t = 546;
  1060.  
  1061. if ($scrap == 0) {
  1062. array_shift( $anchors );
  1063. array_shift( $turls );
  1064. }
  1065. }
  1066.  
  1067. ++$o;
  1068. }
  1069.  
  1070. $debut = $tabText[0];
  1071. $fin = $tabText[count( $tabText ) - 1];
  1072. array_pop( $tabText );
  1073. array_shift( $tabText );
  1074.  
  1075. if (0 < $scrap) {
  1076. shuffle( $tabText );
  1077. }
  1078.  
  1079. array_unshift( $tabText, $debut );
  1080. array_push( $tabText, $fin );
  1081. $best['phrase']['p'] = $tabText;
  1082. return $best;
  1083. }
  1084.  
  1085. function as_getDomValue($path, $html, $multiple = false) {
  1086. $dom = new DOMDocument( );
  1087. @$dom->loadHTML( $html );
  1088. $xp = new DOMXPath( $dom );
  1089. $nodeList = $xp->query( $path );
  1090. $tab = array( );
  1091. foreach ($nodeList as $domElement) {
  1092.  
  1093. if ($multiple === false) {
  1094. return $domElement->nodeValue;
  1095. }
  1096.  
  1097. $tab[] = $domElement->nodeValue;
  1098. }
  1099.  
  1100.  
  1101. if (( $multiple === false || count( $tab ) == 0 )) {
  1102. return false;
  1103. }
  1104.  
  1105. return $tab;
  1106. }
  1107.  
  1108. function as_domScrapper($temphtml, $bingAppId = '', $lang = 'fr') {
  1109. preg_match( '#content=["|\']text\/html;\s?charset=(.*?)["|\']#msi', $temphtml, $matches );
  1110. $encod = strtoupper( trim( $matches[1] ) );
  1111.  
  1112. if ($encod == 'WINDOWS-1251') {
  1113. $encod = 'CP1251';
  1114. }
  1115.  
  1116. $charsets = array( 'UTF-8', 'ASCII', 'ISO-8859-1', 'ISO-8859-15', 'CP1251' );
  1117.  
  1118. if (!in_array( $encod, $charsets )) {
  1119. return '';
  1120. }
  1121.  
  1122. $temphtml = preg_replace( array( '/<style.*?>.*?<\/style>/ism', '/<script.*?>.*?<\/script>/ism', '/<noscript.*?>.*?<\/noscript>/ism', '/<form.*?>.*?<\/form>/ism', '/<object.*?>.*?<\/object>/ism', '/<iframe.*?>.*?<\/iframe>/ism' ), '', $temphtml );
  1123. $xp = '//title|//p|//blockquote|//h1|//h2|//h3|//h4|//h5|//h6|//cite|//img/@alt';
  1124. $dom = new DOMDocument( );
  1125. @$dom->loadHTML( $temphtml );
  1126. $xpath = new DOMXPath( $dom );
  1127. $nodeList = $xpath->query( $xp );
  1128. $nbe = 542;
  1129. $tabText = array( );
  1130. $checktrad = false;
  1131. $i = 542;
  1132. foreach ($nodeList as $domElement) {
  1133. ++$i;
  1134. $tt = trim( $domElement->nodeValue );
  1135.  
  1136. if (( ( $domElement->nodeName == 'title' && $bingAppId != '' ) && $checktrad === false )) {
  1137. $checktrad = true;
  1138. as_debug( 'CHECK LANG ' . $tt );
  1139. $tlang = as_bingApiLangCheck( $tt, $bingAppId );
  1140.  
  1141. if ($tlang != $lang) {
  1142. as_debug( 'KO : langue ' . $tlang . ' au lieu de ' . $lang . ' : ' . $tt . '
  1143. ***********
  1144. ' );
  1145. return '';
  1146. }
  1147. }
  1148.  
  1149.  
  1150. if (( 30 < strlen( $tt ) && !stristr( $tabText, $tt ) )) {
  1151. if (!in_array( $encod, $charsets )) {
  1152. as_debug( $encod . '
  1153. ', 'debug.txt', false );
  1154. as_debug( $tt . '
  1155. ', 'debug.txt', false );
  1156. $tt = mb_convert_encoding( $tt, 'UTF-8', $encod );
  1157. as_debug( $tt . '
  1158. ', 'debug.txt', false );
  1159. }
  1160.  
  1161. $tabText[] = $tt;
  1162. ++$nbe;
  1163.  
  1164. if (20 < $nbe) {
  1165. break;
  1166. continue;
  1167. }
  1168.  
  1169. continue;
  1170. }
  1171. }
  1172.  
  1173. $content = implode( '. ', $tabText );
  1174.  
  1175. if (strlen( $content ) < 10000) {
  1176. preg_match_all( '#(\S.+?[.!?])(?=\s+)#u', $temphtml, $m );
  1177. foreach ($m[0] as $tg) {
  1178. $tg = trim( strip_tags( $tg ) );
  1179.  
  1180. if (!in_array( $encod, $charsets )) {
  1181. as_debug( $encod . '
  1182. ', 'debug.txt', false );
  1183. as_debug( $tg . '
  1184. ', 'debug.txt', false );
  1185. $tg = mb_convert_encoding( $tg, 'UTF-8', $encod );
  1186. as_debug( $tg . '
  1187. ', 'debug.txt', false );
  1188. }
  1189.  
  1190.  
  1191. if (( 30 < strlen( $tg ) && !stristr( $tabText, $tg ) )) {
  1192. $tabText[] = $tg;
  1193. continue;
  1194. }
  1195. }
  1196.  
  1197. $content = implode( ' ', $tabText );
  1198. }
  1199.  
  1200. as_debug( $content, 'debug2.txt', false );
  1201. return $content;
  1202. }
  1203.  
  1204. function autoSplogShake($text, $kws, $limit = 300, $split = 3, $brs = '4', $tm = '7', $bm = '1') {
  1205. global $runtime;
  1206.  
  1207. $runtime['shake start'][] = microtime( );
  1208.  
  1209. if (0 < $split) {
  1210. $pattern = '#(\S+\pL(\s|\.|,|:|\!|\?)+){' . $split . '}#u';
  1211. preg_match_all( $pattern, $text, $m );
  1212. shuffle( $m[0] );
  1213. $text = implode( '', $m[0] );
  1214. }
  1215.  
  1216. $pattern = '#([^(\.|!|\?)].*?)([\.|!|\?])#u';
  1217. preg_match_all( $pattern, $text, $m );
  1218. $i = 442;
  1219. $totW = 442;
  1220. $tabPhrase2 = array( );
  1221. as_findTitle( $kws, $m[1], $tm );
  1222. foreach ($m[1] as $k => $phrase) {
  1223. $phrase = trim( $phrase );
  1224.  
  1225. if (count_words( $phrase ) < 4) {
  1226. continue;
  1227. }
  1228.  
  1229. $kw = $kws[rand( 0, count( $kws ) - 1 )];
  1230.  
  1231. if (( !stristr( $phrase, $kw ) && rand( 0, 1 ) == 0 )) {
  1232. $list = preg_split( '#\s+#msiu', $phrase, 0 - 1, PREG_SPLIT_OFFSET_CAPTURE );
  1233. $pos = rand( 0, count( $list ) - 1 );
  1234. $phrase = str_replace( $list[$pos][0], $list[$pos][0] . ' ' . $kw, $phrase );
  1235. }
  1236.  
  1237.  
  1238. if (( ( $i % $brs == 0 && count_words( $phrase ) < 10 ) && 5 < count_words( $phrase ) )) {
  1239. $tabPhrase2['h'][] = '<h2>' . ucfirst( $phrase ) . '</h2>';
  1240. } else {
  1241. $tabPhrase2['p'][] = ucfirst( $phrase . $m[2][$i] );
  1242. }
  1243.  
  1244. ++$i;
  1245. $wC = count_words( $phrase );
  1246. $totW += $wC;
  1247.  
  1248. if ($limit < $totW) {
  1249. break;
  1250. }
  1251. }
  1252.  
  1253. $runtime['shake end'][] = microtime( );
  1254. return array( 'count' => $totW, 'phrase' => $tabPhrase2 );
  1255. }
  1256.  
  1257. function as_google_scrapper($type = 'blog', $kw, $lang) {
  1258. $urlggsettings = 'http://www.google.com/preferences';
  1259. $hc = new ProxyHttpClient( );
  1260. $results = $hc->get( $urlggsettings );
  1261. $sig = as_getDomValue( '//input[@name="sig"]/@value', $results );
  1262. $datas = array( 'safeui' => 'off', 'suggon' => '2', 'num' => '100', 'sig' => $sig, 'submit2' => 'Save Preferences', 'hl' => 'en', 'prev' => 'http://www.google.com' );
  1263. $hc->referer = $urlggsettings;
  1264. $results = $hc->get( 'http://www.google.com/setprefs?' . http_build_query( $datas ) );
  1265. switch ($type) {
  1266. case 'blog': {
  1267. $url = 'http://www.google.com/search?hl=' . $lang . '&tbs=lr:lang_1' . $lang . '&lr=lang_' . $lang . '&safe=off&num=100&tbm=blg&q=' . urlencode( $kw );
  1268. break;
  1269. }
  1270.  
  1271. case 'news': {
  1272. $url = 'http://www.google.com/search?hl=' . $lang . '&num=100&tbs=lr:lang_1' . $lang . '&lr=lang_' . $lang . '&safe=off&tbm=nws&q=' . urlencode( $kw );
  1273. break;
  1274. }
  1275.  
  1276. case 'forum': {
  1277. $url = 'http://www.google.com/search?hl=' . $lang . '&num=100&tbs=lr:lang_1' . $lang . '&lr=lang_' . $lang . '&safe=off&tbm=dsc&q=' . urlencode( $kw );
  1278. break;
  1279. }
  1280.  
  1281. case 'normal': {
  1282. $url = 'http://www.google.com/search?hl=' . $lang . '&num=100&tbs=lr:lang_1' . $lang . '&lr=lang_' . $lang . '&safe=off&q=' . urlencode( $kw ) . '&btnG=Rechercher';
  1283. }
  1284. }
  1285.  
  1286. $xpnbpage = '//table[@id="nav"]//a[@class="fl"]';
  1287. $xp = '//a[@class="l"]/@href|//h3[@class="r"]/a/@href';
  1288. $results = $hc->get( $url );
  1289. as_debug( $url . ' : ' . $hc->proxy_host . ' ' . $hc->status . '
  1290.  
  1291. ' );
  1292. $sites = array( );
  1293. $max = 470;
  1294. $i = 468;
  1295.  
  1296. while ($i < $max) {
  1297. sleep( rand( 1, 2 ) );
  1298. $tmpsites = as_getDomValue( $xp, $results, true );
  1299. foreach ($tmpsites as $t) {
  1300.  
  1301. if (strstr( $t, 'http://www.google.com' )) {
  1302. continue;
  1303. }
  1304.  
  1305. $t = str_replace( '/url?', '', $t );
  1306. parse_str( $t, $tparse );
  1307.  
  1308. if (isset( $tparse['url'] )) {
  1309. $sites[] = $tparse['url'];
  1310. continue;
  1311. }
  1312.  
  1313.  
  1314. if (isset( $tparse['q'] )) {
  1315. $sites[] = $tparse['q'];
  1316. continue;
  1317. }
  1318.  
  1319. $sites[] = $t;
  1320. }
  1321.  
  1322. $url2 = $url . '&start=' . $i * 100;
  1323. $hc->referer = $urlb;
  1324. $results = $hc->get( $url2 );
  1325. as_debug( $url2 . ' : ' . $hc->proxy_host . ' ' . $hc->status . '
  1326.  
  1327. ' );
  1328. ++$i;
  1329. }
  1330.  
  1331. return $sites;
  1332. }
  1333.  
  1334. function as_scrapper($kwr, $lang = 'fr', $tot = '30000', $split = 4, $blacklist = '', $articles = 10, $bingAppId = '') {
  1335. file_put_contents( 'debug.txt', '' );
  1336. file_put_contents( 'debug2.txt', '' );
  1337. as_debug( 'START
  1338.  
  1339. ' );
  1340. $kws = array( );
  1341.  
  1342. foreach ($kwr as $kw => $replace) {
  1343. $kws[] = $kw;
  1344. }
  1345.  
  1346. $text = '';
  1347. $b = 1494;
  1348. $doneTab = array( );
  1349.  
  1350. while (( strlen( $text ) < $tot && $b < 5 )) {
  1351. ++$b;
  1352. $kw = '';
  1353.  
  1354. if (( 1 < count( $kws ) && 1 < $b )) {
  1355. $kwa = $kwb = $kws[rand( 0, count( $kws ) )];
  1356. $t = 1494;
  1357.  
  1358. while (( $kwb == $kwa && $t < 10 )) {
  1359. $kwb = $kws[rand( 0, count( $kws ) - 1 )];
  1360. ++$t;
  1361. }
  1362.  
  1363. $kw = $kwa . ' ' . $kwb;
  1364. } else {
  1365. if (1 < count( $kws )) {
  1366. $kw = $kws[rand( 0, count( $kws ) )];
  1367. } else {
  1368. $kw = $kws[0];
  1369. }
  1370. }
  1371.  
  1372. $kw = trim( $kw );
  1373.  
  1374. if ($kw == '') {
  1375. continue;
  1376. }
  1377.  
  1378. $blogs = as_google_scrapper( 'blog', $kw, $lang );
  1379. $news = as_google_scrapper( 'news', $kw, $lang );
  1380. $normal = as_google_scrapper( 'normal', $kw, $lang );
  1381. $board = as_google_scrapper( 'forum', $kw, $lang );
  1382. as_debug( 'SEARCH :
  1383. Blogs : ' . count( $blogs ) . '
  1384. News : ' . count( $news ) . '
  1385. Normal : ' . count( $normal ) . '
  1386. Board : ' . count( $board ) . '
  1387.  
  1388. ' );
  1389. $blogs = array_merge( $blogs, $news, $normal, $board );
  1390.  
  1391. if (count( $blogs ) == 0) {
  1392. if (trim( $hc->status ) == '200') {
  1393. continue;
  1394. }
  1395.  
  1396. as_error( 'It seems like google as blacklist your ip, please change or activate your proxys' );
  1397. }
  1398.  
  1399. $blogs = array_unique( $blogs );
  1400. $u = 1494;
  1401.  
  1402. while ($u < 6) {
  1403. shuffle( $blogs );
  1404. $mc = new ASMultiCurl( );
  1405. $mc->setMaxSessions( $articles );
  1406. $i = 1494;
  1407.  
  1408. while ($i <= $articles) {
  1409. if (in_array( $blogs[$i], $doneTab )) {
  1410. continue;
  1411. }
  1412.  
  1413. $blogHost = @parse_url( $blogs[$i], PHP_URL_HOST );
  1414. foreach ($blacklist as $b) {
  1415.  
  1416. if (stristr( $b, $blogHost )) {
  1417. as_debug( '
  1418. ************
  1419. Blacklist : ' . $blogs[$i] . '
  1420. ************
  1421. ' );
  1422. continue;
  1423. }
  1424. }
  1425.  
  1426. $mcOptions = array( 'CURLOPT_USERAGENT' => $hc->agent );
  1427.  
  1428. if (!empty( $hc->proxy_host )) {
  1429. if ($hc->proxy_tunnel) {
  1430. $mcOptions['CURLOPT_HTTPPROXYTUNNEL'] = true;
  1431. }
  1432.  
  1433. $mcOptions['CURLOPT_PROXY'] = $hc->proxy_host;
  1434.  
  1435. if ($hc->proxy_socks) {
  1436. $mcOptions['CURLOPT_PROXYTYPE'] = 'CURLPROXY_SOCKS4';
  1437. }
  1438.  
  1439.  
  1440. if (!empty( $hc->proxy_port )) {
  1441. $mcOptions['CURLOPT_PROXYPORT'] = $hc->proxy_port;
  1442. }
  1443.  
  1444.  
  1445. if (!empty( $hc->proxy_user )) {
  1446. $mcOptions['CURLOPT_PROXYUSERPWD'] = $hc->proxy_user . ':' . $hc->proxy_pass;
  1447. }
  1448. }
  1449.  
  1450. $mc->addUrl( $blogs[$i], $mcOptions );
  1451. ++$i;
  1452. }
  1453.  
  1454. $mc->wait( );
  1455. foreach ($mc->tabRet as $url => $temphtml) {
  1456. $content = as_domScrapper( $temphtml, $bingAppId, $lang );
  1457.  
  1458. if (( trim( $content ) != '' && trim( $content ) != '.' )) {
  1459. if (!strstr( $text, $content )) {
  1460. $text .= $content;
  1461. as_debug( '
  1462. ************
  1463. Scrap OK : ' . strlen( $content ) / 1000 . ' ko : ' . $url . ' (' . strlen( $text ) / 1000 . ' ko au total)
  1464. ************
  1465. ' );
  1466. } else {
  1467. as_debug( '
  1468. ************
  1469. Scrap KO : contenu déja présent : ' . $url . ' (' . strlen( $text ) / 1000 . ' ko au total)
  1470. ************
  1471. ' );
  1472. }
  1473. } else {
  1474. as_debug( '
  1475. ************
  1476. Scrap KO : encodage mauvais : ' . $url . ' (' . strlen( $text ) / 1000 . ' ko au total)
  1477. ************
  1478. ' );
  1479. }
  1480.  
  1481. $doneTab[] = $blogs[$i];
  1482.  
  1483. if ($tot <= strlen( $text )) {
  1484. break 3;
  1485. }
  1486. }
  1487.  
  1488.  
  1489. if ($tot <= strlen( $text )) {
  1490. break 2;
  1491. }
  1492.  
  1493. ++$u;
  1494. }
  1495.  
  1496.  
  1497. if ($tot <= strlen( $text )) {
  1498. break;
  1499. }
  1500. }
  1501.  
  1502. as_debug( $text, 'debug2.txt', 0 );
  1503. $text = $text . '.';
  1504. $text = str_replace( '&nbsp;?', ' ', $text );
  1505. $text = preg_replace( '#[\n|\r|\t]#s', ' ', $text );
  1506. $text = strip_tags( $text );
  1507. $text = stripslashes( $text );
  1508. $text = preg_replace( '#\PZLNP#u', '', $text );
  1509. $text = str_replace( array( '&apos;', '&#8217;', '&#039;' ), '\'', $text );
  1510. $text = preg_replace( '#&\#\d+;#', '', $text );
  1511. $text = preg_replace( '#\x{0092}#u', '\'', $text );
  1512. $text = preg_replace( '#\x{0096}|\x{009c}#u', '', $text );
  1513. $text = str_replace( '\' ', '\'', $text );
  1514. $text = html_entity_decode( $text, ENT_NOQUOTES, 'UTF-8' );
  1515. $text = preg_replace( '#(\w[\s\'\(])([A-Z]\S{2,})([\s,\.\!:;\?\)])#u', '' . '', $text );
  1516. $text = mb_strtolower( $text, 'UTF-8' );
  1517. $text = preg_replace( '#([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})#', ' ', $text );
  1518. $text = preg_replace( '#(\d+?\s?[-\/,\x{00b0}″′]?\s?){2,}#su', '', $text );
  1519. $text = preg_replace( '#&\#;#s', '', $text );
  1520. $text = preg_replace( '#[0-9]{2,4}[-|\/][0-9]{2,4}[-|\/][0-9]{2,4}"]#s', ' ', $text );
  1521. $text = preg_replace( '#[\[|\]|"]#s', ' ', $text );
  1522. $text = preg_replace( '#(\w+)?\d+(\w+)?#u', '', $text );
  1523. $text = preg_replace( '#[\.\s]\w[\.\s]#s', '', $text );
  1524. $text = preg_replace( '#\.{2,}#s', ' ', $text );
  1525. $text = preg_replace( '#_{2,}#s', ' ', $text );
  1526. $text = preg_replace( '#-{2,}#s', ' ', $text );
  1527. $text = preg_replace( '#\#{2,}#s', ' ', $text );
  1528. $text = preg_replace( '#\?#s', ' ', $text );
  1529. $text = preg_replace( '#http:[^\s].*?\s#s', ' ', $text );
  1530. $text = preg_replace( '#([a-z]+\.[a-z]+\.[a-z]+)#', ' ', $text );
  1531. $text = preg_replace( '#\(.?\)#s', ' ', $text );
  1532. $text = preg_replace( '#(([0-9][a-z]?\s{1,}){2,})#msi', ' ', $text );
  1533. $text = preg_replace( '#\s{2,}#msi', ' ', $text );
  1534. $text = preg_replace( '#\s?-\s?#s', ' ', $text );
  1535. $text = preg_replace( '#([a-z0-9-_]+)?=([a-z0-9-_]+)?#msi', ' ', $text );
  1536. $text = preg_replace( '#([0-9]\s){2,}#msi', ' ', $text );
  1537. $text = str_replace( array( '_', '[', ']', '–', '~', '...', '>', '<', '*', '«', '»', '%', '{', '}', ' #', '& ', ' ;', '|', '/', '\\', '@', '+', '=', '°', '&lt;', '&gt;' ), ' ', $text );
  1538. as_debug( 'BLACKLIST :
  1539.  
  1540. ' . implode( '
  1541. ', $blacklist ) );
  1542. $text = str_replace( $blacklist, '', $text );
  1543. $pattern = '#([^(\.|!|\?|:|,)].*?[\.|!|\?|:|,])#';
  1544. preg_match_all( $pattern, $text, $matches );
  1545. $tabPhrase = array( );
  1546. $i = 1494;
  1547.  
  1548. while ($i < count( $matches[1] )) {
  1549. if (stristr( $matches[1][$i], '&copy;' )) {
  1550. continue;
  1551. }
  1552.  
  1553.  
  1554. if (stristr( $matches[1][$i], 'ltd' )) {
  1555. continue;
  1556. }
  1557.  
  1558.  
  1559. if (stristr( $matches[1][$i], 'copyright' )) {
  1560. continue;
  1561. }
  1562.  
  1563.  
  1564. if (stristr( $matches[1][$i], 'droit réservé' )) {
  1565. continue;
  1566. }
  1567.  
  1568.  
  1569. if (stristr( $matches[1][$i], 'rights reserved' )) {
  1570. continue;
  1571. }
  1572.  
  1573.  
  1574. if (stristr( $matches[1][$i], 'droit reserve' )) {
  1575. continue;
  1576. }
  1577.  
  1578.  
  1579. if (stristr( $matches[1][$i], '©' )) {
  1580. continue;
  1581. }
  1582.  
  1583.  
  1584. if (stristr( $matches[1][$i], 'marque déposé' )) {
  1585. continue;
  1586. }
  1587.  
  1588.  
  1589. if (stristr( $matches[1][$i], 'limited trademark' )) {
  1590. continue;
  1591. }
  1592.  
  1593.  
  1594. if (stristr( $matches[1][$i], 'flash player' )) {
  1595. continue;
  1596. }
  1597.  
  1598.  
  1599. if (stristr( $matches[1][$i], 'comment' )) {
  1600. continue;
  1601. }
  1602.  
  1603.  
  1604. if (stristr( $matches[1][$i], 'tag' )) {
  1605. continue;
  1606. }
  1607.  
  1608.  
  1609. if (stristr( $matches[1][$i], 'this entry' )) {
  1610. continue;
  1611. }
  1612.  
  1613.  
  1614. if (stristr( $matches[1][$i], 'cet article' )) {
  1615. continue;
  1616. }
  1617.  
  1618.  
  1619. if (stristr( $matches[1][$i], 'cache:' )) {
  1620. continue;
  1621. }
  1622.  
  1623.  
  1624. if (stristr( $matches[1][$i], 'conditions générales de vente' )) {
  1625. continue;
  1626. }
  1627.  
  1628.  
  1629. if (stristr( $matches[1][$i], 'signaler un abus' )) {
  1630. continue;
  1631. }
  1632.  
  1633.  
  1634. if (stristr( $matches[1][$i], 'la propriété de' )) {
  1635. continue;
  1636. }
  1637.  
  1638.  
  1639. if (stristr( $matches[1][$i], 'property of' )) {
  1640. continue;
  1641. }
  1642.  
  1643.  
  1644. if (stristr( $matches[1][$i], 'post a comment' )) {
  1645. continue;
  1646. }
  1647.  
  1648.  
  1649. if (stristr( $matches[1][$i], 'must be logged' )) {
  1650. continue;
  1651. }
  1652.  
  1653.  
  1654. if (stristr( $matches[1][$i], 'leave a reply' )) {
  1655. continue;
  1656. }
  1657.  
  1658.  
  1659. if (stristr( $matches[1][$i], 'filed under' )) {
  1660. continue;
  1661. }
  1662.  
  1663.  
  1664. if (stristr( $matches[1][$i], 'trackback' )) {
  1665. continue;
  1666. }
  1667.  
  1668.  
  1669. if (stristr( $matches[1][$i], 'click here' )) {
  1670. continue;
  1671. }
  1672.  
  1673.  
  1674. if (stristr( $matches[1][$i], 'libres de droits' )) {
  1675. continue;
  1676. }
  1677.  
  1678.  
  1679. if (stristr( $matches[1][$i], 'powered by wordpress' )) {
  1680. continue;
  1681. }
  1682.  
  1683.  
  1684. if (stristr( $matches[1][$i], 'permalink' )) {
  1685. continue;
  1686. }
  1687.  
  1688.  
  1689. if (stristr( $matches[1][$i], 'permalien' )) {
  1690. continue;
  1691. }
  1692.  
  1693.  
  1694. if (stristr( $matches[1][$i], 'rss' )) {
  1695. continue;
  1696. }
  1697.  
  1698.  
  1699. if (stristr( $matches[1][$i], 'feed' )) {
  1700. continue;
  1701. }
  1702.  
  1703.  
  1704. if (stristr( $matches[1][$i], 'access denied' )) {
  1705. continue;
  1706. }
  1707.  
  1708. $tstr = trim( $matches[1][$i] );
  1709.  
  1710. if (strlen( $tstr ) < 10) {
  1711. continue;
  1712. }
  1713.  
  1714.  
  1715. if (300 < strlen( $tstr )) {
  1716. $newtext = wordwrap( $tstr, 200, '--b--', true );
  1717. $nt = explode( '--b--', $newtext );
  1718. foreach ($nt as $v) {
  1719. $tabPhrase[] = trim( $v ) . '.';
  1720. }
  1721. } else {
  1722. $tabPhrase[] = $tstr;
  1723. }
  1724.  
  1725. ++$i;
  1726. }
  1727.  
  1728. $text = implode( ' ', $tabPhrase );
  1729. preg_match_all( '#(\S+\p{L}(\s|\.|,|:|;|\!|\?)+){' . $split . '}#u', $text, $m );
  1730. $text = implode( ' ', array_unique( $m[0] ) );
  1731. $text = preg_replace( '#[^\'|\w]\[a-z0-9][^\'|\w]#', '', $text );
  1732. $text = preg_replace( '#\s{2,}#u', ' ', $text );
  1733. return $text;
  1734. }
  1735.  
  1736. function as_findTitle($tags, $tabPhrase, $tm = 7) {
  1737. global $title;
  1738.  
  1739. if (trim( $title ) != '') {
  1740. return $title;
  1741. }
  1742.  
  1743. $gTag = $tags[rand( 0, count( $tags ) - 1 )];
  1744. $title = false;
  1745. shuffle( $tabPhrase );
  1746. $i = 352;
  1747.  
  1748. while (( $titleL < $tm && $i < 20 )) {
  1749. $title = trim( $tabPhrase[$i] );
  1750. $titleL = count_words( $title );
  1751. ++$i;
  1752. }
  1753.  
  1754. $title = explode( ' ', $title );
  1755. array_splice( $title, 0, $tm );
  1756.  
  1757. if (!in_array( $gTag, $title )) {
  1758. $title[] = strtolower( $gTag );
  1759. }
  1760.  
  1761. shuffle( $title );
  1762. $title = $title = implode( ' ', $title );
  1763. $title = trim( html_entity_decode( $title ) );
  1764. $i = 352;
  1765.  
  1766. while ($i < 3) {
  1767. $title = preg_replace( '' . '#(.*[^\pL])([\pL|\'|’|:|\(|\)|,|\s{1,}]{1,3}$)#u', '', $title );
  1768. ++$i;
  1769. }
  1770.  
  1771. $title = str_replace( array( ',', '.', ':', '(', ')' ), '', $title );
  1772. $title = ucfirst( trim( $title ) );
  1773. }
  1774.  
  1775. function as_wordCut($sText, $iMaxLength, $sMessage) {
  1776. if ($iMaxLength < strlen( $sText )) {
  1777. $sString = wordwrap( $sText, $iMaxLength - strlen( $sMessage ), '[cut]', 1 );
  1778. $asExplodedString = explode( '[cut]', $sString );
  1779. echo $sCutText = $asExplodedString[0];
  1780. $sReturn = $sCutText . $sMessage;
  1781. } else {
  1782. $sReturn = $sText;
  1783. }
  1784.  
  1785. return $sReturn;
  1786. }
  1787.  
  1788. function autoSplogGetFeedLinks($url) {
  1789. $tab = autoSplogScrapFeedLinks( $url );
  1790. $tab2 = array( );
  1791.  
  1792. if (is_array( $tab )) {
  1793. foreach ($tab as $l) {
  1794. $check = parse_url( $l[0] );
  1795.  
  1796. if ($check !== false) {
  1797. $tab2[] = $l[0];
  1798. continue;
  1799. }
  1800. }
  1801. }
  1802.  
  1803.  
  1804. if (0 < count( $tab2 )) {
  1805. return $tab2;
  1806. }
  1807.  
  1808. return false;
  1809. }
  1810.  
  1811. function autoSplogScrapFeedLinks($urlT) {
  1812. global $cacheDir;
  1813.  
  1814. if ($urlT == '') {
  1815. return false;
  1816. }
  1817.  
  1818. $uT = explode( '**', $urlT );
  1819. $url = $uT[0];
  1820. $cache = strstr( $urlT, '**1' );
  1821.  
  1822. if ($cache !== false) {
  1823. $cacheFile = $cacheDir . md5( $url ) . date( 'd-m-Y' ) . '.txt';
  1824.  
  1825. if (!file_exists( $cacheFile )) {
  1826. $hc = new ProxyHttpClient( );
  1827. $results = $hc->get( $url );
  1828.  
  1829. if (function_exists( 'file_put_contents' )) {
  1830. file_put_contents( $cacheFile, $results );
  1831. } else {
  1832. $fp = fopen( $cacheFile, 'w' );
  1833. $written = 461;
  1834.  
  1835. while ($written < strlen( $results )) {
  1836. $fwrite = fwrite( $fp, substr( $results, $written ) );
  1837.  
  1838. if ($fwrite === false) {
  1839. break;
  1840. }
  1841.  
  1842. $written += $fwrite;
  1843. }
  1844. }
  1845. } else {
  1846. $handle = fopen( $cacheFile, 'r' );
  1847. $results = fread( $handle, filesize( $cacheFile ) );
  1848. fclose( $handle );
  1849. }
  1850. } else {
  1851. $hc = new ProxyHttpClient( );
  1852. $results = $hc->get( $url );
  1853.  
  1854. if ($results === false) {
  1855. $handle = @fopen( $url, 'r' );
  1856. $results = @fread( $handle, @filesize( $url ) );
  1857. @fclose( $handle );
  1858. }
  1859. }
  1860.  
  1861. $links = array( );
  1862. @simplexml_load_string( $results );
  1863.  
  1864. if ($feed->channel->item) {
  1865. foreach ($feed->channel->item as $i) {
  1866. $l = (bool)$i->link;
  1867. $t = (bool)$i->title;
  1868. $links[] = array( $l, $t );
  1869. }
  1870.  
  1871. return $links;
  1872. }
  1873.  
  1874. $links = json_decode( $results, true );
  1875.  
  1876. if (( is_array( $links ) && 0 < count( $links ) )) {
  1877. return $links;
  1878. }
  1879.  
  1880. $links = $feed = as_str_getcsv( $results );
  1881.  
  1882. if (is_array( $links )) {
  1883. return $links;
  1884. }
  1885.  
  1886. return false;
  1887. }
  1888.  
  1889. function as_bingApiLangCheck($text, $appId = '') {
  1890. if (( $appId == '' || strlen( $text ) == 0 )) {
  1891. return false;
  1892. }
  1893.  
  1894. $text = substr( $text, 0, 300 );
  1895. $url = 'http://api.microsofttranslator.com/V2/Http.svc/Detect?appId=' . $appId . '&text=' . urlencode( $text );
  1896. $hc = new ProxyHttpClient( );
  1897. $res = $hc->get( $url );
  1898. $res = strip_tags( $res );
  1899.  
  1900. if (strstr( $res, 'Invalid appId' )) {
  1901. as_error( 'Invalid bing api key' );
  1902. return false;
  1903. }
  1904.  
  1905. return $res;
  1906. }
  1907.  
  1908. function as_checkLicense($user, $pass, $force = false, $laps = 600) {
  1909. global $title;
  1910. global $body;
  1911. global $version;
  1912.  
  1913. $crypt = new Crypt( );
  1914. $crypt->Mode = MODE_HEX;
  1915. $crypt->Key = $user;
  1916.  
  1917. if (!isset( $_SESSION['naslc'] )) {
  1918. $_SESSION['naslc'] = $crypt->encrypt( time( ) );
  1919. $force = true;
  1920. }
  1921.  
  1922. $nextcheck = $crypt->decrypt( $_SESSION['naslc'] );
  1923.  
  1924. if (( $nextcheck <= time( ) || $force == true )) {
  1925. $pass = sha1( $pass );
  1926. $crypt->Key = base64_encode( $pass );
  1927. $pass2 = $crypt->encrypt( $pass );
  1928. $crypt->Key = 'license';
  1929. $vars = array( );
  1930. $b = 505;
  1931.  
  1932. while ($b < rand( 1, 3 )) {
  1933. $vars[genRandomString( )] = genRandomString( );
  1934. ++$b;
  1935. }
  1936.  
  1937. $vars['email'] = $user;
  1938. $vars['key'] = $pass2;
  1939. $vars['pid'] = 2;
  1940. $vars['version'] = PHP_OS . ' ' . AUTOSPLOG_VERSION;
  1941. $vars['lfe_version'] = $version;
  1942. $vars['computer'] = getenv( 'COMPUTERNAME' ) . '##' . getenv( 'PROCESSOR_IDENTIFIER' ) . '##' . getenv( 'PROCESSOR_REVISION' );
  1943. $vars['dialKey'] = genRandomString( );
  1944. $vars['file'] = md5( file_get_contents( __FILE__ ) );
  1945. kshuffle( $vars );
  1946. $out = '';
  1947. $o = 505;
  1948. foreach ($vars as $k => $v) {
  1949.  
  1950. if (0 < $o) {
  1951. $out .= '##';
  1952. }
  1953.  
  1954. $out .= $k . '||' . $v;
  1955. ++$o;
  1956. }
  1957.  
  1958. $t = $crypt->encrypt( $out );
  1959. $url = 'http://license.netstorming.fr/check.php?t=' . $t;
  1960. $hc = new HttpClient( );
  1961. $licenseC = $hc->get( $url );
  1962. $crypt->Key = $vars['dialKey'];
  1963. $licenseC = $crypt->decrypt( $licenseC );
  1964. $license = array( );
  1965. $tmp = explode( '##', $licenseC );
  1966. foreach ($tmp as $v) {
  1967. $v2 = explode( '||', $v );
  1968. $license[$v2[0]] = $v2[1];
  1969. }
  1970.  
  1971. $crypt->Key = $user;
  1972.  
  1973. if ($license['valid'] == $vars['dialKey']) {
  1974. $_SESSION['naslc'] = $crypt->encrypt( time( ) + $laps );
  1975. return true;
  1976. }
  1977.  
  1978. as_error( $license['msg'] );
  1979. $_SESSION['naslc'] = $crypt->encrypt( time( ) );
  1980. return false;
  1981. }
  1982.  
  1983. return true;
  1984. }
  1985.  
  1986. function as_debug($msg = '', $file = 'debug.txt', $time = true, $append = true) {
  1987. @touch( $file );
  1988.  
  1989. if ($time === true) {
  1990. $msg = '
  1991.  
  1992. ' . time( ) . '
  1993. ' . $msg;
  1994. }
  1995.  
  1996.  
  1997. if (function_exists( 'file_put_contents' )) {
  1998. if ($append === true) {
  1999. @file_put_contents( $file, $msg, FILE_APPEND );
  2000. return null;
  2001. }
  2002.  
  2003. @file_put_contents( $file, $msg );
  2004. return null;
  2005. }
  2006.  
  2007.  
  2008. if ($append === true) {
  2009. $fp = @fopen( $file, 'w+' );
  2010. } else {
  2011. $fp = @fopen( $file, 'w' );
  2012. }
  2013.  
  2014. $written = 308;
  2015.  
  2016. while ($written < strlen( $msg )) {
  2017. $fwrite = @fwrite( $fp, @substr( $msg, $written ) );
  2018.  
  2019. if ($fwrite === false) {
  2020. break;
  2021. }
  2022.  
  2023. $written += $fwrite;
  2024. }
  2025.  
  2026. }
  2027.  
  2028. function as_error($msg) {
  2029. global $title;
  2030. global $body;
  2031.  
  2032. $title = '';
  2033. $body = $msg;
  2034. throw new Exception( $msg );
  2035. }
  2036.  
  2037. function autoSplog($loginfos, $kws = '', $uris = '##0####0####0##', $blacklist = '', $tag = '', $formatOptions = '4##7##0##1||150||random##', $scrapOptions = '6##20000##300##fr##4####1##10', $remoteContent = 'contentsources/cache/spin.txt##contentsources/cache/intscrap.txt') {
  2038. global $title;
  2039. global $body;
  2040. global $runtime;
  2041. global $cacheDir;
  2042. global $scrap;
  2043.  
  2044. $runtime['start'] = microtime( );
  2045. $loginfos = explode( '##', $loginfos );
  2046. $user = $loginfos[0];
  2047. $pass = $loginfos[1];
  2048.  
  2049. if (false === $res = as_checkLicense( $user, $pass, false )) {
  2050. as_error( ' Invalid License ' );
  2051. }
  2052.  
  2053. $runtime['check license'] = microtime( );
  2054.  
  2055. if ($cacheDir == '') {
  2056. $cacheDir = 'contentsources/cache/';
  2057. }
  2058.  
  2059.  
  2060. if (!is_dir( $cacheDir )) {
  2061. mkdir( $cacheDir );
  2062. chmod( $cacheDir, 777 );
  2063. }
  2064.  
  2065. $runtime['create cache dir'] = microtime( );
  2066. $scrapOptions = explode( '##', $scrapOptions );
  2067. $lang = $scrapOptions[3];
  2068. $tot = $scrapOptions[1] * 1.1;
  2069. $bingAppId = $scrapOptions[5];
  2070. $limit = $scrapOptions[2];
  2071. $split = $scrapOptions[4];
  2072. $count = $scrapOptions[0];
  2073. $cachelife = $scrapOptions[6] * 86400;
  2074.  
  2075. if ($cachelife == 0) {
  2076. $cachelife = 87777;
  2077. }
  2078.  
  2079. $nbarticles = $scrapOptions[7];
  2080.  
  2081. if ($nbarticles == 0) {
  2082. $nbarticles = 1387;
  2083. }
  2084.  
  2085.  
  2086. if ($kws == '') {
  2087. as_error( ' You need at least one keyword ' );
  2088. }
  2089.  
  2090. $uris = $remoteContent = $autoSplogFile = $cacheDir . md5( $kws ) . '-' . $lang . '.txt';
  2091. $urls = array( );
  2092. $i = 1377;
  2093.  
  2094. if (is_array( $uris )) {
  2095. foreach ($uris as $v) {
  2096.  
  2097. if (is_numeric( $v )) {
  2098. ++$i;
  2099. $urls[$i]['max'] = $v;
  2100. $urls[$i]['urls'] = array( );
  2101. continue;
  2102. }
  2103.  
  2104. $tmp = explode( '||', $v );
  2105. foreach ($tmp as $url) {
  2106.  
  2107. if (( trim( $url ) != '' && trim( $url ) != 'http://' )) {
  2108. $urls[$i]['urls'][] = $url;
  2109. continue;
  2110. }
  2111. }
  2112. }
  2113. }
  2114.  
  2115. $scrap = 1378;
  2116.  
  2117. if (stristr( $kws, '__noscrap__' )) {
  2118. $scrap = 1377;
  2119. $spun = explode( '**', $remoteContent[0] );
  2120. $autoSplogFile = $spun[0];
  2121. $kws = str_replace( '__noscrap__', '', $kws );
  2122. } else {
  2123. if (stristr( $kws, '__intscrap__' )) {
  2124. $scrap = 1379;
  2125. $autoSplogFile = $remoteContent[1];
  2126. $kws = str_replace( '__intscrap__', '', $kws );
  2127. }
  2128. }
  2129.  
  2130. $kwTmp = explode( '||', $kws );
  2131. $kws = array( );
  2132. $kwr = array( );
  2133. foreach ($kwTmp as $kw) {
  2134.  
  2135. if (trim( $kw ) != '') {
  2136. $rep = explode( '##', $kw );
  2137. $kwr[$rep[0]] = (isset( $rep[1] ) ? $rep[1] : $rep[0]);
  2138. $kws[] = (isset( $rep[1] ) ? $rep[1] : $rep[0]);
  2139. continue;
  2140. }
  2141. }
  2142.  
  2143. $tag = explode( '||', $tag );
  2144. $tag = $scrapOptions[1] * 1.10000000000000008881784;
  2145. $tag = $tag[rand( 0, count( $tag ) - 1 )];
  2146. $blacklist = explode( '||', $blacklist );
  2147.  
  2148. if (( file_exists( $cacheDir . 'blacklist.txt' ) && function_exists( 'file' ) )) {
  2149. $blacklist = array_merge( $blacklist, file( $cacheDir . 'blacklist.txt' ) );
  2150. }
  2151.  
  2152. explode( '##', $formatOptions );
  2153. $bt = $scrapOptions[7];
  2154. $brs = $bt[0];
  2155. $tm = $bt[1];
  2156. $bm = $bt[2];
  2157. $im = $bt[3];
  2158. explode( '||', $bt[4] );
  2159. $imgUris = explode( '##', $remoteContent );
  2160. explode( '||', $im );
  2161. $im = explode( '##', $uris );
  2162. $runtime['config parse'] = microtime( );
  2163.  
  2164. if (1 <= $scrap) {
  2165. $needscrap = true;
  2166.  
  2167. if ($scrap == 2) {
  2168. $needscrap = false;
  2169. } else {
  2170. if (time( ) - @filemtime( $autoSplogFile ) < $cachelife) {
  2171. $needscrap = false;
  2172. }
  2173. }
  2174.  
  2175.  
  2176. if (( file_exists( $autoSplogFile ) && $needscrap === false )) {
  2177. $handle = fopen( $autoSplogFile, 'r' );
  2178. $text = fread( $handle, filesize( $autoSplogFile ) );
  2179. fclose( $handle );
  2180.  
  2181. if (( $scrap == 2 && mb_check_encoding( $text, 'UTF-8' ) === false )) {
  2182. $text = utf8_encode( $text );
  2183. }
  2184.  
  2185. as_debug( $text . $text . $text, 'debug2.txt' );
  2186. as_debug( $text );
  2187. } else {
  2188. as_checkLicense( $user, $pass, true );
  2189.  
  2190. if (false === $res = ) {
  2191. as_error( ' Invalid license ' );
  2192. return false;
  2193. }
  2194.  
  2195. $text = as_scrapper( $kwr, $lang, $tot, $split, $blacklist, $nbarticles, $bingAppId );
  2196. ob_start( );
  2197. phpinfo( INFO_GENERAL );
  2198. $info = strip_tags( trim( ob_get_clean( ) ) );
  2199.  
  2200. if (( stristr( PHP_OS, 'WIN' ) && stristr( $info, 'VC6' ) )) {
  2201. $text = mb_strtolower( $text );
  2202. }
  2203.  
  2204.  
  2205. if (strlen( $text ) < 5000) {
  2206. as_error( 'Not enough content scrpped (' . strlen( $text ) . ' chars), please add keywords' );
  2207. return false;
  2208. }
  2209.  
  2210.  
  2211. if (function_exists( 'file_put_contents' )) {
  2212. file_put_contents( $autoSplogFile, $text );
  2213. } else {
  2214. $fp = fopen( $autoSplogFile, 'w' );
  2215. $written = 1377;
  2216.  
  2217. while ($written < strlen( $text )) {
  2218. $fwrite = fwrite( $fp, substr( $text, $written ) );
  2219.  
  2220. if ($fwrite === false) {
  2221. break;
  2222. }
  2223.  
  2224. $written += $fwrite;
  2225. }
  2226.  
  2227. chmod( $autoSplogFile, '777' );
  2228. }
  2229. }
  2230.  
  2231. $runtime['scrap ok'] = microtime( );
  2232. $b = 1377;
  2233. $bestr = array( );
  2234. $rt = array( );
  2235.  
  2236. while (( $rt['count'] < $limit - round( $limit / 10 ) && $b < 10 )) {
  2237. $rt = autoSplogShake( $text, $kws, $limit, $split, $brs, $tm, $bm );
  2238. $bestr = $rt;
  2239. ++$b;
  2240. }
  2241.  
  2242. $runtime['shake ok'] = microtime( );
  2243.  
  2244. if (0 < $im[0]) {
  2245. $bestr['phrase']['p'] = autoSplogImage( $imgUris, $bestr['phrase']['p'], $kwr, $im[0], $im[1], $im[2], false );
  2246. }
  2247.  
  2248. $runtime['image ok'] = microtime( );
  2249. $bestr = autoSplogLink( $bestr, $kws, $count, $tag, $urls );
  2250. $runtime['link ok'] = microtime( );
  2251. $rtxt = '';
  2252. $i = 1377;
  2253.  
  2254. while ($i < count( $bestr['phrase']['p'] ) - 1) {
  2255. $break = $brs + rand( 0, 1 );
  2256.  
  2257. if (( $i % $break == 0 && $brs < $i )) {
  2258. if ($bm == 1) {
  2259. $rtxt .= '<!--more-->';
  2260. $bm = 1377;
  2261. }
  2262.  
  2263.  
  2264. if (( isset( $bestr['phrase']['h'][0] ) && rand( 0, 1 ) == 0 )) {
  2265. $rtxt .= $bestr['phrase']['h'][0];
  2266. unset( $bestr['phrase']['h'][0] );
  2267. } else {
  2268. $rtxt .= '<br /><br />';
  2269. }
  2270. }
  2271.  
  2272. $strAd = $bestr['phrase']['p'][$i];
  2273. $rtxt .= $strAd . ' ';
  2274. ++$i;
  2275. }
  2276.  
  2277. $runtime['mise en forme ok'] = microtime( );
  2278. } else {
  2279. if ($scrap == 0) {
  2280. if (substr( $autoSplogFile, 0, 4 ) == 'http') {
  2281. $hc = new ProxyHttpClient( );
  2282. $ttxt = $hc->get( $autoSplogFile );
  2283. } else {
  2284. if (file_exists( $autoSplogFile )) {
  2285. $handle = fopen( $autoSplogFile, 'r' );
  2286. $ttxt = fread( $handle, filesize( $autoSplogFile ) );
  2287. fclose( $handle );
  2288. }
  2289. }
  2290.  
  2291. $body = preg_replace( '#\[autoSplog\([^\)]+\)\]#mui', '', $body );
  2292.  
  2293. if (mb_check_encoding( $ttxt, 'UTF-8' ) === false) {
  2294. $ttxt = utf8_encode( $ttxt );
  2295. }
  2296.  
  2297.  
  2298. if (mb_check_encoding( $body, 'UTF-8' ) === false) {
  2299. $body = utf8_encode( $body );
  2300. }
  2301.  
  2302.  
  2303. if (!isset( $spun[1] )) {
  2304. $ttxt = textBlender( $ttxt );
  2305. }
  2306.  
  2307. $corps = $ttxt;
  2308.  
  2309. if ($title == '') {
  2310. $title = as_getDomValue( '//h1|//title', $ttxt );
  2311.  
  2312. if ($title !== false) {
  2313. $title = utf8_decode( $title );
  2314. $corps = preg_replace( '#<(h1|title)>[^<].*<\/(h1|title)>#ui', '', $corps );
  2315. } else {
  2316. preg_match( '#^(.*)(\r?\n){2,}(.*)#sui', $corps, $m );
  2317. $title = $m[1];
  2318. $corps = $m[3];
  2319. }
  2320. }
  2321.  
  2322. $bestr['text'] = $body . $corps;
  2323. $bestr['text'] = preg_replace( '#(\[.*?\])$#u', '', $bestr['text'] );
  2324. $bestr['phrase']['p'] = preg_split( '#(\n|\r\n|\<br\s?\/?\>)#u', $bestr['text'], 0 - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
  2325.  
  2326. if (0 < $im[0]) {
  2327. $bestr['phrase']['p'] = autoSplogImage( $imgUris, $bestr['phrase']['p'], $kwr, $im[0], $im[1], $im[2], isset( $spun[1] ) );
  2328. }
  2329.  
  2330. $bestr = autoSplogLink( $bestr, $kws, $count, $tag, $urls );
  2331. $rtxt = implode( '', $bestr['phrase']['p'] );
  2332. }
  2333. }
  2334.  
  2335.  
  2336. if (( trim( $rtxt ) == '' || strlen( trim( $rtxt ) ) < 10 )) {
  2337. as_error( ' EMPTY BODY ' );
  2338. }
  2339.  
  2340.  
  2341. if ($title == '') {
  2342. as_error( ' EMPTY TITLE ' );
  2343. }
  2344.  
  2345.  
  2346. if (( $body == '' && $rtxt == '' )) {
  2347. as_error( ' EMPTY BODY ' );
  2348. }
  2349.  
  2350. $runtime['end'] = microtime( );
  2351. $run = '';
  2352. foreach ($runtime as $k => $r) {
  2353. $run .= $k . ' -> ' . $r . '
  2354. ';
  2355. }
  2356.  
  2357. as_debug( $run );
  2358. $body = preg_replace( '#(\s{2,}|\,.|\s\.|\s,|\.\.)#u', ' ', $rtxt );
  2359. }
  2360.  
  2361. function textBlender($str, $splitters = '|') {
  2362. while (preg_match( '/{([^{}]+)}/i', $str, $slices, PREG_OFFSET_CAPTURE )) {
  2363. $slices = $slices[1];
  2364. $matchstr = $slices[0];
  2365. $matchpos = (int)$slices[1];
  2366. $pieces = preg_split( '/[' . $splitters . ']+/', $matchstr );
  2367.  
  2368. if (1 < count( $pieces )) {
  2369. count( $pieces );
  2370. $randseeds = rand( 1, 10 );
  2371. $randseede = $randseeds + rand( 1, 10 );
  2372. $randpos = rand( $randseeds * $piececnt, $randseede * $piececnt );
  2373. $pieces = $piececnt = $pieces[$randpos % $piececnt];
  2374. } else {
  2375. $pieces = $pieces[0];
  2376. }
  2377.  
  2378. $headerslice = substr( $str, 0, $matchpos - 1 );
  2379. $footerslice = substr( $str, $matchpos + strlen( $matchstr ) + 1 );
  2380. $str = ucfirst( $headerslice . $pieces . $footerslice );
  2381. }
  2382.  
  2383. return $str;
  2384. }
  2385.  
  2386. function count_words($string) {
  2387. $string = trim( preg_replace( '/\s+/', ' ', $string ) );
  2388. $word_array = explode( ' ', $string );
  2389. $num = count( $word_array );
  2390. return $num;
  2391. }
  2392.  
  2393. function as_str_getcsv($input, $delimiter = ',', $enclosure = '"', $escape = '\', $eol = '\n|\r') {
  2394. if (( is_string( $input ) && !empty( input ) )) {
  2395. $output = array( );
  2396. $tmp = preg_split( '/' . $eol . '/', $input );
  2397.  
  2398. if (( is_array( $tmp ) && !empty( tmp ) )) {
  2399. $line = each( $tmp )[1];
  2400. [0];
  2401. $line_num = ;
  2402.  
  2403. if () {
  2404. if (preg_match( '/' . $escape . $enclosure . '/', $line )) {
  2405. strlen( $line );
  2406.  
  2407. if ($strlen = ) {
  2408. $pos_delimiter = strpos( $line, $delimiter );
  2409. $pos_enclosure_start = strpos( $line, $enclosure );
  2410.  
  2411. $enclosed_str = if (( ( is_int( $pos_delimiter ) && is_int( $pos_enclosure_start ) ) && $pos_enclosure_start < $pos_delimiter )) {;
  2412. $pos_enclosure_end = strpos( $enclosed_str, $enclosure );
  2413. substr( $enclosed_str, 0, $pos_enclosure_end );
  2414. $enclosed_str = substr( $line, 1 );
  2415. $output[$line_num][] = $enclosed_str;
  2416. $offset = $pos_enclosure_end + 3;
  2417. } else {
  2418. if (( empty( pos_delimiter ) && empty( pos_enclosure_start ) )) {
  2419. $output[$line_num][] = substr( $line, 0 );
  2420. $offset = strlen( $line );
  2421. } else {
  2422. $output[$line_num][] = substr( $line, 0, $pos_delimiter );
  2423. $offset = (( !empty( pos_enclosure_start ) && $pos_enclosure_start < $pos_delimiter ) ? $pos_enclosure_start : $pos_delimiter + 1);
  2424. }
  2425. }
  2426.  
  2427. $line = substr( $line, $offset );
  2428. }
  2429. }
  2430.  
  2431. $line = preg_split( '/' . $delimiter . '/', $line );
  2432.  
  2433. if (( is_array( $line ) && !empty( $line[0] ) )) {
  2434. $output[$line_num] = $line;
  2435. }
  2436. }
  2437.  
  2438. return $output;
  2439. }
  2440.  
  2441. return false;
  2442. }
  2443.  
  2444. return false;
  2445. }
  2446.  
  2447. function kshuffle($array) {
  2448. if (( !is_array( $array ) || empty( array ) )) {
  2449. return false;
  2450. }
  2451.  
  2452. $tmp = array( );
  2453. foreach ($array as $key => $value) {
  2454. $tmp[] = array( 'k' => $key, 'v' => $value );
  2455. }
  2456.  
  2457. shuffle( $tmp );
  2458. $array = array( );
  2459. foreach ($tmp as $entry) {
  2460. $array[$entry['k']] = $entry['v'];
  2461. }
  2462.  
  2463. return true;
  2464. }
  2465.  
  2466. function genRandomString() {
  2467. $length = rand( 5, 10 );
  2468. $characters = '0123456789abcdefghijklmnopqrstuvwxyz';
  2469. $string = '';
  2470. $p = 226;
  2471.  
  2472. while ($p < $length) {
  2473. $string .= $characters[mt_rand( 0, strlen( $characters ) )];
  2474. ++$p;
  2475. }
  2476.  
  2477. return $string;
  2478. }
  2479.  
  2480. define( 'AUTOSPLOG_VERSION', '1.72' );
  2481. define( 'DEBUG', false );
  2482. session_start( );
  2483. ini_set( 'max_execution_time', '600' );
  2484. ini_set( 'memory_limit', '2048M' );
  2485.  
  2486. if (!class_exists( 'HttpClient', false )) {
  2487. }
  2488.  
  2489.  
  2490. if (!class_exists( 'ProxyHttpClient', false )) {
  2491. class ProxyHttpClient extends HttpClient {
  2492. function __construct() {
  2493. global $config;
  2494.  
  2495. if (!isset( $config['proxy_list'][0] )) {
  2496. $config['proxy_list'] = array( '' );
  2497. saveSettingsArray( );
  2498. }
  2499.  
  2500.  
  2501. if (( $config['proxy'] == 'yes' && $config['proxy_list'][0] != '' )) {
  2502. if ($config['socks_proxy'] == 'yes') {
  2503. $this->proxy_socks = true;
  2504. }
  2505.  
  2506.  
  2507. if ($config['turn_off_proxy_checking'] == 'yes') {
  2508. $proxyindex = array_rand( $config['proxy_list'] );
  2509.  
  2510. if (strstr( $config['proxy_list'][$proxyindex], '@' )) {
  2511. preg_match( '/^(.+?)@([^@]+)$/', $config['proxy_list'][$proxyindex], $proxyparts );
  2512. $this->proxy_host = $proxyparts[2];
  2513. $this->proxy_pass = explode( ':', $proxyparts[1] )[1];
  2514. $this->proxy_user = [0];
  2515. } else {
  2516. $this->proxy_host = $config['proxy_list'][$proxyindex];
  2517. }
  2518. } else {
  2519. do {
  2520. if (isset( proxyindex )) {
  2521. unset( $config['proxy_list'][$proxyindex] );
  2522. sort( $config['proxy_list'] );
  2523. saveSettingsArray( );
  2524. }
  2525.  
  2526. $proxyindex = array_rand( $config['proxy_list'] );
  2527.  
  2528. if (strstr( $config['proxy_list'][$proxyindex], '@' )) {
  2529. preg_match( '/^(.+?)@([^@]+)$/', $config['proxy_list'][$proxyindex], $proxyparts );
  2530. $this->proxy_host = $proxyparts[2];
  2531. $this->proxy_pass = explode( ':', $proxyparts[1] )[1];
  2532. $this->proxy_user = [0];
  2533. } else {
  2534. $this->proxy_host = $config['proxy_list'][$proxyindex];
  2535. }
  2536.  
  2537. $test = $this->get( 'http://google.com/' );
  2538. }while (!( ( !stristr( $test, '<title>Google' ) && 0 < count( $config['proxy_list'] ) )));
  2539. }
  2540. }
  2541.  
  2542. $this->agent = $config['user_agent'][array_rand( $config['user_agent'] )];
  2543. $this->cookiefile = dirname( __FILE__ ) . '/tmp/' . randstr( 16 ) . '.cookies';
  2544. }
  2545. }
  2546. }
  2547.  
  2548. $db = new FakeDB( );
  2549.  
  2550. if (!function_exists( 'saveSettingsArray' )) {
  2551. function saveSettingsArray() {
  2552. return true;
  2553. }
  2554. }
  2555.  
  2556.  
  2557. if (!function_exists( 'randstr' )) {
  2558. function randstr($int) {
  2559. return 'cookie';
  2560. }
  2561. }
  2562.  
  2563.  
  2564. if (!function_exists( 'urlCombine' )) {
  2565. function urlCombine($a, $b) {
  2566. return $b;
  2567. }
  2568. }
  2569.  
  2570. class ASMultiCurl extends MultiCurl {
  2571. var $tabRet = array( );
  2572.  
  2573. function onLoad($url, $content, $info) {
  2574. if (400 <= (int)$info['http_code']) {
  2575. as_debug( '
  2576. ************
  2577. KO : ' . $info['http_code'] . ' -> ' . $url . '
  2578. ************
  2579. ' );
  2580. return false;
  2581. }
  2582.  
  2583.  
  2584. if (( !stristr( $info['content_type'], 'html' ) && !stristr( $info['content_type'], 'xml' ) )) {
  2585. as_debug( '
  2586. ************
  2587. KO : ' . $info['content_type'] . ' -> ' . $url . '
  2588. ************
  2589. ' );
  2590. return false;
  2591. }
  2592.  
  2593.  
  2594. if (trim( $content ) == '') {
  2595. as_debug( '
  2596. ************
  2597. KO : Vide -> ' . $url . '
  2598. ************
  2599. ' );
  2600. return false;
  2601. }
  2602.  
  2603. $this->tabRet[$url] = trim( $content );
  2604. }
  2605. }
  2606.  
  2607. ?>
  2608. ..................................................
  2609. ..........................
  2610. ................
Add Comment
Please, Sign In to add comment