Jump to content

Search the Community

Showing results for tags 'curl'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 6 results

  1. Php Guys, Are you aware of any function or method where I can prevent downloads ? Imagine a page with a lot of links. Like: links to pages and links to imgs or links to downloads. Now, imagine I fetched that page with curl and the user is viewing the links present on the page. Q1a. Now, if I were to prevent any downloads from the download links. How would I do it ? Q1b -. Any php function that manages this prevention ? Q1b - If not, then any workarounds you can think of ? I'm thinking of str_replacing the download links so they no longer showup as download links but as something else such as nothing. Q2a. How would you get your cURL script to spot a download link and get it to not appear on your user's screen ? Q2b. Would you get the script to check for the file extension that would reveal if it's a viewable file (html page, img file, etc.) or a downloading file ? Q2c. What are the long list of download file extensions ? When I cURL fetch or build my own web proxy or build my crawler, have to make sure they ignore download links.
  2. Fellow Php'ers, I'm a php learner. Beginner. Very enthusiastic enough to try to build my own web proxy. See how far I have reached. The following is cURL. It shows you a ui text box where you type a url and cURL would fetch that url. 1. Now, in that fetched url, there could be links like so: <a href="http://www.google.com">Google</a> <a href="http://yahoo.com">Yahoo</a> This script is supposed to precede 'proxified_page_test.php?url_to_proxify=' on all links. So now, the links present on the proxified page (cURL fetched page) should look like this: <a href="proxified_page_test.php?url_to_proxify=http://www.google.com">Google</a> <a href="proxified_page_test.php?url_to_proxify=http://yahoo.com">Yahoo</a> 2. Also, in that fetched url, there could be a search box, like the google search box. Search box containing search box code like so ... "....action = http://google.com/q?" Again, this script is supposed to precede 'proxified_page_test.php?url_to_proxify=' on all links including on those forms that forward you to their processor.php. So now, the links present on the proxified page (cURL fetched page) should look like this: "....action = proxified_page_test.php?url_to_proxify=http://google.com/q?" That way, if you do a search on the proxified page then the SERPs presented would contain links where proxified_page_test.php?url_to_proxify= have been added. That way, if you were viewing google and doing a search, the SERPs presented would list links that precede the "proxified_page_test.php?url_to_proxify=" so that the result links can also be proxified when clicked. ISSUE Problem is, if you type "http://www.google.com" then it does not fetch that page. What is hindering the fetch ? <?php /* ERROR HANDLING */ declare(strict_types=1); ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); error_reporting(E_ALL); /* STEP 2: The IF gets triggered as soon as the "submit" button is clicked in the ui text box labeled: Url Following IF code deals with GET method. */ if(isset($_GET["url_to_proxify"]) === TRUE) { echo "IF got triggered!"; $url_to_proxify = filter_input(INPUT_GET, 'url_to_proxify', FILTER_VALIDATE_URL); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "$url_to_proxify"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_HEADER, 5); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $curl_result = curl_exec($ch); $domain = parse_url($url_to_proxify, PHP_URL_HOST); echo var_dump($domain); //Add proxy link on all links present on proxified page $pattern = array("http://", "https://", "http://www.", "https://www.", "localhost"); $replace = array("proxified_page_test.php?url_to_proxify=http://\".$domain\"", "proxified_page_test.php?url_to_proxify=https://\".$domain\"", "proxified_page_test.php?url_to_proxify=http://www.\".$domain\"", "proxified_page_test.php?url_to_proxify=https://www.\".$domain\"", "proxified_page_test.php?url_to_proxify=http://www.\".$domain\""); $string_replaced_data = str_replace($pattern, $replace, $curl_result); echo var_dump($string_replaced_data); //Add proxy link on all Image Links (Eg. Google Img File) $pattern = array('src="', 'src = "', 'src= "', 'src ="', "src='", "src = '", "src= '", "src='"); $replace = array('src="proxified_page_test.php?url_to_proxify=\".$domain\""', 'src = "proxified_page_test.php?url_to_proxify=\".$domain\""', 'src= "proxified_page_test.php?url_to_proxify=\".$domain\""', 'src ="proxified_page_test.php?url_to_proxify=\".$domain\""', "src='proxified_page_test.php?url_to_proxify=\".$domain\"'", "src = 'proxified_page_test.php?url_to_proxify=\".$domain\"'", "src= 'proxified_page_test.php?url_to_proxify=\".$domain\"'", "src ='proxified_page_test.php?url_to_proxify=\".$domain\"'"); $string_replaced_data = str_replace($pattern, $replace, $curl_result); echo var_dump($string_replaced_data); //Add proxy link on all links presented by the searchengine result pages (SERPS). Eg. Google Search Pages (SERPs) $pattern = array('action="', 'action = "', 'action= "', 'action ="', "action='", "action = '", "action= '", "action='"); $replace = array('action="proxified_page_test.php?url_to_proxify=\".$domain\""', 'action = "proxified_page_test.php?url_to_proxify=\".$domain\""', 'action= "proxified_page_test.php?url_to_proxify=\".$domain\""', 'action ="proxified_page_test.php?url_to_proxify=\".$domain\""', "action='proxified_page_test.php?url_to_proxify=\".$domain\"'", "action = 'proxified_page_test.php?url_to_proxify=\".$domain\"'", "action= 'proxified_page_test.php?url_to_proxify=\".$domain\"'", "action ='proxified_page_test.php?url_to_proxify=\".$domain\"'"); $string_replaced_data = str_replace($pattern, $replace, $curl_result); echo var_dump($string_replaced_data); print_r($curl_result); curl_close($ch); } else { echo "ELSE got triggered!"; //Html Form ?> <html> <body> <form action = "<?php echo $_SERVER['PHP_SELF']; ?>" method = "GET"> Url: <input type = "text" name = "url_to_proxify" /> <input type = "submit" /> </form> </body> </html> <?php } ?>
  3. Folks, Usually cURL works on my xampp. So, why not tonight ? I see white blank page! <?php /* ERROR HANDLING */ declare(strict_types=1); ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $url='https://oscarliang.com'; $ch=curl_init(); $timeout=5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); // Get URL content $lines_string=curl_exec($ch); // close handle to release resources curl_close($ch); //output, you can also save it locally on the server echo $lines_string; ?>
  4. Hey Guys, I'm just starting to learn Curl so that I connect to an API. At the moment I have this php code: <?php //******************************************************************************// // // //THIS FILE TAKES A CURRENT JOB AND ADDS IT TO A PAL LABEL PROJECT // // // //******************************************************************************// // ******* TURN ON ERROR REPORTING *****// error_reporting(E_ALL); ini_set('display_errors', '1'); //**** SET THE HEADERS UP FOR AUTHENTICATION *****// $headers = array(); $headers[] = "X-SUBDOMAIN:XXXXXXXXXXX"; // Set the sub domain $headers[] = "X-AUTH-TOKEN:XXXXXXXXXX"; // Set the API Code $headers[] = "application/json"; $total = 50; // this is the max number of pages we will search. with 100 items on a page, and 100 items that means we can return 10,000 items $curl = curl_init(); //**** WE GET ALL OF THE ITEMS CURRENTLY IN THE CURRENT PROJECT AND PUT THEIR UNIQUE ID INTO THE ASSETS ARRAY ***// curl_setopt($curl, CURLOPT_RETURNTRANSFER,true); curl_setopt($curl, CURLOPT_URL, 'https://api.current-rms.com/api/v1/products?page=1&per_page=100'); // allows up to 1 million products curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); // Send the request & save response to $resp $resp = curl_exec($curl); // Convert the response to an array $obj = json_decode($resp, true); // The Obj array currently contains every item in the DB and loads of useless info. We need to extract just the ID and the Name! If I print_r the $obj variable it returns this: I have cut the output down a bit, each item in the products array is about 50 lines long, The only information I actually need to recall is the first two lines which is [id] and the [name]. Is there a simple way that I can do this? So far I have tried to do a Foreach loop and create a new array, but this take a very long time (there are about 600 records!) there must be a much simpler way, where I can unset everything that I don't need, or only call the information that I need from the API? Here is the foreach loop that I used: foreach ($obj as $key) { foreach ($key as $id => $value) { if (!empty($value['name'])) { $products[] = array('Name'=>$value['name'], 'ID' => $value['id'] ); } } } **EDIT ** Once I have my array of ID's (which will be around 600 values long) I then need to get a list of serial numbers that are linked to these id's (there could be up to 100 per id) which will leave me with an array that will be huge! So far I have been getting gateway 504 error's, which I'm hoping is just due to the fact that I'm currently pulling out so much more information than I actually need, so I'm trying to make this more efficient and slim lined. I'm fairly new to PHP, and just do it as a hobby, so go easy on me please! Thanks AJLX
  5. I have never used cURL before and have hit a roadblock in my learning. I am trying to make a HTTP GET request to my Wowza server which uses the Rest API to return JSON results. I have authentication set to none on the server at the moment until I can get the script working. I have tested the code below with an external website and it works but, when I try to use it with the URL from the server with the Rest API it just times out. I can make the request in a browser fine, just not from the code. What am I missing or not doing correctly? $ch = curl_init("http://IP_TO_SERVER:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_/incomingstreams/ncopeland"); // such as http://example.com/example.xml curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, 0); $data = curl_exec($ch); curl_close($ch); print $data; The response should be this. { "serverName": "_defaultServer_", "sourceIp": "ncopeland", "isPTZEnabled": false, "applicationInstance": "_definst_", "name": "ncopeland", "isRecordingSet": false, "isStreamManagerStream": true, "isPublishedToVOD": false, "isConnected": true, "ptzPollingInterval": 2000 } -Thanks!
  6. somebody have an example or reference for PHP code that make login to a website and handle with the redirection after? thanks!
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.