public static function ToString($err) { if (is_a($err, 'Error')) { return Error::ToString($err->id) . ': ' . $err->mesg; } switch ($err) { case self::no_translation: return Language::Word('no translation'); case self::db_error: return Language::Word('internal database error'); case self::arg_not_valid: return Language::Word('argument not valid'); case self::ambiguously: return Language::Word('ambigiously'); case self::not_found: return Language::Word('not found'); case self::error: return Language::Word('error'); } }
clear_tmp_images_dir(Report::$type, $id); clear_tmp_files_dir(Report::$type, $id); $head_addition .= '<script type="text/javascript" src="js/files_upload.js"></script>'; $ob_id = $_POST['id']; $ob = Report::FetchBy(['eq_conds' => ['id' => $ob_id], 'is_unique' => true]); $receivers = User::FetchBy(['select_list' => 'id, name, surname', 'where_addition' => '(received_reports LIKE ("%\\"' . $ob_id . '\\"%"))']); $users = ''; foreach ($receivers as $key => $user) { $users .= '<div class="row">'; $users .= '<div class="' . ColAllTypes(12) . '">'; $users .= $user->LinkToThis(); $users .= '</div>'; $users .= '</div>'; } if (Error::IsError($ob)) { $content = AlertMessage('alert-danger', 'Error occured during fetching: ' . Error::ToString($ob)); } else { $path_to_file = $ob->GetPathToFile(); $author_id = GetUserID(); $head_addition .= MakeScript('files_type = "' . Report::$type . '"; files_action = "edit"; owner_id = ' . $ob->GetID() . '; max_files = 1; author_id = ' . $author_id . ';'); $content .= '<form method="post" action="' . $link_to_utility_sql_worker . '" enctype="multipart/form-data">'; $content .= PairLabelAndPanel(4, 5, Language::Word('current receivers'), $users); $content .= '<div class="row">'; $content .= '<div class="' . ColAllTypes(4) . ' vcenter" align="right">'; $content .= '<b>' . Language::Word('change receivers') . '</b>'; $content .= '</div>'; $content .= '<div class="' . ColAllTypes(5) . ' vcenter" align="center">'; $content .= '<div class="dropdown">'; $content .= '<input onkeyup="showUsers(this);" placeholder="' . Language::Word('start to insert name') . '" class="form-control margin-sm dropdown-toggle" type="text" id="recipient_input" name="recipient_input" aria-haspopup="true" value="">'; $content .= '<ul class="dropdown-menu" id="users_list">'; $content .= '</ul>';
public static function InsertToDB($request) { global $db_connection; global $link_to_report_images; global $link_to_report_files; $author_id = $db_connection->real_escape_string($request->author_id); $name = $db_connection->real_escape_string($request->name); $res = $db_connection->query("INSERT INTO `" . self::$table . "` (`author_id`, `name`) VALUES ('" . $author_id . "', '" . $name . "')"); if (!$res) { echo $db_connection->error; return false; } $id = $db_connection->insert_id; $request->text_block = preg_replace('/tmp_(\\d+)\\//', $id . '/', $request->text_block); $text_block = $db_connection->real_escape_string($request->text_block); $res = $db_connection->query("UPDATE `" . self::$table . "` SET `text_block`=\"" . $text_block . "\" WHERE `id`=" . $id); if (!$res) { echo $db_connection->error; $db_connection->query("DELETE FROM `" . self::$table . "` WHERE `id` = " . $id); return false; } $request->id = $id; $upload_path = ''; recurse_copy($link_to_report_images . 'tmp_' . GetUserID(), $link_to_report_images . $id); recurse_copy($link_to_report_files . 'tmp_' . GetUserID(), $link_to_report_files . $id); $receiver_emails = []; foreach ($request->recipient_ids as $key => $aim) { $received = User::FetchBy(['select_list' => 'received_reports, email', 'is_unique' => true, 'eq_conds' => ['id' => $aim]]); if (Error::IsError($received)) { echo Error::ToString($received); return false; } $tmp = $received->GetReceivedReports(); array_push($tmp, $id . ''); $rc = $db_connection->query("UPDATE users SET received_reports = '" . $db_connection->real_escape_string(json_encode($tmp)) . "' WHERE id = " . $aim); if (!$rc) { echo $db_connection->error; return false; } array_push($receiver_emails, $received->GetEmail()); } $sended = User::FetchBy(['select_list' => 'sended_reports', 'is_unique' => true, 'eq_conds' => ['id' => $request->GetAuthorID()]]); if (Error::IsError($sended)) { echo Error::ToString($sended); return false; } $tmp = $sended->GetSendedReports(); array_push($tmp, $id . ''); $rc = $db_connection->query("UPDATE users SET sended_reports = '" . $db_connection->real_escape_string(json_encode($tmp)) . "' WHERE id = " . $request->GetAuthorID()); if (!$rc) { echo $db_connection->error; return false; } $receiver_emails = array_unique($receiver_emails); foreach ($receiver_emails as $key => $email) { $subject = 'New report on lgmis.cs.msu.ru'; $message = '<html>'; $message .= '<head><title>New report from on your name</title></head>'; $message .= '<body>'; $message .= '<table width="100%" align="center">'; $message .= '<tr><td>You can see more information about this report: <a href="' . $request->ToHTMLFullVersLite() . '">go on site</a></td></tr>'; $message .= '</table>'; $message .= '</body>'; $message .= '</html>'; $headers = 'From: LGMIS Admin <*****@*****.**>' . PHP_EOL . 'Reply-To: <*****@*****.**>' . PHP_EOL . 'X-Mailer: PHP/' . phpversion() . 'MIME-Version: 1.0' . PHP_EOL . 'Content-type: text/html; charset=UTF-8' . PHP_EOL; if (!mail($email, $subject, $message, $headers, '-f no-reply@lgmis.cs.msu.ru')) { echo 'error:' . error_get_last(); return false; } } return true; }
$content .= 'allowedContent: true, });'; $content .= 'CKEDITOR.config.height = 400;'; $content .= '</script>'; $content .= '<div class="row">'; $content .= '<input type="submit" class="btn btn-primary btn-lg" name="add" value="' . Language::Word('save') . '">'; $content .= '</div>'; $content .= '</form>'; $title = Language::Word('language adding'); $header = $title; } } else { if (!isset($_REQUEST['id'])) { echo 'user id is unset'; exit; } $ob_id = $_REQUEST['id']; $ob = Article::FetchBy(['eq_conds' => array('id' => $ob_id), 'is_unique' => true]); if (Error::IsError($ob)) { $content = AlertMessage('alert-danger', Error::ToString($ob)); } else { $title = ''; $header = ''; $content = ''; $title = Language::Word('article'); $header = htmlspecialchars($ob->GetName()); $content = $ob->ToHTMLAutoFull(GetUserPrivileges()); } } } } include_once $link_to_admin_template;
$content .= AlertMessage('alert-warning', Language::Word('cover was not uploaded')); } } break; case Report::$type: $ob = Report::FetchBy(['eq_conds' => ['id' => $_POST['id']], 'is_unique' => true]); if (Error::IsError($ob)) { $content .= AlertMessage('alert-danger', 'Error while receiving user: '******'recipient_ids'] = urldecode($assoc['recipient_ids']); $ob->FetchFromAssocEditing($assoc); $tmp = $ob->Save(); if (Error::IsError($tmp)) { $content .= AlertMessage('alert-danger', Language::Word('it was not succeeded to save') . ':error: ' . Error::ToString($tmp)); } else { $content .= AlertMessage('alert-success', Language::Word('changes are saved')); } break; case Direction::$type: $direction = Direction::FetchByID($_POST['id']); if ($direction === NULL) { break; } $direction->FetchFromAssocEditing($_POST); if ($direction->Save() === false) { $content .= AlertMessage('alert-danger', Language::Word('it was not succeeded to save')); } else { $content .= AlertMessage('alert-success', Language::Word('changes are saved')); if ($direction->FetchCoverFromAssocEditing($_FILES) < 0) {
public static function GetIDByLogin($login) { $user = self::FetchBy(['select_list' => 'id', 'eq_conds' => ['login' => $login], 'is_unique' => true]); if (Error::IsError($user)) { echo Error::ToString($user); return NULL; } return $user->id; }
<?php require_once 'utility_lgmis_lib.php'; require_once $link_to_utility_authorization; if (isset($_POST['id']) && isset($_GET['id']) && $_POST['id'] !== $_GET['id']) { $content = AlertMessage('alert-danger', 'Неоднозначные id'); } else { $user = User::FetchBy(['eq_conds' => ['id' => $_REQUEST['id']], 'is_unique' => true]); if (Error::IsError($user)) { echo Error::ToString($user); exit; } $prev_page = ''; if (isset($_REQUEST['edit'])) { $title = Language::Word('profile edit'); $header = $title; $content = $user->ToHTMLEditing(); } else { $title = $user->GetName(); $header = htmlspecialchars(Language::Translit($user->GetName() . ' ' . $user->GetSurname() . ' ' . $user->GetFathername())); $content = $user->ToHTMLAutoFull(GetUserPrivileges()); $no_content_center = true; } } require_once $link_to_admin_template;
$is_error = true; $content = json_encode(['error' => 'File with name ' . $name . ' already exists']); break; } } if ($is_error) { break; } $new_dir_it->next(); } if ($is_error) { break; } for ($i = 0; $i < $size; ++$i) { if ($rc = Error::IsError(MyFile::InsertToDB($myfiles[$i]))) { $content = json_encode(['error' => Error::ToString($rc)]); $is_error = true; break; } } if ($is_error) { break; } simple_copy($dir, $new_dir); clear_tmp_files_dir(MyFile::$type, 0); $content = json_encode(['ok' => true]); break; default: break; } }