| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | // Der Zugriff auf die Daten des Klassenbuch erfolgt über diese Datei
|
|---|
| 4 | define("_KBSECURE", true);
|
|---|
| 5 |
|
|---|
| 6 | require_once("core.php");
|
|---|
| 7 |
|
|---|
| 8 | Core::import("includes.jsonrpc.service");
|
|---|
| 9 |
|
|---|
| 10 | // Selbst definierte Fehlermeldungen
|
|---|
| 11 | JSONRPCErrorCodes::add("AUTHENTICATION_FAILED", 800, "Authentifizierung fehlgeschlagen");
|
|---|
| 12 | JSONRPCErrorCodes::add("INVALID_DATABASE_QUERY", 801, "Ungültige Datenbankabfrage");
|
|---|
| 13 |
|
|---|
| 14 | function gettasks($start = null, $end = null) {
|
|---|
| 15 | $database = Core::getDatabase();
|
|---|
| 16 | $user = Core::getUser();
|
|---|
| 17 |
|
|---|
| 18 | if ($start == null) {
|
|---|
| 19 | $start = mktime(0, 0, 0);
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | if ($end) {
|
|---|
| 23 | $cond = " AND t.date < " . $database->quote($end);
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | $database->setQuery("SELECT t.*, COUNT(c.userid) AS comments" .
|
|---|
| 27 | ($user->authenticated() ? ", FIND_IN_SET(" . $database->quote($user->id) . ", t.commentsreadby) AS commentsread " : " ") .
|
|---|
| 28 | "FROM #__tasks AS t LEFT JOIN #__comments AS c ON t.id = c.taskid " .
|
|---|
| 29 | "WHERE t.date >= " . $database->quote($start) . $cond . " GROUP BY t.id ORDER BY t.date");
|
|---|
| 30 |
|
|---|
| 31 | $taskResponse = $database->loadAssocList();
|
|---|
| 32 |
|
|---|
| 33 | if (!$database->success()) {
|
|---|
| 34 | return new JSONRPCErrorResponse("INVALID_DATABASE_QUERY", "MySQL-Fehlermeldung: " . $database->getErrorMsg());
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | $tasks = Array();
|
|---|
| 38 |
|
|---|
| 39 | foreach ($taskResponse as $task) {
|
|---|
| 40 | $tasks[] = Array(
|
|---|
| 41 | "id" => (int) $task["id"],
|
|---|
| 42 | "date" => (int) $task["date"],
|
|---|
| 43 | "subject" => (int) $task["subject"],
|
|---|
| 44 | "important" => (bool) $task["important"],
|
|---|
| 45 | "text" => (string) $task["text"],
|
|---|
| 46 | "userid" => (int) $task["userid"],
|
|---|
| 47 | "added" => (int) $task["added"],
|
|---|
| 48 | "removed" => (bool) $task["removed"],
|
|---|
| 49 | "comments" => (int) $task["comments"],
|
|---|
| 50 | "newcomments" => ($user->authenticated() && (int) $task["comments"] && !(bool) $task["commentsread"] ? true : false),
|
|---|
| 51 | );
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | return $tasks;
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | function removetask($taskid) {
|
|---|
| 58 | $user = Core::getUser();
|
|---|
| 59 |
|
|---|
| 60 | if (!$user->authenticated()) {
|
|---|
| 61 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | $task = Table::getInstance("tasks");
|
|---|
| 65 |
|
|---|
| 66 | if (!$task->load($taskid)) {
|
|---|
| 67 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", $task->getError());
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 | if (!$task->save(Array("removed" => true))) {
|
|---|
| 71 | return new JSONRPCErrorResponse("SERVER_ERROR", $task->getError());
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | $subject = getsubject($task->subject);
|
|---|
| 75 |
|
|---|
| 76 | shoutbox_say_system("hat die " . $subject["short"] . "-Aufgabe \"" . $task->text . "\" gelöscht.");
|
|---|
| 77 |
|
|---|
| 78 | return true;
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | function createtask($subject, $date, $text, $important = false) {
|
|---|
| 82 | $user = Core::getUser();
|
|---|
| 83 |
|
|---|
| 84 | if (!$user->authenticated()) {
|
|---|
| 85 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | $task = Table::getInstance("tasks");
|
|---|
| 89 |
|
|---|
| 90 | if (!$task->save(Array(
|
|---|
| 91 | "date" => $date,
|
|---|
| 92 | "subject" => $subject,
|
|---|
| 93 | "text" => $text,
|
|---|
| 94 | "important" => $important,
|
|---|
| 95 | "userid" => $user->id,
|
|---|
| 96 | "added" => time()))) {
|
|---|
| 97 | return new JSONRPCErrorResponse("SERVER_ERROR", $task->getError());
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | $subject = getsubject($task->subject);
|
|---|
| 101 |
|
|---|
| 102 | shoutbox_say_system("hat eine neue " . $subject["short"] . "-Aufgabe für den " . localizedDate("j. F", $task->date) .
|
|---|
| 103 | " eingetragen:[BR /]\"" . $task->text . "\"");
|
|---|
| 104 |
|
|---|
| 105 | return $task->id;
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | function edittask($id, $date, $text, $important = false) {
|
|---|
| 109 | $user = Core::getUser();
|
|---|
| 110 |
|
|---|
| 111 | if (!$user->authenticated()) {
|
|---|
| 112 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | $task = Table::getInstance("tasks");
|
|---|
| 116 |
|
|---|
| 117 | if (!$task->load($id)) {
|
|---|
| 118 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", $task->getError());
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | if (!$task->save(Array("date" => $date, "text" => $text, "important" => $important))) {
|
|---|
| 122 | return new JSONRPCErrorResponse("SERVER_ERROR", $task->getError());
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | return true;
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | function getsubjects() {
|
|---|
| 129 | $database = Core::getDatabase();
|
|---|
| 130 |
|
|---|
| 131 | $database->setQuery("SELECT * FROM #__subjects");
|
|---|
| 132 | $subjectsResponse = $database->loadAssocList();
|
|---|
| 133 |
|
|---|
| 134 | if (!$database->success()) {
|
|---|
| 135 | return new JSONRPCErrorResponse("INVALID_DATABASE_QUERY", "MySQL-Fehlermeldung: " . $database->getErrorMsg());
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | $subjects = Array();
|
|---|
| 139 |
|
|---|
| 140 | foreach ($subjectsResponse as $subject) {
|
|---|
| 141 | $subjects[] = Array(
|
|---|
| 142 | "id" => (int) $subject["id"],
|
|---|
| 143 | "long" => (string) $subject["long"],
|
|---|
| 144 | "short" => (string) $subject["short"]
|
|---|
| 145 | );
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 | return $subjects;
|
|---|
| 149 | }
|
|---|
| 150 |
|
|---|
| 151 | function getsubject($id) {
|
|---|
| 152 | $subject = Table::getInstance("subjects");
|
|---|
| 153 |
|
|---|
| 154 | if (!$subject->load($id)) {
|
|---|
| 155 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", $subject->getError());
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | return Array(
|
|---|
| 159 | "id" => (int) $subject->id,
|
|---|
| 160 | "long" => (string) $subject->long,
|
|---|
| 161 | "short" => (string) $subject->short
|
|---|
| 162 | );
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | function getcomments($taskid) {
|
|---|
| 166 | $database = Core::getDatabase();
|
|---|
| 167 | $user = Core::getUser();
|
|---|
| 168 |
|
|---|
| 169 | if (!$user->authenticated()) {
|
|---|
| 170 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | $task = Table::getInstance("tasks");
|
|---|
| 174 |
|
|---|
| 175 | if (!$task->load($taskid)) {
|
|---|
| 176 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", $task->getError());
|
|---|
| 177 | }
|
|---|
| 178 |
|
|---|
| 179 | $readBy = explode(",", $task->commentsreadby);
|
|---|
| 180 |
|
|---|
| 181 | if (!in_array($user->id, $readBy)) {
|
|---|
| 182 | array_push($readBy, $user->id);
|
|---|
| 183 |
|
|---|
| 184 | if (!$task->save(Array("commentsreadby" => implode(",", $readBy)))) {
|
|---|
| 185 | return new JSONRPCErrorResponse("SERVER_ERROR", $task->getError());
|
|---|
| 186 | }
|
|---|
| 187 | }
|
|---|
| 188 |
|
|---|
| 189 | $database->setQuery("SELECT * FROM #__comments WHERE taskid = " . $database->quote($taskid) . " ORDER BY date");
|
|---|
| 190 |
|
|---|
| 191 | $commentsResponse = $database->loadAssocList();
|
|---|
| 192 |
|
|---|
| 193 | if (!$database->success()) {
|
|---|
| 194 | return new JSONRPCErrorResponse("INVALID_DATABASE_QUERY", "MySQL-Fehlermeldung: " . $database->getErrorMsg());
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 | $comments = Array();
|
|---|
| 198 |
|
|---|
| 199 | foreach ($commentsResponse as $comment) {
|
|---|
| 200 | $comments[] = Array(
|
|---|
| 201 | "id" => (int) $comment["id"],
|
|---|
| 202 | "taskid" => (int) $comment["taskid"],
|
|---|
| 203 | "userid" => (int) $comment["userid"],
|
|---|
| 204 | "date" => (int) $comment["date"],
|
|---|
| 205 | "text" => (string) $comment["comment"]
|
|---|
| 206 | );
|
|---|
| 207 | }
|
|---|
| 208 |
|
|---|
| 209 | return $comments;
|
|---|
| 210 | }
|
|---|
| 211 |
|
|---|
| 212 | function createcomment($taskid, $text) {
|
|---|
| 213 | $user = Core::getUser();
|
|---|
| 214 |
|
|---|
| 215 | if (!$user->authenticated()) {
|
|---|
| 216 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 217 | }
|
|---|
| 218 |
|
|---|
| 219 | $task = Table::getInstance("tasks");
|
|---|
| 220 |
|
|---|
| 221 | if (!$task->load($taskid)) {
|
|---|
| 222 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", $task->getError());
|
|---|
| 223 | }
|
|---|
| 224 |
|
|---|
| 225 | if ($task->date < mktime(0, 0, 0)) {
|
|---|
| 226 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Aufgaben in der Vergangenheit können leider nicht mehr kommentiert werden.");
|
|---|
| 227 | }
|
|---|
| 228 |
|
|---|
| 229 | $comment = Table::getInstance("comments");
|
|---|
| 230 |
|
|---|
| 231 | if (!$comment->save(Array("taskid" => $task->id, "userid" => $user->id, "date" => time(), "comment" => $text))) {
|
|---|
| 232 | return new JSONRPCErrorResponse("SERVER_ERROR", $comment->getError());
|
|---|
| 233 | }
|
|---|
| 234 |
|
|---|
| 235 | $task->save(Array("commentsreadby" => $user->id));
|
|---|
| 236 | $user->save(Array("posts" => $user->posts + 1));
|
|---|
| 237 |
|
|---|
| 238 | return $comment->id;
|
|---|
| 239 | }
|
|---|
| 240 |
|
|---|
| 241 | function editcomment($id, $text) {
|
|---|
| 242 | $user = Core::getUser();
|
|---|
| 243 |
|
|---|
| 244 | if (!$user->authenticated()) {
|
|---|
| 245 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 246 | }
|
|---|
| 247 |
|
|---|
| 248 | $comment = Table::getInstance("comments");
|
|---|
| 249 |
|
|---|
| 250 | if (!$comment->load($id)) {
|
|---|
| 251 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", $comment->getError());
|
|---|
| 252 | }
|
|---|
| 253 |
|
|---|
| 254 | if ($comment->userid != $user->id) {
|
|---|
| 255 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Du darfst diesen Kommentar nicht bearbeiten.");
|
|---|
| 256 | }
|
|---|
| 257 |
|
|---|
| 258 | if (!$comment->save(Array("comment" => $text))) {
|
|---|
| 259 | return new JSONRPCErrorResponse("SERVER_ERROR", $comment->getError());
|
|---|
| 260 | }
|
|---|
| 261 |
|
|---|
| 262 | return true;
|
|---|
| 263 | }
|
|---|
| 264 |
|
|---|
| 265 | function getcontacts() {
|
|---|
| 266 | $database = Core::getDatabase();
|
|---|
| 267 | $user = Core::getUser();
|
|---|
| 268 |
|
|---|
| 269 | $database->setQuery("SELECT u.*, COUNT(t.userid) AS tasks FROM #__users AS u LEFT JOIN #__tasks AS t ON u.id = t.userid GROUP BY u.id");
|
|---|
| 270 |
|
|---|
| 271 | $contactsResponse = $database->loadAssocList();
|
|---|
| 272 |
|
|---|
| 273 | if (!$database->success()) {
|
|---|
| 274 | return new JSONRPCErrorResponse("INVALID_DATABASE_QUERY", "MySQL-Fehlermeldung: " . $database->getErrorMsg());
|
|---|
| 275 | }
|
|---|
| 276 |
|
|---|
| 277 | $contacts = Array();
|
|---|
| 278 |
|
|---|
| 279 | foreach ($contactsResponse as $contact) {
|
|---|
| 280 | $lastcontact = (double) $contact["lastcontact"];
|
|---|
| 281 | $state = (int) $contact["state"];
|
|---|
| 282 |
|
|---|
| 283 | if ($lastcontact < time() - 100) {
|
|---|
| 284 | $state = 0;
|
|---|
| 285 | }
|
|---|
| 286 |
|
|---|
| 287 | $contacts[] = Array(
|
|---|
| 288 | "id" => (int) $contact["id"],
|
|---|
| 289 | "firstname" => (string) $contact["firstname"],
|
|---|
| 290 | "surname" => (string) $contact["surname"],
|
|---|
| 291 | "nickname" => (string) $contact["nickname"],
|
|---|
| 292 | "mail" => (string) ($user->authenticated()) ? $contact["mail"] : (($contact["mail"]) ? "hidden" : ""),
|
|---|
| 293 | "address" => (string) ($user->authenticated()) ? $contact["address"] : (($contact["address"]) ? "hidden" : ""),
|
|---|
| 294 | "plz" => (int) ($user->authenticated()) ? $contact["plz"] : 0,
|
|---|
| 295 | "location" => (string) ($user->authenticated()) ? $contact["location"] : (($contact["location"]) ? "hidden" : ""),
|
|---|
| 296 | "phone" => (string) ($user->authenticated()) ? $contact["phone"] : (($contact["phone"]) ? "hidden" : ""),
|
|---|
| 297 | "mobile" => (string) ($user->authenticated()) ? $contact["mobile"] : (($contact["mobile"]) ? "hidden" : ""),
|
|---|
| 298 | "mainsubject" => (string) $contact["mainsubject"],
|
|---|
| 299 | "posts" => (int) $contact["posts"],
|
|---|
| 300 | "tasks" => (int) $contact["tasks"],
|
|---|
| 301 | "classmember" => (bool) $contact["classmember"],
|
|---|
| 302 | "lastcontact" => $lastcontact,
|
|---|
| 303 | "state" => $state
|
|---|
| 304 | );
|
|---|
| 305 | }
|
|---|
| 306 |
|
|---|
| 307 | return $contacts;
|
|---|
| 308 | }
|
|---|
| 309 |
|
|---|
| 310 | function getfiles() {
|
|---|
| 311 | $database = Core::getDatabase();
|
|---|
| 312 |
|
|---|
| 313 | $database->setQuery("SELECT * FROM #__files ORDER BY uploaded");
|
|---|
| 314 | $filesResponse = $database->loadAssocList();
|
|---|
| 315 |
|
|---|
| 316 | if (!$database->success()) {
|
|---|
| 317 | return new JSONRPCErrorResponse("INVALID_DATABASE_QUERY", "MySQL-Fehlermeldung: " . $database->getErrorMsg());
|
|---|
| 318 | }
|
|---|
| 319 |
|
|---|
| 320 | $files = Array();
|
|---|
| 321 |
|
|---|
| 322 | foreach ($filesResponse as $file) {
|
|---|
| 323 | if ((bool) $file["forcedarchiving"] || time() - (int) $file["uploaded"] >= 2592000) {
|
|---|
| 324 | $archived = true;
|
|---|
| 325 | } else {
|
|---|
| 326 | $archived = false;
|
|---|
| 327 | }
|
|---|
| 328 |
|
|---|
| 329 | $files[] = Array(
|
|---|
| 330 | "id" => (int) $file["id"],
|
|---|
| 331 | "name" => (string) $file["name"],
|
|---|
| 332 | "description" => (string) $file["description"],
|
|---|
| 333 | "size" => (int) $file["size"],
|
|---|
| 334 | "userid" => (int) $file["userid"],
|
|---|
| 335 | "uploaded" => (int) $file["uploaded"],
|
|---|
| 336 | "archived" => $archived
|
|---|
| 337 | );
|
|---|
| 338 | }
|
|---|
| 339 |
|
|---|
| 340 | return $files;
|
|---|
| 341 | }
|
|---|
| 342 |
|
|---|
| 343 | function archivefile($id) {
|
|---|
| 344 | $user = Core::getUser();
|
|---|
| 345 |
|
|---|
| 346 | if (!$user->authenticated()) {
|
|---|
| 347 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 348 | }
|
|---|
| 349 |
|
|---|
| 350 | $file = Table::getInstance("files");
|
|---|
| 351 |
|
|---|
| 352 | if (!$file->load($id)) {
|
|---|
| 353 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", $file->getError());
|
|---|
| 354 | }
|
|---|
| 355 |
|
|---|
| 356 | if ($file->userid !== $user->id) {
|
|---|
| 357 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Du darfst diese Datei leider nicht archivieren. " .
|
|---|
| 358 | "Dies ist dem Benutzer vorbehalten, der die Datei hochgeladen hat.");
|
|---|
| 359 | }
|
|---|
| 360 |
|
|---|
| 361 | if (!$file->save(Array("forcedarchiving" => true))) {
|
|---|
| 362 | return new JSONRPCErrorResponse("SERVER_ERROR", $file->getError());
|
|---|
| 363 | }
|
|---|
| 364 |
|
|---|
| 365 | shoutbox_say_system("hat die Datei \"" . $file->name . "\" archiviert.");
|
|---|
| 366 |
|
|---|
| 367 | return true;
|
|---|
| 368 | }
|
|---|
| 369 |
|
|---|
| 370 | function uploadfile($description) {
|
|---|
| 371 | $user = Core::getUser();
|
|---|
| 372 | $settings = Core::getSettings();
|
|---|
| 373 |
|
|---|
| 374 | if (!$user->authenticated()) {
|
|---|
| 375 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 376 | }
|
|---|
| 377 |
|
|---|
| 378 | if (!$_FILES["Filedata"]) {
|
|---|
| 379 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Keine Datei hochgeladen");
|
|---|
| 380 | }
|
|---|
| 381 |
|
|---|
| 382 | $fnParts = parseFileName(utf8_decode(sanitizeFileName($_FILES["Filedata"]["name"])));
|
|---|
| 383 |
|
|---|
| 384 | if (in_array(strtolower($fnParts["ext"]), $settings->get("upload_extblacklist"))) {
|
|---|
| 385 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Aus Sicherheitsgründen sind keine " .
|
|---|
| 386 | strtoupper($fnParts["ext"]) . "-Dateien erlaubt");
|
|---|
| 387 | }
|
|---|
| 388 |
|
|---|
| 389 | $fnPartsNew = $fnParts;
|
|---|
| 390 | $i = 1;
|
|---|
| 391 |
|
|---|
| 392 | while (is_file("files/" . $fnPartsNew["base"] . "." . $fnPartsNew["ext"])) {
|
|---|
| 393 | $fnPartsNew["base"] = $fnParts["base"] . "_(" . ++$i .")";
|
|---|
| 394 | }
|
|---|
| 395 |
|
|---|
| 396 | $newFileName = $fnPartsNew["base"] . "." . $fnPartsNew["ext"];
|
|---|
| 397 | $fileSize = $_FILES["Filedata"]["size"];
|
|---|
| 398 |
|
|---|
| 399 | if (!move_uploaded_file($_FILES["Filedata"]["tmp_name"], "files/" . $newFileName)) {
|
|---|
| 400 | return new JSONRPCErrorResponse("SERVER_ERROR");
|
|---|
| 401 | }
|
|---|
| 402 |
|
|---|
| 403 | $file = Table::getInstance("files");
|
|---|
| 404 |
|
|---|
| 405 | if (!$file->save(Array(
|
|---|
| 406 | "name" => $newFileName,
|
|---|
| 407 | "description" => $description,
|
|---|
| 408 | "size" => $fileSize,
|
|---|
| 409 | "userid" => $user->id,
|
|---|
| 410 | "uploaded" => time()))) {
|
|---|
| 411 | return new JSONRPCErrorResponse("SERVER_ERROR", $file->getError());
|
|---|
| 412 | }
|
|---|
| 413 |
|
|---|
| 414 | shoutbox_say_system("hat die Datei \"" . $newFileName . "\" hochgeladen.");
|
|---|
| 415 |
|
|---|
| 416 | return Array("id" => $file->id, "filename" => $file->name);
|
|---|
| 417 | }
|
|---|
| 418 |
|
|---|
| 419 | function signin($nickname, $password) {
|
|---|
| 420 | $user = Core::getUser();
|
|---|
| 421 |
|
|---|
| 422 | if (!$user->signIn($nickname, $password)) {
|
|---|
| 423 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 424 | }
|
|---|
| 425 |
|
|---|
| 426 | return getuserdata();
|
|---|
| 427 | }
|
|---|
| 428 |
|
|---|
| 429 | function requestpassword($username, $password) {
|
|---|
| 430 | $database = Core::getDatabase();
|
|---|
| 431 | $settings = Core::getSettings();
|
|---|
| 432 |
|
|---|
| 433 | if (!$username) {
|
|---|
| 434 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Keinen Benutzernamen angegeben.");
|
|---|
| 435 | }
|
|---|
| 436 |
|
|---|
| 437 | if (!$password) {
|
|---|
| 438 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Kein Passwort angegeben.");
|
|---|
| 439 | }
|
|---|
| 440 |
|
|---|
| 441 | $database->setQuery("SELECT * FROM #__users WHERE nickname = " . $database->quote($username));
|
|---|
| 442 | $user = $database->loadAssoc();
|
|---|
| 443 |
|
|---|
| 444 | if (!$database->success()) {
|
|---|
| 445 | return new JSONRPCErrorResponse("INVALID_DATABASE_QUERY", "MySQL-Fehlermeldung: " . $database->getErrorMsg());
|
|---|
| 446 | }
|
|---|
| 447 |
|
|---|
| 448 | if ($database->getNumRows() != 1) {
|
|---|
| 449 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Benutzer existiert nicht.");
|
|---|
| 450 | }
|
|---|
| 451 |
|
|---|
| 452 | $requestKey = generateRandomString();
|
|---|
| 453 |
|
|---|
| 454 | $database->setQuery("UPDATE #__users SET " .
|
|---|
| 455 | "newpassword = " . $database->quote(md5($password)) . ", " .
|
|---|
| 456 | "newpasswordkey = " . $database->quote($requestKey) . " WHERE " .
|
|---|
| 457 | "nickname = " . $database->quote($username)
|
|---|
| 458 | );
|
|---|
| 459 |
|
|---|
| 460 | if (!$database->query()) {
|
|---|
| 461 | return new JSONRPCErrorResponse("INVALID_DATABASE_QUERY", "MySQL-Fehlermeldung: " . $database->getErrorMsg());
|
|---|
| 462 | }
|
|---|
| 463 |
|
|---|
| 464 | if (!mail($user["mail"], "Neues Klassenbuchpasswort bestätigen",
|
|---|
| 465 | "Hallo " . $user["firstname"] . ",\n\n" .
|
|---|
| 466 | "Du hast im Klassenbuch ein neues Passwort angefordert. Klicke auf den foldenden Link, " .
|
|---|
| 467 | "damit dein Passwort endgültig auf \"$password\" gewechselt wird. Wenn du kein Passwort angefordert hast, " .
|
|---|
| 468 | "solltest du nicht auf diesen Link klicken, sondern diese E-Mail gleich löschen!\n\n" .
|
|---|
| 469 | $settings->get("domain") . "index.php?passwordverification=$requestKey",
|
|---|
| 470 | "From: Klassenbuch <" . $settings->get("mail") . ">")) {
|
|---|
| 471 | return new JSONRPCErrorResponse("SERVER_ERROR");
|
|---|
| 472 | }
|
|---|
| 473 |
|
|---|
| 474 | return true;
|
|---|
| 475 | }
|
|---|
| 476 |
|
|---|
| 477 | function verifynewpassword($key) {
|
|---|
| 478 | $database = Core::getDatabase();
|
|---|
| 479 |
|
|---|
| 480 | if (!$key) {
|
|---|
| 481 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Kein Bestätigungsschlussel angegeben");
|
|---|
| 482 | }
|
|---|
| 483 |
|
|---|
| 484 | $database->setQuery("SELECT * FROM #__users WHERE newpasswordkey = " . $database->quote($key));
|
|---|
| 485 | $user = $database->loadAssoc();
|
|---|
| 486 |
|
|---|
| 487 | if (!$database->success()) {
|
|---|
| 488 | return new JSONRPCErrorResponse("INVALID_DATABASE_QUERY", "MySQL-Fehlermeldung: " . $database->getErrorMsg());
|
|---|
| 489 | }
|
|---|
| 490 |
|
|---|
| 491 | if ($database->getNumRows() != 1) {
|
|---|
| 492 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Ungültiger Bestätigungsschlüssel.");
|
|---|
| 493 | }
|
|---|
| 494 |
|
|---|
| 495 | $database->setQuery("UPDATE #__users SET " .
|
|---|
| 496 | "password = " . $database->quote($user["newpassword"]) . ", " .
|
|---|
| 497 | "newpasswordkey = '', " .
|
|---|
| 498 | "newpassword = '' WHERE " .
|
|---|
| 499 | "id = " . $database->quote($user["id"])
|
|---|
| 500 | );
|
|---|
| 501 |
|
|---|
| 502 | if (!$database->query()) {
|
|---|
| 503 | return new JSONRPCErrorResponse("INVALID_DATABASE_QUERY", "MySQL-Fehlermeldung: " . $database->getErrorMsg());
|
|---|
| 504 | }
|
|---|
| 505 |
|
|---|
| 506 | return true;
|
|---|
| 507 | }
|
|---|
| 508 |
|
|---|
| 509 | function changepassword($newpassword, $currentpassword) {
|
|---|
| 510 | $user = Core::getUser();
|
|---|
| 511 |
|
|---|
| 512 | if (!$user->authenticated()) {
|
|---|
| 513 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 514 | }
|
|---|
| 515 |
|
|---|
| 516 | if (!$newpassword || !$currentpassword || md5($currentpassword) !== $user->password) {
|
|---|
| 517 | return new JSONRPCErrorResponse("INCORRECT_PARAMS");
|
|---|
| 518 | }
|
|---|
| 519 |
|
|---|
| 520 | if (!$user->save(Array("password" => md5($newpassword)))) {
|
|---|
| 521 | return new JSONRPCErrorResponse("SERVER_ERROR", $comment->getError());
|
|---|
| 522 | };
|
|---|
| 523 |
|
|---|
| 524 | return true;
|
|---|
| 525 | }
|
|---|
| 526 |
|
|---|
| 527 | function getuserdata() {
|
|---|
| 528 | $user = Core::getUser();
|
|---|
| 529 |
|
|---|
| 530 | if (!$user->authenticated()) {
|
|---|
| 531 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 532 | }
|
|---|
| 533 |
|
|---|
| 534 | return Array(
|
|---|
| 535 | "id" => $user->id,
|
|---|
| 536 | "nickname" => $user->nickname,
|
|---|
| 537 | "token" => $user->token,
|
|---|
| 538 | "profile" => $user->getProfile(),
|
|---|
| 539 | "settings" => $user->getSettings(),
|
|---|
| 540 | "isadmin" => $user->isadmin
|
|---|
| 541 | );
|
|---|
| 542 | }
|
|---|
| 543 |
|
|---|
| 544 | function updateuserprofile($profileInformation) {
|
|---|
| 545 | $user = Core::getUser();
|
|---|
| 546 |
|
|---|
| 547 | if (!$user->authenticated()) {
|
|---|
| 548 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 549 | }
|
|---|
| 550 |
|
|---|
| 551 | if (!$user->updateProfile($profileInformation)) {
|
|---|
| 552 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", $user->getError());
|
|---|
| 553 | }
|
|---|
| 554 |
|
|---|
| 555 | return true;
|
|---|
| 556 | }
|
|---|
| 557 |
|
|---|
| 558 | function changeusersettings($settings) {
|
|---|
| 559 | $user = Core::getUser();
|
|---|
| 560 |
|
|---|
| 561 | if (!$user->authenticated()) {
|
|---|
| 562 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 563 | }
|
|---|
| 564 |
|
|---|
| 565 | $currentSettings = $user->getSettings();
|
|---|
| 566 |
|
|---|
| 567 | foreach ($settings as $key => $value) {
|
|---|
| 568 | $currentSettings[$key] = $value;
|
|---|
| 569 | }
|
|---|
| 570 |
|
|---|
| 571 | if (!$user->save(Array("settings" => $currentSettings))) {
|
|---|
| 572 | return new JSONRPCErrorResponse("SERVER_ERROR", $user->getError());
|
|---|
| 573 | }
|
|---|
| 574 |
|
|---|
| 575 | return true;
|
|---|
| 576 | }
|
|---|
| 577 |
|
|---|
| 578 | function setuserstate($state) {
|
|---|
| 579 | $user = Core::getUser();
|
|---|
| 580 |
|
|---|
| 581 | if (!$user->authenticated()) {
|
|---|
| 582 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 583 | }
|
|---|
| 584 |
|
|---|
| 585 | if ($state == User::OFFLINE || $state == User::AWAY || $state == User::ONLINE) {
|
|---|
| 586 | return $user->setState($state);
|
|---|
| 587 | } else {
|
|---|
| 588 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Kein gültiger Status angegeben.");
|
|---|
| 589 | }
|
|---|
| 590 | }
|
|---|
| 591 |
|
|---|
| 592 | function signout() {
|
|---|
| 593 | $user = Core::getUser();
|
|---|
| 594 |
|
|---|
| 595 | return $user->signOut();
|
|---|
| 596 | }
|
|---|
| 597 |
|
|---|
| 598 | function registeruser($nickname, $firstname, $surname, $mail, $password) {
|
|---|
| 599 | $database = Core::getDatabase();
|
|---|
| 600 | $settings = Core::getSettings();
|
|---|
| 601 |
|
|---|
| 602 | $nickname = trim(strip_tags($nickname));
|
|---|
| 603 | $firstname = trim(strip_tags($firstname));
|
|---|
| 604 | $surname = trim(strip_tags($surname));
|
|---|
| 605 | $mail = trim(strip_tags($mail));
|
|---|
| 606 |
|
|---|
| 607 | if (!$nickname) {
|
|---|
| 608 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Kein Nickname angegeben.");
|
|---|
| 609 | }
|
|---|
| 610 |
|
|---|
| 611 | if (!$firstname) {
|
|---|
| 612 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Kein Vorname angegeben.");
|
|---|
| 613 | }
|
|---|
| 614 |
|
|---|
| 615 | if (!$surname) {
|
|---|
| 616 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Kein Nachname angegeben.");
|
|---|
| 617 | }
|
|---|
| 618 |
|
|---|
| 619 | if (!$mail) {
|
|---|
| 620 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Keine E-Mail-Adresse angegeben.");
|
|---|
| 621 | }
|
|---|
| 622 |
|
|---|
| 623 | if (!$password) {
|
|---|
| 624 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Keine Passwort angegeben.");
|
|---|
| 625 | }
|
|---|
| 626 |
|
|---|
| 627 | /* $database->setQuery("SELECT * FROM #__users WHERE nickname = " . $database->quote($nickname) . " OR mail = " .
|
|---|
| 628 | $database->quote($mail));
|
|---|
| 629 | $response = $database->query();
|
|---|
| 630 |
|
|---|
| 631 | if ($database->getNumRows() != 0) {
|
|---|
| 632 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Ein Benutzer mit diesem Nicknamen bzw. dieser E-Mail-Adresse existiert " .
|
|---|
| 633 | "bereits.");
|
|---|
| 634 | } */
|
|---|
| 635 |
|
|---|
| 636 | /* $database->setQuery("INSERT INTO #__users (nickname, firstname, surname, mail, password) VALUES(" .
|
|---|
| 637 | $database->quote($nickname) . ", " . $database->quote($firstname) . ", " . $database->quote($surname) . ", " .
|
|---|
| 638 | $database->quote(md5($password)) . ", " . $database->quote($mail) . ")");
|
|---|
| 639 |
|
|---|
| 640 | $response = $database->query();
|
|---|
| 641 | if (!$response) {
|
|---|
| 642 | return new JSONRPCErrorResponse("INVALID_DATABASE_QUERY", "MySQL-Fehlermeldung: " . $database->getErrorMsg());
|
|---|
| 643 | } else { */
|
|---|
| 644 |
|
|---|
| 645 | try {
|
|---|
| 646 | mail($settings->get("adminmail"), "Neuen Klassenbuchbenutzer hinzufügen", $firstname . " " . $surname .
|
|---|
| 647 | "hat sich im Klassenbuch unter dem Nicknamen \"" . $nickname . "\" angemeldet.\n\n" .
|
|---|
| 648 | "E-Mail-Adresse: " . $mail . "\n" . "Passwort: " . md5($password),
|
|---|
| 649 | "From: " . $settings->get("mail") . "\r\nX-Mailer: PHP/' . phpversion()");
|
|---|
| 650 | } catch(Exception $e) {
|
|---|
| 651 | return new JSONRPCErrorResponse("SERVER_ERROR", "Fehler beim E-Mailversand.");
|
|---|
| 652 | }
|
|---|
| 653 |
|
|---|
| 654 | return true;
|
|---|
| 655 | }
|
|---|
| 656 |
|
|---|
| 657 | function gallery_getalbums() {
|
|---|
| 658 | $database = Core::getDatabase();
|
|---|
| 659 |
|
|---|
| 660 | $database->setQuery("SELECT a.*, COUNT(p.albumid) AS pictures " . |
|---|
| 661 | "FROM #__gallery_albums AS a LEFT JOIN #__gallery_pictures AS p ON a.id = p.albumid GROUP BY a.id"); |
|---|
| 662 |
|
|---|
| 663 | $albumsResponse = $database->loadAssocList();
|
|---|
| 664 |
|
|---|
| 665 | if (!$database->success()) {
|
|---|
| 666 | return new JSONRPCErrorResponse("INVALID_DATABASE_QUERY", "MySQL-Fehlermeldung: " . $database->getErrorMsg());
|
|---|
| 667 | }
|
|---|
| 668 |
|
|---|
| 669 | $albums = Array();
|
|---|
| 670 |
|
|---|
| 671 | foreach ($albumsResponse as $album) {
|
|---|
| 672 | $albums[] = Array(
|
|---|
| 673 | "id" => (int) $album["id"],
|
|---|
| 674 | "name" => (string) $album["name"],
|
|---|
| 675 | "description" => (string) $album["description"],
|
|---|
| 676 | "pictures" => (int) $album["pictures"]
|
|---|
| 677 | );
|
|---|
| 678 | }
|
|---|
| 679 |
|
|---|
| 680 | return $albums;
|
|---|
| 681 | }
|
|---|
| 682 |
|
|---|
| 683 | function gallery_createalbum($name, $description = "") {
|
|---|
| 684 | $user = Core::getUser();
|
|---|
| 685 |
|
|---|
| 686 | if (!$user->authenticated()) {
|
|---|
| 687 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 688 | }
|
|---|
| 689 |
|
|---|
| 690 | $album = Table::getInstance("albums");
|
|---|
| 691 |
|
|---|
| 692 | if (!$album->save(Array(
|
|---|
| 693 | "name" => $name,
|
|---|
| 694 | "description" => $description,
|
|---|
| 695 | "date" => time()))) {
|
|---|
| 696 | return new JSONRPCErrorResponse("SERVER_ERROR", $album->getError());
|
|---|
| 697 | }
|
|---|
| 698 |
|
|---|
| 699 | shoutbox_say_system("hat das Fotoalbum \"" . $name . "\" hinzugefügt.");
|
|---|
| 700 |
|
|---|
| 701 | return $album->id;
|
|---|
| 702 | }
|
|---|
| 703 |
|
|---|
| 704 | function gallery_removealbum($id) {
|
|---|
| 705 | $user = Core::getUser();
|
|---|
| 706 |
|
|---|
| 707 | if (!$user->authenticated()) {
|
|---|
| 708 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 709 | }
|
|---|
| 710 |
|
|---|
| 711 | $albumTable = Table::getInstance("albums");
|
|---|
| 712 |
|
|---|
| 713 | if (!$albumTable->delete($id)) {
|
|---|
| 714 | return new JSONRPCErrorResponse("SERVER_ERROR", $album->getError());
|
|---|
| 715 | }
|
|---|
| 716 |
|
|---|
| 717 | shoutbox_say_system("hat das Fotoalbum " . $name . " gelöscht.");
|
|---|
| 718 |
|
|---|
| 719 | return true;
|
|---|
| 720 | }
|
|---|
| 721 |
|
|---|
| 722 | function gallery_downloadalbum($albumid) {
|
|---|
| 723 | $database = Core::getDatabase();
|
|---|
| 724 | $user = Core::getUser();
|
|---|
| 725 |
|
|---|
| 726 | $album = Table::getInstance("albums");
|
|---|
| 727 |
|
|---|
| 728 | if (!$album->load($albumid)) {
|
|---|
| 729 | return new JSONRPCErrorResponse("SERVER_ERROR", $album->getError());
|
|---|
| 730 | }
|
|---|
| 731 |
|
|---|
| 732 | $fileName = "files/" . sanitizeFilename(strtolower($album->name)) . ".zip";
|
|---|
| 733 | $rebuild = true;
|
|---|
| 734 |
|
|---|
| 735 | if (file_exists($fileName)) {
|
|---|
| 736 | $database->setQuery("SELECT * FROM #__gallery_pictures WHERE " .
|
|---|
| 737 | "albumid = " . $database->quote($albumid) . " AND " .
|
|---|
| 738 | "submitted > " . $database->quote(filemtime($fileName))
|
|---|
| 739 | );
|
|---|
| 740 |
|
|---|
| 741 | if ($database->getNumRows($database->query()) == 0) {
|
|---|
| 742 | $rebuild = false;
|
|---|
| 743 | }
|
|---|
| 744 | }
|
|---|
| 745 |
|
|---|
| 746 | if ($rebuild) {
|
|---|
| 747 | if (file_exists($fileName)) {
|
|---|
| 748 | unlink($fileName);
|
|---|
| 749 | }
|
|---|
| 750 |
|
|---|
| 751 | Core::import("includes.compression");
|
|---|
| 752 |
|
|---|
| 753 | $zippedFile = new zip_file($fileName);
|
|---|
| 754 | $zippedFile->set_options(array("inmemory" => 0, "recurse" => 0, "storepaths" => 0, "overwrite" => 0, "level" => 0));
|
|---|
| 755 |
|
|---|
| 756 | $database->setQuery("SELECT * FROM #__gallery_pictures WHERE albumid = " . $database->quote($albumid));
|
|---|
| 757 | $pictures = $database->loadAssocList();
|
|---|
| 758 |
|
|---|
| 759 | if (!$database->success()) {
|
|---|
| 760 | return new JSONRPCErrorResponse("INVALID_DATABASE_QUERY", "MySQL-Fehlermeldung: " . $database->getErrorMsg());
|
|---|
| 761 | }
|
|---|
| 762 |
|
|---|
| 763 | foreach ($pictures as $picture) {
|
|---|
| 764 | $zippedFile->add_files("gallery/originals/" . $picture["filename"]);
|
|---|
| 765 | }
|
|---|
| 766 |
|
|---|
| 767 | if ($zippedFile->create_archive() === 0) {
|
|---|
| 768 | return new JSONRPCErrorResponse("SERVER_ERROR", "Archiv konnte nicht erstellt werden");
|
|---|
| 769 | }
|
|---|
| 770 | }
|
|---|
| 771 |
|
|---|
| 772 | return $fileName;
|
|---|
| 773 | }
|
|---|
| 774 |
|
|---|
| 775 | function gallery_getpictures($albumid) {
|
|---|
| 776 | $database = Core::getDatabase();
|
|---|
| 777 |
|
|---|
| 778 | $album = Table::getInstance("albums");
|
|---|
| 779 |
|
|---|
| 780 | if (!$album->load($albumid)) {
|
|---|
| 781 | return new JSONRPCErrorResponse("SERVER_ERROR", $album->getError());
|
|---|
| 782 | }
|
|---|
| 783 |
|
|---|
| 784 | $database->setQuery("SELECT * FROM #__gallery_pictures WHERE albumid = " . $database->quote($albumid) .
|
|---|
| 785 | " ORDER BY taken ASC");
|
|---|
| 786 |
|
|---|
| 787 | $picturesResponse = $database->loadAssocList();
|
|---|
| 788 |
|
|---|
| 789 | if (!$database->success()) {
|
|---|
| 790 | return new JSONRPCErrorResponse("INVALID_DATABASE_QUERY", "MySQL-Fehlermeldung: " . $database->getErrorMsg());
|
|---|
| 791 | }
|
|---|
| 792 |
|
|---|
| 793 | $pictures = Array();
|
|---|
| 794 |
|
|---|
| 795 | foreach ($picturesResponse as $picture) {
|
|---|
| 796 | $pictures[] = Array(
|
|---|
| 797 | "id" => (int) $picture["id"],
|
|---|
| 798 | "filename" => (string) $picture["filename"],
|
|---|
| 799 | "caption" => (string) $picture["caption"],
|
|---|
| 800 | "userid" => (int) $picture["userid"],
|
|---|
| 801 | "submitted" => (int) $picture["submitted"],
|
|---|
| 802 | "taken" => (int) $picture["taken"]);
|
|---|
| 803 | }
|
|---|
| 804 |
|
|---|
| 805 | return $pictures;
|
|---|
| 806 | }
|
|---|
| 807 |
|
|---|
| 808 | function gallery_uploadpicture($albumid) {
|
|---|
| 809 | $user = Core::getUser();
|
|---|
| 810 | $database = Core::getDatabase();
|
|---|
| 811 |
|
|---|
| 812 | if (!$user->authenticated()) {
|
|---|
| 813 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 814 | }
|
|---|
| 815 |
|
|---|
| 816 | $album = Table::getInstance("albums");
|
|---|
| 817 |
|
|---|
| 818 | if (!$album->load($albumid)) {
|
|---|
| 819 | return new JSONRPCErrorResponse("SERVER_ERROR", $album->getError());
|
|---|
| 820 | }
|
|---|
| 821 |
|
|---|
| 822 | if (!$_FILES["Filedata"]) {
|
|---|
| 823 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Kein Foto hochgeladen");
|
|---|
| 824 | }
|
|---|
| 825 |
|
|---|
| 826 | $allowedExtensions = Array("jpg", "bmp", "gif", "png");
|
|---|
| 827 |
|
|---|
| 828 | $fnParts = parseFileName(sanitizeFileName(utf8_decode($_FILES["Filedata"]["name"])));
|
|---|
| 829 | $fnPartsNew = $fnParts;
|
|---|
| 830 |
|
|---|
| 831 | $size = $_FILES["Filedata"]["size"];
|
|---|
| 832 |
|
|---|
| 833 | if ($size == 0) {
|
|---|
| 834 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Eine 0-Byte-Datei");
|
|---|
| 835 | }
|
|---|
| 836 |
|
|---|
| 837 | if (!in_array($fnParts["ext"], $allowedExtensions)) {
|
|---|
| 838 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Nicht unterstützter Dateityp.");
|
|---|
| 839 | }
|
|---|
| 840 |
|
|---|
| 841 | $i = 1;
|
|---|
| 842 |
|
|---|
| 843 | while (is_file("gallery/originals/" . $fnPartsNew["base"] . "." . $fnPartsNew["ext"])) {
|
|---|
| 844 | $fnPartsNew["base"] = $fnParts["base"] . "_(" . ++$i .")";
|
|---|
| 845 | }
|
|---|
| 846 |
|
|---|
| 847 | $newFileName = $fnPartsNew["base"] . "." . $fnPartsNew["ext"];
|
|---|
| 848 |
|
|---|
| 849 | if (!move_uploaded_file($_FILES["Filedata"]["tmp_name"], "gallery/originals/" . $newFileName)) {
|
|---|
| 850 | return new JSONRPCErrorResponse("SERVER_ERROR");
|
|---|
| 851 | }
|
|---|
| 852 |
|
|---|
| 853 | $exifData = exif_read_data("gallery/originals/" . $newFileName, 0, true);
|
|---|
| 854 | $takenRaw = $exifData["EXIF"]["DateTimeOriginal"];
|
|---|
| 855 |
|
|---|
| 856 | $taken = mktime(
|
|---|
| 857 | intval(substr($takenRaw, 11, 2)),
|
|---|
| 858 | intval(substr($takenRaw, 14, 2)),
|
|---|
| 859 | intval(substr($takenRaw, 17, 2)),
|
|---|
| 860 | intval(substr($takenRaw, 5, 2)),
|
|---|
| 861 | intval(substr($takenRaw, 8, 2)),
|
|---|
| 862 | intval(substr($takenRaw, 0, 4))
|
|---|
| 863 | );
|
|---|
| 864 |
|
|---|
| 865 | $retval = gallery_generatethumbnails($newFileName);
|
|---|
| 866 |
|
|---|
| 867 | if ($retval !== true) {
|
|---|
| 868 | unlink("gallery/originals/" . $newFileName);
|
|---|
| 869 | return $retval;
|
|---|
| 870 | }
|
|---|
| 871 |
|
|---|
| 872 | chmod("gallery/originals/" . $newFileName, 0644);
|
|---|
| 873 |
|
|---|
| 874 | $database->setQuery("SELECT * FROM #__gallery_pictures WHERE " .
|
|---|
| 875 | "userid = " . $database->quote($user->id) . " AND " .
|
|---|
| 876 | "albumid = " . $database->quote($albumid) . " AND " .
|
|---|
| 877 | "submitted > " . $database->quote(time() - 15)
|
|---|
| 878 | );
|
|---|
| 879 |
|
|---|
| 880 | if (!$database->getNumRows($database->query())) {
|
|---|
| 881 | shoutbox_say_system("lädt neue Fotos ins Album \"" . $album->name . "\".");
|
|---|
| 882 | }
|
|---|
| 883 |
|
|---|
| 884 | $picture = Table::getInstance("pictures");
|
|---|
| 885 |
|
|---|
| 886 | if ($picture->save(Array(
|
|---|
| 887 | "filename" => $newFileName,
|
|---|
| 888 | "albumid" => $albumid,
|
|---|
| 889 | "userid" => $user->id,
|
|---|
| 890 | "submitted" => time(),
|
|---|
| 891 | "taken" => $taken))) {
|
|---|
| 892 | return $picture->id;
|
|---|
| 893 | } else {
|
|---|
| 894 | return new JSONRPCErrorResponse("SERVER_ERROR", $picture->getError());
|
|---|
| 895 | }
|
|---|
| 896 | }
|
|---|
| 897 |
|
|---|
| 898 | function gallery_rotatepicture($id, $degree) {
|
|---|
| 899 | $user = Core::getUser();
|
|---|
| 900 |
|
|---|
| 901 | if (!$user->authenticated()) {
|
|---|
| 902 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 903 | }
|
|---|
| 904 |
|
|---|
| 905 | if (!$id) {
|
|---|
| 906 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Kein gültiges Bild angegeben.");
|
|---|
| 907 | }
|
|---|
| 908 |
|
|---|
| 909 | if ($degree % 90 != 0) {
|
|---|
| 910 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Kein gültiger Winkel angegeben.");
|
|---|
| 911 | }
|
|---|
| 912 |
|
|---|
| 913 | $picture = Table::getInstance("pictures");
|
|---|
| 914 |
|
|---|
| 915 | if (!$picture->load($id)) {
|
|---|
| 916 | return new JSONRPCErrorResponse("INCORRECT_PARAMS", "Kein gültiges Bild angegeben.");
|
|---|
| 917 | }
|
|---|
| 918 |
|
|---|
| 919 | if (!($user->isadmin || $picture->userid == $user->id)) {
|
|---|
| 920 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED", "Fotos dürfen nur von demjenigen Benutzer bearbeitet werden, " .
|
|---|
| 921 | "der das betreffende Foto hochgeladen hat. Ansonsten hat nur der Administrator das Recht dazu.");
|
|---|
| 922 | }
|
|---|
| 923 |
|
|---|
| 924 | if (!function_exists("gd_info")) {
|
|---|
| 925 | return new JSONRPCErrorResponse("SERVER_ERROR", "Der Server nicht über eine benötigte Grafikbibliothek zu verfügen.");
|
|---|
| 926 | }
|
|---|
| 927 |
|
|---|
| 928 | $path = "gallery/originals/" . $picture->filename;
|
|---|
| 929 |
|
|---|
| 930 | $source = imagecreatefromjpeg($path);
|
|---|
| 931 | $rotated = imagerotate($source, $degree, 0);
|
|---|
| 932 | imagejpeg($rotated, $path, 85);
|
|---|
| 933 | imagedestroy($rotated);
|
|---|
| 934 |
|
|---|
| 935 | gallery_generatethumbnails($picture->filename);
|
|---|
| 936 |
|
|---|
| 937 | return true;
|
|---|
| 938 | }
|
|---|
| 939 |
|
|---|
| 940 | function gallery_generatethumbnails($fileName) {
|
|---|
| 941 | Core::import("includes.phpthumb.phpthumb");
|
|---|
| 942 |
|
|---|
| 943 | $phpThumb = new phpThumb();
|
|---|
| 944 |
|
|---|
| 945 | $phpThumb->src = "gallery/originals/" . $fileName;
|
|---|
| 946 | $phpThumb->w = 120;
|
|---|
| 947 | $phpThumb->h = 90;
|
|---|
| 948 | $phpThumb->q = 85;
|
|---|
| 949 |
|
|---|
| 950 | if (!$phpThumb->GenerateThumbnail() || !$phpThumb->RenderToFile("gallery/thumbnails/" . $fileName)) {
|
|---|
| 951 | if (strpos(implode(",", $phpThumb->debugmessages), "Source image is too large")) {
|
|---|
| 952 | return new JSONRPCErrorResponse("SERVER_ERROR", "Das Bild ist zu gross. Bitte zuerst verkleinern.");
|
|---|
| 953 | }
|
|---|
| 954 |
|
|---|
| 955 | return new JSONRPCErrorResponse("SERVER_ERROR", "Miniaturansicht konnte nicht erstellt werden");
|
|---|
| 956 | }
|
|---|
| 957 |
|
|---|
| 958 | $phpThumb2 = new phpThumb();
|
|---|
| 959 |
|
|---|
| 960 | $phpThumb2->src = "gallery/originals/" . $fileName;
|
|---|
| 961 | $phpThumb2->w = 640;
|
|---|
| 962 | $phpThumb2->h = 480;
|
|---|
| 963 | $phpThumb->q = 85;
|
|---|
| 964 |
|
|---|
| 965 | if (!$phpThumb2->GenerateThumbnail() || !$phpThumb2->RenderToFile("gallery/pictures/" . $fileName)) {
|
|---|
| 966 | return new JSONRPCErrorResponse("SERVER_ERROR", "Diashow-Version des Fotos konnte nicht erstellt werden");
|
|---|
| 967 | }
|
|---|
| 968 |
|
|---|
| 969 | // Setzt die Zugriffsrechte
|
|---|
| 970 | chmod("gallery/pictures/" . $fileName, 0644);
|
|---|
| 971 | chmod("gallery/thumbnails/" . $fileName, 0644);
|
|---|
| 972 |
|
|---|
| 973 | return true;
|
|---|
| 974 | }
|
|---|
| 975 |
|
|---|
| 976 | function shoutbox_poll($startAfter) {
|
|---|
| 977 | $database = Core::getDatabase();
|
|---|
| 978 |
|
|---|
| 979 | if ($startAfter) {
|
|---|
| 980 | $database->setQuery("SELECT * FROM #__messages WHERE id > " . $database->quote($startAfter));
|
|---|
| 981 | } else {
|
|---|
| 982 | $database->setQuery("SELECT * FROM #__messages ORDER BY id DESC LIMIT 100");
|
|---|
| 983 | }
|
|---|
| 984 |
|
|---|
| 985 | $messagesResponse = $database->loadAssocList();
|
|---|
| 986 |
|
|---|
| 987 | if (!$database->success()) {
|
|---|
| 988 | return new JSONRPCErrorResponse("INVALID_DATABASE_QUERY", "MySQL-Fehlermeldung: " . $database->getErrorMsg());
|
|---|
| 989 | }
|
|---|
| 990 |
|
|---|
| 991 | $messages = Array();
|
|---|
| 992 |
|
|---|
| 993 | foreach ($messagesResponse as $message) {
|
|---|
| 994 | $messages[] = Array(
|
|---|
| 995 | "id" => (int) $message["id"],
|
|---|
| 996 | "userid" => (int) $message["userid"],
|
|---|
| 997 | "date" => (int) $message["date"],
|
|---|
| 998 | "text" => (string) $message["text"],
|
|---|
| 999 | "system" => (bool) $message["system"]
|
|---|
| 1000 | );
|
|---|
| 1001 | }
|
|---|
| 1002 |
|
|---|
| 1003 | if (count($messages)) {
|
|---|
| 1004 | $user = Core::getUser();
|
|---|
| 1005 |
|
|---|
| 1006 | if (!$user->authenticated()) {
|
|---|
| 1007 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 1008 | }
|
|---|
| 1009 | }
|
|---|
| 1010 |
|
|---|
| 1011 | return array_reverse($messages);
|
|---|
| 1012 | };
|
|---|
| 1013 |
|
|---|
| 1014 | function shoutbox_say($text, $startAfter, $system = false) {
|
|---|
| 1015 | $user = Core::getUser();
|
|---|
| 1016 |
|
|---|
| 1017 | if (!$user->authenticated()) {
|
|---|
| 1018 | return new JSONRPCErrorResponse("AUTHENTICATION_FAILED");
|
|---|
| 1019 | }
|
|---|
| 1020 |
|
|---|
| 1021 | $message = Table::getInstance("messages");
|
|---|
| 1022 |
|
|---|
| 1023 | if (!$message->save(Array(
|
|---|
| 1024 | "userid" => $user->id,
|
|---|
| 1025 | "date" => time(),
|
|---|
| 1026 | "text" => $text,
|
|---|
| 1027 | "system" => $system))) {
|
|---|
| 1028 | return new JSONRPCErrorResponse("SERVER_ERROR", $message->getError());
|
|---|
| 1029 | }
|
|---|
| 1030 |
|
|---|
| 1031 | if ($startAfter) {
|
|---|
| 1032 | return shoutbox_poll($startAfter);
|
|---|
| 1033 | } else {
|
|---|
| 1034 | return $message->id;
|
|---|
| 1035 | }
|
|---|
| 1036 | }
|
|---|
| 1037 |
|
|---|
| 1038 | // Used internally only
|
|---|
| 1039 | function shoutbox_say_system($text) {
|
|---|
| 1040 | return shoutbox_say($text, 0, true);
|
|---|
| 1041 | }
|
|---|
| 1042 |
|
|---|
| 1043 | // Die Dispatch Map für diesen Webservice: In ihr enthalten sind die Namen aller Methoden, die dieser Service bereitstellt.
|
|---|
| 1044 | // Zusätzlich enthält sie Angaben darüber, welche Parameter die bestimmten Methoden erwarten.
|
|---|
| 1045 | // Eine kurze Beschreibung aller Methoden ist ebenfalls enthalten.
|
|---|
| 1046 | $dispatchMap = Array(
|
|---|
| 1047 | "gettasks" => Array(
|
|---|
| 1048 | "function" => "gettasks",
|
|---|
| 1049 | "signature" => Array(Array("array"), Array("array", "int"), Array("array", "int", "int")),
|
|---|
| 1050 | "docstring" => "Gibt die Hausaufgaben für einen bestimmten Zeitraum aus. Standardmässig werden alle " .
|
|---|
| 1051 | "anstehenden Aufgaben zurückgegeben.",
|
|---|
| 1052 | ),
|
|---|
| 1053 |
|
|---|
| 1054 | "removetask" => Array(
|
|---|
| 1055 | "function" => "removetask",
|
|---|
| 1056 | "signature" => Array(Array("boolean", "int")),
|
|---|
| 1057 | "docstring" => "Markiert eine bestimmte Aufgabe im Klassenbuch als entfernt, löscht sie also nicht endgültig aus" .
|
|---|
| 1058 | "der Datenbank."
|
|---|
| 1059 | ),
|
|---|
| 1060 |
|
|---|
| 1061 | "createtask" => Array(
|
|---|
| 1062 | "function" => "createtask",
|
|---|
| 1063 | "signature" => Array(Array("int", "int", "int", "string"), Array("int", "int", "int", "string", "boolean")),
|
|---|
| 1064 | "docstring" => "Trägt eine Aufgabe in die Datenbank ein und gibt die ID der Aufgabe zurück."
|
|---|
| 1065 | ),
|
|---|
| 1066 |
|
|---|
| 1067 | "edittask" => Array(
|
|---|
| 1068 | "function" => "edittask",
|
|---|
| 1069 | "signature" => Array(Array("boolean", "int", "int", "string"), Array("boolean", "int", "int", "string", "boolean")),
|
|---|
| 1070 | "docstring" => "Bearbeitet eine bestehende Aufgabe. Dabei kann nur das Datum, der Aufgabetext und die " .
|
|---|
| 1071 | "Wichtigkeit verändert werden."
|
|---|
| 1072 | ),
|
|---|
| 1073 |
|
|---|
| 1074 | "getsubjects" => Array(
|
|---|
| 1075 | "function" => "getsubjects",
|
|---|
| 1076 | "signature" => Array(Array("array")),
|
|---|
| 1077 | "docstring" => "Gibt eine Liste der Schulfächer zurück, die beim Eintragen von Aufgaben verwendet werden können."
|
|---|
| 1078 | ),
|
|---|
| 1079 |
|
|---|
| 1080 | "getcomments" => Array(
|
|---|
| 1081 | "function" => "getcomments",
|
|---|
| 1082 | "signature" => Array(Array("array", "int")),
|
|---|
| 1083 | "docstring" => "Gibt die Kommentare zu einer bestimmten Aufgabe an und markiert die Kommentare als gelesen, wenn" .
|
|---|
| 1084 | "der Benutzer angemeldet ist."
|
|---|
| 1085 | ),
|
|---|
| 1086 |
|
|---|
| 1087 | "createcomment" => Array(
|
|---|
| 1088 | "function" => "createcomment",
|
|---|
| 1089 | "signature" => Array(Array("int", "int", "string")),
|
|---|
| 1090 | "docstring" => "Erstellt einen neuen Kommentar zu einer bestimmten Aufgabe und gibt die ID des Kommentars zurück."
|
|---|
| 1091 | ),
|
|---|
| 1092 |
|
|---|
| 1093 | "editcomment" => Array(
|
|---|
| 1094 | "function" => "editcomment",
|
|---|
| 1095 | "signature" => Array(Array("boolean", "int", "string")),
|
|---|
| 1096 | "docstring" => "Bearbeitet einen bestimmten Kommentar."
|
|---|
| 1097 | ),
|
|---|
| 1098 |
|
|---|
| 1099 | "getcontacts" => Array(
|
|---|
| 1100 | "function" => "getcontacts",
|
|---|
| 1101 | "signature" => Array(Array("array")),
|
|---|
| 1102 | "docstring" => "Gibt eine Liste aller Kontakte aus. Wenn der Benutzer nicht angemeldet ist, werden die Felder " .
|
|---|
| 1103 | "mit persönlichen Informationen nicht übertragen."
|
|---|
| 1104 | ),
|
|---|
| 1105 |
|
|---|
| 1106 | "getfiles" => Array(
|
|---|
| 1107 | "function" => "getfiles",
|
|---|
| 1108 | "signature" => Array(Array("array")),
|
|---|
| 1109 | "docstring" => "Gibt eine Liste der Dateien in der Dateiablage aus."
|
|---|
| 1110 | ),
|
|---|
| 1111 |
|
|---|
| 1112 | "archivefile" => Array(
|
|---|
| 1113 | "function" => "archivefile",
|
|---|
| 1114 | "signature" => Array(Array("boolean", "int")),
|
|---|
| 1115 | "docstring" => "Markiert eine bestimmte Datei in der Dateiablage als archiviert."
|
|---|
| 1116 | ),
|
|---|
| 1117 |
|
|---|
| 1118 | "uploadfile" => Array(
|
|---|
| 1119 | "function" => "uploadfile",
|
|---|
| 1120 | "signature" => Array(Array("array", "string")),
|
|---|
| 1121 | "docstring" => "Lädt eine beliebige Datei in die Dateiablage hoch und gibt die ID und der endgültige Name der " .
|
|---|
| 1122 | "Datei zurück."
|
|---|
| 1123 | ),
|
|---|
| 1124 |
|
|---|
| 1125 | "signin" => Array(
|
|---|
| 1126 | "function" => "signin",
|
|---|
| 1127 | "signature" => Array(Array("array", "string", "string")),
|
|---|
| 1128 | "docstring" => "Erkennt einen Benutzer anhand eines eingegebenen Passworts und meldet ihn beim Klassenbuch an. " .
|
|---|
| 1129 | "Zusätzlich werden Informationen über den Benutzer zurückgegeben."
|
|---|
| 1130 | ),
|
|---|
| 1131 |
|
|---|
| 1132 | "requestpassword" => Array(
|
|---|
| 1133 | "function" => "requestpassword",
|
|---|
| 1134 | "signature" => Array(Array("boolean", "string", "string")),
|
|---|
| 1135 | "docstring" => "Wenn der Benutzer sein Passwort vergessen hat, kann er mit dieser Funktion sein Bestehendes " .
|
|---|
| 1136 | "ändern. Er gibt seinen Benutzernamen und ein neues Passwort nach Wahl ein und erhält dann eine " .
|
|---|
| 1137 | "E-Mail mit einem Bestätigungslink."
|
|---|
| 1138 | ),
|
|---|
| 1139 |
|
|---|
| 1140 | "verifynewpassword" => Array(
|
|---|
| 1141 | "function" => "verifynewpassword",
|
|---|
| 1142 | "signature" => Array(Array("boolean", "string")),
|
|---|
| 1143 | "docstring" => "Bestätigt ein neu angefordertes Passwort mit Hilfe des Bestätigungs-Schlüssels."
|
|---|
| 1144 | ),
|
|---|
| 1145 |
|
|---|
| 1146 | "changepassword" => Array(
|
|---|
| 1147 | "function" => "changepassword",
|
|---|
| 1148 | "signature" => Array(Array("boolean", "string", "string")),
|
|---|
| 1149 | "docstring" => "Ändert das Passwort des aktuell angemeldeten Benutzers. Aus Sicherheitsgründen muss das alte " .
|
|---|
| 1150 | "Passwort ebenfalls angegeben werden."
|
|---|
| 1151 | ),
|
|---|
| 1152 |
|
|---|
| 1153 | "getuserdata" => Array(
|
|---|
| 1154 | "function" => "getuserdata",
|
|---|
| 1155 | "signature" => Array(Array("array")),
|
|---|
| 1156 | "docstring" => "Wenn der Benutzer angemeldet ist, können mit dieser Methode benutzerspezifische Informationen " .
|
|---|
| 1157 | "und zusätzlich auch die aktuell gültige Session-ID abgerufen werden."
|
|---|
| 1158 | ),
|
|---|
| 1159 |
|
|---|
| 1160 | "updateuserprofile" => Array(
|
|---|
| 1161 | "function" => "updateuserprofile",
|
|---|
| 1162 | "signature" => Array(Array("boolean", "array")),
|
|---|
| 1163 | "docstring" => "Verändert das Profil des angemeldeten Benutzers."
|
|---|
| 1164 | ),
|
|---|
| 1165 |
|
|---|
| 1166 | "changeusersettings" => Array(
|
|---|
| 1167 | "function" => "changeusersettings",
|
|---|
| 1168 | "signature" => Array(Array("boolean", "array")),
|
|---|
| 1169 | "docstring" => "Verändert die Einstellungen des angemeldeten Benutzers. Wenn eine bestimmte Einstellung bereits " .
|
|---|
| 1170 | "vorhanden ist, wird sie durch die neue überschrieben und falls eine Einstellung noch nicht " .
|
|---|
| 1171 | "vorhanden ist, wird diese hinzugefügt."
|
|---|
| 1172 | ),
|
|---|
| 1173 |
|
|---|
| 1174 | "signout" => Array(
|
|---|
| 1175 | "function" => "signout",
|
|---|
| 1176 | "signature" => Array(Array("boolean")),
|
|---|
| 1177 | "docstring" => "Meldet einen Benutzer vom Klassenbuch ab, indem es die Session und alles was dazu gehört löscht."
|
|---|
| 1178 | ),
|
|---|
| 1179 |
|
|---|
| 1180 | "setuserstate" => Array(
|
|---|
| 1181 | "function" => "setuserstate",
|
|---|
| 1182 | "signature" => Array(Array("boolean", "int")),
|
|---|
| 1183 | "docstring" => "Aktualisiert den Status des angemeldeten Benutzers. Der Status '1' bedeutet, dass der Benutzer " .
|
|---|
| 1184 | "abwesend ist, während '2' darauf schliessen lässt, dass der Benutzer online ist und gerade im " .
|
|---|
| 1185 | "Klassenbuch aktiv ist."
|
|---|
| 1186 | ),
|
|---|
| 1187 |
|
|---|
| 1188 | "registeruser" => Array(
|
|---|
| 1189 | "function" => "registeruser",
|
|---|
| 1190 | "signature" => Array(Array("boolean", "string", "string", "string", "string", "string")),
|
|---|
| 1191 | "docstring" => "Ermöglicht es einem Benutzer, ein neues Konto beim Klassenbuch zu erstellen. Dazu muss er " .
|
|---|
| 1192 | "lediglich einen Nicknamen, Vor- und Nachnamen, eine gültige E-Mail-Adresse und ein Passwort " .
|
|---|
| 1193 | "angegeben. Die restlichen Profildaten kann er dann selber eintragen. Der Verwalter des " .
|
|---|
| 1194 | "Klassenbuchs erhält daraufhin eine E-Mail mit diesen Informationen, welche er dann noch in die " .
|
|---|
| 1195 | "Datenbank eintragen muss"
|
|---|
| 1196 | ),
|
|---|
| 1197 |
|
|---|
| 1198 | "gallery_getalbums" => Array(
|
|---|
| 1199 | "function" => "gallery_getalbums",
|
|---|
| 1200 | "signature" => Array(Array("array")),
|
|---|
| 1201 | "docstring" => "Gibt eine Liste aller Alben in der Fotogalerie aus. Die Ausgabe enthält auch Informationen " .
|
|---|
| 1202 | "über die Anzahl Fotos in diesem Album."
|
|---|
| 1203 | ),
|
|---|
| 1204 |
|
|---|
| 1205 | "gallery_createalbum" => Array(
|
|---|
| 1206 | "function" => "gallery_createalbum",
|
|---|
| 1207 | "signature" => Array(Array("int", "string"), Array("int", "string", "string")),
|
|---|
| 1208 | "docstring" => "Erstellt ein neues Album in der Fotogalerie. Ein Name muss zwingend angegeben werden, während " .
|
|---|
| 1209 | "eine kurze Beschreibung optional ist."
|
|---|
| 1210 | ),
|
|---|
| 1211 |
|
|---|
| 1212 | "gallery_removealbum" => Array(
|
|---|
| 1213 | "function" => "gallery_removealbum",
|
|---|
| 1214 | "signature" => Array(Array("boolean", "int")),
|
|---|
| 1215 | "docstring" => "Löscht ein Album komplett aus der Fotogalerie. Bei diesem Vorgang werden auch alle im Album " .
|
|---|
| 1216 | "enthaltenen Fotos gelöscht."
|
|---|
| 1217 | ),
|
|---|
| 1218 |
|
|---|
| 1219 | "gallery_downloadalbum" => Array(
|
|---|
| 1220 | "function" => "gallery_downloadalbum",
|
|---|
| 1221 | "signature" => Array(Array("string", "int")),
|
|---|
| 1222 | "docstring" => "Erstellt aus allen Originalfotos in einem einzelnen Album ein mit Datum versehenes ZIP-Archiv " .
|
|---|
| 1223 | "im 'files'-Verzeichnis. Die Funktion gibt im Erfolgsfall den Namen der Datei zurück."
|
|---|
| 1224 | ),
|
|---|
| 1225 |
|
|---|
| 1226 | "gallery_getpictures" => Array(
|
|---|
| 1227 | "function" => "gallery_getpictures",
|
|---|
| 1228 | "signature" => Array(Array("array", "int")),
|
|---|
| 1229 | "docstring" => "Gibt eine Liste aller Fotos in einem bestimmten Album aus."
|
|---|
| 1230 | ),
|
|---|
| 1231 |
|
|---|
| 1232 | "gallery_uploadpicture" => Array(
|
|---|
| 1233 | "function" => "gallery_uploadpicture",
|
|---|
| 1234 | "signature" => Array(Array("int", "int")),
|
|---|
| 1235 | "docstring" => "Lädt ein Bild zum Server hoch und legt es in einem bestimmten Album ab."),
|
|---|
| 1236 |
|
|---|
| 1237 |
|
|---|
| 1238 | "gallery_rotatepicture" => Array(
|
|---|
| 1239 | "function" => "gallery_rotatepicture",
|
|---|
| 1240 | "signature" => Array(Array("boolean", "int", "int")),
|
|---|
| 1241 | "docstring" => "Ermöglicht es, ein Foto in der Fotogalerie um einen bestimmten Winkel zu drehen. Erlaubt sind " .
|
|---|
| 1242 | "nur Vielfache von 90°. Diese Aktion kann nur vom Administrator, oder von demjenigen Benutzer, " .
|
|---|
| 1243 | "der das Foto hochgeladen hat, durchgeführt werden."),
|
|---|
| 1244 |
|
|---|
| 1245 | "shoutbox_poll" => Array(
|
|---|
| 1246 | "function" => "shoutbox_poll",
|
|---|
| 1247 | "signature" => Array(Array("array"), Array("array", "int")),
|
|---|
| 1248 | "docstring" => "Gibt die aktuellen Nachrichten in der Shoutbox zurück. Standardmässig werden die letzten 100 " .
|
|---|
| 1249 | "Nachrichten übertragen, es ist jedoch auch möglich, alle Nachrichten zu erhalten, die neuer " .
|
|---|
| 1250 | "sind als eine bestimmte Nachricht."),
|
|---|
| 1251 |
|
|---|
| 1252 | "shoutbox_say" => Array(
|
|---|
| 1253 | "function" => "shoutbox_say",
|
|---|
| 1254 | "signature" => Array(Array("array", "string"), Array("array", "string", "int")),
|
|---|
| 1255 | "docstring" => "Trägt eine neue Nachricht in die Shoutbox ein. Falls zusätzlich ein Wert für den zweiten " .
|
|---|
| 1256 | "Parameter angegeben wird, gibt die Methode zusätzlich eine Auflistung der neuen Nachrichten " .
|
|---|
| 1257 | "zurück.")
|
|---|
| 1258 | );
|
|---|
| 1259 |
|
|---|
| 1260 | $service = new JSONRPCService($dispatchMap, false);
|
|---|
| 1261 | $service->response_charset_encoding = "UTF-8";
|
|---|
| 1262 |
|
|---|
| 1263 | if ($_POST["jsonrpc"]) {
|
|---|
| 1264 | $service->service(strip_tags(stripcslashes($_POST["jsonrpc"])), true);
|
|---|
| 1265 | } elseif (!(defined("INTERNAL_REQUEST") && INTERNAL_REQUEST)) {
|
|---|
| 1266 | $service->service(null, true);
|
|---|
| 1267 | }
|
|---|
| 1268 |
|
|---|
| 1269 | function doInternalRequest($method = "", $params = Array()) {
|
|---|
| 1270 | global $service;
|
|---|
| 1271 |
|
|---|
| 1272 | $json = new Services_JSON();
|
|---|
| 1273 | return $service->service($json->encode(Array(
|
|---|
| 1274 | "method" => $method,
|
|---|
| 1275 | "params" => $params
|
|---|
| 1276 | )), false);
|
|---|
| 1277 | }
|
|---|
| 1278 |
|
|---|
| 1279 | ?> |
|---|