Skip to main content
GameDev.net gamedev.net

PRO Tired of ads? Read GameDev.net ad-free and help keep the community independent with GameDev Pro — $3/month.

Useful script?

Useful script?

benryves
benryves
Any Colour You Like · · 1 min read
1,896 1
If you have a website of your own, you might want to have your journal on it. (I do [wink]).
This script can be used to generate a simple HTML document (such as this one!) containing a brief description of your recent entries, a title and a link to the item itself.

# UPDATE_JOURNAL.PHP# Ben Ryves 2005.# CONFIG:$journal_id = 273102;           # ID number of your journal.$items      = 8;                # How many recent journal entries do you want?$saved_page = 'journal.htm';    # Which page do you want to save the journal to?$password   = 'password';       # What's the password required to fire off an update?if (isset($_POST['submit'])) {    if ($_POST['password']==$password) {        # Run the update script:        $url='http://www.gamedev.net/community/forums/lib/rss.asp?mode=journal&jn='.$journal_id;        $handle = fopen($url,'r');        $writer = fopen($saved_page,'w');        if (!$handle) {        	echo "The RSS feed is not available at the moment - sorry.";        } else {        	global $cur_pos, $buffer;        	$buffer = '';        	while (!feof ($handle)) {        		$buffer .= fgets($handle, 4096);        	}        	fclose($handle);        	$cur_pos = strpos($buffer,"");        	for ($i=0; $i<$items; ++$i) {        		$title = get_between_text("","");        		if ($title===false) break;        		$link = get_between_text("","");        		$description = html_entity_decode(preg_replace("#<(.*?)>#i","",get_between_text("","")),ENT_QUOTES);        		$description = preg_replace("#<(.*)#i","...",$description);        		fwrite($writer,"$link\" target=\"_blank\">$title<small>$description</small>");        	}        	fclose($writer);        	echo "$saved_page has been updated!";        	return;        }    } else {        echo "Invalid password: sorry!";        unset($_POST['submit']);    }}?>
"post">Please enter your password:"password" name="password" />"submit" value="Go!" name="submit" />function get_between_text($before, $after) {   global $buffer, $cur_pos;   $cur_pos = strpos($buffer, $before, $cur_pos);   if ($cur_pos===false) {      return false;   } else {      $cur_pos+=strlen($before);      $e = strpos($buffer, $after, $cur_pos);      return substr($buffer, $cur_pos, $e-$cur_pos);   }}?>

You need to set a password just to stop people from running the script (it's a pretty basic system). You'll also need to set the correct ID number. It's a very quick-and-dirty script, so if you have any problems with it give me a shout!

Discussion

Loading comments...