/modules/Administration/callJSRepair.php

https://github.com/ganesharun77/TestProjec · PHP · 77 lines · 27 code · 11 blank · 39 comment · 10 complexity · 4928fbcaddb3032ba3c29abfb866f3a6 MD5 · raw file

  1. <?php
  2. if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
  3. /*********************************************************************************
  4. * The contents of this file are subject to the SugarCRM Master Subscription
  5. * Agreement ("License") which can be viewed at
  6. * http://www.sugarcrm.com/crm/en/msa/master_subscription_agreement_11_April_2011.pdf
  7. * By installing or using this file, You have unconditionally agreed to the
  8. * terms and conditions of the License, and You may not use this file except in
  9. * compliance with the License. Under the terms of the license, You shall not,
  10. * among other things: 1) sublicense, resell, rent, lease, redistribute, assign
  11. * or otherwise transfer Your rights to the Software, and 2) use the Software
  12. * for timesharing or service bureau purposes such as hosting the Software for
  13. * commercial gain and/or for the benefit of a third party. Use of the Software
  14. * may be subject to applicable fees and any use of the Software without first
  15. * paying applicable fees is strictly prohibited. You do not have the right to
  16. * remove SugarCRM copyrights from the source code or user interface.
  17. *
  18. * All copies of the Covered Code must include on each user interface screen:
  19. * (i) the "Powered by SugarCRM" logo and
  20. * (ii) the SugarCRM copyright notice
  21. * in the same form as they appear in the distribution. See full license for
  22. * requirements.
  23. *
  24. * Your Warranty, Limitations of liability and Indemnity are expressly stated
  25. * in the License. Please refer to the License for the specific language
  26. * governing these rights and limitations under the License. Portions created
  27. * by SugarCRM are Copyright (C) 2004-2011 SugarCRM, Inc.; All Rights Reserved.
  28. ********************************************************************************/
  29. /*
  30. **this is the ajax call that is called from RebuildJSLang.php. It processes
  31. **the Request object in order to call correct methods for repairing/rebuilding JSfiles
  32. *Note that minify.php has already been included as part of index.php, so no need to include again.
  33. */
  34. //set default root directory
  35. $from = getcwd();
  36. if(isset($_REQUEST['root_directory']) && !empty($_REQUEST['root_directory'])){
  37. $from = $_REQUEST['root_directory'];
  38. }
  39. //this script can take a while, change max execution time to 10 mins
  40. $tmp_time = ini_get('max_execution_time');
  41. ini_set('max_execution_time','600');
  42. //figure out which commands to call.
  43. if($_REQUEST['js_admin_repair'] == 'concat' ){
  44. //concatenate mode, call the files that will concatenate javascript group files
  45. $_REQUEST['js_rebuild_concat'] = 'rebuild';
  46. require_once('jssource/minify.php');
  47. }else{
  48. $_REQUEST['root_directory'] = getcwd();
  49. require_once('jssource/minify.php');
  50. if($_REQUEST['js_admin_repair'] == 'replace'){
  51. //should replace compressed JS with source js
  52. reverseScripts("$from/jssource/src_files","$from");
  53. }elseif($_REQUEST['js_admin_repair'] == 'mini'){
  54. //should replace compressed JS with minified version of source js
  55. reverseScripts("$from/jssource/src_files","$from");
  56. BackUpAndCompressScriptFiles("$from","",false);
  57. ConcatenateFiles("$from");
  58. }elseif($_REQUEST['js_admin_repair'] == 'repair'){
  59. //should compress existing javascript (including changes done) without overwriting original source files
  60. BackUpAndCompressScriptFiles("$from","",false);
  61. ConcatenateFiles("$from");
  62. }
  63. }
  64. //set execution time back to what it was
  65. ini_set('max_execution_time',$tmp_time);
  66. ?>