first commit
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir . '/../config.php';
|
||||
|
||||
$accessToken = filterAccessToken($_POST['access_token']);
|
||||
|
||||
$res = array();
|
||||
try {
|
||||
$headers = array('Accept: application/json', 'Authorization: Bearer ' . $accessToken);
|
||||
$data = getRemoteData($apiDomainAuth . 'api/profile_applicant/check_access_token', null, true, false, $headers);
|
||||
if ($data->success) {
|
||||
$res = $data->info;
|
||||
} else {
|
||||
throw new Exception('Не удалось соединиться с удаленным сервером.', 522);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
setResponseCode($e->getCode());
|
||||
$res['error'] = 'Ошибка при проверке токена. ' . $e->getMessage();
|
||||
}
|
||||
loadHeaders();
|
||||
echo json_encode($res);
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir . '/../config.php';
|
||||
|
||||
$response = array(
|
||||
'client_id' => $clientId,
|
||||
'vuz_id' => $vuzId,
|
||||
'api_domain_auth' => $apiDomainAuth,
|
||||
'api_domain_vikon' => $apiDomen,
|
||||
'api_domain_filemanager' => $filemanagerApiDomen,
|
||||
'vuz_name' => $vuzName,
|
||||
);
|
||||
loadHeaders();
|
||||
echo json_encode($response);
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir . '/../config.php';
|
||||
loadHeaders();
|
||||
echo '[]';
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir . '/../config.php';
|
||||
|
||||
$login = filterLogin($_POST['login']);
|
||||
$password = filterPassword($_POST['password']);
|
||||
$code = filterInt($_POST['code']);
|
||||
|
||||
$res = array();
|
||||
try {
|
||||
$postFields = array(
|
||||
'grant_type' => 'password',
|
||||
'client_id' => $clientId,
|
||||
'client_secret' => $clientSecret,
|
||||
'username' => $login,
|
||||
'password' => $password,
|
||||
'code' => $code,
|
||||
'scope' => '',
|
||||
);
|
||||
$data = getRemoteData($apiDomainAuth . 'oauth/token', null, true, $postFields);
|
||||
if ($data->success) {
|
||||
setResponseCode($data->code);
|
||||
$res = $data->info;
|
||||
} else {
|
||||
throw new Exception('Не удалось соединиться с удаленным сервером.', 522);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
setResponseCode($e->getCode());
|
||||
$res['error'] = 'Ошибка при получении токена. ' . $e->getMessage();
|
||||
}
|
||||
loadHeaders();
|
||||
echo json_encode($res);
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir . '/../config.php';
|
||||
|
||||
$refreshToken = filterAccessToken($_POST['refresh_token']);
|
||||
|
||||
$res = array();
|
||||
try {
|
||||
$postFields = array(
|
||||
'grant_type' => 'refresh_token',
|
||||
'refresh_token' => $refreshToken,
|
||||
'client_id' => $clientId,
|
||||
'client_secret' => $clientSecret,
|
||||
'scope' => '',
|
||||
);
|
||||
$data = getRemoteData($apiDomainAuth . 'oauth/token', null, true, $postFields);
|
||||
if ($data->success) {
|
||||
$res = $data->info;
|
||||
} else {
|
||||
throw new Exception('Не удалось соединиться с удаленным сервером.', 522);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
setResponseCode($e->getCode());
|
||||
$res['error'] = 'Ошибка при обновлении токена. ' . $e->getMessage();
|
||||
}
|
||||
loadHeaders();
|
||||
echo json_encode($res);
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
$letters = 'ABCDEFGKIJKLMNPQRSTUVWXYZ23456789';
|
||||
$caplen = 4;
|
||||
$width = 120; $height = 20;
|
||||
$font = 'fonts/comic.ttf';
|
||||
$fontsize = 14;
|
||||
|
||||
header('Content-type: image/png');
|
||||
|
||||
$im = imagecreatetruecolor($width, $height);
|
||||
imagesavealpha($im, true);
|
||||
$bg = imagecolorallocatealpha($im, 0, 0, 0, 127);
|
||||
imagefill($im, 0, 0, $bg);
|
||||
|
||||
$captcha = '';
|
||||
|
||||
for ($i = 0; $i < $caplen; $i++) {
|
||||
$captcha .= $letters[ rand(0, strlen($letters)-1) ];
|
||||
$x = ($width - 20) / $caplen * $i + 10;
|
||||
$x = rand($x, $x+4);
|
||||
$y = $height - ( ($height - $fontsize) / 2 );
|
||||
$curcolor = imagecolorallocate( $im, rand(0, 100), rand(0, 100), rand(0, 100) );
|
||||
$angle = rand(-25, 25);
|
||||
imagettftext($im, $fontsize, $angle, $x, $y, $curcolor, $font, $captcha[$i]);
|
||||
}
|
||||
|
||||
session_start();
|
||||
$_SESSION['captcha'] = $captcha;
|
||||
|
||||
imagepng($im);
|
||||
imagedestroy($im);
|
||||
Binary file not shown.
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
function isCurlExists()
|
||||
{
|
||||
if (in_array('curl', get_loaded_extensions())) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function checkCurl($url, $postFields = false)
|
||||
{
|
||||
$error = '';
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_ENCODING, "");
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
if (is_array($postFields)) {
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
$postVars = "";
|
||||
foreach ($postFields as $key => $value) {
|
||||
$postVars .= $key . '=' . $value . '&';
|
||||
}
|
||||
$postVars = rtrim($postVars, '&');
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postVars);
|
||||
}
|
||||
curl_exec($ch);
|
||||
if (curl_errno($ch) > 0 || curl_error($ch)) {
|
||||
$error = 'Curl error code: ' . curl_errno($ch) . '. Error: ' . curl_error($ch);
|
||||
}
|
||||
curl_close($ch);
|
||||
return $error;
|
||||
}
|
||||
|
||||
if (!isCurlExists()) {
|
||||
echo '<p class="alert alert-danger">
|
||||
На Вашем сервере отсутствует расширение PHP для работы с cURL.<br>
|
||||
Вам следует обратиться в службу технической поддержки Вашего хостинг-провайдера с просьбой
|
||||
включить PHP расширение curl.
|
||||
</p>';
|
||||
} else {
|
||||
if (($err = checkCurl($apiDomen)) || ($err = checkCurl($apiDomen, array('post' => 42)))) {
|
||||
echo '<p class="alert alert-danger">
|
||||
В процессе тестирования соединения с сервером обновлений, PHP расширение cURL вернуло
|
||||
следующую ошибку:<br> ' . $err .
|
||||
'</p>';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir .'/config.php';
|
||||
|
||||
$resultBody = array('success' => true, 'forward_code' => 200, 'message' => 'Временные файлы успешно удалены.');
|
||||
|
||||
$clearZip = clearZip();
|
||||
removeDirectory($selfDir . '/../update_tmp/');
|
||||
|
||||
if ($clearZip === false) {
|
||||
$resultBody = array('success' => true, 'forward_code' => 500, 'message' => 'При удалении временных файлов произошла ошибка.');
|
||||
}
|
||||
|
||||
loadHeaders();
|
||||
setResponseCode(200);
|
||||
echo json_encode($resultBody);
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir . '/config.php';
|
||||
|
||||
$res['success'] = false;
|
||||
|
||||
try {
|
||||
$headers = array(
|
||||
'Accept: application/json',
|
||||
'Authorization: Bearer ' . $token = filterAccessToken($_POST['access_token']),
|
||||
);
|
||||
|
||||
$response = remoteRequest($apiDomen . 'pull_updates/assist/updateEndedSuccessJson', true, array(), $headers);
|
||||
if (!$response->curlHasError) {
|
||||
if ($response->code == 200) {
|
||||
$resultBody = array(
|
||||
'success' => true,
|
||||
'forward_code' => 200,
|
||||
);
|
||||
} else {
|
||||
$resultBody = array(
|
||||
'success' => false,
|
||||
'forward_code' => $response->code,
|
||||
'message' => !empty($response->responseBody->message )
|
||||
? $response->responseBody->message
|
||||
: 'Неизвестная ошибка'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException( 'CURL ' . $response->curlErrorTxt);
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
$resultBody = array('success' => false, 'forward_code' => 500, 'message' => $ex->getMessage());
|
||||
}
|
||||
|
||||
loadHeaders();
|
||||
setResponseCode(200);
|
||||
echo json_encode($resultBody);
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
$selfDir = dirname(__FILE__);
|
||||
|
||||
ini_set('max_execution_time', '60');
|
||||
ini_set('default_socket_timeout', '60');
|
||||
|
||||
$domenName = 'ntspi.ru';
|
||||
$apiDomen = 'https://db-nica.ru/';
|
||||
$apiDomainAuth = 'https://auth.db-nica.ru/';
|
||||
$filemanagerApiDomen = 'https://file.db-nica.ru/';
|
||||
$clientId = '542';
|
||||
$clientSecret = '0mmk80mv8zpk7h5uhjvjsmsskvpkn9nmkywgy83vwg7tpzdw0y7rao0k9pvmn8xxwj5mgw8554nhtq6s';
|
||||
$vuzId = '16775';
|
||||
$parts = '{"common":"\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f","struct":"\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0438 \u043e\u0440\u0433\u0430\u043d\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0435\u0439","document":"\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b","education":"\u041e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435","eduStandarts":"\u041e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u044b \u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f","employees":"\u0420\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e. \u041f\u0435\u0434\u0430\u0433\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 (\u043d\u0430\u0443\u0447\u043d\u043e-\u043f\u0435\u0434\u0430\u0433\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439) \u0441\u043e\u0441\u0442\u0430\u0432","objects":"\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044c\u043d\u043e-\u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u0435 \u0438 \u043e\u0441\u043d\u0430\u0449\u0451\u043d\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430","grants":"\u0421\u0442\u0438\u043f\u0435\u043d\u0434\u0438\u0438 \u0438 \u043c\u0435\u0440\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445\u0441\u044f","paid_edu":"\u041f\u043b\u0430\u0442\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u043b\u0443\u0433\u0438","budget":"\u0424\u0438\u043d\u0430\u043d\u0441\u043e\u0432\u043e-\u0445\u043e\u0437\u044f\u0439\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c","vacant":"\u0412\u0430\u043a\u0430\u043d\u0442\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 \u0434\u043b\u044f \u043f\u0440\u0438\u0451\u043c\u0430 (\u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430) \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445\u0441\u044f","ovz":"\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u0430\u044f \u0441\u0440\u0435\u0434\u0430","inter":"\u041c\u0435\u0436\u0434\u0443\u043d\u0430\u0440\u043e\u0434\u043d\u043e\u0435 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u043e","catering":"\u041e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0438\u0442\u0430\u043d\u0438\u044f \u0432 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438","abitur":"\u0410\u0431\u0438\u0442\u0443\u0440\u0438\u0435\u043d\u0442\u0443"}';
|
||||
$removeAbiturFiles = 'bachelor;special;basic_higher;magistr;aspirant;ordinat;adunkt;assist;inter;specialized_higher;spo_kvalif;spo_sredn;prof_podg;perepod_raboch;povysh_kvalif_raboch;dop_obsheraz;dop_predpr;dop_predpr_iskustv;dop_predpr_sport;povysh_kvalif;prof_perepod;doshk;nachaln_obsh;osn_obsh;sredn_obsh;archive;index.html';
|
||||
$vuzName = 'Нижнетагильский государственный социально-педагогический институт (филиал) "Российского государственного профессионально-педагогического университета"';
|
||||
|
||||
define('DEBUG_MODE', isset($_GET['debug_mode']) && $_GET['debug_mode'] || isset($_POST['debug_mode']) && $_POST['debug_mode']);
|
||||
define('NO_DEL_FILE_PHP', isset($_GET['no_del_file_php']) && $_GET['no_del_file_php'] || isset($_POST['no_del_file_php']) && $_POST['no_del_file_php']);
|
||||
|
||||
if (DEBUG_MODE === true) {
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors','on');
|
||||
} else {
|
||||
error_reporting(0);
|
||||
}
|
||||
|
||||
require_once $selfDir. '/helper.php';
|
||||
@@ -0,0 +1 @@
|
||||
5.34.1.9
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir . '/config.php';
|
||||
|
||||
$optNameLengthMin = 2;
|
||||
$optNameLengthMax = 255;
|
||||
$optSubjectLengthMin = 2;
|
||||
$optSubjectLengthMax = 255;
|
||||
$optMessageLengthMin = 2;
|
||||
$optMessageLengthMax = 1000;
|
||||
|
||||
$res['success'] = true;
|
||||
$res['errorID'] = array();
|
||||
$res['messages'] = array();
|
||||
|
||||
$name = filter_var($_POST['name'], FILTER_SANITIZE_STRING);
|
||||
$email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
|
||||
$subject = filter_var($_POST['subject'], FILTER_SANITIZE_STRING);
|
||||
$message = filter_var($_POST['message'], FILTER_SANITIZE_STRING);
|
||||
$consent = filter_var($_POST['consent'], FILTER_SANITIZE_NUMBER_INT);
|
||||
|
||||
$lenName = mb_strlen($name);
|
||||
if ($lenName < $optNameLengthMin || $lenName >= $optNameLengthMax) {
|
||||
$res['success'] = false;
|
||||
$res['messages'][] = 'Имя должно содержать от ' .
|
||||
$optNameLengthMin . ' до ' .
|
||||
$optNameLengthMax . ' символов.';
|
||||
$res['errorID'][] = 'name';
|
||||
}
|
||||
if (!$email) {
|
||||
$res['success'] = false;
|
||||
$res['messages'][] = 'Введен некорректный email.';
|
||||
$res['errorID'][] = 'email';
|
||||
}
|
||||
$lenSubject = mb_strlen($subject);
|
||||
if ($lenSubject < $optSubjectLengthMin || $lenSubject >= $optSubjectLengthMax) {
|
||||
$res['success'] = false;
|
||||
$res['messages'][] = 'Тема сообщения должна содержать от ' .
|
||||
$optSubjectLengthMin . ' до ' .
|
||||
$optSubjectLengthMax . ' символов.';
|
||||
$res['errorID'][] = 'subject';
|
||||
}
|
||||
$lenMessage = mb_strlen($message);
|
||||
if ($lenMessage < $optMessageLengthMin || $lenMessage >= $optMessageLengthMax) {
|
||||
$res['success'] = false;
|
||||
$res['messages'][] = 'Сообщение должно содержать от ' .
|
||||
$optMessageLengthMin . ' до ' .
|
||||
$optMessageLengthMax . ' символов.';
|
||||
$res['errorID'][] = 'message';
|
||||
}
|
||||
if($consent != true){
|
||||
$res['success'] = false;
|
||||
$res['messages'][] = 'Не получено согласие на обработку персональных данных.';
|
||||
$res['errorID'][] = 'consent';
|
||||
}
|
||||
|
||||
$code = filter_var($_POST['captcha'], FILTER_SANITIZE_STRING);
|
||||
session_start();
|
||||
if (!isset($_SESSION['captcha']) || strtoupper(trim($_SESSION['captcha'])) != strtoupper(trim($code))) {
|
||||
$res['success'] = false;
|
||||
$res['errorID'][] = 'captcha';
|
||||
$res['messages'][] = 'Неверный код с картинки.';
|
||||
}
|
||||
unset($_SESSION['captcha']);
|
||||
|
||||
if ($res['success']) {
|
||||
$res['success'] = false;
|
||||
|
||||
$headers = array('Accept: application/json');
|
||||
$data = getRemoteData($apiDomen . 'oauth2/ClientCredentials', null, true,
|
||||
array(
|
||||
'client_id' => $clientId,
|
||||
'client_secret' => $clientSecret,
|
||||
'grant_type' => 'client_credentials',
|
||||
'scope' => 'feedback',
|
||||
), $headers
|
||||
);
|
||||
|
||||
if ($data->success) {
|
||||
if (isset($data->info->access_token)) {
|
||||
$accessToken = $data->info->access_token;
|
||||
|
||||
try {
|
||||
$data = getRemoteData($apiDomen . 'update/feedbackSendMail?access_token=' . $accessToken . '&d=' . $domenName .
|
||||
'&n=' . urlencode($name) .
|
||||
'&e=' . urlencode($email) .
|
||||
'&s=' . urlencode($subject) .
|
||||
'&m=' . urlencode($message)
|
||||
);
|
||||
|
||||
if ($data->info->success) {
|
||||
$res['success'] = true;
|
||||
} else {
|
||||
$res['message'] = $data->info->message;
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
$res['message'] = 'Ошибка. '.$e->getMessage();
|
||||
}
|
||||
|
||||
$res['success'] = true;
|
||||
} else {
|
||||
$res['message'] = 'Ошибка ' . $data->info->message;
|
||||
}
|
||||
} else {
|
||||
$res['message'] = $data->message;
|
||||
}
|
||||
}
|
||||
|
||||
loadHeaders();
|
||||
|
||||
echo json_encode($res);
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir . '/config.php';
|
||||
|
||||
$res['success'] = false;
|
||||
$code = filterAccessToken($_POST['code']);
|
||||
$domen = filterUrl($_POST['domen']);
|
||||
try {
|
||||
$headers = array('Accept: application/json');
|
||||
$data = getRemoteData($apiDomen . 'oauth2/authorize/token', null, true, array(
|
||||
'code' => $code,
|
||||
'client_id' => $clientId,
|
||||
'client_secret' => $clientSecret,
|
||||
'redirect_uri' => $domen . '/sveden/update/index.php',
|
||||
'grant_type' => 'authorization_code',
|
||||
), $headers);
|
||||
if ($data->success) {
|
||||
if (isset($data->info->access_token)) {
|
||||
$res['access_token'] = $data->info->access_token;
|
||||
$res['refresh_token'] = $data->info->refresh_token;
|
||||
$res['success'] = true;
|
||||
} else {
|
||||
$res['message'] = $data->info->message;
|
||||
setResponseCode($data->code);
|
||||
}
|
||||
} else {
|
||||
$res['message'] = 'Не удалось соединиться с сервером.';
|
||||
setResponseCode($data->code);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
$res['message'] = 'Ошибка при получении ключа. ' . $e->getMessage();
|
||||
setResponseCode(500);
|
||||
}
|
||||
loadHeaders();
|
||||
echo json_encode($res);
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
//частично переписанно. Для того чтобы можно было переписать js
|
||||
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir . '/config.php';
|
||||
$token = filterAccessToken($_GET['access_token']);
|
||||
|
||||
$dlHandler = null;
|
||||
|
||||
try {
|
||||
$versionResp = remoteRequest($apiDomen . 'update/version?&d=' . $domenName . '&access_token=' . $token);
|
||||
|
||||
if ($versionResp->curlHasError) {
|
||||
throw new RuntimeException('CURL ' . $versionResp->curlErrorTxt);
|
||||
}
|
||||
|
||||
if ($versionResp->code != 200) {
|
||||
$resultBody = array(
|
||||
'success' => false,
|
||||
'forward_code' => $versionResp->code,
|
||||
'message' => 'Не удается получить новую версию. ' . (!empty($versionResp->responseBody->message ) ? $versionResp->responseBody->message : 'Неизвестная ошибка')
|
||||
);
|
||||
loadHeaders();
|
||||
setResponseCode(200);
|
||||
echo json_encode($resultBody);
|
||||
die();
|
||||
}
|
||||
$serverVersion = $versionResp->responseBody->version;
|
||||
$createZipResp = remoteRequest($apiDomen . 'update/get?&d=' . $domenName . '&access_token=' . $token);
|
||||
|
||||
if ($createZipResp->curlHasError) {
|
||||
throw new RuntimeException('CURL ' . $createZipResp->curlErrorTxt);
|
||||
}
|
||||
if ($createZipResp->code != 200) {
|
||||
$resultBody = array(
|
||||
'success' => false,
|
||||
'forward_code' => $createZipResp->code,
|
||||
'message' => 'Не удается сформировать архив с обновлениями. ' . (!empty($createZipResp->responseBody->message ) ? $createZipResp->responseBody->message : 'Неизвестная ошибка')
|
||||
);
|
||||
loadHeaders();
|
||||
setResponseCode(200);
|
||||
echo json_encode($resultBody);
|
||||
die();
|
||||
}
|
||||
|
||||
$headers = array(
|
||||
'Accept-Encoding: zip, gzip',
|
||||
'Authorization: Bearer ' . $token
|
||||
);
|
||||
$zip = remoteRequest($createZipResp->responseBody->link . '?&d=' . $domenName . '&access_token=' . $token, false, false, $headers);
|
||||
if ($zip->curlHasError) {
|
||||
throw new RuntimeException('CURL ' . $zip->curlErrorTxt);
|
||||
}
|
||||
|
||||
if ($zip->code != 200) {
|
||||
$zip->responseBody = json_decode($zip->responseBody);
|
||||
|
||||
$resultBody = array(
|
||||
'success' => false,
|
||||
'forward_code' => $zip->code,
|
||||
'message' => 'Не удается скачать файл с обновлениями. ' . (!empty($zip->responseBody->message ) ? $zip->responseBody->message : 'Неизвестная ошибка')
|
||||
);
|
||||
|
||||
loadHeaders();
|
||||
setResponseCode(200);
|
||||
echo json_encode($resultBody);
|
||||
die();
|
||||
}
|
||||
|
||||
$filename = $selfDir . '/update-' . $serverVersion . '.zip';
|
||||
$dlHandler = fopen($filename, 'w');
|
||||
if (!fwrite($dlHandler, $zip->responseBody)) {
|
||||
throw new RuntimeException('Не удается записать архив на диск' , 500);
|
||||
}
|
||||
|
||||
$resultBody = array(
|
||||
'success' => true,
|
||||
'forward_code' => 200,
|
||||
'version' => $serverVersion,
|
||||
'message' => 'Архив с базовыми обновлениями успешно загружен.'
|
||||
);
|
||||
|
||||
} catch (Exception $ex) {
|
||||
$resultBody = array('success' => false, 'forward_code' => 500, 'message' => $ex->getMessage());
|
||||
}
|
||||
|
||||
if ($dlHandler) {
|
||||
fclose($dlHandler);
|
||||
}
|
||||
|
||||
loadHeaders();
|
||||
setResponseCode(200);
|
||||
echo json_encode($resultBody);
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir . '/config.php';
|
||||
|
||||
include($selfDir . '/read_settings.php');
|
||||
|
||||
$res['success'] = false;
|
||||
$token = filterAccessToken($_GET['access_token']);
|
||||
try {
|
||||
$data = getRemoteData($filemanagerApiDomen . 'sync/getCountFiles?token=' . $token);
|
||||
if ($data->success) {
|
||||
if ($data->info->success) {
|
||||
if ($data->info->count > 0) {
|
||||
$res['success'] = true;
|
||||
$res['count'] = $data->info->count;
|
||||
$res['message'] = 'Количество файлов получено.';
|
||||
} else {
|
||||
$res['success'] = true;
|
||||
$res['count'] = 0;
|
||||
$res['message'] = 'Файлов для обновления не найдено.';
|
||||
}
|
||||
} else {
|
||||
$res['error'] = isset($data->info->error) ? $data->info->error : '';
|
||||
$res['message'] = 'Ошибка в получении количества файлов.';
|
||||
}
|
||||
} else {
|
||||
$res['message'] = 'Не удалось соединиться с файловым сервером.';
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$res['message'] = 'Ошибка при получении списка файлов. ' . $e->getMessage();
|
||||
}
|
||||
loadHeaders();
|
||||
echo json_encode($res);
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir . '/config.php';
|
||||
|
||||
$res['success'] = false;
|
||||
$token = filterAccessToken($_GET['access_token']);
|
||||
try {
|
||||
$existingFiles = scandir($selfDir . '/../files');
|
||||
if (is_array($existingFiles)) {
|
||||
$data = getRemoteData($filemanagerApiDomen . 'sync/getFilesForSync?token=' . $token);
|
||||
if ($data->success) {
|
||||
if ($data->info->success) {
|
||||
if ($files = $data->info->files) {
|
||||
foreach ($existingFiles as $key => $file) {
|
||||
if (!in_array($file, $files) && $file != '.' && $file != '..') {
|
||||
$filePath = $selfDir . '/../files/' . $file;
|
||||
if (is_dir($filePath)) {
|
||||
removeDirectory($filePath);
|
||||
} else {
|
||||
unlink($filePath);
|
||||
}
|
||||
} else {
|
||||
if (filesize($selfDir . '/../files/' . $file) <= 0) {
|
||||
unset($existingFiles[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$filesForSync = array();
|
||||
foreach ($files as $file) {
|
||||
if (!in_array($file, $existingFiles)) {
|
||||
$filesForSync[] = $file;
|
||||
}
|
||||
}
|
||||
$res['success'] = true;
|
||||
$res['message'] = count($filesForSync) > 0
|
||||
? 'Получен список недостающих файлов.'
|
||||
: 'Недостающих файлов не обнаружено.';
|
||||
$res['files'] = $filesForSync;
|
||||
} else {
|
||||
$res['success'] = true;
|
||||
$res['files'] = array();
|
||||
$res['Список всех файлов пуст. Синхронизация отменена.'];
|
||||
}
|
||||
} else {
|
||||
$res['error'] = isset($data->info->error) ? $data->info->error : '';
|
||||
$res['message'] = 'Ошибка в получении списка всех файлов.';
|
||||
}
|
||||
} else {
|
||||
$res['message'] = 'Не удалось соединиться с файловым сервером.';
|
||||
}
|
||||
} else {
|
||||
$res['message'] = 'Не удалось просканировать существующие файлы.';
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$res['message'] = 'Ошибка. ' . $e->getMessage();
|
||||
}
|
||||
loadHeaders();
|
||||
echo json_encode($res);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir . '/config.php';
|
||||
include($selfDir . '/read_settings.php');
|
||||
|
||||
$res['success'] = false;
|
||||
$token = filterAccessToken($_GET['access_token']);
|
||||
$startFiles = filterInt($_GET['startFiles']);
|
||||
$filesForPart = filterInt($_GET['filesForPart']);
|
||||
try {
|
||||
$data = getRemoteData($filemanagerApiDomen . 'sync/createPackFiles?files_for_part=' . $filesForPart . '&token=' . $token);
|
||||
include('pack_files.php');
|
||||
} catch (Exception $e) {
|
||||
$res['message'] = 'Ошибка при получении списка файлов. ' . $e->getMessage();
|
||||
}
|
||||
loadHeaders();
|
||||
echo json_encode($res);
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir. '/config.php';
|
||||
|
||||
$res['success'] = false;
|
||||
$files = isset($_POST['files']) ? $_POST['files'] : array();
|
||||
if (count($files) > 0) {
|
||||
foreach ($files as &$file) {
|
||||
$file = filterFileName($file);
|
||||
$file = str_replace('+', '%2B', $file);
|
||||
}
|
||||
$files = json_encode($files);
|
||||
$token = filterAccessToken($_POST['access_token']);
|
||||
try {
|
||||
$requestParams = array(
|
||||
'token' => $token,
|
||||
'files' => $files,
|
||||
);
|
||||
$data = getRemoteData($filemanagerApiDomen . 'sync/getPackFilesForSync', null, true, $requestParams);
|
||||
include( $selfDir . '/pack_files.php');
|
||||
} catch (Exception $e) {
|
||||
$res['message'] = 'Ошибка при получении списка файлов. ' . $e->getMessage();
|
||||
}
|
||||
} else {
|
||||
$res['success'] = true;
|
||||
$res['message'] = 'Не получен список файлов';
|
||||
}
|
||||
loadHeaders();
|
||||
echo json_encode($res);
|
||||
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
//Используйте dirname(__FILE__) для определение относительных путей в функции. Файл может быть подключён.
|
||||
|
||||
class getResult
|
||||
{
|
||||
public $success = false;
|
||||
public $code = 200;
|
||||
public $message = 'Не удается получить данные от удаленного сервера';
|
||||
public $info = '';
|
||||
}
|
||||
|
||||
// @deprecated use remoteRequest
|
||||
function getRemoteData($url, $opts = NULL, $decode = true, $postFields = false, $headers = array())
|
||||
{
|
||||
$result = new getResult();
|
||||
$result->success = false;
|
||||
|
||||
$output = null;
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_ENCODING, "");
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST , 0);
|
||||
if (is_array($postFields)) {
|
||||
curl_setopt($ch, CURLOPT_POST , true);
|
||||
$postVars = "";
|
||||
foreach($postFields as $key => $value) {
|
||||
$postVars .= $key . '=' . $value . '&';
|
||||
}
|
||||
$postVars = rtrim($postVars ,'&');
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS , $postVars);
|
||||
} else {
|
||||
$headers[] = 'Content-type: application/json';
|
||||
}
|
||||
if ($headers !== array()) {
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
}
|
||||
$output = curl_exec($ch);
|
||||
if (curl_errno($ch) > 0 || curl_error($ch)) {
|
||||
if (DEBUG_MODE === true) {
|
||||
$result->message .= ';' . '#:' . curl_errno($ch) . 'Error:' . curl_error($ch);
|
||||
}
|
||||
}
|
||||
$curlInfo = curl_getinfo($ch);
|
||||
$result->code = $curlInfo['http_code'];
|
||||
curl_close($ch);
|
||||
|
||||
if ($output) {
|
||||
$result->success = true;
|
||||
$result->info = ($decode) ? json_decode($output) : $output;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getContents($url, $opts)
|
||||
{
|
||||
return file_get_contents($url, false, ($opts != NULL) ? stream_context_create($opts) : NULL);
|
||||
}
|
||||
|
||||
function loadHeaders()
|
||||
{
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Content-type: application/json');
|
||||
}
|
||||
|
||||
function removeDirectory($dir, $folderIsDel = true)
|
||||
{
|
||||
$success = false;
|
||||
if (file_exists($dir)) {
|
||||
if ($objs = glob($dir . "/*")) {
|
||||
foreach ($objs as $obj) {
|
||||
if (is_dir($obj)) {
|
||||
removeDirectory($obj);
|
||||
} else {
|
||||
if (NO_DEL_FILE_PHP && substr($obj, -4) === '.php') {
|
||||
$folderIsDel = false;
|
||||
} else {
|
||||
unlink($obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($folderIsDel) {
|
||||
$success = rmdir($dir);
|
||||
} else {
|
||||
$success = true;
|
||||
}
|
||||
}
|
||||
return $success;
|
||||
}
|
||||
|
||||
function copyDirectory($src, $dst) {
|
||||
$dir = opendir($src);
|
||||
if (!file_exists($dst)) {
|
||||
mkdir($dst, 0775, true);
|
||||
}
|
||||
while(($file = readdir($dir)) !== false) {
|
||||
if (($file != '.') && ($file != '..')) {
|
||||
if (is_dir($src . '/' . $file)) {
|
||||
copyDirectory($src . '/' . $file, $dst . '/' . $file);
|
||||
} else {
|
||||
copy($src . '/' . $file, $dst . '/' . $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
}
|
||||
|
||||
function unpackZipWithReplaceFolder($fileName, $pathToUnpack, $selfDir, $part)
|
||||
{
|
||||
$resUnpack['success'] = false;
|
||||
$resUnpack['message'] = '';
|
||||
$pathToFolder = $selfDir . '/../' . $part;
|
||||
$tmpPathToFolder = $selfDir . '/../_' . $part;
|
||||
if (file_exists($tmpPathToFolder)) {
|
||||
$tmpPathToFolder = $tmpPathToFolder . '_tmp';
|
||||
}
|
||||
|
||||
if (file_exists($pathToFolder)) {
|
||||
rename($pathToFolder, $tmpPathToFolder);
|
||||
$resUnpack = unpackZip($fileName, $pathToUnpack);
|
||||
if ($resUnpack['success']) {
|
||||
if (file_exists($tmpPathToFolder)) {
|
||||
removeDirectory($tmpPathToFolder);
|
||||
}
|
||||
} else {
|
||||
rename($tmpPathToFolder, $pathToFolder);
|
||||
}
|
||||
} else {
|
||||
$resUnpack = unpackZip($fileName, $pathToUnpack);
|
||||
}
|
||||
|
||||
return $resUnpack;
|
||||
}
|
||||
|
||||
function unpackZip($fileName, $pathToUnpack)
|
||||
{
|
||||
$res['success'] = false;
|
||||
$res['message'] = '';
|
||||
if($pathToUnpack) {
|
||||
if (extension_loaded('zip')) {
|
||||
$zip = new ZipArchive;
|
||||
if ($isOpenedZip = $zip->open($fileName)) {
|
||||
$zip->extractTo($pathToUnpack);
|
||||
$zip->close();
|
||||
$res['success'] = true;
|
||||
|
||||
} else {
|
||||
$res['message'] = 'Ошибка при распоковке файлов библиотеки ZIP:' . $isOpenedZip;
|
||||
}
|
||||
} else {
|
||||
require_once dirname(__FILE__) . '/zip_helper.php';
|
||||
$archive = new PclZip($fileName);
|
||||
$unZipResult = $archive->extract(PCLZIP_OPT_PATH, $pathToUnpack,
|
||||
PCLZIP_CB_PRE_EXTRACT, 'preExtractCallback', PCLZIP_OPT_REPLACE_NEWER);
|
||||
if ($unZipResult == 0) {
|
||||
$res['message'] = 'Ошибка при распоковке файлов:' . $archive->errorInfo(true);
|
||||
} else {
|
||||
$res['success'] = true;
|
||||
}
|
||||
$archive->privCloseFd();
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
function preExtractCallback($preEvent, &$preHeader)
|
||||
{
|
||||
if (!is_dir($preHeader['filename'])) {
|
||||
if (strpos($preHeader['filename'], '.htaccess')) {
|
||||
return 0;
|
||||
}
|
||||
if (file_exists($preHeader['filename'])) {
|
||||
unlink($preHeader['filename']);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
function filterAccessToken($token)
|
||||
{
|
||||
return filter_var($token, FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^[a-z0-9_\-\.]+$/i')));
|
||||
}
|
||||
|
||||
function filterFileName($file)
|
||||
{
|
||||
return filter_var($file, FILTER_VALIDATE_REGEXP,
|
||||
array('options' => array('regexp' => '/^[a-z0-9\+\.\,\(\)\;\#\№\-\_\«\»\!\%\=\$\@\'\&\–]+$/i'))
|
||||
);
|
||||
}
|
||||
|
||||
function filterPath($file)
|
||||
{
|
||||
return filter_var($file, FILTER_VALIDATE_REGEXP,
|
||||
array('options' => array('regexp' => '/^[a-z0-9\.\-\_\–\/]+$/i'))
|
||||
);
|
||||
}
|
||||
|
||||
function filterInt($number)
|
||||
{
|
||||
return filter_var($number, FILTER_VALIDATE_INT);
|
||||
}
|
||||
|
||||
function filterUrl($url)
|
||||
{
|
||||
return filter_var($url, FILTER_VALIDATE_URL);
|
||||
}
|
||||
|
||||
function filterVersion($version)
|
||||
{
|
||||
return filter_var($version, FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^[0-9\.]+$/')));
|
||||
}
|
||||
|
||||
function filterPartName($part)
|
||||
{
|
||||
return filter_var($part, FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^[a-z\_]+$/i')));
|
||||
}
|
||||
|
||||
function filterLogin($str)
|
||||
{
|
||||
return filter_var($str, FILTER_VALIDATE_EMAIL);
|
||||
}
|
||||
|
||||
function filterPassword($str)
|
||||
{
|
||||
return filter_var($str, FILTER_SANITIZE_STRING);
|
||||
}
|
||||
|
||||
function logFile($message) {
|
||||
$file_name = date("Y_m_d")."_log.log";
|
||||
// Запись в файл
|
||||
$file = fopen($file_name, 'a+');
|
||||
fwrite($file, date('Y-m-d H:i:s') . ' --- ' . $message . "\r\n");
|
||||
fclose($file);
|
||||
}
|
||||
|
||||
function clearZip()
|
||||
{
|
||||
if ($filelist = glob(dirname(__FILE__) . '/../update/*.zip')) {
|
||||
foreach ($filelist as $file) {
|
||||
if (!unlink($file)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function setResponseCode($code, $reason = null) {
|
||||
$code = intval($code);
|
||||
|
||||
if (version_compare(phpversion(), '5.4', '>') && is_null($reason)) {
|
||||
http_response_code($code);
|
||||
} else {
|
||||
header(trim("HTTP/1.0 $code $reason"));
|
||||
}
|
||||
}
|
||||
|
||||
class RemoteResult
|
||||
{
|
||||
public $curlHasError = true;
|
||||
public $curlErrorTxt = '';
|
||||
|
||||
public $code = 0;
|
||||
public $responseBody = '';
|
||||
}
|
||||
|
||||
function remoteRequest($url, $responseAsJson = true, $postFields = false, $headers = array())
|
||||
{
|
||||
$result = new RemoteResult();
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_ENCODING, "");
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
|
||||
if (is_array($postFields)) {
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
$postVars = "";
|
||||
foreach ($postFields as $key => $value) {
|
||||
$postVars .= $key . '=' . $value . '&';
|
||||
}
|
||||
$postVars = rtrim($postVars, '&');
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postVars);
|
||||
}
|
||||
|
||||
if ($headers !== array()) {
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
}
|
||||
$output = curl_exec($ch);
|
||||
|
||||
if (curl_errno($ch) > 0 || curl_error($ch)) {
|
||||
$result->curlErrorTxt .= ';' . '#:' . curl_errno($ch) . 'Error:' . curl_error($ch);
|
||||
} else{
|
||||
$result->curlHasError = false;
|
||||
|
||||
$curlInfo = curl_getinfo($ch);
|
||||
$result->code = (int) $curlInfo['http_code'];
|
||||
$result->responseBody = ($responseAsJson) ? json_decode($output) : $output;
|
||||
}
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
Executable
+204
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir. '/config.php';
|
||||
require_once $selfDir. '/helper.php';
|
||||
|
||||
header('Content-Type: text/html; charset=UTF-8');
|
||||
$currentVersion = file_get_contents($selfDir . '/cur_version.php');
|
||||
|
||||
$assetsUpdateDir = (!empty($GLOBALS['VIKON_PATH']))
|
||||
? '//' . $domenName . $GLOBALS['VIKON_PATH'] . '/sveden/assets/update/'
|
||||
: '//' . $domenName . '/sveden/assets/update/';
|
||||
|
||||
$assetsCommonDir = (!empty($GLOBALS['VIKON_PATH']))
|
||||
? '//' . $domenName . $GLOBALS['VIKON_PATH'] . '/sveden/assets/review/v1/common/'
|
||||
: '//' . $domenName . '/sveden/assets/review/v1/common/';
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
|
||||
<meta http-equiv="Cache-Control" content="no-cache">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
<title>Обновление сведений об образовательной организации</title>
|
||||
<link href="<?php echo $assetsCommonDir ?>css/vendor.css?v=<?php echo $currentVersion; ?>" rel="stylesheet" type="text/css"/>
|
||||
<link href="<?php echo $assetsUpdateDir ?>css/sveden.update.css?v=<?php echo $currentVersion; ?>" rel="stylesheet" type="text/css"/>
|
||||
</head>
|
||||
<body class="vikon-wrapper">
|
||||
<input type="hidden" name="domen" value="<?php echo $domenName; ?>">
|
||||
<input type="hidden" name="api_domen" value="<?php echo $apiDomen; ?>">
|
||||
<input type="hidden" name="client_id" value="<?php echo $clientId; ?>">
|
||||
<input type="hidden" name="current_version" value="<?php echo $currentVersion; ?>">
|
||||
<input type="hidden" name="code" value="<?php echo isset($_GET['code']) ? $_GET['code'] : null; ?>">
|
||||
|
||||
<div class="wrapper container">
|
||||
|
||||
<div class="main-wrapper">
|
||||
|
||||
<header class="header">
|
||||
Обновление сведений об образовательной организации
|
||||
<hr>
|
||||
</header>
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
<div class="form-group">
|
||||
<a href="/sveden" class="btn btn-primary">На главную</a>
|
||||
<a href="/sveden/update/index.php" class="btn btn-primary" id="exit" style="display: none;">Выход</a>
|
||||
<a href="https://db-nica.ru/rukovodstvo/selectFaq/43/132" target="_blank" class="btn btn-primary help-button">Помощь</a>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-danger" id="message-container" style="display: none;"></div>
|
||||
|
||||
<div class="row" id="wait-load">
|
||||
<div class="text-center">
|
||||
<img src="<?= $assetsCommonDir ?>/images/throbber.gif">
|
||||
идет загрузка страницы
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" id="no-enter" style="display: none;">
|
||||
<div class="col-sm-12 text-center">
|
||||
<h3>Требуется вход</h3>
|
||||
<div class="form-group">
|
||||
<button type="button" class="btn btn-primary" id="enter-vikon">
|
||||
Войти через VIKON
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" id="yes-enter" style="display: none;">
|
||||
<div class="col-sm-6">
|
||||
<h3>Текущая версия системы: <span class="label label-default"><?php echo $currentVersion; ?></span></h3>
|
||||
<div class="form-group settings-update" id="settings-update">
|
||||
<h3>Обновление по частям:</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<div class="checkbox">
|
||||
<input type="checkbox" name="select-all" id="select-all" checked>
|
||||
<label for="select-all">Выбрать все</label>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<b>Обновить следующие разделы:</b>
|
||||
<ul>
|
||||
<?php
|
||||
$parts = json_decode($parts);
|
||||
foreach ($parts as $partKey => $partVal) { ?>
|
||||
<li>
|
||||
<div class="checkbox">
|
||||
<input type="checkbox" name="part" id="<?php echo $partKey; ?>"
|
||||
value="<?php echo $partKey; ?>" checked>
|
||||
<label for="<?php echo $partKey; ?>"><?php echo $partVal; ?></label>
|
||||
</div>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<b>Синхронизация файлов:</b>
|
||||
<ul>
|
||||
<li>
|
||||
<div class="checkbox">
|
||||
<input type="checkbox" name="sync" id="sync" value="sync" checked>
|
||||
<label for="sync">Синхронизировать файлы</label>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="count-files">
|
||||
<select class="form-control select-count-files" name="count-files-in-batch">
|
||||
<?php
|
||||
$minCountFilesInBatch = 1;
|
||||
for ($counFilesInBatch = 5; $counFilesInBatch >= $minCountFilesInBatch; $counFilesInBatch--) { ?>
|
||||
<option value="<?php echo $counFilesInBatch; ?>">
|
||||
<?php echo $counFilesInBatch; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
Максимальное количество файлов в пакете обновлений
|
||||
<span class="glyphicon glyphicon-question-sign text-info"
|
||||
title="Рекомендуется уменьшить в случае возникновения ошибок получения файлов"></span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="form-group hide admin-mode-panel" id="admin-mode-panel">
|
||||
<b>Дополнительные опции для администратора:</b>
|
||||
<ul>
|
||||
<li>
|
||||
<div class="checkbox">
|
||||
<input type="checkbox" name="no_core" id="no_core" value="no_core">
|
||||
<label for="no_core">Не обновлять ядро</label>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="checkbox">
|
||||
<input type="checkbox" name="debug_mode" id="debug_mode" value="debug_mode">
|
||||
<label for="debug_mode">Debug Mode</label>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-6">
|
||||
<h3>Наличие обновления: <span class="label label-warning" id="new-version">получение информации...</span></h3>
|
||||
<div class="form-group">
|
||||
<button type="button" class="btn btn-primary" id="start-update">Начать обновление</button>
|
||||
</div>
|
||||
<p class="alert alert-success" id="update-complete" style="display: none;"></p>
|
||||
<p class="alert alert-danger" id="clear_tmp_error_layout" style="display: none;"></p>
|
||||
<div class="row" id="progressbar-container" style="display: none;">
|
||||
<div class="col-xs-12">
|
||||
<div class="progress">
|
||||
<div id="progressbar" class="progress-bar progress-bar-primary progress-bar-striped"
|
||||
role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"
|
||||
style="width: 0;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-info process-container" id="process-container" style="display: none;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php require_once $selfDir . '/is_writable.php'; ?>
|
||||
<?php require_once $selfDir . '/check_curl.php'; ?>
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<hr>
|
||||
<div class="text-center">
|
||||
<p class="copyright">
|
||||
Национальный фонд поддержки инноваций в сфере образования (НФПИ)
|
||||
<br>
|
||||
Copyright © 2013-<?php echo date('Y') ?>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$vendorJsPath = $assetsCommonDir . 'js/vendor.js?v=' . $currentVersion;
|
||||
$updateJsPath = $assetsUpdateDir . 'js/sveden.update.js?v=' . $currentVersion;
|
||||
if (isset($_GET['vendorJsPath'])) {
|
||||
$vendorJsPathParam = filterPath($_GET['vendorJsPath']);
|
||||
$vendorJsPath = $apiDomen . $vendorJsPathParam . '?v=' . $currentVersion;
|
||||
}
|
||||
if (isset($_GET['updateJsPath'])) {
|
||||
$updateJsPathParam = filterPath($_GET['updateJsPath']);
|
||||
$updateJsPath = $apiDomen . $updateJsPathParam . '?v=' . $currentVersion;
|
||||
}
|
||||
?>
|
||||
|
||||
<script src="<?php echo $vendorJsPath ?>"></script>
|
||||
<script src="<?php echo $updateJsPath ?>"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
$selfDir = dirname(__FILE__);
|
||||
function isWritableR($dir)
|
||||
{
|
||||
$message = '';
|
||||
if (is_dir($dir)) {
|
||||
if (is_writable($dir)) {
|
||||
$objects = scandir($dir);
|
||||
foreach ($objects as $object) {
|
||||
if ($object != "." && $object != "..") {
|
||||
$message .= isWritableR($dir . "/" . $object);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$message .= 'Отсутствуют права на запись: "' . $dir . '"<br>';
|
||||
}
|
||||
} else if (!is_writable($dir)) {
|
||||
$message .= 'Отсутствуют права на запись: "' . $dir . '"<br>';
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
|
||||
$messageSveden = '';
|
||||
if (file_exists( $selfDir . '/../')) {
|
||||
$messageSveden = isWritableR($selfDir . '/../');
|
||||
}
|
||||
$messageAbitur = '';
|
||||
if (file_exists($selfDir .'/../../abitur')) {
|
||||
$messageAbitur = isWritableR($selfDir . '/../../abitur');
|
||||
}
|
||||
|
||||
if ($messageSveden || $messageAbitur) {
|
||||
echo '<p class="alert alert-danger">' . $messageSveden . $messageAbitur . '</p>';
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
$selfDir = dirname(__FILE__);
|
||||
if ($data->success) {
|
||||
if ($data->info->success) {
|
||||
if ($data->info->archiveName) {
|
||||
$opts = array(
|
||||
'http' => array(
|
||||
'method' => "GET",
|
||||
'header' => "Accept-language: ru\r\n" .
|
||||
"Accept-Encoding: zip, gzip"
|
||||
)
|
||||
);
|
||||
$zip = getRemoteData($filemanagerApiDomen . 'file/archive/' . $data->info->archiveName . '?token=' . $token, $opts, false);
|
||||
if ($zip->success) {
|
||||
$fileName = $data->info->archiveName;
|
||||
$pathToFileCreateFile = $selfDir . '/' . $fileName;
|
||||
|
||||
$dlHandler = fopen($pathToFileCreateFile, 'w');
|
||||
if (fwrite($dlHandler, $zip->info)) {
|
||||
try {
|
||||
$resUnpack = unpackZip($pathToFileCreateFile, $selfDir . "/../files/");
|
||||
if ($resUnpack['success']) {
|
||||
$res['success'] = true;
|
||||
$res['message'] = 'Пакет файлов ' . $fileName . ' распакован.';
|
||||
$clearArchive = getRemoteData($filemanagerApiDomen . 'file/removeArchive/' . $fileName . '?token=' . $token);
|
||||
} else {
|
||||
$res['message'] = $resUnpack['message'];
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$res['message'] = 'Ошибка при распоковке пакета файлов ' . $fileName . ' ' . $e->getMessage();
|
||||
}
|
||||
} else {
|
||||
$res['message'] = 'Не удается записать пакет с файлами на диск.';
|
||||
}
|
||||
fclose($dlHandler);
|
||||
clearZip();
|
||||
} else {
|
||||
$res['message'] = 'Не удается скачать пакет с файлами. ' . $zip->message;
|
||||
}
|
||||
} else {
|
||||
$res['success'] = true;
|
||||
$res['message'] = 'Пакет с файлами пустой.';
|
||||
}
|
||||
} else {
|
||||
$res['error'] = isset($data->info->error) ? $data->info->error : '';
|
||||
$res['message'] = 'Ошибка в формировании пакета файлов.' . $data->info->message;
|
||||
}
|
||||
} else {
|
||||
$res['message'] = 'Не удалось соединиться с файловым сервером. ' . $data->message;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
function tempCopyFile($fromDir, $delDir, $tempDir)
|
||||
{
|
||||
copy($fromDir . '/index.html', $tempDir. '/index.html');
|
||||
removeDirectory($delDir);
|
||||
if (!file_exists($fromDir)) mkdir($fromDir);
|
||||
copy($tempDir . '/index.html', $fromDir. '/index.html');
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir . '/config.php';
|
||||
|
||||
$res['success'] = false;
|
||||
$refreshToken = filterAccessToken($_POST['refresh_token']);
|
||||
try {
|
||||
$headers = array('Accept: application/json');
|
||||
$data = getRemoteData($apiDomen . 'oauth2/RefreshToken', null, true, array(
|
||||
'refresh_token' => $refreshToken,
|
||||
'client_id' => $clientId,
|
||||
'client_secret' => $clientSecret,
|
||||
'grant_type' => 'refresh_token',
|
||||
), $headers);
|
||||
if ($data->success) {
|
||||
if (isset($data->info->access_token)) {
|
||||
$res['access_token'] = $data->info->access_token;
|
||||
$res['refresh_token'] = $data->info->refresh_token;
|
||||
$res['success'] = true;
|
||||
} else {
|
||||
$res['message'] = $data->info->message;
|
||||
setResponseCode($data->code);
|
||||
}
|
||||
} else {
|
||||
$res['message'] = 'Не удалось соединиться с сервером.';
|
||||
setResponseCode($data->code);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
$res['message'] = 'Ошибка при обновлении ключа. ' . $e->getMessage();
|
||||
setResponseCode(500);
|
||||
}
|
||||
loadHeaders();
|
||||
echo json_encode($res);
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir . '/config.php';
|
||||
|
||||
$token = filterAccessToken($_POST['access_token']);
|
||||
$part = filterPartName($_POST['part']);
|
||||
|
||||
try {
|
||||
$headers = array(
|
||||
'Accept: application/json',
|
||||
'Authorization: Bearer ' . $token,
|
||||
);
|
||||
|
||||
$post = array('part' => $part);
|
||||
$response = remoteRequest($apiDomen . 'pull_updates/generatePartJson', true, $post, $headers);
|
||||
if (!$response->curlHasError) {
|
||||
if ($response->code == 200) {
|
||||
$resultBody = array(
|
||||
'success' => true,
|
||||
'operation_identity' => $response->responseBody->operation_identity,
|
||||
'ttl' => $response->responseBody->ttl,
|
||||
'forward_code' => 200,
|
||||
);
|
||||
} else {
|
||||
$resultBody = array(
|
||||
'success' => false,
|
||||
'forward_code' => $response->code,
|
||||
'message' => !empty($response->responseBody->message ) ? $response->responseBody->message : 'Неизвестная ошибка'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException('CURL ' . $response->curlErrorTxt);
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
$resultBody = array('success' => false, 'forward_code' => 500, 'message' => $ex->getMessage());
|
||||
}
|
||||
|
||||
loadHeaders();
|
||||
setResponseCode(200);
|
||||
echo json_encode($resultBody);
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir . '/config.php';
|
||||
|
||||
$token = filterAccessToken($_POST['access_token']);
|
||||
$operationIdentity = (string) filter_var($_POST['operation_identity'], FILTER_SANITIZE_STRING);
|
||||
$part = filterPartName($_POST['part']);
|
||||
|
||||
try {
|
||||
$headers = array(
|
||||
'Accept: application/json',
|
||||
'Authorization: Bearer ' . $token,
|
||||
);
|
||||
|
||||
$response = remoteRequest(
|
||||
$apiDomen . 'pull_updates/checkPartGenerationResultJson?operation_identity=' . $operationIdentity . '&part=' . $part,
|
||||
true,
|
||||
false,
|
||||
$headers
|
||||
);
|
||||
if (!$response->curlHasError) {
|
||||
if ($response->code == 200) {
|
||||
$resultBody = array(
|
||||
'success' => true,
|
||||
'forward_code' => 200,
|
||||
);
|
||||
} else {
|
||||
$resultBody = array(
|
||||
'success' => false,
|
||||
'forward_code' => $response->code,
|
||||
'message' => !empty($response->responseBody->message ) ? $response->responseBody->message : 'Неизвестная ошибка'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException('CURL ' . $response->curlErrorTxt);
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
$resultBody = array('success' => false, 'forward_code' => 500, 'message' => $ex->getMessage());
|
||||
}
|
||||
|
||||
loadHeaders();
|
||||
setResponseCode(200);
|
||||
echo json_encode($resultBody);
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir . '/config.php';
|
||||
|
||||
$dlHandler = null;
|
||||
$token = filterAccessToken($_POST['access_token']);
|
||||
$operationIdentity = (string) filter_var($_POST['operation_identity'], FILTER_SANITIZE_STRING);
|
||||
$part = filterPartName($_POST['part']);
|
||||
|
||||
try {
|
||||
$headers = array(
|
||||
'Authorization: Bearer ' . $token,
|
||||
'Accept-Encoding: zip, gzip'
|
||||
);
|
||||
|
||||
$response = remoteRequest(
|
||||
$apiDomen . 'pull_updates/downloadPartResult?operation_identity=' . $operationIdentity . '&part=' . $part,
|
||||
false,
|
||||
false,
|
||||
$headers
|
||||
);
|
||||
|
||||
if (!$response->curlHasError) {
|
||||
if ($response->code == 200) {
|
||||
$filename = $selfDir . '/' . $operationIdentity . '.zip';
|
||||
$dlHandler = fopen($filename, 'w');
|
||||
if (!fwrite($dlHandler, $response->responseBody) ) {
|
||||
throw new RuntimeException('Не удается записать архив на диск');
|
||||
}
|
||||
|
||||
$unpackTmpPath = $selfDir . '/../update_tmp/';
|
||||
if (!file_exists($unpackTmpPath)) {
|
||||
mkdir($unpackTmpPath, 0775);
|
||||
}
|
||||
if ($part === 'abitur') {
|
||||
$unpackPath = $unpackTmpPath;
|
||||
} else {
|
||||
$unpackPath = $selfDir . '/../';
|
||||
}
|
||||
|
||||
$resUnpack = unpackZipWithReplaceFolder($filename, $unpackPath, $selfDir, $part);
|
||||
if (!$resUnpack['success']) {
|
||||
throw new RuntimeException('Не удалось распаковать архив раздела ' . $part . '.');
|
||||
}
|
||||
|
||||
if ($part === 'abitur') {
|
||||
$abiturPath = $selfDir . '/../../abitur';
|
||||
if (!file_exists($abiturPath)) {
|
||||
mkdir($abiturPath, 0775);
|
||||
} else {
|
||||
$removeAbiturFiles = explode(';', $removeAbiturFiles);
|
||||
foreach ($removeAbiturFiles as $file) {
|
||||
$filePath = $abiturPath . '/' . $file;
|
||||
if (file_exists($filePath)) {
|
||||
if (is_dir($filePath)) {
|
||||
removeDirectory($filePath);
|
||||
} else {
|
||||
unlink($filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
copyDirectory($unpackPath . 'abitur', $abiturPath);
|
||||
}
|
||||
$resultBody = array('success' => true, 'forward_code' => 200, 'message' => 'Раздел ' . $part . ' успешно обновлен.');
|
||||
} else {
|
||||
$response->responseBody = json_decode($response->responseBody);
|
||||
|
||||
$resultBody = array(
|
||||
'success' => false,
|
||||
'forward_code' => $response->code,
|
||||
'message' => !empty($response->responseBody->message ) ? $response->responseBody->message : 'неизвестная ошибка'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException('CURL ' . $response->curlErrorTxt);
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
$resultBody = array('success' => false, 'forward_code' => 500, 'message' => $ex->getMessage());
|
||||
}
|
||||
|
||||
if($dlHandler != null){
|
||||
fclose($dlHandler);
|
||||
}
|
||||
|
||||
clearZip();
|
||||
loadHeaders();
|
||||
setResponseCode(200);
|
||||
echo json_encode($resultBody);
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir . '/config.php';
|
||||
|
||||
$operationIdentity = (string) filter_var($_GET['operation_identity'], FILTER_SANITIZE_STRING);
|
||||
$token = filterAccessToken($_GET['access_token']);
|
||||
|
||||
try {
|
||||
$headers = array('Accept: application/json', 'Authorization: Bearer ' . $token);
|
||||
$response = remoteRequest($apiDomen . 'pull_updates/getStatusPartGenerationJson?operation_identity=' . $operationIdentity, true, false, $headers);
|
||||
if (!$response->curlHasError) {
|
||||
if ($response->code == 200) {
|
||||
$resultBody = array(
|
||||
'success' => true,
|
||||
'status' => $response->responseBody->status,
|
||||
'forward_code' => 200,
|
||||
);
|
||||
} else {
|
||||
$resultBody = array(
|
||||
'success' => false,
|
||||
'forward_code' => $response->code,
|
||||
'message' => !empty($response->responseBody->message ) ? $response->responseBody->message : 'неизвестная ошибка'
|
||||
);
|
||||
}
|
||||
}else {
|
||||
throw new RuntimeException('CURL ' . $response->curlErrorTxt);
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
setResponseCode(!empty($response->code) ? $response->code : 500 );
|
||||
$resultBody = array('success' => false, 'forward_code' => 500, 'message' => $ex->getMessage());
|
||||
}
|
||||
|
||||
loadHeaders();
|
||||
setResponseCode(200);
|
||||
echo json_encode($resultBody);
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
$selfDir = dirname(__FILE__);
|
||||
require_once $selfDir . '/config.php';
|
||||
|
||||
$version = filterVersion($_GET['version']);
|
||||
$fileName = $selfDir. '/update-' . $version . '.zip';
|
||||
$resultBody = array('success' => true, 'forward_code' => 200, 'message' => 'Скрипты обновления успешно обновлены');
|
||||
|
||||
if (file_exists($fileName)) {
|
||||
try {
|
||||
$res = unpackZip($fileName, $selfDir . '/'. './../../');
|
||||
if (!$res['success']) {
|
||||
$resultBody = array('success' => false, 'forward_code' => 500, 'message' => $res['message']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$resultBody = array(
|
||||
'success' => false,
|
||||
'forward_code' => 500,
|
||||
'message' => 'Ошибка при распаковке скриптов обновления' . $e->getMessage()
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$resultBody = array(
|
||||
'success' => false,
|
||||
'forward_code' => 500,
|
||||
'message' => 'Не найден файл ' . $fileName . ' для распаковки'
|
||||
);
|
||||
}
|
||||
|
||||
loadHeaders();
|
||||
setResponseCode(200);
|
||||
echo json_encode($resultBody);
|
||||
Executable
+5451
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user