sync
This commit is contained in:
2
.htaccess
Normal file
2
.htaccess
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
RewriteEngine on
|
||||||
|
RewriteRule .? - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||||
BIN
_api_server_vue_20.11.2020.rar
Normal file
BIN
_api_server_vue_20.11.2020.rar
Normal file
Binary file not shown.
BIN
api_24.10.2018.rar
Normal file
BIN
api_24.10.2018.rar
Normal file
Binary file not shown.
41
connection.php
Normal file
41
connection.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// $serverName = "WINDOWS-BASIC-1";
|
||||||
|
// $Database = 'Tehnokort';
|
||||||
|
// $UID = 'Admin';
|
||||||
|
// $PWD = 'TK2009UcheTSQL';
|
||||||
|
|
||||||
|
//$serverName = "Test";
|
||||||
|
//$Database = 'Tehnokort';
|
||||||
|
//$UID = 'lord';
|
||||||
|
//$PWD = 'lord';
|
||||||
|
|
||||||
|
// $serverName="192.168.72.77";
|
||||||
|
// $Database="Tehnokort";
|
||||||
|
// $UID="Admin";
|
||||||
|
// $PWD="AMK";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$serverName = '192.168.76.100';
|
||||||
|
$Database = 'eReport';
|
||||||
|
$UID = 'dimagenius';
|
||||||
|
$PWD = 'dimagenius';
|
||||||
|
|
||||||
|
ini_set('display_errors', 'Off');
|
||||||
|
|
||||||
|
$connectionInfo = array('Database' => $Database, 'UID' => $UID, 'PWD' => $PWD);
|
||||||
|
$conn = sqlsrv_connect($serverName, $connectionInfo);
|
||||||
|
if ($conn) {
|
||||||
|
header('Content-Type:text/html; charset=UTF-8', true, 200);
|
||||||
|
} else {
|
||||||
|
header('Content-Type:text/html; charset=UTF-8', true, 301);
|
||||||
|
if (($errors = sqlsrv_errors()) != null) {
|
||||||
|
foreach ($errors as $error) {
|
||||||
|
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
|
||||||
|
echo "code: ".$error[ 'code']."<br />";
|
||||||
|
echo "message: ".iconv('windows-1251', 'UTF-8', $error['message'])."<br />";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
44
core.php
Normal file
44
core.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace API;
|
||||||
|
|
||||||
|
|
||||||
|
foreach (glob("modules/$project_name/*.php") as $filename) { include_once $filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
$traits_array_= array();
|
||||||
|
$traits_array = get_declared_traits();
|
||||||
|
foreach ($traits_array as $key) {
|
||||||
|
array_push($traits_array_, substr($key, 4));
|
||||||
|
}
|
||||||
|
$traits_name=implode(",", $traits_array_);
|
||||||
|
|
||||||
|
eval("
|
||||||
|
namespace API;
|
||||||
|
final class API
|
||||||
|
{
|
||||||
|
use $traits_name;
|
||||||
|
private static \$instance;
|
||||||
|
public static function getInstance(): self
|
||||||
|
{
|
||||||
|
if (null === static::\$instance) {
|
||||||
|
static::\$instance = new static();
|
||||||
|
}
|
||||||
|
return static::\$instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
");
|
||||||
|
|
||||||
|
$api = API::getInstance();
|
||||||
|
|
||||||
|
$_POST = json_decode(file_get_contents('php://input'), true);
|
||||||
|
if (isset($_POST)) {
|
||||||
|
$params=$_POST['params'];
|
||||||
|
$flag=$params['flag'];
|
||||||
|
if (method_exists($api, $flag)) {
|
||||||
|
call_user_func(array($api, $flag), $params);
|
||||||
|
} else {
|
||||||
|
header('Content-Type:text/html; charset=UTF-8', true, 301);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
65
core__.php
Normal file
65
core__.php
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
namespace API;
|
||||||
|
//новая версия с классом api
|
||||||
|
|
||||||
|
$IP = $_SERVER['REMOTE_ADDR'];
|
||||||
|
|
||||||
|
foreach (glob("modules/*.php") as $filename) {
|
||||||
|
include $filename;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
final class API
|
||||||
|
{
|
||||||
|
//подключение модулей
|
||||||
|
use Common, Companies, Devices, Stats, Users;
|
||||||
|
//стандартный шаблон singleton
|
||||||
|
private static $instance;
|
||||||
|
public static function getInstance(): API
|
||||||
|
{
|
||||||
|
if (null === static::$instance) {
|
||||||
|
static::$instance = new static();
|
||||||
|
}
|
||||||
|
|
||||||
|
return static::$instance;
|
||||||
|
}
|
||||||
|
private function __construct(){}
|
||||||
|
private function __clone(){}
|
||||||
|
private function __wakeup(){}
|
||||||
|
}
|
||||||
|
$api=API::getInstance();
|
||||||
|
|
||||||
|
$_POST = json_decode(file_get_contents('php://input'), true);
|
||||||
|
|
||||||
|
if (isset($_POST)) {
|
||||||
|
$params=$_POST['params'];
|
||||||
|
$flag=$params['flag'];
|
||||||
|
//echo ($flag);
|
||||||
|
if (method_exists($api, $flag)) {
|
||||||
|
call_user_func(array($api, $flag), $params);
|
||||||
|
} else {
|
||||||
|
header('Content-Type:text/html; charset=UTF-8', true, 301);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//старая версия без класса api
|
||||||
|
|
||||||
|
// foreach (glob("api/modules/*.php") as $filename) {
|
||||||
|
// include $filename;
|
||||||
|
// }
|
||||||
|
// $_POST = json_decode(file_get_contents('php://input'), true);
|
||||||
|
// if (isset($_POST)) {
|
||||||
|
// $params=$_POST['params'];
|
||||||
|
// $flag=$params['flag'];
|
||||||
|
// if (function_exists($flag)) {
|
||||||
|
// call_user_func($flag, $params);
|
||||||
|
// } else {
|
||||||
|
// header('Content-Type:text/html; charset=UTF-8', true, 301);
|
||||||
|
// exit;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
8
index.php
Normal file
8
index.php
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
|
header('Access-Control-Allow-Origin: *');
|
||||||
|
header('Access-Control-Allow-Headers: *');
|
||||||
|
|
||||||
|
if ($_SERVER['HTTP_AUTHORIZATION']==='*') {
|
||||||
|
include("server.php");
|
||||||
|
}
|
||||||
379
libs/JWT.php
Normal file
379
libs/JWT.php
Normal file
@@ -0,0 +1,379 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Firebase\JWT;
|
||||||
|
use \DomainException;
|
||||||
|
use \InvalidArgumentException;
|
||||||
|
use \UnexpectedValueException;
|
||||||
|
use \DateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSON Web Token implementation, based on this spec:
|
||||||
|
* https://tools.ietf.org/html/rfc7519
|
||||||
|
*
|
||||||
|
* PHP version 5
|
||||||
|
*
|
||||||
|
* @category Authentication
|
||||||
|
* @package Authentication_JWT
|
||||||
|
* @author Neuman Vong <neuman@twilio.com>
|
||||||
|
* @author Anant Narayanan <anant@php.net>
|
||||||
|
* @license http://opensource.org/licenses/BSD-3-Clause 3-clause BSD
|
||||||
|
* @link https://github.com/firebase/php-jwt
|
||||||
|
*/
|
||||||
|
class JWT
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When checking nbf, iat or expiration times,
|
||||||
|
* we want to provide some extra leeway time to
|
||||||
|
* account for clock skew.
|
||||||
|
*/
|
||||||
|
public static $leeway = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow the current timestamp to be specified.
|
||||||
|
* Useful for fixing a value within unit testing.
|
||||||
|
*
|
||||||
|
* Will default to PHP time() value if null.
|
||||||
|
*/
|
||||||
|
public static $timestamp = null;
|
||||||
|
|
||||||
|
public static $supported_algs = array(
|
||||||
|
'HS256' => array('hash_hmac', 'SHA256'),
|
||||||
|
'HS512' => array('hash_hmac', 'SHA512'),
|
||||||
|
'HS384' => array('hash_hmac', 'SHA384'),
|
||||||
|
'RS256' => array('openssl', 'SHA256'),
|
||||||
|
'RS384' => array('openssl', 'SHA384'),
|
||||||
|
'RS512' => array('openssl', 'SHA512'),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a JWT string into a PHP object.
|
||||||
|
*
|
||||||
|
* @param string $jwt The JWT
|
||||||
|
* @param string|array $key The key, or map of keys.
|
||||||
|
* If the algorithm used is asymmetric, this is the public key
|
||||||
|
* @param array $allowed_algs List of supported verification algorithms
|
||||||
|
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
|
||||||
|
*
|
||||||
|
* @return object The JWT's payload as a PHP object
|
||||||
|
*
|
||||||
|
* @throws UnexpectedValueException Provided JWT was invalid
|
||||||
|
* @throws SignatureInvalidException Provided JWT was invalid because the signature verification failed
|
||||||
|
* @throws BeforeValidException Provided JWT is trying to be used before it's eligible as defined by 'nbf'
|
||||||
|
* @throws BeforeValidException Provided JWT is trying to be used before it's been created as defined by 'iat'
|
||||||
|
* @throws ExpiredException Provided JWT has since expired, as defined by the 'exp' claim
|
||||||
|
*
|
||||||
|
* @uses jsonDecode
|
||||||
|
* @uses urlsafeB64Decode
|
||||||
|
*/
|
||||||
|
public static function decode($jwt, $key, array $allowed_algs = array())
|
||||||
|
{
|
||||||
|
$timestamp = is_null(static::$timestamp) ? time() : static::$timestamp;
|
||||||
|
|
||||||
|
if (empty($key)) {
|
||||||
|
throw new InvalidArgumentException('Key may not be empty');
|
||||||
|
}
|
||||||
|
$tks = explode('.', $jwt);
|
||||||
|
if (count($tks) != 3) {
|
||||||
|
throw new UnexpectedValueException('Wrong number of segments');
|
||||||
|
}
|
||||||
|
list($headb64, $bodyb64, $cryptob64) = $tks;
|
||||||
|
if (null === ($header = static::jsonDecode(static::urlsafeB64Decode($headb64)))) {
|
||||||
|
throw new UnexpectedValueException('Invalid header encoding');
|
||||||
|
}
|
||||||
|
if (null === $payload = static::jsonDecode(static::urlsafeB64Decode($bodyb64))) {
|
||||||
|
throw new UnexpectedValueException('Invalid claims encoding');
|
||||||
|
}
|
||||||
|
if (false === ($sig = static::urlsafeB64Decode($cryptob64))) {
|
||||||
|
throw new UnexpectedValueException('Invalid signature encoding');
|
||||||
|
}
|
||||||
|
if (empty($header->alg)) {
|
||||||
|
throw new UnexpectedValueException('Empty algorithm');
|
||||||
|
}
|
||||||
|
if (empty(static::$supported_algs[$header->alg])) {
|
||||||
|
throw new UnexpectedValueException('Algorithm not supported');
|
||||||
|
}
|
||||||
|
if (!in_array($header->alg, $allowed_algs)) {
|
||||||
|
throw new UnexpectedValueException('Algorithm not allowed');
|
||||||
|
}
|
||||||
|
if (is_array($key) || $key instanceof \ArrayAccess) {
|
||||||
|
if (isset($header->kid)) {
|
||||||
|
if (!isset($key[$header->kid])) {
|
||||||
|
throw new UnexpectedValueException('"kid" invalid, unable to lookup correct key');
|
||||||
|
}
|
||||||
|
$key = $key[$header->kid];
|
||||||
|
} else {
|
||||||
|
throw new UnexpectedValueException('"kid" empty, unable to lookup correct key');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the signature
|
||||||
|
if (!static::verify("$headb64.$bodyb64", $sig, $key, $header->alg)) {
|
||||||
|
throw new SignatureInvalidException('Signature verification failed');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the nbf if it is defined. This is the time that the
|
||||||
|
// token can actually be used. If it's not yet that time, abort.
|
||||||
|
if (isset($payload->nbf) && $payload->nbf > ($timestamp + static::$leeway)) {
|
||||||
|
throw new BeforeValidException(
|
||||||
|
'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->nbf)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that this token has been created before 'now'. This prevents
|
||||||
|
// using tokens that have been created for later use (and haven't
|
||||||
|
// correctly used the nbf claim).
|
||||||
|
if (isset($payload->iat) && $payload->iat > ($timestamp + static::$leeway)) {
|
||||||
|
throw new BeforeValidException(
|
||||||
|
'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->iat)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if this token has expired.
|
||||||
|
if (isset($payload->exp) && ($timestamp - static::$leeway) >= $payload->exp) {
|
||||||
|
throw new ExpiredException('Expired token');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts and signs a PHP object or array into a JWT string.
|
||||||
|
*
|
||||||
|
* @param object|array $payload PHP object or array
|
||||||
|
* @param string $key The secret key.
|
||||||
|
* If the algorithm used is asymmetric, this is the private key
|
||||||
|
* @param string $alg The signing algorithm.
|
||||||
|
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
|
||||||
|
* @param mixed $keyId
|
||||||
|
* @param array $head An array with header elements to attach
|
||||||
|
*
|
||||||
|
* @return string A signed JWT
|
||||||
|
*
|
||||||
|
* @uses jsonEncode
|
||||||
|
* @uses urlsafeB64Encode
|
||||||
|
*/
|
||||||
|
public static function encode($payload, $key, $alg = 'HS256', $keyId = null, $head = null)
|
||||||
|
{
|
||||||
|
$header = array('typ' => 'JWT', 'alg' => $alg);
|
||||||
|
if ($keyId !== null) {
|
||||||
|
$header['kid'] = $keyId;
|
||||||
|
}
|
||||||
|
if ( isset($head) && is_array($head) ) {
|
||||||
|
$header = array_merge($head, $header);
|
||||||
|
}
|
||||||
|
$segments = array();
|
||||||
|
$segments[] = static::urlsafeB64Encode(static::jsonEncode($header));
|
||||||
|
$segments[] = static::urlsafeB64Encode(static::jsonEncode($payload));
|
||||||
|
$signing_input = implode('.', $segments);
|
||||||
|
|
||||||
|
$signature = static::sign($signing_input, $key, $alg);
|
||||||
|
$segments[] = static::urlsafeB64Encode($signature);
|
||||||
|
|
||||||
|
return implode('.', $segments);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sign a string with a given key and algorithm.
|
||||||
|
*
|
||||||
|
* @param string $msg The message to sign
|
||||||
|
* @param string|resource $key The secret key
|
||||||
|
* @param string $alg The signing algorithm.
|
||||||
|
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
|
||||||
|
*
|
||||||
|
* @return string An encrypted message
|
||||||
|
*
|
||||||
|
* @throws DomainException Unsupported algorithm was specified
|
||||||
|
*/
|
||||||
|
public static function sign($msg, $key, $alg = 'HS256')
|
||||||
|
{
|
||||||
|
if (empty(static::$supported_algs[$alg])) {
|
||||||
|
throw new DomainException('Algorithm not supported');
|
||||||
|
}
|
||||||
|
list($function, $algorithm) = static::$supported_algs[$alg];
|
||||||
|
switch($function) {
|
||||||
|
case 'hash_hmac':
|
||||||
|
return hash_hmac($algorithm, $msg, $key, true);
|
||||||
|
case 'openssl':
|
||||||
|
$signature = '';
|
||||||
|
$success = openssl_sign($msg, $signature, $key, $algorithm);
|
||||||
|
if (!$success) {
|
||||||
|
throw new DomainException("OpenSSL unable to sign data");
|
||||||
|
} else {
|
||||||
|
return $signature;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify a signature with the message, key and method. Not all methods
|
||||||
|
* are symmetric, so we must have a separate verify and sign method.
|
||||||
|
*
|
||||||
|
* @param string $msg The original message (header and body)
|
||||||
|
* @param string $signature The original signature
|
||||||
|
* @param string|resource $key For HS*, a string key works. for RS*, must be a resource of an openssl public key
|
||||||
|
* @param string $alg The algorithm
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @throws DomainException Invalid Algorithm or OpenSSL failure
|
||||||
|
*/
|
||||||
|
private static function verify($msg, $signature, $key, $alg)
|
||||||
|
{
|
||||||
|
if (empty(static::$supported_algs[$alg])) {
|
||||||
|
throw new DomainException('Algorithm not supported');
|
||||||
|
}
|
||||||
|
|
||||||
|
list($function, $algorithm) = static::$supported_algs[$alg];
|
||||||
|
switch($function) {
|
||||||
|
case 'openssl':
|
||||||
|
$success = openssl_verify($msg, $signature, $key, $algorithm);
|
||||||
|
if ($success === 1) {
|
||||||
|
return true;
|
||||||
|
} elseif ($success === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// returns 1 on success, 0 on failure, -1 on error.
|
||||||
|
throw new DomainException(
|
||||||
|
'OpenSSL error: ' . openssl_error_string()
|
||||||
|
);
|
||||||
|
case 'hash_hmac':
|
||||||
|
default:
|
||||||
|
$hash = hash_hmac($algorithm, $msg, $key, true);
|
||||||
|
if (function_exists('hash_equals')) {
|
||||||
|
return hash_equals($signature, $hash);
|
||||||
|
}
|
||||||
|
$len = min(static::safeStrlen($signature), static::safeStrlen($hash));
|
||||||
|
|
||||||
|
$status = 0;
|
||||||
|
for ($i = 0; $i < $len; $i++) {
|
||||||
|
$status |= (ord($signature[$i]) ^ ord($hash[$i]));
|
||||||
|
}
|
||||||
|
$status |= (static::safeStrlen($signature) ^ static::safeStrlen($hash));
|
||||||
|
|
||||||
|
return ($status === 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode a JSON string into a PHP object.
|
||||||
|
*
|
||||||
|
* @param string $input JSON string
|
||||||
|
*
|
||||||
|
* @return object Object representation of JSON string
|
||||||
|
*
|
||||||
|
* @throws DomainException Provided string was invalid JSON
|
||||||
|
*/
|
||||||
|
public static function jsonDecode($input)
|
||||||
|
{
|
||||||
|
if (version_compare(PHP_VERSION, '5.4.0', '>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) {
|
||||||
|
/** In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you
|
||||||
|
* to specify that large ints (like Steam Transaction IDs) should be treated as
|
||||||
|
* strings, rather than the PHP default behaviour of converting them to floats.
|
||||||
|
*/
|
||||||
|
$obj = json_decode($input, false, 512, JSON_BIGINT_AS_STRING);
|
||||||
|
} else {
|
||||||
|
/** Not all servers will support that, however, so for older versions we must
|
||||||
|
* manually detect large ints in the JSON string and quote them (thus converting
|
||||||
|
*them to strings) before decoding, hence the preg_replace() call.
|
||||||
|
*/
|
||||||
|
$max_int_length = strlen((string) PHP_INT_MAX) - 1;
|
||||||
|
$json_without_bigints = preg_replace('/:\s*(-?\d{'.$max_int_length.',})/', ': "$1"', $input);
|
||||||
|
$obj = json_decode($json_without_bigints);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (function_exists('json_last_error') && $errno = json_last_error()) {
|
||||||
|
static::handleJsonError($errno);
|
||||||
|
} elseif ($obj === null && $input !== 'null') {
|
||||||
|
throw new DomainException('Null result with non-null input');
|
||||||
|
}
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode a PHP object into a JSON string.
|
||||||
|
*
|
||||||
|
* @param object|array $input A PHP object or array
|
||||||
|
*
|
||||||
|
* @return string JSON representation of the PHP object or array
|
||||||
|
*
|
||||||
|
* @throws DomainException Provided object could not be encoded to valid JSON
|
||||||
|
*/
|
||||||
|
public static function jsonEncode($input)
|
||||||
|
{
|
||||||
|
$json = json_encode($input);
|
||||||
|
if (function_exists('json_last_error') && $errno = json_last_error()) {
|
||||||
|
static::handleJsonError($errno);
|
||||||
|
} elseif ($json === 'null' && $input !== null) {
|
||||||
|
throw new DomainException('Null result with non-null input');
|
||||||
|
}
|
||||||
|
return $json;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode a string with URL-safe Base64.
|
||||||
|
*
|
||||||
|
* @param string $input A Base64 encoded string
|
||||||
|
*
|
||||||
|
* @return string A decoded string
|
||||||
|
*/
|
||||||
|
public static function urlsafeB64Decode($input)
|
||||||
|
{
|
||||||
|
$remainder = strlen($input) % 4;
|
||||||
|
if ($remainder) {
|
||||||
|
$padlen = 4 - $remainder;
|
||||||
|
$input .= str_repeat('=', $padlen);
|
||||||
|
}
|
||||||
|
return base64_decode(strtr($input, '-_', '+/'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode a string with URL-safe Base64.
|
||||||
|
*
|
||||||
|
* @param string $input The string you want encoded
|
||||||
|
*
|
||||||
|
* @return string The base64 encode of what you passed in
|
||||||
|
*/
|
||||||
|
public static function urlsafeB64Encode($input)
|
||||||
|
{
|
||||||
|
return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to create a JSON error.
|
||||||
|
*
|
||||||
|
* @param int $errno An error number from json_last_error()
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private static function handleJsonError($errno)
|
||||||
|
{
|
||||||
|
$messages = array(
|
||||||
|
JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
|
||||||
|
JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON',
|
||||||
|
JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
|
||||||
|
JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON',
|
||||||
|
JSON_ERROR_UTF8 => 'Malformed UTF-8 characters' //PHP >= 5.3.3
|
||||||
|
);
|
||||||
|
throw new DomainException(
|
||||||
|
isset($messages[$errno])
|
||||||
|
? $messages[$errno]
|
||||||
|
: 'Unknown JSON error: ' . $errno
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the number of bytes in cryptographic strings.
|
||||||
|
*
|
||||||
|
* @param string
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private static function safeStrlen($str)
|
||||||
|
{
|
||||||
|
if (function_exists('mb_strlen')) {
|
||||||
|
return mb_strlen($str, '8bit');
|
||||||
|
}
|
||||||
|
return strlen($str);
|
||||||
|
}
|
||||||
|
}
|
||||||
79
libs/hs256.php
Normal file
79
libs/hs256.php
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function base64UrlEncode(string $data): string
|
||||||
|
{
|
||||||
|
$urlSafeData = strtr(base64_encode($data), '+/', '-_');
|
||||||
|
return rtrim($urlSafeData, '=');
|
||||||
|
}
|
||||||
|
|
||||||
|
function base64UrlDecode(string $data): string
|
||||||
|
{
|
||||||
|
$urlUnsafeData = strtr($data, '-_', '+/');
|
||||||
|
$paddedData = str_pad($urlUnsafeData, strlen($data) % 4, '=', STR_PAD_RIGHT);
|
||||||
|
return base64_decode($paddedData);
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateJWT(
|
||||||
|
string $algo,
|
||||||
|
array $header,
|
||||||
|
array $payload,
|
||||||
|
string $secret
|
||||||
|
): string {
|
||||||
|
$headerEncoded = base64UrlEncode(json_encode($header));
|
||||||
|
|
||||||
|
$payloadEncoded = base64UrlEncode(json_encode($payload));
|
||||||
|
|
||||||
|
// Delimit with period (.)
|
||||||
|
$dataEncoded = "$headerEncoded.$payloadEncoded";
|
||||||
|
|
||||||
|
$rawSignature = hash_hmac($algo, $dataEncoded, $secret, true);
|
||||||
|
|
||||||
|
$signatureEncoded = base64UrlEncode($rawSignature);
|
||||||
|
|
||||||
|
// Delimit with second period (.)
|
||||||
|
$jwt = "$dataEncoded.$signatureEncoded";
|
||||||
|
|
||||||
|
return $jwt;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Highly confidential
|
||||||
|
$secret = 'HIGHLY CONFIDENTIAL SECRET KEY SAMOFALOV';
|
||||||
|
|
||||||
|
// JWT Header
|
||||||
|
$header = [
|
||||||
|
'alg' => 'HS256',
|
||||||
|
'typ' => 'JWT',
|
||||||
|
];
|
||||||
|
|
||||||
|
// JWT Payload data
|
||||||
|
// $payload = [
|
||||||
|
// 'sub' => '1234567890',
|
||||||
|
// 'name' => 'John Doe',
|
||||||
|
// 'admin' => true,
|
||||||
|
// ];
|
||||||
|
|
||||||
|
// Create the JWT
|
||||||
|
// $jwt = generateJWT('sha256', $header, $payload, $secret);
|
||||||
|
//var_dump($jwt); // string(149) "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.6pteLozCETeYDL9Dgm-k4INQ1oEsUf0nFy8Tn2OIxgo"
|
||||||
|
|
||||||
|
|
||||||
|
// if (strlen($jwtToken)!==0) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
function verifyJWT(string $algo, string $jwt, string $secret): bool
|
||||||
|
{
|
||||||
|
list($headerEncoded, $payloadEncoded, $signatureEncoded) = explode('.', $jwt);
|
||||||
|
|
||||||
|
$dataEncoded = "$headerEncoded.$payloadEncoded";
|
||||||
|
|
||||||
|
$signature = base64UrlDecode($signatureEncoded);
|
||||||
|
|
||||||
|
$rawSignature = hash_hmac($algo, $dataEncoded, $secret, true);
|
||||||
|
|
||||||
|
return hash_equals($rawSignature, $signature);
|
||||||
|
}
|
||||||
21
modules/BOFHeatPhase/BOFHeatPhase.php
Normal file
21
modules/BOFHeatPhase/BOFHeatPhase.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace API;
|
||||||
|
|
||||||
|
trait BOFHeatPhase
|
||||||
|
{
|
||||||
|
public function getData_BOFHeatPhase($params)
|
||||||
|
{
|
||||||
|
$query = "EXEC [Level3_KKC].[dbo].[BOFHeatPhase]
|
||||||
|
@BD = '".$params['dateStart']."',
|
||||||
|
@ED = '".$params['dateEnd']."'";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
public function getData_BOFHeatPhaseProstoi($params)
|
||||||
|
{
|
||||||
|
$query = "EXEC [Level3_KKC].[dbo].[BOFHeatPhaseProstoi]
|
||||||
|
@BD = '".$params['dateStart']."',
|
||||||
|
@ED = '".$params['dateEnd']."'";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
}
|
||||||
15
modules/BOFHeatPhaseAllStatus/BOFHeatPhaseAllStatus.php
Normal file
15
modules/BOFHeatPhaseAllStatus/BOFHeatPhaseAllStatus.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace API;
|
||||||
|
|
||||||
|
trait BOFHeatPhaseAllStatus
|
||||||
|
{
|
||||||
|
public function getData_BOFHeatPhaseAllStatus($params)
|
||||||
|
{
|
||||||
|
$q=1;
|
||||||
|
$query = "EXEC [Level3_KKC].[dbo].[BOFHeatPhase]
|
||||||
|
@BD = '".$params['dateStart']."',
|
||||||
|
@ED = '".$params['dateEnd']."'";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
}
|
||||||
111
modules/BOFReport/BOFReport.php
Normal file
111
modules/BOFReport/BOFReport.php
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace API;
|
||||||
|
|
||||||
|
trait BOFReport
|
||||||
|
{
|
||||||
|
public function getData_BOFReportSample_A1($params)
|
||||||
|
{
|
||||||
|
$query = "EXEC [Production].[dbo].[BOFReport_ReportIndexBof]
|
||||||
|
@dateStart = '".$params['dateStart']."',
|
||||||
|
@dateEnd = '".$params['dateEnd']."',
|
||||||
|
@aggID = '".$params['aggID']."'";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
public function getData_BOFReportAvgData_Marka($params)
|
||||||
|
{
|
||||||
|
$query = "EXEC [Production].[dbo].[BOFReport_ReportIndexBofMarka]
|
||||||
|
@dateStart = '".$params['dateStart']."',
|
||||||
|
@dateEnd = '".$params['dateEnd']."',
|
||||||
|
@aggID = '".$params['aggID']."'";
|
||||||
|
select_ru($query);
|
||||||
|
}
|
||||||
|
public function getDataSetpoints_BOFReportAvgData_Marka()
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM [Production].[dbo].[BofChartSetpoints]";
|
||||||
|
select_ru($query);
|
||||||
|
}
|
||||||
|
public function getData_BOFReportSample_A2($params)
|
||||||
|
{
|
||||||
|
$query = "EXEC [Production].[dbo].[BOFReport_ReportIndexBofDaily]
|
||||||
|
@dateStart = '".$params['dateStart']."',
|
||||||
|
@dateEnd = '".$params['dateEnd']."',
|
||||||
|
@aggID = '".$params['aggID']."'";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
public function getData_BOFReportSample_B1($params)
|
||||||
|
{
|
||||||
|
|
||||||
|
$query = "EXEC [Production].[dbo].[BOFReport_ReportMaterials]
|
||||||
|
@ds = '".$params['dateStart']."',
|
||||||
|
@de = '".$params['dateEnd']."'";
|
||||||
|
select_ru($query);
|
||||||
|
}
|
||||||
|
public function getData_BOFReportSample_C1($params)
|
||||||
|
{
|
||||||
|
$query = "EXEC [Production].[dbo].[BOFReport_GetDataForPerformanceIndicators]
|
||||||
|
@ds = '".$params['dateStart']."',
|
||||||
|
@de = '".$params['dateEnd']."',
|
||||||
|
@agg = 0";
|
||||||
|
select_ru($query);
|
||||||
|
}
|
||||||
|
public function getData_BOFReportSample_D1($params)
|
||||||
|
{
|
||||||
|
$query = "EXEC [Production].[dbo].[BOFReport_GetDataForAnalizHeatsReport]
|
||||||
|
@ds = '".$params['dateStart']."',
|
||||||
|
@de = '".$params['dateEnd']."'";
|
||||||
|
select_ru($query);
|
||||||
|
}
|
||||||
|
public function getData_BOFReportSample_D1_countHets($params)
|
||||||
|
{
|
||||||
|
$query = "EXEC [Production].[dbo].[BOFReport_GetCountAndPercentCheckedHeatsFromAllHeats]
|
||||||
|
@ds = '".$params['dateStart']."',
|
||||||
|
@de = '".$params['dateEnd']."'";
|
||||||
|
select_ru($query);
|
||||||
|
}
|
||||||
|
public function getData_BOFReportSample_D1_sampleCounts($params)
|
||||||
|
{
|
||||||
|
$query = "EXEC [Production].[dbo].[BOFReport_GetCountsAndPercentForAnalizHeatsReport]
|
||||||
|
@ds = '".$params['dateStart']."',
|
||||||
|
@de = '".$params['dateEnd']."'";
|
||||||
|
select_ru($query);
|
||||||
|
}
|
||||||
|
public function getData_BOFReportSample_D1_master($params)
|
||||||
|
{
|
||||||
|
$query = "EXEC [Production].[dbo].[BOFReport_GetCountCheckedHeatsGroupBOFMaster]
|
||||||
|
@ds = '".$params['dateStart']."',
|
||||||
|
@de = '".$params['dateEnd']."'";
|
||||||
|
select_ru($query);
|
||||||
|
}
|
||||||
|
public function getData_BOFReportSample_D1_operator($params)
|
||||||
|
{
|
||||||
|
$query = "EXEC [Production].[dbo].[BOFReport_GetCountCheckedHeatsGroupBOFOperator]
|
||||||
|
@ds = '".$params['dateStart']."',
|
||||||
|
@de = '".$params['dateEnd']."'";
|
||||||
|
select_ru($query);
|
||||||
|
}
|
||||||
|
public function getData_BOFReportSample_D1_shift($params)
|
||||||
|
{
|
||||||
|
$query = "EXEC [Production].[dbo].[BOFReport_GetCountCheckedHeatsGroupShiftTeamNo]
|
||||||
|
@ds = '".$params['dateStart']."',
|
||||||
|
@de = '".$params['dateEnd']."'";
|
||||||
|
select_ru($query);
|
||||||
|
}
|
||||||
|
public function getData_BOFReportSample_D1_avgData($params)
|
||||||
|
{
|
||||||
|
$query = "EXEC [Production].[dbo].[BOFReport_GetAVGDataForAnalizHeatsReport]
|
||||||
|
@ds = '".$params['dateStart']."',
|
||||||
|
@de = '".$params['dateEnd']."'";
|
||||||
|
select_ru($query);
|
||||||
|
}
|
||||||
|
public function getData_BOFMainUseConfig($params)
|
||||||
|
{
|
||||||
|
$query = "EXEC [Production].[dbo].[Raport_BOF_MainUseConfig]
|
||||||
|
@dateStart = '".$params['dateStart']."',
|
||||||
|
@dateEnd = '".$params['dateEnd']."',
|
||||||
|
@aggID = '".$params['aggID']."'";
|
||||||
|
select_ru($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
119
modules/HMCarReport/HMCarReport.php
Normal file
119
modules/HMCarReport/HMCarReport.php
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace API;
|
||||||
|
|
||||||
|
trait HMCarReport
|
||||||
|
{
|
||||||
|
public function getData_HMCarReport($params)
|
||||||
|
{
|
||||||
|
$query = "
|
||||||
|
SET NOCOUNT ON
|
||||||
|
SELECT
|
||||||
|
PBHR.HEAT_START
|
||||||
|
,HB.[HM_Ladle] as [КЧ]
|
||||||
|
,HB.[TorpNO] as [МП350 №]
|
||||||
|
,HB.[DC_Tap_NO] as [Номер выпуска ДЦ]
|
||||||
|
,HB.[HEAT_NUMBER] as [Номер плавки ККЦ]
|
||||||
|
,CAST(HB.[RL_Tare]/1000 as decimal(5,2)) as [Тара, т]
|
||||||
|
,CAST(HB.[RL_Gross]/1000 as decimal(5,2)) as [Брутто, т]
|
||||||
|
,CAST(HB.[RL_Net]/1000 as decimal(5,2)) as [Нетто, т]
|
||||||
|
,CAST(round([RL_Net]-([RL_Net]*0.6/100),0)/1000 as decimal(5,2)) as [Вес со снятием, т]
|
||||||
|
,0.6 as [Снятие, %]
|
||||||
|
,CAST(HB.[AFTDS_CRANEWT_Tare]/1000 as decimal(5,2)) as [Тара, т ]
|
||||||
|
,CAST(HB.[AFTDS_CRANEWT_Gross]/1000 as decimal(5,2)) as [Брутто, т ]
|
||||||
|
,CAST(HB.[AFTDS_CRANEWT_Net]/1000 as decimal(5,2)) as [Нетто, т ]
|
||||||
|
,CAST(HB.[DS_LOSS_wt] as decimal(5,2)) as [Снятие на десульфурации, т]
|
||||||
|
FROM [PasportBOF].[dbo].[PASPORT_BOFHEATREPORT] PBHR
|
||||||
|
INNER JOIN [Level3_KKC].[dbo].[HM_BALANCE] HB
|
||||||
|
ON PBHR.HEAT_NUMBER=HB.HEAT_NUMBER
|
||||||
|
WHERE (ISNULL(DELETED,0)=0) AND
|
||||||
|
(HEAT_START >= '".$params['dateStart']."')
|
||||||
|
AND (HEAT_END < '".$params['dateEnd']."')
|
||||||
|
ORDER BY [SHOW_AGGREGATE_ID], [HEAT_START]";
|
||||||
|
select($query);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// $query = "
|
||||||
|
// SET NOCOUNT ON
|
||||||
|
// DECLARE
|
||||||
|
// @BD DATETIME = '06.03.2024',
|
||||||
|
// @ED DATETIME = '08.03.2024'
|
||||||
|
// SELECT
|
||||||
|
// PBHR.HEAT_START
|
||||||
|
// ,HB.[HM_Ladle] as [КЧ]
|
||||||
|
// ,HB.[TorpNO] as [МП350 №]
|
||||||
|
// ,HB.[DC_Tap_NO] as [Номер выпуска ДЦ]
|
||||||
|
// ,HB.[HEAT_NUMBER] as [Номер плавки ККЦ]
|
||||||
|
// ,HB.[RL_Tare] as [Тара, т]
|
||||||
|
// ,HB.[RL_Gross] as [Брутто, т]
|
||||||
|
// ,HB.[RL_Net] as [Нетто, т]
|
||||||
|
// ,round([RL_Net]-([RL_Net]*0.6/100),0) as [Вес со снятием, т]
|
||||||
|
// ,0.6 as [Снятие, %]
|
||||||
|
// ,HB.[AFTDS_CRANEWT_Tare] as [Тара, т ]
|
||||||
|
// ,HB.[AFTDS_CRANEWT_Gross] as [Брутто, т ]
|
||||||
|
// ,HB.[AFTDS_CRANEWT_Net] as [Нетто, т ]
|
||||||
|
// ,HB.[DS_LOSS_wt] as [Снятие на десульфурации, т]
|
||||||
|
// FROM [PasportBOF].[dbo].[PASPORT_BOFHEATREPORT] PBHR
|
||||||
|
// INNER JOIN [Level3_KKC].[dbo].[HM_BALANCE] HB
|
||||||
|
// ON PBHR.HEAT_NUMBER=HB.HEAT_NUMBER
|
||||||
|
// WHERE (ISNULL(DELETED,0)=0) AND
|
||||||
|
// (HEAT_START >= '".$params['dateStart']."')
|
||||||
|
// AND (HEAT_START < '".$params['dateEnd']."')
|
||||||
|
// ORDER BY [SHOW_AGGREGATE_ID], [HEAT_START]";
|
||||||
|
// select($query);
|
||||||
|
|
||||||
|
|
||||||
|
// $query = "
|
||||||
|
// SELECT
|
||||||
|
// [HM_Ladle] as [КЧ]
|
||||||
|
// ,[TorpNO] as [МП350 №]
|
||||||
|
// ,[DC_Tap_NO] as [Номер выпуска ДЦ]
|
||||||
|
// ,[HEAT_NUMBER] as [Номер плавки ККЦ]
|
||||||
|
// ,[RL_Tare] as [Тара, т]
|
||||||
|
// ,[RL_Gross] as [Брутто, т]
|
||||||
|
// ,[RL_Net] as [Нетто, т]
|
||||||
|
// ,round([RL_Net]-([RL_Net]*0.6/100),0) as [Вес со снятием, т]
|
||||||
|
// ,0.6 as [Снятие, %]
|
||||||
|
// ,[AFTDS_CRANEWT_Tare] as [Тара, т ]
|
||||||
|
// ,[AFTDS_CRANEWT_Gross] as [Брутто, т ]
|
||||||
|
// ,[AFTDS_CRANEWT_Net] as [Нетто, т ]
|
||||||
|
// ,[DS_LOSS_wt] as [Снятие на десульфурации, т]
|
||||||
|
// FROM [Level3_KKC].[dbo].[HM_BALANCE]
|
||||||
|
// Where [RL_WT_TIME]>='".$params['dateStart']."' and [RL_WT_TIME] <='".$params['dateEnd']."'";
|
||||||
|
// select($query);
|
||||||
|
|
||||||
|
}
|
||||||
|
public function getData_HMCarReport_SUM($params)
|
||||||
|
{
|
||||||
|
$query = "
|
||||||
|
SELECT
|
||||||
|
sum([RL_Tare]) [RL_Tare]
|
||||||
|
,sum([RL_Gross])[RL_Gross]
|
||||||
|
,sum([RL_Net]) [RL_Net]
|
||||||
|
,sum(round([RL_Net]-([RL_Net]*0.6/100),0)) [RL_Net1]
|
||||||
|
,sum([AFTDS_CRANEWT_Tare])[AFTDS_CRANEWT_Tare]
|
||||||
|
,sum([AFTDS_CRANEWT_Gross]) [AFTDS_CRANEWT_Gross]
|
||||||
|
,sum([AFTDS_CRANEWT_Net])[AFTDS_CRANEWT_Net]
|
||||||
|
,sum([DS_LOSS_wt]) [DS_LOSS_wt]
|
||||||
|
FROM [Level3_KKC].[dbo].[HM_BALANCE]
|
||||||
|
Where [RL_WT_TIME]>='".$params['dateStart']."' and [RL_WT_TIME] <='".$params['dateEnd']."'";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
public function getData_HMCarReport_AVG($params)
|
||||||
|
{
|
||||||
|
$query = "
|
||||||
|
SELECT
|
||||||
|
avg([RL_Tare]) [RL_Tare]
|
||||||
|
,avg([RL_Gross])[RL_Gross]
|
||||||
|
,avg([RL_Net]) [RL_Net]
|
||||||
|
,avg(round([RL_Net]-([RL_Net]*0.6/100),0)) [RL_Net1]
|
||||||
|
,avg([AFTDS_CRANEWT_Tare])[AFTDS_CRANEWT_Tare]
|
||||||
|
,avg([AFTDS_CRANEWT_Gross]) [AFTDS_CRANEWT_Gross]
|
||||||
|
,avg([AFTDS_CRANEWT_Net])[AFTDS_CRANEWT_Net]
|
||||||
|
,avg([DS_LOSS_wt]) [DS_LOSS_wt]
|
||||||
|
FROM [Level3_KKC].[dbo].[HM_BALANCE]
|
||||||
|
Where [RL_WT_TIME]>='".$params['dateStart']."' and [RL_WT_TIME] <='".$params['dateEnd']."'";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
}
|
||||||
15
modules/HM_DC/HM_DC.php
Normal file
15
modules/HM_DC/HM_DC.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace API;
|
||||||
|
|
||||||
|
trait HM_DC
|
||||||
|
{
|
||||||
|
public function getData($params)
|
||||||
|
{
|
||||||
|
$d=1;
|
||||||
|
$query = "SELECT
|
||||||
|
*
|
||||||
|
FROM [Level3_KKC].[dbo].[HM_DC] WHERE [Date] BETWEEN '".$params['dateStart']."' AND '".$params['dateEnd']."'";
|
||||||
|
select_ru($query);
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
modules/KKC.rar
Normal file
BIN
modules/KKC.rar
Normal file
Binary file not shown.
50
modules/KKC/app.php
Normal file
50
modules/KKC/app.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace API;
|
||||||
|
|
||||||
|
trait app
|
||||||
|
{
|
||||||
|
public function appUser($params)
|
||||||
|
{
|
||||||
|
//WHERE [ip]='".$_SERVER['REMOTE_ADDR']."'
|
||||||
|
$query = "SELECT TOP 1 [id]
|
||||||
|
,[ip]
|
||||||
|
,[user_desc]
|
||||||
|
,[isAdmin]
|
||||||
|
,[isBan]
|
||||||
|
FROM [SITE].[dbo].[kkc_users]
|
||||||
|
WHERE [ip]='".$_SERVER['REMOTE_ADDR']."'
|
||||||
|
AND isBan <> 1";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function appHeadersById($params)
|
||||||
|
{
|
||||||
|
if ($params['isAdmin']) {
|
||||||
|
$query = "SELECT *
|
||||||
|
FROM [SITE].[dbo].[kkc_headers]
|
||||||
|
ORDER BY id";
|
||||||
|
} else {
|
||||||
|
$query = "SELECT * FROM [SITE].[dbo].[get_headers_by_user_id] ('".$params['id_user']."')";
|
||||||
|
}
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function appAllSubheaders($params)
|
||||||
|
{
|
||||||
|
$query = "SELECT *
|
||||||
|
FROM [SITE].[dbo].[kkc_headers]
|
||||||
|
WHERE isHeader is not null
|
||||||
|
and idSubHeader is null
|
||||||
|
";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function appVisits($params)
|
||||||
|
{
|
||||||
|
$query = "SELECT count([isVisit]) countVisits
|
||||||
|
FROM [SITE].[dbo].[kkc_stat]
|
||||||
|
where [isVisit]=1";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
}
|
||||||
300
modules/KKC/dashboard.php
Normal file
300
modules/KKC/dashboard.php
Normal file
@@ -0,0 +1,300 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace API;
|
||||||
|
|
||||||
|
trait dashboard
|
||||||
|
{
|
||||||
|
////////////////////////////STAT/////////////////////////////////////////
|
||||||
|
public function dashboardStat($params)
|
||||||
|
{
|
||||||
|
$query = "SELECT
|
||||||
|
convert(varchar, date, 104)+' '+convert(varchar, cast(date as datetime),108) as date
|
||||||
|
,ip
|
||||||
|
,user_desc
|
||||||
|
,title
|
||||||
|
,path
|
||||||
|
FROM [SITE].[dbo].[kkc_stat] s
|
||||||
|
INNER JOIN [SITE].[dbo].[kkc_users] u
|
||||||
|
ON s.id_user=u.id
|
||||||
|
where [isVisit] is null
|
||||||
|
and date>='".$params['dateStart']."' and date <='".$params['dateEnd']." 23:59:59'
|
||||||
|
order by date desc";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
public function dashboardStatCounts($params)
|
||||||
|
{
|
||||||
|
$query = "SELECT
|
||||||
|
count(id) as visit_counts
|
||||||
|
FROM [SITE].[dbo].[kkc_stat]
|
||||||
|
where [isVisit]=1
|
||||||
|
and DATEDIFF(day, date, GETDATE()) = 0
|
||||||
|
union all
|
||||||
|
SELECT
|
||||||
|
count(id) as visit_counts
|
||||||
|
FROM [SITE].[dbo].[kkc_stat]
|
||||||
|
where [isVisit]=1
|
||||||
|
and DATEDIFF(day, date, GETDATE()) = 1
|
||||||
|
union all
|
||||||
|
SELECT
|
||||||
|
count(id) as visit_counts
|
||||||
|
FROM [SITE].[dbo].[kkc_stat]
|
||||||
|
where [isVisit]=1
|
||||||
|
and DATEDIFF(day, date, GETDATE()) <= 7
|
||||||
|
union all
|
||||||
|
SELECT
|
||||||
|
count(id) as visit_counts
|
||||||
|
FROM [SITE].[dbo].[kkc_stat]
|
||||||
|
where [isVisit]=1
|
||||||
|
and DATEDIFF(month, date, GETDATE()) = 0
|
||||||
|
union all
|
||||||
|
SELECT
|
||||||
|
count(id) as visit_counts
|
||||||
|
FROM [SITE].[dbo].[kkc_stat]
|
||||||
|
where [isVisit]=1
|
||||||
|
and DATEDIFF(month, date, GETDATE()) = 1
|
||||||
|
union all
|
||||||
|
SELECT
|
||||||
|
count(id) as visit_counts
|
||||||
|
FROM [SITE].[dbo].[kkc_stat]
|
||||||
|
where [isVisit]=1";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
////////////////////////////ITEMS/////////////////////////////////////////
|
||||||
|
public function dashboardItemsAllHeaders($params)
|
||||||
|
{
|
||||||
|
$query = "SELECT *
|
||||||
|
FROM [SITE].[dbo].[kkc_headers]
|
||||||
|
ORDER BY id";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
public function dashboardItemsAdd($params)
|
||||||
|
{
|
||||||
|
$convName = iconv('UTF-8', 'windows-1251', $params['data']['name']);
|
||||||
|
global $conn;
|
||||||
|
$query = "SET NOCOUNT ON
|
||||||
|
DECLARE @insert_id int
|
||||||
|
INSERT INTO [SITE].[dbo].[kkc_headers]
|
||||||
|
VALUES(".$params['data']['idSubHeader'].",
|
||||||
|
".$params['data']['parent'].",
|
||||||
|
'$convName',
|
||||||
|
'".$params['data']['path']."',
|
||||||
|
'".$params['data']['pathFrame']."',
|
||||||
|
".$params['data']['isFrame'].",
|
||||||
|
".$params['data']['isHeader'].")
|
||||||
|
SELECT SCOPE_IDENTITY() as insert_id;
|
||||||
|
SET @insert_id=(SELECT SCOPE_IDENTITY())";
|
||||||
|
$result = sqlsrv_query($conn, $query);
|
||||||
|
sqlsrv_fetch($result);
|
||||||
|
|
||||||
|
if ($params['data']['isFrame']===1) {
|
||||||
|
$id_insert = sqlsrv_get_field($result, 0);
|
||||||
|
$query = "UPDATE [SITE].[dbo].[kkc_headers]
|
||||||
|
SET path='".$params['data']['path']."'+'$id_insert'
|
||||||
|
WHERE id=$id_insert";
|
||||||
|
$result = sqlsrv_query($conn, $query);
|
||||||
|
sqlsrv_fetch($result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function dashboardItemsEdit($params)
|
||||||
|
{
|
||||||
|
$convName = iconv('UTF-8', 'windows-1251', $params['data']['name']);
|
||||||
|
$query = "UPDATE [SITE].[dbo].[kkc_headers]
|
||||||
|
SET name='$convName',
|
||||||
|
path='".$params['data']['path']."',
|
||||||
|
pathFrame='".$params['data']['pathFrame']."'
|
||||||
|
WHERE id=".$params['data']['id']."";
|
||||||
|
update($query);
|
||||||
|
}
|
||||||
|
public function dashboardItemsDelete($params)
|
||||||
|
{
|
||||||
|
$query = "DELETE [SITE].[dbo].[kkc_groups_roles]
|
||||||
|
WHERE id_header in
|
||||||
|
(select id from [SITE].[dbo].[kkc_headers]
|
||||||
|
where idSubHeader=".$params['data']['id'].")
|
||||||
|
|
||||||
|
DELETE [SITE].[dbo].[kkc_groups_roles]
|
||||||
|
WHERE id_header=".$params['data']['id']."
|
||||||
|
|
||||||
|
DELETE [SITE].[dbo].[kkc_headers]
|
||||||
|
WHERE id=".$params['data']['id']."
|
||||||
|
OR idSubHeader=".$params['data']['id']."
|
||||||
|
";
|
||||||
|
delete($query);
|
||||||
|
}
|
||||||
|
////////////////////////////USERS/////////////////////////////////////////
|
||||||
|
public function dashboardUsers($params)
|
||||||
|
{
|
||||||
|
$query = "SELECT [id]
|
||||||
|
,[ip]
|
||||||
|
,[user_desc]
|
||||||
|
,[isAdmin]
|
||||||
|
,[isBan]
|
||||||
|
FROM [SITE].[dbo].[kkc_users]";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dashboardUsersWithoutAdmin($params)
|
||||||
|
{
|
||||||
|
$query = "SELECT [id]
|
||||||
|
,[ip]
|
||||||
|
,[user_desc]
|
||||||
|
,[isAdmin]
|
||||||
|
,[isBan]
|
||||||
|
FROM [SITE].[dbo].[kkc_users]
|
||||||
|
WHERE isAdmin=0 and isBan=0";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dashboardGroups($params)
|
||||||
|
{
|
||||||
|
$query = "SELECT
|
||||||
|
g.id,
|
||||||
|
g.name,
|
||||||
|
users.id as user_id,
|
||||||
|
users.user_desc as user_name,
|
||||||
|
users.ip as user_ip,
|
||||||
|
users.isAdmin as isAdmin
|
||||||
|
FROM [SITE].[dbo].[kkc_groups] g
|
||||||
|
inner join [SITE].[dbo].[kkc_users_groups] ug on
|
||||||
|
g.id=ug.group_id
|
||||||
|
inner join [SITE].[dbo].[kkc_users] users on
|
||||||
|
ug.user_id=users.id";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dashboardUsersAdmin($params)
|
||||||
|
{
|
||||||
|
$query = "UPDATE [SITE].[dbo].[kkc_users]
|
||||||
|
SET isAdmin='".$params['data']['value']."'
|
||||||
|
WHERE id=".$params['data']['id']."";
|
||||||
|
update($query);
|
||||||
|
}
|
||||||
|
public function dashboardUsersBan($params)
|
||||||
|
{
|
||||||
|
$query = "UPDATE [SITE].[dbo].[kkc_users]
|
||||||
|
SET isBan='".$params['data']['value']."'
|
||||||
|
WHERE id=".$params['data']['id']."";
|
||||||
|
update($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function dashboardUsersAdd($params)
|
||||||
|
{
|
||||||
|
$name = iconv('UTF-8', 'windows-1251', $params['data']['user_desc']);
|
||||||
|
$query = "INSERT INTO [SITE].[dbo].[kkc_users]
|
||||||
|
VALUES('".$params['data']['ip']."',
|
||||||
|
'$name',
|
||||||
|
0,0)";
|
||||||
|
insert($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dashboardUsersEdit($params)
|
||||||
|
{
|
||||||
|
$name = iconv('UTF-8', 'windows-1251', $params['data']['user_desc']);
|
||||||
|
$query = "UPDATE [SITE].[dbo].[kkc_users]
|
||||||
|
SET [user_desc]='$name',
|
||||||
|
ip='".$params['data']['ip']."'
|
||||||
|
WHERE id=".$params['data']['id']."";
|
||||||
|
update($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dashboardUsersDelete($params)
|
||||||
|
{
|
||||||
|
$query = "DELETE [SITE].[dbo].[kkc_users]
|
||||||
|
WHERE id=".$params['data']['id']."
|
||||||
|
|
||||||
|
DELETE [SITE].[dbo].[kkc_users_groups]
|
||||||
|
WHERE [user_id]=".$params['data']['id']."";
|
||||||
|
delete($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////GROUPS//////////////////////////////////////////////////
|
||||||
|
public function dashboardGroupsAll($params)
|
||||||
|
{
|
||||||
|
$query = "SELECT g.id,
|
||||||
|
g.name,
|
||||||
|
count(ug.id) as group_count
|
||||||
|
FROM [SITE].[dbo].[kkc_groups] g
|
||||||
|
left join [SITE].[dbo].[kkc_users_groups] ug on
|
||||||
|
g.id=ug.group_id
|
||||||
|
left join [SITE].[dbo].[kkc_users] users on
|
||||||
|
ug.user_id=users.id
|
||||||
|
group by g.id, g.name";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dashboardUsersGroupsAdd($params)
|
||||||
|
{
|
||||||
|
$name = iconv('UTF-8', 'windows-1251', $params['data']['name']);
|
||||||
|
$query = "INSERT INTO [SITE].[dbo].[kkc_groups]
|
||||||
|
VALUES('$name')";
|
||||||
|
insert($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dashboardUsersGroupsEdit($params)
|
||||||
|
{
|
||||||
|
$name = iconv('UTF-8', 'windows-1251', $params['data']['name']);
|
||||||
|
$query = "UPDATE [SITE].[dbo].[kkc_groups]
|
||||||
|
SET [name]='$name'
|
||||||
|
WHERE id=".$params['data']['id']."";
|
||||||
|
update($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dashboardUsersGroupsDelete($params)
|
||||||
|
{
|
||||||
|
$query = "DELETE [SITE].[dbo].[kkc_groups]
|
||||||
|
WHERE id=".$params['data']['id']."
|
||||||
|
|
||||||
|
DELETE [SITE].[dbo].[kkc_users_groups]
|
||||||
|
WHERE [group_id]=".$params['data']['id']."
|
||||||
|
|
||||||
|
DELETE [SITE].[dbo].[kkc_groups_roles]
|
||||||
|
WHERE [id_group]=".$params['data']['id']."
|
||||||
|
";
|
||||||
|
delete($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////ROLES//////////////////////////////////////////////////
|
||||||
|
public function dashboardRoles($params)
|
||||||
|
{
|
||||||
|
$query = "SELECT [id]
|
||||||
|
,[id_group]
|
||||||
|
,[id_header]
|
||||||
|
FROM [SITE].[dbo].[kkc_groups_roles]";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dashboardGroupsCheckUser($params)
|
||||||
|
{
|
||||||
|
$query = "INSERT INTO [SITE].[dbo].[kkc_users_groups]
|
||||||
|
VALUES(".$params['data']['userID'].",
|
||||||
|
".$params['data']['groupID'].")";
|
||||||
|
insert($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dashboardGroupsUnCheckUser($params)
|
||||||
|
{
|
||||||
|
$query = "DELETE [SITE].[dbo].[kkc_users_groups]
|
||||||
|
WHERE [user_id] =".$params['data']['userID']."
|
||||||
|
AND [group_id]=".$params['data']['groupID']."";
|
||||||
|
delete($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dashboardRolesDel($params)
|
||||||
|
{
|
||||||
|
$query = "DELETE [SITE].[dbo].[kkc_groups_roles]
|
||||||
|
WHERE [id_group] =".$params['data']['groupId']."";
|
||||||
|
delete($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dashboardRolesAdd($params)
|
||||||
|
{
|
||||||
|
foreach ($params['data']['values'] as $key => $value) {
|
||||||
|
$query = "INSERT INTO [SITE].[dbo].[kkc_groups_roles]
|
||||||
|
VALUES(".$params['data']['groupId'].",
|
||||||
|
".$value['id'].")";
|
||||||
|
insert($query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
256
modules/KKC/mega_report.php
Normal file
256
modules/KKC/mega_report.php
Normal file
@@ -0,0 +1,256 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace API;
|
||||||
|
|
||||||
|
trait mega_report
|
||||||
|
{
|
||||||
|
public function getAllData($params)
|
||||||
|
{
|
||||||
|
$query = "SELECT
|
||||||
|
distinct
|
||||||
|
ctr.REPORT_ID ID
|
||||||
|
,HEAT_NUMBER
|
||||||
|
,DS_HM_LADLE_NUMBER [КЧ]
|
||||||
|
,HM_LADLE_CYCLE [Стойкость КЧ]
|
||||||
|
,DS_SHIFT_TEAM [Бригада ДС]
|
||||||
|
,FIRSTDS_Si [Si до ДС]
|
||||||
|
,FIRSTDS_S [S до ДС]
|
||||||
|
,FIRSTDS_P [P до ДС]
|
||||||
|
,FIRSTDS_Mn [Mn до ДС]
|
||||||
|
,HM_TEMP [T чугуна]
|
||||||
|
,HM_WEIGHT [Вес чугуна]
|
||||||
|
,convert(varchar, cast(CYCLE as smalldatetime),108) as [Цикл ДС]
|
||||||
|
,BRIGADA [№ бригады]
|
||||||
|
,STOIKOST [Стойкость конв.]
|
||||||
|
,MARKA [Марка стали]
|
||||||
|
,convert(varchar, cast(DT as datetime),104)+' '+convert(varchar, cast(DT as datetime),108) [Начало плавки]
|
||||||
|
,convert(varchar, cast(DTEnd as datetime),104)+' '+convert(varchar, cast(DTEnd as datetime),108) [Конец плавки]
|
||||||
|
,convert(varchar, cast(Cycl as smalldatetime),108) [Цикл плавки]
|
||||||
|
,BOF_HM_Weight [Вес чугуна]
|
||||||
|
,SCRAP_Weight [Вес лома]
|
||||||
|
,HEAT_Weight [Вес плавки]
|
||||||
|
,Si [Si чуг]
|
||||||
|
,CTR.S [S чуг]
|
||||||
|
,P [P чуг]
|
||||||
|
,Mn [Mn чуг]
|
||||||
|
,BOF_HM_Temp [T чугуна]
|
||||||
|
,C_p [C стали]
|
||||||
|
,S_p [S стали]
|
||||||
|
,P_p [P стали]
|
||||||
|
,Mn_p [Mn стали]
|
||||||
|
,HEAT_Temp [T стали]
|
||||||
|
,CTR.MgO [MgO шлака]
|
||||||
|
,CTR.FeO [FeO шлака]
|
||||||
|
,Bass [Основность шлака]
|
||||||
|
,LF_TREATMENTNO [№ обработки]
|
||||||
|
,LF_PLANTNO [Позиция]
|
||||||
|
,LF_LADLENO [№ сталь ковша]
|
||||||
|
,LF_MRESISTANCELADLE [Стойкость сталь ковша]
|
||||||
|
,LF_BRIGADANO [Бригада]
|
||||||
|
,LF_MTEMPERATUREBEFORE [Темп. приб]
|
||||||
|
,LF_LASTMEASTEMP [Темп. конечная]
|
||||||
|
,LF_HEATTIME [Время обраб.]
|
||||||
|
,LF_ARCONTIME [Время нагрева]
|
||||||
|
,LF_C
|
||||||
|
,LF_Mn
|
||||||
|
,LF_Si
|
||||||
|
,LF_S
|
||||||
|
,LF_P
|
||||||
|
,LF_Al
|
||||||
|
,LF_Nb
|
||||||
|
,LF_V
|
||||||
|
,LF_B
|
||||||
|
,LF_Cr
|
||||||
|
,LF_Ni
|
||||||
|
,LF_Cu
|
||||||
|
,lf.Al2O3 [Al2O3 шлак]
|
||||||
|
,lf.CaO [CaO шлак]
|
||||||
|
,lf.FeO [FeO шлак]
|
||||||
|
,lf.MgO [MgO шлак]
|
||||||
|
,lf.MnO [MnO шлак]
|
||||||
|
,lf.P2O5 [P2O5 шлак]
|
||||||
|
,lf.S [S шлак]
|
||||||
|
,lf.SiO2 [SiO2 шлак]
|
||||||
|
,CCM_ccm [Мнлз]
|
||||||
|
,CCM_TREATMENTNO [№ обр.]
|
||||||
|
,CCM_Br [Бригада]
|
||||||
|
,CCM_sech1 [Сечение Р1]
|
||||||
|
,CCM_sech2 [Сечение Р2]
|
||||||
|
,CCM_Cikl [Цикл]
|
||||||
|
,CCM_avgSpeedR1 [Скорость Р1 (сред)]
|
||||||
|
,CCM_avgSpeedR2 [Скорость Р2 (сред)]
|
||||||
|
,CCM_powder_str1 [Тип ШОС Р1]
|
||||||
|
,CCM_powder_str2 [Тип ШОС Р2]
|
||||||
|
,CCM_HEAT_IN_CAST [Серия/Плавка в серии]
|
||||||
|
,CCM_tund [Промковш/Плавка в промковше]
|
||||||
|
FROM Level3_KKC.dbo.BOF_CCM_TOTAL_REPORT CTR
|
||||||
|
left join (SELECT distinct lf1.[SLAGANALYSISID]
|
||||||
|
,lf1.[HEATNO]
|
||||||
|
,lf1.[ANALYSISDATE]
|
||||||
|
,lf1.[VALUEELEM1] as Al2O3
|
||||||
|
,lf1.[VALUEELEM2] as CaO
|
||||||
|
,lf1.[VALUEELEM3] as FeO
|
||||||
|
,lf1.[VALUEELEM4] as MgO
|
||||||
|
,lf1.[VALUEELEM5] as MnO
|
||||||
|
,lf1.[VALUEELEM6] as P2O5
|
||||||
|
,lf1.[VALUEELEM7] as S
|
||||||
|
,lf1.[VALUEELEM8] as SiO2
|
||||||
|
FROM [Level3_KKC].[dbo].[QLC_PRO_SLAGANALYSISHEADER_VD_L3] lf1
|
||||||
|
inner join [Level3_KKC].[dbo].[QLC_PRO_SLAGANALYSISHEADER_VD_L3] lf2 on
|
||||||
|
lf1.[SLAGANALYSISID]=lf2.[SLAGANALYSISID]
|
||||||
|
where lf1.[PLANTNO] IN (3,4)
|
||||||
|
and lf1.[SAMPLENO]=(select max([SAMPLENO]) from [Level3_KKC].[dbo].[QLC_PRO_SLAGANALYSISHEADER_VD_L3] where [HEATNO]=lf1.[HEATNO] and [PLANTNO] IN (3,4))) lf
|
||||||
|
on lf.HEATNO=HEAT_NUMBER
|
||||||
|
Where DT>='".$params['dateStart']."' and DT <='".$params['dateEnd']."'
|
||||||
|
--and BOF_AGGREGATE_ID = 1
|
||||||
|
order by HEAT_NUMBER,CCM_ccm,CCM_TREATMENTNO,LF_TREATMENTNO";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
public function getSteelData($params)
|
||||||
|
{
|
||||||
|
$query = "SELECT distinct
|
||||||
|
hm.[HEAT_NUMBER]
|
||||||
|
,[Name] [Установка]
|
||||||
|
,convert(varchar, cast(ANALYSISDATE as datetime),108) as 'Время'
|
||||||
|
,[Sample_number] [№]
|
||||||
|
,[value_1] Fe
|
||||||
|
,[value_2] P
|
||||||
|
,[value_3] S
|
||||||
|
,[value_4] Al
|
||||||
|
,[value_5] Cu
|
||||||
|
,[value_6] Cr
|
||||||
|
,[value_7] N
|
||||||
|
,[value_8] V
|
||||||
|
,[value_9] Nb
|
||||||
|
,[value_10] Ti
|
||||||
|
,[value_11] Sn
|
||||||
|
,[value_12] C
|
||||||
|
,[value_13] Mo
|
||||||
|
,[value_14] Si
|
||||||
|
,[value_15] W
|
||||||
|
,[value_16] Ni
|
||||||
|
,[value_17] Mn
|
||||||
|
,[value_18] Pb
|
||||||
|
,[value_19] Sb
|
||||||
|
,[value_20] B
|
||||||
|
,[value_21] Zr
|
||||||
|
,[value_22] Co
|
||||||
|
,[value_23] [As]
|
||||||
|
,[value_24] Zn
|
||||||
|
,[value_25] Ca
|
||||||
|
from(
|
||||||
|
(select distinct HEAT_NUMBER
|
||||||
|
FROM Level3_KKC.dbo.BOF_CCM_TOTAL_REPORT
|
||||||
|
Where DT>='".$params['dateStart']."' and DT <='".$params['dateEnd']."')) tr
|
||||||
|
left join [ANA_Operator].[dbo].[ANA_ALL_TRU] hm
|
||||||
|
on tr.HEAT_NUMBER=hm.Heat_number
|
||||||
|
where Sample_number<>0
|
||||||
|
and (Name IN ('LF', 'CCM1', 'CCM2', 'VD', 'BOF1', 'BOF2','AS1','AS2', 'DS', 'RL', 'ВАК'))
|
||||||
|
order by hm.HEAT_NUMBER, hm.Sample_number, Name";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
public function getHmData($params)
|
||||||
|
{
|
||||||
|
$query = "SELECT distinct
|
||||||
|
hm.[HEAT_NUMBER]
|
||||||
|
,[Name] [Установка]
|
||||||
|
,convert(varchar, cast(ANALYSISDATE as datetime),108) as 'Время'
|
||||||
|
,[Sample_number] [№]
|
||||||
|
,[value_1] C
|
||||||
|
,[value_2] Si
|
||||||
|
,[value_3] Mn
|
||||||
|
,[value_4] P
|
||||||
|
,[value_5] S
|
||||||
|
,[value_6] Cr
|
||||||
|
,[value_7] Mo
|
||||||
|
,[value_8] Ni
|
||||||
|
,[value_9] V
|
||||||
|
,[value_10] Al
|
||||||
|
,[value_11] Cu
|
||||||
|
,[value_12] Ti
|
||||||
|
,[value_13] Nb
|
||||||
|
,[value_14] W
|
||||||
|
,[value_15] [As]
|
||||||
|
,[value_16] Sn
|
||||||
|
,[value_17] Co
|
||||||
|
,[value_18] Pb
|
||||||
|
,[value_19] B
|
||||||
|
,[value_20] Sb
|
||||||
|
,[value_21] Bi
|
||||||
|
,[value_22] Zn
|
||||||
|
,[value_23] Ce
|
||||||
|
,[value_24] Fe
|
||||||
|
from(
|
||||||
|
(select distinct HEAT_NUMBER
|
||||||
|
FROM Level3_KKC.dbo.BOF_CCM_TOTAL_REPORT
|
||||||
|
Where DT>='".$params['dateStart']."' and DT <='".$params['dateEnd']."')) tr
|
||||||
|
left join [ANA_Operator].[dbo].[ANA_CHUGUN_ALL_TRU] hm
|
||||||
|
on tr.HEAT_NUMBER=hm.Heat_number
|
||||||
|
where Sample_number<>0
|
||||||
|
and (Name IN ('LF', 'CCM1', 'CCM2', 'VD', 'BOF1', 'BOF2', 'DS', 'RL', 'ВАК'))
|
||||||
|
order by hm.HEAT_NUMBER, hm.Sample_number, Name";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
public function getSlgData($params)
|
||||||
|
{
|
||||||
|
$query = "SELECT distinct
|
||||||
|
hm.[HEAT_NUMBER]
|
||||||
|
,[Name] [Установка]
|
||||||
|
,convert(varchar, cast(ANALYSISDATE as datetime),108) as 'Время'
|
||||||
|
,[Sample_number] [№]
|
||||||
|
,[value_1] Al2O3
|
||||||
|
,[value_2] CaO
|
||||||
|
,[value_3] MgO
|
||||||
|
,[value_4] MnO
|
||||||
|
,[value_5] P
|
||||||
|
,[value_6] S
|
||||||
|
,[value_7] SiO2
|
||||||
|
,[value_8] Fe
|
||||||
|
,[value_9] FeOp
|
||||||
|
,[value_10] Fe2O3p
|
||||||
|
,[value_11] P2O5p
|
||||||
|
,[value_12] [Основнось]
|
||||||
|
from(
|
||||||
|
(select distinct HEAT_NUMBER
|
||||||
|
FROM Level3_KKC.dbo.BOF_CCM_TOTAL_REPORT
|
||||||
|
Where DT>='".$params['dateStart']."' and DT <='".$params['dateEnd']."')) tr
|
||||||
|
left join
|
||||||
|
(select * from (select heatno as HEAT_NUMBER
|
||||||
|
, sampleno as Sample_number
|
||||||
|
,ANALYSISDATE, 'LF' as Name
|
||||||
|
,[VALUEELEM1] as value_1
|
||||||
|
,[VALUEELEM2] as value_2
|
||||||
|
,[VALUEELEM4] as value_3
|
||||||
|
,[VALUEELEM5] as value_4
|
||||||
|
,'' as value_5
|
||||||
|
,[VALUEELEM7] as value_6
|
||||||
|
,[VALUEELEM8] as value_7
|
||||||
|
,'' as value_8
|
||||||
|
,[VALUEELEM3] as value_9
|
||||||
|
,'' as value_10
|
||||||
|
,[VALUEELEM6] as value_11
|
||||||
|
,'' as value_12
|
||||||
|
from [Level3_KKC].[dbo].[QLC_PRO_SLAGANALYSISHEADER_VD_L3] where [PLANTNO] IN (3,4)
|
||||||
|
union all
|
||||||
|
SELECT Heat_number as HEAT_NUMBER
|
||||||
|
, Sample_number as Sample_number
|
||||||
|
,ANALYSISDATE as 'ДАТА', name
|
||||||
|
, value_1
|
||||||
|
, value_2
|
||||||
|
, value_3
|
||||||
|
, value_4
|
||||||
|
, value_5
|
||||||
|
, value_6
|
||||||
|
, value_7
|
||||||
|
, value_8
|
||||||
|
, value_9
|
||||||
|
, value_10
|
||||||
|
, value_11
|
||||||
|
, value_12
|
||||||
|
FROM [ANA_Operator].[dbo].[ANA_SLG_ALL_TRU])a) hm
|
||||||
|
on tr.HEAT_NUMBER=hm.Heat_number
|
||||||
|
where Sample_number<>0
|
||||||
|
order by hm.HEAT_NUMBER, hm.Sample_number, Name";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
}
|
||||||
14
modules/LadleUse/LadleUse.php
Normal file
14
modules/LadleUse/LadleUse.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace API;
|
||||||
|
|
||||||
|
trait LadleUse
|
||||||
|
{
|
||||||
|
public function getData_LadleUse($params)
|
||||||
|
{
|
||||||
|
$query = "EXEC [Production].[dbo].[LADLE_USE]
|
||||||
|
@ds = '".$params['dateStart']."',
|
||||||
|
@de = '".$params['dateEnd']."'";
|
||||||
|
select_ru($query);
|
||||||
|
}
|
||||||
|
}
|
||||||
141
modules/PRB_FileControl/File_Upload.php
Normal file
141
modules/PRB_FileControl/File_Upload.php
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
|
header('Access-Control-Allow-Origin: *');
|
||||||
|
header('Access-Control-Allow-Headers: *');
|
||||||
|
|
||||||
|
$input_name = 'file';
|
||||||
|
|
||||||
|
// Разрешенные расширения файлов.
|
||||||
|
$allow = array('xlsx', 'docx', 'xls', 'doc');
|
||||||
|
|
||||||
|
// Запрещенные расширения файлов.
|
||||||
|
$deny = array(
|
||||||
|
'phtml', 'php', 'php3', 'php4', 'php5', 'php6', 'php7', 'phps', 'cgi', 'pl', 'asp',
|
||||||
|
'aspx', 'shtml', 'shtm', 'htaccess', 'htpasswd', 'ini', 'log', 'sh', 'js', 'html',
|
||||||
|
'htm', 'css', 'sql', 'spl', 'scgi', 'fcgi'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Директория куда будут загружаться файлы.
|
||||||
|
$path = __DIR__ . '/uploads/';
|
||||||
|
|
||||||
|
if (isset($_FILES[$input_name])) {
|
||||||
|
// Проверим директорию для загрузки.
|
||||||
|
if (!is_dir($path)) {
|
||||||
|
mkdir($path, 0777, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Преобразуем массив $_FILES в удобный вид для перебора в foreach.
|
||||||
|
$files = array();
|
||||||
|
$diff = count($_FILES[$input_name]) - count($_FILES[$input_name], COUNT_RECURSIVE);
|
||||||
|
if ($diff == 0) {
|
||||||
|
$files = array($_FILES[$input_name]);
|
||||||
|
} else {
|
||||||
|
foreach($_FILES[$input_name] as $k => $l) {
|
||||||
|
foreach($l as $i => $v) {
|
||||||
|
$files[$i][$k] = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$error = $success = '';
|
||||||
|
|
||||||
|
// Проверим на ошибки загрузки.
|
||||||
|
if (!empty($file['error']) || empty($file['tmp_name'])) {
|
||||||
|
switch (@$file['error']) {
|
||||||
|
case 1:
|
||||||
|
case 2: $error = 'Превышен размер загружаемого файла.'; break;
|
||||||
|
case 3: $error = 'Файл был получен только частично.'; break;
|
||||||
|
case 4: $error = 'Файл не был загружен.'; break;
|
||||||
|
case 6: $error = 'Файл не загружен - отсутствует временная директория.'; break;
|
||||||
|
case 7: $error = 'Не удалось записать файл на диск.'; break;
|
||||||
|
case 8: $error = 'PHP-расширение остановило загрузку файла.'; break;
|
||||||
|
case 9: $error = 'Файл не был загружен - директория не существует.'; break;
|
||||||
|
case 10: $error = 'Превышен максимально допустимый размер файла.'; break;
|
||||||
|
case 11: $error = 'Данный тип файла запрещен.'; break;
|
||||||
|
case 12: $error = 'Ошибка при копировании файла.'; break;
|
||||||
|
default: $error = 'Файл не был загружен - неизвестная ошибка.'; break;
|
||||||
|
}
|
||||||
|
} elseif ($file['tmp_name'] == 'none' || !is_uploaded_file($file['tmp_name'])) {
|
||||||
|
$error = 'Не удалось загрузить файл.';
|
||||||
|
} else {
|
||||||
|
// Оставляем в имени файла только буквы, цифры и некоторые символы.
|
||||||
|
$pattern = "[^a-zа-яё0-9,~!@#%^-_\$\?\(\)\{\}\[\]\.]";
|
||||||
|
$name = mb_eregi_replace($pattern, '-', $file['name']);
|
||||||
|
$name = mb_ereg_replace('[-]+', '-', $name);
|
||||||
|
|
||||||
|
// Т.к. есть проблема с кириллицей в названиях файлов (файлы становятся недоступны).
|
||||||
|
// Сделаем их транслит:
|
||||||
|
// $converter = array(
|
||||||
|
// 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e',
|
||||||
|
// 'ё' => 'e', 'ж' => 'zh', 'з' => 'z', 'и' => 'i', 'й' => 'y', 'к' => 'k',
|
||||||
|
// 'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r',
|
||||||
|
// 'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c',
|
||||||
|
// 'ч' => 'ch', 'ш' => 'sh', 'щ' => 'sch', 'ь' => '', 'ы' => 'y', 'ъ' => '',
|
||||||
|
// 'э' => 'e', 'ю' => 'yu', 'я' => 'ya',
|
||||||
|
|
||||||
|
// 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Д' => 'D', 'Е' => 'E',
|
||||||
|
// 'Ё' => 'E', 'Ж' => 'Zh', 'З' => 'Z', 'И' => 'I', 'Й' => 'Y', 'К' => 'K',
|
||||||
|
// 'Л' => 'L', 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', 'Р' => 'R',
|
||||||
|
// 'С' => 'S', 'Т' => 'T', 'У' => 'U', 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C',
|
||||||
|
// 'Ч' => 'Ch', 'Ш' => 'Sh', 'Щ' => 'Sch', 'Ь' => '', 'Ы' => 'Y', 'Ъ' => '',
|
||||||
|
// 'Э' => 'E', 'Ю' => 'Yu', 'Я' => 'Ya',
|
||||||
|
// );
|
||||||
|
|
||||||
|
// $name = strtr($name, $converter);
|
||||||
|
$parts = pathinfo($name);
|
||||||
|
|
||||||
|
if (empty($name) || empty($parts['extension'])) {
|
||||||
|
$error = 'Недопустимое тип файла';
|
||||||
|
|
||||||
|
} elseif (!empty($allow) && !in_array(strtolower($parts['extension']), $allow)) {
|
||||||
|
$error = 'Недопустимый тип файла';
|
||||||
|
|
||||||
|
} elseif (!empty($deny) && in_array(strtolower($parts['extension']), $deny)) {
|
||||||
|
$error = 'Недопустимый тип файла';
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//Чтобы не затереть файл с таким же названием, добавим префикс.
|
||||||
|
// $i = 0;
|
||||||
|
// $prefix = '';
|
||||||
|
// while (is_file($path . $parts['filename'] . $prefix . '.' . $parts['extension'])) {
|
||||||
|
// $prefix = '(' . ++$i . ')';
|
||||||
|
// }
|
||||||
|
// $name = $parts['filename'] . $prefix . '.' . $parts['extension'];
|
||||||
|
|
||||||
|
date_default_timezone_set('Europe/Moscow');
|
||||||
|
$i = 0;
|
||||||
|
$prefix = '_(' . date("d-m-Y") . ')';
|
||||||
|
while (is_file($path . $parts['filename'] . $prefix . '.' . $parts['extension'])) {
|
||||||
|
$prefix = '_(' . date("d-m-Y") . ')(' . ++$i . ')';
|
||||||
|
}
|
||||||
|
$name = $parts['filename'] . $prefix . '.' . $parts['extension'];
|
||||||
|
|
||||||
|
// Перемещаем файл в директорию.
|
||||||
|
if (move_uploaded_file($file['tmp_name'], $path . $name)) {
|
||||||
|
// Далее можно сохранить название файла в БД и т.п.
|
||||||
|
|
||||||
|
$success = 'Файл «' . $name . '» успешно загружен.';
|
||||||
|
} else {
|
||||||
|
$error = 'Не удалось загрузить файл.';
|
||||||
|
var_dump(http_response_code(300));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Выводим сообщение о результате загрузки.
|
||||||
|
if (!empty($success)) {
|
||||||
|
$post_data = array(
|
||||||
|
'success'=>$success,
|
||||||
|
'uploadIP'=>$_SERVER['REMOTE_ADDR'],
|
||||||
|
'fileName'=>$name,
|
||||||
|
'filePATH'=> $path . $name
|
||||||
|
);
|
||||||
|
echo json_encode(array('item' => $post_data), JSON_FORCE_OBJECT);
|
||||||
|
} else {
|
||||||
|
var_dump(http_response_code(300));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
81
modules/PRB_FileControl/PRB_FileControl.php
Normal file
81
modules/PRB_FileControl/PRB_FileControl.php
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace API;
|
||||||
|
|
||||||
|
trait PRB_FileControl
|
||||||
|
{
|
||||||
|
public function insertFileInfo($params)
|
||||||
|
{
|
||||||
|
date_default_timezone_set('Europe/Moscow');
|
||||||
|
$time=date('H:i:s');
|
||||||
|
$name = iconv('UTF-8', 'windows-1251', $params['data']['item']['fileName']);
|
||||||
|
$filePATH = iconv('UTF-8', 'windows-1251', $params['data']['item']['filePATH']);
|
||||||
|
$query = "INSERT INTO [Production].[dbo].[PRB_FileControl] VALUES (
|
||||||
|
0,
|
||||||
|
'$name',
|
||||||
|
'$filePATH',
|
||||||
|
'".$params['data']['item']['uploadIP']."',
|
||||||
|
'".$params['data']['date']." $time')";
|
||||||
|
insert($query);
|
||||||
|
}
|
||||||
|
public function getFiles($params)
|
||||||
|
{
|
||||||
|
$query = "SELECT
|
||||||
|
[isCompleted]
|
||||||
|
,[file_name]
|
||||||
|
,[file_path]
|
||||||
|
,convert(varchar, [upload_date],104)+' - '+convert(varchar, [upload_date],108) as [Дата загрузки]
|
||||||
|
,[id]
|
||||||
|
FROM [Production].[dbo].[PRB_FileControl]
|
||||||
|
WHERE CAST([upload_date] as DATE)='".$params['data']."'
|
||||||
|
order by upload_date desc";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCompleted($params)
|
||||||
|
{
|
||||||
|
$query = "UPDATE [Production].[dbo].[PRB_FileControl]
|
||||||
|
SET isCompleted='".$params['data']['value']."'
|
||||||
|
WHERE id=".$params['data']['id']."";
|
||||||
|
update($query);
|
||||||
|
}
|
||||||
|
public function setHistory($params)
|
||||||
|
{
|
||||||
|
$query = "INSERT INTO [Production].[dbo].[PRB_FileLog] VALUES (
|
||||||
|
'".$params['id']."',
|
||||||
|
'".$_SERVER['REMOTE_ADDR']."',
|
||||||
|
GETDATE())";
|
||||||
|
insert($query);
|
||||||
|
}
|
||||||
|
public function getHistory($params)
|
||||||
|
{
|
||||||
|
$query = "SELECT
|
||||||
|
[upload_ip]+' ('+[DESCRIPT]+')' as IP_Author
|
||||||
|
,[download_ip]+' ('+[DESCRIPT]+')'as IP_Client
|
||||||
|
,convert(varchar, [download_date],104)+' - '+convert(varchar, [download_date],108) as download_date
|
||||||
|
FROM [Production].[dbo].[PRB_FileLog] fl
|
||||||
|
inner join [Production].[dbo].[PRB_FileControl] fc
|
||||||
|
on fl.file_id=fc.id
|
||||||
|
left join [SITE].[dbo].[Police_IP] ip
|
||||||
|
on fl.download_ip=ip.IP_ADDR
|
||||||
|
WHERE CAST([download_date] as DATE)='".$params['data']['date']."'
|
||||||
|
and file_id='".$params['data']['id']."'
|
||||||
|
order by download_date desc";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
public function deleteData($params)
|
||||||
|
{
|
||||||
|
$query = "DELETE [Production].[dbo].[PRB_FileControl]
|
||||||
|
WHERE id=".$params['data']['id']."";
|
||||||
|
delete($query);
|
||||||
|
$query = "DELETE [Production].[dbo].[PRB_FileLog]
|
||||||
|
WHERE file_id=".$params['data']['id']."";
|
||||||
|
delete($query);
|
||||||
|
$path = __DIR__ . '/uploads/';
|
||||||
|
$input_name=$params['data']['name'];
|
||||||
|
$f=$path.'/'.$input_name;
|
||||||
|
if (file_exists($f)) {
|
||||||
|
unlink($f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
modules/Pasport_KRO/Pasport_KRO.php
Normal file
14
modules/Pasport_KRO/Pasport_KRO.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace API;
|
||||||
|
|
||||||
|
trait Pasport_KRO
|
||||||
|
{
|
||||||
|
public function getData_Pasport_KRO($params)
|
||||||
|
{
|
||||||
|
$query = "EXEC [Production].[dbo].[PASPORT_KRO]
|
||||||
|
@ds = '".$params['dateStart']."',
|
||||||
|
@de = '".$params['dateEnd']."'";
|
||||||
|
select_ru($query);
|
||||||
|
}
|
||||||
|
}
|
||||||
14
modules/crewAggregateWeight/crewAggregateWeight.php
Normal file
14
modules/crewAggregateWeight/crewAggregateWeight.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace API;
|
||||||
|
|
||||||
|
trait LadleUse
|
||||||
|
{
|
||||||
|
public function getData_crewAggregateWeight($params)
|
||||||
|
{
|
||||||
|
$query = "EXEC [Level3_KKC].[dbo].[crewAggregateWeight]
|
||||||
|
@bd = '".$params['dateStart']."',
|
||||||
|
@ed = '".$params['dateEnd']."'";
|
||||||
|
select_ru($query);
|
||||||
|
}
|
||||||
|
}
|
||||||
57
modules/prohodnaya/prohodnaya.php
Normal file
57
modules/prohodnaya/prohodnaya.php
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace API;
|
||||||
|
|
||||||
|
trait prohodnaya
|
||||||
|
{
|
||||||
|
public function get_services()
|
||||||
|
{
|
||||||
|
|
||||||
|
$query = "SELECT distinct[SERVICE], [ID_SERVICE]
|
||||||
|
FROM [eTabel].[dbo].[LIST_OF_WORKERS_TODAY]
|
||||||
|
order by [SERVICE]";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
public function get_departments()
|
||||||
|
{
|
||||||
|
$query = "SELECT distinct[DEPARTMENT], [ID_SERVICE], [ID_DEPARTMENT]
|
||||||
|
FROM [eTabel].[dbo].[LIST_OF_WORKERS_TODAY]
|
||||||
|
order by [DEPARTMENT]";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
public function get_crews()
|
||||||
|
{
|
||||||
|
$query = "SELECT distinct crew_desc.CREW as CREW_DESC, crew.ID_DEPARTMENT, crew.CREW, crew.SERVICE
|
||||||
|
FROM [eTabel].[dbo].[LIST_OF_WORKERS_TODAY] crew
|
||||||
|
inner join [eTabel].[dbo].[CREWS_DESC] crew_desc
|
||||||
|
on crew.CREW=crew_desc.ID_CREW
|
||||||
|
order by crew_desc.CREW";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
public function get_persons($params)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
$query = "SELECT
|
||||||
|
DATE,
|
||||||
|
TAB,
|
||||||
|
FIO,
|
||||||
|
convert(varchar, cast(DATE_IN as smalldatetime),108) as DATE_IN,
|
||||||
|
convert(varchar, cast(DATE_OUT as smalldatetime),108) as DATE_OUT,
|
||||||
|
NAME_IN,
|
||||||
|
NAME_OUT,
|
||||||
|
crew_desc.CREW,
|
||||||
|
crew.CREW as ID_CREW,
|
||||||
|
SERVICE,
|
||||||
|
DEPARTMENT,
|
||||||
|
SHIFT,
|
||||||
|
SHEDULE
|
||||||
|
FROM [eTabel].[dbo].[IN_OUT_BY_DATE_TABLE] (
|
||||||
|
'".$params['date']."'
|
||||||
|
,'".$params['date']."') crew
|
||||||
|
inner join [eTabel].[dbo].[CREWS_DESC] crew_desc
|
||||||
|
on crew.CREW=crew_desc.ID_CREW
|
||||||
|
order by SERVICE, DEPARTMENT, CREW";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
}
|
||||||
52
modules/stat/stat.php
Normal file
52
modules/stat/stat.php
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace API;
|
||||||
|
|
||||||
|
trait stat
|
||||||
|
{
|
||||||
|
public function statAdd($params)
|
||||||
|
{
|
||||||
|
$query = "INSERT INTO [SITE].[dbo].[app_hub_stat] VALUES (
|
||||||
|
'".$params['data']."',
|
||||||
|
'".$_SERVER['REMOTE_ADDR']."'
|
||||||
|
,GETDATE())";
|
||||||
|
insert($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function statGet($params)
|
||||||
|
{
|
||||||
|
$query = "
|
||||||
|
select
|
||||||
|
a.[project_name]
|
||||||
|
,count(a.[project_name]) as project_count
|
||||||
|
,convert(VARCHAR(10),b.[last_date],104) as last_date
|
||||||
|
FROM [SITE].[dbo].[app_hub_stat] a
|
||||||
|
left join (
|
||||||
|
SELECT project_name, max([last_date]) last_date FROM [SITE].[dbo].[app_hub_stat]
|
||||||
|
group by project_name
|
||||||
|
) b on b.project_name=a.project_name
|
||||||
|
group by a.[project_name], b.[last_date]
|
||||||
|
order by b.[last_date] desc
|
||||||
|
";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function statGetInfo($params)
|
||||||
|
{
|
||||||
|
$w=1;
|
||||||
|
$query = "
|
||||||
|
SELECT
|
||||||
|
--[project_name]
|
||||||
|
pip.DESCRIPT ip_desc
|
||||||
|
,[ip]
|
||||||
|
--,last_date
|
||||||
|
,convert(varchar, cast([last_date] as datetime),104)+' '+convert(varchar, cast([last_date] as datetime),108) date
|
||||||
|
--,convert(VARCHAR(10),[last_date],104)+' '+convert(VARCHAR(10),[last_date],108) as last_date
|
||||||
|
FROM [SITE].[dbo].[app_hub_stat] ahs
|
||||||
|
left join [SITE].[dbo].[Police_IP] pip
|
||||||
|
on ahs.ip=pip.ip_addr
|
||||||
|
where [project_name]='".$params['data']."'
|
||||||
|
order by last_date desc";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
}
|
||||||
36
modules/tundishSample/tundishSample.php
Normal file
36
modules/tundishSample/tundishSample.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace API;
|
||||||
|
|
||||||
|
trait tundishSample
|
||||||
|
{
|
||||||
|
public function getDataHeats($params)
|
||||||
|
{
|
||||||
|
$query = "SELECT distinct
|
||||||
|
[HEAT_NAME]
|
||||||
|
,convert(varchar, [OPEN_TIME], 104) +' '+convert(varchar, [OPEN_TIME], 108) as OPEN_TIME
|
||||||
|
,convert(varchar, [CLOSE_TIME], 104) +' '+convert(varchar, [CLOSE_TIME], 108) as CLOSE_TIME
|
||||||
|
FROM [Level3_KKC].[dbo].[HEAT_CCM1_L3]
|
||||||
|
-- left join [Pasport_CCM].[dbo].[OPC_T_Tundish_sample_VALUES] ts
|
||||||
|
-- on [OPEN_TIME]<=ts.datetime and CLOSE_TIME>=ts.datetime
|
||||||
|
where CAST([CLOSE_TIME] as DATE) between'".$params['dateStart']."' and '".$params['dateEnd']."'
|
||||||
|
order by [OPEN_TIME] desc, [CLOSE_TIME] desc";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
public function getDataValues($params)
|
||||||
|
{
|
||||||
|
|
||||||
|
$query = "SELECT distinct
|
||||||
|
[HEAT_NAME]
|
||||||
|
,[button_all]
|
||||||
|
,[opc_T_sample_value]
|
||||||
|
,[count]
|
||||||
|
,convert(varchar, [datetime], 104) +' '+convert(varchar, [datetime], 108) as [datetime]
|
||||||
|
FROM [Level3_KKC].[dbo].[HEAT_CCM1_L3] ccm
|
||||||
|
inner join [Pasport_CCM].[dbo].[OPC_T_Tundish_sample_VALUES] ts
|
||||||
|
on [OPEN_TIME]<=ts.datetime and CLOSE_TIME>=ts.datetime
|
||||||
|
where CAST([CLOSE_TIME] as DATE) between'".$params['dateStart']."' and '".$params['dateEnd']."'
|
||||||
|
order by [datetime] desc";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
}
|
||||||
17
modules/weatherAvg/weatherAvg.php
Normal file
17
modules/weatherAvg/weatherAvg.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace API;
|
||||||
|
|
||||||
|
trait weatherAvg
|
||||||
|
{
|
||||||
|
public function getData($params)
|
||||||
|
{
|
||||||
|
$query = "SELECT
|
||||||
|
round(avg([AirTemp_DegC]),2) as value
|
||||||
|
,convert(varchar, dt, 104) as dt
|
||||||
|
FROM [ASUTP].[dbo].[Weather_Status]
|
||||||
|
WHERE CAST(dt as DATE) BETWEEN '".$params['dateStart']."' AND '".$params['dateEnd']."'
|
||||||
|
group by convert(varchar, dt, 104)";
|
||||||
|
select($query);
|
||||||
|
}
|
||||||
|
}
|
||||||
195
server.php
Normal file
195
server.php
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
<?php
|
||||||
|
if (isset($_SERVER['HTTP_PROJECT'])) {
|
||||||
|
$project_name = $_SERVER['HTTP_PROJECT'];
|
||||||
|
if (isset($project_name)) {
|
||||||
|
header('Content-Type:text/html; charset=UTF-8', true, 200);
|
||||||
|
} else {
|
||||||
|
header('Content-Type:text/html; charset=UTF-8', true, 301);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ini_set('serialize_precision', -1);
|
||||||
|
|
||||||
|
function exception_error_handler($severity, $message, $file, $line)
|
||||||
|
{
|
||||||
|
if (!(error_reporting() & $severity)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new ErrorException($message, 0, $severity, $file, $line);
|
||||||
|
}
|
||||||
|
set_error_handler('exception_error_handler');
|
||||||
|
$sql = array();
|
||||||
|
function insert($query)
|
||||||
|
{
|
||||||
|
global $sql;
|
||||||
|
array_push($sql, array(
|
||||||
|
'insert' => $query,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
function select($query)
|
||||||
|
{
|
||||||
|
global $sql;
|
||||||
|
array_push($sql, array(
|
||||||
|
'select' => $query,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
function select_ru($query)
|
||||||
|
{
|
||||||
|
global $sql;
|
||||||
|
array_push($sql, array(
|
||||||
|
'select_ru' => $query,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
function update($query)
|
||||||
|
{
|
||||||
|
global $sql;
|
||||||
|
array_push($sql, array(
|
||||||
|
'update' => $query,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
function delete($query)
|
||||||
|
{
|
||||||
|
global $sql;
|
||||||
|
array_push($sql, array(
|
||||||
|
'delete' => $query,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
function querySelect_ru($sql_query)
|
||||||
|
{
|
||||||
|
global $conn;
|
||||||
|
global $response;
|
||||||
|
global $multiSelect;
|
||||||
|
$result = sqlsrv_query($conn, $sql_query);
|
||||||
|
$items = array();
|
||||||
|
while ($row = sqlsrv_fetch_object($result)) {
|
||||||
|
foreach ($row as $key=> &$value) {
|
||||||
|
if (is_string($value)) {
|
||||||
|
$value = iconv('windows-1251', 'UTF-8', $value);
|
||||||
|
}
|
||||||
|
if (is_numeric($value)) {
|
||||||
|
$value = round($value, 4);
|
||||||
|
}
|
||||||
|
$key = iconv('windows-1251', 'UTF-8', $key);
|
||||||
|
$a[$key]=$value;
|
||||||
|
}
|
||||||
|
unset($value);
|
||||||
|
unset($key);
|
||||||
|
array_push($items, $a);
|
||||||
|
}
|
||||||
|
if (true == $multiSelect) {
|
||||||
|
array_push($response, $items);
|
||||||
|
} else {
|
||||||
|
echo json_encode($items);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (false === $result) {
|
||||||
|
if (null != ($errors = sqlsrv_errors())) {
|
||||||
|
header('Content-Type:text/html; charset=UTF-8', true, 301);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function querySelect($sql_query)
|
||||||
|
{
|
||||||
|
global $conn;
|
||||||
|
global $response;
|
||||||
|
global $multiSelect;
|
||||||
|
$result = sqlsrv_query($conn, $sql_query);
|
||||||
|
$items = array();
|
||||||
|
while ($row = sqlsrv_fetch_object($result)) {
|
||||||
|
foreach ($row as &$value) {
|
||||||
|
if (is_string($value)) {
|
||||||
|
$value = iconv('windows-1251', 'UTF-8', $value);
|
||||||
|
}
|
||||||
|
if (is_numeric($value)) {
|
||||||
|
$value = round($value, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($value);
|
||||||
|
$items[] = $row;
|
||||||
|
}
|
||||||
|
if (true == $multiSelect) {
|
||||||
|
array_push($response, $items);
|
||||||
|
} else {
|
||||||
|
echo json_encode($items);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (false === $result) {
|
||||||
|
if (null != ($errors = sqlsrv_errors())) {
|
||||||
|
header('Content-Type:text/html; charset=UTF-8', true, 301);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function queryOther($sql_query)
|
||||||
|
{
|
||||||
|
global $conn;
|
||||||
|
$result = sqlsrv_query($conn, $sql_query);
|
||||||
|
$rows_affected = sqlsrv_rows_affected($result);
|
||||||
|
//if (false === $rows_affected) {
|
||||||
|
if ($rows_affected >= 1) {
|
||||||
|
header('Content-Type:text/html; charset=UTF-8', true, 200);
|
||||||
|
} else {
|
||||||
|
header('Content-Type:text/html; charset=UTF-8', true, 301);
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
// include("libs/hs256.php");
|
||||||
|
// include("libs/JWT.php");
|
||||||
|
// use \Firebase\JWT\JWT;
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// $JWTdecoded = JWT::decode($jwtToken, $secret, array('HS256'));
|
||||||
|
// } catch (\Throwable $th) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
include_once 'connection.php';
|
||||||
|
include_once 'core.php';
|
||||||
|
|
||||||
|
$multiSelect = false;
|
||||||
|
if (isset($params['multiSelect'])) {
|
||||||
|
$multiSelect = $params['multiSelect'];
|
||||||
|
if (true == $multiSelect) {
|
||||||
|
$response = array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// $query="SELECT id FROM [dbo].[users] where id=$JWTdecoded->id AND is_logged=1";
|
||||||
|
// $params = array();
|
||||||
|
// $options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
|
||||||
|
// $stmt = sqlsrv_query($conn, $query, $params, $options);
|
||||||
|
// $row_count = sqlsrv_num_rows($stmt);
|
||||||
|
|
||||||
|
// if ($row_count === false || $row_count ===0) {
|
||||||
|
// header('HTTP/1.0 401 Unauthorized');
|
||||||
|
// exit;
|
||||||
|
// } else {
|
||||||
|
// $verify = verifyJWT('sha256', $jwtToken, $secret);
|
||||||
|
// if ($verify) {
|
||||||
|
foreach ($sql as $key => $value) {
|
||||||
|
$sql_key = array_keys(array_filter($value))[0];
|
||||||
|
$sql_query = array_values(array_filter($value))[0];
|
||||||
|
if ('select' === $sql_key) {
|
||||||
|
querySelect($sql_query);
|
||||||
|
} elseif ('select_ru' === $sql_key) {
|
||||||
|
querySelect_ru($sql_query);
|
||||||
|
} else {
|
||||||
|
//if ($JWTdecoded->role===1) {
|
||||||
|
queryOther($sql_query);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// } else {
|
||||||
|
// header('HTTP/1.0 401 Unauthorized');
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
} catch (Throwable $t) {
|
||||||
|
header($t);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (true == $multiSelect) {
|
||||||
|
echo json_encode($response);
|
||||||
|
}
|
||||||
169
server__.php
Normal file
169
server__.php
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
ini_set( 'serialize_precision', -1 );
|
||||||
|
|
||||||
|
$_POST = json_decode(file_get_contents('php://input'), true);
|
||||||
|
|
||||||
|
if (isset($_POST)) {
|
||||||
|
$params=$_POST['params'];
|
||||||
|
$flag=$params['flag'];
|
||||||
|
if (method_exists($api, $flag)) {
|
||||||
|
call_user_func(array($api, $flag), $params);
|
||||||
|
} else {
|
||||||
|
header('Content-Type:text/html; charset=UTF-8', true, 301);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function exception_error_handler($severity, $message, $file, $line)
|
||||||
|
{
|
||||||
|
if (!(error_reporting() & $severity)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new ErrorException($message, 0, $severity, $file, $line);
|
||||||
|
}
|
||||||
|
set_error_handler("exception_error_handler");
|
||||||
|
$sql = array();
|
||||||
|
function insert($query)
|
||||||
|
{
|
||||||
|
global $sql;
|
||||||
|
array_push($sql, array(
|
||||||
|
'insert' => $query,
|
||||||
|
));
|
||||||
|
};
|
||||||
|
function select($query)
|
||||||
|
{
|
||||||
|
global $sql;
|
||||||
|
array_push($sql, array(
|
||||||
|
'select' => $query,
|
||||||
|
));
|
||||||
|
};
|
||||||
|
function update($query)
|
||||||
|
{
|
||||||
|
global $sql;
|
||||||
|
array_push($sql, array(
|
||||||
|
'update' => $query,
|
||||||
|
));
|
||||||
|
};
|
||||||
|
function delete($query)
|
||||||
|
{
|
||||||
|
global $sql;
|
||||||
|
array_push($sql, array(
|
||||||
|
'delete' => $query,
|
||||||
|
));
|
||||||
|
};
|
||||||
|
|
||||||
|
function querySelect($sql_query)
|
||||||
|
{
|
||||||
|
global $conn;
|
||||||
|
global $response;
|
||||||
|
global $multiSelect;
|
||||||
|
$result = sqlsrv_query($conn, $sql_query);
|
||||||
|
$items=array();
|
||||||
|
while ($row = sqlsrv_fetch_object($result)) {
|
||||||
|
foreach ($row as &$value) {
|
||||||
|
//if (gettype($value)=="string") { //Бодавский, не удалять!!!
|
||||||
|
if (is_string($value)) { //added samofalov
|
||||||
|
$value = iconv('windows-1251', 'UTF-8', $value);
|
||||||
|
}
|
||||||
|
if (is_numeric($value)) { //added samofalov
|
||||||
|
$value =round($value, 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($value);
|
||||||
|
$items[] = $row;
|
||||||
|
}
|
||||||
|
if ($multiSelect==true) {
|
||||||
|
array_push($response, $items);
|
||||||
|
} else {
|
||||||
|
echo json_encode($items);
|
||||||
|
// $test=json_encode($items);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($result === false) {
|
||||||
|
if (($errors = sqlsrv_errors()) != null) {
|
||||||
|
header('Content-Type:text/html; charset=UTF-8', true, 301);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function queryOther($sql_query)
|
||||||
|
{
|
||||||
|
global $conn;
|
||||||
|
$result = sqlsrv_query($conn, $sql_query);
|
||||||
|
$rows_affected = sqlsrv_rows_affected($result);
|
||||||
|
if ($rows_affected === false) {
|
||||||
|
if ($rows_affected >= 1) {
|
||||||
|
header('Content-Type:text/html; charset=UTF-8', true, 200);
|
||||||
|
} else {
|
||||||
|
header('Content-Type:text/html; charset=UTF-8', true, 301);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
include("libs/hs256.php");
|
||||||
|
include("libs/JWT.php");
|
||||||
|
use \Firebase\JWT\JWT;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$JWTdecoded = JWT::decode($jwtToken, $secret, array('HS256'));
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
include("connection.php");
|
||||||
|
|
||||||
|
include("api.php");
|
||||||
|
|
||||||
|
|
||||||
|
$multiSelect=false;
|
||||||
|
if (isset($params['multiSelect'])) {
|
||||||
|
$multiSelect=$params['multiSelect'];
|
||||||
|
if ($multiSelect==true) {
|
||||||
|
$response=array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
$query="SELECT id FROM [dbo].[users] where id=$JWTdecoded->id AND is_logged=1";
|
||||||
|
$params = array();
|
||||||
|
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
|
||||||
|
$stmt = sqlsrv_query($conn, $query, $params, $options);
|
||||||
|
$row_count = sqlsrv_num_rows($stmt);
|
||||||
|
|
||||||
|
if ($row_count === false || $row_count ===0) {
|
||||||
|
header('HTTP/1.0 401 Unauthorized');
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
$verify = verifyJWT('sha256', $jwtToken, $secret);
|
||||||
|
if ($verify) {
|
||||||
|
foreach ($sql as $key => $value) {
|
||||||
|
$sql_key=array_keys(array_filter($value))[0];
|
||||||
|
$sql_query=array_values(array_filter($value))[0];
|
||||||
|
if ($sql_key==='select') {
|
||||||
|
querySelect($sql_query);
|
||||||
|
} else {
|
||||||
|
if ($JWTdecoded->role===1) {
|
||||||
|
queryOther($sql_query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
header('HTTP/1.0 401 Unauthorized');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Throwable $t) {
|
||||||
|
header($t);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($multiSelect==true) {
|
||||||
|
echo json_encode($response);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user