Jump to content

pianoman993

Members
  • Posts

    68
  • Joined

  • Last visited

    Never

Posts posted by pianoman993

  1. Hello .htaccess geniuses! I have a small question for you. Would it be possible to:

     

    Detect "mysite.com/#/profile" in a url and change it to "mysite.com/profile?" (all within a .htacces file?)

     

    If so, what kind of code would I have to use to implement such a task? I'm assuming I need an if statement followed by a 301 redirect, but I'm not sure what that kind of code would look like.

     

    Any help would be greatly appreciated!! Thanks in advance!

    Mark Anderson

  2. Hello there PHP experts! I have a simple question. Basically I have a script that takes user input and processes it through this procedure:

    strip_tags(trim(htmlentities($_POST['field'])));

     

    However, the problem is that I come back with values such as

     

    [quote]This is Track 10 of 20 of the album ¡U&I R 1MB!
    The album will be released April 30th, free for download.  Here is a sample from the album ¡ENJOY![/quote]

     

    And

     

    [quote]¡U&I R 1MB![/quote]

     

    Is there any way I can take the user input and disallow HTML but still display quotation marks and funky characters like upside down exclamation marks?

     

    Any help would be greatly appreciated!!

    - Pianoman993

  3. Hello there PHP experts! I am trying to use a string like this:

     

    a:7:{s:10:"country_id";s:3:"226";s:5:"email";s:22:"email@wi.rr.com";s:10:"last_visit";s:19:"2009-02-20 10:22:58";s:7:"created";s:19:"2009-02-20 10:22:58";s:8:"modified";s:19:"0000-00-00 00:00:00";s:3:"URI";s:5:"/home";s:17:"FreakAuth_captcha";s:5:"sqqpi";}
    

     

    And be able to "explode" the data so I can get each value. So for instance I could fetch the country_id value by typing string_array['country_id']. is this possible?

     

    Any help is greatly appreciated! Thank you!

     

    - Pianoman993

  4. Hello there PHP experts. I have a small expression that checks to make sure the given string has Only alpha characters, digits, underline or dash characters. However, would it be possible to edit it to allow one space between words?

     

    Here is what I've got:

    '/^([a-z0-9])([a-z0-9_\-])*$/ix'

     

    Example "Example String" (the expression allows one space between example and string)

     

    An even more adventurous example: "Another Example String" Still allows a space between words

     

    If anyone has any ideas please post!

    Thank you for your time!

     

    - Pianoman993

  5. I just created a new topic but have asked the forum mods to delete it.

     

    Basically, I would like to pay you if you are able to help me since you have been the one all along helping me! If you would like my offer to pay you, my offer of $10 still stands.

     

        * When the message form is submitted and sent to the bb_encoder function, the preg_replace that detects all quote tag dates and converts them automatically will generate a "headers already sent error" and "undefined offset 1 error" if no quote tag with dates is included. (Basically if you just submitted the words "Hello World" in the message textbox, you would get those errors)

        * When the tags [ quote author=... date=... ] [ / quote ] is actually found and the preg_replace function converts the date to readable format, it converts nicely. However if there are more than one sets of quotes, the date conversion is rendered the same for each occurrence.

        * How can you reverse this process in the bb_decoder?

  6. Hello there php experts. Basically, I have a pretty good bbcode system in place with some minor issues (listed below)

    • When the message form is submitted and sent to the bb_encoder function, the preg_replace that detects all quote tag dates and converts them automatically will generate a "headers already sent error" and "undefined offset 1 error" if no quote tag with dates is included. (Basically if you just submitted the words "Hello World" in the message textbox, you would get those errors)
    • When the tags [ quote author=... date=... ] [ / quote ] is actually found and the preg_replace function converts the date to readable format, it converts nicely. However if there are more than one sets of quotes, the date conversion is rendered the same for each occurrence.
    • How can you reverse this process in the bb_decoder?

     

    The first to post the working PHP code that has these 3 fixes will get $10.00. I use Paypal so please let me know what your email is :)

     

    Thank you for reading this, here is my code!

     

    function bb_encode ($str) {  
        $str = nl2br(htmlentities($str));
    
    
        preg_match('~\[quote.*?date=(\d+?)\]~is',$str,$timestamp);
        $date = date("m:d:Y H:i:s", $timestamp[1]);
      
        $simple_search = array(  
                    //added line break  
    			'~\[quote\]~is',
    			'~\[/quote\]~is',
    			'~\[quote author=(.*?) date=(.*?)\]~is',
    			'~\[/quote\]~is',
                    '/\[b\](.*?)\[\/b\]/is',  
                    '/\[i\](.*?)\[\/i\]/is',  
                    '/\[u\](.*?)\[\/u\]/is',  
    			'/\[s\](.*?)\[\/s\]/is',  
                    '/\[url\=(.*?)\](.*?)\[\/url\]/is',  
                    '/\[url\](.*?)\[\/url\]/is',  
                    '/\[align\=(left|center|right)\](.*?)\[\/align\]/is',  
                    '/\[img\](.*?)\[\/img\]/is',  
                    '/\[mail\=(.*?)\](.*?)\[\/mail\]/is',  
                    '/\[mail\](.*?)\[\/mail\]/is',  
                    '/\[font\=(.*?)\](.*?)\[\/font\]/is',  
                    '/\[size\=(.*?)\](.*?)\[\/size\]/is',  
                    '/\[color\=(.*?)\](.*?)\[\/color\]/is',  
                      //added textarea for code presentation  
                   '/\[codearea\](.*?)\[\/codearea\]/is',  
                     //added pre class for code presentation  
                  '/\[code\](.*?)\[\/code\]/is',  
                    //added paragraph  
                  '/\[p\](.*?)\[\/p\]/is'  
                    );  
      
        $simple_replace = array( 
    
    	   	    '<table class="bbc_quote_table"><tr><td class="bbc_quote_header">$1</td></tr><tr><td class="bbc_quote_body">',
    			'</td></tr></table>',
    	   	    '<table class="bbc_quote_table"><tr><td class="bbc_quote_header"><span class="quote_from">Quote from</span> <span class="author">$1</span> on <span class="date">'.$date.'</span></td></tr><tr><td class="bbc_quote_body">',
    			'</td></tr></table>',
    			//added line break  
                    '<strong>$1</strong>',  
                    '<em>$1</em>',  
                    '<u>$1</u>',
    			'<s>$1</s>',
    			// added nofollow to prevent spam  
                    '<a href="$1" rel="nofollow" title="$1">$1</a>', 
    			'<a href="$1" rel="nofollow" title="$2 - $1">$2</a>',  
                    '<div style="text-align: $1;">$2</div>',  
    			//added alt attribute for validation  
                    '<img src="$1" alt="" />',  
                    '<a href="mailto:$1">$2</a>',  
                    '<a href="mailto:$1">$1</a>',  
                    '<span style="font-family: $1;">$2</span>',  
                    '<span style="font-size: $1;">$2</span>',  
                    '<span style="color: $1;">$2</span>',  
    			//added textarea for code presentation  
    			'<textarea class="code_container" rows="30" cols="70">$1</textarea>',  
    			//added pre class for code presentation  
    			'<pre class="code">$1</pre>',  
    			//added paragraph  
    			'<p>$1</p>' 
                    );  
      
        // Do simple BBCode's  
        $str = preg_replace ($simple_search, $simple_replace, $str);  
      
        return $str;
    
    }
    
    function bb_decode ($str) {  
    
    $bbcode = array(
    
    	"/\<strong>(.*?)<\/strong>/is" => "[b]$1[/b]",
    	"/\<em>(.*?)<\/em>/is" => "[i]$1[/i]",
    	"/\<u>(.*?)<\/u>/is" => "[u]$1[/u]",
    	"/\<s>(.*?)<\/s>/is" => "[s]$1[/s]",
    	"/\<table class=\"bbc_quote_table\"><tr><td class=\"bbc_quote_header\"><\/td><\/tr><tr><td class=\"bbc_quote_body\">/is" => "[quote]$1",
    	"/\<table class=\"bbc_quote_table\"><tr><td class=\"bbc_quote_header\"><span class=\"quote_from\">Quote from<\/span> <span class=\"author\">(.*?)<\/span> on <span class=\"date\">(.*?)<\/span><\/td><\/tr><tr><td class=\"bbc_quote_body\">/is" => "[quote author=$1 date=$2]$3",
    	"/\<\/td><\/tr><\/table>/is" => "[/quote]",
    
           	"/\<a href=\"(.*?)\" rel=\"nofollow\" title=\"(.*?)\">(.*?)<\/a>/is" => "[url]$1[/url]", 
    	"/\<img src=\"(.*?)\" alt=\"\" \/>/is" => "[img=$1]",
    
    	"/\<br \/>/is" => ""
    
    );
    
    $str = preg_replace(array_keys($bbcode), array_values($bbcode), $str);
      
        return $str; 
    
    }
    

  7. That's strange, for some reason I'm getting a bunch of errors now :/

     

    A PHP Error was encountered

     

    Severity: Notice

     

    Message: Undefined offset: 1

    Line Number: 250

    A PHP Error was encountered

     

    Severity: Warning

     

    Message: Cannot modify header information - headers already sent by

     

    Severity: Warning

     

    Message: Cannot modify header information - headers already sent by

  8. So in a nutshell, if I used this code:

     

    function bb_decode ($str) {  
    
        preg_match('~\[quote.*?date=(\d+?)\]~is',$str,$timestamp);
        $date = strtotime("m:d:Y H:i:s", $timestamp[1]); 
    
    $bbcode = array(
    
    	"/\<strong>(.*?)<\/strong>/is" => "[b]$1[/b]",
    	"/\<em>(.*?)<\/em>/is" => "[i]$1[/i]",
    	"/\<u>(.*?)<\/u>/is" => "[u]$1[/u]",
    	"/\<s>(.*?)<\/s>/is" => "[s]$1[/s]",
    	"/\<table class=\"bbc_quote_table\"><tr><td class=\"bbc_quote_header\"><\/td><\/tr><tr><td class=\"bbc_quote_body\">/is" => "[quote]$1",
    	"/\<table class=\"bbc_quote_table\"><tr><td class=\"bbc_quote_header\"><span class=\"quote_from\">Quote from<\/span> <span class=\"author\">(.*?)<\/span> on <span class=\"date\">(.*?)<\/span><\/td><\/tr><tr><td class=\"bbc_quote_body\">/is" => "[quote author=$1 date=$date]$3",
    	"/\<\/td><\/tr><\/table>/is" => "[/quote]",
    
    
    	"/\<br \/>/is" => ""
    
    );
    
    

     

    I would be able to convert the date= field to the original time string?

  9. Sorry about that. Here's my php code

     

    function bb_encode ($str) {  
        $str = nl2br(htmlentities($str));  
      
        $simple_search = array(  
    			'~\[quote author=(.*?) date=(.*?)\]~is',
    			'~\[/quote\]~is',
                    );  
      
        $simple_replace = array( 
    
    	   	    '<table class="bbc_quote_table"><tr><td class="bbc_quote_header"><b>Quote from </b>$1</b> on unix_to_human($2)</td></tr><tr><td class="bbc_quote_body">',
    			'</td></tr></table>'
                    );  
      
        // Do simple BBCode's  
        $str = preg_replace ($simple_search, $simple_replace, $str);  
      
        return $str;  
    }
    

     

    And here is what I right

     

    [ quote author=UrbanTwitch date=1227397761]Thank you so much!!

    [ /quote ]

     

    Here is what I get

     

    Quote from UrbanTwitch on unix_to_human(1227397761) ...
  10. Hello there PHP experts. I have a small question for you. Is it possible to format a date (number) in a preg_replace statement?

     

    Here is a snippet of code I am using, you will see the unix_to_human($2) is my stab at a conversion to a real date. Is it possible to do this? If so, could please post an example? Thank you!

     

    '<table class="bbc_quote_table"><tr><td class="bbc_quote_header"><b>Quote from </b>$1</b> on unix_to_human($2)</td></tr><tr><td class="bbc_quote_body">',

     

    Any help is greatly appreciated :)

     

    - Pianoman993

  11. Hello there PHP experts! I recently posted a similar post about decoding bbcode. In this question I am wondering why I keep getting an extra <br /> tag after every set of [ center ] [ / center ] tags. Here is my code!

     

    	function bb_encode ($str) {  
        $str = nl2br(htmlentities($str));  
      
        $simple_search = array(  
                    //added line break  
                    '/\[b\](.*?)\[\/b\]/is',  
                    '/\[i\](.*?)\[\/i\]/is',  
                    '/\[u\](.*?)\[\/u\]/is',  
    			'/\[s\](.*?)\[\/s\]/is',  
    			'/\[center\](.*?)\[\/center\]/is',  
                    '/\[url\=(.*?)\](.*?)\[\/url\]/is',  
                    '/\[url\](.*?)\[\/url\]/is',  
                    '/\[align\=(left|center|right)\](.*?)\[\/align\]/is',  
                    '/\[img\](.*?)\[\/img\]/is',  
                    '/\[mail\=(.*?)\](.*?)\[\/mail\]/is',  
                    '/\[mail\](.*?)\[\/mail\]/is',  
                    '/\[font\=(.*?)\](.*?)\[\/font\]/is',  
                    '/\[size\=(.*?)\](.*?)\[\/size\]/is',  
                    '/\[color\=(.*?)\](.*?)\[\/color\]/is',  
                      //added textarea for code presentation  
                   '/\[codearea\](.*?)\[\/codearea\]/is',  
                     //added pre class for code presentation  
                  '/\[code\](.*?)\[\/code\]/is',  
                    //added paragraph  
                  '/\[p\](.*?)\[\/p\]/is',  
                    );  
      
        $simple_replace = array(  
    			//added line break  
                    '<strong>$1</strong>',  
                    '<em>$1</em>',  
                    '<u>$1</u>',
    			'<s>$1</s>',  
    			'<div style="text-align:center">$1</div>',  
    			// added nofollow to prevent spam  
                    '<a href="$1" rel="nofollow" title="$2 - $1">$2</a>',  
                    '<a href="$1" rel="nofollow" title="$1">$1</a>',  
                    '<div style="text-align: $1;">$2</div>',  
    			//added alt attribute for validation  
                    '<img src="$1" alt="" />',  
                    '<a href="mailto:$1">$2</a>',  
                    '<a href="mailto:$1">$1</a>',  
                    '<span style="font-family: $1;">$2</span>',  
                    '<span style="font-size: $1;">$2</span>',  
                    '<span style="color: $1;">$2</span>',  
    			//added textarea for code presentation  
    			'<textarea class="code_container" rows="30" cols="70">$1</textarea>',  
    			//added pre class for code presentation  
    			'<pre class="code">$1</pre>',  
    			//added paragraph  
    			'<p>$1</p>',  
                    );  
      
        // Do simple BBCode's  
        $str = preg_replace ($simple_search, $simple_replace, $str);  
      
        return $str;  
    }
    
    function bb_decode ($str) {  
        $str = ($str);
    
    $bbcode = array(
    
    	"/\<strong>(.*?)<\/strong>/is" => "[b]$1[/b]",
    	"/\<em>(.*?)<\/em>/is" => "[i]$1[/i]",
    	"/\<u>(.*?)<\/u>/is" => "[u]$1[/u]",
    	"/\<s>(.*?)<\/s>/is" => "[s]$1[/s]",
    	"/\<div style=\"text-align:center\">(.*?)<\/div>/is" => "
    [center]$1[/center]
    ", 
    	"/\<br \/>/is" => ""
    
    );
    
    $str = preg_replace(array_keys($bbcode), array_values($bbcode), $str);
      
        return $str;  
    }  
    

     

    Any help would be greatly appreciated! Thanks!

     

    - Pianoman993

  12. I was able to fix the problem.

     

    function bb_decode ($str) {  
        $str = ($str);
    
    $bbcode = array(
    
    	"/\<strong>(.*?)<\/strong>/is" => "[b]$1[/b]",
    	"/\<br \/>/is" => ""
    
    );
    
    $str = preg_replace(array_keys($bbcode), array_values($bbcode), $str);
      
        return $str;  
    }  
    

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.