Jump to content

Infected.Shadow

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Everything posted by Infected.Shadow

  1. It's a string operator used to concatenate strings. http://php.net/manual/en/language.operators.string.php
  2. In the edit form leave out parseBBCode. Problem solved... Oops, my skim reading led me to believe you were storing it in the database after you parsed it. Carry on. Haha, nope. Just rendering.
  3. While handy, that's going to take significantly more space to store. Takes more space in the database yes, but usually that's never going to be a big issue. Though a better way might be store the original text in the database then implement some sort of caching system to store the rendered text that way you just take out the time of querying the database if there are no new posts. In the edit form leave out parseBBCode. Problem solved...
  4. Yeah I ended up finding an example in the comments of highlight_string on the php manual. As for the other point: That's something I never even thought of, so thank you for that idea. I'd been encoding it as I stored it because I figured that was more secure at the time (which I recall was about 4am when the caffeine was wearing off )
  5. I'm attempting to add syntax highlighting to my bbcode function. I started with the general basis for a bbcode function that there are a million tutorials on. To make things simpler I took out the rest of the bbcode tags. <?php //Eventually will need to add some logic to color the code tags function parseBBCode($string) { $search = array( '/\[code\](.*?)\[\/code\]/is', ); $replace = array( '<div class="code"><code>$1</code></div>' ); //Render the tabs in html //may need to find a better place for this in the future $string = str_replace(' ', ' ', $string); return preg_replace($search, $replace, $string); } ?> I've tried using the highlight_string() function but it never highlights it. I assumed this was because when I store the data in the database I used htmlentities() on the text. So I also tried the following to no avail: '<div class="code">'.highlight_string(html_entity_decode('$1'), true).'</div>' And this where I'm calling the function: $posts = ''; while($post = $db->fetchArray($content)) { $posts .= '<span style="font-size: 22px;">'.$post['title'].'</span><br /> <hr />'; $posts .= '<br />'.nl2br(stripslashes(parseBBCode($post['post']))).'<br /><br /><hr />'; $user = $db->query('SELECT username FROM isnet_users WHERE id = '.$post['poster_id'].';'); $user = $db->fetchArray($user); $posts .= '<strong>Author: </strong>'.$user['username'].'<br /><br />'; } //end while I've tried a few other methods that have produced syntax highlighting but have broken other posts that don't need it. So is there something I'm just obliviously missing?
  6. It's a tad hard to understand what you are trying to accomplish. Perhaps posting the code you've been working with could help make it clearer what you are trying to accomplish. From what I can gather: It sounds like you're trying to reduce the amount of html used in the php file, and some one suggested you use a class. They might have been referring to a template class. If that is the case then I personally suggest following tutorial: http://www.pixel2life.com/publish/tutorials/457/simple_template_engine_find_and_replace_variables/
  7. For some reason when this script runs, the main directory is listed correctly. All the folders are marked as directories. But when I go down to one of those directories, the directories in that folder are seen as files. Why is this happening on subfolders? case 'direc': $current_dir = $_GET['dir']; $dir = opendir($current_dir); echo '<strong>CURRENTLY BORWSING:</strong> '.$current_dir.'<br /><hr />'; while($file = readdir($dir)) { if(is_dir($file)) { echo '[DIR] <a href="'.$_SERVER['PHP_SELF'].'?mode=direc&dir='.$file.'">'.$file.'</a><br />'; } } $dir = opendir($current_dir); while($file = readdir($dir)) { if(!is_dir($file)) { $f = $file; $f = explode('.', $f); $filename = $f[0]; $filetype = $f[1]; echo '- <a href="'.$_SERVER['PHP_SELF'].'?mode=ss&filename='.$filename.'&filetype='.$filetype.'&fdir='.$current_dir.'">'.$file.'</a><br />'; } } break;
  8. Not sure if this relevant to your problem though it may help later: <form action="<?php echo $PHP_SELF; ?>" method="post" enctype="multipart/form-data"> Upload file: <input type="file" name="my_file" /><br /> <input type="submit" name="check_if_press" value="send_file" /> </form> I don't see $PHP_SELF declared anywhere before hand, so I think you mean to put <?php echo $_SERVER['PHP_SELF']; ?>
  9. I've been looking for one for a while. I couldn't find anything. Best thing to do is download some software you know has a module system and look at it, see how it works and such. It's really helped me get an idea of where to go with mine. This post I found is pretty old (2002), but it kinda gives you an idea of how it works on a very simple level. http://forums.devarticles.com/general-programming-help-4/oop-emergency-making-a-module-system-491.html
  10. Ah thank you so much. I'm still kind of new to variable variables with how they work at times. Much thanks again.
  11. I'm currently in the process of coding a module sys for my site. So far I have it detecting and loading everything perfectly. Though I've recently hit a brick wall. <?php class module { var $moduleList; var $functionList; var $modCount; var $path = 'modules/'; function module() { $this->loadModules(); } // emd module()) private function loadModules() { $handle = @opendir($this->path) or die('Unable to open '.$this->path); $this->modCount = 0; while($file = readdir($handle)) { // !!!!! Why is this working? !!!!! // !is_dir($file) is detecting directories when it should not be... // further investigation needed later. Perhaps a better way to check. // ***slight fix by reverting back to just single file modules instead of modules in directories if(!is_dir($file)) { $temp = explode('.', $file); $this->moduleList[$this->modCount] = $temp[0]; $this->modCount++; } } closedir($handle); } // end loadModule()) // This function is for testing purposes only. To be moved to administrator panel in the future... public function listModules() { echo '<strong>'.$this->modCount.' modules loaded...</strong><br />'; for($i = 0; $i < $this->modCount; $i++) { echo $this->moduleList[$i].'<br />'; } } // end listModules() public function getModCount() { return $this->modCount; } // end getModCount() // *** Clean this up in the future public function load($module) { include($this->path.$this->moduleList[$module].'.php'); $l = new ${$this->moduleList[$module]()}; //doesn't work $k = new test(); //works (temp testing) } // end load() } // end class module ?> My problem is in the load() function. $k works fine in creating the object, where as $l is producing: I'm trying to make it so that you only need to create the object and the rest is handled in the constructor of the class. I've tested variable variables with calling functions and such, and don't see why it shouldn't work here. Am I wrong in this thinking or did I just happen to mess up some where? edit: In case it helps, here are the other two files... index.php <?php include('module.php'); $m = new module(); $m->listModules(); //implement module on/off later for($i = 0; $i < $m->getModCount(); $i++) { $m->load($i); } ?> modules/test.php <?php class test extends module { function test() { $this->display(); } function display() { echo 'Test!'; } } ?>
  12. Well perhaps you could elaborate on what you are looking for? Do you mean like: [Prev] 1 - 2 - 3 ... - 10 -11 [Next] ? ok exactly what i want is here go to http://tpa-rpg.co.cc click the splash, make an account, login and go on the left menu where it says "news comments" then under where it displays the news it shows how many pages of comments there are. i already know how to display the news and stuff but i want to be able to display the "comment pages" where ever i want on my web page. if that makes sense. So you're looking to paginate the comments? Just apply what Bendude14 said to your comments section of your code.
  13. Well perhaps you could elaborate on what you are looking for? Do you mean like: [Prev] 1 - 2 - 3 ... - 10 -11 [Next] ?
  14. This is exactly what I was looking for! Thank you!
  15. I noticed you tried '20%'. The correct format is '%20', maybe try it that way?
  16. Okay so I haven't written any code for this yet. I would also like to apologize if I'm not communicating this thoroughly. I'm finding it hard to describe the problem at hand. My problem is this: Say a user enters this into a text field: Now on most sites I've been to, it would output like that on the page. When I go to try this in my code it always ends up coming out like this: So usually I'm pulling these values from a database, so I'm wondering if there is a function in php that will keep the same formatting the user wants (Spaces, line skips, etc.). Any help would be greatly appreciated.
×
×
  • 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.