add client route

This commit is contained in:
Andrey Kuvshinov
2020-04-26 19:54:50 +03:00
parent 5d501c6f5d
commit 90ea0aa6a3
3 changed files with 59 additions and 0 deletions

View File

@@ -17,4 +17,5 @@ define('API', 'http://api.argumenti.ru/');
db_config('argumentiru', 'mysql:host=mysql;dbname=argumentiru', 'newser', 'Chjk90yuiREY');
db_config('reader', 'mysql:host=mysql;dbname=argumentiru', 'reader', 'ghjyjkUIOhg56Fh');
db_config('writer', 'mysql:host=mysql;dbname=argumentiru', 'chitatel', 'hjYu78kl*90Uio');

View File

@@ -4,6 +4,7 @@ require 'vendor/autoload.php';
require 'confg.php';
require 'modules/anpdf/anpdf.php';
require 'routes/price.php';
require 'routes/client.php';
_kuri();

57
app/routes/client.php Normal file
View File

@@ -0,0 +1,57 @@
<?php
function addclient_kuri(){
$buys = db_get("SELECT `buy_id`, `buy_email`, `date_start` FROM `anbuy`");
foreach($buys as $buy){
if ($buy['date_start'] == '0000-00-00 00:00:00')
$clientdate = date('Y-m-d G:i:s');
else
$clientdate = $buy['date_start'];
$clientmail = strtolower(trim($buy['buy_email']));
$clienthash = md5($clientmail);
$client = db_get("SELECT `client_id`, `clientcard`, `clientdate` FROM `clients` WHERE `clientmail` = '$clientmail' LIMIT 1");
if (isset($client['client_id'])){
if ($client['clientdate'] == '0000-00-00 00:00:00'){
$updsql = "UPDATE `clients` SET `clientdate` = '$clientdate' WHERE `client_id` = '{$client['client_id']}'";
db_get($updsql, 'writer');
echo "$updsql \n";
}
if ($client['clienthash'] == '' ){
$updsql = "UPDATE `clients` SET `clienthash` = '$clienthash' WHERE `client_id` = '{$client['client_id']}'";
db_get($updsql, 'writer');
echo "$updsql \n";
}
}
else {
$inssql = "INSERT INTO `clients` (clientmail, clientdate, clienthash) VALUES ('$clientmail', '$clientdate', '$clienthash')";
db_get($inssql, 'writer');
echo "$inssql \n";
}
}
}
// номер клубной карты
function addcard($id, $date) {
$year = substr($date, 0, 4);
$number = str_pad($id, 9, '0', STR_PAD_LEFT);
return "$year$number";
}