PageRenderTime 43ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/endpointmanager-1.0/endpointman/includes/update_check.php

https://github.com/robertleeplummerjr/bluebox
PHP | 107 lines | 1 code | 0 blank | 106 comment | 0 complexity | 9cc67e9d9b08cf952c32035d86638a03 MD5 | raw file
  1. <?PHP
  2. /**
  3. * Endpoint Manager Update Check File
  4. *
  5. * @author Andrew Nagy
  6. * @license MPL / GPLv2 / LGPL
  7. * @package Provisioner
  8. error_reporting(0);
  9. $rfh=fopen("/etc/amportal.conf","r") or Die("amportal.conf did not open.");
  10. if ($rfh) {
  11. while (!feof($rfh)) {
  12. $line = fgets($rfh);
  13. if (strstr($line,"AMPDBUSER=")) {
  14. $temp=explode("=",$line);
  15. $temp[1]=trim($temp[1]);
  16. $ampdata['user'] = $temp[1];
  17. }elseif (strstr($line,"AMPDBPASS=")) {
  18. $temp=explode("=",$line);
  19. $temp[1]=trim($temp[1]);
  20. $ampdata['pass'] = $temp[1];
  21. }
  22. }
  23. }
  24. echo "Welcome\n";
  25. include 'functions.inc';
  26. global $endpoint, $amp_conf;
  27. $amp_conf['AMPDBUSER'] = $ampdata['user'];
  28. $amp_conf['AMPDBPASS'] = $ampdata['pass'];
  29. $amp_conf['AMPDBNAME'] = 'asterisk';
  30. $endpoint = new endpointmanager();
  31. $brand_up = $endpoint->brand_update_check();
  32. $note = "<br/> <br/>NOTE: This was generated by the Endpoint Manager Module, not by FreePBX<br/> You can turn off these updates on the settings page within the Endpoint Manager Settings Page";
  33. $sql="SELECT * from endpointman_brand_list WHERE id > 0 AND hidden = 0 AND installed = 1 ORDER BY id ASC ";
  34. $result=mysql_query($sql);
  35. $i = 0;
  36. while($row = mysql_fetch_assoc($result)) {
  37. $row_out[$i] = $row;
  38. $row_out[$i]['count'] = $i;
  39. $id = $endpoint->arraysearchrecursive($row['name'], $brand_up,'brand_name');
  40. $id = $id[0];
  41. if(isset($brand_up[$id]['update'])) {
  42. echo "Brand '".$brand_up[$id]['brand_name']."' has updates available\n";
  43. echo "Old Version: ".$row['cfg_ver']." New Version: ".$brand_up[$id]['version']."\n";
  44. echo "Changes: ". $brand_up[$id]['changes']."\n";
  45. $endpoint->add_freepbx_notification("PU_".$brand_up[$id]['brand_name'], '', "Brand \'".$brand_up[$id]['brand_name']."\' has updates available", "Old Version: ".$row['cfg_ver']." New Version: ".$brand_up[$id]['version']."<br/>"."Changes: ". $brand_up[$id]['changes'].$note, "");
  46. $email_message .= "Brand \'".$brand_up[$id]['brand_name']."\' has updates available \n Old Version: ".$row['cfg_ver']." New Version: ".$brand_up[$id]['version']."\n"."Changes: ". $brand_up[$id]['changes']."\n\n";
  47. }
  48. if($row['installed']){
  49. $j = 0;
  50. $sql = 'SELECT * FROM endpointman_product_list WHERE hidden = 0 AND brand = '.$row['id'].' ORDER BY long_name ASC';
  51. $result2=mysql_query($sql);
  52. while($row2 = mysql_fetch_assoc($result2)) {
  53. $row_out[$i]['products'][$j] = $row2;
  54. if(($temp = $endpoint->product_update_check($row2['id'])) AND ($row2['installed'] == 1)) {
  55. echo "Product '".$row2['long_name']."' has updates available\n";
  56. echo "Old Version: ".$row2['cfg_ver']." New Version: ".$temp['data']['version']."\n";
  57. echo "Changes: ". $temp['data']['description']."\n";
  58. $endpoint->add_freepbx_notification("PU_".$row2['long_name'], '', "There is a Product update for ".$row2['long_name'], "Old Version: ".$row2['cfg_ver']." New Version: ".$temp['data']['version']."<br/>"."Changes: ". $temp['data']['description'].$note, "");
  59. $email_message .= "There is a Product update for ".$row2['long_name']."\n"."Old Version: ".$row2['cfg_ver']." New Version: ".$temp['data']['version']."\n"."Changes: ". $temp['data']['description']."\n\n";
  60. }
  61. if(($temp = $endpoint->firmware_update_check($row2['id'])) AND ($row['firmware_vers'] > 0)) {
  62. echo "Product '".$row2['long_name']."' has new firmware available\n";
  63. echo "Old Version: ".$row2['cfg_ver']." New Version: ".$temp['data']['version']."\n";
  64. $endpoint->add_freepbx_notification("PU_".$row2['long_name'], '', "There is a firmware update for phone module ".$row2['long_name'], "Old Version: ".$row2['firmware_vers']." New Version: ".$temp['data']['version'].$note, "");
  65. $email_message .= "There is a firmware update for phone module ".$row2['long_name']."\n Old Version: ".$row2['firmware_vers']." New Version: ".$temp['data']['version']."\n\n";
  66. }
  67. $j++;
  68. }
  69. }
  70. $i++;
  71. }
  72. $email_message .= "\n\n\nNOTE: This was generated by the Endpoint Manager Module, not by FreePBX\n You can turn off these updates on the settings page within the Endpoint Manager Settings Page";
  73. $sql = 'SELECT * FROM `admin` WHERE `variable` = CONVERT(_utf8 \'email\' USING latin1) COLLATE latin1_swedish_ci';
  74. $result=mysql_query($sql);
  75. $row = mysql_fetch_assoc($result);
  76. $email = $row['value'];
  77. $time = time() - 25200;
  78. $sql = 'SELECT * FROM `notifications` WHERE `module` = CONVERT(_utf8 \'endpointman\' USING latin1) COLLATE latin1_swedish_ci';
  79. $result=mysql_query($sql);
  80. while($row = mysql_fetch_assoc($result)) {
  81. if(($row['timestamp'] > $time) AND ($row['reset'] != 1)) {
  82. // In case any of our lines are larger than 70 characters, we should use wordwrap()
  83. $message = wordwrap($email_message, 70);
  84. // Send
  85. mail($email, 'Phone Updates Available', $message);
  86. }
  87. }
  88. *
  89. */