mysql to mysqli and a lot of cleanup and mvc
parent
d50cc21f50
commit
bfb0cacd54
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a fatal message and stops execution.
|
||||||
|
* @param string $message
|
||||||
|
*/
|
||||||
|
function engelsystem_error($message) {
|
||||||
|
die($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt zwischengespeicherte Fehlermeldungen zurück und löscht den Zwischenspeicher
|
||||||
|
*/
|
||||||
|
function msg() {
|
||||||
|
if (!isset ($_SESSION['msg']))
|
||||||
|
return "";
|
||||||
|
$msg = $_SESSION['msg'];
|
||||||
|
$_SESSION['msg'] = "";
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rendert eine Information
|
||||||
|
*/
|
||||||
|
function info($msg, $immediatly = false) {
|
||||||
|
if ($immediatly) {
|
||||||
|
if ($msg == "")
|
||||||
|
return "";
|
||||||
|
return '<p class="info">' . $msg . '</p>';
|
||||||
|
} else {
|
||||||
|
if (!isset ($_SESSION['msg']))
|
||||||
|
$_SESSION['msg'] = "";
|
||||||
|
$_SESSION['msg'] .= info($msg, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rendert eine Fehlermeldung
|
||||||
|
*/
|
||||||
|
function error($msg, $immediatly = false) {
|
||||||
|
if ($immediatly) {
|
||||||
|
if ($msg == "")
|
||||||
|
return "";
|
||||||
|
return '<p class="error">' . $msg . '</p>';
|
||||||
|
} else {
|
||||||
|
if (!isset ($_SESSION['msg']))
|
||||||
|
$_SESSION['msg'] = "";
|
||||||
|
$_SESSION['msg'] .= error($msg, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rendert eine Erfolgsmeldung
|
||||||
|
*/
|
||||||
|
function success($msg, $immediatly = false) {
|
||||||
|
if ($immediatly) {
|
||||||
|
if ($msg == "")
|
||||||
|
return "";
|
||||||
|
return '<p class="success">' . $msg . '</p>';
|
||||||
|
} else {
|
||||||
|
if (!isset ($_SESSION['msg']))
|
||||||
|
$_SESSION['msg'] = "";
|
||||||
|
$_SESSION['msg'] .= success($msg, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a string by key.
|
||||||
|
* @param string $textid
|
||||||
|
* @param string $sprache
|
||||||
|
*/
|
||||||
|
function Sprache($textid, $sprache) {
|
||||||
|
$sprache_source = sql_select("SELECT * FROM `Sprache` WHERE `TextID`='" . sql_escape($textid) . "' AND `Sprache`='" . sql_escape($sprache) . "' LIMIT 1");
|
||||||
|
if($sprache_source === false)
|
||||||
|
return false;
|
||||||
|
if(count($sprache_source) == 1)
|
||||||
|
return $sprache_source[0];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,176 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close connection.
|
||||||
|
*/
|
||||||
|
function sql_close() {
|
||||||
|
global $sql_connection;
|
||||||
|
|
||||||
|
return $sql_connection->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start new transaction.
|
||||||
|
*/
|
||||||
|
function sql_transaction_start() {
|
||||||
|
global $sql_nested_transaction_level;
|
||||||
|
|
||||||
|
if($sql_nested_transaction_level++ == 0)
|
||||||
|
return sql_query("BEGIN");
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Commit transaction.
|
||||||
|
*/
|
||||||
|
function sql_transaction_commit() {
|
||||||
|
global $sql_nested_transaction_level;
|
||||||
|
|
||||||
|
if(--$sql_nested_transaction_level == 0)
|
||||||
|
return sql_query("COMMIT");
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop transaction, revert database.
|
||||||
|
*/
|
||||||
|
function sql_transaction_rollback() {
|
||||||
|
global $sql_nested_transaction_level;
|
||||||
|
|
||||||
|
if(--$sql_nested_transaction_level == 0)
|
||||||
|
return sql_query("ROLLBACK");
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs an sql error.
|
||||||
|
* @param string $message
|
||||||
|
* @return false
|
||||||
|
*/
|
||||||
|
function sql_error($message) {
|
||||||
|
sql_close();
|
||||||
|
|
||||||
|
$message = trim($message) . "\n";
|
||||||
|
$message .= debug_string_backtrace() . "\n";
|
||||||
|
|
||||||
|
error_log('mysql_provider error: ' . $message);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connect to mysql server.
|
||||||
|
* @param string $host Host
|
||||||
|
* @param string $user Username
|
||||||
|
* @param string $pass Password
|
||||||
|
* @param string $db DB to select
|
||||||
|
* @return mysqli The connection handler
|
||||||
|
*/
|
||||||
|
function sql_connect($host, $user, $pass, $db) {
|
||||||
|
global $sql_connection;
|
||||||
|
|
||||||
|
$sql_connection = new mysqli($host, $user, $pass, $db);
|
||||||
|
if ($sql_connection->connect_errno)
|
||||||
|
return sql_error("Unable to connect to MySQL: " . $sql_connection->connect_error);
|
||||||
|
|
||||||
|
$result = $sql_connection->query("SET CHARACTER SET utf8;");
|
||||||
|
if (! $result)
|
||||||
|
return sql_error("Unable to set utf8 character set (" . $sql_connection->errno . ") " . $sql_connection->error);
|
||||||
|
|
||||||
|
$result = $sql_connection->set_charset('utf8');
|
||||||
|
if (! $result)
|
||||||
|
return sql_error("Unable to set utf8 names (" . $sql_connection->errno . ") " . $sql_connection->error);
|
||||||
|
|
||||||
|
return $sql_connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the selected db in current mysql-connection.
|
||||||
|
* @param $db_name
|
||||||
|
* @return bool true on success, false on error
|
||||||
|
*/
|
||||||
|
function sql_select_db($db_name) {
|
||||||
|
global $sql_connection;
|
||||||
|
if (!$sql_connection->select_db($db_name))
|
||||||
|
return sql_error("No database selected.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MySQL SELECT query
|
||||||
|
* @param string $query
|
||||||
|
* @return Result array or false on error
|
||||||
|
*/
|
||||||
|
function sql_select($query) {
|
||||||
|
global $sql_connection;
|
||||||
|
|
||||||
|
$result = $sql_connection->query($query);
|
||||||
|
if ($result) {
|
||||||
|
$data = array();
|
||||||
|
while ($line = $result->fetch_assoc())
|
||||||
|
array_push($data, $line);
|
||||||
|
return $data;
|
||||||
|
} else
|
||||||
|
return sql_error("MySQL-query error: " . $query . " (" . $sql_connection->errno . ") " . $sql_connection->error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MySQL execute a query
|
||||||
|
* @param string $query
|
||||||
|
* @return mysqli_result|boolean Result resource or false on error
|
||||||
|
*/
|
||||||
|
function sql_query($query) {
|
||||||
|
global $sql_connection;
|
||||||
|
|
||||||
|
$result = $sql_connection->query($query);
|
||||||
|
if ($result) {
|
||||||
|
return $result;
|
||||||
|
} else
|
||||||
|
usr_error("MySQL-query error: " . $query . " (" . $sql_connection->errno . ") " . $sql_connection->error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns last inserted id.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
function sql_id() {
|
||||||
|
global $sql_connection;
|
||||||
|
return $sql_connection->insert_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escape a string for a sql query.
|
||||||
|
*
|
||||||
|
* @param string $query
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function sql_escape($query) {
|
||||||
|
global $sql_connection;
|
||||||
|
return $sql_connection->real_escape_string($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count query result lines.
|
||||||
|
*
|
||||||
|
* @param string $query
|
||||||
|
* @return int Count of result lines
|
||||||
|
*/
|
||||||
|
function sql_num_query($query) {
|
||||||
|
global $sql_connection;
|
||||||
|
return sql_query($query)->num_rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sql_select_single_col($query) {
|
||||||
|
$result = sql_select($query);
|
||||||
|
return array_map('array_shift', $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
function sql_select_single_cell($query) {
|
||||||
|
return array_shift(array_shift(sql_select($query)));
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -1,110 +1,105 @@
|
|||||||
<?php
|
<?php
|
||||||
function admin_language() {
|
function admin_language() {
|
||||||
global $user;
|
global $user;
|
||||||
|
global $languages;
|
||||||
$html = "";
|
|
||||||
if (!isset ($_POST["TextID"])) {
|
$html = "";
|
||||||
$html .= Get_Text("Hello") . User_Nick_render($user) . ", <br />\n";
|
if (!isset ($_POST["TextID"])) {
|
||||||
$html .= Get_Text("pub_sprache_text1") . "<br /><br />\n";
|
$html .= Get_Text("Hello") . User_Nick_render($user) . ", <br />\n";
|
||||||
|
$html .= Get_Text("pub_sprache_text1") . "<br /><br />\n";
|
||||||
$html .= "<a href=\"" . page_link_to("admin_language") . "&ShowEntry=y\">" . Get_Text("pub_sprache_ShowEntry") . "</a>";
|
|
||||||
// ausgabe Tabellenueberschift
|
$html .= "<a href=\"" . page_link_to("admin_language") . "&ShowEntry=y\">" . Get_Text("pub_sprache_ShowEntry") . "</a>";
|
||||||
$SQL_Sprachen = "SELECT `Sprache` FROM `Sprache` GROUP BY `Sprache`;";
|
// ausgabe Tabellenueberschift
|
||||||
$erg_Sprachen = sql_query($SQL_Sprachen);
|
$html .= "\t<table border=\"0\" class=\"border\" cellpadding=\"2\" cellspacing=\"1\">\n\t\t<tr>";
|
||||||
|
$html .= "\t\t<td class=\"contenttopic\"><b>" . Get_Text("pub_sprache_TextID") . "</b></td>";
|
||||||
for ($i = 0; $i < mysql_num_rows($erg_Sprachen); $i++)
|
foreach($languages as $language => $language_name) {
|
||||||
$Sprachen[mysql_result($erg_Sprachen, $i, "Sprache")] = $i;
|
$html .= "<td class=\"contenttopic\"><b>" .
|
||||||
|
Get_Text("pub_sprache_Sprache") . " " . $language .
|
||||||
$html .= "\t<table border=\"0\" class=\"border\" cellpadding=\"2\" cellspacing=\"1\">\n\t\t<tr>";
|
"</b></td>";
|
||||||
$html .= "\t\t<td class=\"contenttopic\"><b>" . Get_Text("pub_sprache_TextID") . "</b></td>";
|
$Sprachen[$language] = $language_name;
|
||||||
foreach ($Sprachen as $Name => $Value)
|
}
|
||||||
$html .= "<td class=\"contenttopic\"><b>" .
|
$html .= "\t\t<td class=\"contenttopic\"><b>" . Get_Text("pub_sprache_Edit") . "</b></td>";
|
||||||
Get_Text("pub_sprache_Sprache") . " " . $Name .
|
$html .= "\t\t</tr>";
|
||||||
"</b></td>";
|
|
||||||
$html .= "\t\t<td class=\"contenttopic\"><b>" . Get_Text("pub_sprache_Edit") . "</b></td>";
|
if (isset ($_GET["ShowEntry"])) {
|
||||||
$html .= "\t\t</tr>";
|
// ausgabe eintraege
|
||||||
|
$sprache_source = sql_select("SELECT * FROM `Sprache` ORDER BY `TextID`, `Sprache`");
|
||||||
if (isset ($_GET["ShowEntry"])) {
|
|
||||||
// ausgabe eintraege
|
$TextID_Old = $sprache_source[0]['TextID'];
|
||||||
$SQL = "SELECT * FROM `Sprache` ORDER BY `TextID`;";
|
foreach($sprache_source as $sprache_entry) {
|
||||||
$erg = sql_query($SQL);
|
$TextID_New = $sprache_entry['TextID'];
|
||||||
|
if ($TextID_Old != $TextID_New) {
|
||||||
$TextID_Old = mysql_result($erg, 0, "TextID");
|
$html .= "<form action=\"" . page_link_to("admin_language") . "\" method=\"post\">";
|
||||||
for ($i = 0; $i < mysql_num_rows($erg); $i++) {
|
$html .= "<tr class=\"content\">\n";
|
||||||
$TextID_New = mysql_result($erg, $i, "TextID");
|
$html .= "\t\t<td>$TextID_Old " .
|
||||||
if ($TextID_Old != $TextID_New) {
|
"<input name=\"TextID\" type=\"hidden\" value=\"$TextID_Old\"> </td>\n";
|
||||||
$html .= "<form action=\"" . page_link_to("admin_language") . "\" method=\"post\">";
|
|
||||||
$html .= "<tr class=\"content\">\n";
|
foreach ($Sprachen as $Name => $Value) {
|
||||||
$html .= "\t\t<td>$TextID_Old " .
|
$Value = html_entity_decode($Value, ENT_QUOTES);
|
||||||
"<input name=\"TextID\" type=\"hidden\" value=\"$TextID_Old\"> </td>\n";
|
$html .= "\t\t<td><textarea name=\"$Name\" cols=\"22\" rows=\"8\">$Value</textarea></td>\n";
|
||||||
|
$Sprachen[$Name] = "";
|
||||||
foreach ($Sprachen as $Name => $Value) {
|
}
|
||||||
$Value = html_entity_decode($Value, ENT_QUOTES);
|
|
||||||
$html .= "\t\t<td><textarea name=\"$Name\" cols=\"22\" rows=\"8\">$Value</textarea></td>\n";
|
$html .= "\t\t<td><input type=\"submit\" value=\"Save\"></td>\n";
|
||||||
$Sprachen[$Name] = "";
|
$html .= "</tr>";
|
||||||
}
|
$html .= "</form>\n";
|
||||||
|
$TextID_Old = $TextID_New;
|
||||||
$html .= "\t\t<td><input type=\"submit\" value=\"Save\"></td>\n";
|
}
|
||||||
$html .= "</tr>";
|
$Sprachen[$sprache_entry['Sprache']] = $sprache_entry['Text'];
|
||||||
$html .= "</form>\n";
|
} /*FOR*/
|
||||||
$TextID_Old = $TextID_New;
|
}
|
||||||
}
|
|
||||||
$Sprachen[mysql_result($erg, $i, "Sprache")] = mysql_result($erg, $i, "Text");
|
//fuer neu eintraege
|
||||||
} /*FOR*/
|
$html .= "<form action=\"" . page_link_to("admin_language") . "\" method=\"post\">";
|
||||||
}
|
$html .= "<tr class=\"content\">\n";
|
||||||
|
$html .= "\t\t<td><input name=\"TextID\" type=\"text\" size=\"40\" value=\"new\"> </td>\n";
|
||||||
//fuer neu eintraege
|
|
||||||
$html .= "<form action=\"" . page_link_to("admin_language") . "\" method=\"post\">";
|
foreach ($Sprachen as $Name => $Value)
|
||||||
$html .= "<tr class=\"content\">\n";
|
$html .= "\t\t<td><textarea name=\"$Name\" cols=\"22\" rows=\"8\">$Name Text</textarea></td>\n";
|
||||||
$html .= "\t\t<td><input name=\"TextID\" type=\"text\" size=\"40\" value=\"new\"> </td>\n";
|
|
||||||
|
$html .= "\t\t<td><input type=\"submit\" value=\"Save\"></td>\n";
|
||||||
foreach ($Sprachen as $Name => $Value)
|
$html .= "</tr>";
|
||||||
$html .= "\t\t<td><textarea name=\"$Name\" cols=\"22\" rows=\"8\">$Name Text</textarea></td>\n";
|
$html .= "</form>\n";
|
||||||
|
|
||||||
$html .= "\t\t<td><input type=\"submit\" value=\"Save\"></td>\n";
|
$html .= "</table>\n";
|
||||||
$html .= "</tr>";
|
} /*if( !isset( $TextID ) )*/
|
||||||
$html .= "</form>\n";
|
else {
|
||||||
|
$html .= "edit: " . $_POST["TextID"] . "<br /><br />";
|
||||||
$html .= "</table>\n";
|
foreach ($_POST as $k => $v) {
|
||||||
} /*if( !isset( $TextID ) )*/
|
if ($k != "TextID") {
|
||||||
else {
|
$sql_test = "SELECT * FROM `Sprache` " .
|
||||||
$html .= "edit: " . $_POST["TextID"] . "<br /><br />";
|
"WHERE `TextID`='" . sql_escape($_POST["TextID"])
|
||||||
foreach ($_POST as $k => $v) {
|
. "' AND `Sprache`='"
|
||||||
if ($k != "TextID") {
|
. sql_escape($k) . "'";
|
||||||
$sql_test = "SELECT * FROM `Sprache` " .
|
|
||||||
"WHERE `TextID`='" . sql_escape($_POST["TextID"])
|
$erg_test = sql_select("SELECT * FROM `Sprache` WHERE `TextID`='" . sql_escape($_POST["TextID"]) . "' AND `Sprache`='" . sql_escape($k) . "'");
|
||||||
. "' AND `Sprache`='"
|
if (count($erg_test) == 0) {
|
||||||
. sql_escape($k) . "'";
|
$sql_save = "INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) " .
|
||||||
|
"VALUES ('" . sql_escape($_POST["TextID"]) . "', '"
|
||||||
$erg_test = sql_query($sql_test);
|
. sql_escape($k) . "', '"
|
||||||
|
. sql_escape($v) . "')";
|
||||||
if (mysql_num_rows($erg_test) == 0) {
|
|
||||||
$sql_save = "INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) " .
|
$html .= $sql_save . "<br />";
|
||||||
"VALUES ('" . sql_escape($_POST["TextID"]) . "', '"
|
$Erg = sql_query($sql_save);
|
||||||
. sql_escape($k) . "', '"
|
$html .= success("$k Save: OK<br />\n", true);
|
||||||
. sql_escape($v) . "')";
|
} else
|
||||||
|
if ($erg_test[0]['Text'] != $v) {
|
||||||
$html .= $sql_save . "<br />";
|
$sql_save = "UPDATE `Sprache` SET `Text`='"
|
||||||
$Erg = sql_query($sql_save);
|
. sql_escape($v) . "' " .
|
||||||
$html .= success("$k Save: OK<br />\n", true);
|
"WHERE `TextID`='"
|
||||||
} else
|
. sql_escape($_POST["TextID"])
|
||||||
if (mysql_result($erg_test, 0, "Text") != $v) {
|
. "' AND `Sprache`='" . sql_escape($k) . "' ";
|
||||||
$sql_save = "UPDATE `Sprache` SET `Text`='"
|
|
||||||
. sql_escape($v) . "' " .
|
$html .= $sql_save . "<br />";
|
||||||
"WHERE `TextID`='"
|
$Erg = sql_query($sql_save);
|
||||||
. sql_escape($_POST["TextID"])
|
$html .= success(" $k Update: OK<br />\n", true);
|
||||||
. "' AND `Sprache`='" . sql_escape($k) . "' ";
|
} else
|
||||||
|
$html .= "\t $k no changes<br />\n";
|
||||||
$html .= $sql_save . "<br />";
|
}
|
||||||
$Erg = sql_query($sql_save);
|
}
|
||||||
$html .= success(" $k Update: OK<br />\n", true);
|
|
||||||
} else
|
}
|
||||||
$html .= "\t $k no changes<br />\n";
|
return $html;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return $html;
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -1,107 +1,120 @@
|
|||||||
<?php
|
<?php
|
||||||
function user_unread_messages() {
|
function user_unread_messages() {
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
|
|
||||||
if (in_array("user_messages", $privileges)) {
|
if (in_array("user_messages", $privileges)) {
|
||||||
$new_messages = sql_num_query("SELECT * FROM `Messages` WHERE isRead='N' AND `RUID`=" . sql_escape($user['UID']));
|
$new_messages = sql_num_query("SELECT * FROM `Messages` WHERE isRead='N' AND `RUID`=" . sql_escape($user['UID']));
|
||||||
|
|
||||||
if ($new_messages > 0)
|
if ($new_messages > 0)
|
||||||
return sprintf('<p class="info"><a href="%s">%s %s %s</a></p><hr />', page_link_to("user_messages"), Get_Text("pub_messages_new1"), $new_messages, Get_Text("pub_messages_new2"));
|
return sprintf('<p class="info"><a href="%s">%s %s %s</a></p><hr />', page_link_to("user_messages"), Get_Text("pub_messages_new1"), $new_messages, Get_Text("pub_messages_new2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_messages() {
|
function user_messages() {
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (!isset ($_REQUEST['action'])) {
|
if (!isset ($_REQUEST['action'])) {
|
||||||
$users = sql_select("SELECT * FROM `User` WHERE NOT `UID`=" . sql_escape($user['UID']) . " ORDER BY `Nick`");
|
$users = sql_select("SELECT * FROM `User` WHERE NOT `UID`=" . sql_escape($user['UID']) . " ORDER BY `Nick`");
|
||||||
|
|
||||||
$to_select_data = array (
|
$to_select_data = array (
|
||||||
"" => "Select recipient..."
|
"" => "Select recipient..."
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($users as $u)
|
foreach ($users as $u)
|
||||||
$to_select_data[$u['UID']] = $u['Nick'];
|
$to_select_data[$u['UID']] = $u['Nick'];
|
||||||
|
|
||||||
$to_select = html_select_key('to', 'to', $to_select_data, '');
|
$to_select = html_select_key('to', 'to', $to_select_data, '');
|
||||||
|
|
||||||
$messages_html = "";
|
$messages_html = "";
|
||||||
$messages = sql_select("SELECT * FROM `Messages` WHERE `SUID`=" . sql_escape($user['UID']) . " OR `RUID`=" . sql_escape($user['UID']) . " ORDER BY `isRead`,`Datum` DESC");
|
$messages = sql_select("SELECT * FROM `Messages` WHERE `SUID`=" . sql_escape($user['UID']) . " OR `RUID`=" . sql_escape($user['UID']) . " ORDER BY `isRead`,`Datum` DESC");
|
||||||
foreach ($messages as $message) {
|
foreach ($messages as $message) {
|
||||||
|
$sender_user_source = User($message['SUID']);
|
||||||
$messages_html .= sprintf('<tr %s> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td>' .
|
if($sender_user_source === false)
|
||||||
'<td>%s</td>', ($message['isRead'] == 'N' ? ' class="new_message"' : ''), ($message['isRead'] == 'N' ? '•' : ''), date("Y-m-d H:i", $message['Datum']), UID2Nick($message['SUID']), UID2Nick($message['RUID']), str_replace("\n", '<br />', $message['Text']));
|
engelsystem_error("Unable to load user.");
|
||||||
|
$receiver_user_source = User($message['RUID']);
|
||||||
$messages_html .= '<td>';
|
if($receiver_user_source === false)
|
||||||
if ($message['RUID'] == $user['UID']) {
|
engelsystem_error("Unable to load user.");
|
||||||
if ($message['isRead'] == 'N')
|
|
||||||
$messages_html .= '<a href="' . page_link_to("user_messages") . '&action=read&id=' . $message['id'] . '">' . Get_Text("pub_messages_MarkRead") . '</a>';
|
$messages_html .= sprintf(
|
||||||
} else {
|
'<tr %s> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td><td>%s</td>',
|
||||||
$messages_html .= '<a href="' . page_link_to("user_messages") . '&action=delete&id=' . $message['id'] . '">' . Get_Text("pub_messages_DelMsg") . '</a>';
|
($message['isRead'] == 'N' ? ' class="new_message"' : ''),
|
||||||
}
|
($message['isRead'] == 'N' ? '•' : ''),
|
||||||
$messages_html .= '</td></tr>';
|
date("Y-m-d H:i", $message['Datum']),
|
||||||
}
|
User_Nick_render($sender_user_source),
|
||||||
|
User_Nick_render($receiver_user_source),
|
||||||
return template_render('../templates/user_messages.html', array (
|
str_replace("\n", '<br />', $message['Text'])
|
||||||
'link' => page_link_to("user_messages"),
|
);
|
||||||
'greeting' => Get_Text("Hello") . User_Nick_render($user) . ", <br />\n" . Get_Text("pub_messages_text1") . "<br /><br />\n",
|
|
||||||
'messages' => $messages_html,
|
$messages_html .= '<td>';
|
||||||
'new_label' => Get_Text("pub_messages_Neu"),
|
if ($message['RUID'] == $user['UID']) {
|
||||||
'date_label' => Get_Text("pub_messages_Datum"),
|
if ($message['isRead'] == 'N')
|
||||||
'from_label' => Get_Text("pub_messages_Von"),
|
$messages_html .= '<a href="' . page_link_to("user_messages") . '&action=read&id=' . $message['id'] . '">' . Get_Text("pub_messages_MarkRead") . '</a>';
|
||||||
'to_label' => Get_Text("pub_messages_An"),
|
} else {
|
||||||
'text_label' => Get_Text("pub_messages_Text"),
|
$messages_html .= '<a href="' . page_link_to("user_messages") . '&action=delete&id=' . $message['id'] . '">' . Get_Text("pub_messages_DelMsg") . '</a>';
|
||||||
'date' => date("Y-m-d H:i"),
|
}
|
||||||
'from' => User_Nick_render($user),
|
$messages_html .= '</td></tr>';
|
||||||
'to_select' => $to_select,
|
}
|
||||||
'submit_label' => Get_Text("save")
|
|
||||||
));
|
return template_render('../templates/user_messages.html', array (
|
||||||
} else {
|
'link' => page_link_to("user_messages"),
|
||||||
switch ($_REQUEST['action']) {
|
'greeting' => Get_Text("Hello") . User_Nick_render($user) . ", <br />\n" . Get_Text("pub_messages_text1") . "<br /><br />\n",
|
||||||
case "read" :
|
'messages' => $messages_html,
|
||||||
if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
|
'new_label' => Get_Text("pub_messages_Neu"),
|
||||||
$id = $_REQUEST['id'];
|
'date_label' => Get_Text("pub_messages_Datum"),
|
||||||
else
|
'from_label' => Get_Text("pub_messages_Von"),
|
||||||
return error("Incomplete call, missing Message ID.", true);
|
'to_label' => Get_Text("pub_messages_An"),
|
||||||
|
'text_label' => Get_Text("pub_messages_Text"),
|
||||||
$message = sql_select("SELECT * FROM `Messages` WHERE `id`=" . sql_escape($id) . " LIMIT 1");
|
'date' => date("Y-m-d H:i"),
|
||||||
if (count($message) > 0 && $message[0]['RUID'] == $user['UID']) {
|
'from' => User_Nick_render($user),
|
||||||
sql_query("UPDATE `Messages` SET `isRead`='Y' WHERE `id`=" . sql_escape($id) . " LIMIT 1");
|
'to_select' => $to_select,
|
||||||
redirect(page_link_to("user_messages"));
|
'submit_label' => Get_Text("save")
|
||||||
} else
|
));
|
||||||
return error("No Message found.", true);
|
} else {
|
||||||
break;
|
switch ($_REQUEST['action']) {
|
||||||
|
case "read" :
|
||||||
case "delete" :
|
if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
|
||||||
if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
|
$id = $_REQUEST['id'];
|
||||||
$id = $_REQUEST['id'];
|
else
|
||||||
else
|
return error("Incomplete call, missing Message ID.", true);
|
||||||
return error("Incomplete call, missing Message ID.", true);
|
|
||||||
|
$message = sql_select("SELECT * FROM `Messages` WHERE `id`=" . sql_escape($id) . " LIMIT 1");
|
||||||
$message = sql_select("SELECT * FROM `Messages` WHERE `id`=" . sql_escape($id) . " LIMIT 1");
|
if (count($message) > 0 && $message[0]['RUID'] == $user['UID']) {
|
||||||
if (count($message) > 0 && $message[0]['SUID'] == $user['UID']) {
|
sql_query("UPDATE `Messages` SET `isRead`='Y' WHERE `id`=" . sql_escape($id) . " LIMIT 1");
|
||||||
sql_query("DELETE FROM `Messages` WHERE `id`=" . sql_escape($id) . " LIMIT 1");
|
redirect(page_link_to("user_messages"));
|
||||||
redirect(page_link_to("user_messages"));
|
} else
|
||||||
} else
|
return error("No Message found.", true);
|
||||||
return error("No Message found.", true);
|
break;
|
||||||
break;
|
|
||||||
|
case "delete" :
|
||||||
case "send" :
|
if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
|
||||||
$text = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($_REQUEST['text']));
|
$id = $_REQUEST['id'];
|
||||||
$to = preg_replace("/([^0-9]{1,})/ui", '', strip_tags($_REQUEST['to']));
|
else
|
||||||
if ($text != "" && is_numeric($to) && sql_num_query("SELECT * FROM `User` WHERE `UID`=" . sql_escape($to) . " AND NOT `UID`=" . sql_escape($user['UID']) . " LIMIT 1") > 0) {
|
return error("Incomplete call, missing Message ID.", true);
|
||||||
sql_query("INSERT INTO `Messages` SET `Datum`=" . sql_escape(time()) . ", `SUID`=" . sql_escape($user['UID']) . ", `RUID`=" . sql_escape($to) . ", `Text`='" . sql_escape($text) . "'");
|
|
||||||
redirect(page_link_to("user_messages"));
|
$message = sql_select("SELECT * FROM `Messages` WHERE `id`=" . sql_escape($id) . " LIMIT 1");
|
||||||
} else {
|
if (count($message) > 0 && $message[0]['SUID'] == $user['UID']) {
|
||||||
return error(Get_Text("pub_messages_Send_Error"), true);
|
sql_query("DELETE FROM `Messages` WHERE `id`=" . sql_escape($id) . " LIMIT 1");
|
||||||
}
|
redirect(page_link_to("user_messages"));
|
||||||
break;
|
} else
|
||||||
|
return error("No Message found.", true);
|
||||||
default :
|
break;
|
||||||
return error("Wrong action.", true);
|
|
||||||
}
|
case "send" :
|
||||||
}
|
$text = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($_REQUEST['text']));
|
||||||
|
$to = preg_replace("/([^0-9]{1,})/ui", '', strip_tags($_REQUEST['to']));
|
||||||
|
if ($text != "" && is_numeric($to) && sql_num_query("SELECT * FROM `User` WHERE `UID`=" . sql_escape($to) . " AND NOT `UID`=" . sql_escape($user['UID']) . " LIMIT 1") > 0) {
|
||||||
|
sql_query("INSERT INTO `Messages` SET `Datum`=" . sql_escape(time()) . ", `SUID`=" . sql_escape($user['UID']) . ", `RUID`=" . sql_escape($to) . ", `Text`='" . sql_escape($text) . "'");
|
||||||
|
redirect(page_link_to("user_messages"));
|
||||||
|
} else {
|
||||||
|
return error(Get_Text("pub_messages_Send_Error"), true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default :
|
||||||
|
return error("Wrong action.", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -1,86 +1,87 @@
|
|||||||
<?php
|
<?php
|
||||||
function user_wakeup() {
|
function user_wakeup() {
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$html = "";
|
$html = "";
|
||||||
|
|
||||||
if (isset ($_REQUEST['action'])) {
|
if (isset ($_REQUEST['action'])) {
|
||||||
switch ($_REQUEST['action']) {
|
switch ($_REQUEST['action']) {
|
||||||
case 'create' :
|
case 'create' :
|
||||||
$date = DateTime::createFromFormat("Y-m-d H:i", $_REQUEST['Date']);
|
$date = DateTime::createFromFormat("Y-m-d H:i", $_REQUEST['Date']);
|
||||||
if ($date != null) {
|
if ($date != null) {
|
||||||
$date = $date->getTimestamp();
|
$date = $date->getTimestamp();
|
||||||
$bemerkung = strip_request_item_nl('Bemerkung');
|
$bemerkung = strip_request_item_nl('Bemerkung');
|
||||||
$ort = strip_request_item('Ort');
|
$ort = strip_request_item('Ort');
|
||||||
$SQL = "INSERT INTO `Wecken` (`UID`, `Date`, `Ort`, `Bemerkung`) "
|
$SQL = "INSERT INTO `Wecken` (`UID`, `Date`, `Ort`, `Bemerkung`) "
|
||||||
. "VALUES ('" . sql_escape($user['UID']) . "', '"
|
. "VALUES ('" . sql_escape($user['UID']) . "', '"
|
||||||
. sql_escape($date) . "', '" . sql_escape($ort) . "', " . "'"
|
. sql_escape($date) . "', '" . sql_escape($ort) . "', " . "'"
|
||||||
. sql_escape($bemerkung) . "')";
|
. sql_escape($bemerkung) . "')";
|
||||||
sql_query($SQL);
|
sql_query($SQL);
|
||||||
$html .= success(Get_Text(4), true);
|
$html .= success(Get_Text(4), true);
|
||||||
} else
|
} else
|
||||||
$html .= error("Broken date!", true);
|
$html .= error("Broken date!", true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete' :
|
case 'delete' :
|
||||||
if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
|
if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
|
||||||
$id = $_REQUEST['id'];
|
$id = $_REQUEST['id'];
|
||||||
else
|
else
|
||||||
return error("Incomplete call, missing wake-up ID.", true);
|
return error("Incomplete call, missing wake-up ID.", true);
|
||||||
|
|
||||||
$wakeup = sql_select("SELECT * FROM `Wecken` WHERE `ID`=" . sql_escape($id) . " LIMIT 1");
|
$wakeup = sql_select("SELECT * FROM `Wecken` WHERE `ID`=" . sql_escape($id) . " LIMIT 1");
|
||||||
if (count($wakeup) > 0 && $wakeup[0]['UID'] == $user['UID']) {
|
if (count($wakeup) > 0 && $wakeup[0]['UID'] == $user['UID']) {
|
||||||
sql_query("DELETE FROM `Wecken` WHERE `ID`=" . sql_escape($id) . " LIMIT 1");
|
sql_query("DELETE FROM `Wecken` WHERE `ID`=" . sql_escape($id) . " LIMIT 1");
|
||||||
$html .= success("Wake-up call deleted.", true);
|
$html .= success("Wake-up call deleted.", true);
|
||||||
} else
|
} else
|
||||||
return error("No wake-up found.", true);
|
return error("No wake-up found.", true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= "<p>" . Get_Text("Hello") . User_Nick_render($user) . ",<br />"
|
$html .= "<p>" . Get_Text("Hello") . User_Nick_render($user) . ",<br />"
|
||||||
. Get_Text("pub_wake_beschreibung") . "</p>\n\n";
|
. Get_Text("pub_wake_beschreibung") . "</p>\n\n";
|
||||||
$html .= Get_Text("pub_wake_beschreibung2");
|
$html .= Get_Text("pub_wake_beschreibung2");
|
||||||
$html .= '
|
$html .= '
|
||||||
<table border="0" width="100%" class="border" cellpadding="2" cellspacing="1">
|
<table border="0" width="100%" class="border" cellpadding="2" cellspacing="1">
|
||||||
<tr class="contenttopic">
|
<tr class="contenttopic">
|
||||||
<th>' . Get_Text("pub_wake_Datum") . '</th>
|
<th>' . Get_Text("pub_wake_Datum") . '</th>
|
||||||
<th>' . Get_Text("pub_waeckliste_Nick") . '</th>
|
<th>' . Get_Text("pub_waeckliste_Nick") . '</th>
|
||||||
<th>' . Get_Text("pub_wake_Ort") . '</th>
|
<th>' . Get_Text("pub_wake_Ort") . '</th>
|
||||||
<th>' . Get_Text("pub_wake_Bemerkung") . '</th>
|
<th>' . Get_Text("pub_wake_Bemerkung") . '</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
';
|
';
|
||||||
|
|
||||||
$sql = "SELECT * FROM `Wecken` ORDER BY `Date` ASC";
|
$wecken_source = sql_select("SELECT * FROM `Wecken` ORDER BY `Date` ASC");
|
||||||
$Erg = sql_query($sql);
|
foreach($wecken_source as $wecken) {
|
||||||
$count = mysql_num_rows($Erg);
|
$html .= '<tr class="content">';
|
||||||
|
$html .= '<td>' . date("Y-m-d H:i", $wecken['Date']) . ' </td>';
|
||||||
|
|
||||||
for ($i = 0; $i < $count; $i++) {
|
$user_source = User($wecken['UID']);
|
||||||
$row = mysql_fetch_row($Erg);
|
if($user_source === false)
|
||||||
$html .= '<tr class="content">';
|
engelsystem_error("Unable to load user.");
|
||||||
$html .= '<td>' . date("Y-m-d H:i", mysql_result($Erg, $i, "Date")) . ' </td>';
|
|
||||||
$html .= '<td>' . UID2Nick(mysql_result($Erg, $i, "UID")) . ' </td>';
|
|
||||||
$html .= '<td>' . mysql_result($Erg, $i, "Ort") . ' </td>';
|
|
||||||
$html .= '<td>' . mysql_result($Erg, $i, "Bemerkung") . ' </td>';
|
|
||||||
if (mysql_result($Erg, $i, "UID") == $user['UID'])
|
|
||||||
$html .= '<td><a href="' . page_link_to("user_wakeup") . '&action=delete&id=' . mysql_result($Erg, $i, "ID") . "\">" . Get_Text("pub_wake_del") . '</a></td>';
|
|
||||||
else
|
|
||||||
$html .= '<td></td>';
|
|
||||||
$html .= '</tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$html .= '</table><hr />' . Get_Text("pub_wake_Text2");
|
$html .= '<td>' . User_Nick_render($user_source) . ' </td>';
|
||||||
|
$html .= '<td>' . $wecken['Ort'] . ' </td>';
|
||||||
|
$html .= '<td>' . $wecken['Bemerkung'] . ' </td>';
|
||||||
|
if ($wecken['UID'] == $user['UID'])
|
||||||
|
$html .= '<td><a href="' . page_link_to("user_wakeup") . '&action=delete&id=' . $wecken['ID'] . "\">" . Get_Text("pub_wake_del") . '</a></td>';
|
||||||
|
else
|
||||||
|
$html .= '<td></td>';
|
||||||
|
$html .= '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
$html .= template_render('../templates/user_wakeup.html', array (
|
$html .= '</table><hr />' . Get_Text("pub_wake_Text2");
|
||||||
'wakeup_link' => page_link_to("user_wakeup"),
|
|
||||||
'date_text' => Get_Text("pub_wake_Datum"),
|
$html .= template_render('../templates/user_wakeup.html', array (
|
||||||
'date_value' => date("Y-m-d H:i"),
|
'wakeup_link' => page_link_to("user_wakeup"),
|
||||||
'place_text' => Get_Text("pub_wake_Ort"),
|
'date_text' => Get_Text("pub_wake_Datum"),
|
||||||
'comment_text' => Get_Text("pub_wake_Bemerkung"),
|
'date_value' => date("Y-m-d H:i"),
|
||||||
'comment_value' => "Knock knock Leo, follow the white rabbit to the blue tent",
|
'place_text' => Get_Text("pub_wake_Ort"),
|
||||||
'submit_text' => Get_Text("pub_wake_bouton")
|
'comment_text' => Get_Text("pub_wake_Bemerkung"),
|
||||||
));
|
'comment_value' => "Knock knock Leo, follow the white rabbit to the blue tent",
|
||||||
return $html;
|
'submit_text' => Get_Text("pub_wake_bouton")
|
||||||
|
));
|
||||||
|
return $html;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Liste verfügbarer Sprachen
|
|
||||||
*/
|
|
||||||
$languages = array (
|
|
||||||
'DE' => "Deutsch",
|
|
||||||
'EN' => "English"
|
|
||||||
);
|
|
||||||
|
|
||||||
function Get_Text($TextID, $NoError = false) {
|
|
||||||
global $con, $error_messages, $debug;
|
|
||||||
|
|
||||||
if (!isset ($_SESSION['Sprache']))
|
|
||||||
$_SESSION['Sprache'] = "EN";
|
|
||||||
if ($_SESSION['Sprache'] == "")
|
|
||||||
$_SESSION['Sprache'] = "EN";
|
|
||||||
if (isset ($_GET["SetLanguage"]))
|
|
||||||
$_SESSION['Sprache'] = $_GET["SetLanguage"];
|
|
||||||
|
|
||||||
$SQL = "SELECT * FROM `Sprache` WHERE TextID=\"$TextID\" AND Sprache ='" . $_SESSION['Sprache'] . "'";
|
|
||||||
@ $Erg = mysql_query($SQL, $con);
|
|
||||||
|
|
||||||
if (mysql_num_rows($Erg) == 1)
|
|
||||||
return mysql_result($Erg, 0, "Text");
|
|
||||||
elseif ($NoError && !$debug)
|
|
||||||
return "";
|
|
||||||
elseif ($debug)
|
|
||||||
return "Error Data, '$TextID' found " . mysql_num_rows($Erg) . "x";
|
|
||||||
else
|
|
||||||
return $TextID;
|
|
||||||
}
|
|
||||||
|
|
||||||
function Print_Text($TextID, $NoError = false) {
|
|
||||||
echo Get_Text($TextID, $NoError);
|
|
||||||
}
|
|
||||||
?>
|
|
@ -1,84 +0,0 @@
|
|||||||
<?php
|
|
||||||
function sql_connect($host, $user, $pw, $db) {
|
|
||||||
global $con;
|
|
||||||
global $host;
|
|
||||||
|
|
||||||
@ $con = mysql_connect($host, $user, $pw);
|
|
||||||
|
|
||||||
if ($con == null)
|
|
||||||
die("no mysql-connection");
|
|
||||||
|
|
||||||
if (!mysql_select_db($db, $con))
|
|
||||||
die("mysql db-selection failed");
|
|
||||||
|
|
||||||
mysql_query("SET CHARACTER SET utf8;", $con);
|
|
||||||
mysql_query("SET NAMES 'utf8'", $con);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do select query
|
|
||||||
function sql_select($query) {
|
|
||||||
global $con;
|
|
||||||
$start = microtime(true);
|
|
||||||
if ($result = mysql_query($query, $con)) {
|
|
||||||
$data = array ();
|
|
||||||
while ($line = mysql_fetch_assoc($result)) {
|
|
||||||
array_push($data, $line);
|
|
||||||
}
|
|
||||||
return $data;
|
|
||||||
} else {
|
|
||||||
print_r(debug_backtrace());
|
|
||||||
die('MySQL-query error: ' . $query . ", " . mysql_error($con));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function sql_select_single_col($query) {
|
|
||||||
$result = sql_select($query);
|
|
||||||
return array_map('array_shift', $result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function sql_select_single_cell($query) {
|
|
||||||
return array_shift(array_shift(sql_select($query)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Execute a query
|
|
||||||
function sql_query($query) {
|
|
||||||
global $con;
|
|
||||||
$start = microtime(true);
|
|
||||||
if ($result = mysql_query($query, $con)) {
|
|
||||||
return $result;
|
|
||||||
} else {
|
|
||||||
die('MySQL-query error: ' . $query . ", " . mysql_error($con));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function sql_id() {
|
|
||||||
global $con;
|
|
||||||
return mysql_insert_id($con);
|
|
||||||
}
|
|
||||||
|
|
||||||
function sql_escape($query) {
|
|
||||||
return mysql_real_escape_string($query);
|
|
||||||
}
|
|
||||||
|
|
||||||
function sql_num_query($query) {
|
|
||||||
return mysql_num_rows(sql_query($query));
|
|
||||||
}
|
|
||||||
|
|
||||||
function sql_error() {
|
|
||||||
global $con;
|
|
||||||
return mysql_error($con);
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql_transaction_counter = 0;
|
|
||||||
function sql_start_transaction() {
|
|
||||||
global $sql_transaction_counter;
|
|
||||||
if ($sql_transaction_counter++ == 0)
|
|
||||||
sql_query("START TRANSACTION");
|
|
||||||
}
|
|
||||||
|
|
||||||
function sql_stop_transaction() {
|
|
||||||
global $sql_transaction_counter;
|
|
||||||
if ($sql_transaction_counter-- == 1)
|
|
||||||
sql_query("COMMIT");
|
|
||||||
}
|
|
||||||
?>
|
|
@ -1,133 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
function User_Nick_render($user_source) {
|
|
||||||
global $user, $privileges;
|
|
||||||
if($user['UID'] == $user_source['UID'] || in_array('user_shifts_admin', $privileges))
|
|
||||||
return '<a href="' . page_link_to('user_myshifts') . '&id=' . $user_source['UID'] . '">' . htmlspecialchars($user_source['Nick']) . '</a>';
|
|
||||||
else
|
|
||||||
return htmlspecialchars($user_source['Nick']);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Available T-Shirt sizes
|
|
||||||
*/
|
|
||||||
$tshirt_sizes = array (
|
|
||||||
'' => "Please select...",
|
|
||||||
'S' => "S",
|
|
||||||
'M' => "M",
|
|
||||||
'L' => "L",
|
|
||||||
'XL' => "XL",
|
|
||||||
'2XL' => "2XL",
|
|
||||||
'3XL' => "3XL",
|
|
||||||
'4XL' => "4XL",
|
|
||||||
'5XL' => "5XL",
|
|
||||||
'S-G' => "S Girl",
|
|
||||||
'M-G' => "M Girl",
|
|
||||||
'L-G' => "L Girl",
|
|
||||||
'XL-G' => "XL Girl"
|
|
||||||
);
|
|
||||||
|
|
||||||
function UID2Nick($UID) {
|
|
||||||
if ($UID > 0)
|
|
||||||
$SQL = "SELECT Nick FROM `User` WHERE UID='" . sql_escape($UID) . "'";
|
|
||||||
else
|
|
||||||
$SQL = "SELECT Name FROM `Groups` WHERE UID='" . sql_escape($UID) . "'";
|
|
||||||
|
|
||||||
$Erg = sql_select($SQL);
|
|
||||||
|
|
||||||
if (count($Erg) > 0) {
|
|
||||||
if ($UID > 0)
|
|
||||||
return $Erg[0]['Nick'];
|
|
||||||
else
|
|
||||||
return "Group-" . $Erg[0]['Name'];
|
|
||||||
} else {
|
|
||||||
if ($UID == -1)
|
|
||||||
return "Guest";
|
|
||||||
else
|
|
||||||
return "UserID $UID not found";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function TID2Type($TID) {
|
|
||||||
global $con;
|
|
||||||
|
|
||||||
$SQL = "SELECT Name FROM `EngelType` WHERE TID='" . sql_escape($TID) . "'";
|
|
||||||
$Erg = mysql_query($SQL, $con);
|
|
||||||
|
|
||||||
if (mysql_num_rows($Erg))
|
|
||||||
return mysql_result($Erg, 0);
|
|
||||||
else
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
function ReplaceSmilies($neueckig) {
|
|
||||||
$neueckig = str_replace(";o))", "<img src=\"pic/smiles/icon_redface.gif\">", $neueckig);
|
|
||||||
$neueckig = str_replace(":-))", "<img src=\"pic/smiles/icon_redface.gif\">", $neueckig);
|
|
||||||
$neueckig = str_replace(";o)", "<img src=\"pic/smiles/icon_wind.gif\">", $neueckig);
|
|
||||||
$neueckig = str_replace(":)", "<img src=\"pic/smiles/icon_smile.gif\">", $neueckig);
|
|
||||||
$neueckig = str_replace(":-)", "<img src=\"pic/smiles/icon_smile.gif\">", $neueckig);
|
|
||||||
$neueckig = str_replace(":(", "<img src=\"pic/smiles/icon_sad.gif\">", $neueckig);
|
|
||||||
$neueckig = str_replace(":-(", "<img src=\"pic/smiles/icon_sad.gif\">", $neueckig);
|
|
||||||
$neueckig = str_replace(":o(", "<img src=\"pic/smiles/icon_sad.gif\">", $neueckig);
|
|
||||||
$neueckig = str_replace(":o)", "<img src=\"pic/smiles/icon_lol.gif\">", $neueckig);
|
|
||||||
$neueckig = str_replace(";o(", "<img src=\"pic/smiles/icon_cry.gif\">", $neueckig);
|
|
||||||
$neueckig = str_replace(";(", "<img src=\"pic/smiles/icon_cry.gif\">", $neueckig);
|
|
||||||
$neueckig = str_replace(";-(", "<img src=\"pic/smiles/icon_cry.gif\">", $neueckig);
|
|
||||||
$neueckig = str_replace("8)", "<img src=\"pic/smiles/icon_rolleyes.gif\">", $neueckig);
|
|
||||||
$neueckig = str_replace("8o)", "<img src=\"pic/smiles/icon_rolleyes.gif\">", $neueckig);
|
|
||||||
$neueckig = str_replace(":P", "<img src=\"pic/smiles/icon_evil.gif\">", $neueckig);
|
|
||||||
$neueckig = str_replace(":-P", "<img src=\"pic/smiles/icon_evil.gif\">", $neueckig);
|
|
||||||
$neueckig = str_replace(":oP", "<img src=\"pic/smiles/icon_evil.gif\">", $neueckig);
|
|
||||||
$neueckig = str_replace(";P", "<img src=\"pic/smiles/icon_mad.gif\">", $neueckig);
|
|
||||||
$neueckig = str_replace(";oP", "<img src=\"pic/smiles/icon_mad.gif\">", $neueckig);
|
|
||||||
$neueckig = str_replace("?)", "<img src=\"pic/smiles/icon_question.gif\">", $neueckig);
|
|
||||||
|
|
||||||
return $neueckig;
|
|
||||||
}
|
|
||||||
|
|
||||||
function GetPictureShow($UID) {
|
|
||||||
global $con;
|
|
||||||
|
|
||||||
$SQL = "SELECT `show` FROM `UserPicture` WHERE `UID`='" . sql_escape($UID) . "'";
|
|
||||||
$res = mysql_query($SQL, $con);
|
|
||||||
|
|
||||||
if (mysql_num_rows($res) == 1)
|
|
||||||
return mysql_result($res, 0, 0);
|
|
||||||
else
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
function displayPicture($UID, $height = "30") {
|
|
||||||
global $url, $ENGEL_ROOT;
|
|
||||||
|
|
||||||
if ($height > 0)
|
|
||||||
return ("<div class=\"avatar\"><img src=\"" . $url . $ENGEL_ROOT . "ShowUserPicture.php?UID=$UID\" height=\"$height\" alt=\"picture of USER$UID\" class=\"photo\"></div>");
|
|
||||||
else
|
|
||||||
return ("<div class=\"avatar\"><img class=\"avatar\" src=\"" . $url . $ENGEL_ROOT . "ShowUserPicture.php?UID=$UID\" alt=\"picture of USER$UID\"></div>");
|
|
||||||
}
|
|
||||||
|
|
||||||
function displayavatar($UID, $height = "30") {
|
|
||||||
global $con, $url, $ENGEL_ROOT;
|
|
||||||
|
|
||||||
if (GetPictureShow($UID) == 'Y')
|
|
||||||
return " " . displayPicture($UID, $height);
|
|
||||||
|
|
||||||
$user = sql_select("SELECT * FROM `User` WHERE `UID`=" . sql_escape($UID) . " LIMIT 1");
|
|
||||||
if (count($user) > 0)
|
|
||||||
if ($user[0]['Avatar'] > 0)
|
|
||||||
return '<div class="avatar">' . (" <img src=\"pic/avatar/avatar" . $user[0]['Avatar'] . ".gif\">") . '</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
function UIDgekommen($UID) {
|
|
||||||
global $con;
|
|
||||||
|
|
||||||
$SQL = "SELECT `Gekommen` FROM `User` WHERE UID='" . sql_escape($UID) . "'";
|
|
||||||
$Erg = mysql_query($SQL, $con);
|
|
||||||
|
|
||||||
if (mysql_num_rows($Erg))
|
|
||||||
return mysql_result($Erg, 0);
|
|
||||||
else
|
|
||||||
return "0";
|
|
||||||
}
|
|
||||||
?>
|
|
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Calc shift length in format 12:23h.
|
||||||
|
* @param Shift $shift
|
||||||
|
*/
|
||||||
|
function shift_length($shift) {
|
||||||
|
$length = round(($shift['end'] - $shift['start']) / (60 * 60), 0) . ":";
|
||||||
|
$length .= str_pad((($shift['end'] - $shift['start']) % (60 * 60)) / 60, 2, "0", STR_PAD_LEFT) . "h";
|
||||||
|
return $length;
|
||||||
|
}
|
||||||
|
?>
|
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Names of available languages.
|
||||||
|
*/
|
||||||
|
$languages = array (
|
||||||
|
'DE' => "Deutsch",
|
||||||
|
'EN' => "English"
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display acutual translation of given text id.
|
||||||
|
* @param string $TextID
|
||||||
|
* @param bool $NoError
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function Get_Text($TextID, $NoError = false) {
|
||||||
|
global $debug;
|
||||||
|
|
||||||
|
if (!isset ($_SESSION['Sprache']))
|
||||||
|
$_SESSION['Sprache'] = "EN";
|
||||||
|
if ($_SESSION['Sprache'] == "")
|
||||||
|
$_SESSION['Sprache'] = "EN";
|
||||||
|
if (isset ($_GET["SetLanguage"]))
|
||||||
|
$_SESSION['Sprache'] = $_GET["SetLanguage"];
|
||||||
|
|
||||||
|
$sprache_source = Sprache($TextID, $_SESSION['Sprache']);
|
||||||
|
if($sprache_source === false)
|
||||||
|
engelsystem_error("Unable to load text key.");
|
||||||
|
if($sprache_source == null) {
|
||||||
|
if($NoError && !$debug)
|
||||||
|
return "";
|
||||||
|
return $TextID;
|
||||||
|
}
|
||||||
|
return $sprache_source['Text'];
|
||||||
|
}
|
||||||
|
?>
|
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Available T-Shirt sizes
|
||||||
|
*/
|
||||||
|
$tshirt_sizes = array (
|
||||||
|
'' => "Please select...",
|
||||||
|
'S' => "S",
|
||||||
|
'M' => "M",
|
||||||
|
'L' => "L",
|
||||||
|
'XL' => "XL",
|
||||||
|
'2XL' => "2XL",
|
||||||
|
'3XL' => "3XL",
|
||||||
|
'4XL' => "4XL",
|
||||||
|
'5XL' => "5XL",
|
||||||
|
'S-G' => "S Girl",
|
||||||
|
'M-G' => "M Girl",
|
||||||
|
'L-G' => "L Girl",
|
||||||
|
'XL-G' => "XL Girl"
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render a users avatar.
|
||||||
|
* @param User $user
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function User_Avatar_render($user) {
|
||||||
|
return '<div class="avatar"> <img src="pic/avatar/avatar' . $user['Avatar'] . '.gif"></div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render a user nickname.
|
||||||
|
* @param User $user_source
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function User_Nick_render($user_source) {
|
||||||
|
global $user, $privileges;
|
||||||
|
if($user['UID'] == $user_source['UID'] || in_array('user_shifts_admin', $privileges))
|
||||||
|
return '<a href="' . page_link_to('user_myshifts') . '&id=' . $user_source['UID'] . '">' . htmlspecialchars($user_source['Nick']) . '</a>';
|
||||||
|
else
|
||||||
|
return htmlspecialchars($user_source['Nick']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -1,51 +0,0 @@
|
|||||||
<?php
|
|
||||||
include "../includes/config.php";
|
|
||||||
include "../includes/config_IAX.php";
|
|
||||||
include "../includes/config_db.php";
|
|
||||||
include "../includes/error_handler.php";
|
|
||||||
include "../includes/funktion_modem.php";
|
|
||||||
include "../includes/funktion_cron.php";
|
|
||||||
|
|
||||||
// ausfuerungs Ruetmuss (in s)
|
|
||||||
$StartTimeBeforEvent = (60 / 4) * 60;
|
|
||||||
$AnrufDelay = -5;
|
|
||||||
$DebugDECT = false;
|
|
||||||
|
|
||||||
// Timeout erhoehen
|
|
||||||
set_time_limit(50000);
|
|
||||||
|
|
||||||
// SQL zusammensetzen
|
|
||||||
$SQL = "SELECT Shifts.DateS, Shifts.RID, ShiftEntry.UID, ShiftEntry.TID ".
|
|
||||||
"FROM `Shifts` INNER JOIN `ShiftEntry` ON `Shifts`.`SID` = `ShiftEntry`.`SID` ";
|
|
||||||
|
|
||||||
if($DebugDECT)
|
|
||||||
$SQL .= "WHERE (Shifts.DateS>'2007-07-09 09:45:00' AND ".
|
|
||||||
"Shifts.DateS<='2007-07-09 11:00:00');";
|
|
||||||
else
|
|
||||||
$SQL .= "WHERE ((`Shifts`.`DateS`>'". gmdate("Y-m-d H:i:s", time()+120+$gmdateOffset). "') AND ".
|
|
||||||
"(`Shifts`.`DateS`<='". gmdate("Y-m-d H:i:s", time()+120+$gmdateOffset+$StartTimeBeforEvent). "') );";
|
|
||||||
|
|
||||||
$Erg = mysql_query($SQL, $con);
|
|
||||||
echo mysql_error($con);
|
|
||||||
|
|
||||||
$Z = 0;
|
|
||||||
|
|
||||||
for($i = 0; $i < mysql_num_rows($Erg); $i++) {
|
|
||||||
if(mysql_result($Erg, $i, "UID") > 0) {
|
|
||||||
$DECTnumber = UID2DECT(mysql_result($Erg, $i, "UID"));
|
|
||||||
|
|
||||||
if($DECTnumber != "") {
|
|
||||||
echo "dial $DECTnumber\n";
|
|
||||||
DialNumberIAX( $DECTnumber, mysql_result($Erg, $i, "DateS"), mysql_result($Erg, $i, "RID"), mysql_result($Erg, $i, "TID"));
|
|
||||||
DialNumberModem( $DECTnumber, mysql_result($Erg, $i, "DateS"));
|
|
||||||
|
|
||||||
if($Z++ > 10) {
|
|
||||||
$Z = 0;
|
|
||||||
sleep(30);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
?>
|
|
@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
include "../includes/db.php";
|
|
||||||
include "../includes/config.php";
|
|
||||||
include "../includes/funktion_modem.php";
|
|
||||||
|
|
||||||
$SQL = "SELECT DECT FROM `User`;";
|
|
||||||
$Erg = mysql_query($SQL, $con);
|
|
||||||
|
|
||||||
echo mysql_error($con);
|
|
||||||
|
|
||||||
for($i=0; $i < mysql_num_rows($Erg); $i++) {
|
|
||||||
$Number = "#10" . mysql_result($Erg, $i, "DECT");
|
|
||||||
|
|
||||||
if(strlen($Number) == 7)
|
|
||||||
DialNumber($Number);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
?>
|
|
@ -1,75 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once "../includes/config_jabber.php";
|
|
||||||
require_once "../includes/funktion_jabber.php";
|
|
||||||
include "../includes/config_MessegeServer.php";
|
|
||||||
|
|
||||||
// Set time limit to indefinite execution
|
|
||||||
set_time_limit(0);
|
|
||||||
|
|
||||||
if(DEBUG)
|
|
||||||
echo "DEBUG mode is enable\n\tjabber is disable\n\n";
|
|
||||||
|
|
||||||
if(!DEBUG) {
|
|
||||||
echo "INIT jabber\n";
|
|
||||||
$jabber = new Jabber($server, $port, $username, $password, $resource);
|
|
||||||
|
|
||||||
if(!($jabber->Connect() && $jabber->SendAuth()))
|
|
||||||
die("Couldn't connect to Jabber Server.");
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "INIT socked\n";
|
|
||||||
|
|
||||||
// Create a UDP socket
|
|
||||||
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP) or die('Could not create socked (' . socket_strerror(socket_last_error()) . ')');
|
|
||||||
|
|
||||||
// Bind the socket to an address/port
|
|
||||||
socket_bind($sock, SERVER_ADDRESS, SERVER_PORT) or die('Could not bind to address (' . socket_strerror(socket_last_error()) . ')');
|
|
||||||
|
|
||||||
// Setzt Nonbock Mode
|
|
||||||
socket_set_nonblock($sock);
|
|
||||||
|
|
||||||
$RUNNING = true;
|
|
||||||
|
|
||||||
while($RUNNING) {
|
|
||||||
if(@socket_recvfrom($sock, $data, 65535, 0, $ip, $port)) {
|
|
||||||
// daten empfangen
|
|
||||||
$data = substr($data, 0, strlen($data)-1); //ENTER entfernen
|
|
||||||
echo "\n". gmdate("Y-m-d H:i:s", time()). "\tresive from $ip:$port ". strlen($data). " byte data ($data)\n";
|
|
||||||
PackedAnalyser( $data);
|
|
||||||
}
|
|
||||||
|
|
||||||
usleep(100000); // 100ms delay keeps the doctor away
|
|
||||||
} // end while
|
|
||||||
|
|
||||||
// disconnect jabber
|
|
||||||
if(!DEBUG)
|
|
||||||
$jabber->Disconnect();
|
|
||||||
|
|
||||||
// Close the master sockets
|
|
||||||
socket_close($sock);
|
|
||||||
|
|
||||||
function PackedAnalyser($data) {
|
|
||||||
global $jabber, $RUNNING;
|
|
||||||
// init array
|
|
||||||
$matches = array();
|
|
||||||
|
|
||||||
//#message
|
|
||||||
if(preg_match("/^#(message) ([^ ]+) (.+)/i", $data, $matches)) {
|
|
||||||
if($matches[2]=="" || $matches[3]=="")
|
|
||||||
echo "\t\t\t\t#messaage parameter fail\n";
|
|
||||||
else {
|
|
||||||
// Whisper
|
|
||||||
if(!DEBUG)
|
|
||||||
$jabber->SendMessage($value, "normal", NULL, array("body" => $message, "subject" => "Error in Pentabarf"), NULL);
|
|
||||||
else
|
|
||||||
echo "\t\t\t\tmessage to:\"". $matches[2]. "\" Text: \"". $matches[3]. "\"\n";
|
|
||||||
}
|
|
||||||
} elseif(preg_match("/^#quit/i", $data, $matches)) {
|
|
||||||
if(DEBUG) {
|
|
||||||
echo "\t\t\t\tSystem Shutdown\n\n";
|
|
||||||
$RUNNING = false;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
echo "\t\t\t\tcommand not found\n\n";
|
|
||||||
}
|
|
||||||
?>
|
|
Loading…
Reference in New Issue