Current location: Hot Scripts Forums » Programming Languages » PHP » [SOLVED] UniqueID.html


[SOLVED] UniqueID.html

Reply
  #1 (permalink)  
Old 12-21-08, 09:40 PM
!Unreal's Avatar
!Unreal !Unreal is offline
Wannabe Coder
 
Join Date: Aug 2008
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up [SOLVED] UniqueID.html

Hello.

Ive got this small script which caches a web page. It names the file with a unique ID which is all fine but I need it to name it with the unique ID but with a HTML extention.

How would I do this?

Heres my script...

PHP Code:

<?php

$page 
file_get_contents('http://www.google.com');

$num md5(uniqid());

$filename $num;

file_put_contents($filename,$page);

?>
__________________
Free Online Movies
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 12-21-08, 11:00 PM
DAL's Avatar
DAL DAL is offline
Code Master
 
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
$filename = $num.".html"; ????? what part where you stuck on I'm a little lost
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 12-21-08, 11:09 PM
!Unreal's Avatar
!Unreal !Unreal is offline
Wannabe Coder
 
Join Date: Aug 2008
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
Yes that was what I was looking for. I knew it was something like that I just couldnt get the syntax right.

Thank you so much
__________________
Free Online Movies
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 12-21-08, 11:17 PM
DAL's Avatar
DAL DAL is offline
Code Master
 
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
wow, I was expecting a little more complication, oh well cool that your on your way.

Kind regards
Dal
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 12-22-08, 03:22 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
This is a little bit more secure...
PHP Code:

do

{
    
$filename md5(uniqid(rand(), true)) . '.html';
}
while (
is_file($filename));

file_put_contents($filename$page); 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 12-22-08, 11:23 AM
!Unreal's Avatar
!Unreal !Unreal is offline
Wannabe Coder
 
Join Date: Aug 2008
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks Nico. Ill use that
__________________
Free Online Movies
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 12:14 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.