Jump to content

KingOfHeart

Members
  • Posts

    222
  • Joined

  • Last visited

Everything posted by KingOfHeart

  1. I understand what the functions are suppose to do. I haven't worked with it enough to just write my own script. Answer me this, do you yourself see a major fault with the script? If it's simple, just tell me please. If it's complicated..well, I'll just google for more menu scripts and just fiddle with it.
  2. I hover over the menu with my mouse, all it does is highlight the main buttons. Nothing drops down so all I see is "home", "tutorials", and "more" I don't see the rest. No CSS, no tutorial, no About us, and no contact us.. I'm still a newbie so can't really debug..all I plan on doing is changing link names, playing with the x/y, just taking it one step at a time and see how custom I can make it.
  3. I found this script online and while everything looks ok, for some reason the menu is not working. <html> <head> <title>MyMenu</title> <!--The CSS code.--> <style type="text/css" media="screen"> #mymenu { margin: 0; padding: 0; } #mymenu li { margin: 0; padding: 0; list-style: none; float: left; } #mymenu li a { display: block; margin: 0 1px 0 0; padding: 4px 10px; width: 80px; background: #bbbaaa; color: #ffffff; text-align: center; } #mymenu li a:hover { background: #aaddaa} #mymenu ul { position: absolute; visibility: hidden; margin: 0; padding: 0; background: #eeebdd; border: 1px solid #ffffff} #mymenu ul a { position: relative; display: block; margin: 0; padding: 5px 10px; width: 80px; text-align: left; background: #eeebdd; color: #000000; } #mymenu ul a:hover { background: #aaffaa; } </style> <!--The end of the CSS code.--> <!--The Javascript menu code.--> <script type="text/javascript"> //variables' declaration var timer = 0; var item = 0; //function for opening of submenu elements function openelement(num) { //checks whether there is an open submenu and makes it invisible if(item) item.style.visibility = 'hidden'; //shows the chosen submenu element item = document.getElementById(num); item.style.visibility = 'visible'; } // function for closing of submenu elements function closeelement() { //closes the open submenu elements and loads the timer with 500ms timer = window.setTimeout('if(item) item.style.visibility = 'hidden';',500); } //function for keeping the submenu loaded after the end of the 500 ms timer function keepsubmenu() { window.clearTimeout(timer); } //hides the visualized menu after clicking outside of its area and expiring of the loaded timer document.onclick = closeelement; </script> <!--END of CSS code--> </head> <body> <!--HTML code for the menu --> <ul id="mymenu"> <li><a href="http://siteground.com/">Home</a> </li> <li><a href="http://www.siteground.com/tutorials/" onmouseover="openelement('menu2')">Tutorials</a> <ul id="menu2" onmouseover="keepsubmenu()" onmouseout="closeelement()"> <a href="http://www.siteground.com/tutorials/cssbasics/index.htm">CSS</a> <a href="http://www.siteground.com/tutorials/flash/index.htm">Flash</a> </ul> </li> <li><a href="#" onmouseover="openelement('menu3')" onmouseout="closeelement()">More</a> <ul id="menu3" onmouseover="keepsubmenu()" onmouseout="closeelement()"> <a href="http://www.siteground.com/about_us.htm">About Us</a> <a href="http://www.siteground.com/contact_us.htm">Contact Us</a> </ul> </li> </ul> <div style="clear:both"></div> <!--the end of the HTML code for the menu --> </body> </html> http://king-trading.freeoda.com/TF2_quiz/trade_widow.html ---------------------------------- Also this entire fire can be turned into a javascript file, right? How do I call it in the body area?
  4. Tried different commands and nothing seemed to work as good as ../ so I guess I'll just continue using that method.
  5. You have to set it? What do I set it to? That's the command I'm looking for
  6. You sure that's it? I just used this and got an error. require $basedir . "/db.php"; but this works,, require "../db.php";
  7. If I'm in a subfolder on my site how do I call a file from the base folder? I'm in the folder "Scripts" for example and I want to call a function from the parent folder. I know you could use "../" if I remember right, but I'm looking for a php function. It would use scripts something like this... include $basefunction . "/index.php"
  8. I found something shorter and simpler. preg_match_all("/(?<!\\\\)\[img(?:\s+)width(?::\d+)?=(.*?)(?:\s+)height(?::\d+)?=(.*?)(?:\s+)src(?::\w+)?=(.*?)\]/si", $message, $matches); foreach ($matches[1] as $num) { $wid = "width=" . $num; $message = ($num > 700)? str_replace("$wid", "width=700", $message) : $message; } foreach ($matches[2] as $num2) { $hei = "height=" . $num2; $message = ($num2 > 700)? str_replace("$hei", "height=700", $message) : $message; } I decided to remove px and % but don't know how to make the bbcode work only if you use numbers. I started to use d+ but it still converted the bbcode into html. I got to go to bed now but any idea how? '/(?<!\\\\)\[img(?:\s+)width(?::\d+)?=(.*?)(?:\s+)height(?::\d+)?=(.*?)(?:\s+)src(?::\w+)?=(.*?)\]/si' => "<img width=\"\\1\" height=\"\\2\" src=\"\\3\"/>", I want to convert it to an image with the width and height < this works fine and I want to convert to plain text as < no idea how Hope all I have to do is add another symbol to the search.
  9. I don't consider myself ready to use something like this. If it becomes an issue I'll use non-preg or remove the rights for the user to use this function. Unless if you think you can work with me, I'm going to just pass. Also besides px, they're allowed to use % as well
  10. Sweet, I got the image preg to work finally....Not sure if this is how you would do it, but at least now I can use sizes if needed...I'll try to see if I can use your function '/(?<!\\\\)\[img(?::\w+)?=(.*?)\]/si' => "<img src=\"\\1\" alt=\"\\1\"/>", '/(?<!\\\\)\[img(?:\s+)width(?::\w+)?=(.*?)(?:\s+)height(?::\w+)?=(.*?)(?:\s+)src(?::\w+)?=(.*?)\]/si' => "<img width=\"\\1\" height=\"\\2\" src=\"\\3\"/>",
  11. Your actually getting one step ahead so let me state the problem. As of right now when I use it returns it as meaning plain text...it did not find this exact match. -------------- I was wondering how I shoujld go about setting limits. Haven't used too much preg yet..would I just use it like this... function bbcode2html($message) { $preg = array( '/(?<!\\\\)\[img(?::\s+)? width(?::\w+)?=(.*?)(?::\s+)? height(?::\w+)?=(.*?)(?::\s+)? src(?::\w+)?=(.*?)\]\]/si' => "<img width=\"\\1\" height=\"\2\" src=\"\\3\"/>" ); preg_replace_callback(array_keys($preg), array_values($preg), $message);// < do I call it like this??? $message = preg_replace(array_keys($preg), array_values($preg), $message); return $message; } $new = preg_replace_callback('...', function($matches) { // need the src, width, and height to work if (!isset($matches[1], $matches[2], $matches[3])) { return $matches[0]; // unchanged } list(, $width, $height, $src) = $matches; // you may want to check for a valid width and height here // eg, is there a risk that someone will use width=9999999px? if (ctype_digit($width)) { $width .= "px"; } if (ctype_digit($height)) { $height .= "px"; } return "<img src=\"" . htmlentities($src) . "\" style=\"width: {$width}; height: {$height}\" />"; }, $old); ------------------------- I think I'll create a shorter function like [test ] and make it only work if I have a space after the word test and work my way on from there
  12. The w+ worked in all the other scripts so far but none of the scripts required spacing. The w+ allowed the numbers after the equal sign if I understood correct. I know \s+ or maybe it's just \s that's used to check for spacing but not sure yet which symbols to use next to it. Guess I could/should replace the ones that require numbers with a d+ right if I only allowed numbers.. but I might also want to allow things like this "" or "" as an option.
  13. Figured the backslash part since I used it lots of times in other scripts. I understand now for the colon. Still can't get the required space so far..trying different combinations. '/(?<!\\\\)\[img(?::\s+)? width(?::\w+)?=(.*?)(?::\s+)? height(?::\w+)?=(.*?)(?::\s+)? src(?::\w+)?=(.*?)\]\]/si' => "<img width=\"\\1\" height=\"\2\" src=\"\\3\"/>",
  14. BTW, what does the :: mean?? I managed to create some new bbcodes but not 100% sure on the required 1 space thing. '/(?<!\\\\)\[img(?::\s+)width(?::\w+)?=(.*?)(?::\s+)height(?::\w+)?=(.*?)(?::\s)src(?::\w+)?=(.*?)\]\]/si' => "<img width=\"\\1\" height=\"\2\" src=\"\\3\"/>", < this should output an image with a width of 24 and a height of 40. I manged to create a bbode without the width and height so far.
  15. Love2c0de that script wouldn't make sence since I need $admin to always equal that session...ok, will change the case for session. edit: the caps made the difference..I was a little rusty
  16. Once you set a session it suppose to stay set, right? <? if(!isset($_SESSION)) session_start(); $login = htmlentities($_GET['login']); if($login == "admin") $_Session['admin'] = true; $admin = $_Session['admin']; echo $_Session['admin']; if($admin != true) return; echo" Welcome Admin!"; ?> So for testing purpose I set the admin session to 1 once I use login == "admin". It sets fine, the I reload the page and I'm not in admin mode, Is there more to it or what?
  17. Now that looks more like it I will copy and save all info.
  18. I found a script I used, now all I need help with is for someone to teach me how it works exactly. function bbcode2html($message) { $preg = array( '/(?<!\\\\)\[color(?::\w+)?=(.*?)\](.*?)\[\/color(?::\w+)?\]/si' => "<span style=\"color:\\1\">\\2</span>", '/(?<!\\\\)\[size(?::\w+)?=(.*?)\](.*?)\[\/size(?::\w+)?\]/si' => "<span style=\"font-size:\\1pt\">\\2</span>", '/(?<!\\\\)\[font(?::\w+)?=(.*?)\](.*?)\[\/font(?::\w+)?\]/si' => "<span style=\"font-family:\\1\">\\2</span>", '/(?<!\\\\)\[align(?::\w+)?=(.*?)\](.*?)\[\/align(?::\w+)?\]/si' => "<div style=\"text-align:\\1\">\\2</div>", '/(?<!\\\\)\[b(?::\w+)?\](.*?)\[\/b(?::\w+)?\]/si' => "<span style=\"font-weight:bold\">\\1</span>", '/(?<!\\\\)\[i(?::\w+)?\](.*?)\[\/i(?::\w+)?\]/si' => "<span style=\"font-style:italic\">\\1</span>", '/(?<!\\\\)\[u(?::\w+)?\](.*?)\[\/u(?::\w+)?\]/si' => "<span style=\"text-decoration:underline\">\\1</span>", '/(?<!\\\\)\[center(?::\w+)?\](.*?)\[\/center(?::\w+)?\]/si' => "<div style=\"text-align:center\">\\1</div>", // [email] '/(?<!\\\\)\[email(?::\w+)?\](.*?)\[\/email(?::\w+)?\]/si' => "<a href=\"mailto:\\1\" class=\"bb-email\">\\1</a>", '/(?<!\\\\)\[email(?::\w+)?=(.*?)\](.*?)\[\/email(?::\w+)?\]/si' => "<a href=\"mailto:\\1\" class=\"bb-email\">\\2</a>", // [url] '/(?<!\\\\)\[url(?::\w+)?\]www\.(.*?)\[\/url(?::\w+)?\]/si' => "<a href=\"http://www.\\1\" target=\"_blank\" class=\"bb-url\">\\1</a>", '/(?<!\\\\)\[url(?::\w+)?\](.*?)\[\/url(?::\w+)?\]/si' => "<a href=\"\\1\" target=\"_blank\" class=\"bb-url\">\\1</a>", '/(?<!\\\\)\[url(?::\w+)?=(.*?)?\](.*?)\[\/url(?::\w+)?\]/si' => "<a href=\"\\1\" target=\"_blank\" class=\"bb-url\">\\2</a>", // [img] '/(?<!\\\\)\[img(?::\w+)?\](.*?)\[\/img(?::\w+)?\]/si' => "<img width = 100 height = 100 src=\"\\1\" alt=\"\\1\" class=\"bb-image\" />", '/(?<!\\\\)\[img(?::\w+)?=(.*?)x(.*?)\](.*?)\[\/img(?::\w+)?\]/si' => "<img width=\"\\1\" height=\"\\2\" src=\"\\3\" alt=\"\\3\" class=\"bb-image\" />", // [list] '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\*(?::\w+)?\](.*?)(?=(?:\s*<br\s*\/?>\s*)?\[\*|(?:\s*<br\s*\/?>\s*)?\[\/?list)/si' => "\n<li class=\"bb-listitem\">\\1</li>", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\/list(?!u|o)\w+)?\](?:<br\s*\/?>)?/si' => "\n</ul>", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\/list:u(:\w+)?\](?:<br\s*\/?>)?/si' => "\n</ul>", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\/list:o(:\w+)?\](?:<br\s*\/?>)?/si' => "\n</ol>", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?!u|o)\w+)?\]\s*(?:<br\s*\/?>)?/si' => "\n<ul>", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list:u(:\w+)?\]\s*(?:<br\s*\/?>)?/si' => "\n<ul class=\"bb-list-unordered\">", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list:o(:\w+)?\]\s*(?:<br\s*\/?>)?/si' => "\n<ol>", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?:)?(:\w+)?=1\]\s*(?:<br\s*\/?>)?/si' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-d\">", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?:)?(:\w+)?=i\]\s*(?:<br\s*\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-lr\">", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?:)?(:\w+)?=I\]\s*(?:<br\s*\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-ur\">", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?:)?(:\w+)?=a\]\s*(?:<br\s*\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-la\">", '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?:)?(:\w+)?=A\]\s*(?:<br\s*\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-ua\">", //line breaks '/\n/' => "<br>", // escaped tags like \[b], \[color], \[url], ... '/\\\\(\[\/?\w+(?::\w+)*\])/' => "\\1" ); $message = preg_replace(array_keys($preg), array_values($preg), $message); return $message; } */ function bbcode2html($message) { $bbcode = array( "'\[center\](.*?)\[/center\]'is" => "<center>\\1</center>", "'\[left\](.*?)\[/left\]'is" => "<div style='text-align: left;'>\\1</div>", "'\[right\](.*?)\[/right\]'is" => "<div style='text-align: right;'>\\1</div>", "'\[pre\](.*?)\[/pre\]'is" => "<pre>\\1</pre>", "'\[b\](.*?)\[/b\]'is" => "<b>\\1</b>", "'\[quote\](.*?)\[/quote\]'is" => "<div class='top'><b>Quote:</b><hr>\\1</div>", "'\[i\](.*?)\[/i\]'is" => "<i>\\1</i>", "'\[u\](.*?)\[/u\]'is" => "<u>\\1</u>", "'\[s\](.*?)\[/s\]'is" => "<del>\\1</del>", "'\[url\](.*?)\[/url\]'is" => "<a href='\\1' target='_BLANK'>\\1</a>", "'\[url=(.*?)\](.*?)\[/url\]'is" => "<a href=\"\\1\" target=\"_BLANK\">\\2</a>", "'\[page=(.*?)\](.*?)\[/page\]'is" => "<a href=\"http://openzelda.thegaminguniverse.org/\\1\" target=\"_BLANK\">\\2</a>", "'\[img\](.*?)\[/img\]'is" => "<img border=\"0\" src=\"\\1\">", "'\[img=(.*?)\]'" => "<img border=\"0\" src=\"\\1\">", "'\[email\](.*?)\[/email\]'is" => "<a href='mailto: \\1'>\\1</a>", "'\[size=(.*?)\](.*?)\[/size\]'is" => "<span style='font-size: \\1;'>\\2</span>", "'\[font=(.*?)\](.*?)\[/font\]'is" => "<span style='font-family: \\1;'>\\2</span>", "'\[color=(.*?)\](.*?)\[/color\]'is" => "<span style='color: \\1;'>\\2</span>", "'\n'is" => "<br>", "' 'is" => " ", "' 'is" => " ", "'\[list=o\](.*?)\[/list\]'is" => "<ol>\\1</ol>", "'\[list=u\](.*?)\[/list\]'is" => "<ul>\\1</ol>", "'\[list\](.*?)\[/list\]'is" => "<ol>\\1</ol>", "'\[li\](.*?)\[/li\]'is" => "<li>\\1</li>", "'\[code\](.*?)\[/code\]'is" => "<div class='code'>\\1</div>", "'\[spoiler=(.*?)\](.*?)\[/spoiler\]'is" => "<a href=\"javascript:unhide('\\1');\">\\2</a>", "'\[hide=(.*?)\](.*?)\[/hide\]'is" => "<div id='\\1' class='hidden'>\\2</div>" ); $message = preg_replace(array_keys($bbcode), array_values($bbcode), $message); return $message; } What does the \\1 and \\2 mean? (.*?) < where can I find out about this? What other symbols are there?
  19. Fine..then how about about turning bbcode into html output? [b]This area would be bolded[/b] [color = red]This color would be red[/color] etc. How would I use preg for that?
  20. I need it split up and I want, I really want to use preg_match. So often I needed this function but too confused to use it other then copy & paste
  21. preg_match/preg_match_all ........something about this function always screw me with understanding it, way too many symbols. So when helping me, try to simplfy when I need to do to understand. http://tf2spreadsheet.blogspot.com/ I want to extract the quality, class, item, refined, alt version(notes not needed) How do I echo all this data? Using file_get_contests I can get all the main part, but now how do I split it up? Please don't link me to the "http://php.net/manual/en/function.preg-match-all.php" Too many patterns at once..any way we can break it up to teaching me one step at a time for all the symbols I need to use and stuff?
  22. I hate these time limits where I can't modify my post. I wanted to explain it more. I used to have a wiki file with the name, function, and description for each coding command. I now need to transfer that data to a mysql field. So I need to search through this data, ignore the HTML, and just get the data from the name, function, and description. After I receive that data, instead of echoing it I'll just insert it into a mysql table(already know how to do this) The name of the function starts after <a name=. The function itself starts after <table style. Lastly the description starts after <p>. That's why I used strpos but probably doesn't work in this case.
  23. I need to search through a text file and output certain text. My current script doesn't work well at all. <? $file = 'flist.txt'; $handle = @fopen($file, "r"); $names = array(); $func = array(); $desc = array(); $nme; $fnc; $dsc; $s = -1; $e = -1; $n = 0; if ($handle) { while (($buffer = fgets($handle, 4096)) !== false) { if($nme == 0) { if(strpos($buffer,"<a name") !== false) { $nme = 1; $s = strpos($buffer,"<a name"); } } else if($nme == 1) { if(strpos($buffer,"</span>") !== false) { $nme = 2; $e = strpos($buffer,"</span>"); $num = $e - $s; $names[$n] = strip_tags(substr($buffer,$s,$num)); } } else if($nme == 2) { if($fnc == 0) { if(strpos($buffer,"<table style") !== false) { $fnc = 1; $s = strpos($buffer,"<table style"); } } else if($fnc == 1) { if(strpos($buffer,"</td>") !== false) { $fnc = 2; $e = strpos($buffer,"</td>"); $num = $e - $s; $func[$n] = strip_tags(substr($buffer,$s,$num)); } } else if($fnc == 2) { if($dsc == 0) { if(strpos($buffer,"<p>") !== false) { $dsc = 1; $s = strpos($buffer,"<p>"); } } else if($dsc == 1) { if(strpos($buffer,"</p>") !== false) { $fnc = 0; $nme = 0; $dsc = 0; $e = strpos($buffer,"</p>"); $num = $e - $s; $desc[$n] = strip_tags(substr($buffer,$s,$num)); } } } } } if (!feof($handle)) { echo "Error: unexpected fgets() fail\n"; } fclose($handle); $n = 0; while($n < 100) { echo $names[$n] . "<br>"; echo $func[$n] . "<br>"; echo $desc[$n] . "<p>"; $n ++; } } ?> 4096 gets the data for each line, right? Well some of my data uses two lines. After all the searching is done I need it to output $names, $func, and $desc in plain text.
  24. If I did that how can I use tags, also it makes a scroll box. http://openzelda.thegaminguniverse.org/tutorials.php?name=&type=0&order=0&dir=0&id=3
  25. I made a little codebox by using a . Only problem is when I insert a code and need a tab, it does not create any. Now I could just create a [tab] function but it would make long codes very annoying to add in. Inside this codebox I'll be using tags so I can colorize certain words, otherwise I'd just use a pre tag. So how can I get tabs to show up as tabs but only inside of this code box. function bbcode2html($message) { $bbcode = array( "'\[center\](.*?)\[/center\]'is" => "<center>\\1</center>", "'\[left\](.*?)\[/left\]'is" => "<div style='text-align: left;'>\\1</div>", "'\[right\](.*?)\[/right\]'is" => "<div style='text-align: right;'>\\1</div>", "'\[pre\](.*?)\[/pre\]'is" => "<pre>\\1</pre>", "'\[b\](.*?)\[/b\]'is" => "<b>\\1</b>", "'\[quote\](.*?)\[/quote\]'is" => "<div class='top'><b>Quote:</b><hr>\\1</div>", "'\[i\](.*?)\[/i\]'is" => "<i>\\1</i>", "'\[u\](.*?)\[/u\]'is" => "<u>\\1</u>", "'\[s\](.*?)\[/s\]'is" => "<del>\\1</del>", "'\[url\](.*?)\[/url\]'is" => "<a href='\\1' target='_BLANK'>\\1</a>", "'\[url=(.*?)\](.*?)\[/url\]'is" => "<a href=\"\\1\" target=\"_BLANK\">\\2</a>", "'\[img\](.*?)\[/img\]'is" => "<img border=\"0\" src=\"\\1\">", "'\[img=(.*?)\]'" => "<img border=\"0\" src=\"\\1\">", "'\[email\](.*?)\[/email\]'is" => "<a href='mailto: \\1'>\\1</a>", "'\[size=(.*?)\](.*?)\[/size\]'is" => "<span style='font-size: \\1;'>\\2</span>", "'\[font=(.*?)\](.*?)\[/font\]'is" => "<span style='font-family: \\1;'>\\2</span>", "'\[color=(.*?)\](.*?)\[/color\]'is" => "<span style='color: \\1;'>\\2</span>", "'\n'is" => "<br>", "'\[list=o(.*?)\](.*?)\[/list\]'is" => "<ol>\\2</ol>", "'\[list=u(.*?)\](.*?)\[/list\]'is" => "<ul>\\2</ol>", "'\[li\](.*?)\[/li\]'is" => "<li>\\1</li>", "'\[code\](.*?)\[/code\]'is" => "<div class='code'>\\1</div>", ); $message = preg_replace(array_keys($bbcode), array_values($bbcode), $message); return $message; }
×
×
  • 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.