public static function votedown($data) { $out = array(); if (!MyUser::isloggedin()) { throw new APIException("User ist nicht angemeldet.", 100); } if (MyUser::getKarmaPoints() < 100) { throw new APIException("Du benötigst 100 Karma-Punkte um einen negativen Vote zu geben.", 200); } if (!isset($data["question"])) { throw new APIException("Benötigter Parameter fehlt (question).", 50); } $db = new SQL(0); $row = $db->cmdrow(0, 'SELECT * FROM questions WHERE id={0}', array($data["question"] + 0)); if (!isset($row["id"])) { throw new APIException("Diese Frage existiert nicht (mehr)", 300); } if ($row["author"] == MyUser::id()) { throw new APIException("Sie dürfen nicht auf Ihre eigene Frage voten", 301); } $raw = $db->cmdrow(0, 'SELECT * FROM question_votes WHERE question={0} AND user={1} LIMIT 0,1', array($data["question"] + 0, MyUser::id())); $w = array(); $w["question"] = $data["question"] + 0; $w["user"] = MyUser::id(); $w["vote"] = -1; $db->CreateUpdate(0, "question_votes", $w); $db->cmd(0, 'UPDATE questions as T1 SET count_votes = (SELECT sum(vote) FROM question_votes WHERE question=T1.id) WHERE id={0} LIMIT 1', false, array($w["question"])); $out["sumvotes"] = self::getVotes(array("question" => $w["question"])); if (!isset($raw["id"])) { Karma::RuleAction("VOTEDOWN_QUESTION", array("user" => $row["author"], "question" => $w["question"])); } Badge::add(9, MyUser::id(), array("question" => $w["question"])); //Kritiker: für downvote return $out; }
private static function _load($id) { if (isset(self::$_cache[$id])) { return; } $db = new SQL(0); self::$_cache[$id + 0] = $db->cmdrow(0, 'SELECT * FROM user_list WHERE id={0} LIMIT 0,1', array($id + 0)); }
protected static function _load($id) { if (isset(self::$_cache[$id])) { return self::$_cache[$id]; } $db = new SQL(0); $row = $db->cmdrow(0, 'SELECT * FROM questions WHERE id={0} LIMIT 0,1', array($id)); if (!isset($row["id"])) { return null; } self::$_cache[$row["id"]] = $row; return $row; }
} } //print_r($_GET); } function OpenIDAddLogin($openIdentifier, $data) { $userlist = $openIdentifier; $db = new SQL(0); $w = array(); $w["username"] = $userlist; $w["provider"] = "openid"; $w["user"] = MyUser::id(); $db->CreateUpdate(0, 'user_login', $w); PageEngine::AddSuccessMessage("openid", "Zugriffsart hinzugefügt"); } function OpenIDRegisterLogin($openIdentifier, $data) { $userlist = $openIdentifier; $db = new SQL(0); $row = $db->cmdrow(0, 'SELECT * FROM user_login WHERE username="******" AND provider="openid" LIMIT 0,1', array($userlist)); if (!isset($row["username"])) { $db->cmd(0, 'INSERT IGNORE INTO user_list '); $w = array(); if (isset($data["nickname"])) { $w["username"] = $data["nickname"] . "#" . rand(0, 99999); } else { $w["username"] = "******" . rand(0, 99999); } $w["email_standard"] = $data["email"]; if (isset($data["language"])) {
private static function _load() { if (!self::isloggedin()) { return false; } $db = new SQL(0); self::$_usercache = $db->cmdrow(0, 'SELECT * FROM user_list WHERE id={0} LIMIT 0,1', array(self::id())); }
<?php $db = new SQL(0); $info = $db->cmdrow(0, 'SELECT * FROM questions WHERE id={0} LIMIT 0,1', array($params["id"])); $versions = $db->cmdrows(0, 'SELECT * FROM qatext_versions WHERE type="q" AND keyid="{0}" ORDER BY dt_created ASC', array($info["id"] + 0)); PageEngine::html("html_head"); PageEngine::html("header"); ?> <div id="Content" class="content-wrapper PageQuestionEdit"> <article class="ContentLeft"> <h1>Frage bearbeiten [<a href="<?php echo Question::PermalinkByData($info["id"], $info["title"]); ?> ">zurück</a>]</h1> <SELECT name="revision"> <?php foreach ($versions as $row) { echo '<OPTION value="V' . $row["id"] . '">Sicherung vom ' . date("d.m.Y H:i:s", $row["dt_created"]) . ' Uhr</OPTION>'; } ?> <OPTION value="current">Aktuelle Version</OPTION> </SELECT><button id="BtnLoadRevision" type="button" DISABLED="DISABLED">laden</button> <form method="POST"><INPUT type="hidden" name="action" value="save"/> <b>Titel:</b> <INPUT class="gblue" type="text" name="title" value="<?php echo html($info["title"]); ?> "/> <p><?php
<?php PageEngine::html("html_head"); PageEngine::html("header", array("searchquery" => isset($_GET["query"]) ? $_GET["query"] : "")); $db = new SQL(0); $userinfo = $db->cmdrow(0, 'SELECT * FROM user_list WHERE id={0} LIMIT 0,1', array($params["user_id"])); $infos = $db->cmdrows(0, 'SELECT T1.*, T2.title FROM karma_log as T1 LEFT JOIN questions as T2 ON T1.question=T2.id WHERE user={0} ORDER BY created DESC', array($userinfo["id"])); ?> <div id="Content" class="content-wrapper PageUserKarma"> <article> <h1 class="search-result-summary"><?php echo _e("{0}'s Karma Übersicht", array(0 => html($userinfo["username"]))); ?> </h1> <?php PageEngine::html("box_userprofile_navi", array("id" => $userinfo["id"], "name" => $userinfo["username"])); ?> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1", {packages:["corechart"]}); google.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable(<?php $out = array(array("Datum", "Karma")); $rows = $db->cmdrows(0, 'SELECT sum(points) as Karma, substr(stamp,1,10) as Datum FROM karma_log WHERE user={0} GROUP BY Datum ORDER BY Datum ASC', array($userinfo["id"])); $raws = array(); $sum = 0; $time = $userinfo["dt_registered"] - 86400; foreach ($rows as $row) {
public static function accept($data) { $out = array(); if (!MyUser::isloggedin()) { throw new APIException("User ist nicht angemeldet.", 100); } if (!isset($data["answer"])) { throw new APIException("Benötigter Parameter fehlt (answer).", 50); } $db = new SQL(0); $info = $db->cmdrow(0, 'SELECT * FROM answers WHERE id={0} LIMIT 0,1', array($data["answer"] + 0)); if (!isset($info["id"])) { throw new APIException("Diese Antwort existiert nicht (mehr)", 300); } if ($info["right_answer"] == "1") { throw new APIException("Dies ist bereits die beste Antwort", 330); } $qinfo = $db->cmdrow(0, 'SELECT * FROM questions WHERE id={0} LIMIT 0,1', array($info["question"] + 0)); if (!isset($qinfo["id"])) { throw new APIException("Diese Frage existiert nicht (mehr)", 300); } if ($qinfo["is_closed"] == "1") { throw new APIException("Diese Frage ist bereits geschlossen", 310); } if ($qinfo["author"] != MyUser::id()) { throw new APIException("Dies ist nicht ihre Frage", 320); } if ($info["author"] == MyUser::id() and MyUser::getKarmaPoints() < 50) { throw new APIException("Deine eigene Antwort darf erst ab 50 Karma Punkten die beste Antwort sein", 210); } $db->cmd(0, 'UPDATE answers SET right_answer = "1" WHERE id={0} LIMIT 1', true, array($info["id"])); $db->cmd(0, 'UPDATE questions SET is_answered = "1" WHERE id={0} LIMIT 1', true, array($info["question"])); if (MyUser::id() != $info["author"]) { Karma::RuleAction("ACCEPT_ANSWER", array("user" => $info["author"], "question" => $info["question"], "answer" => $info["id"])); } if (MyUser::id() != $info["author"] && $info["is_bounty"] == "1") { Bounty::Release($info["question"], $info["author"]); } //Gib dem Autor die Bounty return true; }
break; } return true; } public static function hasBadge($badge, $user) {
<?php if (isset($_POST["action"]) and $_POST["action"] == "save") { $db = new SQL(0); $info = $db->cmdrow(0, 'SELECT T1.*, T2.title FROM answers as T1 LEFT JOIN questions as T2 ON T1.question=T2.id WHERE T1.id={0} LIMIT 0,1', array($params["id"] + 0)); if ($info["author"] != MyUser::id() && !isset($_SESSION["myuser"]["lastwritten"]["answers"][$info["id"]])) { die("Dies ist nicht Ihre Frage."); } $w = array(); $w["keyid"] = $info["id"]; $w["type"] = "a"; $w["title"] = ""; $w["text"] = $info["txt"]; $w["user"] = MyUser::id(); $w["dt_created"] = time(); $db->CreateUpdate(0, 'qatext_versions', $w); $w2 = array(); $w2["id"] = $info["id"]; $w2["txt"] = $_POST["text"]; $w2["author"] = MyUser::id(); $w2["date_edited"] = time(); $db->CreateUpdate(0, 'answers', $w2); $w3 = array(); $w3["id"] = $info["question"] + 0; $w3["date_action"] = time(); $w3["user_action"] = MyUser::id(); $db->CreateUpdate(0, 'questions', $w3); Badges::add(10, MyUser::id()); //Erfolg Redakteur: Editiere einen Beitrag header("Location: " . Question::PermalinkByData($info["question"], $info["title"]) . "#answer-" . $w2["id"]); exit(1);
<?php PageEngine::html("html_head"); PageEngine::html("header", array("searchquery" => isset($_GET["query"]) ? $_GET["query"] : "")); $db = new SQL(0); $info = $db->cmdrow(0, 'SELECT * FROM user_list as T1 LEFT JOIN user_action as T2 ON T1.id=T2.user WHERE T1.id={0} LIMIT 0,1', array($params["user_id"])); $rows = $db->cmdrows(0, 'SELECT * FROM user_rights WHERE user={0}', array($info["id"])); foreach ($rows as $row) { $rinfo[$row["right"]] = $row; } ?> <div id="Content" class="content-wrapper PageUserprofile"> <article> <h1 class="search-result-summary"><?php echo _e("{0}'s Profil-Übersicht", array(0 => html($info["username"]))); ?> </h1> <?php PageEngine::html("box_userprofile_navi", array("id" => $info["id"], "name" => $info["username"])); ?> <table class="wrapper"><tr style="vertical-align: top;"> <td style="text-align: center;"> <div class="box_gravatar" style="width:140px; height:140px margin-bottom: 10px; position: relative;"> <img class="profile photo" src="http://www.gravatar.com/avatar/<?php echo md5($info["email_standard"]); ?> ?s=140&d=identicon" style="border: #EEE 1px solid; padding: 5px; border-radius: 3px; "> <?php if (isset($rinfo["expert"])) {
public static function userexists($name) { $db = new SQL(0); $row = $db->cmdrow(0, 'SELECT id FROM user_list WHERE username LIKE "{0}" LIMIT 0,1', array($name)); return isset($row["id"]); }
?> </ul> <h1 class="search-result-summary"><?php echo _e("Datenbankprüfung"); ?> </h1> <?php $doc = new DOMDocument(); $doc->load($_ENV["basepath"] . "/app/code/install.mysql.xml"); foreach ($doc->getElementsByTagName("table") as $child) { $CreateSQL1 = trim($child->textContent); $TableName = $child->attributes->item(0)->value; try { $row = $db->cmdrow(0, 'SHOW CREATE TABLE `' . $TableName . '`'); } catch (Exception $ex) { $row[1] = ""; } $CreateSQL2 = trim($row[1] . ";"); $CreateSQL1b = preg_replace("`AUTO_INCREMENT=([0-9]+)`", "AUTO_INCREMENT=???", $CreateSQL1); $CreateSQL2b = preg_replace("`AUTO_INCREMENT=([0-9]+)`", "AUTO_INCREMENT=???", $CreateSQL2); $CreateSQL1c = str_replace(array(chr(10), chr(32), chr(13)), "", $CreateSQL1b); $CreateSQL2c = str_replace(array(chr(10), chr(32), chr(13)), "", $CreateSQL2b); echo '<h4 style="margin-bottom:0px; padding-bottom:0px;">' . html($TableName) . '</h4>'; if ($CreateSQL1c == $CreateSQL2c) { echo '<p style="color: green; margin-top: 0px;">korrekt</p>'; } else { $CreateSQL1 = preg_replace("@ AUTO\\_INCREMENT\\=[0-9]+@", "", $CreateSQL1); $CreateSQL2 = preg_replace("@ AUTO\\_INCREMENT\\=[0-9]+@", "", $CreateSQL2); $out = diff_line_text($CreateSQL2, $CreateSQL1);
<?php $db = new SQL(0); $info = $db->cmdrow(0, 'SELECT T1.*,T2.*,T3.right FROM user_list as T1 LEFT JOIN user_action as T2 ON T1.id=T2.user LEFT JOIN user_rights as T3 ON T1.id=T3.user AND T3.right="expert" WHERE T1.id={0} LIMIT 0,1', array($params["user_id"])); $str = WebCache::get("http://www.gravatar.com/" . md5(strtolower(trim($info["email_standard"]))) . ".json", 10000, array("entry", "}")); $gdata = json_decode($str, true); PageEngine::html("html_head", array("title" => _h("{0}'s Karmaprofil", array($info["username"])))); PageEngine::html("header", array("searchquery" => isset($_GET["query"]) ? $_GET["query"] : "")); ?> <div id="Content" class="content-wrapper PageUserprofile"> <article> <h1 class="search-result-summary"><?php echo _e("{0}'s Profil bearbeiten", array(0 => html($info["username"]))); ?> </h1> <?php PageEngine::html("box_userprofile_navi", array("id" => $info["id"], "name" => $info["username"])); ?> <table class="wrapper"><tr style="vertical-align: top;"> <td style="text-align: center;"> <div class="box_gravatar" style="width:140px; height:140px margin-bottom: 10px; position: relative;"> <img class="profile photo" src="http://www.gravatar.com/avatar/<?php echo md5($info["email_standard"]); ?> ?s=140&d=identicon" style="border: #EEE 1px solid; padding: 5px; border-radius: 3px; "> <?php if (isset($info["right"]) and $info["right"] == "expert") { echo '<img src="' . get_path("/skins/default/images/icons/expert.png") . '" TITLE="Experte für dieses Thema" style="position: absolute; width: 70px; height: 70px; bottom: -35px; right: -35px;"/>'; }
<?php $db = new SQL(0); $info = $db->cmdrow(0, 'SELECT * FROM tag_details WHERE tag = "{0}" LIMIT 0,1', array($params["id"])); PageEngine::html("html_head", array("title" => $params["id"], "index" => isset($info["long_desc"]))); PageEngine::html("header"); ?> <div id="Content" class="content-wrapper PageUserprofile"> <article class="ContentLeft"> <?php PageEngine::html("box_tags_navi", array("tag" => $params["id"])); ?> <h1 class="search-result-summary"><?php echo _e("Infos for Tag '{0}'", array(0 => $params["id"])); ?> </h1> <?php BBCode::render(isset($info["long_desc"]) ? $info["long_desc"] : "", true); if (!isset($info["long_desc"]) or trim($info["long_desc"]) == "") { echo '<p class="noTagDescription">' . _e("Dieser Tag hat aktuell noch keine Erklärung. Ab 2500 Karma Punkten kannst Du diesen Artikel erstellen und so anderen Usern helfen oder einen kurzen Einblick in das Thema bieten.") . '</p>'; } if (MyUser::isloggedin() and MyUser::getKarmaPoints() >= 2500 or MyUser::hasAdminRight()) { echo '<a href="' . get_path("/tags/" . urlencode($params["id"]) . "/info/edit") . '"><button class="blue" type="button">' . _e("edit") . '</button></a>'; } ?> </article> <aside class="ContentRight"> <div style="text-align: center;">
function UsernameAlreadyInUse($name, $myuserid = 0) { $db = new SQL(0); $row = $db->cmdrow(0, 'SELECT id FROM user_list WHERE username = "******" AND id != {1} LIMIT 0,1', array($name, $myuserid + 0)); return isset($row["id"]); }
<?php $db = new SQL(0); $info = $db->cmdrow(0, "SELECT T1.*,T2.username as authorname, T2.country, T2.show_country, T2.email_standard as authoremail, T2.karma as authorkarma, T2.award_gold, T2.award_silver, T2.award_bronce, T2.website as authorwebsite, T3.vote as MyVote, T4.right as authorexpert, T5.username as user_actionname\r\tFROM questions as T1 \r\tLEFT JOIN user_list as T2 ON T1.author=T2.id \r\tLEFT JOIN user_list as T5 ON T1.user_action=T5.id \r\tLEFT JOIN question_votes as T3 ON T1.id=T3.question AND T3.user={1}\r\tLEFT JOIN user_rights as T4 ON T1.author=T4.user AND T4.right = 'expert'\r\tWHERE T1.id={0} GROUP BY T1.id LIMIT 0,1", array($params["id"], MyUser::id() + 0)); if (!isset($info["id"])) { PageEngine::html("page_404"); } $tags = $db->cmdrows(0, "SELECT * FROM question_tags WHERE question={0} ORDER BY tag ASC", array($info["id"])); switch (isset($_GET["sort"]) ? $_GET["sort"] : "") { case "oldest": $ansorder = "date_created ASC"; break; case "latest": $ansorder = "date_created DESC"; break; default: $ansorder = "count_votes DESC"; } $answers = $db->cmdrows(0, "SELECT T1.*,T2.username as authorname,T2.email_standard as authoremail, T2.GooglePlus, T2.country, T2.show_country, T2.karma as authorkarma, T2.award_gold, T2.award_silver, T2.award_bronce, T2.website as authorwebsite, T2.FlattrUID, T3.vote as MyVote, T4.right as authorexpert\r\tFROM answers as T1\r\tLEFT JOIN user_list as T2 ON T1.author=T2.id \r\tLEFT JOIN answer_votes as T3 ON T1.id=T3.answer AND T3.user={1}\r\tLEFT JOIN user_rights as T4 ON T1.author=T4.user AND T4.right = 'expert'\r\tWHERE T1.question={0} \r\tORDER BY " . $ansorder . ", right_answer DESC", array($info["id"], MyUser::id() + 0)); $bounties = $db->cmdrows(0, 'SELECT sum(amount) as amount, currency FROM question_bounty WHERE question={0} GROUP BY currency', array($info["id"] + 0), "currency"); if ($info["author"] != MyUser::id()) { $db->cmd(0, 'INSERT LOW_PRIORITY IGNORE INTO `question_views` (`question`, `IP`, `day`) VALUES (' . $info["id"] . ', "' . $_SERVER["REMOTE_ADDR"] . '", ' . date("Ymd") . ');', true); $db->cmd(0, 'UPDATE LOW_PRIORITY `questions` SET count_views=(SELECT count(*) FROM `question_views` WHERE question=questions.id) WHERE id={0} LIMIT 1', true, array($info["id"])); if ($info["count_views"] == 500) { Badges::add(21, $info["author"], array("question" => $info["id"])); } elseif ($info["count_views"] == 250) { Badges::add(31, $info["author"], array("question" => $info["id"])); } elseif ($info["count_views"] == 150) { Badges::add(41, $info["author"], array("question" => $info["id"])); } }