shoutbox auto refresh

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Joshua Tijssen

joshua Tijssen

05/09/2010 19:15:44
Quote Anchor link
Hallo,

Ik gebruik een shoutbox die ik op internet heb gevonden en ik zou graag willen dat hij voor alle users de shouts automatisch refreshed als er een nieuwe shout is geplaatst.
Het is niet de bedoeling dat het met een meta refresh gebeurd, omdat dan ook het invoerveld word gewist bij een refresh (niet handig als je net iets aan het typen bent)

Wie kan mij van tips voorzien?

hieronder de codes die ik gebruik:

viewshoutbox.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<?php


  include("_include-config.php");

$time_string = explode(" ", microtime());
$stime = $time_string[1] . substr($time_string[0],1,strlen($time_string[0]));

if (isset($shoutinfo)) {
    $info = explode("|",$shoutinfo);
    if (!isset($nick)) { $nick = $info[0]; }
    if (!isset($url)) { $url = $info[1]; }
}

require_once("shoutboxconf.php");

?>

<html>
<head>
<title><?=_SHOUTBOX></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?=_CHARSET?>">
<?
  if (!isset($stylesheet)) {
      $stylesheet="borkes.css";
  }

?>

<link rel="stylesheet" href="<?=$stylesheet?>" type="text/css">
<script>
<!--

/* clears default values from input boxes */
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function submitonce(theform) {
    if (document.all||document.getElementById) {
        for (i=0;i<theform.length;i++) {
            var tempobj=theform.elements[i];
            if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
                tempobj.disabled=true
        }
    }
}
//-->
</script>




<? if (0) {?><link rel="stylesheet" href="borkes.css" type="text/css"><?}?>
</head>
<body bgcolor="#000000" text="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="window.scrollTo(0,99999);" link="#FF9900">
<form name="sbx" action="shoutbox.php">
  <input type="hidden" name="action" value="add">
  <?php $action="show"; require_once("shoutbox.php")?>
  <table class="formarea" width="100%">
    <tr>
      <td>
       <font color="#ff3300" size="1"><B><?=$error?></B></font><font color="#33ff00" size="1"><B><?=$message?></B></font>
        <div align="center">
          <?php
      if (!isset($nick)) {
          $nick = _FORM_NAME;
          $onfocusnick = "onFocus=\"clearText(this)\" ";
      }

      if (!isset($shout) || trim($shout)=="") {
          $shout = _FORM_MESSAGE;
          $onfocusshout = "onFocus=\"clearText(this)\" ";
      }

      if (!isset($url) || trim($url)=="") {
          $url = _FORM_URL;
          $onfocusurl = "onFocus=\"clearText(this)\" ";
      }

  ?>

                        <div align="left">  
<input type="hidden" name="nick" size="22" maxlength="30" <?=$onfocusnick?>value="<?=$data->login?>" class="editbox" title="<?=_FORM_NAME?>"><br>
          <input type="text" name="shout" size="50" maxlength="<?=$maxshoutlen?>" <?=$onfocusshout?>value="<?=$shout?>" class="editbox" title="<?=_FORM_MESSAGE?>"><br>
  <input type="submit" name="Submit" value="<?=_SHOUT?>" class="button" onSubmit="submitonce(this)"><br>
          </b>
          <?php
    $time_string2
= explode(" ", microtime());
    $etime = $time_string2[1] . substr($time_string2[0], 1, strlen($time_string2[0]));
    echo "\n<!-- This page was rendered in a mere " . substr($etime - $stime, 0, 8) . "sec using Shoutbox ".$version." -->\n";
?>

          </span></div>
      </td>
    </tr>
  </table>
</form>
</body>
</html>



shoutbox.php

<?php
$time_string
= explode(" ", microtime());
$stime = $time_string[1] . substr($time_string[0],1,strlen($time_string[0]));
$version = "2.32";
if (1!=1) {?>
<link rel="stylesheet" href="../stylesheet.css" type="text/css"><?}

if (!isset($conf)) {
    $conf="shoutboxconf.php";
} else {
    # michel v was there :)
    $conf = str_replace(':', '', $conf); // hi cross-site scripting, bye cross-site scripting
    $conf = str_replace('%3a', '', $conf); // hi cross-site scripting, bye cross-site scripting
}

require_once ($conf);
require_once ("shoutboxsmileys.php");
require_once ("shoutbox_censor.php");


$page = $PHP_SELF;
$c = strlen($page);
while (substr($page,$c,1) <> "/") { $page = substr($page,0,$c); $c--; }
$page .= "viewshoutbox.php";


