Jump to content

doddsey_65

Members
  • Posts

    902
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by doddsey_65

  1. Yes, it was only a few hours worth of coding. Just really experimenting with different methods. The next update includes a save of background image choice and the option to add a url as the background image.
  2. when running a query use an "or die()" statement. If there is an error the script will abort and the error message aswell as a line number will be displayed. Example: $sql = ""; mysql_query($sql) or die(mysql_error());
  3. ive now added the option to bookmark topics. The layout of the list needs some graphical work but the actual function works. When saving a discussion the page is reloaded because a cookie is added. I will be adding the option to delete these bookmarks soon.
  4. I was thinking of adding some sort of tracking system so you can get quick access to discussions you have commented on. The only way to do this would be with cookies (since there is no login) in a sort of bookmarking for discussions.
  5. ive thought about the viability of this. At the minute it shows the first 100 discussions ordered by the time they were posted. I will be changing this to the first 100 updated discussions. Also old discussions will be added to an archive list so they can still be replied to. Also if the display gets too cluttered and confusing you can click sort to organize the results in a tabular way.
  6. okay the image is now a background image, and I have incorporated more jquery
  7. I did make it a bg image but with varying sizes of screen resolution i would require a fixed width site for it to be centered. having it as an image means i can position it centerally whatever the screen width.
  8. fair enough, you can now drag the discussions around.
  9. sorry forgot i protected it during development. The password has been removed.
  10. Heres a new concept project i thought of last night while trying to sleep. http://asimpleforum.co.uk/dit basically its a discussion forum stripped of all the unneeded parts. No need to register or login, simply click new discussion at the bottom and start a discussion. or you can take part in a discussion already posted. Simply double click on it to view the content and reply. All discussions are scattered about randomly on the page. The newest ones are more forward than the older ones, and ones posted today will appear orange(y). Clicking on one will bring it to the front so you can see more of it. Clicking shuffle at the bottom will shuffle all discussions randomly. There is no way of stopping spam, nor is there a way to track discussions, these will be added later. So what do you think?
  11. Having used unix timestamps in the past formatting the date used to be easy. But since converting to mysql DATETIME im struggling to format it properly. I basically pull the date from the database, convert it using strtotime(), then convert it to a date using date(). The problem is that when i use 'a' to display am/pm the time almost always says am. If the time is 11am then it will display 11am. If it's 12pm then it will display 12pm, but if it comes to 1pm and above it will revert back to 1am. This is the date string I use: date('jS M Y g:i a'); is this due to the fact that mysql DATETIME uses 24 hour clock ('H'), if so is there a way around this?
  12. they were added by the forum. Didnt know they were there sorry.
  13. there are many options for something like this so i will just throw one out there: $url = preg_replace('|http:\/\/|i', '[url=http://www.youtube.com/watch?v=ty62YzGryU4]http://www.youtube.com/watch?v=ty62YzGryU4[/url]', $url); if(preg_match('|watch|i', $url)) { $url_parts = explode('=', $url); $vid_code = $url_parts[1]; } else { $url_parts = explode('/', $url); $vid_code = $url_parts[1]; } first i removed the http from the url so the else statement doesnt throw up too many array keys. if the word watch is in the url then we split the url at the "=" sign which gives an array with 2 keys, the code is the second key. if the word watch isn't in the url then we split the url at the "/" (that's why i removed the http) and the code is the second key in the array
  14. im working on a php syntax highlighter for a bbeditor. basically all text within code tags will be placed into the function parse_code(). It works fine until i add the code to instantiate a class within the tags. This is supposed to just be a string but it looks like the 'e' modifier of preg_replace is recognising the code as php and executing it. Is there any way around this? Heres the regex: '|\[code=(.*?)\](.*?)\[\/code\]|sie', 'self::parse_code("\\1", "\\2")', and the parse_code method public static function parse_code($code, $content) { $words = explode(' ', $content); dump($words); $keywords = array( 'php_words' => array( 'function', 'echo', 'class', 'new', ), ); foreach($words as $key => $value) { foreach($keywords as $group => $array) { foreach($array as $keyword) { $words[$key] = preg_replace('|'.$keyword.'|si', '<span class="'.$group.'">'.$keyword.'</span>', $words[$key]); } } $words[$key] = preg_replace("|\\'(.*?)\\'|si", '<span class="string">\'\\1\'</span>', $words[$key]); } $content = implode(' ', $words); $lines = explode("\n", $content); unset($lines[0]); for($i=1; $i<count($lines); $i++) { $lines[$i] = '<p class="line_number">'.$i.'. </p>'.$lines[$i]; } $content = implode("\n", $lines); return stripslashes('<blockquote class="code"><div class="code_header"><p>'.$code.'</p></div><div class="code_content"><p>'.$content.'</p></div></blockquote>'); }
  15. For my forum I used the phpbb template engine, which I grew to love. But I wasn't happy with including another forums code within mine. I have started to create my own template engine which is based off theirs. I am not using any of their code and have deleted phpbb off my system so i don't feel like cheating. The class below will take a file, replace the content with the variables you specify (including looped content) and then create a php cached file. If anyone has any pointers or crits so far then please let me know. Thanks /** * Asf Template * * This file handles the setting of the main template * and the setting af template specific variables to * be handled in the cached file */ class Asf_Template { /** * Holds the name of the template file * to be included within current page */ public $tpl_file = null; /** * this is an array of all the variables * that are used to replace the placeholders * in the html template file */ public $tpl_data = array(); /** * The name of the template we are using */ public $template = null; /** * The extension of the template files */ public $tpl_ext = '.html'; /** * The directory in which cached files are stored */ public $cache_dir = './cache'; /** * Sets the template to be used * * @params $template string * @return void */ public function set_template($template) { $this->template = $template; } /** * Sets the variables which are used * to replace the placeholders in the html file * * @params $vars array * @return void */ public function set_vars(array $vars) { if(!is_array($vars)) { return false; } foreach($vars as $key => $val) { $this->tpl_data[$key] = $val; } } /** * Sets the variables which are used * to replace the placeholders in the html file * * @params $loop string * @params $vars array * @return void */ public function loop_vars($loop, array $vars) { if(!is_array($vars)) { return false; } foreach($vars as $key => $val) { $this->tpl_data[$loop][$key][] = $val; } } /** * Sets the html file to be used * * @params $file string * @return void */ public function set_file($file) { $this->tpl_file = $file; } /** * Replaces the placeholders in the html file * with the template variables and caches the * file * * @return $cached string */ public function render() { $content = file_get_contents($this->tpl_file.$this->tpl_ext); foreach($this->tpl_data as $key => $val) { if(preg_match('|\{'.$key.'\}|i', $content)) { $content = preg_replace('|\{'.$key.'\}|i', "<?php echo \$this->tpl_data['$key']; ?>", $content); } echo $key.'<br />'; if(preg_match('|\<!-- BEGIN '.$key.' --\>|i', $content)) { foreach($this->tpl_data[$key] as $l_key => $l_val) { for($i=0; $i<count($this->tpl_data[$key][$l_key]); $i++) { $content = preg_replace('|\{'.$key.'.'.$l_key.'\}|i', "<?php foreach(\$this->tpl_data['$key']['$l_key'] as \$var){ echo \$var; } ?>", $content); } } } } $handle = fopen($this->cache_dir.'/'.$this->tpl_file.'_tpl.php', 'w'); fwrite($handle, $content); fclose($handle); include($this->cache_dir.'/'.$this->tpl_file.'_tpl.php'); dump($this->tpl_data); } } // instantiate the class $template = new Asf_Template; // set the template to be used $template->set_template('default'); // set the tpl file to be rendered $template->set_file('test'); // set some template specific vars $template->set_vars(array( 'HELLO' => 'Howdy!', 'FRENCH' => 'Bonjoúr', ) ); // set a template specific loop for($i=0; $i<10; $i++) { $template->loop_vars('loop', array( 'NUMBER' => $i, ) ); } // render the template $template->render(); So the html file would look like this: {HELLO} {FRENCH} <!-- BEGIN loop --> {loop.NUMBER} <!-- END loop --> which would ouput a php cache file with this content <?php echo $this->tpl_data['HELLO']; ?> <?php echo $this->tpl_data['FRENCH']; ?> <!-- BEGIN loop --> <?php foreach($this->tpl_data['loop']['NUMBER'] as $var){ echo $var; } ?> <!-- END loop --> And the output to the browser is: Howdy!Bonjoúr 0123456789 Any tips or suggestions then? I plan on extending this code to perform more functions.
  16. There were no backups of any kind available. And considering how long it took me to get to that point by myself, i will not be starting it again. Far too much work.
  17. if its done right and kept within the <head> tags then there's nothing wrong with it
  18. you cant include php code in a css file. You could use the php in a html document and create inline styling: <style type="text/css"> body { background-color: <?php echo $color; ?>; } </style>
  19. i had a feeling that was coming after i posted that
  20. can you change my username to a bright blue one?
  21. perhaps you would recieve help if you asked a question
  22. well ive just recovered from a virus ( didnt have any protection ), which meant a full system reboot. So all files on my local system were lost. Unfortunatly i had removed all files from the live server so i could work on the current bugs knowing there wouldnt be any new bugs yet. In short, i have lost ASF.
  23. if you are processing the data on the same page as the form then you could just use action=""
  24. The above answer is good but please dont follow the code to the letter. use of the short tags "<?" can cause alot of problems if your server doesnt have the short_tags option enabled. Get into the habbit of using <?php
  25. Should do now. I fixed it locally but forgot to upload the new image to the server. Thanks
×
×
  • 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.