Jump to content

shoutbox!!


runnerjp

Recommended Posts

hey all...ok i have this code to retrieve the shouts posted and then its displaed as a marquee

[quote]<?php
#################################
include("shoutbox/config/config.php");
#################################

mysql_connect($host,$dbuser,$dbpass) or die(mysql_error());
// Select the database.
mysql_select_db($dbname) or die(mysql_error());
$query = "SELECT message, author, eml FROM shoutbox order by id DESC LIMIT 1";
$result = mysql_query($query);
$marquee = "";
while($r=mysql_fetch_array($result))
{
  $marquee.= $r[message]. '<a href=\"$r[eml]\">'. $r[author]. '</a>'";
}
echo "<marquee><font size='3'>". $marquee. "</font></marqee>";[/quote]

rite but the shout box i have saves the stuff in a textbox...it has instructions to make it mysql but very complex.... anyways is their away to retrieve the posts from the txt file??
Link to comment
https://forums.phpfreaks.com/topic/17764-shoutbox/
Share on other sites

[quote author=runnerjp link=topic=104529.msg416968#msg416968 date=1155754168]
hey all...ok i have this code to retrieve the shouts posted and then its displaed as a marquee

rite but the shout box i have saves the stuff in a textbox...it has instructions to make it mysql but very complex.... anyways is their away to retrieve the posts from the txt file??
[/quote]

Ok, so you're using someone else's code for storing shouts, but you have no idea how to get the shouts out for display?

That's your punishment for using code you don't comprehend. ;D

Nah, I'll help you out. Just show me a couple of lines of the text file.

This is, however a good time to give you my take on using other people's code.

My advice is, don't. I could give you plenty of reasons, and others might argue with me (framework?), but I think it's generally only a good idea if you can be sure you understand every line of code in it, and know exactly how it works.

That means, when I do write the code for you to display your shouts, you will have to figure out how it works.

Code snippets aren't lego blocks.  :P
Link to comment
https://forums.phpfreaks.com/topic/17764-shoutbox/#findComment-75847
Share on other sites

Like I said, I need a couple of lines from the file.

Alternatively, show me the code that assembles the string it writes. If you know were that is. ::)

[quote]lol well actually the code was [s]helped[/s] [u]made[/u] by ppl on here[/quote]

Code snippets aren't lego blocks. Did I mention that?  ;)

Link to comment
https://forums.phpfreaks.com/topic/17764-shoutbox/#findComment-75867
Share on other sites

sorry  :)


here u go
[quote]MA%253D%253D%7CMA%253D%253D%7C%7CMQ%253D%253D%7CUm9i%7C%7CMg%253D%253D%7CaHR0cDovL3d3dy5rdWhhYy5jby51aw%253D%253D%7C%7CMw%253D%253D%7CODMuMTAwLjE5My4xNw%253D%253D%7C%7CNA%253D%253D%7CSVwnbGwgZG8gZ3JhZmZpdGkgaWYgeW91IHNpbmcgdG8gbWUgaW4gZnJlbmNo%7C%7CNQ%253D%253D%7CMTE1NTc2MDg0MA%253D%253D [/quote]
Link to comment
https://forums.phpfreaks.com/topic/17764-shoutbox/#findComment-75896
Share on other sites

ohh ok
here is index bit
[code]include("./config.php");
include("./lang.php");

// array_to_string and string_to_array functions
// originally by daenders AT yahoo DOT com on php.net
function array_to_string($array) {
  $retval = '';
  foreach ($array as $index => $value) {
      $retval .= urlencode(base64_encode($index)) . '|' . urlencode(base64_encode($value)) . '||';
  }
  return urlencode(substr($retval, 0, -2));
}

function string_to_array($string) {
  $retval = array();
  $string = urldecode($string);
  $tmp_array = explode('||', $string);
  foreach ($tmp_array as $tmp_val) {
      list($index, $value) = explode('|', $tmp_val);
      $retval[base64_decode(urldecode($index))] = base64_decode(urldecode($value));
  }
  return $retval;
}
function check_words($string,$banwordz) {
  for($i=0;$i<sizeof($banwordz);$i++){
    $string=eregi_replace($banwordz[$i], "****", $string);
  }
  return $string;
}
function check_ip($bannedipz) {
  $isokay = true;
  foreach($bannedipz as $banip) {
    if ($_SERVER['REMOTE_ADDR'] == $banip) {
      $isokay = false;
    }
  }
  return $isokay;
}
function getTagName($text,$cnt)
{
        while(($cnt < strlen($text))&&(eregi("[^a-z0-9]",substr($text,$cnt,1))))$cnt++;
        $tagNameStart=$cnt;
        while(($cnt < strlen($text))&&(!eregi("[^a-z0-9]",substr($text,$cnt,1))))$cnt++;
        return substr($text,$tagNameStart,$cnt-$tagNameStart);
}
function getTagEnd($text,$cnt)
{
        return strpos($text,">",$cnt);
}
function closeUnclosedTags($text)
{
        $openedTags=array();
        $cnt=0;
        while(($cnt < strlen($text))&&(true))
        {
                if(substr($text,$cnt,2)=="</")
                {
                        $tagEnd=getTagEnd($text,$cnt);
                        $tagName=getTagName($text,$cnt);
                        $lastOpenedTag=array_pop($openedTags);
                        if($lastOpenedTag==NULL)
                        {
                                //error: no tag was opened - delete the close tag
                                $text=substr($text,0,$cnt).substr($text,$tagEnd+1);
                        }elseif($lastOpenedTag!=$tagName){
                                //error: closing unopened tag (possible cross-nesting) - return the original opened tag and delete the close tag
                                array_push($openedTags,$lastOpenedTag);
                                $text=substr($text,0,$cnt).substr($text,$tagEnd+1);
                        }else{ $cnt=$tagEnd+1; }
                }elseif(substr($text,$cnt,1)=="<"){
                        $tagEnd=getTagEnd($text,$cnt);
                        $tagName=getTagName($text,$cnt);
                        if(substr($text,$tagEnd-1,1)!="/")array_push($openedTags,$tagName);
                        $cnt=$tagEnd+1;
                }else{
                        $cnt++;
                }
        }
        while(count($openedTags)>0)$text.="</".array_pop($openedTags).">";
        return $text;
}
function parse_smileys($string) {
$smileylist = array();
$i = 0;
if ($handle = opendir('./smileys/')) {
  while (false !== ($file = readdir($handle))) {
      if ($file != "." && $file != "..") {
          $smileylist[$i] = str_replace(".gif", "", $file);
          $i++;
      }
  }
  closedir($handle);
}
foreach ($smileylist as $smileycheck){
        $string = str_replace(":".$smileycheck.":", "<img src=\"smileys/".$smileycheck.".gif\" />", $string);
}
return $string;
}

[/code]
Link to comment
https://forums.phpfreaks.com/topic/17764-shoutbox/#findComment-75904
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.