Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.95 KB | None | 0 0
  1. <?php
  2.  
  3. defined('BASEPATH') OR exit('No direct script access allowed');
  4.  
  5. class Action extends CI_Controller {
  6.  
  7. public function index() {
  8. redirect(site_url() . 'home');
  9. }
  10.  
  11. public function login() {
  12. if ($this->session->userdata('logged_in') === true AND ! empty($this->session->userdata('csrf_token'))) {
  13. redirect(site_url() . 'home');
  14. } else {
  15. $user = filter($this->input->post('user'));
  16. $pass = sha1($this->input->post('pass'));
  17. $this->db->where('user', $user);
  18. $this->db->where('pass', $pass);
  19. if ($this->db->get('users')->num_rows() == 1) {
  20. $this->session->set_userdata('logged_in', true);
  21. $this->session->set_userdata('user', $user);
  22. $this->session->set_userdata('csrf_token', sha1(md5(time())));
  23. }
  24. redirect(site_url() . '3xPanelShit');
  25. }
  26. }
  27.  
  28. public function logout() {
  29. if ($this->session->userdata('logged_in')) {
  30. $this->session->sess_destroy();
  31. }
  32. redirect(site_url() . '3xPanelShit');
  33. }
  34.  
  35. public function add_cpanel() {
  36. if ($this->input->post('csrf_token') == $this->session->userdata('csrf_token') AND $this->session->userdata('logged_in') === true) {
  37. $string = $this->input->post('string');
  38. $cArr = explode("\n", $string);
  39. foreach ($cArr as $c) {
  40. $data = array('string' => $c);
  41. if ($this->db->insert('cpanels', $data)) {
  42. $status = 1;
  43. }
  44. }
  45. redirect(site_url() . '3xPanelShit');
  46. }
  47. }
  48.  
  49. public function edit_cpanel() {
  50. if ($this->input->post('csrf_token') == $this->session->userdata('csrf_token') AND $this->session->userdata('logged_in') === true) {
  51. $string = $this->input->post('string');
  52. $data = array('string' => $string);
  53. $this->db->where('id', filter($this->input->post('id')));
  54. $this->db->update('cpanels', $data);
  55. $status = 1;
  56. redirect(site_url() . '3xPanelShit');
  57. }
  58. }
  59.  
  60. public function delete_cpanel() {
  61. if ($this->input->post('csrf_token') == $this->session->userdata('csrf_token') AND $this->session->userdata('logged_in') === true) {
  62. $string = $this->input->post('string');
  63. $this->db->where('id', filter($this->input->post('id')));
  64. $this->db->delete('cpanels');
  65. $status = 1;
  66. redirect(site_url() . '3xPanelShit');
  67. }
  68. }
  69.  
  70. public function add_mailer() {
  71. if ($this->input->post('csrf_token') == $this->session->userdata('csrf_token') AND $this->session->userdata('logged_in') === true) {
  72. $string = $this->input->post('string');
  73. $cArr = explode("\n", $string);
  74. foreach ($cArr as $c) {
  75. $data = array('string' => $c);
  76. if ($this->db->insert('mailers', $data)) {
  77. $status = 1;
  78. }
  79. }
  80. redirect(site_url() . '3xPanelShit');
  81. }
  82. }
  83.  
  84. public function edit_mailer() {
  85. if ($this->input->post('csrf_token') == $this->session->userdata('csrf_token') AND $this->session->userdata('logged_in') === true) {
  86. $string = $this->input->post('string');
  87. $data = array('string' => $string);
  88. $this->db->where('id', filter($this->input->post('id')));
  89. $this->db->update('mailers', $data);
  90. $status = 1;
  91. redirect(site_url() . '3xPanelShit');
  92. }
  93. }
  94.  
  95. public function delete_mailer() {
  96. if ($this->input->post('csrf_token') == $this->session->userdata('csrf_token') AND $this->session->userdata('logged_in') === true) {
  97. $string = $this->input->post('string');
  98. $this->db->where('id', filter($this->input->post('id')));
  99. $this->db->delete('mailers');
  100. $status = 1;
  101. redirect(site_url() . '3xPanelShit');
  102. }
  103. }
  104.  
  105. public function add_shell() {
  106. if ($this->input->post('csrf_token') == $this->session->userdata('csrf_token') AND $this->session->userdata('logged_in') === true) {
  107. $string = $this->input->post('string');
  108. $cArr = explode("\n", $string);
  109. foreach ($cArr as $c) {
  110. $data = array('string' => $c);
  111. if ($this->db->insert('shells', $data)) {
  112. $status = 1;
  113. }
  114. }
  115. redirect(site_url() . '3xPanelShit');
  116. }
  117. }
  118.  
  119. public function edit_shell() {
  120. if ($this->input->post('csrf_token') == $this->session->userdata('csrf_token') AND $this->session->userdata('logged_in') === true) {
  121. $string = $this->input->post('string');
  122. $data = array('string' => $string);
  123. $this->db->where('id', filter($this->input->post('id')));
  124. $this->db->update('shells', $data);
  125. $status = 1;
  126. redirect(site_url() . '3xPanelShit');
  127. }
  128. }
  129.  
  130. public function delete_shell() {
  131. if ($this->input->post('csrf_token') == $this->session->userdata('csrf_token') AND $this->session->userdata('logged_in') === true) {
  132. $string = $this->input->post('string');
  133. $this->db->where('id', filter($this->input->post('id')));
  134. $this->db->delete('shells');
  135. $status = 1;
  136. redirect(site_url() . '3xPanelShit');
  137. }
  138. }
  139.  
  140. public function update_pricing() {
  141. if ($this->input->post('csrf_token') == $this->session->userdata('csrf_token') AND $this->session->userdata('logged_in') === true) {
  142. $data = array(
  143. 'cpanel' => filter($this->input->post('cpanel')),
  144. 'mailer' => filter($this->input->post('mailer')),
  145. 'shell' => filter($this->input->post('shell')),
  146. );
  147. $this->db->update('pricing', $data);
  148. redirect(site_url() . '3xPanelShit');
  149. }
  150. }
  151.  
  152. public function update_pm_setting() {
  153. if ($this->input->post('csrf_token') == $this->session->userdata('csrf_token') AND $this->session->userdata('logged_in') === true) {
  154. $data = array(
  155. 'PAYEE_ACCOUNT' => filter($this->input->post('account')),
  156. 'ALTERNATE_PASSPHRASE' => filter($this->input->post('passphrase')),
  157. 'DISPLAY_NAME' => filter($this->input->post('display'))
  158. );
  159. $this->db->update('pm_settings', $data);
  160. redirect(site_url() . '3xPanelShit');
  161. }
  162. }
  163.  
  164. public function update_btc_setting() {
  165. if ($this->input->post('csrf_token') == $this->session->userdata('csrf_token') AND $this->session->userdata('logged_in') === true) {
  166. $data = array(
  167. 'btc_secret' => filter($this->input->post('secret')),
  168. 'btc_api' => filter($this->input->post('api')),
  169. 'btc_xpub' => filter($this->input->post('xpub'))
  170. );
  171. $this->db->update('setting', $data);
  172. redirect(site_url() . '3xPanelShit');
  173. }
  174. }
  175.  
  176. public function update_system_setting() {
  177. if ($this->input->post('csrf_token') == $this->session->userdata('csrf_token') AND $this->session->userdata('logged_in') === true) {
  178. $data = array(
  179. 'icq_id' => filter($this->input->post('icq')),
  180. 'shell_id' => filter($this->input->post('shell')),
  181. 'mailer_id' => filter($this->input->post('mailer')),
  182. 'video_embed_content' => $this->input->post('vdc'),
  183. 'box1_title' => filter($this->input->post('b1t')),
  184. 'box1_content' => $this->input->post('b1c'),
  185. 'box2_title' => filter($this->input->post('b2t')),
  186. 'box2_content' => $this->input->post('b2c'),
  187. 'box3_title' => filter($this->input->post('b3t')),
  188. 'box3_content' => $this->input->post('b3c'),
  189. );
  190. $this->db->update('setting', $data);
  191. redirect(site_url() . '3xPanelShit');
  192. }
  193. }
  194.  
  195. public function get_price() {
  196. $item = filter($this->input->post('item'));
  197. if (!empty($item) AND ( $item == "cpanel" OR $item == "mailer" OR $item == "shell")) {
  198. $price = $this->db->get('pricing')->row()->$item;
  199. if ($item == "cpanel") {
  200. $stock = $this->db->get("cpanels")->num_rows();
  201. } elseif ($item == "mailer") {
  202. $stock = $this->db->get("mailers")->num_rows();
  203. } elseif ($item == "shell") {
  204. $stock = $this->db->get("shells")->num_rows();
  205. }
  206. $data = array(
  207. "price" => $price,
  208. "btcprice" => usdToBtc($price),
  209. "stock" => $stock
  210. );
  211. echo json_encode($data);
  212. } else {
  213. $data = array(
  214. "price" => 0,
  215. "btcprice" => usdToBtc($price),
  216. "stock" => 0
  217. );
  218. echo json_encode($data);
  219. }
  220. }
  221.  
  222. public function confirm_item() {
  223. $item = filter($this->input->post('item'));
  224. $quantity = filter($this->input->post('quantity'));
  225. if (is_numeric($quantity) AND ( $item == "cpanel" OR $item == "mailer" OR $item == "shell")) {
  226. $this->load->helper('string');
  227. $payment_id = random_string('alnum', 22);
  228. $secret = sha1(md5(time()));
  229. $this->session->set_userdata('item', $item);
  230. $this->session->set_userdata('quantity', $quantity);
  231. $this->session->set_userdata('selection', 'true');
  232. $this->session->set_userdata('payment_id', $payment_id);
  233. $this->session->set_userdata('file_name', sha1(time()));
  234. $this->session->set_userdata('payment_method', 'pm');
  235. $this->session->set_userdata('secret', $secret);
  236. $data = array(
  237. "status" => 1,
  238. "payment_id" => $payment_id
  239. );
  240. echo json_encode($data);
  241. } else {
  242. $data = array(
  243. "status" => 0
  244. );
  245. echo json_encode($data);
  246. }
  247. }
  248.  
  249. public function cancel_item() {
  250. $this->session->unset_userdata('item');
  251. $this->session->unset_userdata('quantity');
  252. $this->session->unset_userdata('selection');
  253. $this->session->unset_userdata('payment_id');
  254. $this->session->unset_userdata('file_name');
  255. $this->session->unset_userdata('payment_method');
  256. $this->session->unset_userdata('secret');
  257. $data = array(
  258. "status" => 1
  259. );
  260. echo json_encode($data);
  261. }
  262.  
  263. public function set_btc_payment_method() {
  264. $this->session->unset_userdata('payment_method');
  265. $this->session->set_userdata('payment_method', 'btc');
  266. if ($this->session->userdata('selection') == "true") {
  267. $secret = $this->db->get('setting')->row()->btc_secret;
  268. $invoice_id = $this->session->userdata('payment_id');
  269. $my_xpub = $this->db->get('setting')->row()->btc_xpub;
  270. $my_api_key = $this->db->get('setting')->row()->btc_api;
  271. $my_callback_url = site_url() . 'process/process_btc_transaction?secret=' . $secret . '&invoice_id=' . $invoice_id;
  272. $gap_check_url = "https://api.blockchain.info/v2/receive/checkgap?xpub=" . $my_xpub . "&key=" . $my_api_key;
  273. $gap_check_response = file_get_contents($gap_check_url);
  274. $gap_limit = (int) json_decode($gap_check_response)->gap + 2;
  275. $root_url = 'https://api.blockchain.info/v2/receive';
  276. $parameters = 'xpub=' . $my_xpub . '&callback=' . urlencode($my_callback_url) . '&key=' . $my_api_key . '&gap_limit=' . $gap_limit;
  277. $response = file_get_contents($root_url . '?' . $parameters);
  278. $data = json_decode($response);
  279. $address = $data->address;
  280. $item = $this->session->userdata('item');
  281. $item_price = $this->db->get('pricing')->row()->$item;
  282. $total_price = usdToBtc($item_price * $this->session->userdata('quantity'));
  283. $this->session->set_userdata('btc_address', $address);
  284. $this->session->set_userdata('btc_amount', $total_price);
  285. $this->session->set_userdata('usd_amount', $item_price * $this->session->userdata('quantity'));
  286. if (!empty($address)) {
  287. //process address monitor
  288. $ch = curl_init();
  289. curl_setopt($ch, CURLOPT_URL, "https://api.blockchain.info/v2/receive/balance_update");
  290. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  291. curl_setopt($ch, CURLOPT_POST, true);
  292. $data = array(
  293. 'key' => $my_api_key,
  294. 'addr' => $address,
  295. 'callback' => $my_callback_url,
  296. 'onNotification' => 'DELETE',
  297. 'op' => 'RECEIVE',
  298. 'confs' => '4'
  299. );
  300. $json_data = json_encode($data);
  301. curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
  302. curl_close($ch);
  303. //end processing address monitor
  304. $data = array(
  305. "status" => 1,
  306. "address" => $address,
  307. "amount" => $total_price
  308. );
  309. echo json_encode($data);
  310. } else {
  311. $data = array(
  312. "status" => 0,
  313. "data" => $data
  314. );
  315. echo json_encode($data);
  316. }
  317. } else {
  318. $data = array(
  319. "status" => 0
  320. );
  321. echo json_encode($data);
  322. }
  323. }
  324.  
  325. public function check_btc_payment() {
  326. $btc_address = $this->session->userdata('btc_address');
  327. $url = "https://blockchain.info/q/addressbalance/" . $btc_address;
  328. $response = file_get_contents($url);
  329. $value_in_btc = $response / 100000000; //received btc value
  330. $value_in_usd = btcToUsd($value_in_btc);
  331. if ($this->session->userdata('selection') == "true" AND $this->session->userdata('payment_method') == "btc") {
  332. if ($value_in_usd > ($this->session->userdata('usd_amount') * 0.98)) {
  333. $this->session->set_userdata('btc_payment_verified', 1);
  334. $data = array(
  335. "status" => 1
  336. );
  337. echo json_encode($data);
  338. } else {
  339. $data = array(
  340. "status" => 0
  341. );
  342. echo json_encode($data);
  343. }
  344. } else {
  345. $data = array(
  346. "status" => false
  347. );
  348. echo json_encode($data);
  349. }
  350. }
  351.  
  352. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement