BigJackW Skrevet 15. januar 2006 Del Skrevet 15. januar 2006 Hei Kan noen lage eller gi meg et tips til hvordan jeg lager et admin panel til shotboxen på sida mi? Koden må hente ut data fra databasen. I panelet må man kunne redigere innlegg og navn. Noen flere tips til hva man kan gjøre i admin panelet? Og noen tips til hvordan jeg lager det, eller kanskje noen kan lage det til meg? Lenke til kommentar
stian90_2 Skrevet 15. januar 2006 Del Skrevet 15. januar 2006 Har du en shotbox fra før, kan jeg se scriptet først. blir lettere og lage admin panel da, legge linker osv Lenke til kommentar
BigJackW Skrevet 15. januar 2006 Forfatter Del Skrevet 15. januar 2006 (endret) Her er shoutboxen: http://www.nepticlan.hotserv.dk Her er kodene: config.inc.php <? //======================================================================================================== // Database settings //======================================================================================================== $db_server = "never"; // server name $db_user = "never"; // user name $db_pass = "never"; // user password $db_name = "never"; // database name // don't change unless you know what you're doing: $tbl_name = "Shoutbox"; // table name $fld_id = "ID"; // field name: ID $fld_timestamp = "Timestamp"; // field name: timestamp $fld_name = "Name"; // field name: name $fld_email = "EMail"; // field name: e-mail $fld_text = "Text"; // field name: text //======================================================================================================== // Other settings //======================================================================================================== $language = "de"; // shout-box language: de, en, fr $boxFolder = "http://www.nepticlan.hotserv.dk/shoutbox"; // shout-box folder (web-path) $boxWidth = 168; // shout-box width (pixels) $boxHeight = 400; // shout-box height (pixels) $boxEntries = 50; // maximum entries in shout-box (higher values = more traffic!) $boxRefresh = false; // refresh shout-box every .. seconds (lower values = more traffic!) $messageOrder = "DESC"; // message order: ASC (new at bottom) or DESC (new on top) $allowHTML = false; // allow HTML-code in message (true = yes, false = no) $wordLength = 30; // maximum word length (insert spaces into loooooong words; 0 = off) // NOTE: should be 0 for non-European languages (Asian, Arabic, etc.) // bad words $nonos = array("fuck", "asshole", "dickhead", "kuk"); //======================================================================================================== ?> lang_de.inc <? $msg['name'] = " Navn"; $msg['eMail'] = " E-Post"; $msg['message'] = " Melding"; $msg['smilies'] = "Smilyer"; $msg['refresh'] = "Oppdater"; $msg['shout'] = "Shout!"; ?> shout.php <? /* +-------------------------------------------------------------------+ | S H O U T B O X (v1.7) | | P a r t II | | | | Copyright Gerd Tentler www.gerd-tentler.de/tools | | Created: Jun. 1, 2004 Last modified: Dec. 22, 2005 | +-------------------------------------------------------------------+ | This program may be used and hosted free of charge by anyone for | | personal purpose as long as this copyright notice remains intact. | | | | Obtain permission before selling the code for this program or | | hosting this software on a commercial website or redistributing | | this software over the Internet or in any other medium. In all | | cases copyright must remain intact. | +-------------------------------------------------------------------+ */ error_reporting(E_WARNING); //======================================================================================================== // Cookies //======================================================================================================== if(isset($Name)) { $shouter = $Name; setcookie('shouter', $shouter); } if(isset($EMail)) { $shouter_mail = $EMail; setcookie('shouter_mail', $shouter_mail); } //======================================================================================================== // Includes //======================================================================================================== include('config.inc.php'); include('smilies.inc'); //======================================================================================================== // Set variables, if they are not registered globally; needs PHP 4.1.0 or higher //======================================================================================================== if(!isset($Name)) $Name = $_REQUEST['Name']; if(!isset($EMail)) $EMail = $_REQUEST['EMail']; if(!isset($Text)) $Text = $_REQUEST['Text']; //======================================================================================================== // Functions //======================================================================================================== function db_connect() { global $db_name, $db_server, $db_user, $db_pass; $status = true; if(!@mysql_connect($db_server, $db_user, $db_pass)) { echo '<font color=red>' . mysql_errno() . ': ' . mysql_error() . '</font><br>'; $status = false; } else if(!@mysql_select_db($db_name)) { echo '<font color=red>' . mysql_errno() . ': ' . mysql_error() . '</font><br>'; $status = false; } return $status; } function timeStamp($ts) { return substr($ts, 0, 4) . '-' . substr($ts, 4, 2) . '-' . substr($ts, 6, 2) . ' ' . substr($ts, 8, 2) . ':' . substr($ts, 10, 2) . ':' . substr($ts, 12); } function checkRepeats($str) { $newstr = substr($str, 0, 3); for($i = 3; $i < strlen($str); $i++) { if($str[$i] == $str[$i-1] && $str[$i] == $str[$i-2] && $str[$i] == $str[$i-3]) continue; else $newstr .= $str[$i]; } return $newstr; } function checkLongWords($str) { global $wordLength; if($wordLength && strlen($str) > $wordLength) { $words = explode(' ', $str); $str = ''; for($i = 0; $i < count($words); $i++) { if(!eregi('&[#a-z0-9];', $words[$i])) $str .= chunk_split($words[$i], $wordLength, ' '); else $str .= $words[$i]; } } return $str; } function replaceNonos($str) { global $nonos; for($i = 0; $i < count($nonos); $i++) { $repl = substr('********************', 0, strlen($nonos[$i])); $word = chunk_split($nonos[$i], 1, ' *'); $str = preg_replace('/' . substr($word, 0, strlen($word) - 2) . '/i', $repl, $str); } return $str; } function format($str, $sm_code = '', $sm_img = '') { global $allowHTML; if(!$allowHTML) { $str = str_replace('>', '>', $str); $str = str_replace('<', '<', $str); } $str = eregi_replace('http://', '', $str); $str = checkRepeats($str); $str = checkLongWords($str); $str = replaceNonos($str); if($sm_code && $sm_img) $str = str_replace($sm_code, $sm_img, $str); return $str; } //======================================================================================================== // Main //======================================================================================================== if(db_connect()) { $error = ''; header('Cache-control: private, no-cache, must-revalidate'); header('Expires: Sat, 01 Jan 2000 00:00:00 GMT'); header('Date: Sat, 01 Jan 2000 00:00:00 GMT'); header('Pragma: no-cache'); ?> <html> <head> <meta http-equiv="refresh" content="<? echo $boxRefresh; ?>; URL=<? echo basename($PHP_SELF); ?>"> <title>Output</title> <? $messageOrder = strtoupper($messageOrder); if($messageOrder != 'ASC' && $messageOrder != 'DESC') $messageOrder = 'DESC'; if($messageOrder == 'ASC') { ?> <script language="JavaScript"> <!-- function autoscroll() { if(document.body && document.body.offsetHeight) window.scrollBy(0, document.body.offsetHeight); else if(window.innerHeight) window.scrollBy(0, window.innerHeight); else if(document.height) window.scrollBy(0, document.height); } window.onload = autoscroll; //--> </script> <? } ?> <link rel="stylesheet" href="shoutbox.css" type="text/css"> </head> <body marginwidth=0 marginheight=0 topmargin=0 leftmargin=0> <? if($Text) { $tstamp = date('YmdHis'); $sql = "INSERT INTO $tbl_name ($fld_timestamp, $fld_name, $fld_email, $fld_text) "; $sql .= "VALUES ('$tstamp', '$Name', '$EMail', '$Text')"; if(!mysql_query($sql)) $error .= mysql_error() . '<br>'; $sql = "SELECT $fld_id FROM $tbl_name ORDER BY $fld_timestamp DESC LIMIT 1"; $id = mysql_result(mysql_query($sql), $fld_id) - $boxEntries; if($id > 0) { $sql = "DELETE FROM $tbl_name WHERE $fld_id<=$id"; if(!mysql_query($sql)) $error .= mysql_error() . '<br>'; } } ?> <table border=0 cellspacing=0 cellpadding=2 width=100%><tr> <td> <? if($error) echo "<font color=red>$error</font><br>"; ?> <table border=0 cellspacing=0 cellpadding=0 width=100%> <? $sm_code = $sm_img = array(); while(list($code, $img) = each($sm)) { $sm_code[] = $code; $sm_img[] = "<img src='smilies/$img' width=15 height=15 align=top>"; } $sql = "SELECT * FROM $tbl_name ORDER BY $fld_timestamp $messageOrder LIMIT $boxEntries"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $tstamp = timeStamp($row[$fld_timestamp]); $name = $row[$fld_name] ? format($row[$fld_name]) : '?'; $email = $row[$fld_email]; $text = format($row[$fld_text], $sm_code, $sm_img); $bgcolor = ($bgcolor != '#FFFFFF') ? '#FFFFFF' : '#F6F6F6'; ?> <tr bgcolor=<? echo $bgcolor; ?>> <td class="cssSmall" align=right><font color=#A0A0A0><? echo $tstamp; ?></font></td> </tr><tr bgcolor=<? echo $bgcolor; ?>> <td class="cssShoutText"><? if($email) echo '<a href="mailto:' . $email . '">'; ?> <b><? echo $name; ?>:</b><? if($email) echo '</a>'; ?> <? echo $text; ?></td> </tr> <? } mysql_close(); ?> </table> </td> </tr></table> </body> </html> <? } ?> shoutbox.css A, A:active, A:visited { color: black; } A:hover { color: red; } .cssShoutBox { border: 2px inset #EEEEEE; } .cssShoutForm { font-family: Arial, Helvetica; font-size: 11px; background-color: #FFFFFF; border: 2px inset #EEEEEE; } .cssShoutButton { font-family: Arial, Helvetica; font-size: 11px; } .cssShoutText { font-family: Arial, Helvetica; font-size: 11px; } .cssSmall { font-family: Arial, Helvetica; font-size: 9px; } shoutbox.inc.php <? /* +-------------------------------------------------------------------+ | S H O U T B O X (v1.7) | | P a r t I | | | | Copyright Gerd Tentler www.gerd-tentler.de/tools | | Created: Jun. 1, 2004 Last modified: Aug. 4, 2005 | +-------------------------------------------------------------------+ | This program may be used and hosted free of charge by anyone for | | personal purpose as long as this copyright notice remains intact. | | | | Obtain permission before selling the code for this program or | | hosting this software on a commercial website or redistributing | | this software over the Internet or in any other medium. In all | | cases copyright must remain intact. | +-------------------------------------------------------------------+ */ error_reporting(E_WARNING); //======================================================================================================== // Includes //======================================================================================================== $this_dir = str_replace('\\', '/', dirname(__FILE__)); include("$this_dir/config.inc.php"); if(!isset($language)) $language = 'en'; include("$this_dir/lang_$language.inc"); include("$this_dir/smilies.inc"); //======================================================================================================== // Main //======================================================================================================== $input_width = round($boxWidth / 10); if($boxFolder && !ereg('/$', $boxFolder)) $boxFolder .= '/'; ?> <script language="JavaScript"> <!-- var shout_popup = 0; function newWindow(url, w, h, x, y, scroll, menu, tool, resizable) { if(shout_popup && !shout_popup.closed) shout_popup.close(); if(!x && !y) { x = Math.round((screen.width - w) / 2); y = Math.round((screen.height - h) / 2); } shout_popup = window.open(url, "shout_popup", "width=" + w + ",height=" + h + ",left=" + x + ",top=" + y + ",scrollbars=" + scroll + ",menubar=" + menu + ",toolbar=" + tool + ",resizable=" + resizable); shout_popup.focus(); } function refreshBox() { document.fShout.Text.value = ''; document.fShout.submit(); setTimeout("document.fShout.Refresh.disabled=false", 1000); } function shoutIt() { document.fShout.submit(); setTimeout("document.fShout.Text.value=''", 1000); setTimeout("document.fShout.Shout.disabled=false", 1000); } //--> </script> <link rel="stylesheet" href="<? echo $boxFolder; ?>shoutbox.css" type="text/css"> <table border=0 cellspacing=0 cellpadding=0 align=center><tr> <td colspan=2 align=center> <iframe name="ShoutBox" src="<? echo $boxFolder; ?>shout.php" class="cssShoutBox" width=<? echo $boxWidth; ?> height=<? echo $boxHeight; ?> frameborder=0></iframe> </td> </tr> <form name="fShout" action="<? echo $boxFolder; ?>shout.php" target="ShoutBox" method=post> <tr> <td class="cssShoutText"><? echo $msg['name']; ?>:</td> <td align=right><input type=text name="Name" size=<? echo $input_width; ?> maxlength=20 class="cssShoutForm" value="<? echo $shouter; ?>"></td> </tr><tr> <td colspan=2 align=center> <table border=0 cellspacing=0 cellpadding=0 width=100%><tr> <td class="cssShoutText"><? echo $msg['message']; ?>:</td> <td align=right><input type=button value="<? echo $msg['smilies']; ?>" class="cssShoutButton" onClick="newWindow('<? echo $boxFolder; ?>smilies.php', 130, 300, 0, 0, 1)"></td> </tr></table> <textarea name="Text" cols=22 rows=3 style="width:100%" wrap=virtual class="cssShoutForm"></textarea> <table border=0 cellspacing=0 cellpadding=0 width=100%><tr> <td><input type=button name="Refresh" value="<? echo $msg['refresh']; ?>" class="cssShoutButton" onClick="this.disabled=true; refreshBox()"></td> <td align=right><input type=button name="Shout" value="<? echo $msg['shout']; ?>" class="cssShoutButton" onClick="this.disabled=true; shoutIt()"></td> </tr></table> </td> </tr> </form> </table> shoutbox.sql # ====================================================================== # MySQL-Dump # ====================================================================== # # Table structure 'Shoutbox' # CREATE TABLE Shoutbox ( ID int(10) NOT NULL auto_increment, Timestamp varchar(14) NOT NULL, Name varchar(20), EMail varchar(75), Text text NOT NULL, PRIMARY KEY (ID) ); smilies.inc <? $sm[')] = $sm[':-))'] = $sm['] = $sm[':-D'] = 'biggrin.gif'; $sm['] = $sm[':-)'] = 'smile.gif'; $sm['] = $sm[';-)'] = 'wink.gif'; $sm[':/'] = $sm[':-/'] = 'unsure.gif'; $sm[':['] = $sm[':-['] = $sm['] = $sm[':-('] = 'sad.gif'; $sm['] = $sm[':-P'] = 'tongue.gif'; $sm[':o'] = $sm[':-o'] = 'surprised.gif'; $sm[':x'] = $sm[':-x'] = 'angry.gif'; $sm[':|'] = $sm[':-|'] = 'neutral.gif'; $sm['->'] = $sm['=>'] = $sm['->'] = $sm['=>'] = 'arrow.gif'; $sm['] = 'blush.gif'; $sm['] = 'confused.gif'; $sm['] = 'cool.gif'; $sm['] = 'cry.gif'; $sm['] = 'eek.gif'; $sm['] = 'evil.gif'; $sm[':exclaim:'] = 'exclaim.gif'; $sm[':glad:'] = 'glad.gif'; $sm['] = 'idea.gif'; $sm['] = 'lol.gif'; $sm[':naughty:'] = 'naughty.gif'; $sm[':question:'] = 'question.gif'; $sm['] = 'rollseyes.gif'; $sm[':smirk:'] = 'smirk.gif'; $sm[':tired:'] = 'tired.gif'; $sm[':zonked:'] = 'zonked.gif'; ?> smilies.php <? /* +-------------------------------------------------------------------+ | S H O U T B O X (v1.7) | | P a r t III | | | | Copyright Gerd Tentler www.gerd-tentler.de/tools | | Created: Jun. 1, 2004 Last modified: Jul. 21, 2005 | +-------------------------------------------------------------------+ | This program may be used and hosted free of charge by anyone for | | personal purpose as long as this copyright notice remains intact. | | | | Obtain permission before selling the code for this program or | | hosting this software on a commercial website or redistributing | | this software over the Internet or in any other medium. In all | | cases copyright must remain intact. | +-------------------------------------------------------------------+ */ error_reporting(E_WARNING); //======================================================================================================== // Includes //======================================================================================================== include('config.inc.php'); if(!isset($language)) $language = 'en'; include("lang_$language.inc"); include('smilies.inc'); //======================================================================================================== // Main //======================================================================================================== ?> <html> <head> <title><? echo $msg['smilies']; ?></title> <script language="JavaScript"> <!-- function insert(txt) { if(window.opener) { el = window.opener.document.fShout.Text; if(!el.value) el.value = txt + ' '; else el.value += ((el.value.charAt(el.value.length-1) == ' ') ? '' : ' ') + txt + ' '; self.close(); } } //--> </script> <link rel="stylesheet" href="shoutbox.css" type="text/css"> </head> <body leftmargin=5 topmargin=5 marginwidth=5 marginheight=5> <table border=0 cellspacing=0 cellpadding=4 align=center> <? while(list($code, $img) = each($sm)) { if($img != $img_old) { $bgcolor = ($bgcolor != '#E0E0E0') ? '#E0E0E0' : '#F0F0F0'; ?> <tr bgcolor=<? echo $bgcolor; ?>> <td><a href="javascript:insert('<? echo $code; ?>')"> <img src="smilies/<? echo $img; ?>" border=0 width=15 height=15></a></td> <td class="cssShoutText"><b><? echo $code; ?></b></td> </tr> <? } $img_old = $img; } ?> </table> </body> </html> Endret 15. januar 2006 av BigJackW Lenke til kommentar
BigJackW Skrevet 16. januar 2006 Forfatter Del Skrevet 16. januar 2006 (endret) Ja...hvordan blir det med deg?? Endret 16. januar 2006 av BigJackW Lenke til kommentar
Anbefalte innlegg
Opprett en konto eller logg inn for å kommentere
Du må være et medlem for å kunne skrive en kommentar
Opprett konto
Det er enkelt å melde seg inn for å starte en ny konto!
Start en kontoLogg inn
Har du allerede en konto? Logg inn her.
Logg inn nå