Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

regular expressions in php

  • 07-03-2011 11:38pm
    #1
    Registered Users, Registered Users 2 Posts: 42


    Anyone know how to make regular expressions in php (extract info from one site and put it in mine) bypass proxy? Basically, I'm making a website for an assignment and need to get my reg exp working on the uni wifi. I have it working on wifi without proxy settings so it's my last step. Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 452 ✭✭AwayWithFaries


    Try looking at cURL.

    Never used it myself but it has methods for dealing with proxies in PHP. Hopefully that will be of some use to you.


  • Registered Users, Registered Users 2 Posts: 2,345 ✭✭✭Kavrocks


    Regular expressions can't bypass proxies. Regular expressions are used on data so what you need to do is direct your request through the proxy and that solution would depend entirely on how you are retrieving the data (file).


  • Registered Users, Registered Users 2 Posts: 42 Marina-anseo


    $url ="http://www.example.com";
    $contents = file_get_contents($url);

    That's how I'm getting the file and then editing it with a series of preg_replace uses.


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    $url ="http://www.example.com";
    $contents = file_get_contents($url);

    That's how I'm getting the file and then editing it with a series of preg_replace uses.
    I don't get it. Why are you editing the contents of the file?


  • Registered Users, Registered Users 2 Posts: 42 Marina-anseo


    Because it takes the whole html webpage in $url and I only want the headings and descriptions for upcoming events e.g. festivals. I then replaced the original table format with p tags etc to create a more suitable layout in my site.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    Because it takes the whole html webpage in $url and I only want the headings and descriptions for upcoming events e.g. festivals. I then replaced the original table format with p tags etc to create a more suitable layout in my site.
    Ok then that makes more sense.

    And what have you got so far. Where's the problem?


  • Registered Users, Registered Users 2 Posts: 42 Marina-anseo


    I have everything working perfectly on a proxy free internet connection but its just when I'm using my uni internet, (which is what I'll have to use when demonstrating the project) where my data should be, there is just an orange box with a php error complaining about the file_get_contents($url); part of my code, however, I know its the proxy is causing this not an actual problem with my code.


  • Registered Users, Registered Users 2 Posts: 2,345 ✭✭✭Kavrocks


    Yes what you need to do is connect through the proxy. You can set that up using the function located at http://php.net/manual/en/function.stream-context-create.php there is an example by somebody for connecting through a proxy, just change their settings to the ones needed for your uni wifi.

    I hope that works :rolleyes:.


  • Registered Users, Registered Users 2 Posts: 42 Marina-anseo


    Kavrocks wrote: »
    Yes what you need to do is connect through the proxy. You can set that up using the function located at http://php.net/manual/en/function.stream-context-create.php there is an example by somebody for connecting through a proxy, just change their settings to the ones needed for your uni wifi.

    I hope that works :rolleyes:.

    Thank you, I can't test it until Monday but it looks right. :)


  • Registered Users, Registered Users 2 Posts: 2,345 ✭✭✭Kavrocks


    Anytime.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 42 Marina-anseo


    Works :D


Advertisement