Skip to content

Commit

Permalink
New global Strings-solution: various text snippets are now accessed f…
Browse files Browse the repository at this point in the history
…rom a dedicated list - not inline with code. Plus further minor code improvements.
  • Loading branch information
oliveratgithub committed Feb 4, 2018
1 parent 8150a6f commit 6dce9b0
Show file tree
Hide file tree
Showing 20 changed files with 2,631 additions and 2,417 deletions.
220 changes: 99 additions & 121 deletions www/addle.php

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions www/bugtracker.php
@@ -1,4 +1,4 @@
<?PHP
<?php

// Libraries
require_once( __DIR__ .'/includes/main.inc.php');
Expand Down Expand Up @@ -140,4 +140,3 @@

//echo foot();
$smarty->display('file:layout/footer.tpl');
?>
16 changes: 5 additions & 11 deletions www/gallery.php
Expand Up @@ -13,16 +13,12 @@
* @subpackage Gallery
*/

//=============================================================================
// Includes
//=============================================================================
/**
* File Includes
* File includes
* @include main.inc.php
*/
require_once( __DIR__ .'/includes/main.inc.php');



// fuer mod_rewrite solltes
//header("Cache-Control: no-store, no-cache, must-revalidate");
//echo head(29, 'gallery');
Expand All @@ -35,13 +31,12 @@
// Gallery nur für eingeloggte User anzeigen, siehe Bugtracker: http://www.zorg.ch/bugtracker.php?bug_id=708
if ($user->typ == USER_NICHTEINGELOGGT)
{
user_error("<h3>Gallery ist nur f&uuml;r eingeloggte User sichtbar!</h3>
<p>Bitte logge Dich ein oder <a href=\"profil.php?do=anmeldung&menu_id=13\">erstelle einen neuen Benutzer</a></p>", E_USER_NOTICE);
user_error( t('error-not-logged-in', 'gallery', SITE_URL), E_USER_NOTICE);

} else {

// Das Benoten (und mypic markieren) können nebst Schönen auch die registrierten User, deshalb müssen wirs vorziehen...
if ($_GET['do'] && $user->typ == USER_NICHTEINGELOGGT) user_error("Permission denied for <i>".$_GET['do']."</i>", E_USER_ERROR);
if ($_GET['do'] && $user->typ == USER_NICHTEINGELOGGT) user_error( t('permissions-insufficient', 'gallery', $_GET['do']), E_USER_ERROR);
switch ($_GET['do']) {
case "benoten":
doBenoten($_POST['picID'], $_POST['score']);
Expand All @@ -58,7 +53,7 @@


// Ab hier kommt nur noch Zeugs dass Member & Schöne machen dürfen
if ($_GET['do'] && $user->typ != USER_MEMBER) user_error("Permission denied for <i>".$_GET['do']."</i>", E_USER_ERROR);
if ($_GET['do'] && $user->typ != USER_MEMBER) user_error( t('permissions-insufficient', 'gallery', $_GET['do']), E_USER_ERROR);

switch ($_GET['do']) {
case "editAlbum":
Expand Down Expand Up @@ -112,4 +107,3 @@

//echo foot(7);
$smarty->display('file:layout/footer.tpl');
?>
2 changes: 1 addition & 1 deletion www/getfile.php
Expand Up @@ -52,6 +52,6 @@
readfile( FILES_DIR . $d['user'] . DIRECTORY_SEPARATOR . $d['name']);
}else{ // Else return a 404-not found error
header('HTTP/1.0 404 Not Found'); // set HTTP response header
echo "File not found or not linked in database.";
echo t('error-file-notfound');
die; // Make sure to quit, due to error
}
3 changes: 3 additions & 0 deletions www/go.php
Expand Up @@ -11,6 +11,9 @@
* @package Zorg
* @subpackage GO
*/
/**
* @include main.inc.php
*/
include_once( __DIR__ .'/includes/main.inc.php');

/**
Expand Down
27 changes: 13 additions & 14 deletions www/includes/addle.inc.php
Expand Up @@ -2,7 +2,7 @@
/**
* Addle Zusatzfunktionen
*
* Beinhaltet diverse Zusatzfunktionen für Addle
* Beinhaltet diverse Zusatzfunktionen für Addle
*
* @author [z]biko
* @version 1.0
Expand All @@ -14,6 +14,7 @@
*/
include_once( __DIR__ .'/messagesystem.inc.php');
include_once( __DIR__ .'/mysql.inc.php');
include_once( __DIR__ .'/strings.inc.php');

/**
* Konstante MAX_ADDLE_GAMES
Expand All @@ -24,7 +25,7 @@
/**
* Anzahl offene Addle Spiele
*
* Liefert den Text für die Startseite, wieviele Addle Games eines Benutzers noch offen sind.
* Liefert den Text für die Startseite, wieviele Addle Games eines Benutzers noch offen sind.
*
* @author [z]biko
* @version 1.0
Expand Down Expand Up @@ -77,14 +78,14 @@ function addle_remove_old_games () {
Messagesystem::sendMessage(
$winner,
$looser,
'-- Addle -- (autom. Nachricht)',
sprintf('<a href="%s/addle.php?show=play&id=%d">Du hast unser Addle-Game verloren, weil du nicht mehr weiter gespielt hast.</a>', SITE_URL, $d['id'])
t('message-subject', 'addle'),
t('message-game-forceclosed', 'addle', [ SITE_URL, $d['id'], 'verloren', 'du', 'hast' ])
);
Messagesystem::sendMessage(
$looser,
$winner,
'-- Addle -- (autom. Nachricht)',
sprintf('<a href="%s/addle.php?show=play&id=%d">Du hast unser Addle-Game gewonnen, weil ich nicht mehr weiter gespielt habe.</a>', SITE_URL, $d['id'])
t('message-subject', 'addle'),
t('message-game-forceclosed', 'addle', [ SITE_URL, $d['id'], 'gewonnen', 'ich', 'habe' ])
);
$db->query("UPDATE addle SET finish='1', $winner_score=1, $looser_score=0 WHERE id=$d[id]", __FILE__, __LINE__);
_update_dwz($d['id']);
Expand Down Expand Up @@ -234,7 +235,7 @@ function _update_dwz ($id) {
if ($d2) $db->query("UPDATE addle_dwz SET score=$dwz2, prev_score=$prev_score_2 WHERE user=$d[player2]", __FILE__, __LINE__);
else $db->query("INSERT INTO addle_dwz (user, score, prev_score) VALUES ($d[player2], $dwz2, $prev_score_2)", __FILE__, __LINE__);

// dwz_dif für game
// dwz_dif für game
$db->query("UPDATE addle SET dwz_dif=".abs($dif1)." WHERE id=$id AND finish=1", __FILE__, __LINE__);

// rank update
Expand Down Expand Up @@ -268,10 +269,10 @@ function _update_dwz ($id) {
$max_depth = 5;

/**
* KI - höchste Punktzahl wählen
* KI - höchste Punktzahl wählen
*
* Ermittelt, welches Feld die KI nehmen soll,
* um möglichst viele Punkte zu machen aber dem
* um möglichst viele Punkte zu machen aber dem
* Gegner nur kleine Punkte zur Wahl zu lassen
*
* @author [z]stamp & [z]cylander
Expand Down Expand Up @@ -361,10 +362,10 @@ function evil_max($game_data_array, $row, $score_self, $score_chind, $depth, $mo


/**
* KI - möglichst kleine Punktzahl
* KI - möglichst kleine Punktzahl
*
* Ermittelt, welches das kleinste Feld für die KI ist,
* um dem Gegner möglichst wenig Punkte zur Wahl zu lassen
* Ermittelt, welches das kleinste Feld für die KI ist,
* um dem Gegner möglichst wenig Punkte zur Wahl zu lassen
*
* @author [z]stamp & [z]cylander
* @version 1.0
Expand Down Expand Up @@ -466,5 +467,3 @@ function evil_min($game_data_array, $row, $score_self, $score_chind, $depth, $mo
}
}


?>
103 changes: 20 additions & 83 deletions www/includes/forum.inc.php
Expand Up @@ -33,12 +33,14 @@
* @include Utilities
* @include Sunrise
* @include Messagesystem
* @include strings.inc.php Strings die im Zorg Code benutzt werden
*/
require_once( __DIR__ .'/smarty.inc.php');
require_once( __DIR__ .'/usersystem.inc.php');
require_once( __DIR__ .'/util.inc.php');
require_once( __DIR__ .'/sunrise.inc.php');
require_once( __DIR__ .'/messagesystem.inc.php');
require_once( __DIR__ .'/strings.inc.php');

/**
* GLOBALS
Expand Down Expand Up @@ -496,7 +498,7 @@ static function post($parent_id, $board, $user_id, $text, $msg_users="") {
$parent_id = ($parent_id <= 0 ? 1 : $parent_id);

if($parent_id <= 0) {
echo 'Parent id ist kleiner gleich 0.';
echo t('invalid-parent_id', 'commenting');
exit;
}

Expand All @@ -508,7 +510,7 @@ static function post($parent_id, $board, $user_id, $text, $msg_users="") {


if($thread_id <= 0) {
echo 'Thread_id ist kleiner gleich 0.';
echo t('invalid-thread_id', 'commenting');
exit;
}

Expand Down Expand Up @@ -582,31 +584,21 @@ static function post($parent_id, $board, $user_id, $text, $msg_users="") {


// Activity Eintrag auslösen (ausser bei der Bärbel, die trollt zuviel)
// if ($user_id != 59) { Activities::addActivity($user_id, 0, $activities_f[1]); }
if ($user_id != 59) { Activities::addActivity($user_id, 0, 'hat <a href="'.Comment::getLink($board, $rs['parent_id'], $rs['id'], $rs['thread_id']).'">einen Comment</a> '.Forum::getBoardTitlePrefix($rs['board']).' '.Forum::getBoardTitle($rs['board']).' geschrieben.<br/><p><small>
&nbsp;&nbsp;<a href="'.Comment::getLink($board, $$rs['parent_id'], $rs['id'], $rs['thread_id']).'">"'.Comment::getTitle($text, 100).'..."</a></small></p>', 'c'); }
if ($user_id != 59)
{
Activities::addActivity($user_id, 0, t('activity-newcomment', 'commenting', [ Comment::getLink($board, $rs['parent_id'], $rs['id'], $rs['thread_id']), Forum::getBoardTitle($rs['board']), Comment::getTitle($text, 100) ]), 'c');
}


// Message an alle gewünschten senden
if(count($msg_users) > 0) {
for ($i=0; $i < count($msg_users); $i++) {
Messagesystem::sendMessage(
$user_id
, $msg_users[$i]
, addslashes(
stripslashes(
'[Forumpost] von '.usersystem::id2user($user_id)
)
)
, addslashes(
stripslashes(
usersystem::id2user($user_id).' hat geschrieben: <br /><i>'
.$text
.'</i><br /><br /><a href="'.Comment::getLink($board, $parent_id, $rs['id'], $thread_id)
.'">--> zum Post</a>'
)
)
, (is_array($msg_users) ? implode(',', $msg_users) : $msg_users)
$user_id
,$msg_users[$i]
,t('message-newcomment-subject', 'commenting', usersystem::id2user($user_id))
,t('message-newcomment', 'commenting', [ usersystem::id2user($user_id), addslashes(stripslashes($text)), Comment::getLink($board, $parent_id, $rs['id'], $thread_id) ])
,(is_array($msg_users) ? implode(',', $msg_users) : $msg_users)
);
}
}
Expand All @@ -621,29 +613,18 @@ static function post($parent_id, $board, $user_id, $text, $msg_users="") {
if($db->num($result) > 0) {
while($rs2 = $db->fetch($result)) {
Messagesystem::sendMessage(
59,
$rs2['user_id'],
addslashes(stripslashes('[Forum] Reply to post #'.$parent_id)),
addslashes(
stripslashes(
'<a href="'.Comment::getLink($rs['board'], $rs['parent_id'], $rs['id'], $rs['thread_id']).'">'
.Comment::getTitle($rs['text'])
.'</a>'
.' &raquo;</a>'
.' by '
.usersystem::userpagelink($rs['user_id'], $rs['clan_tag'], $rs['username'])
.' @ '
.datename($rs['date'])
)
)
59
,$rs2['user_id']
,t('message-newcomment-subscribed-subject', 'commenting', [ usersystem::id2user($user_id), $parent_id ])
,t('message-newcomment-subscribed', 'commenting', [ usersystem::id2user($user_id), Comment::getLink($rs['board'], $rs['parent_id'], $rs['id'], $rs['thread_id']), addslashes(stripslashes(Comment::getTitle($rs['text']))) ])
);
}
}

return $commentlink;

} else {
echo "Permission denied for posting on thread '$board / $thread_id'";
user_error( t('invalid-permissions', 'commenting', [ $board, $thread_id ]), E_USER_WARNING);
exit;
}
}
Expand Down Expand Up @@ -811,50 +792,6 @@ static function getBoardTitle($board) {
}


/**
* Board Prefix für Activities Text ausgeben
* @author IneX
* @date 18.08.2012
* @desc Ermittelt den korrekten, deutschen Prefix zur erwähnung des Board Titels in einem Text (z.B. Acitivities ;))
* @param $board
* @return string
*/
static function getBoardTitlePrefix($board){
switch ($board) {
case 'f':
return('im');
break;
case 't':
return('im');
break;
case 'b':
return('im');
break;
case 'h':
return('im');
break;
case 'p':
return('im');
break;
case 'g':
return('im');
break;
case 'i':
return('in der');
break;
case 'o':
return('in der');
break;
case 'e':
return('in den');
break;
case 'r':
return('in den');
break;
}
}


/**
* @return String
* @param $comment_id
Expand Down Expand Up @@ -1155,7 +1092,7 @@ static function getLatestComments($num=10, $title = '', $board = '') {

$wboard = $board ? "comments.board='".$board."'" : "1";

//beschr‰nkt auf 365 tage, da sonst unglaublich lahm
//beschränkt auf 365 tage, da sonst unglaublich lahm
$sql ="SELECT
comments.*,
IF(ISNULL(comments_unread.comment_id), 0, 1) AS isunread,
Expand Down Expand Up @@ -2261,7 +2198,7 @@ static function printChildPosts($board, $parent_id, $depth=array("space")) {
global $db, $user;

if(!is_numeric($parent_id)) {
echo '$parent_id is not numeric';
echo t('invalid-parent_id', 'commenting');
exit;
}

Expand Down

0 comments on commit 6dce9b0

Please sign in to comment.