// SELECT ACTION TO PERFORM
switch ($action) {
    case "show": // show current shouts
        showShouts();
        break;
    case "add": // add form submissions
        addShouts();
        break;
    case "deleteshout": // add form submissions
        if ($REMOTE_ADDR == getIP($timestamp)) {
            deleteShout($timestamp);
            $error = _PROCESS_DELETED;
            header ("Location: ".$page."?error=".$error."&showall=".$showall);
        } else {
            // there was an error, so lets send the fields back for them.
            $error = _PROCESS_DELETEFAILED;
            header ("Location: ".$page."?error=".$error."&showall=".$showall);
        }
        break;
}

// This adds a shout to the file
function addShouts() {
    global $nick, $shout, $url, $page, $showall, $maxshoutlen, $lang;
    $defaultnick = trim(_FORM_NAME);
    $defaultshout = trim(_FORM_MESSAGE);
    $nick = trim($nick);
    $shout = trim($shout);

    # michel v was there :)
    $sbvars = array('defaultnick', 'defaultshout', 'defaulturl', 'nick', 'shout', 'url');
    foreach ($sbvars as $sbvar) {
        $$sbvar = str_replace('<', '&lt;', $$sbvar);
        $$sbvar = str_replace('>', '&gt;', $$sbvar);
        if (stristr($sbvar, 'url')) {
            $$sbvar = eregi_replace('javascript:', 'iamsuchawannabehacker:', $$sbvar);
        }
        #if (!get_magic_quotes_gpc()) {
        #    $$sbvar = addslashes($$sbvar);
        #}
    }

    if (!isset($shout) || $shout == $defaultshout || $shout == "") {$error = _PROCESS_INVALIDMSG;} // invalid msg
    if (!isset($nick)|| $nick == $defaultnick || $nick=="") {$error = _PROCESS_INVALIDNAME;} // invalid name
    if ($checkurl) { if (!@fopen($url,"r")) { $error = _PROCESS_URLFAILED; } } // if url doesn't exist
    if (strlen($shout) > $maxshoutlen) {
        $error = _PROCESS_TOOLONG; // too long
        $shout = substr($shout,0,$maxshoutlen);
    }
    if (isFlooding() >= 3) {
        $error .= _PROCESS_FLOODING;    
    }
    
    if (!isset($error)) { // check for null or default posts
        //$nick = htmlspecialchars($nick,ENT_QUOTES);
        //$shout = htmlspecialchars($shout,ENT_QUOTES);
        //$url = htmlspecialchars($url,ENT_QUOTES);
        writeShouts ($nick, $shout, $url);        
        setcookie("shoutinfo","$nick|$url",2147483647);
        header ("Location: ".$page."?showall=".$showall);
    } else {
        
        header ("Location: ".$page."?error=".$error."&nick=".$nick."&shout=".$shout."&url=".$url."&showall=".$showall);
    }
}

// This displays the shouts
function showShouts () {
    global $showamount, $linelength, $direction, $showall, $censormode, $emoticons, $emoticon_theme, $emoticon_text, $REMOTE_ADDR, $lang, $deletetime;
    $count=0;
    $colour=0;
    $shoutcount = countShouts();
    $start = $shoutcount - $showamount;
    if ($showall == TRUE) {
        $start = $shoutcount - 400;
    }
    if ($start<0) {
        $start=0;
    }
    //echo $start.", ".($shoutcount-$start).", ".$showamount."<BR>" ;
    $urlchecks[] = "http://";
    $urlchecks[] = "ftp://";
    $urlchecks[] = "https://";  
    $records = getShouts($start, $shoutcount, $direction);
    for ($count=0;$count!=count($records);$count++) {
        $shouts=$records[$count];
        unset($url);
        if (trim($shouts['nick'])!="" && trim($shouts['shout'])!="" && trim($shouts['time'])!="") {
            $nick = wordwrap($shouts['nick'],$linelength,"<br>",1);
            $ex_shout=explode(" ",$shouts['shout']);
            for ($value=0;$value<count($ex_shout);$value++) {
                $foundurl = "";
                foreach ($urlchecks as $u) {
                    if ($u == substr($ex_shout[$value],0,strlen($u))) {
                        $foundurl = $ex_shout[$value];
                    }
                }
                if (substr($ex_shout[$value],0,4) == "www."){
                    $foundurl = "http://".$ex_shout[$value];
                }
                if (ereg("^([A-Za-z0-9_.-]*)@([A-Za-z0-9._-]*).([A-Za-z]*)$", $ex_shout[$value])){
                    $foundurl = "mailto:".$ex_shout[$value];
                }
                $ex_shout[$value] = wordwrap($ex_shout[$value],$linelength,"<br>",1);
                $ex_shout[$value] = htmlspecialchars($ex_shout[$value],ENT_QUOTES);
                if ($foundurl != "") {
                    $ex_shout[$value] = "<a href='".$foundurl."' target='_blank' class='inlinelink'>".$ex_shout[$value]."</a>";
                }
            }
            $shout = implode(" ",$ex_shout);
            $shout = str_replace("&lt;br&gt;","<BR>",$shout);
            if ($emoticons == "TRUE") {
                $shout = parseEmoticons($shout, $emoticon_theme, $emoticon_text);
            }
            if ($censormode == "TRUE") {
                $shout = parseCensorship($shout);
            }
            $date = formatDate($shouts['time']);
            $datum = $shouts['datum'];
            if ($colour==0) {$colour=1;} else {$colour=0;}
// ########## LAYOUT HERE! ###########
            if (strstr($shouts['url'],"http://")) {
                $url = processLink($nick,$shouts['url']);
            } else {
                $url = processNoLink($nick);
            }
            if (($shouts['ipaddress'] == $REMOTE_ADDR) && ($shouts['time'] > time()-$deletetime)) { //
                $shout = processDeleteLink($shout, $shouts['time']);
            }
            echo outputShout($url,$nick,$shout,$date,$colour,$count);
// ##########################################
        }
    } // end for
} // end showShouts()

