Modul Linkliste
Verfasst: Mi 25. Jan 2006, 18:31
Aufgrund eines Threads in dem es um eine Linkliste geht bei der man nicht für jeden link einen Artikel anlegen muss habe ich mit der zustimmung von Dodger77 auf Basis seines Gästebuchs diese Linkliste gestaltet. Zum Eintrag muss man LINKNAME URL und BESCHREIBUNG angeben wobei die Beschreibung in der Übersicht noch bearbeitet werden kann.
benötigt werden wie beim Gästebuch auch 2 module und die 2 dazugehörenden Templates
Linkliste Eingabe:
Input:
Output:
Linkliste Ausgabe:
Input:
Output:
Templates:
linkliste_eintrag.html
linkliste_ausgabe.html
Vielleicht nicht die eleganteste aber sie funktioniert
benötigt werden wie beim Gästebuch auch 2 module und die 2 dazugehörenden Templates
Linkliste Eingabe:
Input:
Code: Alles auswählen
/***********************************************
* CONTENIDO MODUL - INPUT
*
* Modulname : linkliste 0.1 - Eintrag
* based on : vpGuestbook 1.9 Ingo van Peeren
* Copyright : Ingo van Peeren (ingo@van-peeren.de)
* Modified : rezeptionist (info@rezeptionist.de)
* Created : 2005-03-14
* Modified : 2006-01-23
************************************************/
$cfg["tab"]["linkliste"] = $cfg['sql']['sqlprefix']."_linkliste";
$db = new DB_Contenido;
$sql = "CREATE TABLE IF NOT EXISTS `".$cfg["tab"]["linkliste"]."` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(60) NOT NULL default '',
`email` varchar(80) NOT NULL default '',
`url` varchar(80) NOT NULL default '',
`entry` text NOT NULL,
`image` varchar(255) NOT NULL default '',
`comment` text NOT NULL,
`iphost` varchar(60) NOT NULL default '',
`user1` varchar(255) NOT NULL default '',
`user2` varchar(255) NOT NULL default '',
`user3` varchar(255) NOT NULL default '',
`active` int(1) NOT NULL default '1',
`client` int(10) NOT NULL default '0',
`lang` int(10) NOT NULL default '0',
`art` int(10) NOT NULL default '0',
`date` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
KEY `client` (`client`),
KEY `lang` (`lang`),
KEY `art` (`art`)
) TYPE=MyISAM;";
$db->query($sql);
if (! function_exists('dir_list')) {
#Build folder list recursively
function dir_list($dir, $sPrefix, $show_options = 0) {
global $sSelected, $cfgClient, $client;
$old_path = getcwd();
$sPathDir = $cfgClient[$client]["path"]["frontend"].$cfgClient[$client]["upload"].$dir;
if (is_dir($sPathDir)) {
chdir($sPathDir);
$myhandle = opendir('.');
while (($mydir = readdir($myhandle)) !== false) {
if (($mydir != ".") && ($mydir != "..")) {
if (is_dir($mydir)) {
$dirs[] = $dir.$mydir."/";
$prefixs[] = $sPrefix.$mydir;
$ret = dir_list($dir.$mydir."/", ' '.$sPrefix);
foreach ($ret['dirs'] as $key => $value) {
$dirs[] = $value;
$prefixs[] = $ret['prefixs'][$key];
}
chdir($sPathDir);
}
}
}
closedir($myhandle);
}
chdir($old_path);
if ($show_options == 1) {
array_multisort ($dirs, $prefixs);
foreach ($dirs as $key => $value) {
if ($sSelected == $value) {
echo '<option selected value="'.$value.'">'.$prefixs[$key].'</option>';
}
else {
echo '<option value="'.$value.'">'.$prefixs[$key].'</option>';
}
}
}
else {
$ret['dirs'] = $dirs;
$ret['prefixs'] = $prefixs;
return $ret;
}
}
}
$hier = getcwd ();
if ($cfgClient[$client][tpl][path]) chdir($cfgClient[$client][tpl][path]);
else chdir($cfgClient[$client][path][frontend]."templates/");
$handle = opendir(".");
while ($file = readdir($handle)) {
if (is_dir($file)) $dirlist[] = $file;
if (is_file($file)) $filelist[] = $file;
}
closedir($handle);
chdir($hier);
if ($filelist) {
asort($filelist);
}
$selected = "CMS_VALUE[1]";
echo "<table cellspacing=\"0\" cellpadding=\"10\" border=\"0\">";
echo "<tr><td>Templatedatei: ";
echo "<td><select size=\"1\" name=\"CMS_VAR[3]\">";
while (list ($key, $file) = each ($filelist)) {
echo "<option value=\"$file\"";
if ("CMS_VALUE[3]" == $file) echo " selected=\"selected\" ";
echo ">$file</option>";
}
echo "</td></tr>";
// echo "<tr valign=\"top\"><td width=\"202\">Emailbenachrichtigung: ";
// echo "Ja <input type=\"checkbox\" name=\"CMS_VAR[11]\" value=\"1\" ";
// if ("CMS_VALUE[11]" == 1) echo "checked=\"checked\" ";
// echo "> An:</td><td>";
//echo "<input type=\"text\" name=\"CMS_VAR[12]\" value=\"CMS_VALUE[12]\"></td></tr>";
// echo "<tr>";
// echo "<td width=\"202\">Cookie gegen doppelte Einträge :</td><td><input type=\"radio\" name=\"CMS_VAR[13]\" value=\"0\" ";
// if ("CMS_VALUE[13]" == 0) echo "checked=\"checked\" ";
// echo "> aus <input type=\"radio\" name=\"CMS_VAR[13]\" value=\"1\" ";
// if ("CMS_VALUE[13]" == 1) echo "checked=\"checked\" ";
// echo "> an</td></tr>";
// echo "<tr>";
// echo "<td width=\"202\">Cookie Lebensdauer (in Minuten) :
// </td><td><input type=\"text\" name=\"CMS_VAR[14]\" value=\"CMS_VALUE[14]\" ></td></tr>";
echo "<tr>";
echo "<td width=\"202\">Ausgaben als valides :</td><td><input type=\"radio\" name=\"CMS_VAR[16]\" value=\"0\" ";
if ("CMS_VALUE[16]" == 0) echo "checked=\"checked\" ";
echo "> HTML <input type=\"radio\" name=\"CMS_VAR[16]\" value=\"1\" ";
if ("CMS_VALUE[16]" == 1) echo "checked=\"checked\" ";
echo "> XHTML</td></tr>";
echo "</table>";
Code: Alles auswählen
<?php
/***********************************************
* CONTENIDO MODUL - Output
*
* Modulname : linkliste 0.1 - Eintrag
* based on : vpGuestbook 1.9 Ingo van Peeren
* Copyright : Ingo van Peeren (ingo@van-peeren.de)
* Modified : rezeptionist (info@rezeptionist.de)
* Created : 2005-03-14
* Modified : 2006-01-23
************************************************/
// Mailer-Klasse einbinden
cInclude('classes', 'class.phpmailer.php');
// CMS_VARs initialisieren
$ausgabe_cat = "CMS_VALUE[1]";
$ausgabe_cont = "CMS_VALUE[2]";
$tpl_datei = "CMS_VALUE[3]";
$tpl_art = "normal";
$email_benachrichtigung = "CMS_VALUE[11]";
$emails_an = "CMS_VALUE[12]";
$cookie_aktiv = "CMS_VALUE[13]";
$cookie_dauer = "CMS_VALUE[14]";
$direkt_sichtbar = "1";
$xhtml = "CMS_VALUE[16]";
// CMS_VARs initialisieren Ende
cInclude('classes', 'class.template.php');
if ($xhtml) $einzeltag = " /";
else $einzeltag = "";
$cfg["tab"]["linkliste"] = $cfg['sql']['sqlprefix']."_linkliste";
$db = new DB_Contenido;
// Funktionen
function testURL($url) {
if(eregi("http://", $url)) {
$url = str_replace ("http://", "", $url);
}
if ($url != "") {
$url = "http://".$url;
}
return $url;
}
// function cookie_setzen ($dauer) {
// global $sess, $vpgblastentry;
// $vpgblastentry = time()+$dauer*60;
// if ($sess->is_registered("vpgblastentry")) $sess->unregister("vpgblastentry");
// $sess->register("vpgblastentry");
// }
function benachrichtigung ($name, $email, $url, $entry, $iphost, $user1, $user2, $user3, $image) {
global $emails_an, $userfeld1, $userfeld2, $userfeld3;
$mailtext = "Es gibt einen neuen Eintrag im Gästebuch:
Name: ".html_entity_decode($name)."
E-Mail: $email
Homepage: $url
IP/Hostname: $iphost
$userfeld1: ".html_entity_decode($user1)."
$userfeld2: ".html_entity_decode($user2)."
$userfeld3: ".html_entity_decode($user3)."
Bild: $image
Eintrag:
".html_entity_decode($entry)."
";
$mail = new phpmailer();
$mail->AddAddress($emails_an);
$mail->From = $emails_an;
$mail->FromName = "Gästebuch";
$mail->Subject = "Neuer Gästebucheintrag";
$mail->Body = $mailtext;
if(!$mail->Send()){
$notsend .= $lngNews["mailcouldnotbesend1"].$to.$lngNews["mailcouldnotbesend2"] . "<br>";
}
}
function eintragen () {
global $db, $cfg, $client, $lang, $idart, $direkt_sichtbar, $email_benachrichtigung, $smilies_aktiv, $bbcode_aktiv, $bilder, $xhtml;
// Initialisieren der Variablen
$error = "";
// Name überprüfen
if ($_POST['name'] == "") {
$error = "Bitte geben Sie Ihren Namen an!";
}
else {
$name = htmlentities(strip_tags($_POST['name']));
}
// Email überprüfen
$email_pattern = '/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i';
if (($_POST['email'] == "") || (preg_match($email_pattern, $_POST['email']))) {
$email = $_POST['email'];
}
else {
$error = "Bitte geben Sie eine gültige Email-Adresse an!";
}
// URL überprüfen
if ($_POST['url'] != "") {
$url = htmlentities(strip_tags($_POST['url']));
$url = testURL($url);
}
// Eintrag überprüfen
if ($_POST['entry'] == "") {
$error = "Bitte schreiben Sie einen Eintrag!";
}
else {
$hentry = strip_tags(htmlentities($_POST['entry']));
$entry = $hentry;
if ($smilies_aktiv) $entry = smilies_ersetzen($entry);
if ($bbcode_aktiv) $entry = bbcode_ersetzen($entry);
}
// Bilder prüfen
if (($_POST['image'] == "") || (in_array ($_POST['image'], $bilder))) {
$image = $_POST['image'];
}
// IP und Hostname speichern
$iphost = $_SERVER["REMOTE_ADDR"];
$host = @gethostbyaddr($_SERVER["REMOTE_ADDR"]);
if ($host) $iphost .= " / " . $host;
// der eigentliche Eintrag in die Datenbank
if ($error == "") {
$sql = "INSERT INTO ".$cfg["tab"]["linkliste"]." (name, email, url, entry, image, iphost, user1, user2, user3, active, client, lang, date) VALUES ('$name', '$email', '$url', '$entry', '$image', '$iphost', '$user1', '$user2', '$user3', $direkt_sichtbar, $client, $lang, NOW())";
if (! $db->query($sql)) $error = $db->$Error;
elseif ($email_benachrichtigung) benachrichtigung ($name, $email, $url, $hentry, $iphost, $user1, $user2, $user3, $image);
}
return $error;
}
// Funktionen Ende
$formular_anzeigen = TRUE;
if ($_POST) {
if ($sess->is_registered("vpgblastentry")) {
$lastentry = $GLOBALS["vpgblastentry"];
}
if (($lastentry >= time()) && ($cookie_aktiv)) $fehler = "Bitte nicht mehrmals hintereinander eintragen!";
else $fehler = eintragen();
if ($fehler != "") {
$formular_anzeigen = TRUE;
echo "Fehler: " . $fehler;
}
elseif ($direkt_sichtbar) {
echo "Der Link wurde in die Datenbank aufgenommen <br /><a href=\"javascript:history.back(-1)\">weiteren Termin eintragen</a>";
$formular_anzeigen = FALSE;
if ($cookie_aktiv) cookie_setzen ($cookie_dauer);
}
else {
echo "Vielen Dank für Ihren Eintrag! Dieser wird nach Prüfung freigeschaltet.";
$formular_anzeigen = FALSE;
if ($cookie_aktiv) cookie_setzen ($cookie_dauer);
}
}
if ($formular_anzeigen) {
if ($smilies_aktiv) {
// Smilies HTML-Ausgabe
$smiliesform = smilies_ausgeben($smilies);
}
$nameform = "<input id=\"name\" type=\"text\" name=\"name\" size=\"18\"".$einzeltag.">";
$emailform = "<input id=\"email\" type=\"text\" name=\"email\" size=\"18\"".$einzeltag.">";
$urlform = "<input id=\"url\" type=\"text\" name=\"url\" size=\"18\"".$einzeltag.">";
$entryform = "<textarea id=\"entry\" name=\"entry\" cols=\"30\" rows=\"10\" onselect=\"storeCaret(this);\" onclick=\"storeCaret(this);\" onkeyup=\"storeCaret(this);\"></textarea>";
$submitform = "<input type=\"submit\" class=\"submit\" name=\"vpgb_submit\" value=\"eintragen\"".$einzeltag.">";
$tpl = new Template;
$tpl->reset();
$tpl->set('s', 'NAMEFORM', $nameform);
$tpl->set('s', 'EMAILFORM', $emailform);
$tpl->set('s', 'URLFORM', $urlform);
$tpl->set('s', 'ENTRYFORM', $entryform);
$tpl->set('s', 'SUBMITFORM', $submitform);
?>
<script type="text/javascript">
function submitForm (s) {
s.disabled = true;
s.value = "Vielen Dank!";
return true;
}
</script>
<?php
echo "<form action=\"front_content.php?idcatart=$idcatart\" method=\"post\" id=\"vpgb_eintrag\" onSubmit=\"return submitForm(this.vpgb_submit)\">";
$tpl->generate('templates/' . $tpl_datei);
echo "</form>";
}
?>
Linkliste Ausgabe:
Input:
Code: Alles auswählen
/***********************************************
* CONTENIDO MODUL - INPUT
*
* Modulname : linkliste 0.1 - Ausgabe
* based on : vpGuestbook 1.9 Ingo van Peeren
* Copyright : Ingo van Peeren (ingo@van-peeren.de)
* Modified : rezeptionist (info@rezeptionist.de)
* Created : 2005-03-14
* Modified : 2006-01-23
************************************************/
$cfg["tab"]["linkliste"] = $cfg['sql']['sqlprefix']."_linkliste";
$db = new DB_Contenido;
$sql = "CREATE TABLE IF NOT EXISTS `".$cfg["tab"]["linkliste"]."` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(60) NOT NULL default '',
`email` varchar(80) NOT NULL default '',
`url` varchar(80) NOT NULL default '',
`entry` text NOT NULL,
`image` varchar(255) NOT NULL default '',
`comment` text NOT NULL,
`iphost` varchar(60) NOT NULL default '',
`user1` varchar(255) NOT NULL default '',
`user2` varchar(255) NOT NULL default '',
`user3` varchar(255) NOT NULL default '',
`active` int(1) NOT NULL default '1',
`client` int(10) NOT NULL default '0',
`lang` int(10) NOT NULL default '0',
`art` int(10) NOT NULL default '0',
`date` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
KEY `client` (`client`),
KEY `lang` (`lang`),
KEY `art` (`art`)
) TYPE=MyISAM;";
$db->query($sql);
if (! function_exists('dir_list')) {
#Build folder list recursively
function dir_list($dir, $sPrefix, $show_options = 0) {
global $sSelected, $cfgClient, $client;
$old_path = getcwd();
$sPathDir = $cfgClient[$client]["path"]["frontend"].$cfgClient[$client]["upload"].$dir;
if (is_dir($sPathDir)) {
chdir($sPathDir);
$myhandle = opendir('.');
while (($mydir = readdir($myhandle)) !== false) {
if (($mydir != ".") && ($mydir != "..")) {
if (is_dir($mydir)) {
$dirs[] = $dir.$mydir."/";
$prefixs[] = $sPrefix.$mydir;
$ret = dir_list($dir.$mydir."/", ' '.$sPrefix);
foreach ($ret['dirs'] as $key => $value) {
$dirs[] = $value;
$prefixs[] = $ret['prefixs'][$key];
}
chdir($sPathDir);
}
}
}
closedir($myhandle);
}
chdir($old_path);
if ($show_options == 1) {
array_multisort ($dirs, $prefixs);
foreach ($dirs as $key => $value) {
if ($sSelected == $value) {
echo '<option selected value="'.$value.'">'.$prefixs[$key].'</option>';
}
else {
echo '<option value="'.$value.'">'.$prefixs[$key].'</option>';
}
}
}
else {
$ret['dirs'] = $dirs;
$ret['prefixs'] = $prefixs;
return $ret;
}
}
}
$hier = getcwd ();
if ($cfgClient[$client][tpl][path]) chdir($cfgClient[$client][tpl][path]);
else chdir($cfgClient[$client][path][frontend]."templates/");
$handle = opendir(".");
while ($file = readdir($handle)) {
if (is_dir($file)) $dirlist[] = $file;
if (is_file($file)) $filelist[] = $file;
}
closedir($handle);
chdir($hier);
if ($filelist) {
asort($filelist);
}
echo "<table cellspacing=\"0\" cellpadding=\"10\" border=\"0\">";
// echo "<tr valign=\"top\"><td>Ausgabe mandantenspezifisch: ";
// echo "</td><td><input type=\"checkbox\" name=\"CMS_VAR[1]\" value=\"1\" ";
// if("CMS_VALUE[1]" == 1) echo "checked=\"checked\" ";
// echo ">";
// echo "</td></tr>";
// echo "<tr valign=\"top\"><td>Ausgabe sprachspezifisch: ";
// echo "</td><td><input type=\"checkbox\" name=\"CMS_VAR[2]\" value=\"1\" ";
// if("CMS_VALUE[2]" == 1) echo "checked=\"checked\" ";
// echo ">";
// echo "</td></tr>";
echo "<tr><td>Templatedatei: ";
echo "<td><select size=\"1\" name=\"CMS_VAR[3]\">";
while (list ($key, $file) = each ($filelist)) {
echo "<option value=\"$file\"";
if ("CMS_VALUE[3]" == $file) echo " selected=\"selected\" ";
echo ">$file</option>";
}
echo "</td></tr>";
echo "<tr><td>Einträge pro Seite:</td>";
echo "<td><select size=\"1\" name=\"CMS_VAR[6]\">";
for ($i = 1; $i < 41; $i++) {
echo "<option value=\"$i\"";
if ("CMS_VALUE[6]" == $i) echo " selected=\"selected\" ";
echo ">$i</option>";
}
echo "</select></td></tr>";
echo "<tr>";
echo "<td>Seitennavigation mit</td><td><input type=\"radio\" name=\"CMS_VAR[7]\" value=\"0\" ";
if ("CMS_VALUE[7]" == 0) echo "checked=\"checked\" ";
echo"> Seitenzahlen
<input type=\"radio\" name=\"CMS_VAR[7]\" value=\"1\" ";
if ("CMS_VALUE[7]" == 1) echo "checked=\"checked\" ";
echo"> Einträgen</td></tr>";
// echo "<tr><td>Längste Zeichenfolge:</td>";
// echo "<td><input type=\"text\" name=\"CMS_VAR[11]\" value=\"CMS_VALUE[11]\" size=\"30\" /></td></tr>";
echo "<tr><td>Text \"vor\":</td>";
echo "<td><input type=\"text\" name=\"CMS_VAR[12]\" value=\"CMS_VALUE[12]\" size=\"30\" /></td></tr>";
echo "<tr><td>Text \"zurück\":</td>";
echo "<td><input type=\"text\" name=\"CMS_VAR[13]\" value=\"CMS_VALUE[13]\" size=\"30\" /></td></tr>";
echo "<tr><td>Ab wie vielen Seiten soll die Navigation komprimiert dargestellt werden?:</td>";
echo "<td><input type=\"text\" name=\"CMS_VAR[14]\" value=\"CMS_VALUE[14]\" size=\"30\" /></td></tr>";
echo "</table>";
Code: Alles auswählen
<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname : linkliste 0.1 - Ausgabe
* based on : vpGuestbook 1.9 Ingo van Peeren
* Copyright : Ingo van Peeren (ingo@van-peeren.de)
* Modified : rezeptionist (info@rezeptionist.de)
* Created : 2005-03-14
* Modified : 2006-01-23
************************************************/
// CMS_VARs initialisieren
$spez_client = "CMS_VALUE[1]";
$spez_lang = "CMS_VALUE[2]";
$tpl_datei = "CMS_VALUE[3]";
$tpl_art = "normal";
$eintraege_pro_seite = "CMS_VALUE[6]";
$seitennav_art = "CMS_VALUE[7]";
$locale = "CMS_VALUE[10]";
$wrap_length = "CMS_VALUE[11]";
$link_vor = "CMS_VALUE[12]";
$link_zurueck = "CMS_VALUE[13]";
$max_seiten = "CMS_VALUE[14]";
// CMS_VARs initialisieren Ende
cInclude('classes', 'class.template.php');
$edit_url = "front_content.php?changeview=edit&client=$client&lang=$lang&action=con_editart&idartlang=$idartlang&idart=$idart&idcat=$idcat&contenido=" . $sess->id;
// locale auf ausgewählten Wert setzen
setlocale (LC_ALL, $locale);
// DB-Verbindung konfigurieren
$cfg["tab"]["linkliste"] = $cfg['sql']['sqlprefix']."_linkliste";
$db = new DB_Contenido;
// Funktionen
function htmlwrap($str, $width = 500, $break = "\n", $nobreak = "", $nobr = "pre", $utf = false) {
// Split HTML content into an array delimited by < and >
// The flags save the delimeters and remove empty variables
$content = preg_split("/([<>])/", $str, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
// Transform protected element lists into arrays
$nobreak = explode(" ", $nobreak);
$nobr = explode(" ", $nobr);
// Variable setup
$intag = false;
$innbk = array();
$innbr = array();
$drain = "";
$utf = ($utf) ? "u" : "";
// List of characters it is "safe" to insert line-breaks at
// Do not add ampersand (&) as it will mess up HTML Entities
// It is not necessary to add < and >
$lbrks = "/?!%)-}]\\\"':;";
// We use \r for adding <br /> in the right spots so just switch to \n
if ($break == "\r") $break = "\n";
while (list(, $value) = each($content)) {
switch ($value) {
// If a < is encountered, set the "in-tag" flag
case "<": $intag = true; break;
// If a > is encountered, remove the flag
case ">": $intag = false; break;
default:
// If we are currently within a tag...
if ($intag) {
// If the first character is not a / then this is an opening tag
if ($value{0} != "/") {
// Collect the tag name
preg_match("/^(.*?)(\s|$)/$utf", $value, $t);
// If this is a protected element, activate the associated protection flag
if ((!count($innbk) && in_array($t[1], $nobreak)) || in_array($t[1], $innbk)) $innbk[] = $t[1];
if ((!count($innbr) && in_array($t[1], $nobr)) || in_array($t[1], $innbr)) $innbr[] = $t[1];
// Otherwise this is a closing tag
} else {
// If this is a closing tag for a protected element, unset the flag
if (in_array(substr($value, 1), $innbk)) unset($innbk[count($innbk)]);
if (in_array(substr($value, 1), $innbr)) unset($innbr[count($innbr)]);
}
// Else if we're outside any tags...
} else if ($value) {
// If unprotected, remove all existing \r, replace all existing \n with \r
if (!count($innbr)) $value = str_replace("\n", "\r", str_replace("\r", "", $value));
// If unprotected, enter the line-break loop
if (!count($innbk)) {
do {
$store = $value;
// Find the first stretch of characters over the $width limit
if (preg_match("/^(.*?\s|^)(([^\s&]|&(\w{2,5}|#\d{2,4});){".$width."})(?!(".preg_quote($break, "/")."|\s))(.*)$/s$utf", $value, $match)) {
// Determine the last "safe line-break" character within this match
for ($x = 0, $ledge = 0; $x < strlen($lbrks); $x++) $ledge = max($ledge, strrpos($match[2], $lbrks{$x}));
if (!$ledge) $ledge = strlen($match[2]) - 1;
// Insert the modified string
$value = $match[1].substr($match[2], 0, $ledge + 1).$break.substr($match[2], $ledge + 1).$match[6];
}
// Loop while overlimit strings are still being found
} while ($store != $value);
}
// If unprotected, replace all \r with <br />\n to finish
if (!count($innbr)) $value = str_replace("\r", "<br />\n", $value);
}
}
// Send the modified segment down the drain
$drain .= $value;
}
// Return contents of the drain
return $drain;
}
function toggle_active ($entry) {
global $db, $cfg;
$sql = "UPDATE ".$cfg["tab"]["linkliste"]." SET active = '1' WHERE id='$entry'";
$db->query($sql);
}
function toggle_inactive ($entry) {
global $db, $cfg;
$sql = "UPDATE ".$cfg["tab"]["linkliste"]." SET active = '0' WHERE id='$entry'";
$db->query($sql);
}
function eintrag_loeschen ($entry) {
global $db, $cfg;
$sql = "DELETE FROM ".$cfg["tab"]["linkliste"]." WHERE id='$entry'";
$db->query($sql);
}
function eintraege_zaehlen () {
global $db, $cfg, $client;
$sql = "SELECT COUNT(*) as anzahl FROM ".$cfg["tab"]["linkliste"]." WHERE client=$client AND active=1";
$db->query($sql);
$db->next_record();
return $db->f("anzahl");
}
function eintraege_auslesen ($start, $anzahl) {
global $db, $cfg, $client, $lang, $idart, $spez_client, $spez_lang, $edit;
if ($edit && empty($_GET['edit'])) $where = "WHERE 1";
else $where = "WHERE active=1";
if ($spez_client) $where .= " AND client=$client";
if ($spez_lang) $where .= " AND lang=$lang";
$sql = "SELECT id, active, name, email, url, entry, image, comment, iphost, user1, user2, user3, UNIX_TIMESTAMP(date) as datum FROM ".$cfg["tab"]["linkliste"]." $where ORDER BY name ASC LIMIT $start, $anzahl";
$db->query($sql);
$eintraege = array();
$i = 0;
while ($db->next_record()) {
$eintraege[$i]['id'] = $db->f("id");
$eintraege[$i]['active'] = $db->f("active");
$eintraege[$i]['name'] = $db->f("name");
$eintraege[$i]['email'] = $db->f("email");
$eintraege[$i]['url'] = $db->f("url");
$eintraege[$i]['entry'] = $db->f("entry");
$eintraege[$i]['comment'] = $db->f("comment");
$i++;
}
return $eintraege;
}
function vpgb_navigation ($start, $eintraege_pro_seite, $anzahl_eintraege, $art = 1) {
global $link_vor, $link_zurueck, $idcat, $idcatart, $max_seiten;
$hier = "front_content.php?idcatart=" . $idcatart;
$vpgb_nav = "";
if ($start > 0) {
$vpgb_nav .= "<a href=\"" . $hier . "&start=" . ($start - $eintraege_pro_seite) . "\">" . $link_zurueck . "</a>";
}
if ($anzahl_eintraege > $eintraege_pro_seite) {
$anzahl_seiten = ceil($anzahl_eintraege / $eintraege_pro_seite);
if (($max_seiten == "") || ($max_seiten > $anzahl_seiten)) {
for ($h = 1; $h <= $anzahl_seiten; $h++) {
$hstart = ($h - 1) * $eintraege_pro_seite;
if ($art == 1) {
if ($h == $anzahl_seiten) {
if ($anzahl_eintraege > ($hstart + 1)) $htext = ($hstart + 1) . "-" . $anzahl_eintraege;
else $htext = $anzahl_eintraege;
}
else $htext = ($hstart + 1) . "-" . ($hstart + $eintraege_pro_seite);
}
else $htext = $h;
if ($hstart == $start) $vpgb_nav .= " <a class=\"vpgb_aktiv\" href=\"" . $hier . "&start=" . $hstart . "\">" . $htext . "</a>";
else $vpgb_nav .= " <a href=\"" . $hier . "&start=" . $hstart . "\">" . $htext . "</a>";
}
}
else {
for ($h = 1; $h <= $anzahl_seiten; $h++) {
$hstart = ($h - 1) * $eintraege_pro_seite;
if ($art == 1) {
if ($h == $anzahl_seiten) {
if ($anzahl_eintraege > ($hstart + 1)) $htext = ($hstart + 1) . "-" . $anzahl_eintraege;
else $htext = $anzahl_eintraege;
}
else $htext = ($hstart + 1) . "-" . ($hstart + $eintraege_pro_seite);
}
else $htext = $h;
if (($hstart < $eintraege_pro_seite * 2) || ($hstart > (($anzahl_seiten - 3) * $eintraege_pro_seite)) || (($hstart > ($start - ($eintraege_pro_seite * 2))) && ($hstart < ($start + ($eintraege_pro_seite * 2))))) {
if ($hstart == $start) $vpgb_nav .= " <a class=\"vpgb_aktiv\" href=\"" . $hier . "&start=" . $hstart . "\">" . $htext . "</a>";
else $vpgb_nav .= " <a href=\"" . $hier . "&start=" . $hstart . "\">" . $htext . "</a>";
}
else $vpgb_nav .= "###";
}
}
}
if (($start + $eintraege_pro_seite) < $anzahl_eintraege) {
$vpgb_nav .= " <a href=\"" . $hier . "&start=" . ($start + $eintraege_pro_seite) . "\">" . $link_vor . "</a>";
}
$vpgb_nav = preg_replace("/(\#+)/", " <span class=\"vpgb_punkte\">…</span>", $vpgb_nav);
return $vpgb_nav;
}
function edit_comment ($entry_id, $new_entry, $type) {
global $db, $cfg, $client;
if ($type == "delete") {
$sql = "UPDATE ".$cfg["tab"]["linkliste"]." SET entry = '' WHERE id='$entry_id'";
$db->query($sql);
}
else {
$sql = "UPDATE ".$cfg["tab"]["linkliste"]." SET entry = '$new_entry' WHERE id='$entry_id'";
$db->query($sql);
}
}
// Funktionen Ende
if ($edit && empty($_GET['edit'])) {
if ($_GET['toggle_active'] == "yes") toggle_active($_GET['entry']);
if ($_GET['toggle_inactive'] == "yes") toggle_inactive($_GET['entry']);
if ($_GET['delete'] == "yes") eintrag_loeschen($_GET['entry']);
if ($_POST['edit_comment']) edit_comment($_GET['entry'], $_POST['entry'], "edit");
if ($_POST['delete_comment']) edit_comment($_GET['entry'], $_POST['entry'], "delete");
}
if (! $_GET['start']) $start = 0;
else $start = $_GET['start'];
// Einträge
$anzahl_eintraege = eintraege_zaehlen();
if ($edit && empty($_GET['edit'])) {
$eintraege = eintraege_auslesen(0, 10000);
$seitennavigation = "";
}
else {
$eintraege = eintraege_auslesen($start, $eintraege_pro_seite);
if ($seitennav_art == 1) $seitennavigation = vpgb_navigation($start, $eintraege_pro_seite, $anzahl_eintraege, 1);
else $seitennavigation = vpgb_navigation($start, $eintraege_pro_seite, $anzahl_eintraege, 0);
}
$tpl = new Template;
$tpl->reset();
$tpl->set('s', 'EINTRAEGE', $anzahl_eintraege);
$tpl->set('s', 'SEITENNAVIGATION', $seitennavigation);
foreach ($eintraege as $eintrag) {
if ($edit && empty($_GET['edit'])) {
$tpl->set('d', 'EDIT', "1");
if ($eintrag['active']) $adminlinks = "<a href=\"" . $edit_url . "&toggle_inactive=yes&entry=" . $eintrag['id'] . "\"><img src=\"" . $cfg['path']['contenido_fullhtml'] . "images/online.gif\" width=\"11\" height=\"12\" border=\"0\" title=\"Offline schalten\" alt=\"Offline schalten\"></a>";
else $adminlinks = "<a href=\"" . $edit_url . "&toggle_active=yes&entry=" . $eintrag['id'] . "\"><img src=\"" . $cfg['path']['contenido_fullhtml'] . "images/offline.gif\" width=\"11\" height=\"12\" border=\"0\" title=\"Online schalten\" alt=\"Online schalten\"></a>";
$adminlinks .= '<a title="Modul löschen" href="' . $edit_url . '&delete=yes&entry=' . $eintrag['id'] . '" onClick="return confirm(\'Wollen Sie den Gästebucheintrag von ' . $eintrag['name'] . ' wirklich löschen?\')" ><img src="' . $cfg['path']['contenido_fullhtml'] . 'images/delete.gif" border="0" title="Eintrag löschen" alt="Eintrag löschen"></a>';
$eintraganders = "<form action=\"" . $edit_url . "&entry=" . $eintrag['id'] . "\" method=\"post\">";
$eintraganders .= "<textarea name=\"entry\" style=\"width:100%;\">" . $eintrag['entry'] . "</textarea><input type=\"submit\" name=\"edit_comment\" value=\"ändern\">";
$eintraganders .= "</form>";
}
else {
$comment = htmlwrap($eintrag['comment'], $wrap_length, " ");
}
$tpl->set('d', 'NAME', $eintrag['name']);
$tpl->set('d', 'EMAIL', $eintrag['email']);
$tpl->set('d', 'URL', $eintrag['url']);
$tpl->set('d', 'ENTRY', htmlwrap($eintrag['entry'], $wrap_length, " "));
$tpl->set('d', 'ANDERS', $eintraganders);
$tpl->set('d', 'ADMINLINKS', $adminlinks);
$tpl->next();
}
$tpl->generate('templates/' . $tpl_datei);
?>
Templates:
linkliste_eintrag.html
Code: Alles auswählen
<div><label class="fleft" for="name">Linkname :</label><br />{NAMEFORM} <div />
<div><label class="fleft" for="url">URL :</label><br />{URLFORM} <div />
<div><label class="fleft" for="entry">Beschreibung :</label><br />{ENTRYFORM}<div />
<div class="fright">{SUBMITFORM}</div>
linkliste_ausgabe.html
Code: Alles auswählen
<!-- BEGIN:BLOCK -->
<li><a href="{URL}">{NAME}</a>{ADMINLINKS}</li>
<div style="margin-left:15px; width: 250px;">{ENTRY}</div>
{ANDERS}
<!-- END:BLOCK -->
<div id="nav">{SEITENNAVIGATION}</div>
Vielleicht nicht die eleganteste aber sie funktioniert