Jump to content
Old threads will finally start getting archived ×

thetooth

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

thetooth's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello all! If your reading this i need some testing of my CMS script before next major release. The main areas will be playing with the new extensions system to issuer it is able to support developer needs. Also please report any general bugs that come up. You can get the RC version from here: http://dev.ameoto.com/index.php?page=whitecrane And submit issue to the google code page here: http://code.google.com/p/whitecrane/issues/list Or post right here if you like... Thank you for any help you can bring!~ P.S. its flat-file so just extract and run! no need to setup db's
  2. thetooth

    forms

    you need to set the `value` in each form element to the resulting var called from the database, as for the drop downs you may have to list them with an array and then use a string match to make then drop down auto select the item
  3. thanks alot man this has really been doing my head in. i spent weeks learning php so i could throw this together but there so much i don't know yet debugging is really difficult
  4. yes thats the answer but i am a noob at php so doing that is almost imposable can you help a little with the coding of such a function?
  5. <pre> wont work because the parser dosen't listen to html it just maches srtings i need a defenit way of getting it to not do it it vertan areas
  6. *makes it go up in list* please?
  7. by the looks of what your trying to do i would say its alot easyer to define all your errors in a config first and then use a simple heard redirect that calls it
  8. Hi i am working on my very own cms so far its almost complete but one thing that still has a few issues is the syntax parser. the thing is it works fine but it works to well basicly what i need is to be able to insert say #code[some code here] and any syntax that the parser is designed to parse simply wont be but everything below and above it will function normaly. parser class snippent: class Parser{ //Wiki Syntax var $sand = array( '===' => 'h2', '==' => 'h3' ); //Link System var $internal = array( '\-' => array('a href') ); //BBCode Tags var $tags = array( 'b' => 'strong', 'i' => 'em', 'u' => 'span style="text-decoration:underline"', 'quote' => 'blockquote', 's' => 'span style="text-decoration: line-through"', 'list' => 'ul', '\*' => 'li', 'code' => 'pre' ); //Tags that must be mapped to diffierent parts var $mapped = array( 'url' => array('a','href',true), 'img' => array('img','src',false) ); //Tags with atributes var $tags_with_att = array('color' => array('font','color'),'size' => array('font','size'),'url' => array('a','href')); //Gotta have smilies var $smilies = array( '' => 'smileys/smile.gif', '' => 'smileys/sad.gif', 'XD' => 'smileys/biggrin.gif', ':"(' => 'smileys/cry.gif', '' => 'smileys/tongue.gif', '' => 'smileys/suprised.gif', ':@' => 'smileys/mad.gif', ':|' => 'smileys/confused.gif' ); //Config Variables //Convert new line charactes to linebreaks? var $convert_newlines = false; //Parse For smilies? var $parse_smilies = true; //auto link urls(http and ftp), and email addresses? var $auto_links = true; //Internal Storage var $_code = ''; function BB_Code($new=true,$parse=true,$links=true){ $this->convert_newlines = $new; $this->parse_smilies = $parse; $this->auto_links = $links; } function parse($code){ $this->_code = $code; //$this->_strip_html();// Maybe you will need this... $this->_parse_sand(); $this->_parse_internal(); $this->_parse_tags(); $this->_parse_mapped(); $this->_parse_tags_with_att(); $this->_parse_smilies(); $this->_parse_links(); $this->_convert_nl(); return $this->_code; } function _strip_html(){ $this->_code = strip_tags($this->_code); } function _convert_nl(){ if($this->convert_newlines){ $this->_code = nl2br($this->_code); } } function _parse_sand(){ foreach($this->sand as $old=>$new){ $ex = explode(' ',$new); $this->_code = preg_replace('/'.$old.'(.+?)'.$old.'/is','<'.$new.'>$1</'.$ex[0].'>',$this->_code); } } function _parse_internal(){ foreach($this->internal as $tag=>$data){ //Use URL rewrite engine? $rewrite = false; if($rewrite == true){ $this->_code = preg_replace('/\['.$tag.'(.+?)\|(.+?)\]/is','<'.$data[0].'="/$1">$2</a>',$this->_code); }else{ $this->_code = preg_replace('/\['.$tag.'(.+?)\|(.+?)\]/is','<'.$data[0].'="?page=$1">$2</a>',$this->_code); } //$this->_code = preg_replace('/\['.$tag.'(.+?)\]/is','<'.$data[0].'="/$1">$1</a>',$this->_code);//FIX ME } } function _parse_tags(){ foreach($this->tags as $old=>$new){ $ex = explode(' ',$new); $this->_code = preg_replace('/\['.$old.'\](.+?)\[\/'.$old.'\]/is','<'.$new.'>$1</'.$ex[0].'>',$this->_code); } } function _parse_mapped(){ foreach($this->mapped as $tag=>$data){ $reg = '/\['.$tag.'\](.+?)\[\/'.$tag.'\]/is'; if($data[2]){ $this->_code = preg_replace($reg,'<'.$data[0].' '.$data[1].'="$1">$1</'.$data[0].'>',$this->_code); } else{ $this->_code = preg_replace($reg,'<'.$data[0].' '.$data[1].'="$1">',$this->_code); } } } function _parse_tags_with_att(){ foreach($this->tags_with_att as $tag=>$data){ $this->_code = preg_replace('/\['.$tag.'=(.+?)\](.+?)\[\/'.$tag.'\]/is','<'.$data[0].' '.$data[1].'="$1">$2</'.$data[0].'>',$this->_code); } } function _parse_smilies(){ if($this->parse_smilies){ foreach($this->smilies as $s=>$im){ $this->_code = str_replace($s,'<img src="'.$im.'" alt="" />',$this->_code); } } } function _parse_links(){ if($this->auto_links){ $this->_code = preg_replace('/([^"])(http:\/\/|ftp:\/\/)([^\s,]*)/i','$1<a href="$2$3">$2$3</a>',$this->_code); $this->_code = preg_replace('/([^"])([A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4})/i','$1<a href="mailto:$2">$2</a>',$this->_code); } } function addSand($old,$new){ $this->tags[$old] = $new; } function addinternal($bb,$html,$att){ $this->internal[$bb] = array($html,$att); } function addTag($old,$new){ $this->tags[$old] = $new; } function addMapped($bb,$html,$att,$end=true){ $this->mapped[$bb] = array($html,$att,$end); } function addTagWithAttribute($bb,$html,$att){ $this->tags_with_att[$bb] = array($html,$att); } function addSmiley($code,$src){ $this->smilies[$code] = $src; } } As you can see all it really dose is gos though the code and replaces the tags with there html alteritives but the thing is i want to be able to add a function to it that will protect certan sections of the code from being parsed. the page is call with file_get_contents so here is what i use to call it below $full = $config["path"] . $page . $config["ext"]; if (!is_file($full) || is_dir($full) || !file_exists($full)){ echo $fail['404']; } else { // Send to parser or render page contents // if(!$_REQUEST['act'] == 'Edit'){ if($config["syntax"] == 'Enabled'){ $raw_syntax = file_get_contents($full); $_syntax = new Parser(); $res = $_syntax->parse($raw_syntax); echo $res; }else{ require_once($full); } } } if you solve this for me many many thanks!!!
  9. OMG dude i love you!!!!!!!!!!!!!!!!!!!!!!!!!!!! this thing has had me shit fitin for a week and now it works!!!!!!!!!!!! thank you so much
  10. hi i am using a light weight bbcode parser called http://www.webtech101.com/PHP/simple-bb-code and i've ran into a big prob. i writ a simple file editor so i can type in bbcode and then the parser takes care of it but the prob is i don't know how i should be calling in the text file so the parser can use it. I've tried include and fopen but both don't work because $t must equal 'the raw bbcode' so using some like $t = include('file.txt'); will ether give me an error or will call the file name and script instance rather then the text in the file. so heres my script below please help me! <?php ////////////////////////////////////////////////////////////////////////////////// //Display pharsed text//////////////////////////////////////////////////////////// //error_reporting(~E_ALL); $t = fopen("file.txt","r"); require_once('engine.php'); $bb = new BB_Code(); $res = $bb->parse($t); echo "<div style='border:1px solid #CCCCCC'>$res</div>"; ////////////////////////////////////////////////////////////////////////////////// //Now lets make a form to edit the text :)//////////////////////////////////////// if($_POST['Submit']){ $open = fopen("file.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "File updated.<br />"; echo "File:<br />"; $file = file("file.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("file.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?>
×
×
  • 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.