function isFlooding() {
    global $REMOTE_ADDR, $floodtime;
    $countshouts = countShouts();
    $records = getShouts($countshouts-3,$countshouts,1);
    $floodcount = 0;
    if (count($records)>0) {
        foreach ($records as $shouts) {
            if ( ($shouts['ipaddress'] == $REMOTE_ADDR) && ($shouts['time'] > time()-$floodtime) ) { //
                $floodcount++;
            }
        }
    }
    return ($floodcount);
}

require_once ("shoutbox_cookies.php");

?>
Gewijzigd op 05/09/2010 19:20:36 door Joshua Tijssen
 
PHP hulp

PHP hulp

27/04/2024 03:11:29
 
Wim E

Wim E

05/09/2010 19:19:35
Quote Anchor link
Gebruik van ajax...
 
SilverWolf NL

SilverWolf NL

05/09/2010 19:24:22
Quote Anchor link
Dan zou je hem helemaal moeten omschrijven en er een met AJAX moeten schrijven. Ik denk niet dat iemand het vrijwillig voor je wil doen. Ik geloof dat er een tijdje terug een shoutbox met AJAX gepost was, zal eens kijken of ik hem nog kan vinden.

Al gevonden:
http://www.phphulp.nl/php/script/scripting-ajax-html-css/shoutbox-systeem/1811/

Als je dan een interval op updateSoutbox() zet, update hij gewoon om de zoveel tijd.
Gewijzigd op 05/09/2010 19:27:54 door SilverWolf NL
 
Joshua Tijssen

joshua Tijssen

05/09/2010 19:27:34
Quote Anchor link
het liefst zou ik deze gewoon blijven gebruiken.
heb deze aangepast zodat hij werkt met het login systeem van de hoofdsite en qua css ook naar wens gemaakt.

ik zag hier ook een shoutbox systeem staan met ajax, maar daar zaten een paar foutjes in als ik goed gelezen heb en de maker zou bezig zijn met een vernieuwde versie

Toevoeging op 05/09/2010 19:29:23:

SilverWolf NL op 05/09/2010 19:24:22:

Al gevonden:
http://www.phphulp.nl/php/script/scripting-ajax-html-css/shoutbox-systeem/1811/

Als je dan een interval op updateSoutbox() zet, update hij gewoon om de zoveel tijd.


Dat is precies degene die ik bedoelde.
iig thanx voor het opzoeken, was zelf vergeten te melden dat ik hem dus al gezien had, maar het liefst de gene die ik nu heb wil blijven gebruiken
 
SilverWolf NL

SilverWolf NL

05/09/2010 19:30:15
Quote Anchor link
Je kan beter een nieuwe schrijven met AJAX dan je oude ombouwen, dat is minder werk. Als je wil dat hij samengaat met je loginsysteem, kan je dat natuurlijk altijd (zelf) regelen, maar ik denk niet dat iemand zin heeft om jou hele shoutbox (gratis) om te bouwen...
Gewijzigd op 05/09/2010 19:31:09 door SilverWolf NL
 
Niek s

niek s

05/09/2010 19:34:07
Quote Anchor link
@SilverWolf:
Ik geloof dat Niels nog wat aanpassingen wil doen aan dat Shoutbox Systeem. Dus wellicht nog even wachten met het in gebruik nemen van het betreffende systeem.
 
Joshua Tijssen

joshua Tijssen

05/09/2010 19:36:08
Quote Anchor link
Als er geen optie bestaat door een paar regels aan mn huidige script toe te voegen zit er niets anders op dan overgaan op een ander script.
Werkend maken met mijn login systeem en css aanpassen is inderdaad minder werk dan een compleet systeem ombouwen.

Er zijn genoeg andere systemen te vinden die wellicht doen wat ik wil, dus ik zal ook niemand vragen mijn nu gebruikte systeem om te bouwen
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.