Advertisement
Guest User

Untitled

a guest
Jan 29th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. `use strict`
  2. var server = require('diet')
  3. var mysql = require('mysql')
  4. var connection = mysql.createConnection({
  5.     host: 'localhost',
  6.     user: 'root',
  7.     password: 'pass'
  8. });
  9. var app = server()
  10. app.listen('95.213.203.209:5683/')
  11. //clients
  12. app.get('/clients.get', function($) {
  13.     connection.query("SELECT * FROM `get`.`clients` WHERE 1", function(err, rows, fields) {
  14.         $.json({
  15.             rows
  16.         })
  17.     })
  18. })
  19. app.get('/clients.getarr', function($) {
  20.     connection.query("SELECT * FROM `get`.`clients` WHERE 1", function(err, rows, fields) {
  21.         var arr = rows.map(function(row) {
  22.             return [row.name + "," + row.email + "," + row.type + "," + row.added]
  23.         })
  24.         $.end(arr)
  25.     })
  26. })
  27. app.get('/clients.getsum', function($) {
  28.     connection.query("SELECT * FROM `get`.`clients` WHERE 1", function(err, rows, fields) {
  29.         $.json({
  30.             "rows": [{
  31.                 'clients': rows.length
  32.             }]
  33.         })
  34.     })
  35. })
  36. app.get('/client.getbyid', function($) {
  37.     connection.query("SELECT * FROM `get`.`clients` WHERE `id`=" + connection.escape($.query.id), function(err, rows, fields) {
  38.         $.json({
  39.             rows
  40.         })
  41.     })
  42. })
  43. app.get('/clients.getbyid', function($) {
  44.     connection.query("SELECT * FROM `get`.`clients` WHERE `manager_id` =" + connection.escape($.query.id), function(err, rows, fields) {
  45.         $.json({
  46.             rows
  47.         })
  48.     })
  49. })
  50. app.get('/clients.new', function($) {
  51.     connection.query("INSERT INTO `get`.`clients`(`name`, `email`, `phone`, `manager_id`, `type`, `added`) VALUES (" + connection.escape($.query.name) + "," + connection.escape($.query.email) + "," + connection.escape($.query.phone) + "," + connection.escape($.query.manager_id) + "," + connection.escape($.query.type) + ", CURRENT_DATE())", function(err, rows, fields) {
  52.         if (!err) {
  53.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  54.             $.end('Success')
  55.         } else {
  56.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  57.             $.end(err)
  58.         }
  59.     })
  60. })
  61. app.get('/clients.delete', function($) {
  62.     connection.query("DELETE FROM `get`.`clients` WHERE `id` =" + connection.escape($.query.id), function(err, rows, fields) {
  63.         if (!err) {
  64.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  65.             $.end('Success')
  66.         } else {
  67.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  68.             $.end(err)
  69.         }
  70.     })
  71. })
  72. //comments
  73. app.get('/comment.add', function($) {
  74.     connection.query("INSERT INTO `get`.`comments`(`task_id`, `user_id`, `comment`, `date`) VALUES (" + connection.escape($.query.task_id) + "," + connection.escape($.query.user_id) + "," + connection.escape($.query.comment) + ", NOW())", function(err, rows, fields) {
  75.         if (!err) {
  76.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  77.             $.end('Success')
  78.         } else {
  79.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  80.             $.end(err)
  81.         }
  82.     })
  83. })
  84. app.get('/comments.get', function($) {
  85.     connection.query("SELECT * FROM `get`.`comments` WHERE `task_id` =" + connection.escape($.query.id) + " ORDER BY `comments`.`id` DESC", function(err, rows, fields) {
  86.         $.json({
  87.             rows
  88.         })
  89.     })
  90. })
  91. app.get('/comments.getbyuser', function($) {
  92.     connection.query("SELECT * FROM `get`.`tasks` WHERE `manager_id` =" + connection.escape($.query.id), function(err, rows, fields) {
  93.         var tasks = rows.map(function(row) {
  94.                 return row.id
  95.         })
  96.        
  97.         connection.query("SELECT * FROM `get`.`comments` WHERE `task_id` IN ("+tasks+") ORDER BY `comments`.`id` DESC", function(err, rows, fields) {
  98.             if(!err) {
  99.                 $.json({
  100.                 rows
  101.                 })
  102.                 } else {
  103.                     $.end(err)
  104.                 }
  105.            
  106.         })
  107.     })
  108. })
  109. //developers
  110. app.get('/developers.get', function($) {
  111.     connection.query("SELECT * FROM `get`.`tbl_users` WHERE `group` = 'developer'", function(err, rows, fields) {
  112.         $.json({
  113.             rows
  114.         })
  115.     })
  116. })
  117. //history
  118. app.get('/history.get', function($) {
  119.     connection.query("SELECT * FROM `get`.`history` WHERE `task_id` =" + connection.escape($.query.id), function(err, rows, fields) {
  120.         $.json({
  121.             rows
  122.         })
  123.     })
  124. })
  125. app.get('/history.getbyuser', function($) {
  126.     connection.query("SELECT * FROM `get`.`tasks` WHERE `manager_id` =" + connection.escape($.query.id), function(err, rows, fields) {
  127.         var tasks = rows.map(function(row) {
  128.                 return row.id
  129.         })
  130.         connection.query("SELECT * FROM `get`.`history` WHERE `task_id` IN ("+tasks+") ORDER BY `history`.`id` DESC", function(err, rows, fields) {
  131.             $.json({
  132.                 rows
  133.             })
  134.         })
  135.     })
  136. })
  137. //price
  138. app.get('/price.get', function($) {
  139.     connection.query("SELECT * FROM `get`.`price_head` WHERE 1", function(err, rows, fields) {
  140.         $.json({
  141.             rows
  142.         })
  143.     })
  144. })
  145. app.get('/price.getbyid', function($) {
  146.     connection.query("SELECT * FROM `get`.`price_head` WHERE `id`=" + connection.escape($.query.id), function(err, rows, fields) {
  147.         $.json({
  148.             rows
  149.         })
  150.     })
  151. })
  152. app.get('/price.delete', function($) {
  153.     connection.query("DELETE FROM `get`.`price_head` WHERE `id`=" + connection.escape($.query.id), function(err, rows, fields) {
  154.         if (!err) {
  155.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  156.             $.end('Success')
  157.         } else {
  158.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  159.             $.end(err)
  160.         }
  161.     })
  162. })
  163. app.get('/price.update', function($) {
  164.     connection.query("UPDATE `get`.`price_head` SET `name`=" + connection.escape($.query.name) + ",`cost`=" + connection.escape($.query.cost) + " WHERE `id`=" + connection.escape($.query.id), function(err, rows, fields) {
  165.         if (!err) {
  166.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  167.             $.end('Success')
  168.         } else {
  169.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  170.             $.end(err)
  171.         }
  172.     })
  173. })
  174. app.get('/price.add', function($) {
  175.     connection.query("INSERT INTO `get`.`price_head`(`name`, `cost`) VALUES (" + connection.escape($.query.name) + "," + connection.escape($.query.cost) + ")", function(err, rows, fields) {
  176.         if (!err) {
  177.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  178.             $.end('Success')
  179.         } else {
  180.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  181.             $.end(err)
  182.         }
  183.     })
  184. })
  185. //statuses
  186. app.get('/status.get', function($) {
  187.     connection.query("SELECT * FROM `get`.`statuses` WHERE `id`=" + connection.escape($.query.id), function(err, rows, fields) {
  188.         $.json({
  189.             rows
  190.         })
  191.     })
  192. })
  193. app.get('/statuses', function($) {
  194.     connection.query("SELECT * FROM `get`.`statuses` WHERE 1", function(err, rows, fields) {
  195.         $.json({
  196.             rows
  197.         })
  198.     })
  199. })
  200. app.get('/status.update', function($) {
  201.     connection.query("UPDATE `get`.`tasks` SET `status`=" + connection.escape($.query.status) + " WHERE `id`=" + connection.escape($.query.task_id), function(err, rows, fields) {
  202.         if (!err) {
  203.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  204.             connection.query("INSERT INTO `get`.`history`(`task_id`, `user_id`, `info`, `date`) VALUES (" + connection.escape($.query.task_id) + "," + connection.escape($.query.user_id) + "," + connection.escape($.query.info) + ", NOW())", function(err, rows, fields) {
  205.                 if (!err) {
  206.                     $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  207.                     $.end('Success')
  208.                 } else {
  209.                     $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  210.                     $.end(err)
  211.                 }
  212.             })
  213.         } else {
  214.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  215.             $.end(err)
  216.         }
  217.     })
  218. })
  219. //subprice
  220. app.get('/subprice.delete', function($) {
  221.     connection.query("DELETE FROM `get`.`price_sub` WHERE `id`=" + connection.escape($.query.id), function(err, rows, fields) {
  222.         if (!err) {
  223.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  224.             $.end('Success')
  225.         } else {
  226.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  227.             $.end(err)
  228.         }
  229.     })
  230. })
  231. app.get('/subprice.update', function($) {
  232.     connection.query("UPDATE `get`.`price_sub` SET `name`=" + connection.escape($.query.name) + ",`cost`=" + connection.escape($.query.cost) + " WHERE `id`=" + connection.escape($.query.id), function(err, rows, fields) {
  233.         if (!err) {
  234.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  235.             $.end('Success')
  236.         } else {
  237.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  238.             $.end(err)
  239.         }
  240.     })
  241. })
  242. app.get('/subprice.add', function($) {
  243.     connection.query("INSERT INTO `get`.`price_sub`(`name`, `cost`) VALUES (" + connection.escape($.query.name) + "," + connection.escape($.query.cost) + ")", function(err, rows, fields) {
  244.         if (!err) {
  245.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  246.             $.end('Success')
  247.         } else {
  248.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  249.             $.end(err)
  250.         }
  251.     })
  252. })
  253. app.get('/subprice.get', function($) {
  254.     connection.query("SELECT * FROM `get`.`price_sub` WHERE 1", function(err, rows, fields) {
  255.         $.json({
  256.             rows
  257.         })
  258.     })
  259. })
  260. app.get('/sub.get', function($) {
  261.     connection.query("SELECT * FROM `get`.`price_sub` WHERE `id`in (" + $.query.id + ")", function(err, rows, fields) {
  262.         $.json({
  263.             rows
  264.         })
  265.     })
  266. })
  267. //tasks
  268. app.get('/tasks.get', function($) {
  269.     connection.query("SELECT * FROM `get`.`tasks` WHERE 1", function(err, rows, fields) {
  270.         $.json({
  271.             rows
  272.         })
  273.     })
  274. })
  275. app.get('/tasks.getbyid', function($) {
  276.     connection.query("SELECT * FROM `get`.`tasks` WHERE `manager_id`=" + connection.escape($.query.id), function(err, rows, fields) {
  277.         $.json({
  278.             rows
  279.         })
  280.     })
  281. })
  282. app.get('/tasks.getbyclient', function($) {
  283.     connection.query("SELECT * FROM `get`.`tasks` WHERE `client_id`=" + connection.escape($.query.id), function(err, rows, fields) {
  284.         $.json({
  285.             rows
  286.         })
  287.     })
  288. })
  289. app.get('/tasks.oneid', function($) {
  290.     connection.query("SELECT * FROM `get`.`tasks` WHERE `id`=" + connection.escape($.query.id), function(err, rows, fields) {
  291.         $.json({
  292.             rows
  293.         })
  294.     })
  295. })
  296. app.get('/tasks.getsumbyid', function($) {
  297.     connection.query("SELECT * FROM `get`.`tasks` WHERE `manager_id` =" + connection.escape($.query.id), function(err, rows, fields) {
  298.         var not_payed = rows.map(function(row) {
  299.             if (row.status == '1') {
  300.                 return row.status
  301.             }
  302.         }).filter(function(x) {
  303.             return typeof x !== 'undefined';
  304.         })
  305.         var payed = rows.map(function(row) {
  306.             if (row.status == '2') {
  307.                 return row.status
  308.             }
  309.         }).filter(function(x) {
  310.             return typeof x !== 'undefined';
  311.         })
  312.         var in_development = rows.map(function(row) {
  313.             if (row.status == '3') {
  314.                 return row.status
  315.             }
  316.         }).filter(function(x) {
  317.             return typeof x !== 'undefined';
  318.         })
  319.         var done = rows.map(function(row) {
  320.             if (row.status == '4') {
  321.                 return row.status
  322.             }
  323.         }).filter(function(x) {
  324.             return typeof x !== 'undefined';
  325.         })
  326.         var ended = rows.map(function(row) {
  327.             if (row.status == '5') {
  328.                 return row.status
  329.             }
  330.         }).filter(function(x) {
  331.             return typeof x !== 'undefined';
  332.         })
  333.  
  334.         var re_edit = rows.map(function(row) {
  335.             if (row.status == '6') {
  336.                 return row.status
  337.             }
  338.         }).filter(function(x) {
  339.             return typeof x !== 'undefined';
  340.         })
  341.         var actual_inc = rows.map(function(row) {
  342.             if (row.status == '5') {
  343.                 return row.sum
  344.             }
  345.         }).filter(function(x) {
  346.             return typeof x !== 'undefined';
  347.         })
  348.         var actual_income = 0;
  349.         for (var i = 0; i < actual_inc.length; i++) {
  350.             actual_income = actual_income + parseInt(actual_inc[i]);
  351.         }
  352.  
  353.         var real_inc = rows.map(function(row) {
  354.             if (row.status == '5') {
  355.                 return row.salesum
  356.             }
  357.         }).filter(function(x) {
  358.             return typeof x !== 'undefined';
  359.         })
  360.         var real_income = 0;
  361.         for (var i = 0; i < real_inc.length; i++) {
  362.             real_income = real_income + parseInt(real_inc[i]);
  363.         }
  364.  
  365.  
  366.         var perspective_act = rows.map(function(row) {
  367.             if (row.status == '1' || row.status == '2' || row.status == '3' || row.status == '4' || row.status == '6') {
  368.                 return row.sum
  369.             }
  370.         }).filter(function(x) {
  371.             return typeof x !== 'undefined';
  372.         })
  373.         var perspective_actual = 0;
  374.         for (var i = 0; i < perspective_act.length; i++) {
  375.             perspective_actual = perspective_actual + parseInt(perspective_act[i]);
  376.         }
  377.         var perspective_rea = rows.map(function(row) {
  378.             if (row.status == '1' || row.status == '2' || row.status == '3' || row.status == '4' || row.status == '6') {
  379.                 return row.salesum
  380.             }
  381.         }).filter(function(x) {
  382.             return typeof x !== 'undefined';
  383.         })
  384.         var perspective_real = 0;
  385.         for (var i = 0; i < perspective_rea.length; i++) {
  386.             perspective_real = perspective_real + parseInt(perspective_rea[i]);
  387.         }
  388.  
  389.         var manager_salary = real_income * 0.2
  390.         var developer_salary = actual_income * 0.05
  391.  
  392.         $.json({
  393.             "rows": [{
  394.                 'tasks': rows.length,
  395.                 'not_payed': not_payed.length,
  396.                 'payed': payed.length,
  397.                 'in_development': in_development.length,
  398.                 'done': done.length,
  399.                 'ended': ended.length,
  400.                 're_edit': re_edit.length,
  401.                 'actual_income': actual_income,
  402.                 'real_income': real_income,
  403.                 'perspective_actual': perspective_actual,
  404.                 'perspective_real': perspective_real,
  405.                 'manager_salary': manager_salary,
  406.                 'developer_salry': developer_salary
  407.             }]
  408.         })
  409.     })
  410. })
  411. app.get('/tasks.getsum', function($) {
  412.     connection.query("SELECT * FROM `get`.`tasks` WHERE 1", function(err, rows, fields) {
  413.         var not_payed = rows.map(function(row) {
  414.             if (row.status == '1') {
  415.                 return row.status
  416.             }
  417.         }).filter(function(x) {
  418.             return typeof x !== 'undefined';
  419.         })
  420.         var payed = rows.map(function(row) {
  421.             if (row.status == '2') {
  422.                 return row.status
  423.             }
  424.         }).filter(function(x) {
  425.             return typeof x !== 'undefined';
  426.         })
  427.         var in_development = rows.map(function(row) {
  428.             if (row.status == '3') {
  429.                 return row.status
  430.             }
  431.         }).filter(function(x) {
  432.             return typeof x !== 'undefined';
  433.         })
  434.         var done = rows.map(function(row) {
  435.             if (row.status == '4') {
  436.                 return row.status
  437.             }
  438.         }).filter(function(x) {
  439.             return typeof x !== 'undefined';
  440.         })
  441.         var ended = rows.map(function(row) {
  442.             if (row.status == '5') {
  443.                 return row.status
  444.             }
  445.         }).filter(function(x) {
  446.             return typeof x !== 'undefined';
  447.         })
  448.  
  449.         var re_edit = rows.map(function(row) {
  450.             if (row.status == '6') {
  451.                 return row.status
  452.             }
  453.         }).filter(function(x) {
  454.             return typeof x !== 'undefined';
  455.         })
  456.         var actual_inc = rows.map(function(row) {
  457.             if (row.status == '5') {
  458.                 return row.sum
  459.             }
  460.         }).filter(function(x) {
  461.             return typeof x !== 'undefined';
  462.         })
  463.         var actual_income = 0;
  464.         for (var i = 0; i < actual_inc.length; i++) {
  465.             actual_income = actual_income + parseInt(actual_inc[i]);
  466.         }
  467.  
  468.         var real_inc = rows.map(function(row) {
  469.             if (row.status == '5') {
  470.                 return row.salesum
  471.             }
  472.         }).filter(function(x) {
  473.             return typeof x !== 'undefined';
  474.         })
  475.         var real_income = 0;
  476.         for (var i = 0; i < real_inc.length; i++) {
  477.             real_income = real_income + parseInt(real_inc[i]);
  478.         }
  479.  
  480.  
  481.         var perspective_act = rows.map(function(row) {
  482.             if (row.status == '1' || row.status == '2' || row.status == '3' || row.status == '4' || row.status == '6') {
  483.                 return row.sum
  484.             }
  485.         }).filter(function(x) {
  486.             return typeof x !== 'undefined';
  487.         })
  488.         var perspective_actual = 0;
  489.         for (var i = 0; i < perspective_act.length; i++) {
  490.             perspective_actual = perspective_actual + parseInt(perspective_act[i]);
  491.         }
  492.         var perspective_rea = rows.map(function(row) {
  493.             if (row.status == '1' || row.status == '2' || row.status == '3' || row.status == '4' || row.status == '6') {
  494.                 return row.salesum
  495.             }
  496.         }).filter(function(x) {
  497.             return typeof x !== 'undefined';
  498.         })
  499.         var perspective_real = 0;
  500.         for (var i = 0; i < perspective_rea.length; i++) {
  501.             perspective_real = perspective_real + parseInt(perspective_rea[i]);
  502.         }
  503.  
  504.         var manager_salary = real_income * 0.2
  505.         var developer_salary = actual_income * 0.05
  506.  
  507.         $.json({
  508.             "rows": [{
  509.                 'tasks': rows.length,
  510.                 'not_payed': not_payed.length,
  511.                 'payed': payed.length,
  512.                 'in_development': in_development.length,
  513.                 'done': done.length,
  514.                 'ended': ended.length,
  515.                 're_edit': re_edit.length,
  516.                 'actual_income': actual_income,
  517.                 'real_income': real_income,
  518.                 'perspective_actual': perspective_actual,
  519.                 'perspective_real': perspective_real,
  520.                 'manager_salary': manager_salary,
  521.                 'developer_salry': developer_salary
  522.             }]
  523.         })
  524.     })
  525. })
  526. app.get('/task.new', function($) {
  527.     connection.query("INSERT INTO `get`.`tasks`(`name`, `about`, `manager_id`, `client_id`, `developer_id`, `category`, `sub`, `status`, `sum`, `salesum`, `date`) VALUES (" + connection.escape($.query.name) + ", " + connection.escape($.query.about) + ", " + connection.escape($.query.man_id) + ", " + connection.escape($.query.client_id) + ", " + connection.escape($.query.dev_id) + ", " + connection.escape($.query.cat) + ", " + connection.escape($.query.dops) + ", " + connection.escape($.query.status) + ", " + connection.escape($.query.pay_price) + ", " + connection.escape($.query.sale_sum) + ", CURRENT_DATE())", function(err, rows, fields) {
  528.         if (!err) {
  529.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  530.             $.end('Success')
  531.         } else {
  532.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  533.             $.end(err + "<br>" + rows)
  534.         }
  535.     })
  536. })
  537. //users
  538. app.get('/user.add', function($) {
  539.     connection.query("INSERT INTO `get`.`tbl_users`(`userName`, `userEmail`, `userPass`, `userStatus`, `group`, `tokenCode`) VALUES (" + connection.escape($.query.name) + "," + connection.escape($.query.mail) + "," + connection.escape($.query.pass) + ", 'Y', " + connection.escape($.query.group) + "," + connection.escape($.query.token) + ")", function(err, rows, fields) {
  540.         if (!err) {
  541.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  542.             $.end('Success')
  543.         } else {
  544.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  545.             $.end(err)
  546.         }
  547.     })
  548. })
  549. app.get('/users.get', function($) {
  550.     connection.query("SELECT * FROM `get`.`tbl_users` WHERE `userStatus` = 'Y'", function(err, rows, fields) {
  551.         $.json({
  552.             rows
  553.         })
  554.     })
  555. })
  556. app.get('/users.getbyid', function($) {
  557.     connection.query("SELECT * FROM `get`.`tbl_users` WHERE `userID` =" + connection.escape($.query.id), function(err, rows, fields) {
  558.         $.json({
  559.             rows
  560.         })
  561.     })
  562. })
  563. app.get('/users.getsum', function($) {
  564.     connection.query("SELECT * FROM `get`.`tbl_users` WHERE 1", function(err, rows, fields) {
  565.         var developers = rows.map(function(row) {
  566.             if (row.group == 'developer') {
  567.                 return row.group
  568.             }
  569.         }).filter(function(x) {
  570.             return typeof x !== 'undefined';
  571.         })
  572.         var managers = rows.map(function(row) {
  573.             if (row.group == 'manager') {
  574.                 return row.group
  575.             }
  576.         }).filter(function(x) {
  577.             return typeof x !== 'undefined';
  578.         })
  579.         var admins = rows.map(function(row) {
  580.             if (row.group == 'admin') {
  581.                 return row.group
  582.             }
  583.         }).filter(function(x) {
  584.             return typeof x !== 'undefined';
  585.         })
  586.  
  587.         $.json({
  588.             "rows": [{
  589.                 'users': rows.length,
  590.                 'developers': developers.length,
  591.                 'managerts': managers.length,
  592.                 'admins': admins.length
  593.  
  594.             }]
  595.         })
  596.     })
  597. })
  598. app.get('/users.getin', function($) {
  599.     connection.query("SELECT * FROM `get`.`tbl_users` WHERE `userStatus` = 'N'", function(err, rows, fields) {
  600.         $.json({
  601.             rows
  602.         })
  603.     })
  604. })
  605. app.get('/user.update', function($) {
  606.     connection.query("UPDATE `get`.`tbl_users` SET `userName`=" + connection.escape($.query.name) + ",`userEmail`=" + connection.escape($.query.email) + ",`group`=" + connection.escape($.query.group) + " WHERE `userID`=" + connection.escape($.query.id), function(err, rows, fields) {
  607.         if (!err) {
  608.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  609.             $.end('Success')
  610.         } else {
  611.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  612.             $.end(err)
  613.         }
  614.     })
  615. })
  616. app.get('/user.inactive', function($) {
  617.     connection.query("UPDATE `get`.`tbl_users` SET `userStatus`= 'N' WHERE `userID`=" + connection.escape($.query.id), function(err, rows, fields) {
  618.         if (!err) {
  619.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  620.             $.end('Success')
  621.         } else {
  622.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  623.             $.end(err)
  624.         }
  625.     })
  626. })
  627. app.get('/user.active', function($) {
  628.     connection.query("UPDATE `get`.`tbl_users` SET `userStatus`= 'Y' WHERE `userID`=" + connection.escape($.query.id), function(err, rows, fields) {
  629.         if (!err) {
  630.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  631.             $.end('Success')
  632.         } else {
  633.             $.header('Access-Control-Allow-Origin', 'http://get.tepolis.ru')
  634.             $.end(err)
  635.         }
  636.     })
  637. })
  638.  
  639. function conn() {
  640.     connection.query("SELECT * FROM `get`.`history` WHERE  1", function(err, rows, fields) {
  641.         console.log(rows)
  642.     })
  643. }
  644. setInterval(conn, 24000000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement