bonnag Posted July 15, 2008 Share Posted July 15, 2008 Hi, I'm new to php and I'm stuck. I'm trying to duplicate another page using php, but I have a problem with relative and absolute paths. I've tried include() and I've tried file_get_contents() but I can't figure out how to handle the relative references. As a practice I've just been using the google homepage and the best that I can get can be seen here http://www.drzo.com/cb/1.php It is begining to drive me insane. Thanks in advance, Scott Quote Link to comment https://forums.phpfreaks.com/topic/114905-duplicate-another-page-problem/ Share on other sites More sharing options...
Wuhtzu Posted July 15, 2008 Share Posted July 15, 2008 May we see how you are doing it now to provide you with a solution which fit your current code? Quote Link to comment https://forums.phpfreaks.com/topic/114905-duplicate-another-page-problem/#findComment-590929 Share on other sites More sharing options...
ag3nt42 Posted July 15, 2008 Share Posted July 15, 2008 why do you want to duplicate a page? not to offend but the only reason I can think of, as to why would you want to duplicate a page.. is to steal someone elses work. Quote Link to comment https://forums.phpfreaks.com/topic/114905-duplicate-another-page-problem/#findComment-590931 Share on other sites More sharing options...
Wuhtzu Posted July 15, 2008 Share Posted July 15, 2008 Probably for fun or to allow for some sort "browsing remote sites from a frame" I guess Quote Link to comment https://forums.phpfreaks.com/topic/114905-duplicate-another-page-problem/#findComment-590935 Share on other sites More sharing options...
ag3nt42 Posted July 15, 2008 Share Posted July 15, 2008 Probably for fun or to allow for some sort "browsing remote sites from a frame" I guess well fun=stealing most likely.. yea its fun to play with the code and see what you can do but why duplicate a page?? also if you were to be browsing remote sites in a frame why would you need to use php? all i'm saying is I build stuff on the web.. and I don't want some guy coming over and using php to scoop up what I made ya know. Quote Link to comment https://forums.phpfreaks.com/topic/114905-duplicate-another-page-problem/#findComment-590937 Share on other sites More sharing options...
Wuhtzu Posted July 15, 2008 Share Posted July 15, 2008 I can think of a few uses which is legitimate or handy... Just have a look at google's image search: http://images.google.dk/imgres?imgurl=http://gizmodo.com/assets/resources/2008/04/sphans.jpg&imgrefurl=http://www.gizmodo.com.au/2008/04/news_corp_hires_hacker_to_break_into_dish_satellite_network_steal_security_codes_for_pirate_cards-2.html&h=357&w=494&sz=170&hl=da&start=18&um=1&tbnid=98W6W3_HH-0spM:&tbnh=94&tbnw=130&prev=/images%3Fq%3Dsteal%26um%3D1%26hl%3Dda%26sa%3DG Quote Link to comment https://forums.phpfreaks.com/topic/114905-duplicate-another-page-problem/#findComment-590941 Share on other sites More sharing options...
bonnag Posted July 15, 2008 Author Share Posted July 15, 2008 Hi, I can understand your reservations regarding 'stealing'. I have the premission of a website owner to duplicate some of their pages and they are likely to change. I want to have a way to do have it work dynamically rather than having to pull all the pages over or cron a backup etc. As for the code that I have it is virtually non-existant. <?php $file = file_get_contents ("http://www.google.com"); echo $file; ?> Thats about as far as I got! Regards, Scott Quote Link to comment https://forums.phpfreaks.com/topic/114905-duplicate-another-page-problem/#findComment-590942 Share on other sites More sharing options...
Wuhtzu Posted July 15, 2008 Share Posted July 15, 2008 When you are doing this the way you are, you could parse through the code you get and change the URLs... For example the google page use css to insert pictures: <div align=left style="background:url(/intl/en_com/images/logo_plain.png) no-repeat;height:110px;width:276px" title="Google"> So you have to change /intl/en_com/images/logo_plain.png into http://www.google.com/intl/en_com/images/logo_plain.png Use regex to do this Quote Link to comment https://forums.phpfreaks.com/topic/114905-duplicate-another-page-problem/#findComment-590946 Share on other sites More sharing options...
bonnag Posted July 15, 2008 Author Share Posted July 15, 2008 Yes, That is what I'd like to be able to do, but there are going to be scripts and css references and such like and I was wondering if I could do it globally. Regards, Scott Quote Link to comment https://forums.phpfreaks.com/topic/114905-duplicate-another-page-problem/#findComment-590949 Share on other sites More sharing options...
bonnag Posted July 15, 2008 Author Share Posted July 15, 2008 Should I seek assistance in the regex section then, rather than here? Thanks, Scott Quote Link to comment https://forums.phpfreaks.com/topic/114905-duplicate-another-page-problem/#findComment-591097 Share on other sites More sharing options...
bonnag Posted July 16, 2008 Author Share Posted July 16, 2008 I managed to get it working myself. I'm currently stealing all of ag3nt42's pages ........ Quote Link to comment https://forums.phpfreaks.com/topic/114905-duplicate-another-page-problem/#findComment-591719 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.