1
0

updateWidgets.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) 2008 - 2018 The OGP Development Team
  6. *
  7. * http://www.opengamepanel.org/
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. */
  24. function exec_ogp_module()
  25. {
  26. global $db;
  27. if(!$_POST["data"]){
  28. echo "Invalid data";
  29. exit;
  30. }
  31. //decode JSON data received from AJAX POST request
  32. $data=$_POST["data"];
  33. $data = str_replace('\\','',$data);
  34. $data = json_decode($data);
  35. foreach($data->items as $item)
  36. {
  37. //Extract column number for panel
  38. $col_id = preg_replace('/[^\d\s]/', '', $item->column);
  39. //Extract id of the panel
  40. $widget_id = preg_replace('/[^\d\s]/', '', $item->id);
  41. if (is_numeric($col_id) && is_numeric($widget_id)) {
  42. $db->query("UPDATE ".OGP_DB_PREFIX."widgets_users SET column_id='$col_id', sort_no='".(int)$item->order."', collapsed='".(int)$item->collapsed."' WHERE widget_id='".$widget_id."' AND user_id='".$_SESSION['user_id']."'");
  43. }
  44. }
  45. echo "success";
  46. }
  47. ?>