Results 1 to 4 of 4
  1. #1
    Sub's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Posts
    4
    Reputation
    10
    Thanks
    0

    Txt Based CMS(Flat-File) + Smiley system

    Easy as pie.

    first make this .txt file called updates.txt
    Code:
    downloadx.org update #2
    nextupdate :)
    Code:
    <?
    
    function replace($content) {
    $content = ereg_replace("\n","<br>", $content); 
    $content = ereg_replace(":)","<img src=smile.png>", $content); 
    return $content;
    }
    $rawr = file_get_contents("updates.txt");
    
    echo replace($rawr);
    
    ?>
    now just do this
    Code:
    js/cssetchere
    htmlhtmlhtml
    htmlhtmlhtml
    <? include("news.php"); ?>
    htmlhtmlhtml
    htmlhtmlhtml
    owned

    posted on rune-server.dot.org by me

  2. #2
    yearupie's Avatar
    Join Date
    Apr 2008
    Gender
    male
    Posts
    54
    Reputation
    11
    Thanks
    2
    This is crap!

    Try a better example (this may in a class or function):

    class.ubb.php
    Code:
    <?php
    class Ubb {
    	
    	public $text;
    	public $smilies = array( 
    	':)'    =>     "smile.gif", 
    	':('    =>     "sad.gif", 
    	':D'    =>     "biggrin.gif", 
    	':d'    =>     "biggrin.gif",                 
    	':p'    =>     "tongue.gif", 
    	':P'    =>     "tongue.gif", 
    	':-)'    =>     "unsure.gif", 
    	'(A)'    =>     "angel.gif", 
    	'(a)'    =>     "angel.gif", 
    	':s'    =>     "blink.gif", 
    	':S'    =>     "blink.gif", 
    	':$'    =>     "blush.gif", 
    	'(h)'    =>     "cool.gif", 
    	'(H)'    =>     "cool.gif", 
    	':\'('    =>     "cry.gif", 
    	'--'    =>     "dry.gif", 
    	'-_-'    =>     "dry.gif", 
    	'^^'    =>     "happy.gif", 
    	'^_^'    =>     "happy.gif", 
    	':|'    =>     "huh.gif", 
    	';d'    =>     "laugh.gif", 
    	';D'    =>     "laugh.gif", 
    	':@'    =>     "mad.gif", 
    	':o'    =>     "ohmy.gif", 
    	':O'    =>     "ohmy.gif", 
    	':0'    =>     "ohmy.gif", 
    	'8S'    =>     "woot.gif", 
    	'8s'    =>     "woot.gif", 
    	'8)'    =>     "wacko.gif", 
    	';)'    =>     "wink.gif", 
    	);
    	
    	public function __construct($text) {
    		
    		$this->text = $text;
    	}
    	
    	public function addCodes() {
    	
    		$text = $this->text;
    		
    		# Change characters in html
    		$text = htmlspecialchars($text);
    		
    		# Add enters
    		$text = nl2br($text); 
    		
    		# Run all possibilities
    		foreach($this->smilies AS $find => $replace) 
        {
    	    # Creates an image for each smiley
        	$text = str_replace(htmlentities($find), '<img src="https://www.mpgh.net/forum/images/smileys/'.$replace.'" alt="smileys" />', $text);   
      	}
      	# Add your own image
      	$text = preg_replace('#\[img\](http(s)?://)([a-zA-Z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)\[/img\]#', '<img src="\\1\\3" alt="" />', $text);
      	
      	# Makes colored characters
      	$text = preg_replace('#\[color=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]#si', '<font color="\\1">\\2</font>', $text);
      	
      	return $text;
    	}
    }
    ?>
    How to use?

    Set at the top of your document
    Code:
    <?php
    require_once('class.ubb.php');
    
    $file = file_get_contents("updates.txt");
    $text = new Ubb($file);
    ?>
    And this where you want the text:
    Code:
    <?php
    $text-> addCodes();
    ?>

  3. #3
    Threadstarter
    New Member
    Sub's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Posts
    4
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by yearupie View Post
    This is crap!

    Try a better example (this may in a class or function):

    class.ubb.php
    Code:
    <?php
    class Ubb {
    	
    	public $text;
    	public $smilies = array( 
    	':)'    =>     "smile.gif", 
    	':('    =>     "sad.gif", 
    	':D'    =>     "biggrin.gif", 
    	':d'    =>     "biggrin.gif",                 
    	':p'    =>     "tongue.gif", 
    	':P'    =>     "tongue.gif", 
    	':-)'    =>     "unsure.gif", 
    	'(A)'    =>     "angel.gif", 
    	'(a)'    =>     "angel.gif", 
    	':s'    =>     "blink.gif", 
    	':S'    =>     "blink.gif", 
    	':$'    =>     "blush.gif", 
    	'(h)'    =>     "cool.gif", 
    	'(H)'    =>     "cool.gif", 
    	':\'('    =>     "cry.gif", 
    	'--'    =>     "dry.gif", 
    	'-_-'    =>     "dry.gif", 
    	'^^'    =>     "happy.gif", 
    	'^_^'    =>     "happy.gif", 
    	':|'    =>     "huh.gif", 
    	';d'    =>     "laugh.gif", 
    	';D'    =>     "laugh.gif", 
    	':@'    =>     "mad.gif", 
    	':o'    =>     "ohmy.gif", 
    	':O'    =>     "ohmy.gif", 
    	':0'    =>     "ohmy.gif", 
    	'8S'    =>     "woot.gif", 
    	'8s'    =>     "woot.gif", 
    	'8)'    =>     "wacko.gif", 
    	';)'    =>     "wink.gif", 
    	);
    	
    	public function __construct($text) {
    		
    		$this->text = $text;
    	}
    	
    	public function addCodes() {
    	
    		$text = $this->text;
    		
    		# Change characters in html
    		$text = htmlspecialchars($text);
    		
    		# Add enters
    		$text = nl2br($text); 
    		
    		# Run all possibilities
    		foreach($this->smilies AS $find => $replace) 
        {
    	    # Creates an image for each smiley
        	$text = str_replace(htmlentities($find), '<img src="https://www.mpgh.net/forum/images/smileys/'.$replace.'" alt="smileys" />', $text);   
      	}
      	# Add your own image
      	$text = preg_replace('#\[img\](http(s)?://)([a-zA-Z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)\[/img\]#', '<img src="\\1\\3" alt="" />', $text);
      	
      	# Makes colored characters
      	$text = preg_replace('#\[color=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]#si', '<font color="\\1">\\2</font>', $text);
      	
      	return $text;
    	}
    }
    ?>
    How to use?

    Set at the top of your document
    Code:
    <?php
    require_once('class.ubb.php');
    
    $file = file_get_contents("updates.txt");
    $text = new Ubb($file);
    ?>
    And this where you want the text:
    Code:
    <?php
    $text-> addCodes();
    ?>
    Ill be posting my cms later, it uses a similar bbc system

  4. #4
    Spookerzz's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    4,647
    Reputation
    26
    Thanks
    572
    Bit of a bump there.
    I'm back.

Similar Threads

  1. [Help] Find File In System [solved]
    By alvaritos in forum Visual Basic Programming
    Replies: 3
    Last Post: 06-24-2011, 10:01 AM
  2. Advanced .Bat / .Txt File Creator !!!
    By nökeinbock in forum Visual Basic Programming
    Replies: 2
    Last Post: 01-18-2010, 04:48 PM
  3. <<<<((need player.txt file!!))>>>
    By horogon in forum Combat Arms Mods & Rez Modding
    Replies: 5
    Last Post: 12-28-2009, 12:54 AM
  4. .DLL Opening As .TXT File
    By callenbs in forum Combat Arms Help
    Replies: 11
    Last Post: 09-05-2009, 12:40 AM
  5. "Cannot get a file [version.txt] !"
    By MarcAu in forum WarRock - International Hacks
    Replies: 14
    Last Post: 07-27-2007, 09:51 PM