public function changeKarma() { if ($this->isError()) { return false; } $this->setPrerequisites('karma'); $this->checkPrerequisites(); if ($this->isError()) { return false; } $user = new User($this->getData()); if (!$user->isModerator()) { $this->setUpError("NO RIGHTS"); return false; } $karma = $this->karma + $this->get('karma'); $db = new DB(); $query = 'UPDATE mototimes_events SET karma=? WHERE id=?'; $stmt = $db->prepare($query); $stmt->bind_param('ii', $karma, $this->id); $stmt->execute(); if ($stmt->errno) { $this->setUpError(); } else { $result = array('response' => 'ok'); $this->setResult($result); } return true; }
private function addPoint() { $user = new User($this->getData()); if ($this->get("group_id") == self::$CLOSED_GROUP) { $timeout = self::$CLOSED_GROUP_TIMEOUT; } else { $timeout = self::$OPEN_GROUP_TIMEOUT; } if ($user->isReadOnly()) { $this->noRightsError(); } else { if (time() - $user->getLastCreate()->getTimeStamp() < $timeout && !$user->isModerator()) { $this->timeOutError(round((time() - $user->getLastCreate()->getTimeStamp()) / 60)); } else { $userId = $this->get('userid'); $db = new DB(); $query = 'INSERT INTO mototimes_events (userid, lat, lng, alignment, transport, text) VALUES(?,?,?,?,?,?)'; $stmt = $db->prepare($query); $stmt->bind_param('iddiis', $userId, $this->get('lat'), $this->get('lng'), $this->get('alignment'), $this->get('transport'), $this->get('text')); $stmt->execute(); if ($stmt->errno != 0) { $this->unknownError(); } else { $query = 'UPDATE mototimes_users SET last_create = NOW() WHERE id_vk=?'; $stmt = $db->prepare($query); $stmt->bind_param('i', $userId); $stmt->execute(); $result = array('response' => 'ok'); $this->setResult($result); } } } }
public function erase(User $user) { if ($user->isModerator() || $user->isAdmin()) { ModoAction::create(array('id' => ModoAction::generateId(6), 'user_id' => $user->id, 'type' => 'delete_comment', 'target' => $this->id, 'timestamp' => Utils::tps())); } ChannelAction::table()->delete(array("type" => "comment", "complementary_id" => $this->id)); $this->delete(); }
public static function getUsers($page) { if (!User::isModerator() and !User::isAdmin()) { throw new Exception("Invalid Access!"); } $limit = 30; $offset = ($page - 1) * $limit; $users = Db::query("SELECT * FROM zz_users ORDER BY id LIMIT {$offset}, {$limit}", array(), 0); return $users; }
* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ $message = ""; if (!User::isLoggedIn()) { $app->render("login.html"); die; } $info = User::getUserInfo(); if (!User::isModerator()) { $app->redirect("/"); } if ($_POST) { $status = Util::getPost("status"); $reply = Util::getPost("reply"); $report = Util::getPost("report"); $delete = Util::getPost("delete"); $deleteapi = Util::getPost("deleteapi"); $manualpull = Util::getPost("manualpull"); if (isset($status)) { Db::execute("UPDATE zz_tickets SET status = :status WHERE id = :id", array(":status" => $status, ":id" => $id)); if ($status == 0) { $app->redirect(".."); } }
public function ExportFlightsAndFolders($flightIds, $folderDest) { $Fd = new Folder(); $uId = $this->_user->userInfo['id']; $role = $this->_user->userInfo['role']; $allFolders = []; if (User::isModerator($role)) { $uId = $this->_user->GetUserIdsByAuthor($this->_user->username); } foreach ($folderDest as $dest) { $allFolders = $Fd->SubfoldersDeepScan($dest, $uId, $adminRole); } foreach ($allFolders as $folderId) { $flightIds = array_merge($flightIds, $Fd->GetFlightsByFolder($folderId, $uId, $adminRole)); } unset($Fd); $exportedFiles = array(); $exportedFileName = ''; error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE); $Fl = new Flight(); $C = new DataBaseConnector(); $Bru = new Bru(); foreach ($flightIds as $flightId) { $flightInfo = $Fl->GetFlightInfo($flightId); $fileGuid = uniqid(); $exportedFileDir = UPLOADED_FILES_PATH; $exportedFileName = $flightInfo['bort'] . "_" . date("Y-m-d", $flightInfo['startCopyTime']) . "_" . $flightInfo['voyage'] . "_" . $fileGuid; $exportedFileRoot = $exportedFileDir . $exportedFileName; $headerFile['dir'] = $exportedFileDir; $headerFile['filename'] = "header_" . $flightInfo['bort'] . "_" . $flightInfo['voyage'] . $fileGuid . ".json"; $headerFile['root'] = $headerFile['dir'] . $headerFile['filename']; $exportedFiles[] = $headerFile; $apPrefixes = $Bru->GetBruApCycloPrefixes($flightInfo["bruType"]); for ($i = 0; $i < count($apPrefixes); $i++) { $exportedTable = $C->ExportTable($flightInfo["apTableName"] . "_" . $apPrefixes[$i], $flightInfo["apTableName"] . "_" . $apPrefixes[$i] . "_" . $fileGuid, $exportedFileDir); $exportedFiles[] = $exportedTable; $flightInfo["apTables"][] = array("pref" => $apPrefixes[$i], "file" => $exportedTable["filename"]); } $bpPrefixes = $Bru->GetBruBpCycloPrefixes($flightInfo["bruType"]); for ($i = 0; $i < count($bpPrefixes); $i++) { $exportedTable = $C->ExportTable($flightInfo["bpTableName"] . "_" . $apPrefixes[$i], $flightInfo["bpTableName"] . "_" . $bpPrefixes[$i] . "_" . $fileGuid, $exportedFileDir); $exportedFiles[] = $exportedTable; $flightInfo["bpTables"][] = array("pref" => $bpPrefixes[$i], "file" => $exportedTable["filename"]); } if ($flightInfo["exTableName"] != "") { $exportedTable = $C->ExportTable($flightInfo["exTableName"], $flightInfo["exTableName"] . "_" . $fileGuid, $exportedFileDir); $exportedFiles[] = $exportedTable; $flightInfo["exTables"] = $exportedTable["filename"]; } $exportedFileDesc = fopen($headerFile['root'], "w"); fwrite($exportedFileDesc, json_encode($flightInfo)); fclose($exportedFileDesc); } unset($Fl); unset($C); unset($Bru); $zip = new ZipArchive(); if ($zip->open($exportedFileRoot . '.zip', ZipArchive::CREATE) === TRUE) { for ($i = 0; $i < count($exportedFiles); $i++) { $zip->addFile($exportedFiles[$i]['root'], $exportedFiles[$i]['filename']); } $zip->close(); } else { error_log('Failed zipping flight. Page asyncFileProcessor.php"'); } for ($i = 0; $i < count($exportedFiles); $i++) { if (file_exists($exportedFiles[$i]['root'])) { unlink($exportedFiles[$i]['root']); } } $zipURL = 'http'; if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") { $zipURL .= "s"; } $zipURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $zipURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"]; } else { $zipURL .= $_SERVER["SERVER_NAME"]; } $zipURL .= UPLOADED_FILES_DIR . $exportedFileName . '.zip'; error_reporting(E_ALL); if ($exportedFileName == '') { return false; } return $zipURL; }