Duplicator – WordPress Migration Plugin - Version 1.3.14

Version Description

Download this release

Release Info

Developer cory@lamle.org
Plugin Icon 128x128 Duplicator – WordPress Migration Plugin
Version 1.3.14
Comparing to
See all releases

Code changes from version 1.3.12 to 1.3.14

Files changed (98) hide show
  1. assets/img/logo-box.png +0 -0
  2. assets/img/logo-dpro-300x50.png +0 -0
  3. assets/img/logo-menu.svg +50 -8
  4. classes/class.archive.config.php +0 -2
  5. classes/class.logging.php +1 -1
  6. classes/class.settings.php +9 -0
  7. classes/package/class.pack.archive.zip.php +2 -2
  8. classes/package/class.pack.database.php +34 -3
  9. classes/package/class.pack.installer.php +16 -15
  10. classes/package/class.pack.php +215 -60
  11. classes/package/duparchive/class.pack.archive.duparchive.php +2 -2
  12. classes/package/duparchive/class.pack.archive.duparchive.state.expand.php +3 -3
  13. classes/utilities/class.u.json.php +2 -58
  14. ctrls/class.web.services.php +11 -7
  15. ctrls/ctrl.base.php +2 -2
  16. ctrls/ctrl.package.php +6 -5
  17. deactivation.php +2 -1
  18. define.php +2 -3
  19. duplicator.php +5 -2
  20. installer/dup-installer/assets/inc.css.php +142 -46
  21. installer/dup-installer/classes/Crypt/Random.php +2 -2
  22. installer/dup-installer/classes/Crypt/Rijndael.php +1 -1
  23. installer/dup-installer/classes/class.csrf.php +1 -44
  24. installer/dup-installer/classes/class.engine.php +1 -0
  25. installer/dup-installer/classes/class.installer.state.php +4 -6
  26. installer/dup-installer/classes/class.logging.php +24 -12
  27. installer/dup-installer/classes/class.password.php +0 -2
  28. installer/dup-installer/classes/config/class.archive.config.php +1 -1
  29. installer/dup-installer/classes/config/class.boot.php +11 -4
  30. installer/dup-installer/classes/config/class.conf.srv.php +4 -4
  31. installer/dup-installer/classes/config/class.constants.php +5 -5
  32. installer/dup-installer/classes/utilities/class.u.exceptions.php +1 -1
  33. installer/dup-installer/classes/utilities/class.u.html.php +257 -10
  34. installer/dup-installer/classes/utilities/class.u.notices.manager.php +225 -61
  35. installer/dup-installer/classes/utilities/class.u.php +5 -5
  36. installer/dup-installer/ctrls/ctrl.s1.php +30 -21
  37. installer/dup-installer/ctrls/ctrl.s2.base.php +1 -1
  38. installer/dup-installer/ctrls/ctrl.s2.dbtest.php +56 -3
  39. installer/dup-installer/ctrls/ctrl.s3.php +4 -4
  40. installer/dup-installer/favicon/browserconfig.xml +9 -0
  41. installer/dup-installer/favicon/lite01_android-chrome-192x192.png +0 -0
  42. installer/dup-installer/favicon/lite01_android-chrome-256x256.png +0 -0
  43. installer/dup-installer/favicon/lite01_apple-touch-icon.png +0 -0
  44. installer/dup-installer/favicon/lite01_favicon-16x16.png +0 -0
  45. installer/dup-installer/favicon/lite01_favicon-32x32.png +0 -0
  46. installer/dup-installer/favicon/lite01_favicon.ico +0 -0
  47. installer/dup-installer/favicon/lite01_mstile-150x150.png +0 -0
  48. installer/dup-installer/favicon/lite01_safari-pinned-tab.svg +42 -0
  49. installer/dup-installer/favicon/site.webmanifest +19 -0
  50. installer/dup-installer/main.installer.php +48 -53
  51. installer/dup-installer/views/view.init1.php +45 -59
  52. installer/dup-installer/views/view.s1.base.php +34 -30
  53. installer/dup-installer/views/view.s2.basic.php +11 -1
  54. installer/dup-installer/views/view.s2.dbtest.php +73 -7
  55. installer/dup-installer/views/view.s3.php +14 -7
  56. installer/dup-installer/views/view.s4.php +4 -4
  57. installer/installer.tpl +2 -4100
  58. lib/config/class.wp.config.tranformer.php +6 -2
  59. lib/dup_archive/classes/class.duparchive.engine.php +16 -16
  60. lib/dup_archive/classes/class.duparchive.mini.expander.php +1 -1
  61. lib/dup_archive/classes/headers/class.duparchive.header.directory.php +2 -2
  62. lib/dup_archive/classes/headers/class.duparchive.header.file.php +3 -3
  63. lib/dup_archive/classes/headers/class.duparchive.header.glob.php +2 -2
  64. lib/dup_archive/classes/headers/class.duparchive.header.php +2 -2
  65. lib/dup_archive/classes/headers/class.duparchive.header.u.php +1 -1
  66. lib/dup_archive/classes/processors/class.duparchive.processor.directory.php +1 -1
  67. lib/dup_archive/classes/processors/class.duparchive.processor.file.php +11 -11
  68. lib/dup_archive/classes/util/class.duparchive.u.json.php +3 -11
  69. lib/dup_archive/classes/util/class.duparchive.util.php +4 -4
  70. lib/dup_archive/daws/class.daws.state.expand.php +15 -15
  71. lib/dup_archive/daws/daws.php +50 -50
  72. lib/dup_archive/tester/classes/class.datester.state.create.php +12 -12
  73. lib/dup_archive/tester/classes/class.datester.state.expand.php +12 -12
  74. lib/dup_archive/tester/datester.php +10 -10
  75. lib/snaplib/class.snaplib.exceptions.php +6 -3
  76. lib/snaplib/class.snaplib.logger.php +74 -71
  77. lib/snaplib/class.snaplib.u.io.php +231 -228
  78. lib/snaplib/class.snaplib.u.net.php +35 -32
  79. lib/snaplib/class.snaplib.u.os.php +12 -11
  80. lib/snaplib/class.snaplib.u.stream.php +12 -9
  81. lib/snaplib/class.snaplib.u.string.php +37 -54
  82. lib/snaplib/class.snaplib.u.ui.php +28 -25
  83. lib/snaplib/class.snaplib.u.url.php +41 -38
  84. lib/snaplib/class.snaplib.u.util.php +381 -356
  85. lib/snaplib/class.snaplib.u.wp.php +97 -95
  86. lib/snaplib/snaplib.all.php +16 -12
  87. lib/snaplib/wordpress.core.files.php +0 -1
  88. readme.txt +2 -2
  89. uninstall.php +4 -0
  90. views/packages/details/detail.php +1 -1
  91. views/packages/main/packages.php +91 -133
  92. views/packages/main/s1.setup2.php +1 -1
  93. views/packages/main/s2.scan3.php +2 -2
  94. views/settings/about-info.php +126 -116
  95. views/settings/gopro.php +8 -3
  96. views/settings/license.php +1 -1
  97. views/settings/packages.php +1 -1
  98. views/tools/diagnostics/logging.php +1 -1
assets/img/logo-box.png CHANGED
Binary file
assets/img/logo-dpro-300x50.png CHANGED
Binary file
assets/img/logo-menu.svg CHANGED
@@ -1,12 +1,54 @@
1
  <?xml version="1.0" encoding="utf-8"?>
2
  <!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Artwork" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="23.25px" height="22.375px" viewBox="0 0 23.25 22.375" enable-background="new 0 0 23.25 22.375" xml:space="preserve">
6
- <path fill="#9CA1A6" d="M18.011,1.188c-1.995,0-3.615,1.618-3.615,3.614c0,0.085,0.008,0.167,0.016,0.25L7.733,8.184
7
- C7.084,7.565,6.208,7.182,5.24,7.182c-1.996,0-3.615,1.619-3.615,3.614c0,1.996,1.619,3.613,3.615,3.613
8
- c0.629,0,1.222-0.162,1.737-0.445l2.89,2.438c-0.126,0.368-0.198,0.763-0.198,1.173c0,1.995,1.618,3.613,3.614,3.613
9
- c1.995,0,3.615-1.618,3.615-3.613c0-1.997-1.62-3.614-3.615-3.614c-0.63,0-1.222,0.162-1.737,0.443l-2.89-2.435
10
- c0.126-0.368,0.198-0.763,0.198-1.173c0-0.084-0.008-0.166-0.013-0.25l6.676-3.133c0.648,0.619,1.525,1.002,2.495,1.002
11
- c1.994,0,3.613-1.617,3.613-3.613C21.625,2.806,20.006,1.188,18.011,1.188z"/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  </svg>
1
  <?xml version="1.0" encoding="utf-8"?>
2
  <!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ width="256px" height="256px" viewBox="0 0 256 256" enable-background="new 0 0 256 256" xml:space="preserve">
6
+ <g>
7
+ <g>
8
+ <path fill="#A7A9AC" d="M172.103,35.223l-1.395-24.097L153.36,6.478l-13.253,20.171c-6.742-0.675-13.535-0.696-20.276-0.042
9
+ L106.467,6.27l-17.348,4.647l-1.4,24.204c-6.073,2.724-11.93,6.074-17.485,10.039L48.403,34.183L35.704,46.882l10.91,21.701
10
+ c-4.011,5.522-7.396,11.352-10.17,17.397l-24.367,1.41l-4.648,17.348l20.241,13.3c-0.708,6.734-0.785,13.523-0.166,20.265
11
+ l-20.284,13.33l4.648,17.348l23.324,1.349l0.227-0.826l9.106-33.176c-2.125-24.333,6.104-49.397,24.729-68.023
12
+ c27.393-27.393,68.71-32.315,101.145-14.833L54.422,169.447l-2.585-32.355L30.89,213.398l31.614-31.614L182.735,61.553
13
+ l4.204-4.206l7.978-7.978C187.836,43.557,180.15,38.857,172.103,35.223z"/>
14
+ <path fill="#A7A9AC" d="M105.214,9.558l12.231,18.614l0.945,1.44l1.715-0.166c3.182-0.308,6.423-0.465,9.634-0.465
15
+ c3.347,0,6.736,0.17,10.082,0.506l1.719,0.172l0.95-1.444l12.122-18.449l13.365,3.581l1.274,22.041l0.101,1.724l1.573,0.711
16
+ c7.036,3.175,13.652,7.136,19.711,11.791l-5.717,5.718l-4.203,4.203L60.485,179.766l-23.991,23.992l13.792-50.244l1.292,16.162
17
+ l0.493,6.159l4.369-4.367L172.416,55.49l2.709-2.711l-3.372-1.818c-12.829-6.915-27.349-10.571-41.994-10.571
18
+ c-23.62,0-45.823,9.198-62.522,25.897C48.833,84.69,39.52,110.095,41.639,136.061l-8.587,31.288l-18.962-1.099l-3.581-13.363
19
+ l18.562-12.198l1.431-0.942l-0.156-1.704c-0.592-6.436-0.538-13.065,0.161-19.706l0.182-1.728l-1.452-0.955l-18.518-12.167
20
+ l3.581-13.366l22.309-1.291l1.712-0.098l0.717-1.559c2.729-5.948,6.055-11.639,9.885-16.913l1.021-1.406l-0.779-1.552
21
+ l-9.984-19.859l9.784-9.784l19.988,10.049l1.538,0.774l1.401-1.001c5.343-3.811,11.061-7.094,16.997-9.757l1.581-0.712l0.1-1.728
22
+ l1.281-22.145L105.214,9.558 M106.467,6.27l-17.348,4.647l-1.4,24.204c-6.073,2.726-11.93,6.074-17.486,10.039l-21.83-10.976
23
+ l-12.7,12.701l10.91,21.699c-4.011,5.522-7.396,11.353-10.17,17.397l-24.367,1.41l-4.648,17.348l20.24,13.3
24
+ c-0.708,6.734-0.784,13.523-0.165,20.265l-20.284,13.33l4.648,17.348l23.324,1.349l0.227-0.826l9.106-33.176
25
+ c-2.125-24.333,6.104-49.397,24.729-68.023c16.71-16.711,38.607-25.06,60.505-25.06c13.998,0,27.992,3.411,40.64,10.227
26
+ L54.422,169.449l-2.585-32.357L30.89,213.398l31.614-31.614L182.735,61.553l4.203-4.204l7.979-7.979
27
+ c-7.083-5.815-14.767-10.513-22.814-14.147l-1.395-24.097L153.36,6.478l-13.254,20.17c-3.447-0.346-6.907-0.52-10.366-0.52
28
+ c-3.307,0-6.614,0.16-9.91,0.479L106.467,6.27L106.467,6.27z"/>
29
+ </g>
30
+ <g>
31
+ <path fill="#A7A9AC" d="M87.802,222.21l1.394,24.097l17.348,4.649l13.255-20.17c6.742,0.675,13.533,0.693,20.274,0.041
32
+ l13.365,20.335l17.347-4.646l1.399-24.202c6.073-2.725,11.93-6.074,17.486-10.038l21.831,10.974l12.699-12.698l-10.91-21.701
33
+ c4.012-5.521,7.396-11.352,10.169-17.398l24.369-1.408l4.646-17.348l-20.239-13.3c0.708-6.736,0.784-13.523,0.164-20.266
34
+ l20.284-13.328l-4.647-17.348l-23.323-1.349l-0.228,0.825l-9.107,33.175c2.127,24.332-6.104,49.397-24.729,68.024
35
+ c-27.392,27.393-68.709,32.315-101.144,14.831L205.48,87.984l2.586,32.356l20.948-76.305l-31.615,31.613L77.169,195.88
36
+ l-4.206,4.205l-7.978,7.979C72.068,213.876,79.752,218.575,87.802,222.21z"/>
37
+ <path fill="#A7A9AC" d="M223.409,53.676l-13.793,50.24l-1.29-16.16l-0.494-6.159l-4.368,4.37L87.487,201.942l-2.709,2.712
38
+ l3.373,1.818c12.828,6.914,27.351,10.568,41.997,10.568c23.618,0,45.821-9.195,62.52-25.896
39
+ c18.403-18.402,27.717-43.807,25.598-69.775l8.588-31.283l18.961,1.097l3.582,13.364l-18.563,12.197l-1.43,0.941l0.155,1.705
40
+ c0.592,6.436,0.539,13.067-0.16,19.706l-0.183,1.727l1.451,0.954l18.521,12.171l-3.582,13.365l-22.311,1.291l-1.712,0.099
41
+ l-0.716,1.56c-2.727,5.944-6.053,11.633-9.886,16.911l-1.02,1.404l0.78,1.554l9.983,19.859l-9.785,9.783l-19.99-10.05
42
+ l-1.536-0.772l-1.402,0.999c-5.341,3.814-11.059,7.096-16.994,9.758l-1.582,0.71l-0.099,1.729l-1.283,22.146l-13.363,3.581
43
+ l-12.233-18.615l-0.946-1.438l-1.713,0.163c-3.18,0.31-6.417,0.465-9.626,0.465c-3.348,0-6.743-0.169-10.09-0.505l-1.719-0.171
44
+ l-0.95,1.443l-12.122,18.448l-13.366-3.581l-1.275-22.038l-0.1-1.727l-1.574-0.709c-7.035-3.18-13.653-7.139-19.71-11.792
45
+ l5.716-5.715l4.205-4.207L199.418,77.666L223.409,53.676 M229.015,44.036l-31.615,31.613L77.169,195.88l-4.206,4.205l-7.977,7.979
46
+ c7.08,5.812,14.765,10.511,22.814,14.146l1.394,24.097l17.348,4.649l13.254-20.173c3.448,0.348,6.912,0.523,10.374,0.523
47
+ c3.304,0,6.607-0.162,9.9-0.479l13.365,20.335l17.347-4.646l1.399-24.202c6.073-2.725,11.931-6.077,17.486-10.038l21.831,10.974
48
+ l12.699-12.698l-10.91-21.701c4.012-5.521,7.396-11.352,10.169-17.398l24.369-1.408l4.649-17.348l-20.242-13.3
49
+ c0.708-6.736,0.784-13.523,0.164-20.266l20.285-13.328l-4.648-17.348l-23.324-1.349l-0.227,0.825l-9.107,33.175
50
+ c2.127,24.332-6.104,49.401-24.729,68.024c-16.709,16.71-38.604,25.061-60.501,25.061c-13.998,0-27.995-3.41-40.643-10.229
51
+ L205.48,87.984l2.586,32.356L229.015,44.036L229.015,44.036z"/>
52
+ </g>
53
+ </g>
54
  </svg>
classes/class.archive.config.php CHANGED
@@ -43,6 +43,4 @@ class DUP_Archive_Config
43
 
44
  public $is_outer_root_wp_config_file;
45
  public $is_outer_root_wp_content_dir;
46
-
47
- public $csrf_crypt;
48
  }
43
 
44
  public $is_outer_root_wp_config_file;
45
  public $is_outer_root_wp_content_dir;
 
 
46
  }
classes/class.logging.php CHANGED
@@ -109,7 +109,7 @@ class DUP_Log
109
  $unique_id = sprintf("%08x", abs(crc32($_SERVER['REMOTE_ADDR'].$_SERVER['REQUEST_TIME'].$_SERVER['REMOTE_PORT'])));
110
 
111
  if ($calling_function_override == null) {
112
- $calling_function = SnapLibUtil::getCallingFunctionName();
113
  } else {
114
  $calling_function = $calling_function_override;
115
  }
109
  $unique_id = sprintf("%08x", abs(crc32($_SERVER['REMOTE_ADDR'].$_SERVER['REQUEST_TIME'].$_SERVER['REMOTE_PORT'])));
110
 
111
  if ($calling_function_override == null) {
112
+ $calling_function = DupLiteSnapLibUtil::getCallingFunctionName();
113
  } else {
114
  $calling_function = $calling_function_override;
115
  }
classes/class.settings.php CHANGED
@@ -139,6 +139,15 @@ class DUP_Settings
139
 
140
  return $default;
141
  }
 
 
 
 
 
 
 
 
 
142
  }
143
  //Init Class
144
  DUP_Settings::init();
139
 
140
  return $default;
141
  }
142
+
143
+ public static function get_create_date_format()
144
+ {
145
+ static $ui_create_frmt = null;
146
+ if (is_null($ui_create_frmt)) {
147
+ $ui_create_frmt = is_numeric(self::Get('package_ui_created')) ? self::Get('package_ui_created') : 1;
148
+ }
149
+ return $ui_create_frmt;
150
+ }
151
  }
152
  //Init Class
153
  DUP_Settings::init();
classes/package/class.pack.archive.zip.php CHANGED
@@ -152,7 +152,7 @@ class DUP_Zip extends DUP_Archive
152
 
153
  if(self::$countFiles % 500 == 0) {
154
  // Every so many files update the status so the UI can display
155
- $archive->Package->Status = SnapLibUtil::getWorkPercent(DUP_PackageStatus::ARCSTART, DUP_PackageStatus::ARCVALIDATION, $totalFileCount, self::$countFiles);
156
  $archive->Package->update();
157
  }
158
  }
@@ -177,7 +177,7 @@ class DUP_Zip extends DUP_Archive
177
 
178
  if(self::$countFiles % 500 == 0) {
179
  // Every so many files update the status so the UI can display
180
- $archive->Package->Status = SnapLibUtil::getWorkPercent(DUP_PackageStatus::ARCSTART, DUP_PackageStatus::ARCVALIDATION, $totalFileCount, self::$countFiles);
181
  $archive->Package->update();
182
  }
183
  }
152
 
153
  if(self::$countFiles % 500 == 0) {
154
  // Every so many files update the status so the UI can display
155
+ $archive->Package->Status = DupLiteSnapLibUtil::getWorkPercent(DUP_PackageStatus::ARCSTART, DUP_PackageStatus::ARCVALIDATION, $totalFileCount, self::$countFiles);
156
  $archive->Package->update();
157
  }
158
  }
177
 
178
  if(self::$countFiles % 500 == 0) {
179
  // Every so many files update the status so the UI can display
180
+ $archive->Package->Status = DupLiteSnapLibUtil::getWorkPercent(DUP_PackageStatus::ARCSTART, DUP_PackageStatus::ARCVALIDATION, $totalFileCount, self::$countFiles);
181
  $archive->Package->update();
182
  }
183
  }
classes/package/class.pack.database.php CHANGED
@@ -196,7 +196,7 @@ class DUP_Database
196
  $this->mysqlDump($mysqlDumpPath);
197
  break;
198
  case 'PHP' :
199
- $this->phpDump();
200
  break;
201
  }
202
 
@@ -529,7 +529,7 @@ class DUP_Database
529
  *
530
  * @return bool Returns true if the sql script was successfully created
531
  */
532
- private function phpDump()
533
  {
534
  global $wpdb;
535
 
@@ -599,7 +599,7 @@ class DUP_Database
599
 
600
  $table_number++;
601
  if($table_number % 2 == 0) {
602
- $this->Package->Status = SnapLibUtil::getWorkPercent(DUP_PackageStatus::DBSTART, DUP_PackageStatus::DBDONE, $table_count, $table_number);
603
  $this->Package->update();
604
  }
605
 
@@ -622,6 +622,37 @@ class DUP_Database
622
  $limit = $i * $qryLimit;
623
  $query = "SELECT * FROM `{$table}` LIMIT {$limit}, {$qryLimit}";
624
  $rows = $wpdb->get_results($query, ARRAY_A);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
625
  if (is_array($rows)) {
626
  foreach ($rows as $row) {
627
  $sql .= "INSERT INTO `{$rewrite_table_as}` VALUES(";
196
  $this->mysqlDump($mysqlDumpPath);
197
  break;
198
  case 'PHP' :
199
+ $this->phpDump($package);
200
  break;
201
  }
202
 
529
  *
530
  * @return bool Returns true if the sql script was successfully created
531
  */
532
+ private function phpDump($package)
533
  {
534
  global $wpdb;
535
 
599
 
600
  $table_number++;
601
  if($table_number % 2 == 0) {
602
+ $this->Package->Status = DupLiteSnapLibUtil::getWorkPercent(DUP_PackageStatus::DBSTART, DUP_PackageStatus::DBDONE, $table_count, $table_number);
603
  $this->Package->update();
604
  }
605
 
622
  $limit = $i * $qryLimit;
623
  $query = "SELECT * FROM `{$table}` LIMIT {$limit}, {$qryLimit}";
624
  $rows = $wpdb->get_results($query, ARRAY_A);
625
+
626
+ $select_last_error = $wpdb->last_error;
627
+ if ('' !== $select_last_error) {
628
+ $is_select_error = true;
629
+ DUP_LOG::trace($select_last_error);
630
+ if (false !== stripos($wpdb->last_error, 'is marked as crashed and should be repaired')) {
631
+ $ret_repair = $wpdb->query("repair table `{$table}`");
632
+ $ret_repair = false;
633
+ if ($ret_repair) {
634
+ DUP_LOG::trace("Successfully repaired the {$table}");
635
+ $rows = $wpdb->get_results($query, ARRAY_A);
636
+ if ('' !== $wpdb->last_error) {
637
+ $is_select_error = false;
638
+ }
639
+ }
640
+ }
641
+
642
+ if ($is_select_error) {
643
+ $fix = esc_html__('Please constact your DataBase administrator to fix the error.', 'duplicator');
644
+ $errorMessage = $select_last_error.' '.$fix.'.';
645
+ $package->BuildProgress->set_failed($errorMessage);
646
+ $package->BuildProgress->failed = true;
647
+ $package->failed = true;
648
+ $package->BuildProgress->Status = DUP_PackageStatus::ERROR;
649
+ $package->Status = DUP_PackageStatus::ERROR;
650
+ $package->Update();
651
+ DUP_Log::error($select_last_error, $fix, Dup_ErrorBehavior::Quit);
652
+ return;
653
+ }
654
+ }
655
+
656
  if (is_array($rows)) {
657
  foreach ($rows as $row) {
658
  $sql .= "INSERT INTO `{$rewrite_table_as}` VALUES(";
classes/package/class.pack.installer.php CHANGED
@@ -94,9 +94,9 @@ class DUP_Installer
94
  $mini_expander_string = '';
95
  }
96
 
97
- $search_array = array('@@ARCHIVE@@', '@@VERSION@@', '@@ARCHIVE_SIZE@@', '@@PACKAGE_HASH@@', '@@CSRF_CRYPT@@', '@@DUPARCHIVE_MINI_EXPANDER@@');
98
  $package_hash = $this->Package->getPackageHash();
99
- $replace_array = array($this->Package->Archive->File, DUPLICATOR_VERSION, @filesize($archive_filepath), $package_hash, DUPLICATOR_INSTALLER_CSRF_CRYPT, $mini_expander_string);
100
  $installer_contents = str_replace($search_array, $replace_array, $installer_contents);
101
 
102
  if (@file_put_contents($installer_filepath, $installer_contents) === false) {
@@ -144,7 +144,7 @@ class DUP_Installer
144
  $ac->package_hash = $this->Package->getPackageHash();
145
  $ac->package_notes = $this->Package->Notes;
146
  $ac->url_old = get_option('siteurl');
147
- $ac->opts_delete = DUP_JSON::encode($GLOBALS['DUPLICATOR_OPTS_DELETE']);
148
  $ac->blogname = esc_html(get_option('blogname'));
149
  $ac->wproot = DUPLICATOR_WPROOTPATH;
150
  $ac->relative_content_dir = str_replace(ABSPATH, '', WP_CONTENT_DIR);
@@ -165,9 +165,8 @@ class DUP_Installer
165
  $ac->mu_mode = DUP_MU::getMode();
166
  $ac->is_outer_root_wp_config_file = (!file_exists(DUPLICATOR_WPROOTPATH.'wp-config.php')) ? true : false;
167
  $ac->is_outer_root_wp_content_dir = $this->Package->Archive->isOuterWPContentDir();
168
- $ac->csrf_crypt = DUPLICATOR_INSTALLER_CSRF_CRYPT;
169
 
170
- $json = DUP_JSON::encodePrettyPrint($ac);
171
  DUP_Log::TraceObject('json', $json);
172
 
173
  if (file_put_contents($archive_config_filepath, $json) === false) {
@@ -303,9 +302,9 @@ class DUP_Installer
303
  $installer_backup_filepath = dirname($installer_filepath)."/{$installer_backup_filename}";
304
 
305
  DUP_Log::Info('Adding enhanced installer files to archive using DupArchive');
306
- SnapLibIOU::copy($installer_filepath, $installer_backup_filepath);
307
  DupArchiveEngine::addFileToArchiveUsingBaseDirST($archive_filepath, dirname($installer_backup_filepath), $installer_backup_filepath);
308
- SnapLibIOU::rm($installer_backup_filepath);
309
 
310
  $this->numFilesAdded++;
311
 
@@ -470,14 +469,16 @@ class DUP_Installer
470
  * @param $temp_conf_ark_file_path Temp config file path
471
  */
472
  private static function cleanTempWPConfArkFilePath($temp_conf_ark_file_path) {
473
- require_once(DUPLICATOR_PLUGIN_PATH . 'lib/config/class.wp.config.tranformer.php');
474
- $transformer = new WPConfigTransformer($temp_conf_ark_file_path);
475
- $constants = array('DB_NAME', 'DB_USER', 'DB_PASSWORD', 'DB_HOST');
476
- foreach ($constants as $constant) {
477
- if ($transformer->exists('constant', $constant)) {
478
- $transformer->update('constant', $constant, '');
479
- }
480
- }
 
 
481
  }
482
 
483
  /**
94
  $mini_expander_string = '';
95
  }
96
 
97
+ $search_array = array('@@ARCHIVE@@', '@@VERSION@@', '@@ARCHIVE_SIZE@@', '@@PACKAGE_HASH@@', '@@DUPARCHIVE_MINI_EXPANDER@@');
98
  $package_hash = $this->Package->getPackageHash();
99
+ $replace_array = array($this->Package->Archive->File, DUPLICATOR_VERSION, @filesize($archive_filepath), $package_hash, $mini_expander_string);
100
  $installer_contents = str_replace($search_array, $replace_array, $installer_contents);
101
 
102
  if (@file_put_contents($installer_filepath, $installer_contents) === false) {
144
  $ac->package_hash = $this->Package->getPackageHash();
145
  $ac->package_notes = $this->Package->Notes;
146
  $ac->url_old = get_option('siteurl');
147
+ $ac->opts_delete = DupLiteSnapLibUtil::wp_json_encode_pprint($GLOBALS['DUPLICATOR_OPTS_DELETE']);
148
  $ac->blogname = esc_html(get_option('blogname'));
149
  $ac->wproot = DUPLICATOR_WPROOTPATH;
150
  $ac->relative_content_dir = str_replace(ABSPATH, '', WP_CONTENT_DIR);
165
  $ac->mu_mode = DUP_MU::getMode();
166
  $ac->is_outer_root_wp_config_file = (!file_exists(DUPLICATOR_WPROOTPATH.'wp-config.php')) ? true : false;
167
  $ac->is_outer_root_wp_content_dir = $this->Package->Archive->isOuterWPContentDir();
 
168
 
169
+ $json = DupLiteSnapLibUtil::wp_json_encode_pprint($ac);
170
  DUP_Log::TraceObject('json', $json);
171
 
172
  if (file_put_contents($archive_config_filepath, $json) === false) {
302
  $installer_backup_filepath = dirname($installer_filepath)."/{$installer_backup_filename}";
303
 
304
  DUP_Log::Info('Adding enhanced installer files to archive using DupArchive');
305
+ DupLiteSnapLibIOU::copy($installer_filepath, $installer_backup_filepath);
306
  DupArchiveEngine::addFileToArchiveUsingBaseDirST($archive_filepath, dirname($installer_backup_filepath), $installer_backup_filepath);
307
+ DupLiteSnapLibIOU::rm($installer_backup_filepath);
308
 
309
  $this->numFilesAdded++;
310
 
469
  * @param $temp_conf_ark_file_path Temp config file path
470
  */
471
  private static function cleanTempWPConfArkFilePath($temp_conf_ark_file_path) {
472
+ if (function_exists('token_get_all')) {
473
+ require_once(DUPLICATOR_PLUGIN_PATH . 'lib/config/class.wp.config.tranformer.php');
474
+ $transformer = new WPConfigTransformer($temp_conf_ark_file_path);
475
+ $constants = array('DB_NAME', 'DB_USER', 'DB_PASSWORD', 'DB_HOST');
476
+ foreach ($constants as $constant) {
477
+ if ($transformer->exists('constant', $constant)) {
478
+ $transformer->update('constant', $constant, '');
479
+ }
480
+ }
481
+ }
482
  }
483
 
484
  /**
classes/package/class.pack.php CHANGED
@@ -285,7 +285,7 @@ class DUP_Package
285
  $report['RPT']['ScanTime'] = DUP_Util::elapsedTime(DUP_Util::getMicrotime(), $timerStart);
286
  $fp = fopen(DUPLICATOR_SSDIR_PATH_TMP."/{$this->ScanFile}", 'w');
287
 
288
- fwrite($fp, DUP_JSON::encodePrettyPrint($report));
289
  fclose($fp);
290
 
291
  return $report;
@@ -492,17 +492,16 @@ class DUP_Package
492
  */
493
  public static function is_active_package_present()
494
  {
495
- $activePakcs = self::get_all_by_status(array(
496
  array('op' => '>=', 'status' => DUP_PackageStatus::CREATED),
497
  array('op' => '<', 'status' => DUP_PackageStatus::COMPLETE)
498
  ), true);
499
 
500
- return in_array( DUP_Settings::Get('active_package_id') , $activePakcs);
501
  }
502
 
503
  /**
504
- * Get all packages with status conditions
505
- * @global wpdb $wpdb
506
  * @param array $conditions es. [
507
  * relation = 'AND',
508
  * [ 'op' => '>=' ,
@@ -510,88 +509,245 @@ class DUP_Package
510
  * [ 'op' => '<' ,
511
  * 'status' => DUP_PackageStatus::COMPLETED ]
512
  * ]
513
- * @param bool $getIds if true return array of id
514
- *
515
- * @return DUP_Package[]|int[]
516
  */
517
- public static function get_all_by_status($conditions = array(),$getIds = false)
518
  {
519
- global $wpdb;
520
- $result = array();
521
-
522
- $tablePrefix = DUP_Util::getTablePrefix();
523
- $table = $tablePrefix . "duplicator_packages";
524
-
525
- $accepted_op = array('<', '>', '=', '<>', '>=', '<=');
526
- $relation = (isset($conditions['relation']) && strtoupper($conditions['relation']) == 'OR') ? ' OR ' : ' AND ';
527
- unset($conditions['relation']);
528
-
529
- $where = '';
530
 
531
- if (!empty($conditions)) {
532
  $str_conds = array();
533
 
534
  foreach ($conditions as $cond) {
535
- $op = (isset($cond['op']) && in_array($cond['op'], $accepted_op)) ? $cond['op'] : '=';
536
- $status = isset($cond['status']) ? (int) $cond['status'] : 0;
537
  $str_conds[] = 'status '.$op.' '.$status;
538
  }
539
- $where = ' WHERE '.implode($relation, $str_conds).' ';
 
540
  }
 
541
 
542
- $cols = $getIds ? 'id' : '*';
543
- $rows = $wpdb->get_results("SELECT {$cols} FROM `{$table}` {$where} ORDER BY id DESC", ARRAY_A);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
544
 
 
545
  if ($rows != null) {
546
- if ($getIds) {
547
- foreach ($rows as $row) {
548
- $result[] = (int) $row['id'];
549
- }
550
- } else {
551
- foreach ($rows as $row) {
552
- $Package = unserialize($row['package']);
553
- if ($Package) {
554
- // We was not storing Status in Lite 1.2.52, so it is for backward compatibility
555
- if (!isset($Package->Status)) {
556
- $Package->Status = $row['status'];
 
 
 
 
 
 
 
 
 
 
557
  }
558
-
559
- $result[] = $Package;
560
  }
561
- }
562
  }
563
  }
 
 
564
 
565
- return $result;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
566
  }
567
 
568
  /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
569
  *
570
  * @global wpdb $wpdb
571
- * @return DUP_Package[]
 
 
 
 
 
 
 
572
  */
573
- public static function get_all()
574
  {
575
  global $wpdb;
576
- $tablePrefix = DUP_Util::getTablePrefix();
577
- $table = $tablePrefix."duplicator_packages";
578
 
579
- $packages = array();
580
- $rows = $wpdb->get_results("SELECT * FROM `{$table}` ORDER BY id DESC", ARRAY_A);
581
- if ($rows != null) {
582
- foreach ($rows as $row) {
583
- $Package = unserialize($row['package']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
584
  if ($Package) {
585
  // We was not storing Status in Lite 1.2.52, so it is for backward compatibility
586
  if (!isset($Package->Status)) {
587
  $Package->Status = $row['status'];
588
  }
 
 
 
 
 
 
 
589
 
590
- $packages[] = $Package;
 
 
 
 
 
 
 
 
 
 
 
 
591
  }
592
  }
593
  }
594
- return $packages;
595
  }
596
 
597
  /**
@@ -852,24 +1008,23 @@ class DUP_Package
852
  }
853
 
854
  // RUNNING PACKAGES
855
- $active_pack = self::get_all_by_status(array(
856
  'relation' => 'AND',
857
  array('op' => '>=' , 'status' => DUP_PackageStatus::CREATED ),
858
  array('op' => '<' , 'status' => DUP_PackageStatus::COMPLETE )
859
  ));
860
  $active_files = array();
861
-
862
- foreach($active_pack as $package) {
863
- $active_files[] = $package->NameHash; // 20181221_dup_c0b2f1198a92f4f6c47a621494adc5cb_20181221173955
864
  }
865
 
866
  // ERRORS PACKAGES
867
- $err_pack = self::get_all_by_status(array(
868
  array('op' => '<' , 'status' => DUP_PackageStatus::CREATED )
869
  ));
870
  $force_del_files = array();
871
- foreach($err_pack as $package) {
872
- $force_del_files[] = $package->NameHash;
873
  }
874
 
875
  // Don't remove json file;
@@ -1496,7 +1651,7 @@ class DUP_Package
1496
  private function writeLogHeader()
1497
  {
1498
  $php_max_time = @ini_get("max_execution_time");
1499
- if (SnapLibUtil::wp_is_ini_value_changeable('memory_limit'))
1500
  $php_max_memory = @ini_set('memory_limit', DUPLICATOR_PHP_MAX_MEMORY);
1501
  else
1502
  $php_max_memory = @ini_get('memory_limit');
285
  $report['RPT']['ScanTime'] = DUP_Util::elapsedTime(DUP_Util::getMicrotime(), $timerStart);
286
  $fp = fopen(DUPLICATOR_SSDIR_PATH_TMP."/{$this->ScanFile}", 'w');
287
 
288
+ fwrite($fp, DupLiteSnapLibUtil::wp_json_encode_pprint($report));
289
  fclose($fp);
290
 
291
  return $report;
492
  */
493
  public static function is_active_package_present()
494
  {
495
+ $activePakcs = self::get_ids_by_status(array(
496
  array('op' => '>=', 'status' => DUP_PackageStatus::CREATED),
497
  array('op' => '<', 'status' => DUP_PackageStatus::COMPLETE)
498
  ), true);
499
 
500
+ return in_array(DUP_Settings::Get('active_package_id'), $activePakcs);
501
  }
502
 
503
  /**
504
+ *
 
505
  * @param array $conditions es. [
506
  * relation = 'AND',
507
  * [ 'op' => '>=' ,
509
  * [ 'op' => '<' ,
510
  * 'status' => DUP_PackageStatus::COMPLETED ]
511
  * ]
512
+ * @return string
 
 
513
  */
514
+ protected static function statusContitionsToWhere($conditions = array())
515
  {
516
+ if (empty($conditions)) {
517
+ return '';
518
+ } else {
519
+ $accepted_op = array('<', '>', '=', '<>', '>=', '<=');
520
+ $relation = (isset($conditions['relation']) && strtoupper($conditions['relation']) == 'OR') ? ' OR ' : ' AND ';
521
+ unset($conditions['relation']);
 
 
 
 
 
522
 
 
523
  $str_conds = array();
524
 
525
  foreach ($conditions as $cond) {
526
+ $op = (isset($cond['op']) && in_array($cond['op'], $accepted_op)) ? $cond['op'] : '=';
527
+ $status = isset($cond['status']) ? (int) $cond['status'] : 0;
528
  $str_conds[] = 'status '.$op.' '.$status;
529
  }
530
+
531
+ return ' WHERE '.implode($relation, $str_conds).' ';
532
  }
533
+ }
534
 
535
+ /**
536
+ * Get packages with status conditions and/or pagination
537
+ *
538
+ * @global wpdb $wpdb
539
+ *
540
+ * @param array // $conditions es. [
541
+ * relation = 'AND',
542
+ * [ 'op' => '>=' ,
543
+ * 'status' => DUP_PackageStatus::START ]
544
+ * [ 'op' => '<' ,
545
+ * 'status' => DUP_PackageStatus::COMPLETED ]
546
+ * ]
547
+ * if empty get all pacages
548
+ * @param int $limit // max row numbers fi false the limit is PHP_INT_MAX
549
+ * @param int $offset // offset 0 is at begin
550
+ * @param string $orderBy // default `id` ASC if empty no order
551
+ * @param string $resultType // ids => int[]
552
+ * row => row without backage blob
553
+ * fullRow => row with package blob
554
+ * objs => array of DUP_Package objects
555
+ *
556
+ * @return DUP_Package[]|array[]|int[]
557
+ */
558
+ public static function get_packages_by_status($conditions = array(), $limit = false, $offset = 0, $orderBy = '`id` ASC', $resultType = 'obj')
559
+ {
560
+ global $wpdb;
561
+ $table = $wpdb->base_prefix."duplicator_packages";
562
+ $where = self::statusContitionsToWhere($conditions);
563
+
564
+ $packages = array();
565
+ $offsetStr = ' OFFSET '.(int) $offset;
566
+ $limitStr = ' LIMIT '.($limit !== false ? max(0, $limit) : PHP_INT_MAX);
567
+ $orderByStr = empty($orderBy) ? '' : ' ORDER BY '.$orderBy.' ';
568
+ switch ($resultType) {
569
+ case 'ids':
570
+ $cols = '`id`';
571
+ break;
572
+ case 'row':
573
+ $cols = '`id`,`name`,`hash`,`status`,`created`,`owner`';
574
+ break;
575
+ case 'fullRow':
576
+ $cols = '*';
577
+ break;
578
+ case 'objs':
579
+ default:
580
+ $cols = '`status`,`package`';
581
+ break;
582
+ }
583
 
584
+ $rows = $wpdb->get_results('SELECT '.$cols.' FROM `'.$table.'` '.$where.$orderByStr.$limitStr.$offsetStr);
585
  if ($rows != null) {
586
+ switch ($resultType) {
587
+ case 'ids':
588
+ foreach ($rows as $row) {
589
+ $packages[] = $row->id;
590
+ }
591
+ break;
592
+ case 'row':
593
+ case 'fullRow':
594
+ $packages = $rows;
595
+ break;
596
+ case 'objs':
597
+ default:
598
+ foreach ($rows as $row) {
599
+ $Package = unserialize($row->package);
600
+ if ($Package) {
601
+ // We was not storing Status in Lite 1.2.52, so it is for backward compatibility
602
+ if (!isset($Package->Status)) {
603
+ $Package->Status = $row->status;
604
+ }
605
+
606
+ $packages[] = $Package;
607
  }
 
 
608
  }
 
609
  }
610
  }
611
+ return $packages;
612
+ }
613
 
614
+ /**
615
+ * Get packages row db with status conditions and/or pagination
616
+ *
617
+ * @param array // $conditions es. [
618
+ * relation = 'AND',
619
+ * [ 'op' => '>=' ,
620
+ * 'status' => DUP_PackageStatus::START ]
621
+ * [ 'op' => '<' ,
622
+ * 'status' => DUP_PackageStatus::COMPLETED ]
623
+ * ]
624
+ * if empty get all pacages
625
+ * @param int $limit // max row numbers
626
+ * @param int $offset // offset 0 is at begin
627
+ * @param string $orderBy // default `id` ASC if empty no order
628
+ *
629
+ * @return array[] // return row database without package blob
630
+ */
631
+ public static function get_row_by_status($conditions = array(), $limit = false, $offset = 0, $orderBy = '`id` ASC')
632
+ {
633
+ return self::get_packages_by_status($conditions, $limit, $offset, $orderBy, 'row');
634
  }
635
 
636
  /**
637
+ * Get packages ids with status conditions and/or pagination
638
+ *
639
+ * @param array // $conditions es. [
640
+ * relation = 'AND',
641
+ * [ 'op' => '>=' ,
642
+ * 'status' => DUP_PackageStatus::START ]
643
+ * [ 'op' => '<' ,
644
+ * 'status' => DUP_PackageStatus::COMPLETED ]
645
+ * ]
646
+ * if empty get all pacages
647
+ * @param int $limit // max row numbers
648
+ * @param int $offset // offset 0 is at begin
649
+ * @param string $orderBy // default `id` ASC if empty no order
650
+ *
651
+ * @return array[] // return row database without package blob
652
+ */
653
+ public static function get_ids_by_status($conditions = array(), $limit = false, $offset = 0, $orderBy = '`id` ASC')
654
+ {
655
+ return self::get_packages_by_status($conditions, $limit, $offset, $orderBy, 'ids');
656
+ }
657
+
658
+ /**
659
+ * count package with status condition
660
  *
661
  * @global wpdb $wpdb
662
+ * @param array $conditions es. [
663
+ * relation = 'AND',
664
+ * [ 'op' => '>=' ,
665
+ * 'status' => DUP_PackageStatus::START ]
666
+ * [ 'op' => '<' ,
667
+ * 'status' => DUP_PackageStatus::COMPLETED ]
668
+ * ]
669
+ * @return int
670
  */
671
+ public static function count_by_status($conditions = array())
672
  {
673
  global $wpdb;
 
 
674
 
675
+ $table = $wpdb->base_prefix."duplicator_packages";
676
+ $where = self::statusContitionsToWhere($conditions);
677
+
678
+ $count = $wpdb->get_var("SELECT count(id) FROM `{$table}` ".$where);
679
+ return $count;
680
+ }
681
+
682
+ /**
683
+ * Execute $callback function foreach package result
684
+ * For each iteration the memory is released
685
+ *
686
+ * @param callable $callback // function callback(DUP_Package $package)
687
+ * @param array // $conditions es. [
688
+ * relation = 'AND',
689
+ * [ 'op' => '>=' ,
690
+ * 'status' => DUP_PackageStatus::START ]
691
+ * [ 'op' => '<' ,
692
+ * 'status' => DUP_PackageStatus::COMPLETED ]
693
+ * ]
694
+ * if empty get all pacages
695
+ * @param int $limit // max row numbers
696
+ * @param int $offset // offset 0 is at begin
697
+ * @param string $orderBy // default `id` ASC if empty no order
698
+ *
699
+ * @return void
700
+ */
701
+ public static function by_status_callback($callback, $conditions = array(), $limit = false, $offset = 0, $orderBy = '`id` ASC')
702
+ {
703
+ if (!is_callable($callback)) {
704
+ throw new Exception('No callback function passed');
705
+ }
706
+
707
+ $offset = max(0, $offset);
708
+ $numPackages = self::count_by_status($conditions);
709
+ $maxLimit = $offset + ($limit !== false ? max(0, $limit) : PHP_INT_MAX - $offset);
710
+ $numPackages = min($maxLimit, $numPackages);
711
+ $orderByStr = empty($orderBy) ? '' : ' ORDER BY '.$orderBy.' ';
712
+
713
+ global $wpdb;
714
+ $table = $wpdb->base_prefix."duplicator_packages";
715
+ $where = self::statusContitionsToWhere($conditions);
716
+ $sql = 'SELECT * FROM `'.$table.'` '.$where.$orderByStr.' LIMIT 1 OFFSET ';
717
+
718
+ for (; $offset < $numPackages; $offset ++) {
719
+ $rows = $wpdb->get_results($sql.$offset);
720
+ if ($rows != null) {
721
+ $Package = @unserialize($rows[0]->package);
722
  if ($Package) {
723
  // We was not storing Status in Lite 1.2.52, so it is for backward compatibility
724
  if (!isset($Package->Status)) {
725
  $Package->Status = $row['status'];
726
  }
727
+ call_user_func($callback, $Package);
728
+ unset($Package);
729
+ }
730
+ unset($rows);
731
+ }
732
+ }
733
+ }
734
 
735
+ public static function purge_incomplete_package()
736
+ {
737
+ $packages = self::get_packages_by_status(array(
738
+ 'relation' => 'AND',
739
+ array('op' => '>=', 'status' => DUP_PackageStatus::CREATED),
740
+ array('op' => '<', 'status' => DUP_PackageStatus::COMPLETE)
741
+ ), 1, 0, '`id` ASC');
742
+
743
+
744
+ if (count($packages) > 0) {
745
+ foreach ($packages as $package) {
746
+ if (!$package->isRunning()) {
747
+ $package->delete();
748
  }
749
  }
750
  }
 
751
  }
752
 
753
  /**
1008
  }
1009
 
1010
  // RUNNING PACKAGES
1011
+ $active_pack = self::get_row_by_status(array(
1012
  'relation' => 'AND',
1013
  array('op' => '>=' , 'status' => DUP_PackageStatus::CREATED ),
1014
  array('op' => '<' , 'status' => DUP_PackageStatus::COMPLETE )
1015
  ));
1016
  $active_files = array();
1017
+ foreach($active_pack as $row) {
1018
+ $active_files[] = $row->name.'_'.$row->hash;
 
1019
  }
1020
 
1021
  // ERRORS PACKAGES
1022
+ $err_pack = self::get_row_by_status(array(
1023
  array('op' => '<' , 'status' => DUP_PackageStatus::CREATED )
1024
  ));
1025
  $force_del_files = array();
1026
+ foreach($err_pack as $row) {
1027
+ $force_del_files[] = $row->name.'_'.$row->hash;
1028
  }
1029
 
1030
  // Don't remove json file;
1651
  private function writeLogHeader()
1652
  {
1653
  $php_max_time = @ini_get("max_execution_time");
1654
+ if (DupLiteSnapLibUtil::wp_is_ini_value_changeable('memory_limit'))
1655
  $php_max_memory = @ini_set('memory_limit', DUPLICATOR_PHP_MAX_MEMORY);
1656
  else
1657
  $php_max_memory = @ini_get('memory_limit');
classes/package/duparchive/class.pack.archive.duparchive.php CHANGED
@@ -195,7 +195,7 @@ class DUP_DupArchive
195
 
196
  $totalFileCount = count($scanReport->ARC->Files);
197
 
198
- $package->Status = SnapLibUtil::getWorkPercent(DUP_PackageStatus::ARCSTART, DUP_PackageStatus::ARCVALIDATION, $totalFileCount, $createState->currentFileIndex);
199
 
200
  $buildProgress->retries = 0;
201
 
@@ -296,7 +296,7 @@ class DUP_DupArchive
296
  $totalFileCount = count($scanReport->ARC->Files);
297
  $archiveSize = @filesize($expandState->archivePath);
298
 
299
- $package->Status = SnapLibUtil::getWorkPercent(DUP_PackageStatus::ARCVALIDATION, DUP_PackageStatus::COMPLETE, $archiveSize,
300
  $expandState->archiveOffset);
301
  DUP_LOG::TraceObject("package status after expand=", $package->Status);
302
  DUP_LOG::Trace("archive size:{$archiveSize} expand offset:{$expandState->archiveOffset}");
195
 
196
  $totalFileCount = count($scanReport->ARC->Files);
197
 
198
+ $package->Status = DupLiteSnapLibUtil::getWorkPercent(DUP_PackageStatus::ARCSTART, DUP_PackageStatus::ARCVALIDATION, $totalFileCount, $createState->currentFileIndex);
199
 
200
  $buildProgress->retries = 0;
201
 
296
  $totalFileCount = count($scanReport->ARC->Files);
297
  $archiveSize = @filesize($expandState->archivePath);
298
 
299
+ $package->Status = DupLiteSnapLibUtil::getWorkPercent(DUP_PackageStatus::ARCVALIDATION, DUP_PackageStatus::COMPLETE, $archiveSize,
300
  $expandState->archiveOffset);
301
  DUP_LOG::TraceObject("package status after expand=", $package->Status);
302
  DUP_LOG::Trace("archive size:{$archiveSize} expand offset:{$expandState->archiveOffset}");
classes/package/duparchive/class.pack.archive.duparchive.state.expand.php CHANGED
@@ -76,18 +76,18 @@ class DUP_DupArchive_Expand_State extends DupArchiveExpandState
76
  $data = new stdClass();
77
 
78
  if($this->currentFileHeader != null) {
79
- $data->currentFileHeaderString = json_encode($this->currentFileHeader);
80
  } else {
81
  $data->currentFileHeaderString = null;
82
  }
83
 
84
  if($this->archiveHeader != null) {
85
- $data->archiveHeaderString = json_encode($this->archiveHeader);
86
  } else {
87
  $data->archiveHeaderString = null;
88
  }
89
 
90
- $data->failuresString = json_encode($this->failures, JSON_FORCE_OBJECT);
91
 
92
  // Object members auto skipped
93
  DUP_Util::objectCopy($this, $data);
76
  $data = new stdClass();
77
 
78
  if($this->currentFileHeader != null) {
79
+ $data->currentFileHeaderString = DupLiteSnapLibUtil::wp_json_encode($this->currentFileHeader);
80
  } else {
81
  $data->currentFileHeaderString = null;
82
  }
83
 
84
  if($this->archiveHeader != null) {
85
+ $data->archiveHeaderString = DupLiteSnapLibUtil::wp_json_encode($this->archiveHeader);
86
  } else {
87
  $data->archiveHeaderString = null;
88
  }
89
 
90
+ $data->failuresString = DupLiteSnapLibUtil::wp_json_encode($this->failures, JSON_FORCE_OBJECT);
91
 
92
  // Object members auto skipped
93
  DUP_Util::objectCopy($this, $data);
classes/utilities/class.u.json.php CHANGED
@@ -35,11 +35,7 @@ class DUP_JSON
35
  public static function customEncode($value, $iteration = 1)
36
  {
37
  if (DUP_Util::$on_php_53_plus) {
38
- if (function_exists('wp_json_encode')) {
39
- $encoded = wp_json_encode($value);
40
- } else {
41
- $encoded = json_encode($value);
42
- }
43
 
44
  switch (json_last_error()) {
45
  case JSON_ERROR_NONE:
@@ -67,62 +63,10 @@ class DUP_JSON
67
  }
68
  }
69
 
70
- /**
71
- *
72
- * @param mixed $data Variable (usually an array or object) to encode as JSON.
73
- * @param int $options Optional. Options to be passed to json_encode(). Default 0.
74
- * @param int $depth Optional. Maximum depth to walk through $data. Must be
75
- * greater than 0. Default 512.
76
- * @return string|false The JSON encoded string, or false if it cannot be encoded.
77
- */
78
- public static function encodePrettyPrint($data, $options = 0, $depth = 512)
79
- {
80
- if (defined('JSON_PRETTY_PRINT')) {
81
- return self::encode($data, JSON_PRETTY_PRINT | $options, $depth);
82
- } else {
83
- return self::encode($data, $options, $depth);
84
- }
85
- }
86
-
87
- /**
88
- * @param mixed $data Variable (usually an array or object) to encode as JSON.
89
- * @param int $options Optional. Options to be passed to json_encode(). Default 0.
90
- * @param int $depth Optional. Maximum depth to walk through $data. Must be
91
- * greater than 0. Default 512.
92
- * @return string|false The JSON encoded string, or false if it cannot be encoded.
93
- */
94
- public static function encode($data, $options = 0, $depth = 512)
95
- {
96
- $result = false;
97
-
98
- if (function_exists('wp_json_encode')) {
99
- $result = wp_json_encode($data, $options, $depth);
100
- } else {
101
- if (version_compare(PHP_VERSION, '5.5', '>=')) {
102
- $result = json_encode($data, $options, $depth);
103
- } elseif (version_compare(PHP_VERSION, '5.3', '>=')) {
104
- $result = json_encode($data, $options);
105
- } else {
106
- $result = json_encode($data);
107
- }
108
- }
109
-
110
- if ($result === false) {
111
- if (function_exists('json_last_error')) {
112
- $message = self::$_messages[json_last_error()];
113
- } else {
114
- $message = esc_html__("One or more filenames isn't compatible with JSON encoding", 'duplicator');
115
- }
116
- throw new RuntimeException($message);
117
- }
118
-
119
- return $result;
120
- }
121
-
122
  public static function safeEncode($data, $options = 0, $depth = 512)
123
  {
124
  try {
125
- $jsonString = self::encode($data, $options, $depth);
126
  } catch (Exception $e) {
127
  $jsonString = false;
128
  }
35
  public static function customEncode($value, $iteration = 1)
36
  {
37
  if (DUP_Util::$on_php_53_plus) {
38
+ $encoded = DupLiteSnapLibUtil::wp_json_encode_pprint($value);
 
 
 
 
39
 
40
  switch (json_last_error()) {
41
  case JSON_ERROR_NONE:
63
  }
64
  }
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  public static function safeEncode($data, $options = 0, $depth = 512)
67
  {
68
  try {
69
+ $jsonString = DupLiteSnapLibUtil::wp_json_encode($data, $options, $depth);
70
  } catch (Exception $e) {
71
  $jsonString = false;
72
  }
ctrls/class.web.services.php CHANGED
@@ -12,6 +12,15 @@ class DUP_Web_Services
12
  add_action('wp_ajax_duplicator_reset_all_settings', array(__CLASS__, 'ajax_reset_all'));
13
  }
14
 
 
 
 
 
 
 
 
 
 
15
  /**
16
  * reset all ajax action
17
  *
@@ -21,7 +30,7 @@ class DUP_Web_Services
21
  {
22
  check_ajax_referer('duplicator_reset_all_settings', 'nonce');
23
  DUP_Util::hasCapability('export');
24
-
25
  ob_start();
26
  try {
27
  /** Execute function * */
@@ -38,15 +47,10 @@ class DUP_Web_Services
38
  throw new Exception('Security issue');
39
  }
40
 
41
- $noCompletePakcs = DUP_Package::get_all_by_status(array(
42
  array('op' => '<', 'status' => DUP_PackageStatus::COMPLETE)
43
  ));
44
 
45
- /** Delete all not completed packages * */
46
- foreach ($noCompletePakcs as $pack) {
47
- $pack->delete();
48
- }
49
-
50
  /** reset active package id * */
51
  DUP_Settings::Set('active_package_id', -1);
52
  DUP_Settings::Save();
12
  add_action('wp_ajax_duplicator_reset_all_settings', array(__CLASS__, 'ajax_reset_all'));
13
  }
14
 
15
+ /**
16
+ *
17
+ * @param DUP_PRO_Package $package
18
+ */
19
+ public static function package_delete_callback($package)
20
+ {
21
+ $package->delete();
22
+ }
23
+
24
  /**
25
  * reset all ajax action
26
  *
30
  {
31
  check_ajax_referer('duplicator_reset_all_settings', 'nonce');
32
  DUP_Util::hasCapability('export');
33
+
34
  ob_start();
35
  try {
36
  /** Execute function * */
47
  throw new Exception('Security issue');
48
  }
49
 
50
+ DUP_Package::by_status_callback(array(__CLASS__,'package_delete_callback'),array(
51
  array('op' => '<', 'status' => DUP_PackageStatus::COMPLETE)
52
  ));
53
 
 
 
 
 
 
54
  /** reset active package id * */
55
  DUP_Settings::Set('active_package_id', -1);
56
  DUP_Settings::Save();
ctrls/ctrl.base.php CHANGED
@@ -122,7 +122,7 @@ class DUP_CTRL_Result
122
 
123
  switch ($this->CTRL->returnType) {
124
  case 'JSON' :
125
- return json_encode($this);
126
  break;
127
  case 'PHP' :
128
  return $this;
@@ -148,7 +148,7 @@ class DUP_CTRL_Result
148
  $payload['Line'] = $exception->getLine();
149
  $payload['Trace'] = $exception->getTraceAsString();
150
  $this->process($payload, DUP_CTRL_Status::ERROR);
151
- die(json_encode($this));
152
  }
153
 
154
  private function getProcessTime()
122
 
123
  switch ($this->CTRL->returnType) {
124
  case 'JSON' :
125
+ return DupLiteSnapLibUtil::wp_json_encode($this);
126
  break;
127
  case 'PHP' :
128
  return $this;
148
  $payload['Line'] = $exception->getLine();
149
  $payload['Trace'] = $exception->getTraceAsString();
150
  $this->process($payload, DUP_CTRL_Status::ERROR);
151
+ die(DupLiteSnapLibUtil::wp_json_encode($this));
152
  }
153
 
154
  private function getProcessTime()
ctrls/ctrl.package.php CHANGED
@@ -79,7 +79,7 @@ function duplicator_package_build()
79
  $json['runtime'] = $Package->Runtime;
80
  $json['exeSize'] = $Package->ExeSize;
81
  $json['archiveSize'] = $Package->ZipSize;
82
- $json_response = json_encode($json);
83
 
84
  //Simulate a Host Build Interrupt
85
  //die(0);
@@ -183,7 +183,7 @@ function duplicator_duparchive_package_build()
183
  $json['status'] = 4;
184
  }
185
 
186
- $json_response = json_encode($json);
187
 
188
  Dup_Log::TraceObject('json response', $json_response);
189
  error_reporting($errLevel);
@@ -246,7 +246,8 @@ function duplicator_package_delete()
246
  _unlinkFile(DUP_Util::safePath(DUPLICATOR_SSDIR_PATH."/{$nameHash}_database.sql"));
247
  _unlinkFile(DUP_Util::safePath(DUPLICATOR_SSDIR_PATH."/{$nameHash}_installer.php"));
248
  _unlinkFile(DUP_Util::safePath(DUPLICATOR_SSDIR_PATH."/{$nameHash}_scan.json"));
249
- _unlinkFile(DUP_Util::safePath(DUPLICATOR_SSDIR_PATH."/{$nameHash}.log"));
 
250
 
251
  //Unfinished Zip files
252
  $tmpZip = DUPLICATOR_SSDIR_PATH_TMP."/{$nameHash}_archive.zip.*";
@@ -260,12 +261,12 @@ function duplicator_package_delete()
260
  }
261
  } catch (Exception $e) {
262
  $json['error'] = "{$e}";
263
- die(json_encode($json));
264
  }
265
 
266
  $json['ids'] = "{$postIDs}";
267
  $json['removed'] = $delCount;
268
- echo json_encode($json);
269
  die();
270
  }
271
 
79
  $json['runtime'] = $Package->Runtime;
80
  $json['exeSize'] = $Package->ExeSize;
81
  $json['archiveSize'] = $Package->ZipSize;
82
+ $json_response = DupLiteSnapLibUtil::wp_json_encode($json);
83
 
84
  //Simulate a Host Build Interrupt
85
  //die(0);
183
  $json['status'] = 4;
184
  }
185
 
186
+ $json_response = DupLiteSnapLibUtil::wp_json_encode($json);
187
 
188
  Dup_Log::TraceObject('json response', $json_response);
189
  error_reporting($errLevel);
246
  _unlinkFile(DUP_Util::safePath(DUPLICATOR_SSDIR_PATH."/{$nameHash}_database.sql"));
247
  _unlinkFile(DUP_Util::safePath(DUPLICATOR_SSDIR_PATH."/{$nameHash}_installer.php"));
248
  _unlinkFile(DUP_Util::safePath(DUPLICATOR_SSDIR_PATH."/{$nameHash}_scan.json"));
249
+ _unlinkFile(DUP_Util::safePath(DUPLICATOR_SSDIR_PATH."/{$nameHash}_wp-config.txt"));
250
+ _unlinkFile(DUP_Util::safePath(DUPLICATOR_SSDIR_PATH."/{$nameHash}.log"));
251
 
252
  //Unfinished Zip files
253
  $tmpZip = DUPLICATOR_SSDIR_PATH_TMP."/{$nameHash}_archive.zip.*";
261
  }
262
  } catch (Exception $e) {
263
  $json['error'] = "{$e}";
264
+ die(DupLiteSnapLibUtil::wp_json_encode($json));
265
  }
266
 
267
  $json['ids'] = "{$postIDs}";
268
  $json['removed'] = $delCount;
269
+ echo DupLiteSnapLibUtil::wp_json_encode($json);
270
  die();
271
  }
272
 
deactivation.php CHANGED
@@ -124,7 +124,8 @@ if (!function_exists('duplicator_add_deactivation_feedback_dialog_box')) {
124
  + ' <div class="duplicator-modal-dialog">'
125
  + ' <div class="duplicator-modal-body">'
126
  + ' <h2><?php _e('Quick Feedback', 'duplicator'); ?></h2>'
127
- + ' <div class="duplicator-modal-panel active"><p><?php _e('If you have a moment, please let us know why you are deactivating', 'duplicator'); ?>:</p><ul>' + <?php echo json_encode($reasons_list_items_html); ?> + '</ul>'
 
128
  + ' </div>'
129
  + ' </div>'
130
  + ' <div class="duplicator-modal-footer">'
124
  + ' <div class="duplicator-modal-dialog">'
125
  + ' <div class="duplicator-modal-body">'
126
  + ' <h2><?php _e('Quick Feedback', 'duplicator'); ?></h2>'
127
+ + ' <div class="duplicator-modal-panel active"><p><?php _e('If you have a moment, please let us know why you are deactivating', 'duplicator'); ?>:</p>'
128
+ + '<ul>' + <?php echo DupLiteSnapLibUtil::wp_json_encode($reasons_list_items_html); ?> + '</ul>'
129
  + ' </div>'
130
  + ' </div>'
131
  + ' <div class="duplicator-modal-footer">'
define.php CHANGED
@@ -4,8 +4,8 @@ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
4
  //Prevent directly browsing to the file
5
  if (function_exists('plugin_dir_url'))
6
  {
7
- define('DUPLICATOR_VERSION', '1.3.12');
8
- define('DUPLICATOR_VERSION_BUILD', '2019-05-02_08:45');
9
  define('DUPLICATOR_PLUGIN_URL', plugin_dir_url(__FILE__));
10
  define('DUPLICATOR_SITE_URL', get_site_url());
11
 
@@ -56,7 +56,6 @@ if (function_exists('plugin_dir_url'))
56
  define('DUPLICATOR_WEBCONFIG_ORIG_FILENAME', 'web.config.orig');
57
  define("DUPLICATOR_INSTALLER_DIRECTORY", DUPLICATOR_WPROOTPATH . 'dup-installer');
58
  define('DUPLICATOR_MAX_LOG_SIZE', 400000); // The higher this is the more overhead
59
- define("DUPLICATOR_INSTALLER_CSRF_CRYPT", 1);
60
 
61
  $GLOBALS['DUPLICATOR_SERVER_LIST'] = array('Apache','LiteSpeed', 'Nginx', 'Lighttpd', 'IIS', 'WebServerX', 'uWSGI');
62
  $GLOBALS['DUPLICATOR_OPTS_DELETE'] = array('duplicator_ui_view_state', 'duplicator_package_active', 'duplicator_settings');
4
  //Prevent directly browsing to the file
5
  if (function_exists('plugin_dir_url'))
6
  {
7
+ define('DUPLICATOR_VERSION', '1.3.14');
8
+ define('DUPLICATOR_VERSION_BUILD', '2019-05-20_15:40');
9
  define('DUPLICATOR_PLUGIN_URL', plugin_dir_url(__FILE__));
10
  define('DUPLICATOR_SITE_URL', get_site_url());
11
 
56
  define('DUPLICATOR_WEBCONFIG_ORIG_FILENAME', 'web.config.orig');
57
  define("DUPLICATOR_INSTALLER_DIRECTORY", DUPLICATOR_WPROOTPATH . 'dup-installer');
58
  define('DUPLICATOR_MAX_LOG_SIZE', 400000); // The higher this is the more overhead
 
59
 
60
  $GLOBALS['DUPLICATOR_SERVER_LIST'] = array('Apache','LiteSpeed', 'Nginx', 'Lighttpd', 'IIS', 'WebServerX', 'uWSGI');
61
  $GLOBALS['DUPLICATOR_OPTS_DELETE'] = array('duplicator_ui_view_state', 'duplicator_package_active', 'duplicator_settings');
duplicator.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Duplicator
4
  Plugin URI: https://snapcreek.com/duplicator/duplicator-free/
5
  Description: Migrate and backup a copy of your WordPress files and database. Duplicate and move a site from one location to another quickly.
6
- Version: 1.3.12
7
  Author: Snap Creek
8
  Author URI: http://www.snapcreek.com/duplicator/
9
  Text Domain: duplicator
@@ -353,7 +353,10 @@ if (is_admin() == true)
353
  function duplicator_menu()
354
  {
355
  $wpfront_caps_translator = 'wpfront_user_role_editor_duplicator_translate_capability';
356
- $icon_svg = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iQXJ0d29yayIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSIyMy4yNXB4IiBoZWlnaHQ9IjIyLjM3NXB4IiB2aWV3Qm94PSIwIDAgMjMuMjUgMjIuMzc1IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCAyMy4yNSAyMi4zNzUiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxwYXRoIGZpbGw9IiM5Q0ExQTYiIGQ9Ik0xOC4wMTEsMS4xODhjLTEuOTk1LDAtMy42MTUsMS42MTgtMy42MTUsMy42MTRjMCwwLjA4NSwwLjAwOCwwLjE2NywwLjAxNiwwLjI1TDcuNzMzLDguMTg0QzcuMDg0LDcuNTY1LDYuMjA4LDcuMTgyLDUuMjQsNy4xODJjLTEuOTk2LDAtMy42MTUsMS42MTktMy42MTUsMy42MTRjMCwxLjk5NiwxLjYxOSwzLjYxMywzLjYxNSwzLjYxM2MwLjYyOSwwLDEuMjIyLTAuMTYyLDEuNzM3LTAuNDQ1bDIuODksMi40MzhjLTAuMTI2LDAuMzY4LTAuMTk4LDAuNzYzLTAuMTk4LDEuMTczYzAsMS45OTUsMS42MTgsMy42MTMsMy42MTQsMy42MTNjMS45OTUsMCwzLjYxNS0xLjYxOCwzLjYxNS0zLjYxM2MwLTEuOTk3LTEuNjItMy42MTQtMy42MTUtMy42MTRjLTAuNjMsMC0xLjIyMiwwLjE2Mi0xLjczNywwLjQ0M2wtMi44OS0yLjQzNWMwLjEyNi0wLjM2OCwwLjE5OC0wLjc2MywwLjE5OC0xLjE3M2MwLTAuMDg0LTAuMDA4LTAuMTY2LTAuMDEzLTAuMjVsNi42NzYtMy4xMzNjMC42NDgsMC42MTksMS41MjUsMS4wMDIsMi40OTUsMS4wMDJjMS45OTQsMCwzLjYxMy0xLjYxNywzLjYxMy0zLjYxM0MyMS42MjUsMi44MDYsMjAuMDA2LDEuMTg4LDE4LjAxMSwxLjE4OHoiLz48L3N2Zz4=';
 
 
 
357
 
358
  //Main Menu
359
  $perms = 'export';
3
  Plugin Name: Duplicator
4
  Plugin URI: https://snapcreek.com/duplicator/duplicator-free/
5
  Description: Migrate and backup a copy of your WordPress files and database. Duplicate and move a site from one location to another quickly.
6
+ Version: 1.3.14
7
  Author: Snap Creek
8
  Author URI: http://www.snapcreek.com/duplicator/
9
  Text Domain: duplicator
353
  function duplicator_menu()
354
  {
355
  $wpfront_caps_translator = 'wpfront_user_role_editor_duplicator_translate_capability';
356
+ //SVG Icon: See https://websemantics.uk/tools/image-to-data-uri-converter/
357
+ //older version
358
+ //$icon_svg = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iQXJ0d29yayIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSIyMy4yNXB4IiBoZWlnaHQ9IjIyLjM3NXB4IiB2aWV3Qm94PSIwIDAgMjMuMjUgMjIuMzc1IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCAyMy4yNSAyMi4zNzUiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxwYXRoIGZpbGw9IiM5Q0ExQTYiIGQ9Ik0xOC4wMTEsMS4xODhjLTEuOTk1LDAtMy42MTUsMS42MTgtMy42MTUsMy42MTRjMCwwLjA4NSwwLjAwOCwwLjE2NywwLjAxNiwwLjI1TDcuNzMzLDguMTg0QzcuMDg0LDcuNTY1LDYuMjA4LDcuMTgyLDUuMjQsNy4xODJjLTEuOTk2LDAtMy42MTUsMS42MTktMy42MTUsMy42MTRjMCwxLjk5NiwxLjYxOSwzLjYxMywzLjYxNSwzLjYxM2MwLjYyOSwwLDEuMjIyLTAuMTYyLDEuNzM3LTAuNDQ1bDIuODksMi40MzhjLTAuMTI2LDAuMzY4LTAuMTk4LDAuNzYzLTAuMTk4LDEuMTczYzAsMS45OTUsMS42MTgsMy42MTMsMy42MTQsMy42MTNjMS45OTUsMCwzLjYxNS0xLjYxOCwzLjYxNS0zLjYxM2MwLTEuOTk3LTEuNjItMy42MTQtMy42MTUtMy42MTRjLTAuNjMsMC0xLjIyMiwwLjE2Mi0xLjczNywwLjQ0M2wtMi44OS0yLjQzNWMwLjEyNi0wLjM2OCwwLjE5OC0wLjc2MywwLjE5OC0xLjE3M2MwLTAuMDg0LTAuMDA4LTAuMTY2LTAuMDEzLTAuMjVsNi42NzYtMy4xMzNjMC42NDgsMC42MTksMS41MjUsMS4wMDIsMi40OTUsMS4wMDJjMS45OTQsMCwzLjYxMy0xLjYxNywzLjYxMy0zLjYxM0MyMS42MjUsMi44MDYsMjAuMDA2LDEuMTg4LDE4LjAxMSwxLjE4OHoiLz48L3N2Zz4=';
359
+ $icon_svg = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxNS4xLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB3aWR0aD0iMjU2cHgiIGhlaWdodD0iMjU2cHgiIHZpZXdCb3g9IjAgMCAyNTYgMjU2IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCAyNTYgMjU2IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxnPg0KCTxnPg0KCQk8cGF0aCBmaWxsPSIjQTdBOUFDIiBkPSJNMTcyLjEwMywzNS4yMjNsLTEuMzk1LTI0LjA5N0wxNTMuMzYsNi40NzhsLTEzLjI1MywyMC4xNzFjLTYuNzQyLTAuNjc1LTEzLjUzNS0wLjY5Ni0yMC4yNzYtMC4wNDINCgkJCUwxMDYuNDY3LDYuMjdsLTE3LjM0OCw0LjY0N2wtMS40LDI0LjIwNGMtNi4wNzMsMi43MjQtMTEuOTMsNi4wNzQtMTcuNDg1LDEwLjAzOUw0OC40MDMsMzQuMTgzTDM1LjcwNCw0Ni44ODJsMTAuOTEsMjEuNzAxDQoJCQljLTQuMDExLDUuNTIyLTcuMzk2LDExLjM1Mi0xMC4xNywxNy4zOTdsLTI0LjM2NywxLjQxbC00LjY0OCwxNy4zNDhsMjAuMjQxLDEzLjNjLTAuNzA4LDYuNzM0LTAuNzg1LDEzLjUyMy0wLjE2NiwyMC4yNjUNCgkJCWwtMjAuMjg0LDEzLjMzbDQuNjQ4LDE3LjM0OGwyMy4zMjQsMS4zNDlsMC4yMjctMC44MjZsOS4xMDYtMzMuMTc2Yy0yLjEyNS0yNC4zMzMsNi4xMDQtNDkuMzk3LDI0LjcyOS02OC4wMjMNCgkJCWMyNy4zOTMtMjcuMzkzLDY4LjcxLTMyLjMxNSwxMDEuMTQ1LTE0LjgzM0w1NC40MjIsMTY5LjQ0N2wtMi41ODUtMzIuMzU1TDMwLjg5LDIxMy4zOThsMzEuNjE0LTMxLjYxNEwxODIuNzM1LDYxLjU1Mw0KCQkJbDQuMjA0LTQuMjA2bDcuOTc4LTcuOTc4QzE4Ny44MzYsNDMuNTU3LDE4MC4xNSwzOC44NTcsMTcyLjEwMywzNS4yMjN6Ii8+DQoJCTxwYXRoIGZpbGw9IiNBN0E5QUMiIGQ9Ik0xMDUuMjE0LDkuNTU4bDEyLjIzMSwxOC42MTRsMC45NDUsMS40NGwxLjcxNS0wLjE2NmMzLjE4Mi0wLjMwOCw2LjQyMy0wLjQ2NSw5LjYzNC0wLjQ2NQ0KCQkJYzMuMzQ3LDAsNi43MzYsMC4xNywxMC4wODIsMC41MDZsMS43MTksMC4xNzJsMC45NS0xLjQ0NGwxMi4xMjItMTguNDQ5bDEzLjM2NSwzLjU4MWwxLjI3NCwyMi4wNDFsMC4xMDEsMS43MjRsMS41NzMsMC43MTENCgkJCWM3LjAzNiwzLjE3NSwxMy42NTIsNy4xMzYsMTkuNzExLDExLjc5MWwtNS43MTcsNS43MThsLTQuMjAzLDQuMjAzTDYwLjQ4NSwxNzkuNzY2bC0yMy45OTEsMjMuOTkybDEzLjc5Mi01MC4yNDRsMS4yOTIsMTYuMTYyDQoJCQlsMC40OTMsNi4xNTlsNC4zNjktNC4zNjdMMTcyLjQxNiw1NS40OWwyLjcwOS0yLjcxMWwtMy4zNzItMS44MThjLTEyLjgyOS02LjkxNS0yNy4zNDktMTAuNTcxLTQxLjk5NC0xMC41NzENCgkJCWMtMjMuNjIsMC00NS44MjMsOS4xOTgtNjIuNTIyLDI1Ljg5N0M0OC44MzMsODQuNjksMzkuNTIsMTEwLjA5NSw0MS42MzksMTM2LjA2MWwtOC41ODcsMzEuMjg4bC0xOC45NjItMS4wOTlsLTMuNTgxLTEzLjM2Mw0KCQkJbDE4LjU2Mi0xMi4xOThsMS40MzEtMC45NDJsLTAuMTU2LTEuNzA0Yy0wLjU5Mi02LjQzNi0wLjUzOC0xMy4wNjUsMC4xNjEtMTkuNzA2bDAuMTgyLTEuNzI4bC0xLjQ1Mi0wLjk1NWwtMTguNTE4LTEyLjE2Nw0KCQkJbDMuNTgxLTEzLjM2NmwyMi4zMDktMS4yOTFsMS43MTItMC4wOThsMC43MTctMS41NTljMi43MjktNS45NDgsNi4wNTUtMTEuNjM5LDkuODg1LTE2LjkxM2wxLjAyMS0xLjQwNmwtMC43NzktMS41NTINCgkJCWwtOS45ODQtMTkuODU5bDkuNzg0LTkuNzg0bDE5Ljk4OCwxMC4wNDlsMS41MzgsMC43NzRsMS40MDEtMS4wMDFjNS4zNDMtMy44MTEsMTEuMDYxLTcuMDk0LDE2Ljk5Ny05Ljc1N2wxLjU4MS0wLjcxMmwwLjEtMS43MjgNCgkJCWwxLjI4MS0yMi4xNDVMMTA1LjIxNCw5LjU1OCBNMTA2LjQ2Nyw2LjI3bC0xNy4zNDgsNC42NDdsLTEuNCwyNC4yMDRjLTYuMDczLDIuNzI2LTExLjkzLDYuMDc0LTE3LjQ4NiwxMC4wMzlsLTIxLjgzLTEwLjk3Ng0KCQkJbC0xMi43LDEyLjcwMWwxMC45MSwyMS42OTljLTQuMDExLDUuNTIyLTcuMzk2LDExLjM1My0xMC4xNywxNy4zOTdsLTI0LjM2NywxLjQxbC00LjY0OCwxNy4zNDhsMjAuMjQsMTMuMw0KCQkJYy0wLjcwOCw2LjczNC0wLjc4NCwxMy41MjMtMC4xNjUsMjAuMjY1bC0yMC4yODQsMTMuMzNsNC42NDgsMTcuMzQ4bDIzLjMyNCwxLjM0OWwwLjIyNy0wLjgyNmw5LjEwNi0zMy4xNzYNCgkJCWMtMi4xMjUtMjQuMzMzLDYuMTA0LTQ5LjM5NywyNC43MjktNjguMDIzYzE2LjcxLTE2LjcxMSwzOC42MDctMjUuMDYsNjAuNTA1LTI1LjA2YzEzLjk5OCwwLDI3Ljk5MiwzLjQxMSw0MC42NCwxMC4yMjcNCgkJCUw1NC40MjIsMTY5LjQ0OWwtMi41ODUtMzIuMzU3TDMwLjg5LDIxMy4zOThsMzEuNjE0LTMxLjYxNEwxODIuNzM1LDYxLjU1M2w0LjIwMy00LjIwNGw3Ljk3OS03Ljk3OQ0KCQkJYy03LjA4My01LjgxNS0xNC43NjctMTAuNTEzLTIyLjgxNC0xNC4xNDdsLTEuMzk1LTI0LjA5N0wxNTMuMzYsNi40NzhsLTEzLjI1NCwyMC4xN2MtMy40NDctMC4zNDYtNi45MDctMC41Mi0xMC4zNjYtMC41Mg0KCQkJYy0zLjMwNywwLTYuNjE0LDAuMTYtOS45MSwwLjQ3OUwxMDYuNDY3LDYuMjdMMTA2LjQ2Nyw2LjI3eiIvPg0KCTwvZz4NCgk8Zz4NCgkJPHBhdGggZmlsbD0iI0E3QTlBQyIgZD0iTTg3LjgwMiwyMjIuMjFsMS4zOTQsMjQuMDk3bDE3LjM0OCw0LjY0OWwxMy4yNTUtMjAuMTdjNi43NDIsMC42NzUsMTMuNTMzLDAuNjkzLDIwLjI3NCwwLjA0MQ0KCQkJbDEzLjM2NSwyMC4zMzVsMTcuMzQ3LTQuNjQ2bDEuMzk5LTI0LjIwMmM2LjA3My0yLjcyNSwxMS45My02LjA3NCwxNy40ODYtMTAuMDM4bDIxLjgzMSwxMC45NzRsMTIuNjk5LTEyLjY5OGwtMTAuOTEtMjEuNzAxDQoJCQljNC4wMTItNS41MjEsNy4zOTYtMTEuMzUyLDEwLjE2OS0xNy4zOThsMjQuMzY5LTEuNDA4bDQuNjQ2LTE3LjM0OGwtMjAuMjM5LTEzLjNjMC43MDgtNi43MzYsMC43ODQtMTMuNTIzLDAuMTY0LTIwLjI2Ng0KCQkJbDIwLjI4NC0xMy4zMjhsLTQuNjQ3LTE3LjM0OGwtMjMuMzIzLTEuMzQ5bC0wLjIyOCwwLjgyNWwtOS4xMDcsMzMuMTc1YzIuMTI3LDI0LjMzMi02LjEwNCw0OS4zOTctMjQuNzI5LDY4LjAyNA0KCQkJYy0yNy4zOTIsMjcuMzkzLTY4LjcwOSwzMi4zMTUtMTAxLjE0NCwxNC44MzFMMjA1LjQ4LDg3Ljk4NGwyLjU4NiwzMi4zNTZsMjAuOTQ4LTc2LjMwNWwtMzEuNjE1LDMxLjYxM0w3Ny4xNjksMTk1Ljg4DQoJCQlsLTQuMjA2LDQuMjA1bC03Ljk3OCw3Ljk3OUM3Mi4wNjgsMjEzLjg3Niw3OS43NTIsMjE4LjU3NSw4Ny44MDIsMjIyLjIxeiIvPg0KCQk8cGF0aCBmaWxsPSIjQTdBOUFDIiBkPSJNMjIzLjQwOSw1My42NzZsLTEzLjc5Myw1MC4yNGwtMS4yOS0xNi4xNmwtMC40OTQtNi4xNTlsLTQuMzY4LDQuMzdMODcuNDg3LDIwMS45NDJsLTIuNzA5LDIuNzEyDQoJCQlsMy4zNzMsMS44MThjMTIuODI4LDYuOTE0LDI3LjM1MSwxMC41NjgsNDEuOTk3LDEwLjU2OGMyMy42MTgsMCw0NS44MjEtOS4xOTUsNjIuNTItMjUuODk2DQoJCQljMTguNDAzLTE4LjQwMiwyNy43MTctNDMuODA3LDI1LjU5OC02OS43NzVsOC41ODgtMzEuMjgzbDE4Ljk2MSwxLjA5N2wzLjU4MiwxMy4zNjRsLTE4LjU2MywxMi4xOTdsLTEuNDMsMC45NDFsMC4xNTUsMS43MDUNCgkJCWMwLjU5Miw2LjQzNiwwLjUzOSwxMy4wNjctMC4xNiwxOS43MDZsLTAuMTgzLDEuNzI3bDEuNDUxLDAuOTU0bDE4LjUyMSwxMi4xNzFsLTMuNTgyLDEzLjM2NWwtMjIuMzExLDEuMjkxbC0xLjcxMiwwLjA5OQ0KCQkJbC0wLjcxNiwxLjU2Yy0yLjcyNyw1Ljk0NC02LjA1MywxMS42MzMtOS44ODYsMTYuOTExbC0xLjAyLDEuNDA0bDAuNzgsMS41NTRsOS45ODMsMTkuODU5bC05Ljc4NSw5Ljc4M2wtMTkuOTktMTAuMDUNCgkJCWwtMS41MzYtMC43NzJsLTEuNDAyLDAuOTk5Yy01LjM0MSwzLjgxNC0xMS4wNTksNy4wOTYtMTYuOTk0LDkuNzU4bC0xLjU4MiwwLjcxbC0wLjA5OSwxLjcyOWwtMS4yODMsMjIuMTQ2bC0xMy4zNjMsMy41ODENCgkJCWwtMTIuMjMzLTE4LjYxNWwtMC45NDYtMS40MzhsLTEuNzEzLDAuMTYzYy0zLjE4LDAuMzEtNi40MTcsMC40NjUtOS42MjYsMC40NjVjLTMuMzQ4LDAtNi43NDMtMC4xNjktMTAuMDktMC41MDVsLTEuNzE5LTAuMTcxDQoJCQlsLTAuOTUsMS40NDNsLTEyLjEyMiwxOC40NDhsLTEzLjM2Ni0zLjU4MWwtMS4yNzUtMjIuMDM4bC0wLjEtMS43MjdsLTEuNTc0LTAuNzA5Yy03LjAzNS0zLjE4LTEzLjY1My03LjEzOS0xOS43MS0xMS43OTINCgkJCWw1LjcxNi01LjcxNWw0LjIwNS00LjIwN0wxOTkuNDE4LDc3LjY2NkwyMjMuNDA5LDUzLjY3NiBNMjI5LjAxNSw0NC4wMzZsLTMxLjYxNSwzMS42MTNMNzcuMTY5LDE5NS44OGwtNC4yMDYsNC4yMDVsLTcuOTc3LDcuOTc5DQoJCQljNy4wOCw1LjgxMiwxNC43NjUsMTAuNTExLDIyLjgxNCwxNC4xNDZsMS4zOTQsMjQuMDk3bDE3LjM0OCw0LjY0OWwxMy4yNTQtMjAuMTczYzMuNDQ4LDAuMzQ4LDYuOTEyLDAuNTIzLDEwLjM3NCwwLjUyMw0KCQkJYzMuMzA0LDAsNi42MDctMC4xNjIsOS45LTAuNDc5bDEzLjM2NSwyMC4zMzVsMTcuMzQ3LTQuNjQ2bDEuMzk5LTI0LjIwMmM2LjA3My0yLjcyNSwxMS45MzEtNi4wNzcsMTcuNDg2LTEwLjAzOGwyMS44MzEsMTAuOTc0DQoJCQlsMTIuNjk5LTEyLjY5OGwtMTAuOTEtMjEuNzAxYzQuMDEyLTUuNTIxLDcuMzk2LTExLjM1MiwxMC4xNjktMTcuMzk4bDI0LjM2OS0xLjQwOGw0LjY0OS0xNy4zNDhsLTIwLjI0Mi0xMy4zDQoJCQljMC43MDgtNi43MzYsMC43ODQtMTMuNTIzLDAuMTY0LTIwLjI2NmwyMC4yODUtMTMuMzI4bC00LjY0OC0xNy4zNDhsLTIzLjMyNC0xLjM0OWwtMC4yMjcsMC44MjVsLTkuMTA3LDMzLjE3NQ0KCQkJYzIuMTI3LDI0LjMzMi02LjEwNCw0OS40MDEtMjQuNzI5LDY4LjAyNGMtMTYuNzA5LDE2LjcxLTM4LjYwNCwyNS4wNjEtNjAuNTAxLDI1LjA2MWMtMTMuOTk4LDAtMjcuOTk1LTMuNDEtNDAuNjQzLTEwLjIyOQ0KCQkJTDIwNS40OCw4Ny45ODRsMi41ODYsMzIuMzU2TDIyOS4wMTUsNDQuMDM2TDIyOS4wMTUsNDQuMDM2eiIvPg0KCTwvZz4NCjwvZz4NCjwvc3ZnPg0K';
360
 
361
  //Main Menu
362
  $perms = 'export';
installer/dup-installer/assets/inc.css.php CHANGED
@@ -1,14 +1,56 @@
1
  <?php defined('ABSPATH') || defined('DUPXABSPATH') || exit; ?>
2
  <style>
3
- body {font-family:Verdana,Arial,sans-serif; font-size:13px}
4
- fieldset {border:1px solid silver; border-radius:5px; padding:10px}
5
- h3 {margin:1px; padding:1px; font-size:13px;}
6
- a {color:#222}
7
- a:hover{color:gray}
8
- input[type=text], input[type=password], select {width:97%; border-radius:2px; border:1px solid silver; padding:4px; font-family:Verdana,Arial,sans-serif;}
9
- select {padding-left:0; width:99%}
10
- select:disabled {background:#EBEBE4}
11
- input.readonly {background-color:#efefef;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  .no-display { display: none; }
13
 
14
  /* ============================
@@ -34,9 +76,10 @@
34
  .dupx-warn {display:inline-block; color:#555;}
35
  .dupx-notice {display:inline-block; color:#000;}
36
  i[data-tooltip].fa-question-circle {cursor: pointer; color:#C3C3C3}
37
- div.status-badge-pass {float:right; border-radius:4px; color:#fff; padding:0 3px 0 3px; font-size:11px !important; min-width:30px; text-align:center;background-color:#418446; font-weight:normal; }
38
- div.status-badge-fail {float:right; border-radius:4px; color:#fff; padding:0 3px 0 3px; font-size:11px !important; min-width:30px; text-align:center;background-color:maroon; font-weight:normal;}
39
-
 
40
  button.default-btn, .default-btn, .default-btn:hover {
41
  cursor:pointer; color:#fff; font-size:16px; border-radius:5px; padding:7px 25px 5px 25px;
42
  background-color:#13659C; border:1px solid gray; text-decoration: none;
@@ -63,9 +106,9 @@
63
  [data-type="toggle"] > i.fa,
64
  i.fa.fa-toggle-empty { min-width: 8px; }
65
 
66
- /* ============================
67
- NOTICES
68
- ============================ */
69
  /* step messages */
70
  #step-messages { padding: 10px 25px 0; }
71
  .notice {
@@ -73,21 +116,42 @@
73
  border:1px solid #dfdfdf;
74
  border-left: 4px solid #fff;
75
  margin: 4px;
76
- padding: 2px;
77
  border-radius: 4px;
 
78
  }
 
79
  .notice-report {
80
  border-left: 4px solid #fff;
81
  padding-left: 0;
82
  padding-right: 0;
83
  margin-bottom: 4px;
84
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  .notice-report .info {
86
- word-wrap: break-word;
 
 
 
 
87
  }
88
 
89
- .notice-report .title {cursor:pointer; padding: 0 10px;}
90
- .notice-report .info {border-top: 1px solid #dedede; padding: 10px; font-size: 10px; background: #FAFAFA;}
91
  .notice.l-info,
92
  .notice.l-notice {border-left-color: #197b19;}
93
  .notice.l-swarning {border-left-color: #636363;}
@@ -98,8 +162,9 @@
98
  .report-sections-list .section {
99
  border: 1px solid #DFDFDF;
100
  margin-bottom: 25px;
101
- box-shadow: 4px 8px 11px -8px rgba(0,0,0,0.41);
102
  }
 
103
  .report-sections-list .section > .section-title {
104
  background-color: #efefef;
105
  padding: 3px;
@@ -107,9 +172,11 @@
107
  text-align: center;
108
  font-size: 14px;
109
  }
 
110
  .report-sections-list .section > .section-content {
111
  padding: 5px;
112
  }
 
113
  .notice-level-status {
114
  border-radius: 4px;
115
  padding: 2px;
@@ -120,6 +187,7 @@
120
  font-weight: bold;
121
  min-width:55px;
122
  }
 
123
  .notice-level-status.l-info,
124
  .notice-level-status.l-notice {background: #197b19;}
125
  .notice-level-status.l-swarning {background: #636363;}
@@ -155,21 +223,24 @@
155
  /* ============================
156
  INIT 1:SECURE PASSWORD
157
  ============================ */
158
- button.pass-toggle {height:26px; width:26px; position:absolute; top:0px; right:0px; border:1px solid silver; border-radius:0 4px 4px 0;}
159
- button.pass-toggle i { padding:0; display:block; margin:-2px 0 0 0}
160
- div.i1-pass-area {width:100%; text-align:center}
161
- div.i1-pass-data {padding:30px; margin:auto; text-align:center; width:300px}
162
- div.i1-pass-data table {width:100%; border-collapse:collapse; padding:0}
163
- div.i1-pass-data label {font-weight:bold}
164
- div.i1-pass-errmsg {color:maroon; font-weight:bold}
165
- div#i1-pass-input { text-align:center; margin:auto; padding:3px}
166
- input#secure-pass {border-radius:4px 0 0 4px; width:250px}
167
- div.error-pane {border:1px solid #efefef; border-left:4px solid #D54E21; padding:0 0 0 10px; margin:2px 0 10px 0}
168
- div.dupx-ui-error {padding-top:2px; font-size:13px; line-height: 20px}
169
- label.secure-lock {cursor:pointer}
170
- div#i1-pass-toggle {position: relative; margin:auto; width:243px;}
171
- input#secure-pass {border-radius:4px 0 0 4px; width:220px; height:20px; margin:0}
172
- button.pass-toggle {height:30px; width:30px; position:absolute; top:0px; right:0px; border:1px solid silver; border-radius:0 4px 4px 0; cursor:pointer}
 
 
 
173
 
174
 
175
  /* ============================
@@ -289,9 +360,8 @@
289
  /* ============================
290
  STEP 3 VIEW
291
  ============================ */
292
- table.s3-opts{width:100%; border:0;}
293
  table.s3-opts i.fa{font-size:16px}
294
- table.s3-opts input[type=text] {width:95% !important}
295
  table.s3-opts td{white-space:nowrap; padding:3px;}
296
  table.s3-opts td:first-child{width:90px; font-weight: bold}
297
  div#s3-adv-opts {margin-top:5px; }
@@ -328,6 +398,7 @@
328
  div.s4-gopro-btn a{color:green}
329
  div.s4-warn {color:maroon;}
330
  pre.s4-diff-viewer {line-height:11px}
 
331
 
332
  /* ============================
333
  STEP 5 HELP
@@ -408,15 +479,40 @@
408
  }
409
 
410
 
411
- /*!
412
- * password indicator
413
- */
414
- .top_testresult{font-weight:bold; font-size:11px; color:#222; padding:1px 1px 1px 4px; margin:4px 0 0 0; width:495px; dislay:inline-block}
415
- .top_testresult span{margin:0;}
416
- .top_shortPass{background:#edabab; border:1px solid #bc0000;display:block;}
417
- .top_badPass{background:#edabab;border:1px solid #bc0000;display:block;}
418
- .top_goodPass{background:#ffffe0; border:1px solid #e6db55; display:block;}
419
- .top_strongPass{background:#d3edab; border:1px solid #73bc00; display:block;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
420
 
421
  /*================================================
422
  LIB OVERIDES*/
1
  <?php defined('ABSPATH') || defined('DUPXABSPATH') || exit; ?>
2
  <style>
3
+ body {font-family:Verdana,Arial,sans-serif; font-size:13px}
4
+ fieldset {border:1px solid silver; border-radius:5px; padding:10px}
5
+ h3 {margin:1px; padding:1px; font-size:13px;}
6
+ a {color:#222}
7
+ a:hover{color:gray}
8
+
9
+ input:not([type=checkbox]):not([type=radio]):not([type=button]) , select {
10
+ width: 100%;
11
+ border-radius: 2px;
12
+ border: 1px solid silver;
13
+ padding: 4px;
14
+ padding-left: 4px;
15
+ font-family: Verdana,Arial,sans-serif;
16
+ line-height: 20px;
17
+ height: 30px;
18
+ box-sizing: border-box;
19
+ background-color: white;
20
+ color: black;
21
+ border-radius: 4px;
22
+ }
23
+
24
+ input[readonly]:not([type="checkbox"]):not([type="radio"]):not([type="button"]),
25
+ select[readonly],
26
+ select[readonly] option{
27
+ background-color: darkgray;
28
+ color: lightgray;
29
+ cursor: not-allowed;
30
+ }
31
+
32
+ select[size] {
33
+ height: auto;
34
+ line-height: 25px;
35
+ }
36
+
37
+ select , option {
38
+ background-color: lightgray;
39
+ color: black;
40
+ }
41
+ select {
42
+ padding-left:0;
43
+ }
44
+ select option {
45
+ padding: 2px 5px;
46
+ }
47
+ select option[disabled] {
48
+ text-decoration: line-through;
49
+ cursor: not-allowed;
50
+ }
51
+
52
+ select:disabled {background:#EBEBE4}
53
+ input.readonly {background-color:#efefef;}
54
  .no-display { display: none; }
55
 
56
  /* ============================
76
  .dupx-warn {display:inline-block; color:#555;}
77
  .dupx-notice {display:inline-block; color:#000;}
78
  i[data-tooltip].fa-question-circle {cursor: pointer; color:#C3C3C3}
79
+ div.status-badge-pass {background-color:#418446;}
80
+ div.status-badge-fail {background-color:maroon;}
81
+ div.status-badge-warn {background-color:#555;}
82
+ div.status-badge-pass, div.status-badge-fail, div.status-badge-warn {float:right; border-radius:4px; color:#fff; padding:0 3px 0 3px; font-size:11px !important; min-width:30px; text-align:center; font-weight:normal;}
83
  button.default-btn, .default-btn, .default-btn:hover {
84
  cursor:pointer; color:#fff; font-size:16px; border-radius:5px; padding:7px 25px 5px 25px;
85
  background-color:#13659C; border:1px solid gray; text-decoration: none;
106
  [data-type="toggle"] > i.fa,
107
  i.fa.fa-toggle-empty { min-width: 8px; }
108
 
109
+ /* ============================
110
+ NOTICES
111
+ ============================ */
112
  /* step messages */
113
  #step-messages { padding: 10px 25px 0; }
114
  .notice {
116
  border:1px solid #dfdfdf;
117
  border-left: 4px solid #fff;
118
  margin: 4px;
119
+ padding: 5px;
120
  border-radius: 4px;
121
+ font-size: 12px;
122
  }
123
+
124
  .notice-report {
125
  border-left: 4px solid #fff;
126
  padding-left: 0;
127
  padding-right: 0;
128
  margin-bottom: 4px;
129
  }
130
+
131
+ .next-step .title-separator {
132
+ margin-top: 5px;
133
+ padding-top: 5px;
134
+ border-top: 1px solid lightgray;
135
+ }
136
+
137
+ .notice .info pre {
138
+ margin: 0;
139
+ padding: 0;
140
+ overflow: auto;
141
+ }
142
+
143
+ .notice-report .title {
144
+ padding: 0 10px;
145
+ }
146
+
147
  .notice-report .info {
148
+ border-top: 1px solid #dedede;
149
+ padding: 10px;
150
+ font-size: 10px;
151
+ background: #FAFAFA;
152
+ word-wrap: break-word;
153
  }
154
 
 
 
155
  .notice.l-info,
156
  .notice.l-notice {border-left-color: #197b19;}
157
  .notice.l-swarning {border-left-color: #636363;}
162
  .report-sections-list .section {
163
  border: 1px solid #DFDFDF;
164
  margin-bottom: 25px;
165
+ box-shadow: 4px 8px 11px -8px rgba(0,0,0,0.41);
166
  }
167
+
168
  .report-sections-list .section > .section-title {
169
  background-color: #efefef;
170
  padding: 3px;
172
  text-align: center;
173
  font-size: 14px;
174
  }
175
+
176
  .report-sections-list .section > .section-content {
177
  padding: 5px;
178
  }
179
+
180
  .notice-level-status {
181
  border-radius: 4px;
182
  padding: 2px;
187
  font-weight: bold;
188
  min-width:55px;
189
  }
190
+
191
  .notice-level-status.l-info,
192
  .notice-level-status.l-notice {background: #197b19;}
193
  .notice-level-status.l-swarning {background: #636363;}
223
  /* ============================
224
  INIT 1:SECURE PASSWORD
225
  ============================ */
226
+ button.pass-toggle {height:26px; width:26px; position:absolute; top:0px; right:0px; border:1px solid silver; border-radius:0 4px 4px 0;padding:2px 0 0 3px;}
227
+ button.pass-toggle i { padding:0; display:block; margin:-4px 0 0 -5px}
228
+ div.i1-pass-area {
229
+ width:100%;
230
+ text-align:center;
231
+ max-width: 300px;
232
+ margin: auto;
233
+ position: relative;
234
+ }
235
+ div.i1-pass-data table {width:100%; border-collapse:collapse; padding:0}
236
+ div.i1-pass-data label {
237
+ display: block;
238
+ margin-bottom: 10px;
239
+ font-weight:bold;
240
+ }
241
+ div.i1-pass-errmsg {color:maroon; font-weight:bold}
242
+ div#i1-pass-input {position:relative; margin:2px 0 15px 0}
243
+ input#secure-pass {border-radius:4px 0 0 4px; width:250px}
244
 
245
 
246
  /* ============================
360
  /* ============================
361
  STEP 3 VIEW
362
  ============================ */
363
+ table.s3-opts{width:96%; border:0;}
364
  table.s3-opts i.fa{font-size:16px}
 
365
  table.s3-opts td{white-space:nowrap; padding:3px;}
366
  table.s3-opts td:first-child{width:90px; font-weight: bold}
367
  div#s3-adv-opts {margin-top:5px; }
398
  div.s4-gopro-btn a{color:green}
399
  div.s4-warn {color:maroon;}
400
  pre.s4-diff-viewer {line-height:11px}
401
+ div#s4-notice-reports div.section-content div.title {cursor:pointer}
402
 
403
  /* ============================
404
  STEP 5 HELP
479
  }
480
 
481
 
482
+ /*!
483
+ * password indicator
484
+ */
485
+
486
+ .top_testresult{
487
+ font-weight:bold; font-size:11px; color:#222; display: block;
488
+ position: absolute;
489
+ top: 0;
490
+ right: 30px;
491
+ text-align: right;
492
+ padding-right: 20px;
493
+ box-sizing: border-box;
494
+ width: 40%;
495
+ height: 30px;
496
+ line-height: 30px;
497
+ }
498
+
499
+
500
+ .top_shortPass,
501
+ .top_badPass {
502
+ background:#edabab;
503
+ background: transparent linear-gradient(90deg, transparent 20%, #edabab);
504
+ display:block;
505
+ }
506
+ .top_goodPass{
507
+ background:#ffffe0;
508
+ background: transparent linear-gradient(90deg, transparent 20%, #ffffe0);
509
+ display:block;
510
+ }
511
+ .top_strongPass{
512
+ background:#d3edab;
513
+ background: transparent linear-gradient(90deg, transparent 20%, #d3edab);
514
+ display:block;
515
+ }
516
 
517
  /*================================================
518
  LIB OVERIDES*/
installer/dup-installer/classes/Crypt/Random.php CHANGED
@@ -147,7 +147,7 @@ if (!function_exists('crypt_random_string')) {
147
  }
148
 
149
  session_id(1);
150
- if (SnapLibUtil::wp_is_ini_value_changeable('session.use_cookies'))
151
  ini_set('session.use_cookies', 0);
152
  session_cache_limiter('');
153
  session_start();
@@ -172,7 +172,7 @@ if (!function_exists('crypt_random_string')) {
172
  if ($old_session_id != '') {
173
  session_id($old_session_id);
174
  session_start();
175
- if (SnapLibUtil::wp_is_ini_value_changeable('session.use_cookies'))
176
  ini_set('session.use_cookies', $old_use_cookies);
177
  session_cache_limiter($old_session_cache_limiter);
178
  } else {
147
  }
148
 
149
  session_id(1);
150
+ if (DupLiteSnapLibUtil::wp_is_ini_value_changeable('session.use_cookies'))
151
  ini_set('session.use_cookies', 0);
152
  session_cache_limiter('');
153
  session_start();
172
  if ($old_session_id != '') {
173
  session_id($old_session_id);
174
  session_start();
175
+ if (DupLiteSnapLibUtil::wp_is_ini_value_changeable('session.use_cookies'))
176
  ini_set('session.use_cookies', $old_use_cookies);
177
  session_cache_limiter($old_session_cache_limiter);
178
  } else {
installer/dup-installer/classes/Crypt/Rijndael.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- defined('DUPXABSPATH') || exit;
3
  /**
4
  * Pure-PHP implementation of Rijndael.
5
  *
1
  <?php
2
+ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
3
  /**
4
  * Pure-PHP implementation of Rijndael.
5
  *
installer/dup-installer/classes/class.csrf.php CHANGED
@@ -7,7 +7,6 @@ class DUPX_CSRF {
7
  * @var string
8
  */
9
  public static $prefix = '_DUPX_CSRF';
10
- private static $cipher;
11
  private static $CSRFVars;
12
 
13
  public static function setKeyVal($key, $val) {
@@ -39,10 +38,6 @@ class DUPX_CSRF {
39
  $token = $existingToken;
40
  } else {
41
  $token = DUPX_CSRF::token() . DUPX_CSRF::fingerprint();
42
- if (self::isCrypt()) {
43
- // $keyName = self::encrypt($keyName);
44
- $token = self::encrypt($token);
45
- }
46
  }
47
 
48
  self::setKeyVal($keyName, $token);
@@ -56,14 +51,9 @@ class DUPX_CSRF {
56
  */
57
  public static function check($token, $form = NULL) {
58
  $keyName = self::getKeyName($form);
59
- // if (self::isCrypt()) {
60
- // $keyName = self::decrypt($keyName);
61
- // $token = self::decrypt($token);
62
- // }
63
  $CSRFVars = self::getCSRFVars();
64
  if (isset($CSRFVars[$keyName]) && $CSRFVars[$keyName] == $token) { // token OK
65
  return true;
66
- // return (substr($token, -32) == DUPX_CSRF::fingerprint()); // fingerprint OK?
67
  }
68
  return FALSE;
69
  }
@@ -90,18 +80,6 @@ class DUPX_CSRF {
90
  return DUPX_CSRF::$prefix . '_' . $form;
91
  }
92
 
93
- private static function isCrypt() {
94
- if (class_exists('DUPX_Bootstrap')) {
95
- return DUPX_Bootstrap::CSRF_CRYPT;
96
- } else {
97
- return $GLOBALS['DUPX_AC']->csrf_crypt;
98
- }
99
- }
100
-
101
- private static function getCryptKey() {
102
- return 'snapcreek-'.self::getPackageHash();
103
- }
104
-
105
  private static function getPackageHash() {
106
  if (class_exists('DUPX_Bootstrap')) {
107
  return DUPX_Bootstrap::PACKAGE_HASH;
@@ -143,31 +121,10 @@ class DUPX_CSRF {
143
  }
144
 
145
  private static function saveCSRFVars($CSRFVars) {
146
- $contents = json_encode($CSRFVars);
147
  $filePath = self::getFilePath();
148
  file_put_contents($filePath, $contents);
149
  }
150
-
151
- private static function getCipher() {
152
- if (!isset(self::$cipher)) {
153
- self::$cipher = new Crypt_Rijndael();
154
- $cryptKey = self::getCryptKey();
155
- self::$cipher->setKey($cryptKey);
156
- }
157
- return self::$cipher;
158
- }
159
-
160
- private static function encrypt($val) {
161
- $cipher = self::getCipher();
162
- $val = $cipher->encrypt($val);
163
- return base64_encode($val);
164
- }
165
-
166
- private static function decrypt($val) {
167
- $cipher = self::getCipher();
168
- $val = base64_decode($val);
169
- return $cipher->decrypt($val);
170
- }
171
  }
172
 
173
  ?>
7
  * @var string
8
  */
9
  public static $prefix = '_DUPX_CSRF';
 
10
  private static $CSRFVars;
11
 
12
  public static function setKeyVal($key, $val) {
38
  $token = $existingToken;
39
  } else {
40
  $token = DUPX_CSRF::token() . DUPX_CSRF::fingerprint();
 
 
 
 
41
  }
42
 
43
  self::setKeyVal($keyName, $token);
51
  */
52
  public static function check($token, $form = NULL) {
53
  $keyName = self::getKeyName($form);
 
 
 
 
54
  $CSRFVars = self::getCSRFVars();
55
  if (isset($CSRFVars[$keyName]) && $CSRFVars[$keyName] == $token) { // token OK
56
  return true;
 
57
  }
58
  return FALSE;
59
  }
80
  return DUPX_CSRF::$prefix . '_' . $form;
81
  }
82
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  private static function getPackageHash() {
84
  if (class_exists('DUPX_Bootstrap')) {
85
  return DUPX_Bootstrap::PACKAGE_HASH;
121
  }
122
 
123
  private static function saveCSRFVars($CSRFVars) {
124
+ $contents = DupLiteSnapLibUtil::wp_json_encode($CSRFVars);
125
  $filePath = self::getFilePath();
126
  file_put_contents($filePath, $contents);
127
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  }
129
 
130
  ?>
installer/dup-installer/classes/class.engine.php CHANGED
@@ -350,6 +350,7 @@ class DUPX_UpdateEngine
350
  'shortMsg' => 'DATA-REPLACE ERRORS: MySQL',
351
  'level' => DUPX_NOTICE_ITEM::SOFT_WARNING,
352
  'longMsg' => $errMsg,
 
353
  'sections' => 'search_replace'
354
  ));
355
  }
350
  'shortMsg' => 'DATA-REPLACE ERRORS: MySQL',
351
  'level' => DUPX_NOTICE_ITEM::SOFT_WARNING,
352
  'longMsg' => $errMsg,
353
+ 'longMsgMode'=> DUPX_NOTICE_ITEM::MSG_MODE_PRE,
354
  'sections' => 'search_replace'
355
  ));
356
  }
installer/dup-installer/classes/class.installer.state.php CHANGED
@@ -23,7 +23,7 @@ class DUPX_InstallerState
23
  self::$state_filepath = dirname(__FILE__).'/../installer-state.txt';
24
 
25
  if($clearState) {
26
- SnapLibIOU::rm(self::$state_filepath);
27
  }
28
  }
29
 
@@ -81,10 +81,8 @@ class DUPX_InstallerState
81
 
82
  public function save()
83
  {
84
- $data = SnapLibStringU::jsonEncode($this);
85
 
86
- SnapLibIOU::filePutContents(self::$state_filepath, $data);
87
  }
88
- }
89
-
90
- DUPX_InstallerState::init($GLOBALS['INIT']);
23
  self::$state_filepath = dirname(__FILE__).'/../installer-state.txt';
24
 
25
  if($clearState) {
26
+ DupLiteSnapLibIOU::rm(self::$state_filepath);
27
  }
28
  }
29
 
81
 
82
  public function save()
83
  {
84
+ $data = DupLiteSnapLibUtil::wp_json_encode($this);
85
 
86
+ DupLiteSnapLibIOU::filePutContents(self::$state_filepath, $data);
87
  }
88
+ }
 
 
installer/dup-installer/classes/class.logging.php CHANGED
@@ -19,7 +19,6 @@ define('ERR_DBMANUAL', 'The database "%s" has "%s" tables. This does not look to
19
  define('ERR_TESTDB_VERSION_INFO', 'The current version detected was released prior to MySQL 5.5.3 which had a release date of April 8th, 2010. WordPress 4.2 included support for utf8mb4 which is only supported in MySQL server 5.5.3+. It is highly recommended to upgrade your version of MySQL server on this server to be more compatible with recent releases of WordPress and avoid issues with install errors.');
20
  define('ERR_TESTDB_VERSION_COMPAT', 'In order to avoid database incompatibility issues make sure the database versions between the build and installer servers are as close as possible. If the package was created on a newer database version than where it is being installed then you might run into issues.<br/><br/> It is best to make sure the server where the installer is running has the same or higher version number than where it was built. If the major and minor version are the same or close for example [5.7 to 5.6], then the migration should work without issues. A version pair of [5.7 to 5.1] is more likely to cause issues unless you have a very simple setup. If the versions are too far apart work with your hosting provider to upgrade the MySQL engine on this server.<br/><br/> <b>MariaDB:</b> If see a version of 10.N.N then the database distribution is a MariaDB flavor of MySQL. While the distributions are very close there are some subtle differences. Some operating systems will report the version such as "5.5.5-10.1.21-MariaDB" showing the correlation of both. Please visit the online <a href="https://mariadb.com/kb/en/mariadb/mariadb-vs-mysql-compatibility/" target="_blank">MariaDB versus MySQL - Compatibility</a> page for more details.<br/><br/> Please note these messages are simply notices. It is highly recommended that you continue with the install process and closely monitor the dup-installer-log.txt file along with the install report found on step 3 of the installer. Be sure to look for any notices/warnings/errors in these locations to validate the install process did not detect any errors. If any issues are found please visit the FAQ pages and see the question <a href="https://snapcreek.com/duplicator/docs/faqs-tech/#faq-installer-260-q" target="_blank">What if I get database errors or general warnings on the install report?</a>.');
21
 
22
-
23
  /**
24
  * DUPX_Log
25
  * Class used to log information */
@@ -52,7 +51,9 @@ class DUPX_Log
52
  public static function info($msg, $logging = self::LV_DEFAULT, $flush = false)
53
  {
54
  if ($logging <= $GLOBALS["LOGGING"]) {
55
- @fwrite($GLOBALS["LOG_FILE_HANDLE"], str_repeat("\t", self::$indentation).$msg."\n");
 
 
56
 
57
  if ($flush) {
58
  self::flush();
@@ -90,7 +91,22 @@ class DUPX_Log
90
 
91
  public static function flush()
92
  {
93
- @fflush($GLOBALS['LOG_FILE_HANDLE']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  }
95
 
96
  public static function error($errorMessage)
@@ -100,12 +116,13 @@ class DUPX_Log
100
  $log_msg = str_ireplace($breaks, "\r\n", $errorMessage);
101
  $log_msg = str_ireplace($spaces, " ", $log_msg);
102
  $log_msg = strip_tags($log_msg);
103
- @fwrite($GLOBALS["LOG_FILE_HANDLE"], "\nINSTALLER ERROR:\n{$log_msg}\n");
104
- @fclose($GLOBALS["LOG_FILE_HANDLE"]);
 
105
  if (self::$thowExceptionOnError) {
106
  throw new Exception('INSTALL ERROR: '.$errorMessage);
107
  } else {
108
- @fclose($GLOBALS["LOG_FILE_HANDLE"]);
109
  die("<div class='dupx-ui-error'><hr size='1' /><b style='color:#B80000;'>INSTALL ERROR!</b><br/>{$errorMessage}</div>");
110
  }
111
  }
@@ -219,11 +236,6 @@ class DUPX_Handler
219
  DUPX_Log::error($log_message);
220
  break;
221
  case E_NOTICE :
222
- if (DUPX_Log::isLevel(DUPX_Log::LV_DEFAULT)) {
223
- $log_message = self::getMessage($errno, $errstr, $errfile, $errline);
224
- DUPX_Log::info($log_message);
225
- }
226
- break;
227
  case E_WARNING :
228
  default :
229
  $log_message = self::getMessage($errno, $errstr, $errfile, $errline);
@@ -335,4 +347,4 @@ class DUPX_Handler
335
  }
336
  }
337
  @set_error_handler('DUPX_Handler::error');
338
- @register_shutdown_function('DUPX_Handler::shutdown');
19
  define('ERR_TESTDB_VERSION_INFO', 'The current version detected was released prior to MySQL 5.5.3 which had a release date of April 8th, 2010. WordPress 4.2 included support for utf8mb4 which is only supported in MySQL server 5.5.3+. It is highly recommended to upgrade your version of MySQL server on this server to be more compatible with recent releases of WordPress and avoid issues with install errors.');
20
  define('ERR_TESTDB_VERSION_COMPAT', 'In order to avoid database incompatibility issues make sure the database versions between the build and installer servers are as close as possible. If the package was created on a newer database version than where it is being installed then you might run into issues.<br/><br/> It is best to make sure the server where the installer is running has the same or higher version number than where it was built. If the major and minor version are the same or close for example [5.7 to 5.6], then the migration should work without issues. A version pair of [5.7 to 5.1] is more likely to cause issues unless you have a very simple setup. If the versions are too far apart work with your hosting provider to upgrade the MySQL engine on this server.<br/><br/> <b>MariaDB:</b> If see a version of 10.N.N then the database distribution is a MariaDB flavor of MySQL. While the distributions are very close there are some subtle differences. Some operating systems will report the version such as "5.5.5-10.1.21-MariaDB" showing the correlation of both. Please visit the online <a href="https://mariadb.com/kb/en/mariadb/mariadb-vs-mysql-compatibility/" target="_blank">MariaDB versus MySQL - Compatibility</a> page for more details.<br/><br/> Please note these messages are simply notices. It is highly recommended that you continue with the install process and closely monitor the dup-installer-log.txt file along with the install report found on step 3 of the installer. Be sure to look for any notices/warnings/errors in these locations to validate the install process did not detect any errors. If any issues are found please visit the FAQ pages and see the question <a href="https://snapcreek.com/duplicator/docs/faqs-tech/#faq-installer-260-q" target="_blank">What if I get database errors or general warnings on the install report?</a>.');
21
 
 
22
  /**
23
  * DUPX_Log
24
  * Class used to log information */
51
  public static function info($msg, $logging = self::LV_DEFAULT, $flush = false)
52
  {
53
  if ($logging <= $GLOBALS["LOGGING"]) {
54
+ if (is_resource($GLOBALS['LOG_FILE_HANDLE'])) {
55
+ @fwrite($GLOBALS["LOG_FILE_HANDLE"], str_repeat("\t", self::$indentation).$msg."\n");
56
+ }
57
 
58
  if ($flush) {
59
  self::flush();
91
 
92
  public static function flush()
93
  {
94
+ if (is_resource($GLOBALS['LOG_FILE_HANDLE'])) {
95
+ @fflush($GLOBALS['LOG_FILE_HANDLE']);
96
+ }
97
+ }
98
+
99
+ public static function close()
100
+ {
101
+ if (is_resource($GLOBALS['LOG_FILE_HANDLE'])) {
102
+ @fclose($GLOBALS["LOG_FILE_HANDLE"]);
103
+ $GLOBALS["LOG_FILE_HANDLE"] = null;
104
+ }
105
+ }
106
+
107
+ public static function getFileHandle()
108
+ {
109
+ return is_resource($GLOBALS["LOG_FILE_HANDLE"]) ? $GLOBALS["LOG_FILE_HANDLE"] : false;
110
  }
111
 
112
  public static function error($errorMessage)
116
  $log_msg = str_ireplace($breaks, "\r\n", $errorMessage);
117
  $log_msg = str_ireplace($spaces, " ", $log_msg);
118
  $log_msg = strip_tags($log_msg);
119
+
120
+ self::info("\nINSTALLER ERROR:\n{$log_msg}\n");
121
+
122
  if (self::$thowExceptionOnError) {
123
  throw new Exception('INSTALL ERROR: '.$errorMessage);
124
  } else {
125
+ self::close();
126
  die("<div class='dupx-ui-error'><hr size='1' /><b style='color:#B80000;'>INSTALL ERROR!</b><br/>{$errorMessage}</div>");
127
  }
128
  }
236
  DUPX_Log::error($log_message);
237
  break;
238
  case E_NOTICE :
 
 
 
 
 
239
  case E_WARNING :
240
  default :
241
  $log_message = self::getMessage($errno, $errstr, $errfile, $errline);
347
  }
348
  }
349
  @set_error_handler('DUPX_Handler::error');
350
+ @register_shutdown_function('DUPX_Handler::shutdown');
installer/dup-installer/classes/class.password.php CHANGED
@@ -227,5 +227,3 @@ class DUPX_PasswordHash
227
  return $hash === $stored_hash;
228
  }
229
  }
230
-
231
- ?>
227
  return $hash === $stored_hash;
228
  }
229
  }
 
 
installer/dup-installer/classes/config/class.archive.config.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
- defined('ABSPATH') || defined('DUPXABSPATH') || exit;
3
  /**
4
  * Class used to control values about the package meta data
5
  *
@@ -9,6 +8,7 @@ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
9
  * @package SC\DUPX\ArchiveConfig
10
  *
11
  */
 
12
 
13
  class DUPX_ArchiveConfig
14
  {
1
  <?php
 
2
  /**
3
  * Class used to control values about the package meta data
4
  *
8
  * @package SC\DUPX\ArchiveConfig
9
  *
10
  */
11
+ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
12
 
13
  class DUPX_ArchiveConfig
14
  {
installer/dup-installer/classes/config/class.boot.php CHANGED
@@ -55,16 +55,16 @@ class DUPX_Boot
55
  @set_time_limit(3600);
56
 
57
  $ini_get_default_charset = ini_get("default_charset");
58
- if (empty($ini_get_default_charset) && SnapLibUtil::wp_is_ini_value_changeable('default_charset')) {
59
  @ini_set("default_charset", 'utf-8');
60
  }
61
- if (SnapLibUtil::wp_is_ini_value_changeable('memory_limit')) {
62
  @ini_set('memory_limit', DUPLICATOR_PHP_MAX_MEMORY);
63
  }
64
- if (SnapLibUtil::wp_is_ini_value_changeable('max_input_time')) {
65
  @ini_set('max_input_time', '-1');
66
  }
67
- if (SnapLibUtil::wp_is_ini_value_changeable('pcre.backtrack_limit')) {
68
  @ini_set('pcre.backtrack_limit', PHP_INT_MAX);
69
  }
70
  }
@@ -89,4 +89,11 @@ class DUPX_Boot
89
  require_once($GLOBALS['DUPX_INIT'].'/classes/utilities/class.u.html.php');
90
  require_once($GLOBALS['DUPX_INIT'].'/classes/config/class.constants.php');
91
  }
 
 
 
 
 
 
 
92
  }
55
  @set_time_limit(3600);
56
 
57
  $ini_get_default_charset = ini_get("default_charset");
58
+ if (empty($ini_get_default_charset) && DupLiteSnapLibUtil::wp_is_ini_value_changeable('default_charset')) {
59
  @ini_set("default_charset", 'utf-8');
60
  }
61
+ if (DupLiteSnapLibUtil::wp_is_ini_value_changeable('memory_limit')) {
62
  @ini_set('memory_limit', DUPLICATOR_PHP_MAX_MEMORY);
63
  }
64
+ if (DupLiteSnapLibUtil::wp_is_ini_value_changeable('max_input_time')) {
65
  @ini_set('max_input_time', '-1');
66
  }
67
+ if (DupLiteSnapLibUtil::wp_is_ini_value_changeable('pcre.backtrack_limit')) {
68
  @ini_set('pcre.backtrack_limit', PHP_INT_MAX);
69
  }
70
  }
89
  require_once($GLOBALS['DUPX_INIT'].'/classes/utilities/class.u.html.php');
90
  require_once($GLOBALS['DUPX_INIT'].'/classes/config/class.constants.php');
91
  }
92
+
93
+ public static function initArchiveAndLog()
94
+ {
95
+ require_once($GLOBALS['DUPX_INIT'].'/classes/config/class.archive.config.php');
96
+ $GLOBALS['DUPX_AC'] = DUPX_ArchiveConfig::getInstance();
97
+ require_once($GLOBALS['DUPX_INIT'].'/classes/class.logging.php');
98
+ }
99
  }
installer/dup-installer/classes/config/class.conf.srv.php CHANGED
@@ -212,7 +212,7 @@ HTACCESS;
212
  private static function createBackup($file_path, $type)
213
  {
214
  $status = false;
215
- $file_name = SnapLibIOU::getFileName($file_path);
216
  $hash = self::$fileHash;
217
  $source = self::getTypeName($type);
218
  if (is_file($file_path)) {
@@ -241,7 +241,7 @@ HTACCESS;
241
  $status = false;
242
  if (is_file($file_path)) {
243
  $source = self::getTypeName($type);
244
- $file_name = SnapLibIOU::getFileName($file_path);
245
  $status = @unlink($file_path);
246
  if ($status === FALSE) {
247
  @chmod($file_path, 0777);
@@ -448,7 +448,7 @@ HTACCESS;
448
  'longMsg' => $longMsg,
449
  'sections' => 'changes',
450
  'open' => true,
451
- 'longMsgHtml' => true
452
  ), DUPX_NOTICE_MANAGER::ADD_UNIQUE, 'htaccess-changes');
453
  }
454
 
@@ -480,7 +480,7 @@ HTACCESS;
480
  'longMsg' => $longMsg,
481
  'sections' => 'changes',
482
  'open' => true,
483
- 'longMsgHtml' => true
484
  ), DUPX_NOTICE_MANAGER::ADD_UNIQUE, 'wp-config-changes');
485
  }
486
 
212
  private static function createBackup($file_path, $type)
213
  {
214
  $status = false;
215
+ $file_name = DupLiteSnapLibIOU::getFileName($file_path);
216
  $hash = self::$fileHash;
217
  $source = self::getTypeName($type);
218
  if (is_file($file_path)) {
241
  $status = false;
242
  if (is_file($file_path)) {
243
  $source = self::getTypeName($type);
244
+ $file_name = DupLiteSnapLibIOU::getFileName($file_path);
245
  $status = @unlink($file_path);
246
  if ($status === FALSE) {
247
  @chmod($file_path, 0777);
448
  'longMsg' => $longMsg,
449
  'sections' => 'changes',
450
  'open' => true,
451
+ 'longMsgMode'=> DUPX_NOTICE_ITEM::MSG_MODE_HTML
452
  ), DUPX_NOTICE_MANAGER::ADD_UNIQUE, 'htaccess-changes');
453
  }
454
 
480
  'longMsg' => $longMsg,
481
  'sections' => 'changes',
482
  'open' => true,
483
+ 'longMsgMode'=> DUPX_NOTICE_ITEM::MSG_MODE_HTML
484
  ), DUPX_NOTICE_MANAGER::ADD_UNIQUE, 'wp-config-changes');
485
  }
486
 
installer/dup-installer/classes/config/class.constants.php CHANGED
@@ -51,11 +51,11 @@ class DUPX_Constants
51
 
52
  //PHP INI SETUP: all time in seconds
53
  if (!$GLOBALS['DUPX_ENFORCE_PHP_INI']) {
54
- if (SnapLibUtil::wp_is_ini_value_changeable('mysql.connect_timeout'))@ini_set('mysql.connect_timeout', '5000');
55
- if (SnapLibUtil::wp_is_ini_value_changeable('memory_limit')) @ini_set('memory_limit', DUPLICATOR_PHP_MAX_MEMORY);
56
- if (SnapLibUtil::wp_is_ini_value_changeable('max_execution_time')) @ini_set("max_execution_time", '5000');
57
- if (SnapLibUtil::wp_is_ini_value_changeable('max_input_time')) @ini_set("max_input_time", '5000');
58
- if (SnapLibUtil::wp_is_ini_value_changeable('default_socket_timeout')) @ini_set('default_socket_timeout', '5000');
59
  @set_time_limit(0);
60
  }
61
 
51
 
52
  //PHP INI SETUP: all time in seconds
53
  if (!$GLOBALS['DUPX_ENFORCE_PHP_INI']) {
54
+ if (DupLiteSnapLibUtil::wp_is_ini_value_changeable('mysql.connect_timeout'))@ini_set('mysql.connect_timeout', '5000');
55
+ if (DupLiteSnapLibUtil::wp_is_ini_value_changeable('memory_limit')) @ini_set('memory_limit', DUPLICATOR_PHP_MAX_MEMORY);
56
+ if (DupLiteSnapLibUtil::wp_is_ini_value_changeable('max_execution_time')) @ini_set("max_execution_time", '5000');
57
+ if (DupLiteSnapLibUtil::wp_is_ini_value_changeable('max_input_time')) @ini_set("max_input_time", '5000');
58
+ if (DupLiteSnapLibUtil::wp_is_ini_value_changeable('default_socket_timeout')) @ini_set('default_socket_timeout', '5000');
59
  @set_time_limit(0);
60
  }
61
 
installer/dup-installer/classes/utilities/class.u.exceptions.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
- defined('ABSPATH') || defined('DUPXABSPATH') || exit;
3
  /**
4
  * Custom exceptions
5
  *
@@ -9,6 +8,7 @@ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
9
  * @package SC\DUPX\U
10
  *
11
  */
 
12
 
13
  /**
14
  * Dup installer custom exception
1
  <?php
 
2
  /**
3
  * Custom exceptions
4
  *
8
  * @package SC\DUPX\U
9
  *
10
  */
11
+ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
12
 
13
  /**
14
  * Dup installer custom exception
installer/dup-installer/classes/utilities/class.u.html.php CHANGED
@@ -8,11 +8,14 @@
8
  * @package SC\DUPX\U
9
  *
10
  */
11
- defined("DUPXABSPATH") or die("");
12
 
 
 
 
13
  class DUPX_U_Html
14
  {
15
- protected static $lightboxUniqueId = 0;
16
 
17
  /**
18
  * inizialize css for html elements
@@ -20,6 +23,8 @@ class DUPX_U_Html
20
  public static function css()
21
  {
22
  self::lightBoxCss();
 
 
23
  }
24
 
25
  /**
@@ -28,12 +33,14 @@ class DUPX_U_Html
28
  public static function js()
29
  {
30
  self::lightBoxJs();
 
 
31
  }
32
 
33
  private static function getUniqueId()
34
  {
35
- self::$lightboxUniqueId ++;
36
- return 'dup-light-'.self::$lightboxUniqueId.'-'.str_replace('.', '-', microtime(true));
37
  }
38
 
39
  public static function getLigthBox($linkLabelHtml, $titleContent, $htmlContent, $echo = true, $htmlAfterContent = '')
@@ -68,10 +75,10 @@ class DUPX_U_Html
68
  if ($enableTargetDownload) {
69
  $path = parse_url($url, PHP_URL_PATH);
70
  if (!empty($path)) {
71
- $urlPath = parse_url($url,PHP_URL_PATH);
72
  $fileName = basename($urlPath);
73
  } else {
74
- $fileName = parse_url($url,PHP_URL_HOST);
75
  }
76
  $afterContent .= '<a target="_blank" class="button download-button" title="Download" download="'.DUPX_U::esc_attr($fileName).'" href="'.DUPX_U::esc_attr($url).'" onclick="function () { event.preventDefault(); return false;}" ><i class="fa fa-2x fa-download"></i></a>';
77
  }
@@ -175,10 +182,9 @@ class DUPX_U_Html
175
  width: 50%;
176
  box-sizing: border-box;
177
  float: left;
178
- border: 1px solid #8e8d8d;
179
  height: 100%;
180
  overflow: auto;
181
- padding:5px;
182
  }
183
 
184
  .dub-ligthbox-content .row-cols-2 .col-2 {
@@ -292,7 +298,7 @@ class DUPX_U_Html
292
  toggleLightbox($(this).closest('.dub-ligthbox-content'));
293
  });
294
 
295
- $(window).keydown(function(event){
296
  if (event.key === 'Escape' && currentLightboxOpen !== null) {
297
  currentLightboxOpen.find('.close-button').trigger('click');
298
  }
@@ -301,4 +307,245 @@ class DUPX_U_Html
301
  </script>
302
  <?php
303
  }
304
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  * @package SC\DUPX\U
9
  *
10
  */
11
+ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
12
 
13
+ /**
14
+ *
15
+ */
16
  class DUPX_U_Html
17
  {
18
+ protected static $uniqueId = 0;
19
 
20
  /**
21
  * inizialize css for html elements
23
  public static function css()
24
  {
25
  self::lightBoxCss();
26
+ self::moreContentCss();
27
+ self::inputPasswordToggleCss();
28
  }
29
 
30
  /**
33
  public static function js()
34
  {
35
  self::lightBoxJs();
36
+ self::moreContentJs();
37
+ self::inputPasswordToggleJs();
38
  }
39
 
40
  private static function getUniqueId()
41
  {
42
+ self::$uniqueId ++;
43
+ return 'dup-html-id-'.self::$uniqueId.'-'.str_replace('.', '-', microtime(true));
44
  }
45
 
46
  public static function getLigthBox($linkLabelHtml, $titleContent, $htmlContent, $echo = true, $htmlAfterContent = '')
75
  if ($enableTargetDownload) {
76
  $path = parse_url($url, PHP_URL_PATH);
77
  if (!empty($path)) {
78
+ $urlPath = parse_url($url, PHP_URL_PATH);
79
  $fileName = basename($urlPath);
80
  } else {
81
+ $fileName = parse_url($url, PHP_URL_HOST);
82
  }
83
  $afterContent .= '<a target="_blank" class="button download-button" title="Download" download="'.DUPX_U::esc_attr($fileName).'" href="'.DUPX_U::esc_attr($url).'" onclick="function () { event.preventDefault(); return false;}" ><i class="fa fa-2x fa-download"></i></a>';
84
  }
182
  width: 50%;
183
  box-sizing: border-box;
184
  float: left;
185
+ border-right: 1px solid black;
186
  height: 100%;
187
  overflow: auto;
 
188
  }
189
 
190
  .dub-ligthbox-content .row-cols-2 .col-2 {
298
  toggleLightbox($(this).closest('.dub-ligthbox-content'));
299
  });
300
 
301
+ $(window).keydown(function (event) {
302
  if (event.key === 'Escape' && currentLightboxOpen !== null) {
303
  currentLightboxOpen.find('.close-button').trigger('click');
304
  }
307
  </script>
308
  <?php
309
  }
310
+
311
+ /**
312
+ *
313
+ * @param string $htmlContent
314
+ * @param string|string[] $classes additiona classes on main div
315
+ * @param int $step pixel foreach more step
316
+ * @param string $id id on main div
317
+ * @param bool $echo
318
+ *
319
+ * @return string|void
320
+ */
321
+ public static function getMoreContent($htmlContent, $classes = array(), $step = 200, $id = '', $echo = true)
322
+ {
323
+ $inputCls = filter_var($classes, FILTER_SANITIZE_STRING, FILTER_FORCE_ARRAY);
324
+ $mainClasses = array_merge(array('more-content'), $inputCls);
325
+ $atStep = max(100, $step);
326
+ $idAttr = empty($id) ? '' : 'id="'.$id.'" ';
327
+ ob_start();
328
+ ?>
329
+ <div <?php echo $idAttr; ?>class="<?php echo implode(' ', $mainClasses); ?>" data-more-step="<?php echo $atStep; ?>" style="max-height: <?php echo $atStep; ?>px">
330
+ <div class="more-wrapper" ><?php echo $htmlContent; ?></div>
331
+ <button class="more-button" type="button">[ show more ]</button>
332
+ <button class="all-button" type="button" >[ show all ]</button>
333
+ </div>
334
+ <?php
335
+ if ($echo) {
336
+ ob_end_flush();
337
+ } else {
338
+ return ob_get_clean();
339
+ }
340
+ }
341
+
342
+ protected static function moreContentCss()
343
+ {
344
+ ?>
345
+ <style>
346
+ .more-content {
347
+ overflow: hidden;
348
+ position: relative;
349
+ max-height: 0;
350
+ }
351
+
352
+ .more-content.more::after {
353
+ content: "";
354
+ position: absolute;
355
+ bottom: 0;
356
+ right: 0;
357
+ height: 60px;
358
+ width: 100%;
359
+ background-image: linear-gradient(transparent, rgba(255,255,255,0.95) 70%);
360
+ }
361
+
362
+ .more-content .more-button,
363
+ .more-content .all-button {
364
+ position: absolute;
365
+ bottom: 0;
366
+ z-index: 1000;
367
+ display: none;
368
+ background: rgba(255,255,255,0.5);
369
+ border: 0 none;
370
+ padding: 10px 10px 0;
371
+ margin: 0;
372
+ color: #365899;
373
+ cursor: pointer;
374
+ }
375
+
376
+ .more-content .more-button:hover,
377
+ .more-content .all-button:hover {
378
+ text-decoration: underline;
379
+ }
380
+
381
+ .more-content .more-button {
382
+ left: 0;
383
+ }
384
+
385
+ .more-content .all-button {
386
+ right: 0;
387
+ }
388
+
389
+ .more-content.more .more-button,
390
+ .more-content.more .all-button {
391
+ display: block;
392
+ }
393
+
394
+ </style>
395
+ <?php
396
+ }
397
+
398
+ protected static function moreContentJs()
399
+ {
400
+ ?>
401
+ <script>
402
+ $(document).ready(function ()
403
+ {
404
+ function moreCheck(moreCont, moreWrap) {
405
+ if (moreWrap.height() > moreCont.height()) {
406
+ moreCont.addClass('more');
407
+ } else {
408
+ moreCont.removeClass('more');
409
+ }
410
+ }
411
+
412
+ $('.more-content').each(function () {
413
+ var moreCont = $(this);
414
+ var step = moreCont.data('more-step');
415
+ var moreWrap = $(this).find('.more-wrapper');
416
+
417
+ moreCont.find('.more-button').click(function () {
418
+ moreCont.css('max-height', "+=" + step + "px");
419
+ moreCheck(moreCont, moreWrap);
420
+ });
421
+
422
+ moreCont.find('.all-button').click(function () {
423
+ moreCont.css('max-height', "none");
424
+ moreCheck(moreCont, moreWrap);
425
+ });
426
+
427
+ moreCheck(moreCont, moreWrap);
428
+ });
429
+ });
430
+ </script>
431
+ <?php
432
+ }
433
+
434
+ public static function inputPasswordToggle($name, $id = '', $classes = array(), $attrs = array())
435
+ {
436
+ if (!is_array($attrs)) {
437
+ $attrs = array();
438
+ }
439
+ if (!is_array($classes)) {
440
+ if (empty($classes)) {
441
+ $classes = array();
442
+ } else {
443
+ $classes = array($classes);
444
+ }
445
+ }
446
+ $idAttr = empty($id) ? '_id_'.$name : $id;
447
+ $classes[] = 'input-password-group';
448
+
449
+ $attrs['type'] = 'password';
450
+ $attrs['name'] = $name;
451
+ $attrs['id'] = $idAttr;
452
+ $attrsHtml = array();
453
+
454
+ foreach ($attrs as $atName => $atValue) {
455
+ $attrsHtml[] = $atName.'="'.DUPX_U::esc_attr($atValue).'"';
456
+ }
457
+ ?>
458
+ <span class="<?php echo implode(' ', $classes); ?>" >
459
+ <input <?php echo implode(' ', $attrsHtml); ?> />
460
+ <button type="button" title="Show the password"><i class="fas fa-eye fa-xs"></i></button>
461
+ </span>
462
+ <?php
463
+ }
464
+
465
+ protected static function inputPasswordToggleCss()
466
+ {
467
+ ?>
468
+ <style>
469
+ .input-password-group {
470
+ display: inline-block;
471
+ width:100%;
472
+ border: 1px solid darkgray;
473
+ border-radius: 4px;
474
+ overflow: hidden;
475
+ position: relative;
476
+ }
477
+ .input-password-group input:not([type=checkbox]):not([type=radio]):not([type=button]) {
478
+ width: calc(100% - 30px) !important;
479
+ padding: 4px;
480
+ line-height: 20px;
481
+ height: 30px;
482
+ box-sizing: border-box;
483
+ display: inline-block;
484
+ border-radius: 0;
485
+ border: 0 none;
486
+ border-right: 1px solid darkgray;
487
+ }
488
+ .input-password-group button {
489
+ display: inline-block;
490
+ width: 30px;
491
+ height: 30px;
492
+ box-sizing: border-box;
493
+ padding: 0;
494
+ margin: 0;
495
+ border: 0 none;
496
+ overflow: hidden;
497
+ float: right;
498
+ cursor: pointer;
499
+ }
500
+
501
+ .input-password-group button i {
502
+ line-height: 30px;
503
+ margin: 0;
504
+ padding: 0;
505
+ }
506
+
507
+ .input-password-group .parsley-errors-list {
508
+ position: absolute;
509
+ top: 50%;
510
+ transform: translateY(-50%);
511
+ left: 10px;
512
+ }
513
+
514
+ </style>
515
+ <?php
516
+ }
517
+
518
+ protected static function inputPasswordToggleJs()
519
+ {
520
+ ?>
521
+ <script>
522
+ $(document).ready(function () {
523
+ $('.input-password-group').each(function () {
524
+ var group = $(this);
525
+ var pwdInput = group.find('input');
526
+ var pwdLock = group.find('button');
527
+
528
+ pwdLock.click(function () {
529
+ if (pwdInput.attr('type') === 'password') {
530
+ pwdInput.attr({
531
+ 'type': 'text',
532
+ 'title': 'Hide the password'
533
+ });
534
+ pwdLock.find('i')
535
+ .removeClass('fa-eye')
536
+ .addClass('fa-eye-slash');
537
+ } else {
538
+ pwdInput.attr({
539
+ 'type': 'password',
540
+ 'title': 'Show the password'
541
+ });
542
+ pwdLock.find('i').removeClass('fa-eye-slash').addClass('fa-eye');
543
+ }
544
+ });
545
+ });
546
+
547
+ });
548
+ </script>
549
+ <?php
550
+ }
551
+ }
installer/dup-installer/classes/utilities/class.u.notices.manager.php CHANGED
@@ -88,8 +88,7 @@ final class DUPX_NOTICE_MANAGER
88
  $notices['finalReport'][$uniqueId] = $notice->toArray();
89
  }
90
 
91
- $json = json_encode($notices, JSON_PRETTY_PRINT);
92
- file_put_contents($this->persistanceFile, $json);
93
  }
94
 
95
  /**
@@ -104,12 +103,16 @@ final class DUPX_NOTICE_MANAGER
104
  $this->nextStepNotices = array();
105
  $this->finalReporNotices = array();
106
 
107
- foreach ($notices['nextStep'] as $uniqueId => $notice) {
108
- $this->nextStepNotices[$uniqueId] = DUPX_NOTICE_ITEM::getItemFromArray($notice);
 
 
109
  }
110
 
111
- foreach ($notices['finalReport'] as $uniqueId => $notice) {
112
- $this->finalReporNotices[$uniqueId] = DUPX_NOTICE_ITEM::getItemFromArray($notice);
 
 
113
  }
114
 
115
  self::$uniqueCountId = $notices['globalData']['uniqueCountId'];
@@ -172,14 +175,15 @@ final class DUPX_NOTICE_MANAGER
172
  * 'label' => link text if empty get external url link
173
  * ]
174
  * ]
175
- * @param int $mode // ADD_NORMAL | ADD_UNIQUE | ADD_UNIQUE_UPDATE
176
- * @param string $uniqueId // used for ADD_UNIQUE or ADD_UNIQUE_UPDATE
177
  *
178
  * @return string // notice insert id
179
  *
180
  * @throws Exception
181
  */
182
- public function addBothNextAndFinalReportNotice($item, $mode = self::ADD_NORMAL, $uniqueId = null) {
 
183
  $this->addNextStepNotice($item, $mode, $uniqueId);
184
  $this->addFinalReportNotice($item, $mode, $uniqueId);
185
  }
@@ -197,8 +201,8 @@ final class DUPX_NOTICE_MANAGER
197
  * 'label' => link text if empty get external url link
198
  * ]
199
  * ]
200
- * @param int $mode // ADD_NORMAL | ADD_UNIQUE | ADD_UNIQUE_UPDATE
201
- * @param string $uniqueId // used for ADD_UNIQUE or ADD_UNIQUE_UPDATE
202
  *
203
  * @return string // notice insert id
204
  *
@@ -217,8 +221,8 @@ final class DUPX_NOTICE_MANAGER
217
  *
218
  * @param string $message
219
  * @param int $level // warning level
220
- * @param int $mode // ADD_NORMAL | ADD_UNIQUE | ADD_UNIQUE_UPDATE
221
- * @param string $uniqueId // used for ADD_UNIQUE or ADD_UNIQUE_UPDATE
222
  *
223
  * @return string // notice insert id
224
  *
@@ -245,8 +249,8 @@ final class DUPX_NOTICE_MANAGER
245
  * 'label' => link text if empty get external url link
246
  * ]
247
  * ]
248
- * @param int $mode // ADD_NORMAL | ADD_UNIQUE | ADD_UNIQUE_UPDATE
249
- * @param string $uniqueId // used for ADD_UNIQUE or ADD_UNIQUE_UPDATE
250
  *
251
  * @return string // notice insert id
252
  *
@@ -266,8 +270,8 @@ final class DUPX_NOTICE_MANAGER
266
  * @param string $message
267
  * @param string|string[] $sections // message sections on final report
268
  * @param int $level // warning level
269
- * @param int $mode // ADD_NORMAL | ADD_UNIQUE | ADD_UNIQUE_UPDATE
270
- * @param string $uniqueId // used for ADD_UNIQUE or ADD_UNIQUE_UPDATE
271
  *
272
  * @return string // notice insert id
273
  *
@@ -296,8 +300,8 @@ final class DUPX_NOTICE_MANAGER
296
  * 'label' => link text if empty get external url link
297
  * ]
298
  * ]
299
- * @param int $mode // ADD_NORMAL | ADD_UNIQUE | ADD_UNIQUE_UPDATE
300
- * @param string $uniqueId // used for ADD_UNIQUE or ADD_UNIQUE_UPDATE
301
  *
302
  * @return string // notice insert id
303
  *
@@ -536,36 +540,48 @@ final class DUPX_NOTICE_MANAGER
536
  */
537
  private static function stepMsg($notice)
538
  {
539
- $classes = array(
540
  'notice',
 
541
  self::getClassFromLevel($notice->level)
542
  );
 
543
  ?>
544
  <div class="<?php echo implode(' ', $classes); ?>">
545
- <p>
 
 
 
 
546
  <?php
547
- echo self::getNextStepLevelPrefixMessage($notice->level).': <b>'.htmlentities($notice->shortMsg).'</b>';
548
  if (!empty($notice->faqLink)) {
549
  ?>
550
- <br>
551
  See FAQ: <a href="<?php echo $notice->faqLink['url']; ?>" >
552
  <b><?php echo htmlentities(empty($notice->faqLink['label']) ? $notice->faqLink['url'] : $notice->faqLink['label']); ?></b>
553
  </a>
554
  <?php
555
  }
 
 
 
556
  if (!empty($notice->longMsg)) {
557
- //Breaks here are messing up the formatting for Serialization notices
558
- //echo '<br><br>';
559
- if ($notice->longMsgHtml) {
560
- echo $notice->longMsg;
561
- } else {
562
- //Do NOT use <pre> tags here or else the formatting is messed up
563
- echo htmlentities($notice->longMsg);
 
 
 
564
  }
565
  }
566
- ?>
567
- </p>
568
- <!--<button type="button" class="notice-dismiss"><span class="screen-reader-text">Nascondi questa notifica.</span></button>-->
 
569
  </div>
570
  <?php
571
  }
@@ -591,9 +607,17 @@ final class DUPX_NOTICE_MANAGER
591
  <div class="title" <?php echo $toggleLinkData; ?>>
592
  <i class="<?php echo $iconClasses; ?>"></i> <?php echo htmlentities($notice->shortMsg); ?>
593
  </div>
594
- <?php if ($haveContent) { ?>
595
- <div class="info <?php echo $notice->open ? '' : 'no-display'; ?>" id="<?php echo $contentId; ?>">
596
- <?php if (!empty($notice->faqLink)) { ?>
 
 
 
 
 
 
 
 
597
  <b>See FAQ</b>: <a href="<?php echo $notice->faqLink['url']; ?>" >
598
  <?php echo htmlentities(empty($notice->faqLink['label']) ? $notice->faqLink['url'] : $notice->faqLink['label']); ?>
599
  </a>
@@ -603,11 +627,16 @@ final class DUPX_NOTICE_MANAGER
603
  echo '<br><br>';
604
  }
605
  if (!empty($notice->longMsg)) {
606
- if ($notice->longMsgHtml) {
607
- echo $notice->longMsg;
608
- } else {
609
- //Do NOT use <pre> tags here or else the formatting is messed up
610
- echo htmlentities($notice->longMsg);
 
 
 
 
 
611
  }
612
  }
613
  ?>
@@ -619,6 +648,56 @@ final class DUPX_NOTICE_MANAGER
619
  <?php
620
  }
621
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
622
  /**
623
  * get html class from level
624
  *
@@ -771,15 +850,91 @@ final class DUPX_NOTICE_MANAGER
771
  </ul>
772
  LONGMSG;
773
  $manager->addNextStepNotice(array(
774
- 'shortMsg' => 'Full elements next step message',
775
  'level' => DUPX_NOTICE_ITEM::HARD_WARNING,
776
  'longMsg' => $longMsg,
777
- 'longMsgHtml' => true,
778
  'faqLink' => array(
779
  'url' => 'http://www.google.it',
780
  'label' => 'google link'
781
  )
782
  ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
783
  $manager->saveNotices();
784
  }
785
 
@@ -824,7 +979,7 @@ LONGMSG;
824
  'shortMsg' => 'Full elements final report message',
825
  'level' => DUPX_NOTICE_ITEM::HARD_WARNING,
826
  'longMsg' => $longMsg,
827
- 'longMsgHtml' => true,
828
  'sections' => $section,
829
  'faqLink' => array(
830
  'url' => 'http://www.google.it',
@@ -836,7 +991,7 @@ LONGMSG;
836
  'shortMsg' => 'Full elements final report message info high priority',
837
  'level' => DUPX_NOTICE_ITEM::INFO,
838
  'longMsg' => $longMsg,
839
- 'longMsgHtml' => true,
840
  'sections' => $section,
841
  'faqLink' => array(
842
  'url' => 'http://www.google.it',
@@ -860,12 +1015,15 @@ LONGMSG;
860
 
861
  class DUPX_NOTICE_ITEM
862
  {
863
- const INFO = 0;
864
- const NOTICE = 1;
865
- const SOFT_WARNING = 2;
866
- const HARD_WARNING = 3;
867
- const CRITICAL = 4;
868
- const FATAL = 5;
 
 
 
869
 
870
  /**
871
  *
@@ -883,7 +1041,7 @@ class DUPX_NOTICE_ITEM
883
  *
884
  * @var bool if true long msg can be html
885
  */
886
- public $longMsgHtml = false;
887
 
888
  /**
889
  *
@@ -931,9 +1089,9 @@ class DUPX_NOTICE_ITEM
931
  * ]
932
  * @param int priority
933
  * @param bool open
934
- * @param bool longMsgHtml
935
  */
936
- public function __construct($shortMsg, $level = self::INFO, $longMsg = '', $sections = array(), $faqLink = null, $priority = 10, $open = false, $longMsgHtml = false)
937
  {
938
  $this->shortMsg = (string) $shortMsg;
939
  $this->level = (int) $level;
@@ -942,7 +1100,7 @@ class DUPX_NOTICE_ITEM
942
  $this->faqLink = $faqLink;
943
  $this->priority = $priority;
944
  $this->open = $open;
945
- $this->longMsgHtml = $longMsgHtml;
946
  }
947
 
948
  /**
@@ -956,6 +1114,9 @@ class DUPX_NOTICE_ITEM
956
  * 'url' => external link
957
  * 'label' => link text if empty get external url link
958
  * ]
 
 
 
959
  * ]
960
  */
961
  public function toArray()
@@ -968,13 +1129,13 @@ class DUPX_NOTICE_ITEM
968
  'faqLink' => $this->faqLink,
969
  'priority' => $this->priority,
970
  'open' => $this->open,
971
- 'longMsgHtml' => $this->longMsgHtml
972
  );
973
  }
974
 
975
  /**
976
  *
977
- * @param array $array [
978
  * 'shortMsg' => text,
979
  * 'level' => level,
980
  * 'longMsg' => html text,
@@ -982,7 +1143,10 @@ class DUPX_NOTICE_ITEM
982
  * 'faqLink' => [
983
  * 'url' => external link
984
  * 'label' => link text if empty get external url link
985
- * ]
 
 
 
986
  * ]
987
  * @return DUPX_NOTICE_ITEM
988
  */
@@ -996,7 +1160,7 @@ class DUPX_NOTICE_ITEM
996
  }
997
  }
998
  $params = array_merge(self::getDefaultArrayParams(), $array);
999
- $result = new self($params['shortMsg'], $params['level'], $params['longMsg'], $params['sections'], $params['faqLink'], $params['priority'], $params['open'], $params['longMsgHtml']);
1000
  return $result;
1001
  }
1002
 
@@ -1013,7 +1177,7 @@ class DUPX_NOTICE_ITEM
1013
  * ],
1014
  * priority
1015
  * open
1016
- * longMsgHtml
1017
  * ]
1018
  */
1019
  public static function getDefaultArrayParams()
@@ -1026,7 +1190,7 @@ class DUPX_NOTICE_ITEM
1026
  'faqLink' => null,
1027
  'priority' => 10,
1028
  'open' => false,
1029
- 'longMsgHtml' => false
1030
  );
1031
  }
1032
 
88
  $notices['finalReport'][$uniqueId] = $notice->toArray();
89
  }
90
 
91
+ file_put_contents($this->persistanceFile, DupLiteSnapLibUtil::wp_json_encode_pprint($notices));
 
92
  }
93
 
94
  /**
103
  $this->nextStepNotices = array();
104
  $this->finalReporNotices = array();
105
 
106
+ if (!empty($notices['nextStep'])) {
107
+ foreach ($notices['nextStep'] as $uniqueId => $notice) {
108
+ $this->nextStepNotices[$uniqueId] = DUPX_NOTICE_ITEM::getItemFromArray($notice);
109
+ }
110
  }
111
 
112
+ if (!empty($notices['finalReport'])) {
113
+ foreach ($notices['finalReport'] as $uniqueId => $notice) {
114
+ $this->finalReporNotices[$uniqueId] = DUPX_NOTICE_ITEM::getItemFromArray($notice);
115
+ }
116
  }
117
 
118
  self::$uniqueCountId = $notices['globalData']['uniqueCountId'];
175
  * 'label' => link text if empty get external url link
176
  * ]
177
  * ]
178
+ * @param int $mode // ADD_NORMAL | ADD_UNIQUE | ADD_UNIQUE_UPDATE | ADD_UNIQUE_APPEND
179
+ * @param string $uniqueId // used for ADD_UNIQUE or ADD_UNIQUE_UPDATE or ADD_UNIQUE_APPEND
180
  *
181
  * @return string // notice insert id
182
  *
183
  * @throws Exception
184
  */
185
+ public function addBothNextAndFinalReportNotice($item, $mode = self::ADD_NORMAL, $uniqueId = null)
186
+ {
187
  $this->addNextStepNotice($item, $mode, $uniqueId);
188
  $this->addFinalReportNotice($item, $mode, $uniqueId);
189
  }
201
  * 'label' => link text if empty get external url link
202
  * ]
203
  * ]
204
+ * @param int $mode // ADD_NORMAL | ADD_UNIQUE | ADD_UNIQUE_UPDATE | ADD_UNIQUE_APPEND
205
+ * @param string $uniqueId // used for ADD_UNIQUE or ADD_UNIQUE_UPDATE or ADD_UNIQUE_APPEND
206
  *
207
  * @return string // notice insert id
208
  *
221
  *
222
  * @param string $message
223
  * @param int $level // warning level
224
+ * @param int $mode // ADD_NORMAL | ADD_UNIQUE | ADD_UNIQUE_UPDATE | ADD_UNIQUE_APPEND
225
+ * @param string $uniqueId // used for ADD_UNIQUE or ADD_UNIQUE_UPDATE or ADD_UNIQUE_APPEND
226
  *
227
  * @return string // notice insert id
228
  *
249
  * 'label' => link text if empty get external url link
250
  * ]
251
  * ]
252
+ * @param int $mode // ADD_NORMAL | ADD_UNIQUE | ADD_UNIQUE_UPDATE | ADD_UNIQUE_APPEND
253
+ * @param string $uniqueId // used for ADD_UNIQUE or ADD_UNIQUE_UPDATE or ADD_UNIQUE_APPEND
254
  *
255
  * @return string // notice insert id
256
  *
270
  * @param string $message
271
  * @param string|string[] $sections // message sections on final report
272
  * @param int $level // warning level
273
+ * @param int $mode // ADD_NORMAL | ADD_UNIQUE | ADD_UNIQUE_UPDATE | ADD_UNIQUE_APPEND
274
+ * @param string $uniqueId // used for ADD_UNIQUE or ADD_UNIQUE_UPDATE or ADD_UNIQUE_APPEND
275
  *
276
  * @return string // notice insert id
277
  *
300
  * 'label' => link text if empty get external url link
301
  * ]
302
  * ]
303
+ * @param int $mode // ADD_NORMAL | ADD_UNIQUE | ADD_UNIQUE_UPDATE | ADD_UNIQUE_APPEND
304
+ * @param string $uniqueId // used for ADD_UNIQUE or ADD_UNIQUE_UPDATE or ADD_UNIQUE_APPEND
305
  *
306
  * @return string // notice insert id
307
  *
540
  */
541
  private static function stepMsg($notice)
542
  {
543
+ $classes = array(
544
  'notice',
545
+ 'next-step',
546
  self::getClassFromLevel($notice->level)
547
  );
548
+ $haveContent = !empty($notice->faqLink) || !empty($notice->longMsg);
549
  ?>
550
  <div class="<?php echo implode(' ', $classes); ?>">
551
+ <div class="title">
552
+ <?php echo self::getNextStepLevelPrefixMessage($notice->level).': <b>'.htmlentities($notice->shortMsg).'</b>'; ?>
553
+ </div>
554
+ <?php if ($haveContent) { ?>
555
+ <div class="title-separator" ></div>
556
  <?php
557
+ ob_start();
558
  if (!empty($notice->faqLink)) {
559
  ?>
 
560
  See FAQ: <a href="<?php echo $notice->faqLink['url']; ?>" >
561
  <b><?php echo htmlentities(empty($notice->faqLink['label']) ? $notice->faqLink['url'] : $notice->faqLink['label']); ?></b>
562
  </a>
563
  <?php
564
  }
565
+ if (!empty($notice->faqLink) && !empty($notice->longMsg)) {
566
+ echo '<br><br>';
567
+ }
568
  if (!empty($notice->longMsg)) {
569
+ switch ($notice->longMsgMode) {
570
+ case DUPX_NOTICE_ITEM::MSG_MODE_PRE:
571
+ echo '<pre>'.htmlentities($notice->longMsg).'</pre>';
572
+ break;
573
+ case DUPX_NOTICE_ITEM::MSG_MODE_HTML:
574
+ echo $notice->longMsg;
575
+ break;
576
+ case DUPX_NOTICE_ITEM::MSG_MODE_DEFAULT:
577
+ default:
578
+ echo htmlentities($notice->longMsg);
579
  }
580
  }
581
+ $longContent = ob_get_clean();
582
+ DUPX_U_Html::getMoreContent($longContent, 'info', 200);
583
+ }
584
+ ?>
585
  </div>
586
  <?php
587
  }
607
  <div class="title" <?php echo $toggleLinkData; ?>>
608
  <i class="<?php echo $iconClasses; ?>"></i> <?php echo htmlentities($notice->shortMsg); ?>
609
  </div>
610
+ <?php
611
+ if ($haveContent) {
612
+ $infoClasses = array('info');
613
+ if (!$notice->open) {
614
+ $infoClasses[] = 'no-display';
615
+ }
616
+ ?>
617
+ <div id="<?php echo $contentId; ?>" class="<?php echo implode(' ', $infoClasses); ?>" >
618
+ <?php
619
+ if (!empty($notice->faqLink)) {
620
+ ?>
621
  <b>See FAQ</b>: <a href="<?php echo $notice->faqLink['url']; ?>" >
622
  <?php echo htmlentities(empty($notice->faqLink['label']) ? $notice->faqLink['url'] : $notice->faqLink['label']); ?>
623
  </a>
627
  echo '<br><br>';
628
  }
629
  if (!empty($notice->longMsg)) {
630
+ switch ($notice->longMsgMode) {
631
+ case DUPX_NOTICE_ITEM::MSG_MODE_PRE:
632
+ echo '<pre>'.htmlentities($notice->longMsg).'</pre>';
633
+ break;
634
+ case DUPX_NOTICE_ITEM::MSG_MODE_HTML:
635
+ echo $notice->longMsg;
636
+ break;
637
+ case DUPX_NOTICE_ITEM::MSG_MODE_DEFAULT:
638
+ default:
639
+ echo htmlentities($notice->longMsg);
640
  }
641
  }
642
  ?>
648
  <?php
649
  }
650
 
651
+ /**
652
+ *
653
+ * @param DUPX_NOTICE_ITEM $notice
654
+ */
655
+ private static function noticeToText($notice)
656
+ {
657
+ $result = '-----------------------'."\n".
658
+ '['.self::getNextStepLevelPrefixMessage($notice->level, false).'] '.$notice->shortMsg;
659
+
660
+ if (!empty($notice->sections)) {
661
+ $result .= "\n\t".'SECTIONS: '.implode(',', $notice->sections);
662
+ }
663
+ if (!empty($notice->longMsg)) {
664
+ $result .= "\n\t".'LONG MSG: '.$notice->longMsg;
665
+ }
666
+ return $result."\n";
667
+ }
668
+
669
+ public function nextStepLog()
670
+ {
671
+ if (!empty($this->nextStepNotices)) {
672
+ DUPX_Log::info(
673
+ '===================================='."\n".
674
+ 'NEXT STEP NOTICES'."\n".
675
+ '====================================');
676
+ foreach ($this->nextStepNotices as $notice) {
677
+ DUPX_Log::info(self::noticeToText($notice));
678
+ }
679
+ DUPX_Log::info(
680
+ '====================================');
681
+ }
682
+ }
683
+
684
+ public function finalReportLog($sections = array())
685
+ {
686
+ if (!empty($this->finalReporNotices)) {
687
+ DUPX_Log::info(
688
+ '===================================='."\n".
689
+ 'FINAL REPORT NOTICES LIST'."\n".
690
+ '====================================');
691
+ foreach ($this->finalReporNotices as $notice) {
692
+ if (count(array_intersect($notice->sections, $sections)) > 0) {
693
+ DUPX_Log::info(self::noticeToText($notice));
694
+ }
695
+ }
696
+ DUPX_Log::info(
697
+ '====================================');
698
+ }
699
+ }
700
+
701
  /**
702
  * get html class from level
703
  *
850
  </ul>
851
  LONGMSG;
852
  $manager->addNextStepNotice(array(
853
+ 'shortMsg' => 'Full elements next step message MODE HTML',
854
  'level' => DUPX_NOTICE_ITEM::HARD_WARNING,
855
  'longMsg' => $longMsg,
856
+ 'longMsgMode' => DUPX_NOTICE_ITEM::MSG_MODE_HTML,
857
  'faqLink' => array(
858
  'url' => 'http://www.google.it',
859
  'label' => 'google link'
860
  )
861
  ));
862
+
863
+ $longMsg = <<<LONGMSG
864
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc a auctor erat, et lobortis libero.
865
+ Suspendisse aliquet neque in massa posuere mollis. Donec venenatis finibus sapien in bibendum. Donec et ex massa.
866
+
867
+ Aliquam venenatis dapibus tellus nec ullamcorper. Mauris ante velit, tincidunt sit amet egestas et, mattis non lorem. In semper ex ut velit suscipit,
868
+ at luctus nunc dapibus. Etiam blandit maximus dapibus. Nullam eu porttitor augue. Suspendisse pulvinar, massa eget condimentum aliquet, dolor massa tempus dui, vel rhoncus tellus ligula non odio.
869
+ Ut ac faucibus tellus, in lobortis odio.
870
+ LONGMSG;
871
+ $manager->addNextStepNotice(array(
872
+ 'shortMsg' => 'Full elements next step message MODE PRE',
873
+ 'level' => DUPX_NOTICE_ITEM::HARD_WARNING,
874
+ 'longMsg' => $longMsg,
875
+ 'longMsgMode' => DUPX_NOTICE_ITEM::MSG_MODE_PRE,
876
+ 'faqLink' => array(
877
+ 'url' => 'http://www.google.it',
878
+ 'label' => 'google link'
879
+ )
880
+ ));
881
+
882
+ $longMsg = <<<LONGMSG
883
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc a auctor erat, et lobortis libero.
884
+ Suspendisse aliquet neque in massa posuere mollis. Donec venenatis finibus sapien in bibendum. Donec et ex massa.
885
+
886
+ Aliquam venenatis dapibus tellus nec ullamcorper. Mauris ante velit, tincidunt sit amet egestas et, mattis non lorem. In semper ex ut velit suscipit,
887
+ at luctus nunc dapibus. Etiam blandit maximus dapibus. Nullam eu porttitor augue. Suspendisse pulvinar, massa eget condimentum aliquet, dolor massa tempus dui, vel rhoncus tellus ligula non odio.
888
+ Ut ac faucibus tellus, in lobortis odio.
889
+ LONGMSG;
890
+ $manager->addNextStepNotice(array(
891
+ 'shortMsg' => 'Full elements next step message MODE DEFAULT',
892
+ 'level' => DUPX_NOTICE_ITEM::HARD_WARNING,
893
+ 'longMsg' => $longMsg,
894
+ 'longMsgMode' => DUPX_NOTICE_ITEM::MSG_MODE_DEFAULT,
895
+ 'faqLink' => array(
896
+ 'url' => 'http://www.google.it',
897
+ 'label' => 'google link'
898
+ )
899
+ ));
900
+
901
+
902
+ $longMsg = <<<LONGMSG
903
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam cursus porttitor consectetur. Nunc faucibus elementum nisl nec ornare. Phasellus sit amet urna in diam ultricies ornare nec sit amet nibh. Nulla a aliquet leo. Quisque aliquet posuere lectus sit amet commodo. Nullam tempus enim eget urna rutrum egestas. Aliquam eget lorem nisl. Nulla tincidunt massa erat. Phasellus lectus tellus, mollis sit amet aliquam in, dapibus quis metus. Nunc venenatis nulla vitae convallis accumsan.
904
+
905
+ Mauris eu ullamcorper metus. Aenean ultricies et turpis eget mollis. Aliquam auctor, elit scelerisque placerat pellentesque, quam augue fermentum lectus, vel pretium nisi justo sit amet ante. Donec blandit porttitor tempus. Duis vulputate nulla ut orci rutrum, et consectetur urna mollis. Sed at iaculis velit. Pellentesque id quam turpis. Curabitur eu ligula velit. Cras gravida, ipsum sed iaculis eleifend, mauris nunc posuere quam, vel blandit nisi justo congue ligula. Phasellus aliquam eu odio ac porttitor. Fusce dictum mollis turpis sit amet fringilla.
906
+
907
+ Nulla eu ligula mauris. Fusce lobortis ligula elit, a interdum nibh pulvinar eu. Pellentesque rhoncus nec turpis id blandit. Morbi fringilla, justo non varius consequat, arcu ante efficitur ante, sit amet cursus lorem elit vel odio. Phasellus neque ligula, vehicula vel ipsum sed, volutpat dignissim eros. Curabitur at lacus id felis elementum auctor. Nullam ac tempus nisi. Phasellus nibh purus, aliquam nec purus ut, sodales lobortis nulla. Cras viverra dictum magna, ac malesuada nibh dictum ac. Mauris euismod, magna sit amet pretium posuere, ligula nibh ultrices tellus, sit amet pretium odio urna egestas justo. Suspendisse purus erat, eleifend sed magna in, efficitur interdum nibh.
908
+
909
+ Vivamus nibh nunc, fermentum non tortor volutpat, consectetur vulputate velit. Phasellus lobortis, purus et faucibus mollis, metus eros viverra ante, sit amet euismod nibh est eu orci. Duis sodales cursus lacinia. Praesent laoreet ut ipsum ut interdum. Praesent venenatis massa vitae ligula consequat aliquet. Fusce in purus in odio molestie laoreet at ac augue. Fusce consectetur elit a magna mollis aliquet.
910
+
911
+ Nulla eros nisi, dapibus eget diam vitae, tincidunt blandit odio. Fusce interdum tellus nec varius condimentum. Fusce non magna a purus sodales imperdiet sit amet vitae ligula. Quisque viverra leo sit amet mi egestas, et posuere nunc tincidunt. Suspendisse feugiat malesuada urna sed tincidunt. Morbi a urna sed magna volutpat pellentesque sit amet ac mauris. Nulla sed ultrices dui. Etiam massa arcu, tempor ut erat at, cursus malesuada ipsum. Duis sit amet felis dolor.
912
+
913
+ Morbi gravida nisl nunc, vulputate iaculis risus vehicula non. Proin cursus, velit et laoreet consectetur, lacus libero sagittis lacus, quis accumsan odio lectus non erat. Aenean dolor lectus, euismod sit amet justo eget, dictum gravida nisl. Phasellus sed nunc non odio ullamcorper rhoncus non ut ipsum. Duis ante ligula, pellentesque sit amet imperdiet eget, congue vel dui. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nulla facilisi. Suspendisse luctus leo eget justo mollis, convallis convallis ex suscipit. Integer et justo eget odio lobortis sollicitudin. Pellentesque accumsan rhoncus augue, luctus suscipit ex accumsan nec. Maecenas lacinia consectetur risus at bibendum. Etiam venenatis purus lorem, sit amet elementum turpis tristique eu. Proin vulputate faucibus feugiat. Nunc vehicula congue odio consequat vulputate. Quisque bibendum augue id iaculis faucibus. Donec blandit cursus sem, eget accumsan orci commodo sed.
914
+
915
+ Suspendisse iaculis est quam, sed scelerisque purus tincidunt non. Cras hendrerit ante turpis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse purus ipsum, rutrum id sem in, venenatis laoreet metus. Aliquam ac bibendum mauris. Cras egestas rhoncus est, sed lacinia nibh vestibulum id. Proin diam quam, sagittis congue molestie ac, rhoncus et mauris. Phasellus massa neque, ornare vel erat a, rutrum pharetra arcu. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Morbi et nulla eget massa auctor fermentum. Quisque maximus tellus sed cursus cursus. Ut vehicula erat at purus aliquet, quis imperdiet dui sagittis. Nullam eget quam leo.
916
+
917
+ Nulla magna ipsum, congue nec dui ut, lacinia malesuada felis. Cras mattis metus non maximus venenatis. Aliquam euismod est vitae erat sollicitudin, at pellentesque augue sollicitudin. Curabitur euismod maximus cursus. In tortor dui, convallis sed sapien ac, varius congue metus. Nunc ullamcorper ac orci sit amet finibus. Vivamus molestie nibh vitae quam rhoncus, eu ultrices est molestie. Maecenas consectetur eu quam sit amet placerat.
918
+
919
+ Curabitur ut fermentum mauris. Donec et congue nibh. Sed cursus elit sit amet convallis varius. Donec malesuada porta odio condimentum varius. Pellentesque ornare tempor ante, ut volutpat nulla lobortis sed. Nunc congue aliquet erat ac elementum. Quisque a ex sit amet turpis placerat sagittis eget ac ligula. Etiam in augue malesuada, aliquam est non, lacinia justo. Vivamus tincidunt dolor orci, id dignissim lorem maximus at. Vivamus ligula mauris, venenatis vel nibh id, lacinia ultrices ipsum. Mauris cursus, urna ac rutrum aliquet, risus ipsum tincidunt purus, sit amet blandit nunc sem sit amet nibh.
920
+
921
+ Nam eleifend risus lacus, eu pharetra risus egestas eu. Maecenas hendrerit nisl in semper placerat. Vestibulum massa tellus, laoreet non euismod quis, sollicitudin id sapien. Morbi vel cursus metus. Aenean tincidunt nisi est, ut elementum est auctor id. Duis auctor elit leo, ac scelerisque risus suscipit et. Pellentesque lectus nisi, ultricies in elit sed, pulvinar iaculis massa. Morbi viverra eros mi, pretium facilisis neque egestas id. Curabitur non massa accumsan, porttitor sem vitae, ultricies lacus. Curabitur blandit nisl velit. Mauris sollicitudin ultricies purus sit amet placerat. Fusce ac neque sed leo venenatis laoreet ut non ex. Integer elementum rhoncus orci, eu maximus neque tempus eu. Curabitur euismod dignissim tellus, vitae lacinia metus. Mauris imperdiet metus vitae vulputate accumsan. Duis eget luctus nibh, sit amet finibus libero.
922
+
923
+ LONGMSG;
924
+ $manager->addNextStepNotice(array(
925
+ 'shortMsg' => 'Full elements LONG LONG',
926
+ 'level' => DUPX_NOTICE_ITEM::HARD_WARNING,
927
+ 'longMsg' => $longMsg,
928
+ 'longMsgMode' => DUPX_NOTICE_ITEM::MSG_MODE_DEFAULT,
929
+ 'faqLink' => array(
930
+ 'url' => 'http://www.google.it',
931
+ 'label' => 'google link'
932
+ )
933
+ ));
934
+
935
+
936
+
937
+
938
  $manager->saveNotices();
939
  }
940
 
979
  'shortMsg' => 'Full elements final report message',
980
  'level' => DUPX_NOTICE_ITEM::HARD_WARNING,
981
  'longMsg' => $longMsg,
982
+ 'longMsgMode' => DUPX_NOTICE_ITEM::MSG_MODE_HTML,
983
  'sections' => $section,
984
  'faqLink' => array(
985
  'url' => 'http://www.google.it',
991
  'shortMsg' => 'Full elements final report message info high priority',
992
  'level' => DUPX_NOTICE_ITEM::INFO,
993
  'longMsg' => $longMsg,
994
+ 'longMsgMode' => DUPX_NOTICE_ITEM::MSG_MODE_HTML,
995
  'sections' => $section,
996
  'faqLink' => array(
997
  'url' => 'http://www.google.it',
1015
 
1016
  class DUPX_NOTICE_ITEM
1017
  {
1018
+ const INFO = 0;
1019
+ const NOTICE = 1;
1020
+ const SOFT_WARNING = 2;
1021
+ const HARD_WARNING = 3;
1022
+ const CRITICAL = 4;
1023
+ const FATAL = 5;
1024
+ const MSG_MODE_DEFAULT = 'def';
1025
+ const MSG_MODE_HTML = 'html';
1026
+ const MSG_MODE_PRE = 'pre';
1027
 
1028
  /**
1029
  *
1041
  *
1042
  * @var bool if true long msg can be html
1043
  */
1044
+ public $longMsgMode = self::MSG_MODE_DEFAULT;
1045
 
1046
  /**
1047
  *
1089
  * ]
1090
  * @param int priority
1091
  * @param bool open
1092
+ * @param string longMsgMode MSG_MODE_DEFAULT | MSG_MODE_HTML | MSG_MODE_PRE
1093
  */
1094
+ public function __construct($shortMsg, $level = self::INFO, $longMsg = '', $sections = array(), $faqLink = null, $priority = 10, $open = false, $longMsgMode = self::MSG_MODE_DEFAULT)
1095
  {
1096
  $this->shortMsg = (string) $shortMsg;
1097
  $this->level = (int) $level;
1100
  $this->faqLink = $faqLink;
1101
  $this->priority = $priority;
1102
  $this->open = $open;
1103
+ $this->longMsgMode = $longMsgMode;
1104
  }
1105
 
1106
  /**
1114
  * 'url' => external link
1115
  * 'label' => link text if empty get external url link
1116
  * ]
1117
+ * 'priority' => int low first
1118
+ * 'open' => if true the tab is opene on final report
1119
+ * 'longMsgMode'=> MSG_MODE_DEFAULT | MSG_MODE_HTML | MSG_MODE_PRE
1120
  * ]
1121
  */
1122
  public function toArray()
1129
  'faqLink' => $this->faqLink,
1130
  'priority' => $this->priority,
1131
  'open' => $this->open,
1132
+ 'longMsgMode' => $this->longMsgMode
1133
  );
1134
  }
1135
 
1136
  /**
1137
  *
1138
+ * @return array [
1139
  * 'shortMsg' => text,
1140
  * 'level' => level,
1141
  * 'longMsg' => html text,
1143
  * 'faqLink' => [
1144
  * 'url' => external link
1145
  * 'label' => link text if empty get external url link
1146
+ * ],
1147
+ * priority
1148
+ * open
1149
+ * longMsgMode
1150
  * ]
1151
  * @return DUPX_NOTICE_ITEM
1152
  */
1160
  }
1161
  }
1162
  $params = array_merge(self::getDefaultArrayParams(), $array);
1163
+ $result = new self($params['shortMsg'], $params['level'], $params['longMsg'], $params['sections'], $params['faqLink'], $params['priority'], $params['open'], $params['longMsgMode']);
1164
  return $result;
1165
  }
1166
 
1177
  * ],
1178
  * priority
1179
  * open
1180
+ * longMsgMode
1181
  * ]
1182
  */
1183
  public static function getDefaultArrayParams()
1190
  'faqLink' => null,
1191
  'priority' => 10,
1192
  'open' => false,
1193
+ 'longMsgMode' => self::MSG_MODE_DEFAULT
1194
  );
1195
  }
1196
 
installer/dup-installer/classes/utilities/class.u.php CHANGED
@@ -46,8 +46,8 @@ class DUPX_U
46
  {
47
  array_push($GLOBALS['REPLACE_LIST'], array('search' => $search, 'replace' => $replace));
48
 
49
- $search_json = str_replace('"', "", json_encode($search));
50
- $replace_json = str_replace('"', "", json_encode($replace));
51
 
52
  if ($search != $search_json) {
53
  array_push($GLOBALS['REPLACE_LIST'], array('search' => $search_json, 'replace' => $replace_json));
@@ -163,7 +163,7 @@ class DUPX_U
163
  if (function_exists('get_headers')) {
164
  $url = is_integer($port) ? $url . ':' . $port : $url;
165
  DUPX_Handler::setMode(DUPX_Handler::MODE_OFF);
166
- if (SnapLibUtil::wp_is_ini_value_changeable('default_socket_timeout')) {
167
  @ini_set("default_socket_timeout", $timeout);
168
  }
169
  $headers = @get_headers($url);
@@ -173,7 +173,7 @@ class DUPX_U
173
  }
174
  } else {
175
  if (function_exists('fsockopen')) {
176
- if (SnapLibUtil::wp_is_ini_value_changeable('default_socket_timeout')) {
177
  @ini_set("default_socket_timeout", $timeout);
178
  }
179
  $port = isset($port) && is_integer($port) ? $port : 80;
@@ -1770,7 +1770,7 @@ class DUPX_U
1770
  */
1771
  public static function getEscapedGenericString($str, $addQuote = true)
1772
  {
1773
- $result = SnapLibUtil::wp_json_encode(trim($str));
1774
  $result = str_replace(array('\/', '$'), array('/', '\\$'), $result);
1775
  $result = preg_replace_callback(
1776
  '/\\\\u[a-fA-F0-9]{4}/m', array(__CLASS__, 'encodeUtf8CharFromRegexMatch'), $result
46
  {
47
  array_push($GLOBALS['REPLACE_LIST'], array('search' => $search, 'replace' => $replace));
48
 
49
+ $search_json = str_replace('"', "", DupLiteSnapLibUtil::wp_json_encode($search));
50
+ $replace_json = str_replace('"', "", DupLiteSnapLibUtil::wp_json_encode($replace));
51
 
52
  if ($search != $search_json) {
53
  array_push($GLOBALS['REPLACE_LIST'], array('search' => $search_json, 'replace' => $replace_json));
163
  if (function_exists('get_headers')) {
164
  $url = is_integer($port) ? $url . ':' . $port : $url;
165
  DUPX_Handler::setMode(DUPX_Handler::MODE_OFF);
166
+ if (DupLiteSnapLibUtil::wp_is_ini_value_changeable('default_socket_timeout')) {
167
  @ini_set("default_socket_timeout", $timeout);
168
  }
169
  $headers = @get_headers($url);
173
  }
174
  } else {
175
  if (function_exists('fsockopen')) {
176
+ if (DupLiteSnapLibUtil::wp_is_ini_value_changeable('default_socket_timeout')) {
177
  @ini_set("default_socket_timeout", $timeout);
178
  }
179
  $port = isset($port) && is_integer($port) ? $port : 80;
1770
  */
1771
  public static function getEscapedGenericString($str, $addQuote = true)
1772
  {
1773
+ $result = DupLiteSnapLibUtil::wp_json_encode(trim($str));
1774
  $result = str_replace(array('\/', '$'), array('/', '\\$'), $result);
1775
  $result = preg_replace_callback(
1776
  '/\\\\u[a-fA-F0-9]{4}/m', array(__CLASS__, 'encodeUtf8CharFromRegexMatch'), $result
installer/dup-installer/ctrls/ctrl.s1.php CHANGED
@@ -64,7 +64,7 @@ if (! $GLOBALS['DUPX_AC']->exportOnlyDB) {
64
  }
65
 
66
  //ERR_ZIPMANUAL
67
- if ('ziparchive' == $post_archive_engine && !$GLOBALS['DUPX_AC']->installSiteOverwriteOn) {
68
  //ERR_CONFIG_FOUND
69
  $outer_root_path = dirname($root_path);
70
 
@@ -207,57 +207,66 @@ switch ($post_archive_engine) {
207
 
208
  try {
209
  if (!$zip->extractTo($target , $extract_filename)) {
210
- DUPX_Log::info("FILE EXTRACION ERROR: ".$extract_filename);
211
- if (SnapLibUtilWp::isWpCore($extract_filename, SnapLibUtilWp::PATH_RELATIVE)) {
212
- $shortMsg = 'Can\'t extract wp core file: '.$extract_filename;
213
- $finalShortMsg = 'Wp core file '.$extract_filename.' not extracted';
214
  $errLevel = DUPX_NOTICE_ITEM::CRITICAL;
 
215
  } else {
216
- $shortMsg = 'Can\'t extract file: '.$extract_filename;
217
- $finalShortMsg = 'File '.$extract_filename.' not extracted';
 
218
  $errLevel = DUPX_NOTICE_ITEM::SOFT_WARNING;
 
219
  }
220
- $longMsg = DUPX_Handler::getVarLogClean();
221
 
222
  $nManager->addNextStepNotice(array(
223
  'shortMsg' => $shortMsg,
224
  'longMsg' => $longMsg,
 
225
  'level' => $errLevel
226
- ));
227
  $nManager->addFinalReportNotice(array(
228
  'shortMsg' => $finalShortMsg,
229
  'longMsg' => $longMsg,
 
230
  'level' => $errLevel,
231
  'sections' => array('files'),
232
- ));
233
  } else {
234
  DUPX_Log::info("DONE: ".$extract_filename,2);
235
  }
236
  } catch (Exception $ex) {
237
- DUPX_Log::info("FILE EXTRACION ERROR: {$extract_filename} | MSG:".$ex->getMessage());
238
-
239
- if (SnapLibUtilWp::isWpCore($extract_filename, SnapLibUtilWp::PATH_RELATIVE)) {
240
- $shortMsg = 'Can\'t extract wp core file: '.$extract_filename;
241
- $finalShortMsg = 'Wp core file '.$extract_filename.' not extracted';
242
  $errLevel = DUPX_NOTICE_ITEM::CRITICAL;
 
243
  } else {
244
- $shortMsg = 'Can\'t extract file: '.$extract_filename;
245
- $finalShortMsg = 'File '.$extract_filename.' not extracted';
 
246
  $errLevel = DUPX_NOTICE_ITEM::SOFT_WARNING;
 
247
  }
248
- $longMsg = $ex->getMessage();
249
 
250
  $nManager->addNextStepNotice(array(
251
  'shortMsg' => $shortMsg,
252
  'longMsg' => $longMsg,
 
253
  'level' => $errLevel
254
- ));
255
  $nManager->addFinalReportNotice(array(
256
  'shortMsg' => $finalShortMsg,
257
  'longMsg' => $longMsg,
 
258
  'level' => $errLevel,
259
  'sections' => array('files'),
260
- ));
261
  }
262
  }
263
 
@@ -404,4 +413,4 @@ DUPX_Log::info("\nSTEP-1 COMPLETE @ " . @date('h:i:s') . " - RUNTIME: {$ajax1_su
404
  $JSON['pass'] = 1;
405
  error_reporting($ajax1_error_level);
406
  fclose($GLOBALS["LOG_FILE_HANDLE"]);
407
- die(json_encode($JSON));
64
  }
65
 
66
  //ERR_ZIPMANUAL
67
+ if (('ziparchive' == $post_archive_engine || 'shellexec_unzip' == $post_archive_engine) && !$GLOBALS['DUPX_AC']->installSiteOverwriteOn) {
68
  //ERR_CONFIG_FOUND
69
  $outer_root_path = dirname($root_path);
70
 
207
 
208
  try {
209
  if (!$zip->extractTo($target , $extract_filename)) {
210
+ if (DupLiteSnapLibUtilWp::isWpCore($extract_filename, DupLiteSnapLibUtilWp::PATH_RELATIVE)) {
211
+ DUPX_Log::info("FILE CORE EXTRACION ERROR: ".$extract_filename);
212
+ $shortMsg = 'Can\'t extract wp core files';
213
+ $finalShortMsg = 'Wp core files not extracted';
214
  $errLevel = DUPX_NOTICE_ITEM::CRITICAL;
215
+ $idManager = 'wp-extract-error-file-core';
216
  } else {
217
+ DUPX_Log::info("FILE EXTRACION ERROR: ".$extract_filename);
218
+ $shortMsg = 'Can\'t extract files';
219
+ $finalShortMsg = 'Files not extracted';
220
  $errLevel = DUPX_NOTICE_ITEM::SOFT_WARNING;
221
+ $idManager = 'wp-extract-error-file-no-core';
222
  }
223
+ $longMsg = 'FILE: <b>'.htmlspecialchars($extract_filename).'</b><br>Message: '.htmlspecialchars(DUPX_Handler::getVarLogClean()).'<br><br>';
224
 
225
  $nManager->addNextStepNotice(array(
226
  'shortMsg' => $shortMsg,
227
  'longMsg' => $longMsg,
228
+ 'longMsgMode' => DUPX_NOTICE_ITEM::MSG_MODE_HTML,
229
  'level' => $errLevel
230
+ ), DUPX_NOTICE_MANAGER::ADD_UNIQUE_APPEND, $idManager);
231
  $nManager->addFinalReportNotice(array(
232
  'shortMsg' => $finalShortMsg,
233
  'longMsg' => $longMsg,
234
+ 'longMsgMode' => DUPX_NOTICE_ITEM::MSG_MODE_HTML,
235
  'level' => $errLevel,
236
  'sections' => array('files'),
237
+ ), DUPX_NOTICE_MANAGER::ADD_UNIQUE_APPEND, $idManager);
238
  } else {
239
  DUPX_Log::info("DONE: ".$extract_filename,2);
240
  }
241
  } catch (Exception $ex) {
242
+ if (DupLiteSnapLibUtilWp::isWpCore($extract_filename, DupLiteSnapLibUtilWp::PATH_RELATIVE)) {
243
+ DUPX_Log::info("FILE CORE EXTRACION ERROR: {$extract_filename} | MSG:".$ex->getMessage());
244
+ $shortMsg = 'Can\'t extract wp core files';
245
+ $finalShortMsg = 'Wp core files not extracted';
 
246
  $errLevel = DUPX_NOTICE_ITEM::CRITICAL;
247
+ $idManager = 'wp-extract-error-file-core';
248
  } else {
249
+ DUPX_Log::info("FILE EXTRACION ERROR: {$extract_filename} | MSG:".$ex->getMessage());
250
+ $shortMsg = 'Can\'t extract files';
251
+ $finalShortMsg = 'Files not extracted';
252
  $errLevel = DUPX_NOTICE_ITEM::SOFT_WARNING;
253
+ $idManager = 'wp-extract-error-file-no-core';
254
  }
255
+ $longMsg = 'FILE: <b>'.htmlspecialchars($extract_filename).'</b><br>Message: '.htmlspecialchars($ex->getMessage()).'<br><br>';
256
 
257
  $nManager->addNextStepNotice(array(
258
  'shortMsg' => $shortMsg,
259
  'longMsg' => $longMsg,
260
+ 'longMsgMode' => DUPX_NOTICE_ITEM::MSG_MODE_HTML,
261
  'level' => $errLevel
262
+ ), DUPX_NOTICE_MANAGER::ADD_UNIQUE_APPEND, $idManager);
263
  $nManager->addFinalReportNotice(array(
264
  'shortMsg' => $finalShortMsg,
265
  'longMsg' => $longMsg,
266
+ 'longMsgMode' => DUPX_NOTICE_ITEM::MSG_MODE_HTML,
267
  'level' => $errLevel,
268
  'sections' => array('files'),
269
+ ), DUPX_NOTICE_MANAGER::ADD_UNIQUE_APPEND, $idManager);
270
  }
271
  }
272
 
413
  $JSON['pass'] = 1;
414
  error_reporting($ajax1_error_level);
415
  fclose($GLOBALS["LOG_FILE_HANDLE"]);
416
+ die(DupLiteSnapLibUtil::wp_json_encode($JSON));
installer/dup-installer/ctrls/ctrl.s2.base.php CHANGED
@@ -172,4 +172,4 @@ DUPX_Log::info("\nINSERT DATA RUNTIME: " . DUPX_U::elapsedTime($dbinstall->profi
172
  DUPX_Log::info('STEP-2 COMPLETE @ '.@date('h:i:s')." - RUNTIME: {$ajax1_sum}");
173
 
174
  error_reporting($ajax2_error_level);
175
- die(json_encode($JSON));
172
  DUPX_Log::info('STEP-2 COMPLETE @ '.@date('h:i:s')." - RUNTIME: {$ajax1_sum}");
173
 
174
  error_reporting($ajax2_error_level);
175
+ die(DupLiteSnapLibUtil::wp_json_encode($JSON));
installer/dup-installer/ctrls/ctrl.s2.dbtest.php CHANGED
@@ -68,7 +68,7 @@ class DUPX_DBTest
68
  $this->ac = DUPX_ArchiveConfig::getInstance();
69
 
70
  //REQUIRMENTS
71
- //Pass States: skipped = -1 failed = 0 passed = 1
72
  $this->reqs[5] = array('title' => "Create Database User", 'info' => "{$default_msg}", 'pass' => -1);
73
  $this->reqs[10] = array('title' => "Verify Host Connection", 'info' => "{$default_msg}", 'pass' => -1);
74
  $this->reqs[20] = array('title' => "Check Server Version", 'info' => "{$default_msg}", 'pass' => -1);
@@ -76,7 +76,8 @@ class DUPX_DBTest
76
  $this->reqs[40] = array('title' => "Confirm Database Visibility", 'info' => "{$default_msg}", 'pass' => -1);
77
  $this->reqs[50] = array('title' => "Manual Table Check", 'info' => "{$default_msg}", 'pass' => -1);
78
  $this->reqs[60] = array('title' => "Test User Table Privileges", 'info' => "{$default_msg}", 'pass' => -1);
79
- $this->reqs[70] = array('title' => "Check Collation Capability", 'info' => "{$default_msg}", 'pass' => -1);
 
80
  //NOTICES
81
  $this->notices[10] = array('title' => "Table Case Sensitivity", 'info' => "{$default_msg}", 'pass' => -1);
82
  }
@@ -99,7 +100,7 @@ class DUPX_DBTest
99
  $result = $this->out;
100
  return $result;
101
  } elseif ($this->responseMode == 'JSON') {
102
- $result = json_encode($this->out);
103
  return $result;
104
  } else {
105
  die('Please specific the responseMode property');
@@ -143,6 +144,7 @@ class DUPX_DBTest
143
  //NOTICES
144
  $this->n10All($this->notices[10]);
145
  $this->r70All($this->reqs[70]);
 
146
  $this->basicCleanup();
147
  }
148
 
@@ -449,6 +451,48 @@ class DUPX_DBTest
449
 
450
  }
451
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
452
  /**
453
  * Table Case Compatibility
454
  *
@@ -692,6 +736,15 @@ class DUPX_DBTest
692
  }
693
  }
694
 
 
 
 
 
 
 
 
 
 
695
  //Only show notice summary if a test was ran
696
  foreach ($this->notices as $key => $value) {
697
  if ($this->notices[$key]['pass'] == 0) {
68
  $this->ac = DUPX_ArchiveConfig::getInstance();
69
 
70
  //REQUIRMENTS
71
+ //Pass States: skipped = -1 failed = 0 passed = 1 warned = 2
72
  $this->reqs[5] = array('title' => "Create Database User", 'info' => "{$default_msg}", 'pass' => -1);
73
  $this->reqs[10] = array('title' => "Verify Host Connection", 'info' => "{$default_msg}", 'pass' => -1);
74
  $this->reqs[20] = array('title' => "Check Server Version", 'info' => "{$default_msg}", 'pass' => -1);
76
  $this->reqs[40] = array('title' => "Confirm Database Visibility", 'info' => "{$default_msg}", 'pass' => -1);
77
  $this->reqs[50] = array('title' => "Manual Table Check", 'info' => "{$default_msg}", 'pass' => -1);
78
  $this->reqs[60] = array('title' => "Test User Table Privileges", 'info' => "{$default_msg}", 'pass' => -1);
79
+ $this->reqs[70] = array('title' => "Check Collation Capability", 'info' => "{$default_msg}", 'pass' => -1);
80
+ $this->reqs[80] = array('title' => "Check GTID mode", 'info' => "{$default_msg}", 'pass' => -1);
81
  //NOTICES
82
  $this->notices[10] = array('title' => "Table Case Sensitivity", 'info' => "{$default_msg}", 'pass' => -1);
83
  }
100
  $result = $this->out;
101
  return $result;
102
  } elseif ($this->responseMode == 'JSON') {
103
+ $result = DupLiteSnapLibUtil::wp_json_encode($this->out);
104
  return $result;
105
  } else {
106
  die('Please specific the responseMode property');
144
  //NOTICES
145
  $this->n10All($this->notices[10]);
146
  $this->r70All($this->reqs[70]);
147
+ $this->r80All($this->reqs[80]);
148
  $this->basicCleanup();
149
  }
150
 
451
 
452
  }
453
 
454
+ /**
455
+ * Check GTID mode
456
+ *
457
+ * @return null
458
+ */
459
+ private function r80All(&$test)
460
+ {
461
+ try {
462
+ if ($this->isFailedState($test)) {
463
+ return;
464
+ }
465
+
466
+ $gtid_mode_enabled = false;
467
+ $query = "SELECT @@GLOBAL.GTID_MODE";
468
+ $result = mysqli_query($this->dbh, $query);
469
+
470
+ if ($result = mysqli_query($this->dbh, $query)) {
471
+ if ($row = mysqli_fetch_array($result, MYSQLI_NUM)) {
472
+ if ('ON' == $row[0] || 'on' == $row[0])
473
+ $gtid_mode_enabled = true;
474
+ }
475
+ }
476
+
477
+ // $gtid_mode_enabled = true;
478
+ if ($gtid_mode_enabled) {
479
+ $test['pass'] = 2;
480
+ $test['info'] = "Your database server have GTID mode is on, It might make a trouble in Database installation.<br/>"
481
+ . "<small>Details: You might face the error something like Statement violates GTID consistency. "
482
+ . "You should ask hosting provider to make off GTID off. "
483
+ . "You can make off GTID mode as decribed in the <a href='https://dev.mysql.com/doc/refman/5.7/en/replication-mode-change-online-disable-gtids.html' target='_blank'>https://dev.mysql.com/doc/refman/5.7/en/replication-mode-change-online-disable-gtids.html</a>"
484
+ . "</small>";
485
+ } else {
486
+ $test['pass'] = 1;
487
+ $test['info'] = "The installer have not detected GTID mode.";
488
+ }
489
+ } catch (Exception $ex) {
490
+ //Return '1' to allow user to continue
491
+ $test['pass'] = 1;
492
+ $test['info'] = "Failure in attempt to check GTID mode status.<br/>" . $this->formatError($ex);
493
+ }
494
+ }
495
+
496
  /**
497
  * Table Case Compatibility
498
  *
736
  }
737
  }
738
 
739
+ if (1 == $req_status) {
740
+ foreach ($this->reqs as $key => $value) {
741
+ if ($this->reqs[$key]['pass'] == 2) {
742
+ $req_status = 2;
743
+ break;
744
+ }
745
+ }
746
+ }
747
+
748
  //Only show notice summary if a test was ran
749
  foreach ($this->notices as $key => $value) {
750
  if ($this->notices[$key]['pass'] == 0) {
installer/dup-installer/ctrls/ctrl.s3.php CHANGED
@@ -488,7 +488,7 @@ LONGMSG;
488
  'shortMsg' => $shortMsg,
489
  'level' => DUPX_NOTICE_ITEM::HARD_WARNING,
490
  'longMsg' => $longMsg,
491
- 'longMsgHtml' => true,
492
  'sections' => 'general'
493
  ), DUPX_NOTICE_MANAGER::ADD_UNIQUE , 'wp-config-transformer-exception');
494
 
@@ -508,7 +508,7 @@ LONGMSG;
508
  'shortMsg' => $shortMsg,
509
  'level' => DUPX_NOTICE_ITEM::CRITICAL,
510
  'longMsg' => $longMsg,
511
- 'longMsgHtml' => true,
512
  'sections' => 'general'
513
  ), DUPX_NOTICE_MANAGER::ADD_UNIQUE , 'wp-config-transformer-exception');
514
  }
@@ -597,7 +597,7 @@ if (file_exists($wpconfig_ark_path)) {
597
  'shortMsg' => 'wp-config not found',
598
  'level' => DUPX_NOTICE_ITEM::HARD_WARNING,
599
  'longMsg' => $msg,
600
- 'longMsgHtml' => true,
601
  'sections' => 'general'
602
  ), DUPX_NOTICE_MANAGER::ADD_UNIQUE_UPDATE , 'wp-config-not-found');
603
 
@@ -668,4 +668,4 @@ DUPX_Log::info("\nSTEP-3 COMPLETE @ ".@date('h:i:s')." - RUNTIME: {$ajax3_sum} \
668
 
669
  $JSON['step3']['pass'] = 1;
670
  error_reporting($ajax3_error_level);
671
- die(json_encode($JSON));
488
  'shortMsg' => $shortMsg,
489
  'level' => DUPX_NOTICE_ITEM::HARD_WARNING,
490
  'longMsg' => $longMsg,
491
+ 'longMsgMode'=> DUPX_NOTICE_ITEM::MSG_MODE_HTML,
492
  'sections' => 'general'
493
  ), DUPX_NOTICE_MANAGER::ADD_UNIQUE , 'wp-config-transformer-exception');
494
 
508
  'shortMsg' => $shortMsg,
509
  'level' => DUPX_NOTICE_ITEM::CRITICAL,
510
  'longMsg' => $longMsg,
511
+ 'longMsgMode'=> DUPX_NOTICE_ITEM::MSG_MODE_HTML,
512
  'sections' => 'general'
513
  ), DUPX_NOTICE_MANAGER::ADD_UNIQUE , 'wp-config-transformer-exception');
514
  }
597
  'shortMsg' => 'wp-config not found',
598
  'level' => DUPX_NOTICE_ITEM::HARD_WARNING,
599
  'longMsg' => $msg,
600
+ 'longMsgMode'=> DUPX_NOTICE_ITEM::MSG_MODE_HTML,
601
  'sections' => 'general'
602
  ), DUPX_NOTICE_MANAGER::ADD_UNIQUE_UPDATE , 'wp-config-not-found');
603
 
668
 
669
  $JSON['step3']['pass'] = 1;
670
  error_reporting($ajax3_error_level);
671
+ die(DupLiteSnapLibUtil::wp_json_encode($JSON));
installer/dup-installer/favicon/browserconfig.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <browserconfig>
3
+ <msapplication>
4
+ <tile>
5
+ <square150x150logo src="/dup-installer/favicon/lite01_mstile-150x150.png"/>
6
+ <TileColor>#00aba9</TileColor>
7
+ </tile>
8
+ </msapplication>
9
+ </browserconfig>
installer/dup-installer/favicon/lite01_android-chrome-192x192.png ADDED
Binary file
installer/dup-installer/favicon/lite01_android-chrome-256x256.png ADDED
Binary file
installer/dup-installer/favicon/lite01_apple-touch-icon.png ADDED
Binary file
installer/dup-installer/favicon/lite01_favicon-16x16.png ADDED
Binary file
installer/dup-installer/favicon/lite01_favicon-32x32.png ADDED
Binary file
installer/dup-installer/favicon/lite01_favicon.ico ADDED
Binary file
installer/dup-installer/favicon/lite01_mstile-150x150.png ADDED
Binary file
installer/dup-installer/favicon/lite01_safari-pinned-tab.svg ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
3
+ "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
4
+ <svg version="1.0" xmlns="http://www.w3.org/2000/svg"
5
+ width="256.000000pt" height="256.000000pt" viewBox="0 0 256.000000 256.000000"
6
+ preserveAspectRatio="xMidYMid meet">
7
+ <metadata>
8
+ Created by potrace 1.11, written by Peter Selinger 2001-2013
9
+ </metadata>
10
+ <g transform="translate(0.000000,256.000000) scale(0.100000,-0.100000)"
11
+ fill="#000000" stroke="none">
12
+ <path d="M945 2506 c-38 -11 -72 -21 -74 -23 -4 -3 -10 -69 -16 -163 -1 -30
13
+ -3 -63 -4 -72 0 -9 -11 -20 -23 -24 -12 -3 -50 -24 -85 -45 -35 -22 -67 -39
14
+ -72 -39 -5 0 -53 23 -107 50 -54 28 -103 50 -108 50 -6 0 -38 -28 -73 -62
15
+ l-62 -61 56 -111 c43 -86 53 -113 44 -126 -6 -8 -29 -48 -52 -87 -22 -40 -46
16
+ -73 -52 -74 -7 0 -23 -2 -37 -4 -14 -2 -62 -4 -108 -5 -45 -2 -85 -7 -89 -13
17
+ -4 -6 -16 -46 -28 -89 -26 -90 -35 -75 94 -159 l86 -56 0 -105 1 -105 -103
18
+ -68 c-113 -75 -109 -65 -77 -160 8 -22 14 -48 14 -57 0 -26 12 -29 123 -34 56
19
+ -3 107 -7 114 -9 7 -2 20 28 33 78 12 45 28 103 36 128 8 25 16 56 19 68 2 12
20
+ 7 31 10 42 4 11 7 57 7 102 0 286 134 547 367 719 59 43 193 106 277 130 67
21
+ 19 102 23 229 22 133 -1 160 -4 238 -27 49 -15 107 -37 129 -48 l41 -21 -586
22
+ -586 c-322 -322 -588 -584 -590 -582 -3 3 -8 50 -11 105 -8 110 -17 199 -20
23
+ 202 -1 2 -44 -150 -95 -336 -51 -187 -99 -361 -107 -387 l-14 -48 41 39 c23
24
+ 22 401 399 840 838 l799 799 -37 27 c-21 15 -69 46 -108 69 -96 57 -95 55 -96
25
+ 120 0 88 -8 165 -16 172 -7 6 -75 26 -155 45 -12 2 -35 -25 -83 -98 l-68 -102
26
+ -103 1 c-58 1 -106 3 -108 5 -2 2 -31 48 -65 101 -41 63 -68 96 -79 95 -9 -1
27
+ -48 -10 -87 -21z"/>
28
+ <path d="M1452 1307 l-833 -833 23 -20 c26 -24 154 -104 165 -104 5 0 17 -7
29
+ 27 -15 20 -15 23 -31 26 -157 2 -42 6 -81 10 -88 4 -6 45 -22 91 -34 l84 -23
30
+ 67 101 68 101 102 0 103 0 64 -95 c35 -52 66 -98 70 -102 8 -10 170 35 179 49
31
+ 4 6 9 58 10 114 4 104 12 139 35 139 7 0 44 20 82 44 l70 43 104 -54 c57 -29
32
+ 108 -53 112 -53 5 0 37 28 73 62 l64 62 -55 111 -56 112 47 76 c25 42 46 81
33
+ 46 87 0 5 3 10 8 11 30 3 89 8 161 13 46 3 85 6 86 8 5 5 45 154 45 166 0 7
34
+ -45 42 -100 78 l-100 67 0 102 0 102 104 69 103 68 -23 84 c-13 47 -25 87 -28
35
+ 89 -2 3 -35 7 -73 9 -37 3 -89 6 -115 8 l-48 3 -19 -66 c-61 -206 -74 -269
36
+ -76 -366 -4 -126 -9 -158 -47 -272 -84 -255 -290 -461 -548 -546 -100 -33
37
+ -126 -38 -250 -42 -113 -5 -226 14 -338 55 -116 43 -166 -22 492 636 322 323
38
+ 587 583 587 578 1 -5 2 -22 4 -39 5 -59 17 -191 20 -230 2 -22 4 -42 5 -45 1
39
+ -4 73 244 85 295 11 49 25 101 70 259 45 164 58 216 53 216 -2 0 -378 -375
40
+ -836 -833z"/>
41
+ </g>
42
+ </svg>
installer/dup-installer/favicon/site.webmanifest ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "",
3
+ "short_name": "",
4
+ "icons": [
5
+ {
6
+ "src": "/dup-installer/favicon/lite01_android-chrome-192x192.png",
7
+ "sizes": "192x192",
8
+ "type": "image/png"
9
+ },
10
+ {
11
+ "src": "/dup-installer/favicon/lite01_android-chrome-256x256.png",
12
+ "sizes": "256x256",
13
+ "type": "image/png"
14
+ }
15
+ ],
16
+ "theme_color": "#ffffff",
17
+ "background_color": "#ffffff",
18
+ "display": "standalone"
19
+ }
installer/dup-installer/main.installer.php CHANGED
@@ -40,30 +40,34 @@ try {
40
  * init constants and include
41
  */
42
  DUPX_Boot::init();
 
43
 
44
- $exceptionError = false;
 
 
 
 
 
 
 
45
 
46
- require_once($GLOBALS['DUPX_INIT'] . '/classes/config/class.archive.config.php');
47
- $GLOBALS['DUPX_AC'] = DUPX_ArchiveConfig::getInstance();
 
48
 
49
- if ($GLOBALS['DUPX_AC']->csrf_crypt) {
50
- require_once($GLOBALS['DUPX_INIT'].'/classes/Crypt/Rijndael.php');
51
- require_once($GLOBALS['DUPX_INIT'].'/classes/Crypt/Random.php');
52
- }
53
  require_once($GLOBALS['DUPX_INIT'].'/classes/class.csrf.php');
54
 
55
  // ?view=help
56
  if (!empty($_GET['view']) && 'help' == $_GET['view']) {
57
  if (!isset($_GET['archive'])) {
58
  // RSR TODO: Fail gracefully
59
- die("Archive parameter not specified");
60
  }
61
  if (!isset($_GET['bootloader'])) {
62
  // RSR TODO: Fail gracefully
63
- die("Bootloader parameter not specified");
64
  }
65
  } else if (isset($_GET['is_daws']) && 1 == $_GET['is_daws']) { // For daws action
66
- require_once($GLOBALS['DUPX_INIT'].'/classes/utilities/class.u.php');
67
  $post_ctrl_csrf_token = isset($_GET['daws_csrf_token']) ? DUPX_U::sanitize_text_field($_GET['daws_csrf_token']) : '';
68
  if (DUPX_CSRF::check($post_ctrl_csrf_token, 'daws')) {
69
  $outer_root_path = dirname($GLOBALS['DUPX_ROOT']);
@@ -92,13 +96,13 @@ try {
92
  'isWPAlreadyExistsError' => 1,
93
  'error' => "<b style='color:#B80000;'>INSTALL ERROR!</b><br/>". ERR_CONFIG_FOUND,
94
  );
95
- echo json_encode($resp);
96
  } else {
97
  require_once($GLOBALS['DUPX_INIT'].'/lib/dup_archive/daws/daws.php');
98
  }
99
- die();
100
  } else {
101
- die("An invalid request was made to 'daws'. In order to protect this request from unauthorized access please "
102
  . "<a href='../{$GLOBALS['BOOTLOADER_NAME']}'>restart this install process</a>.");
103
  }
104
  } else {
@@ -108,7 +112,7 @@ try {
108
  $_POST['archive'] = $archive;
109
  } else {
110
  // RSR TODO: Fail gracefully
111
- die("Archive parameter not specified");
112
  }
113
  }
114
  if (!isset($_POST['bootloader'])) {
@@ -117,18 +121,15 @@ try {
117
  $_POST['bootloader'] = $bootloader;
118
  } else {
119
  // RSR TODO: Fail gracefully
120
- die("Bootloader parameter not specified");
121
  }
122
  }
123
  }
124
 
125
- require_once($GLOBALS['DUPX_INIT'].'/classes/config/class.constants.php');
126
- require_once($GLOBALS['DUPX_INIT'].'/classes/config/class.archive.config.php');
127
- require_once($GLOBALS['DUPX_INIT'].'/classes/class.installer.state.php');
128
- require_once($GLOBALS['DUPX_INIT'].'/classes/class.password.php');
129
 
130
  if ($GLOBALS['DUPX_AC'] == null) {
131
- die("Can't initialize config globals! Please try to re-run installer.php");
132
  }
133
 
134
  //Password Check
@@ -153,7 +154,7 @@ try {
153
  // TODO: If this is the very first step
154
  $GLOBALS['DUPX_STATE'] = DUPX_InstallerState::getInstance($init_state);
155
  if ($GLOBALS['DUPX_STATE'] == null) {
156
- die("Can't initialize installer state! Please try to re-run installer.php");
157
  }
158
 
159
  if (!empty($GLOBALS['view'])) {
@@ -176,49 +177,25 @@ try {
176
 
177
  if (in_array($post_view, $csrf_views)) {
178
  if (isset($_POST['csrf_token']) && !DUPX_CSRF::check($_POST['csrf_token'], $post_view)) {
179
- /*
180
- var_dump($_POST['csrf_token']);
181
- echo '<br/>';
182
- echo '<pre>';
183
- var_dump($_COOKIE);
184
- echo '</pre>';
185
- echo '<br/>';
186
- */
187
- die("An invalid request was made to '{$post_view}'. In order to protect this request from unauthorized access please "
188
  . "<a href='../{$GLOBALS['BOOTLOADER_NAME']}'>restart this install process</a>.");
189
  }
190
  }
191
  }
192
 
193
- require_once($GLOBALS['DUPX_INIT'] . '/classes/class.db.php');
194
- require_once($GLOBALS['DUPX_INIT'] . '/classes/class.logging.php');
195
- require_once($GLOBALS['DUPX_INIT'] . '/classes/class.http.php');
196
- require_once($GLOBALS['DUPX_INIT'] . '/classes/class.server.php');
197
- require_once($GLOBALS['DUPX_INIT'] . '/classes/config/class.conf.srv.php');
198
- require_once($GLOBALS['DUPX_INIT'] . '/classes/class.view.php');
199
-
200
  $GLOBALS['_CURRENT_URL_PATH'] = $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
201
  $GLOBALS['NOW_TIME'] = @date("His");
202
 
203
  if (!chdir($GLOBALS['DUPX_INIT'])) {
204
  // RSR TODO: Can't change directories
205
- echo "Can't change to directory ".$GLOBALS['DUPX_INIT'];
206
- exit(1);
207
  }
208
 
209
  if (isset($_POST['ctrl_action'])) {
210
  $post_ctrl_csrf_token = isset($_POST['ctrl_csrf_token']) ? $_POST['ctrl_csrf_token'] : '';
211
  $post_ctrl_action = DUPX_U::sanitize_text_field($_POST['ctrl_action']);
212
  if (!DUPX_CSRF::check($post_ctrl_csrf_token, $post_ctrl_action)) {
213
- /*
214
- var_dump($post_ctrl_csrf_token);
215
- echo '<br/>';
216
- echo '<pre>';
217
- var_dump($_COOKIE);
218
- echo '</pre>';
219
- echo '<br/>';
220
- */
221
- die("An invalid request was made to '{$post_ctrl_action}'. In order to protect this request from unauthorized access please "
222
  . "<a href='../{$GLOBALS['BOOTLOADER_NAME']}'>restart this install process</a>.");
223
  }
224
  require_once($GLOBALS['DUPX_INIT'].'/ctrls/ctrl.base.php');
@@ -228,11 +205,13 @@ try {
228
  $pass_hasher = new DUPX_PasswordHash(8, FALSE);
229
  $pass_check = $pass_hasher->CheckPassword(base64_encode($_POST['secure-pass']), $GLOBALS['DUPX_AC']->secure_pass);
230
  if (! $pass_check) {
231
- die("Unauthorized Access: Please provide a password!");
232
  }
233
  }
234
 
235
- switch ($_POST['ctrl_action']) {
 
 
236
  case "ctrl-step1" :
237
  require_once($GLOBALS['DUPX_INIT'].'/ctrls/ctrl.s1.php');
238
  break;
@@ -247,9 +226,12 @@ try {
247
  require_once($GLOBALS['DUPX_INIT'].'/classes/class.engine.php');
248
  require_once($GLOBALS['DUPX_INIT'].'/ctrls/ctrl.s3.php');
249
  break;
 
 
 
250
  }
251
- @fclose($GLOBALS["LOG_FILE_HANDLE"]);
252
- die("");
253
  }
254
  } catch (Exception $e) {
255
  $exceptionError = $e;
@@ -261,7 +243,8 @@ try {
261
  $unespectOutput = ob_get_contents();
262
  ob_clean();
263
  if (!empty($unespectOutput)) {
264
- // @todo something for report unespected output
 
265
  }
266
  ?><!DOCTYPE html>
267
  <html>
@@ -270,6 +253,18 @@ if (!empty($unespectOutput)) {
270
  <meta name="robots" content="noindex,nofollow">
271
  <title>Duplicator</title>
272
  <link rel='stylesheet' href='assets/font-awesome/css/all.min.css' type='text/css' media='all' />
 
 
 
 
 
 
 
 
 
 
 
 
273
  <?php
274
  require_once($GLOBALS['DUPX_INIT'] . '/assets/inc.libs.css.php');
275
  require_once($GLOBALS['DUPX_INIT'] . '/assets/inc.css.php');
40
  * init constants and include
41
  */
42
  DUPX_Boot::init();
43
+ DUPX_Boot::initArchiveAndLog();
44
 
45
+ require_once($GLOBALS['DUPX_INIT'].'/classes/class.installer.state.php');
46
+ require_once($GLOBALS['DUPX_INIT'].'/classes/class.password.php');
47
+ require_once($GLOBALS['DUPX_INIT'].'/classes/class.db.php');
48
+ require_once($GLOBALS['DUPX_INIT'].'/classes/class.http.php');
49
+ require_once($GLOBALS['DUPX_INIT'].'/classes/class.server.php');
50
+ require_once($GLOBALS['DUPX_INIT'].'/classes/config/class.conf.srv.php');
51
+ require_once($GLOBALS['DUPX_INIT'].'/classes/utilities/class.u.php');
52
+ require_once($GLOBALS['DUPX_INIT'].'/classes/class.view.php');
53
 
54
+ $exceptionError = false;
55
+ // DUPX_log::error thotw an exception
56
+ DUPX_Log::setThrowExceptionOnError(true);
57
 
 
 
 
 
58
  require_once($GLOBALS['DUPX_INIT'].'/classes/class.csrf.php');
59
 
60
  // ?view=help
61
  if (!empty($_GET['view']) && 'help' == $_GET['view']) {
62
  if (!isset($_GET['archive'])) {
63
  // RSR TODO: Fail gracefully
64
+ DUPX_Log::error("Archive parameter not specified");
65
  }
66
  if (!isset($_GET['bootloader'])) {
67
  // RSR TODO: Fail gracefully
68
+ DUPX_Log::error("Bootloader parameter not specified");
69
  }
70
  } else if (isset($_GET['is_daws']) && 1 == $_GET['is_daws']) { // For daws action
 
71
  $post_ctrl_csrf_token = isset($_GET['daws_csrf_token']) ? DUPX_U::sanitize_text_field($_GET['daws_csrf_token']) : '';
72
  if (DUPX_CSRF::check($post_ctrl_csrf_token, 'daws')) {
73
  $outer_root_path = dirname($GLOBALS['DUPX_ROOT']);
96
  'isWPAlreadyExistsError' => 1,
97
  'error' => "<b style='color:#B80000;'>INSTALL ERROR!</b><br/>". ERR_CONFIG_FOUND,
98
  );
99
+ echo DupLiteSnapLibUtil::wp_json_encode($resp);
100
  } else {
101
  require_once($GLOBALS['DUPX_INIT'].'/lib/dup_archive/daws/daws.php');
102
  }
103
+ die('');
104
  } else {
105
+ DUPX_Log::error("An invalid request was made to 'daws'. In order to protect this request from unauthorized access please "
106
  . "<a href='../{$GLOBALS['BOOTLOADER_NAME']}'>restart this install process</a>.");
107
  }
108
  } else {
112
  $_POST['archive'] = $archive;
113
  } else {
114
  // RSR TODO: Fail gracefully
115
+ DUPX_Log::error("Archive parameter not specified");
116
  }
117
  }
118
  if (!isset($_POST['bootloader'])) {
121
  $_POST['bootloader'] = $bootloader;
122
  } else {
123
  // RSR TODO: Fail gracefully
124
+ DUPX_Log::error("Bootloader parameter not specified");
125
  }
126
  }
127
  }
128
 
129
+ DUPX_InstallerState::init($GLOBALS['INIT']);
 
 
 
130
 
131
  if ($GLOBALS['DUPX_AC'] == null) {
132
+ DUPX_Log::error("Can't initialize config globals! Please try to re-run installer.php");
133
  }
134
 
135
  //Password Check
154
  // TODO: If this is the very first step
155
  $GLOBALS['DUPX_STATE'] = DUPX_InstallerState::getInstance($init_state);
156
  if ($GLOBALS['DUPX_STATE'] == null) {
157
+ DUPX_Log::error("Can't initialize installer state! Please try to re-run installer.php");
158
  }
159
 
160
  if (!empty($GLOBALS['view'])) {
177
 
178
  if (in_array($post_view, $csrf_views)) {
179
  if (isset($_POST['csrf_token']) && !DUPX_CSRF::check($_POST['csrf_token'], $post_view)) {
180
+ DUPX_Log::error("An invalid request was made to '{$post_view}'. In order to protect this request from unauthorized access please "
 
 
 
 
 
 
 
 
181
  . "<a href='../{$GLOBALS['BOOTLOADER_NAME']}'>restart this install process</a>.");
182
  }
183
  }
184
  }
185
 
 
 
 
 
 
 
 
186
  $GLOBALS['_CURRENT_URL_PATH'] = $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
187
  $GLOBALS['NOW_TIME'] = @date("His");
188
 
189
  if (!chdir($GLOBALS['DUPX_INIT'])) {
190
  // RSR TODO: Can't change directories
191
+ DUPX_Log::error("Can't change to directory ".$GLOBALS['DUPX_INIT']);
 
192
  }
193
 
194
  if (isset($_POST['ctrl_action'])) {
195
  $post_ctrl_csrf_token = isset($_POST['ctrl_csrf_token']) ? $_POST['ctrl_csrf_token'] : '';
196
  $post_ctrl_action = DUPX_U::sanitize_text_field($_POST['ctrl_action']);
197
  if (!DUPX_CSRF::check($post_ctrl_csrf_token, $post_ctrl_action)) {
198
+ DUPX_Log::error("An invalid request was made to '{$post_ctrl_action}'. In order to protect this request from unauthorized access please "
 
 
 
 
 
 
 
 
199
  . "<a href='../{$GLOBALS['BOOTLOADER_NAME']}'>restart this install process</a>.");
200
  }
201
  require_once($GLOBALS['DUPX_INIT'].'/ctrls/ctrl.base.php');
205
  $pass_hasher = new DUPX_PasswordHash(8, FALSE);
206
  $pass_check = $pass_hasher->CheckPassword(base64_encode($_POST['secure-pass']), $GLOBALS['DUPX_AC']->secure_pass);
207
  if (! $pass_check) {
208
+ DUPX_Log::error("Unauthorized Access: Please provide a password!");
209
  }
210
  }
211
 
212
+ // the controllers must die in case of error
213
+ DUPX_Log::setThrowExceptionOnError(false);
214
+ switch ($post_ctrl_action) {
215
  case "ctrl-step1" :
216
  require_once($GLOBALS['DUPX_INIT'].'/ctrls/ctrl.s1.php');
217
  break;
226
  require_once($GLOBALS['DUPX_INIT'].'/classes/class.engine.php');
227
  require_once($GLOBALS['DUPX_INIT'].'/ctrls/ctrl.s3.php');
228
  break;
229
+ default:
230
+ DUPX_Log::setThrowExceptionOnError(true);
231
+ DUPX_Log::error('No valid action request');
232
  }
233
+ DUPX_Log::setThrowExceptionOnError(true);
234
+ DUPX_Log::error('Ctrl action problem');
235
  }
236
  } catch (Exception $e) {
237
  $exceptionError = $e;
243
  $unespectOutput = ob_get_contents();
244
  ob_clean();
245
  if (!empty($unespectOutput)) {
246
+ DUPX_Log::info('ERROR: Unespect output '.DUPX_Log::varToString($unespectOutput));
247
+ $exceptionError = new Exception('Unespected output '.DUPX_Log::varToString($unespectOutput));
248
  }
249
  ?><!DOCTYPE html>
250
  <html>
253
  <meta name="robots" content="noindex,nofollow">
254
  <title>Duplicator</title>
255
  <link rel='stylesheet' href='assets/font-awesome/css/all.min.css' type='text/css' media='all' />
256
+
257
+ <link rel="apple-touch-icon" sizes="180x180" href="/dup-installer/favicon/lite01_apple-touch-icon.png">
258
+ <link rel="icon" type="image/png" sizes="32x32" href="/dup-installer/favicon/lite01_favicon-32x32.png">
259
+ <link rel="icon" type="image/png" sizes="16x16" href="/dup-installer/favicon/lite01_favicon-16x16.png">
260
+ <link rel="manifest" href="/dup-installer/favicon/site.webmanifest">
261
+ <link rel="mask-icon" href="/dup-installer/favicon/lite01_safari-pinned-tab.svg" color="#5bbad5">
262
+ <link rel="shortcut icon" href="/dup-installer/favicon/lite01_favicon.ico">
263
+ <meta name="msapplication-TileColor" content="#da532c">
264
+ <meta name="msapplication-config" content="/favicon/dup-installer/browserconfig.xml">
265
+ <meta name="theme-color" content="#ffffff">
266
+
267
+ <link rel='stylesheet' href='assets/font-awesome/css/font-awesome.min.css' type='text/css' media='all' />
268
  <?php
269
  require_once($GLOBALS['DUPX_INIT'] . '/assets/inc.libs.css.php');
270
  require_once($GLOBALS['DUPX_INIT'] . '/assets/inc.css.php');
installer/dup-installer/views/view.init1.php CHANGED
@@ -43,71 +43,57 @@ if ($_POST['secure-try'] && ! $pass_check) {
43
 
44
  <!-- =========================================
45
  VIEW: STEP 0 - PASSWORD -->
46
- <form method="post" id="i1-pass-form" class="content-form" data-parsley-validate="" autocomplete="oldpassword">
47
- <input type="hidden" name="view" value="secure" />
48
- <input type="hidden" name="csrf_token" value="<?php echo DUPX_CSRF::generate('secure'); ?>">
49
- <input type="hidden" name="secure-try" value="1" />
50
- <input type="hidden" name="bootloader" value="<?php echo DUPX_U::esc_attr($GLOBALS['BOOTLOADER_NAME']); ?>" />
51
- <input type="hidden" name="archive" value="<?php echo DUPX_U::esc_attr($GLOBALS['FW_PACKAGE_PATH']); ?>" />
52
 
53
- <div class="hdr-main">
54
- Installer Password
55
- </div>
56
 
57
- <?php if ($page_err) : ?>
58
- <div class="error-pane">
59
- <p>Invalid Password! Please try again. If the problem persists see the more details link below.</p>
60
- </div>
61
- <?php endif; ?>
62
 
63
- <div style="text-align: center">
64
- This file was password protected when it was created. If you do not remember the password check the details of the package on the site where it was created or visit
65
- the online FAQ for <a href="https://snapcreek.com/duplicator/docs/faqs-tech/#faq-installer-030-q" target="_blank">more details</a>.
66
- <br/><br/><br/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
 
68
- <div class="i1-pass-area">
69
- <label for="secure-pass">Enter Password</label>
70
- <div id="i1-pass-input">
71
- <div id="i1-pass-toggle">
72
- <input type="password" name="secure-pass" id="secure-pass" required="required" />
73
- <button type="button" id="secure-btn" class="pass-toggle" onclick="DUPX.togglePassword()" title="Show/Hide Password"><i class="fas fa-eye fa-xs"></i></button>
74
- </div><br/>
75
- </div>
76
- <div style="margin-top: 15px">
77
- <button type="button" class="default-btn" name="submit-btn" id="submit-btn" onclick="DUPX.checkPassword()">Submit</button>
78
- </div>
79
- </div>
80
- </div>
81
  </form>
82
 
83
  <script>
84
- /**
85
- * Submits the password for validation
86
- */
87
- DUPX.checkPassword = function()
88
- {
89
- var $form = $('#i1-pass-form');
90
- $form.parsley().validate();
91
- if (! $form.parsley().isValid()) {
92
- return;
93
- }
94
- $form.submit();
95
- }
96
-
97
- /**
98
- * Submits the password for validation
99
- */
100
- DUPX.togglePassword = function()
101
- {
102
- var $input = $('#secure-pass');
103
- var $lock = $('#secure-btn');
104
- if (($input).attr('type') == 'text') {
105
- $lock.html('<i class="fas fa-eye fa-xs"></i>');
106
- $input.attr('type', 'password');
107
- } else {
108
- $lock.html('<i class="fas fa-eye-slash fa-xs"></i>');
109
- $input.attr('type', 'text');
110
- }
111
- }
112
  </script>
113
  <!-- END OF VIEW INIT 1 -->
43
 
44
  <!-- =========================================
45
  VIEW: STEP 0 - PASSWORD -->
46
+ <form method="post" id="i1-pass-form" class="content-form" data-parsley-validate="">
47
+ <input type="hidden" name="view" value="secure" />
48
+ <input type="hidden" name="csrf_token" value="<?php echo DUPX_CSRF::generate('secure'); ?>">
49
+ <input type="hidden" name="secure-try" value="1" />
50
+ <input type="hidden" name="bootloader" value="<?php echo DUPX_U::esc_attr($GLOBALS['BOOTLOADER_NAME']); ?>" />
51
+ <input type="hidden" name="archive" value="<?php echo DUPX_U::esc_attr($GLOBALS['FW_PACKAGE_PATH']); ?>" />
52
 
53
+ <div class="hdr-main">
54
+ Installer Password
55
+ </div>
56
 
57
+ <?php if ($page_err) : ?>
58
+ <div class="error-pane">
59
+ <p>Invalid Password! Please try again...</p>
60
+ </div>
61
+ <?php endif; ?>
62
 
63
+ <div style="text-align: center">
64
+ This file was password protected when it was created. If you do not remember the password check the details of the package on the site where it was created or visit
65
+ the online FAQ for <a href="https://snapcreek.com/duplicator/docs/faqs-tech/#faq-installer-030-q" target="_blank">more details</a>.
66
+ <br/><br/><br/>
67
+ </div>
68
+
69
+ <div class="i1-pass-area">
70
+ <div class="i1-pass-data">
71
+ <label for="secure-pass">&nbsp; Enter Password</label>
72
+ <?php
73
+ DUPX_U_Html::inputPasswordToggle('secure-pass', 'secure-pass', array(),
74
+ array(
75
+ 'required' => 'required'
76
+ ));
77
+ ?>
78
+ <br><br>
79
+ <button type="button" name="secure-btn" id="secure-btn" class="default-btn" onclick="DUPX.checkPassword()">Submit</button>
80
+ </div>
81
+ </div>
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  </form>
84
 
85
  <script>
86
+ /**
87
+ * Submits the password for validation
88
+ */
89
+ DUPX.checkPassword = function ()
90
+ {
91
+ var $form = $('#i1-pass-form');
92
+ $form.parsley().validate();
93
+ if (!$form.parsley().isValid()) {
94
+ return;
95
+ }
96
+ $form.submit();
97
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  </script>
99
  <!-- END OF VIEW INIT 1 -->
installer/dup-installer/views/view.s1.base.php CHANGED
@@ -38,8 +38,8 @@ $openbase = ini_get("open_basedir");
38
  $datetime1 = $GLOBALS['DUPX_AC']->created;
39
  $datetime2 = date("Y-m-d H:i:s");
40
  $fulldays = round(abs(strtotime($datetime1) - strtotime($datetime2))/86400);
41
- $root_path = SnapLibIOU::safePath($GLOBALS['DUPX_ROOT'], true);
42
- $archive_path = SnapLibIOU::safePath($GLOBALS['FW_PACKAGE_PATH'], true);
43
  $wpconf_path = "{$root_path}/wp-config.php";
44
  $max_time_zero = ($GLOBALS['DUPX_ENFORCE_PHP_INI']) ? false : @set_time_limit(0);
45
  $max_time_size = 314572800; //300MB
@@ -210,7 +210,7 @@ ARCHIVE
210
  <div class="s1-archive-failed-msg">
211
  <b class="dupx-fail">Archive File Not Found!</b><br/>
212
  The installer file and the archive are bound together as a package when the archive is built. They must be downloaded together and used
213
- together at install time. The archive file name should <u>not</u> be changed when it is downloaded because the file name is strongly bound
214
  to the installer. When downloading the package files make sure both files are from the same package line in the packages view within the
215
  Duplicator WordPress admin.
216
  <br/><br/>
@@ -567,31 +567,35 @@ OPTIONS
567
  <tr>
568
  <td>Extraction:</td>
569
  <td>
570
- <?php $num_selections = ($archive_config->isZipArchive() ? 3 : 2); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
571
  <select id="archive_engine" name="archive_engine" size="<?php echo DUPX_U::esc_attr($num_selections); ?>">
572
- <option <?php echo ($is_wpconfarc_present ? '' : 'disabled'); ?> value="manual">Manual Archive Extraction <?php echo ($is_wpconfarc_present ? '' : '*'); ?></option>
573
- <?php
574
- if($archive_config->isZipArchive()){
575
-
576
- //ZIP-ARCHIVE
577
- if (!$zip_archive_enabled){
578
- echo '<option value="ziparchive" disabled="true">PHP ZipArchive (not detected on server)</option>';
579
- } elseif ($zip_archive_enabled &&!$shell_exec_zip_enabled) {
580
- echo '<option value="ziparchive" selected="true">PHP ZipArchive</option>';
581
- } else {
582
- echo '<option value="ziparchive">PHP ZipArchive</option>';
583
- }
584
-
585
- //SHELL-EXEC UNZIP
586
- if (!$shell_exec_zip_enabled){
587
- echo '<option value="shellexec_unzip" disabled="true">Shell Exec Unzip (not detected on server)</option>';
588
- } else {
589
- echo '<option value="shellexec_unzip" selected="true">Shell Exec Unzip</option>';
590
- }
591
- }
592
- else {
593
- echo '<option value="duparchive" selected="true">DupArchive</option>';
594
- }
595
  ?>
596
  </select><br/>
597
  <?php if(!$is_wpconfarc_present) :?>
@@ -606,9 +610,9 @@ OPTIONS
606
  <td>Permissions:</td>
607
  <td>
608
  <input type="checkbox" name="set_file_perms" id="set_file_perms" value="1" onclick="jQuery('#file_perms_value').prop('disabled', !jQuery(this).is(':checked'));"/>
609
- <label for="set_file_perms">All Files</label><input name="file_perms_value" id="file_perms_value" style="width:30px; margin-left:7px;" value="644" disabled> &nbsp;
610
  <input type="checkbox" name="set_dir_perms" id="set_dir_perms" value="1" onclick="jQuery('#dir_perms_value').prop('disabled', !jQuery(this).is(':checked'));"/>
611
- <label for="set_dir_perms">All Directories</label><input name="dir_perms_value" id="dir_perms_value" style="width:30px; margin-left:7px;" value="755" disabled>
612
  </td>
613
  </tr>
614
  </table><br/><br/>
@@ -798,7 +802,7 @@ DUPX.getManaualArchiveOpt = function ()
798
  DUPX.startExtraction = function()
799
  {
800
  var isManualExtraction = ($("#archive_engine").val() == "manual");
801
- var zipEnabled = <?php echo SnapLibStringU::boolToString($archive_config->isZipArchive()); ?>;
802
 
803
  $("#operation-text").text("Extracting Archive Files");
804
 
38
  $datetime1 = $GLOBALS['DUPX_AC']->created;
39
  $datetime2 = date("Y-m-d H:i:s");
40
  $fulldays = round(abs(strtotime($datetime1) - strtotime($datetime2))/86400);
41
+ $root_path = DupLiteSnapLibIOU::safePath($GLOBALS['DUPX_ROOT'], true);
42
+ $archive_path = DupLiteSnapLibIOU::safePath($GLOBALS['FW_PACKAGE_PATH'], true);
43
  $wpconf_path = "{$root_path}/wp-config.php";
44
  $max_time_zero = ($GLOBALS['DUPX_ENFORCE_PHP_INI']) ? false : @set_time_limit(0);
45
  $max_time_size = 314572800; //300MB
210
  <div class="s1-archive-failed-msg">
211
  <b class="dupx-fail">Archive File Not Found!</b><br/>
212
  The installer file and the archive are bound together as a package when the archive is built. They must be downloaded together and used
213
+ together at install time. The archive file name should <u>NOT</u> be changed when it is downloaded because the file name is strongly bound
214
  to the installer. When downloading the package files make sure both files are from the same package line in the packages view within the
215
  Duplicator WordPress admin.
216
  <br/><br/>
567
  <tr>
568
  <td>Extraction:</td>
569
  <td>
570
+ <?php
571
+ $options = array();
572
+ $options[] = '<option '.($is_wpconfarc_present ? '' : 'disabled').' value="manual">Manual Archive Extraction '.($is_wpconfarc_present ? '' : '*').'</option>';
573
+ if($archive_config->isZipArchive()){
574
+ //ZIP-ARCHIVE
575
+ if (!$zip_archive_enabled){
576
+ $options[] = '<option value="ziparchive" disabled="true">PHP ZipArchive (not detected on server)</option>';
577
+ } elseif ($zip_archive_enabled &&!$shell_exec_zip_enabled) {
578
+ $options[] = '<option value="ziparchive" selected="true">PHP ZipArchive</option>';
579
+ } else {
580
+ $options[] = '<option value="ziparchive">PHP ZipArchive</option>';
581
+ }
582
+ //SHELL-EXEC UNZIP
583
+ if (!$shell_exec_zip_enabled){
584
+ $options[] = '<option value="shellexec_unzip" disabled="true">Shell Exec Unzip (not detected on server)</option>';
585
+ } else {
586
+ $options[] = '<option value="shellexec_unzip" selected="true">Shell Exec Unzip</option>';
587
+ }
588
+ }
589
+ else {
590
+ $options[] = '<option value="duparchive" selected="true">DupArchive</option>';
591
+ }
592
+ $num_selections = count($options);
593
+ ?>
594
  <select id="archive_engine" name="archive_engine" size="<?php echo DUPX_U::esc_attr($num_selections); ?>">
595
+ <?php
596
+ foreach($options as $opt) {
597
+ echo $opt;
598
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
599
  ?>
600
  </select><br/>
601
  <?php if(!$is_wpconfarc_present) :?>
610
  <td>Permissions:</td>
611
  <td>
612
  <input type="checkbox" name="set_file_perms" id="set_file_perms" value="1" onclick="jQuery('#file_perms_value').prop('disabled', !jQuery(this).is(':checked'));"/>
613
+ <label for="set_file_perms">All Files</label><input name="file_perms_value" id="file_perms_value" style="width:45px; margin-left:7px;" value="644" disabled> &nbsp;
614
  <input type="checkbox" name="set_dir_perms" id="set_dir_perms" value="1" onclick="jQuery('#dir_perms_value').prop('disabled', !jQuery(this).is(':checked'));"/>
615
+ <label for="set_dir_perms">All Directories</label><input name="dir_perms_value" id="dir_perms_value" style="width:45px; margin-left:7px;" value="755" disabled>
616
  </td>
617
  </tr>
618
  </table><br/><br/>
802
  DUPX.startExtraction = function()
803
  {
804
  var isManualExtraction = ($("#archive_engine").val() == "manual");
805
+ var zipEnabled = <?php echo DupLiteSnapLibStringU::boolToString($archive_config->isZipArchive()); ?>;
806
 
807
  $("#operation-text").text("Extracting Archive Files");
808
 
installer/dup-installer/views/view.s2.basic.php CHANGED
@@ -109,7 +109,17 @@ BASIC PANEL -->
109
  </td>
110
  </tr>
111
  <tr><td>User:</td><td><input type="text" name="dbuser" id="dbuser" required="true" value="<?php echo DUPX_U::esc_attr($dbuser); ?>" placeholder="valid database username" /></td></tr>
112
- <tr><td>Password:</td><td><input type="text" name="dbpass" id="dbpass" value="<?php echo DUPX_U::esc_attr($dbpass); ?>" placeholder="valid database user password" /></td></tr>
 
 
 
 
 
 
 
 
 
 
113
  </table>
114
  </div>
115
  <br/><br/>
109
  </td>
110
  </tr>
111
  <tr><td>User:</td><td><input type="text" name="dbuser" id="dbuser" required="true" value="<?php echo DUPX_U::esc_attr($dbuser); ?>" placeholder="valid database username" /></td></tr>
112
+ <tr>
113
+ <td>Password:</td>
114
+ <td>
115
+ <?php
116
+ DUPX_U_Html::inputPasswordToggle('dbpass' , 'dbpass' , array() , array(
117
+ 'placeholder' => 'valid database user password' ,
118
+ 'value' => $dbpass
119
+ ));
120
+ ?>
121
+ </td>
122
+ </tr>
123
  </table>
124
  </div>
125
  <br/><br/>
installer/dup-installer/views/view.s2.dbtest.php CHANGED
@@ -243,9 +243,28 @@ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
243
 
244
  </div>
245
 
246
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
 
 
 
 
248
 
 
249
 
250
  <!-- ==================================
251
  NOTICES
@@ -289,9 +308,54 @@ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
289
  Handlebars.registerHelper('if_eq', function(a, b, opts) { return (a == b) ? opts.fn(this) : opts.inverse(this);});
290
  Handlebars.registerHelper('if_neq', function(a, b, opts) { return (a != b) ? opts.fn(this) : opts.inverse(this);});
291
  Handlebars.registerHelper('faqURL', function() { return "https://snapcreek.com/duplicator/docs/faqs-tech/";});
292
- Handlebars.registerHelper('reqText', function(req) { if (req == -1) {return ""}; return (req) ? "Pass" : "Fail";});
293
- Handlebars.registerHelper('reqStyle', function(req) { if (req == -1) {return ""}; return (req) ? "status-badge-pass" : "status-badge-fail";});
294
- Handlebars.registerHelper('noticeStyle',function(req) { if (req == -1) {return ""}; return (req) ? "status-badge-pass" : "status-badge-fail";});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  Handlebars.registerHelper('noticeText', function(warn) { if (warn == -1) {return ""}; return (warn) ? "Good" : "Warn";});
296
  Handlebars.registerHelper('getInfo', function(pass, info) {
297
  return (pass && pass != -1)
@@ -426,9 +490,11 @@ DUPX.intTestDBResults = function(data, result)
426
  $btnTestDB.removeAttr('disabled').removeClass('disabled');
427
  $btnNext.removeAttr('disabled').removeClass('disabled');
428
 
429
- if (data.payload.reqsPass == 1) {
430
  $btnTestDB.addClass('disabled').attr('disabled', 'true');
431
- $divReqsAll.hide()
 
 
432
  } else {
433
  $btnNext.addClass('disabled').attr('disabled', 'true');
434
  $divReqsAll.show();
@@ -436,7 +502,7 @@ DUPX.intTestDBResults = function(data, result)
436
 
437
  data.payload.noticesPass ? $divNoticeAll.hide() : $divNoticeAll.show();
438
 
439
- if (data.payload.reqsPass == 1 && data.payload.noticesPass == 1) {
440
  $btnTestDB.addClass('disabled').attr('disabled', 'true');
441
  }
442
 
243
 
244
  </div>
245
 
246
+ <!-- ==================================
247
+ REQ 80: CHECK GTID -->
248
+ <div class="status {{noticeStyle payload.reqs.80.pass}}">{{reqText payload.reqs.80.pass}}</div>
249
+ <div class="title" data-type="toggle" data-target="#s2-reqs80"><i class="fa fa-caret-right"></i> {{payload.reqs.80.title}}</div>
250
+ <div class="info s2-reqs80" id="s2-reqs80">
251
+ <div class="sub-title">STATUS</div>
252
+ {{{getInfo payload.reqs.80.pass payload.reqs.80.info}}}<br/>
253
+
254
+ <div class="sub-title">DETAILS</div>
255
+ This test checks to make sure the database server should not have GTID mode enabled.
256
+ <br/><br/>
257
+ <div class="sub-title">TROUBLESHOOT</div>
258
+ <ul>
259
+ <li><i class="far fa-file-code"></i> <a href='https://dev.mysql.com/doc/refman/5.6/en/replication-gtids-concepts.html' target='_help'>What is GTID?</a></li>
260
+ </ul>
261
+ </div>
262
 
263
+ </div>
264
+
265
+ </div>
266
 
267
+
268
 
269
  <!-- ==================================
270
  NOTICES
308
  Handlebars.registerHelper('if_eq', function(a, b, opts) { return (a == b) ? opts.fn(this) : opts.inverse(this);});
309
  Handlebars.registerHelper('if_neq', function(a, b, opts) { return (a != b) ? opts.fn(this) : opts.inverse(this);});
310
  Handlebars.registerHelper('faqURL', function() { return "https://snapcreek.com/duplicator/docs/faqs-tech/";});
311
+ Handlebars.registerHelper('reqText', function(req) {
312
+ switch(req) {
313
+ case 0:
314
+ return "Fail";
315
+ break;
316
+ case 1:
317
+ return "Pass";
318
+ break;
319
+ case 2:
320
+ return "Warn";
321
+ break;
322
+ case -1:
323
+ default:
324
+ return "";
325
+ }
326
+ });
327
+ Handlebars.registerHelper('reqStyle', function(req) {
328
+ switch (req) {
329
+ case 0:
330
+ return "status-badge-fail"
331
+ break;
332
+ case 1:
333
+ return "status-badge-pass"
334
+ break;
335
+ case 2:
336
+ return "status-badge-warn"
337
+ break;
338
+ case -1:
339
+ default:
340
+ return "";
341
+ }
342
+ });
343
+ Handlebars.registerHelper('noticeStyle',function(req) {
344
+ switch (req) {
345
+ case 0:
346
+ return "status-badge-fail"
347
+ break;
348
+ case 1:
349
+ return "status-badge-pass"
350
+ break;
351
+ case 2:
352
+ return "status-badge-warn"
353
+ break;
354
+ case -1:
355
+ default:
356
+ return "";
357
+ }
358
+ });
359
  Handlebars.registerHelper('noticeText', function(warn) { if (warn == -1) {return ""}; return (warn) ? "Good" : "Warn";});
360
  Handlebars.registerHelper('getInfo', function(pass, info) {
361
  return (pass && pass != -1)
490
  $btnTestDB.removeAttr('disabled').removeClass('disabled');
491
  $btnNext.removeAttr('disabled').removeClass('disabled');
492
 
493
+ if (data.payload.reqsPass == 1 || data.payload.reqsPass == 2) {
494
  $btnTestDB.addClass('disabled').attr('disabled', 'true');
495
+ if (data.payload.reqsPass == 1) {
496
+ $divReqsAll.hide()
497
+ }
498
  } else {
499
  $btnNext.addClass('disabled').attr('disabled', 'true');
500
  $divReqsAll.show();
502
 
503
  data.payload.noticesPass ? $divNoticeAll.hide() : $divNoticeAll.show();
504
 
505
+ if ((data.payload.reqsPass == 1 || data.payload.reqsPass == 2) && data.payload.noticesPass == 1) {
506
  $btnTestDB.addClass('disabled').attr('disabled', 'true');
507
  }
508
 
installer/dup-installer/views/view.s3.php CHANGED
@@ -173,8 +173,15 @@ VIEW: STEP 3- INPUT -->
173
  </tr>
174
  <tr>
175
  <td>Password:</td>
176
- <td><input type="text" name="wp_password" id="wp_password" value="" title="6 characters minimum" placeholder="(6 or more characters)" /></td>
177
- </tr>
 
 
 
 
 
 
 
178
  <tr>
179
  <td>Email:</td>
180
  <td><input type="text" name="wp_mail" id="wp_mail" value="" title="" placeholder="" /></td>
@@ -234,7 +241,7 @@ VIEW: STEP 3- INPUT -->
234
  <a href="javascript:void(0)" onclick="$('#tables option').prop('selected',true);">[All]</a>
235
  <a href="javascript:void(0)" onclick="$('#tables option').prop('selected',false);">[None]</a>
236
  </div><br style="clear:both" />
237
- <select id="tables" name="tables[]" multiple="multiple" style="width:315px; height:100px">
238
  <?php
239
  foreach( $all_tables as $table ) {
240
  echo '<option selected="selected" value="' . DUPX_U::esc_attr( $table ) . '">' . DUPX_U::esc_html($table) . '</option>';
@@ -250,7 +257,7 @@ VIEW: STEP 3- INPUT -->
250
  <a href="javascript:void(0)" onclick="$('#plugins option').prop('selected',true);">[All]</a>
251
  <a href="javascript:void(0)" onclick="$('#plugins option').prop('selected',false);">[None]</a>
252
  </div><br style="clear:both" />
253
- <select id="plugins" name="plugins[]" multiple="multiple" style="width:315px; height:100px" <?php echo ($_POST['exe_safe_mode'] > 0) ? 'disabled="true"' : ''; ?>>
254
  <?php
255
  $exclude_plugins = array(
256
  'really-simple-ssl/rlrsssl-really-simple-ssl.php',
@@ -309,7 +316,7 @@ VIEW: STEP 3- INPUT -->
309
  $wp_cache_val = $config_transformer->get_value('constant', 'WP_CACHE');
310
  }
311
  ?>
312
- <input type="checkbox" name="cache_wp" id="cache_wp" <?php SnapLibUIU::echoChecked($wp_cache_val);?> /> <label for="cache_wp">Keep Enabled</label>
313
  </td>
314
  </tr>
315
  <tr>
@@ -321,7 +328,7 @@ VIEW: STEP 3- INPUT -->
321
  $wpcachehome_val = $config_transformer->get_value('constant', 'WPCACHEHOME');
322
  }
323
  ?>
324
- <input type="checkbox" name="cache_path" id="cache_path" <?php SnapLibUIU::echoChecked($wpcachehome_val);?> /> <label for="cache_path">Keep Home Path</label>
325
  <br><br>
326
  </td>
327
  </tr>
@@ -334,7 +341,7 @@ VIEW: STEP 3- INPUT -->
334
  $force_ssl_admin_val = $config_transformer->get_value('constant', 'FORCE_SSL_ADMIN');
335
  }
336
  ?>
337
- <input type="checkbox" name="ssl_admin" id="ssl_admin" <?php SnapLibUIU::echoChecked($force_ssl_admin_val);?> /> <label for="ssl_admin">Enforce on Admin</label>
338
  </td>
339
  </tr>
340
  <?php } else { ?>
173
  </tr>
174
  <tr>
175
  <td>Password:</td>
176
+ <td>
177
+ <?php
178
+ DUPX_U_Html::inputPasswordToggle('wp_password', 'wp_password', array(),
179
+ array(
180
+ 'placeholder' => '(6 or more characters)',
181
+ 'title' => '6 characters minimum'
182
+ ));
183
+ ?>
184
+ </tr>
185
  <tr>
186
  <td>Email:</td>
187
  <td><input type="text" name="wp_mail" id="wp_mail" value="" title="" placeholder="" /></td>
241
  <a href="javascript:void(0)" onclick="$('#tables option').prop('selected',true);">[All]</a>
242
  <a href="javascript:void(0)" onclick="$('#tables option').prop('selected',false);">[None]</a>
243
  </div><br style="clear:both" />
244
+ <select id="tables" name="tables[]" multiple="multiple" style="width:315px;" size="10">
245
  <?php
246
  foreach( $all_tables as $table ) {
247
  echo '<option selected="selected" value="' . DUPX_U::esc_attr( $table ) . '">' . DUPX_U::esc_html($table) . '</option>';
257
  <a href="javascript:void(0)" onclick="$('#plugins option').prop('selected',true);">[All]</a>
258
  <a href="javascript:void(0)" onclick="$('#plugins option').prop('selected',false);">[None]</a>
259
  </div><br style="clear:both" />
260
+ <select id="plugins" name="plugins[]" multiple="multiple" style="width:315px;" <?php echo ($_POST['exe_safe_mode'] > 0) ? 'disabled="true"' : ''; ?> size="10">
261
  <?php
262
  $exclude_plugins = array(
263
  'really-simple-ssl/rlrsssl-really-simple-ssl.php',
316
  $wp_cache_val = $config_transformer->get_value('constant', 'WP_CACHE');
317
  }
318
  ?>
319
+ <input type="checkbox" name="cache_wp" id="cache_wp" <?php DupLiteSnapLibUIU::echoChecked($wp_cache_val);?> /> <label for="cache_wp">Keep Enabled</label>
320
  </td>
321
  </tr>
322
  <tr>
328
  $wpcachehome_val = $config_transformer->get_value('constant', 'WPCACHEHOME');
329
  }
330
  ?>
331
+ <input type="checkbox" name="cache_path" id="cache_path" <?php DupLiteSnapLibUIU::echoChecked($wpcachehome_val);?> /> <label for="cache_path">Keep Home Path</label>
332
  <br><br>
333
  </td>
334
  </tr>
341
  $force_ssl_admin_val = $config_transformer->get_value('constant', 'FORCE_SSL_ADMIN');
342
  }
343
  ?>
344
+ <input type="checkbox" name="ssl_admin" id="ssl_admin" <?php DupLiteSnapLibUIU::echoChecked($force_ssl_admin_val);?> /> <label for="ssl_admin">Enforce on Admin</label>
345
  </td>
346
  </tr>
347
  <?php } else { ?>
installer/dup-installer/views/view.s4.php CHANGED
@@ -124,7 +124,7 @@ However if you see a large amount of errors or you experience an issue with your
124
  <ul>
125
  <li>
126
  <b>Unknown collation:</b> See Online FAQ:
127
- <a href="https://snapcreek.com/duplicator/docs/faqs-tech/#faq-trouble-090-q" target="_blank">What is Compatibility mode & 'Unknown collation' errors?</a>
128
  </li>
129
  <li>
130
  <b>Query Limits:</b> Update MySQL server with the <a href="https://dev.mysql.com/doc/refman/5.5/en/packet-too-large.html" target="_blank">max_allowed_packet</a>
@@ -137,7 +137,7 @@ LONGMSG;
137
  'shortMsg' => 'STEP 2 - INSTALL NOTICES ('.$json_decode->step1->query_errs.')',
138
  'level' => DUPX_NOTICE_ITEM::HARD_WARNING,
139
  'longMsg' => $longMsg,
140
- 'longMsgHtml' => true,
141
  'sections' => array('database'),
142
  'priority' => 5,
143
  'open' => true
@@ -177,7 +177,7 @@ LONGMSG;
177
  'shortMsg' => 'TABLE KEY NOTICES ('.$json_decode->step3->errkey_sum.')',
178
  'level' => DUPX_NOTICE_ITEM::SOFT_WARNING,
179
  'longMsg' => $longMsg,
180
- 'longMsgHtml' => true,
181
  'sections' => array('database'),
182
  'priority' => 5,
183
  'open' => true
@@ -218,7 +218,7 @@ LONGMSG;
218
  'shortMsg' => 'Info',
219
  'level' => DUPX_NOTICE_ITEM::INFO,
220
  'longMsg' => $longMsg,
221
- 'longMsgHtml' => true,
222
  'sections' => array('general'),
223
  'priority' => 5,
224
  'open' => true
124
  <ul>
125
  <li>
126
  <b>Unknown collation:</b> See Online FAQ:
127
+ <a href="https://snapcreek.com/duplicator/docs/faqs-tech/#faq-installer-110-q" target="_blank">What is Compatibility mode & 'Unknown collation' errors?</a>
128
  </li>
129
  <li>
130
  <b>Query Limits:</b> Update MySQL server with the <a href="https://dev.mysql.com/doc/refman/5.5/en/packet-too-large.html" target="_blank">max_allowed_packet</a>
137
  'shortMsg' => 'STEP 2 - INSTALL NOTICES ('.$json_decode->step1->query_errs.')',
138
  'level' => DUPX_NOTICE_ITEM::HARD_WARNING,
139
  'longMsg' => $longMsg,
140
+ 'longMsgMode'=> DUPX_NOTICE_ITEM::MSG_MODE_HTML,
141
  'sections' => array('database'),
142
  'priority' => 5,
143
  'open' => true
177
  'shortMsg' => 'TABLE KEY NOTICES ('.$json_decode->step3->errkey_sum.')',
178
  'level' => DUPX_NOTICE_ITEM::SOFT_WARNING,
179
  'longMsg' => $longMsg,
180
+ 'longMsgMode'=> DUPX_NOTICE_ITEM::MSG_MODE_HTML,
181
  'sections' => array('database'),
182
  'priority' => 5,
183
  'open' => true
218
  'shortMsg' => 'Info',
219
  'level' => DUPX_NOTICE_ITEM::INFO,
220
  'longMsg' => $longMsg,
221
+ 'longMsgMode'=> DUPX_NOTICE_ITEM::MSG_MODE_HTML,
222
  'sections' => array('general'),
223
  'priority' => 5,
224
  'open' => true
installer/installer.tpl CHANGED
@@ -58,4069 +58,12 @@ if (wp_is_ini_value_changeable('pcre.backtrack_limit'))
58
  if (wp_is_ini_value_changeable('default_socket_timeout'))
59
  @ini_set('default_socket_timeout', 3600);
60
 
61
- // phpseclib 1.0.14 for the Rijndael Symmetric key encryption
62
- /**
63
- * Base Class for all Crypt_* cipher classes
64
- *
65
- * PHP versions 4 and 5
66
- *
67
- * Internally for phpseclib developers:
68
- * If you plan to add a new cipher class, please note following rules:
69
- *
70
- * - The new Crypt_* cipher class should extend Crypt_Base
71
- *
72
- * - Following methods are then required to be overridden/overloaded:
73
- *
74
- * - _encryptBlock()
75
- *
76
- * - _decryptBlock()
77
- *
78
- * - _setupKey()
79
- *
80
- * - All other methods are optional to be overridden/overloaded
81
- *
82
- * - Look at the source code of the current ciphers how they extend Crypt_Base
83
- * and take one of them as a start up for the new cipher class.
84
- *
85
- * - Please read all the other comments/notes/hints here also for each class var/method
86
- *
87
- * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy
88
- * of this software and associated documentation files (the "Software"), to deal
89
- * in the Software without restriction, including without limitation the rights
90
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
91
- * copies of the Software, and to permit persons to whom the Software is
92
- * furnished to do so, subject to the following conditions:
93
- *
94
- * The above copyright notice and this permission notice shall be included in
95
- * all copies or substantial portions of the Software.
96
- *
97
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
98
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
99
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
100
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
101
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
102
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
103
- * THE SOFTWARE.
104
- *
105
- * @category Crypt
106
- * @package Crypt_Base
107
- * @author Jim Wigginton <terrafrost@php.net>
108
- * @author Hans-Juergen Petrich <petrich@tronic-media.com>
109
- * @copyright 2007 Jim Wigginton
110
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
111
- * @link http://phpseclib.sourceforge.net
112
- */
113
-
114
- /**#@+
115
- * @access public
116
- * @see self::encrypt()
117
- * @see self::decrypt()
118
- */
119
- /**
120
- * Encrypt / decrypt using the Counter mode.
121
- *
122
- * Set to -1 since that's what Crypt/Random.php uses to index the CTR mode.
123
- *
124
- * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Counter_.28CTR.29
125
- */
126
- define('CRYPT_MODE_CTR', -1);
127
- /**
128
- * Encrypt / decrypt using the Electronic Code Book mode.
129
- *
130
- * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Electronic_codebook_.28ECB.29
131
- */
132
- define('CRYPT_MODE_ECB', 1);
133
- /**
134
- * Encrypt / decrypt using the Code Book Chaining mode.
135
- *
136
- * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29
137
- */
138
- define('CRYPT_MODE_CBC', 2);
139
- /**
140
- * Encrypt / decrypt using the Cipher Feedback mode.
141
- *
142
- * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher_feedback_.28CFB.29
143
- */
144
- define('CRYPT_MODE_CFB', 3);
145
- /**
146
- * Encrypt / decrypt using the Output Feedback mode.
147
- *
148
- * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Output_feedback_.28OFB.29
149
- */
150
- define('CRYPT_MODE_OFB', 4);
151
- /**
152
- * Encrypt / decrypt using streaming mode.
153
- */
154
- define('CRYPT_MODE_STREAM', 5);
155
- /**#@-*/
156
-
157
- /**#@+
158
- * @access private
159
- * @see self::Crypt_Base()
160
- * @internal These constants are for internal use only
161
- */
162
- /**
163
- * Base value for the internal implementation $engine switch
164
- */
165
- define('CRYPT_ENGINE_INTERNAL', 1);
166
- /**
167
- * Base value for the mcrypt implementation $engine switch
168
- */
169
- define('CRYPT_ENGINE_MCRYPT', 2);
170
- /**
171
- * Base value for the OpenSSL implementation $engine switch
172
- */
173
- define('CRYPT_ENGINE_OPENSSL', 3);
174
- /**#@-*/
175
-
176
- /**
177
- * Base Class for all Crypt_* cipher classes
178
- *
179
- * @package Crypt_Base
180
- * @author Jim Wigginton <terrafrost@php.net>
181
- * @author Hans-Juergen Petrich <petrich@tronic-media.com>
182
- * @access public
183
- */
184
- class Crypt_Base
185
- {
186
- /**
187
- * The Encryption Mode
188
- *
189
- * @see self::Crypt_Base()
190
- * @var int
191
- * @access private
192
- */
193
- var $mode;
194
-
195
- /**
196
- * The Block Length of the block cipher
197
- *
198
- * @var int
199
- * @access private
200
- */
201
- var $block_size = 16;
202
-
203
- /**
204
- * The Key
205
- *
206
- * @see self::setKey()
207
- * @var string
208
- * @access private
209
- */
210
- var $key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
211
-
212
- /**
213
- * The Initialization Vector
214
- *
215
- * @see self::setIV()
216
- * @var string
217
- * @access private
218
- */
219
- var $iv;
220
-
221
- /**
222
- * A "sliding" Initialization Vector
223
- *
224
- * @see self::enableContinuousBuffer()
225
- * @see self::_clearBuffers()
226
- * @var string
227
- * @access private
228
- */
229
- var $encryptIV;
230
-
231
- /**
232
- * A "sliding" Initialization Vector
233
- *
234
- * @see self::enableContinuousBuffer()
235
- * @see self::_clearBuffers()
236
- * @var string
237
- * @access private
238
- */
239
- var $decryptIV;
240
-
241
- /**
242
- * Continuous Buffer status
243
- *
244
- * @see self::enableContinuousBuffer()
245
- * @var bool
246
- * @access private
247
- */
248
- var $continuousBuffer = false;
249
-
250
- /**
251
- * Encryption buffer for CTR, OFB and CFB modes
252
- *
253
- * @see self::encrypt()
254
- * @see self::_clearBuffers()
255
- * @var array
256
- * @access private
257
- */
258
- var $enbuffer;
259
-
260
- /**
261
- * Decryption buffer for CTR, OFB and CFB modes
262
- *
263
- * @see self::decrypt()
264
- * @see self::_clearBuffers()
265
- * @var array
266
- * @access private
267
- */
268
- var $debuffer;
269
-
270
- /**
271
- * mcrypt resource for encryption
272
- *
273
- * The mcrypt resource can be recreated every time something needs to be created or it can be created just once.
274
- * Since mcrypt operates in continuous mode, by default, it'll need to be recreated when in non-continuous mode.
275
- *
276
- * @see self::encrypt()
277
- * @var resource
278
- * @access private
279
- */
280
- var $enmcrypt;
281
-
282
- /**
283
- * mcrypt resource for decryption
284
- *
285
- * The mcrypt resource can be recreated every time something needs to be created or it can be created just once.
286
- * Since mcrypt operates in continuous mode, by default, it'll need to be recreated when in non-continuous mode.
287
- *
288
- * @see self::decrypt()
289
- * @var resource
290
- * @access private
291
- */
292
- var $demcrypt;
293
-
294
- /**
295
- * Does the enmcrypt resource need to be (re)initialized?
296
- *
297
- * @see Crypt_Twofish::setKey()
298
- * @see Crypt_Twofish::setIV()
299
- * @var bool
300
- * @access private
301
- */
302
- var $enchanged = true;
303
-
304
- /**
305
- * Does the demcrypt resource need to be (re)initialized?
306
- *
307
- * @see Crypt_Twofish::setKey()
308
- * @see Crypt_Twofish::setIV()
309
- * @var bool
310
- * @access private
311
- */
312
- var $dechanged = true;
313
-
314
- /**
315
- * mcrypt resource for CFB mode
316
- *
317
- * mcrypt's CFB mode, in (and only in) buffered context,
318
- * is broken, so phpseclib implements the CFB mode by it self,
319
- * even when the mcrypt php extension is available.
320
- *
321
- * In order to do the CFB-mode work (fast) phpseclib
322
- * use a separate ECB-mode mcrypt resource.
323
- *
324
- * @link http://phpseclib.sourceforge.net/cfb-demo.phps
325
- * @see self::encrypt()
326
- * @see self::decrypt()
327
- * @see self::_setupMcrypt()
328
- * @var resource
329
- * @access private
330
- */
331
- var $ecb;
332
-
333
- /**
334
- * Optimizing value while CFB-encrypting
335
- *
336
- * Only relevant if $continuousBuffer enabled
337
- * and $engine == CRYPT_ENGINE_MCRYPT
338
- *
339
- * It's faster to re-init $enmcrypt if
340
- * $buffer bytes > $cfb_init_len than
341
- * using the $ecb resource furthermore.
342
- *
343
- * This value depends of the chosen cipher
344
- * and the time it would be needed for it's
345
- * initialization [by mcrypt_generic_init()]
346
- * which, typically, depends on the complexity
347
- * on its internaly Key-expanding algorithm.
348
- *
349
- * @see self::encrypt()
350
- * @var int
351
- * @access private
352
- */
353
- var $cfb_init_len = 600;
354
-
355
- /**
356
- * Does internal cipher state need to be (re)initialized?
357
- *
358
- * @see self::setKey()
359
- * @see self::setIV()
360
- * @see self::disableContinuousBuffer()
361
- * @var bool
362
- * @access private
363
- */
364
- var $changed = true;
365
-
366
- /**
367
- * Padding status
368
- *
369
- * @see self::enablePadding()
370
- * @var bool
371
- * @access private
372
- */
373
- var $padding = true;
374
-
375
- /**
376
- * Is the mode one that is paddable?
377
- *
378
- * @see self::Crypt_Base()
379
- * @var bool
380
- * @access private
381
- */
382
- var $paddable = false;
383
-
384
- /**
385
- * Holds which crypt engine internaly should be use,
386
- * which will be determined automatically on __construct()
387
- *
388
- * Currently available $engines are:
389
- * - CRYPT_ENGINE_OPENSSL (very fast, php-extension: openssl, extension_loaded('openssl') required)
390
- * - CRYPT_ENGINE_MCRYPT (fast, php-extension: mcrypt, extension_loaded('mcrypt') required)
391
- * - CRYPT_ENGINE_INTERNAL (slower, pure php-engine, no php-extension required)
392
- *
393
- * @see self::_setEngine()
394
- * @see self::encrypt()
395
- * @see self::decrypt()
396
- * @var int
397
- * @access private
398
- */
399
- var $engine;
400
-
401
- /**
402
- * Holds the preferred crypt engine
403
- *
404
- * @see self::_setEngine()
405
- * @see self::setPreferredEngine()
406
- * @var int
407
- * @access private
408
- */
409
- var $preferredEngine;
410
-
411
- /**
412
- * The mcrypt specific name of the cipher
413
- *
414
- * Only used if $engine == CRYPT_ENGINE_MCRYPT
415
- *
416
- * @link http://www.php.net/mcrypt_module_open
417
- * @link http://www.php.net/mcrypt_list_algorithms
418
- * @see self::_setupMcrypt()
419
- * @var string
420
- * @access private
421
- */
422
- var $cipher_name_mcrypt;
423
-
424
- /**
425
- * The openssl specific name of the cipher
426
- *
427
- * Only used if $engine == CRYPT_ENGINE_OPENSSL
428
- *
429
- * @link http://www.php.net/openssl-get-cipher-methods
430
- * @var string
431
- * @access private
432
- */
433
- var $cipher_name_openssl;
434
-
435
- /**
436
- * The openssl specific name of the cipher in ECB mode
437
- *
438
- * If OpenSSL does not support the mode we're trying to use (CTR)
439
- * it can still be emulated with ECB mode.
440
- *
441
- * @link http://www.php.net/openssl-get-cipher-methods
442
- * @var string
443
- * @access private
444
- */
445
- var $cipher_name_openssl_ecb;
446
-
447
- /**
448
- * The default salt used by setPassword()
449
- *
450
- * @see self::setPassword()
451
- * @var string
452
- * @access private
453
- */
454
- var $password_default_salt = 'phpseclib/salt';
455
-
456
- /**
457
- * The namespace used by the cipher for its constants.
458
- *
459
- * ie: AES.php is using CRYPT_AES_MODE_* for its constants
460
- * so $const_namespace is AES
461
- *
462
- * DES.php is using CRYPT_DES_MODE_* for its constants
463
- * so $const_namespace is DES... and so on
464
- *
465
- * All CRYPT_<$const_namespace>_MODE_* are aliases of
466
- * the generic CRYPT_MODE_* constants, so both could be used
467
- * for each cipher.
468
- *
469
- * Example:
470
- * $aes = new Crypt_AES(CRYPT_AES_MODE_CFB); // $aes will operate in cfb mode
471
- * $aes = new Crypt_AES(CRYPT_MODE_CFB); // identical
472
- *
473
- * @see self::Crypt_Base()
474
- * @var string
475
- * @access private
476
- */
477
- var $const_namespace;
478
-
479
- /**
480
- * The name of the performance-optimized callback function
481
- *
482
- * Used by encrypt() / decrypt()
483
- * only if $engine == CRYPT_ENGINE_INTERNAL
484
- *
485
- * @see self::encrypt()
486
- * @see self::decrypt()
487
- * @see self::_setupInlineCrypt()
488
- * @see self::$use_inline_crypt
489
- * @var Callback
490
- * @access private
491
- */
492
- var $inline_crypt;
493
-
494
- /**
495
- * Holds whether performance-optimized $inline_crypt() can/should be used.
496
- *
497
- * @see self::encrypt()
498
- * @see self::decrypt()
499
- * @see self::inline_crypt
500
- * @var mixed
501
- * @access private
502
- */
503
- var $use_inline_crypt;
504
-
505
- /**
506
- * If OpenSSL can be used in ECB but not in CTR we can emulate CTR
507
- *
508
- * @see self::_openssl_ctr_process()
509
- * @var bool
510
- * @access private
511
- */
512
- var $openssl_emulate_ctr = false;
513
-
514
- /**
515
- * Determines what options are passed to openssl_encrypt/decrypt
516
- *
517
- * @see self::isValidEngine()
518
- * @var mixed
519
- * @access private
520
- */
521
- var $openssl_options;
522
-
523
- /**
524
- * Has the key length explicitly been set or should it be derived from the key, itself?
525
- *
526
- * @see self::setKeyLength()
527
- * @var bool
528
- * @access private
529
- */
530
- var $explicit_key_length = false;
531
-
532
- /**
533
- * Don't truncate / null pad key
534
- *
535
- * @see self::_clearBuffers()
536
- * @var bool
537
- * @access private
538
- */
539
- var $skip_key_adjustment = false;
540
-
541
- /**
542
- * Default Constructor.
543
- *
544
- * Determines whether or not the mcrypt extension should be used.
545
- *
546
- * $mode could be:
547
- *
548
- * - CRYPT_MODE_ECB
549
- *
550
- * - CRYPT_MODE_CBC
551
- *
552
- * - CRYPT_MODE_CTR
553
- *
554
- * - CRYPT_MODE_CFB
555
- *
556
- * - CRYPT_MODE_OFB
557
- *
558
- * (or the alias constants of the chosen cipher, for example for AES: CRYPT_AES_MODE_ECB or CRYPT_AES_MODE_CBC ...)
559
- *
560
- * If not explicitly set, CRYPT_MODE_CBC will be used.
561
- *
562
- * @param int $mode
563
- * @access public
564
- */
565
- function __construct($mode = CRYPT_MODE_CBC)
566
- {
567
- // $mode dependent settings
568
- switch ($mode) {
569
- case CRYPT_MODE_ECB:
570
- $this->paddable = true;
571
- $this->mode = CRYPT_MODE_ECB;
572
- break;
573
- case CRYPT_MODE_CTR:
574
- case CRYPT_MODE_CFB:
575
- case CRYPT_MODE_OFB:
576
- case CRYPT_MODE_STREAM:
577
- $this->mode = $mode;
578
- break;
579
- case CRYPT_MODE_CBC:
580
- default:
581
- $this->paddable = true;
582
- $this->mode = CRYPT_MODE_CBC;
583
- }
584
-
585
- $this->_setEngine();
586
-
587
- // Determining whether inline crypting can be used by the cipher
588
- if ($this->use_inline_crypt !== false) {
589
- $this->use_inline_crypt = version_compare(PHP_VERSION, '5.3.0') >= 0 || function_exists('create_function');
590
- }
591
- }
592
-
593
- /**
594
- * PHP4 compatible Default Constructor.
595
- *
596
- * @see self::__construct()
597
- * @param int $mode
598
- * @access public
599
- */
600
- function Crypt_Base($mode = CRYPT_MODE_CBC)
601
- {
602
- $this->__construct($mode);
603
- }
604
-
605
- /**
606
- * Sets the initialization vector. (optional)
607
- *
608
- * SetIV is not required when CRYPT_MODE_ECB (or ie for AES: CRYPT_AES_MODE_ECB) is being used. If not explicitly set, it'll be assumed
609
- * to be all zero's.
610
- *
611
- * @access public
612
- * @param string $iv
613
- * @internal Can be overwritten by a sub class, but does not have to be
614
- */
615
- function setIV($iv)
616
- {
617
- if ($this->mode == CRYPT_MODE_ECB) {
618
- return;
619
- }
620
-
621
- $this->iv = $iv;
622
- $this->changed = true;
623
- }
624
-
625
- /**
626
- * Sets the key length.
627
- *
628
- * Keys with explicitly set lengths need to be treated accordingly
629
- *
630
- * @access public
631
- * @param int $length
632
- */
633
- function setKeyLength($length)
634
- {
635
- $this->explicit_key_length = true;
636
- $this->changed = true;
637
- $this->_setEngine();
638
- }
639
-
640
- /**
641
- * Returns the current key length in bits
642
- *
643
- * @access public
644
- * @return int
645
- */
646
- function getKeyLength()
647
- {
648
- return $this->key_length << 3;
649
- }
650
-
651
- /**
652
- * Returns the current block length in bits
653
- *
654
- * @access public
655
- * @return int
656
- */
657
- function getBlockLength()
658
- {
659
- return $this->block_size << 3;
660
- }
661
-
662
- /**
663
- * Sets the key.
664
- *
665
- * The min/max length(s) of the key depends on the cipher which is used.
666
- * If the key not fits the length(s) of the cipher it will paded with null bytes
667
- * up to the closest valid key length. If the key is more than max length,
668
- * we trim the excess bits.
669
- *
670
- * If the key is not explicitly set, it'll be assumed to be all null bytes.
671
- *
672
- * @access public
673
- * @param string $key
674
- * @internal Could, but not must, extend by the child Crypt_* class
675
- */
676
- function setKey($key)
677
- {
678
- if (!$this->explicit_key_length) {
679
- $this->setKeyLength(strlen($key) << 3);
680
- $this->explicit_key_length = false;
681
- }
682
-
683
- $this->key = $key;
684
- $this->changed = true;
685
- $this->_setEngine();
686
- }
687
-
688
- /**
689
- * Sets the password.
690
- *
691
- * Depending on what $method is set to, setPassword()'s (optional) parameters are as follows:
692
- * {@link http://en.wikipedia.org/wiki/PBKDF2 pbkdf2} or pbkdf1:
693
- * $hash, $salt, $count, $dkLen
694
- *
695
- * Where $hash (default = sha1) currently supports the following hashes: see: Crypt/Hash.php
696
- *
697
- * @see Crypt/Hash.php
698
- * @param string $password
699
- * @param string $method
700
- * @return bool
701
- * @access public
702
- * @internal Could, but not must, extend by the child Crypt_* class
703
- */
704
- function setPassword($password, $method = 'pbkdf2')
705
- {
706
- $key = '';
707
-
708
- switch ($method) {
709
- default: // 'pbkdf2' or 'pbkdf1'
710
- $func_args = func_get_args();
711
-
712
- // Hash function
713
- $hash = isset($func_args[2]) ? $func_args[2] : 'sha1';
714
-
715
- // WPA and WPA2 use the SSID as the salt
716
- $salt = isset($func_args[3]) ? $func_args[3] : $this->password_default_salt;
717
-
718
- // RFC2898#section-4.2 uses 1,000 iterations by default
719
- // WPA and WPA2 use 4,096.
720
- $count = isset($func_args[4]) ? $func_args[4] : 1000;
721
-
722
- // Keylength
723
- if (isset($func_args[5]) && $func_args[5] > 0) {
724
- $dkLen = $func_args[5];
725
- } else {
726
- $dkLen = $method == 'pbkdf1' ? 2 * $this->key_length : $this->key_length;
727
- }
728
-
729
- switch (true) {
730
- case $method == 'pbkdf1':
731
- /*
732
- if (!class_exists('Crypt_Hash')) {
733
- include_once 'Crypt/Hash.php';
734
- }
735
- */
736
- $hashObj = new Crypt_Hash();
737
- $hashObj->setHash($hash);
738
- if ($dkLen > $hashObj->getLength()) {
739
- user_error('Derived key too long');
740
- return false;
741
- }
742
- $t = $password . $salt;
743
- for ($i = 0; $i < $count; ++$i) {
744
- $t = $hashObj->hash($t);
745
- }
746
- $key = substr($t, 0, $dkLen);
747
-
748
- $this->setKey(substr($key, 0, $dkLen >> 1));
749
- $this->setIV(substr($key, $dkLen >> 1));
750
-
751
- return true;
752
- // Determining if php[>=5.5.0]'s hash_pbkdf2() function avail- and useable
753
- case !function_exists('hash_pbkdf2'):
754
- case !function_exists('hash_algos'):
755
- case !in_array($hash, hash_algos()):
756
- /*
757
- if (!class_exists('Crypt_Hash')) {
758
- include_once 'Crypt/Hash.php';
759
- }
760
- */
761
- $i = 1;
762
- $hmac = new Crypt_Hash();
763
- $hmac->setHash($hash);
764
- $hmac->setKey($password);
765
- while (strlen($key) < $dkLen) {
766
- $f = $u = $hmac->hash($salt . pack('N', $i++));
767
- for ($j = 2; $j <= $count; ++$j) {
768
- $u = $hmac->hash($u);
769
- $f^= $u;
770
- }
771
- $key.= $f;
772
- }
773
- $key = substr($key, 0, $dkLen);
774
- break;
775
- default:
776
- $key = hash_pbkdf2($hash, $password, $salt, $count, $dkLen, true);
777
- }
778
- }
779
-
780
- $this->setKey($key);
781
-
782
- return true;
783
- }
784
-
785
- /**
786
- * Encrypts a message.
787
- *
788
- * $plaintext will be padded with additional bytes such that it's length is a multiple of the block size. Other cipher
789
- * implementations may or may not pad in the same manner. Other common approaches to padding and the reasons why it's
790
- * necessary are discussed in the following
791
- * URL:
792
- *
793
- * {@link http://www.di-mgt.com.au/cryptopad.html http://www.di-mgt.com.au/cryptopad.html}
794
- *
795
- * An alternative to padding is to, separately, send the length of the file. This is what SSH, in fact, does.
796
- * strlen($plaintext) will still need to be a multiple of the block size, however, arbitrary values can be added to make it that
797
- * length.
798
- *
799
- * @see self::decrypt()
800
- * @access public
801
- * @param string $plaintext
802
- * @return string $ciphertext
803
- * @internal Could, but not must, extend by the child Crypt_* class
804
- */
805
- function encrypt($plaintext)
806
- {
807
- if ($this->paddable) {
808
- $plaintext = $this->_pad($plaintext);
809
- }
810
-
811
- if ($this->engine === CRYPT_ENGINE_OPENSSL) {
812
- if ($this->changed) {
813
- $this->_clearBuffers();
814
- $this->changed = false;
815
- }
816
- switch ($this->mode) {
817
- case CRYPT_MODE_STREAM:
818
- return openssl_encrypt($plaintext, $this->cipher_name_openssl, $this->key, $this->openssl_options);
819
- case CRYPT_MODE_ECB:
820
- $result = openssl_encrypt($plaintext, $this->cipher_name_openssl, $this->key, $this->openssl_options);
821
- return !defined('OPENSSL_RAW_DATA') ? substr($result, 0, -$this->block_size) : $result;
822
- case CRYPT_MODE_CBC:
823
- $result = openssl_encrypt($plaintext, $this->cipher_name_openssl, $this->key, $this->openssl_options, $this->encryptIV);
824
- if (!defined('OPENSSL_RAW_DATA')) {
825
- $result = substr($result, 0, -$this->block_size);
826
- }
827
- if ($this->continuousBuffer) {
828
- $this->encryptIV = substr($result, -$this->block_size);
829
- }
830
- return $result;
831
- case CRYPT_MODE_CTR:
832
- return $this->_openssl_ctr_process($plaintext, $this->encryptIV, $this->enbuffer);
833
- case CRYPT_MODE_CFB:
834
- // cfb loosely routines inspired by openssl's:
835
- // {@link http://cvs.openssl.org/fileview?f=openssl/crypto/modes/cfb128.c&v=1.3.2.2.2.1}
836
- $ciphertext = '';
837
- if ($this->continuousBuffer) {
838
- $iv = &$this->encryptIV;
839
- $pos = &$this->enbuffer['pos'];
840
- } else {
841
- $iv = $this->encryptIV;
842
- $pos = 0;
843
- }
844
- $len = strlen($plaintext);
845
- $i = 0;
846
- if ($pos) {
847
- $orig_pos = $pos;
848
- $max = $this->block_size - $pos;
849
- if ($len >= $max) {
850
- $i = $max;
851
- $len-= $max;
852
- $pos = 0;
853
- } else {
854
- $i = $len;
855
- $pos+= $len;
856
- $len = 0;
857
- }
858
- // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize
859
- $ciphertext = substr($iv, $orig_pos) ^ $plaintext;
860
- $iv = substr_replace($iv, $ciphertext, $orig_pos, $i);
861
- $plaintext = substr($plaintext, $i);
862
- }
863
-
864
- $overflow = $len % $this->block_size;
865
-
866
- if ($overflow) {
867
- $ciphertext.= openssl_encrypt(substr($plaintext, 0, -$overflow) . str_repeat("\0", $this->block_size), $this->cipher_name_openssl, $this->key, $this->openssl_options, $iv);
868
- $iv = $this->_string_pop($ciphertext, $this->block_size);
869
-
870
- $size = $len - $overflow;
871
- $block = $iv ^ substr($plaintext, -$overflow);
872
- $iv = substr_replace($iv, $block, 0, $overflow);
873
- $ciphertext.= $block;
874
- $pos = $overflow;
875
- } elseif ($len) {
876
- $ciphertext = openssl_encrypt($plaintext, $this->cipher_name_openssl, $this->key, $this->openssl_options, $iv);
877
- $iv = substr($ciphertext, -$this->block_size);
878
- }
879
-
880
- return $ciphertext;
881
- case CRYPT_MODE_OFB:
882
- return $this->_openssl_ofb_process($plaintext, $this->encryptIV, $this->enbuffer);
883
- }
884
- }
885
-
886
- if ($this->engine === CRYPT_ENGINE_MCRYPT) {
887
- if ($this->changed) {
888
- $this->_setupMcrypt();
889
- $this->changed = false;
890
- }
891
- if ($this->enchanged) {
892
- @mcrypt_generic_init($this->enmcrypt, $this->key, $this->encryptIV);
893
- $this->enchanged = false;
894
- }
895
-
896
- // re: {@link http://phpseclib.sourceforge.net/cfb-demo.phps}
897
- // using mcrypt's default handing of CFB the above would output two different things. using phpseclib's
898
- // rewritten CFB implementation the above outputs the same thing twice.
899
- if ($this->mode == CRYPT_MODE_CFB && $this->continuousBuffer) {
900
- $block_size = $this->block_size;
901
- $iv = &$this->encryptIV;
902
- $pos = &$this->enbuffer['pos'];
903
- $len = strlen($plaintext);
904
- $ciphertext = '';
905
- $i = 0;
906
- if ($pos) {
907
- $orig_pos = $pos;
908
- $max = $block_size - $pos;
909
- if ($len >= $max) {
910
- $i = $max;
911
- $len-= $max;
912
- $pos = 0;
913
- } else {
914
- $i = $len;
915
- $pos+= $len;
916
- $len = 0;
917
- }
918
- $ciphertext = substr($iv, $orig_pos) ^ $plaintext;
919
- $iv = substr_replace($iv, $ciphertext, $orig_pos, $i);
920
- $this->enbuffer['enmcrypt_init'] = true;
921
- }
922
- if ($len >= $block_size) {
923
- if ($this->enbuffer['enmcrypt_init'] === false || $len > $this->cfb_init_len) {
924
- if ($this->enbuffer['enmcrypt_init'] === true) {
925
- @mcrypt_generic_init($this->enmcrypt, $this->key, $iv);
926
- $this->enbuffer['enmcrypt_init'] = false;
927
- }
928
- $ciphertext.= @mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % $block_size));
929
- $iv = substr($ciphertext, -$block_size);
930
- $len%= $block_size;
931
- } else {
932
- while ($len >= $block_size) {
933
- $iv = @mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, $block_size);
934
- $ciphertext.= $iv;
935
- $len-= $block_size;
936
- $i+= $block_size;
937
- }
938
- }
939
- }
940
-
941
- if ($len) {
942
- $iv = @mcrypt_generic($this->ecb, $iv);
943
- $block = $iv ^ substr($plaintext, -$len);
944
- $iv = substr_replace($iv, $block, 0, $len);
945
- $ciphertext.= $block;
946
- $pos = $len;
947
- }
948
-
949
- return $ciphertext;
950
- }
951
-
952
- $ciphertext = @mcrypt_generic($this->enmcrypt, $plaintext);
953
-
954
- if (!$this->continuousBuffer) {
955
- @mcrypt_generic_init($this->enmcrypt, $this->key, $this->encryptIV);
956
- }
957
-
958
- return $ciphertext;
959
- }
960
-
961
- if ($this->changed) {
962
- $this->_setup();
963
- $this->changed = false;
964
- }
965
- if ($this->use_inline_crypt) {
966
- $inline = $this->inline_crypt;
967
- return $inline('encrypt', $this, $plaintext);
968
- }
969
-
970
- $buffer = &$this->enbuffer;
971
- $block_size = $this->block_size;
972
- $ciphertext = '';
973
- switch ($this->mode) {
974
- case CRYPT_MODE_ECB:
975
- for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
976
- $ciphertext.= $this->_encryptBlock(substr($plaintext, $i, $block_size));
977
- }
978
- break;
979
- case CRYPT_MODE_CBC:
980
- $xor = $this->encryptIV;
981
- for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
982
- $block = substr($plaintext, $i, $block_size);
983
- $block = $this->_encryptBlock($block ^ $xor);
984
- $xor = $block;
985
- $ciphertext.= $block;
986
- }
987
- if ($this->continuousBuffer) {
988
- $this->encryptIV = $xor;
989
- }
990
- break;
991
- case CRYPT_MODE_CTR:
992
- $xor = $this->encryptIV;
993
- if (strlen($buffer['ciphertext'])) {
994
- for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
995
- $block = substr($plaintext, $i, $block_size);
996
- if (strlen($block) > strlen($buffer['ciphertext'])) {
997
- $buffer['ciphertext'].= $this->_encryptBlock($xor);
998
- }
999
- $this->_increment_str($xor);
1000
- $key = $this->_string_shift($buffer['ciphertext'], $block_size);
1001
- $ciphertext.= $block ^ $key;
1002
- }
1003
- } else {
1004
- for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
1005
- $block = substr($plaintext, $i, $block_size);
1006
- $key = $this->_encryptBlock($xor);
1007
- $this->_increment_str($xor);
1008
- $ciphertext.= $block ^ $key;
1009
- }
1010
- }
1011
- if ($this->continuousBuffer) {
1012
- $this->encryptIV = $xor;
1013
- if ($start = strlen($plaintext) % $block_size) {
1014
- $buffer['ciphertext'] = substr($key, $start) . $buffer['ciphertext'];
1015
- }
1016
- }
1017
- break;
1018
- case CRYPT_MODE_CFB:
1019
- // cfb loosely routines inspired by openssl's:
1020
- // {@link http://cvs.openssl.org/fileview?f=openssl/crypto/modes/cfb128.c&v=1.3.2.2.2.1}
1021
- if ($this->continuousBuffer) {
1022
- $iv = &$this->encryptIV;
1023
- $pos = &$buffer['pos'];
1024
- } else {
1025
- $iv = $this->encryptIV;
1026
- $pos = 0;
1027
- }
1028
- $len = strlen($plaintext);
1029
- $i = 0;
1030
- if ($pos) {
1031
- $orig_pos = $pos;
1032
- $max = $block_size - $pos;
1033
- if ($len >= $max) {
1034
- $i = $max;
1035
- $len-= $max;
1036
- $pos = 0;
1037
- } else {
1038
- $i = $len;
1039
- $pos+= $len;
1040
- $len = 0;
1041
- }
1042
- // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize
1043
- $ciphertext = substr($iv, $orig_pos) ^ $plaintext;
1044
- $iv = substr_replace($iv, $ciphertext, $orig_pos, $i);
1045
- }
1046
- while ($len >= $block_size) {
1047
- $iv = $this->_encryptBlock($iv) ^ substr($plaintext, $i, $block_size);
1048
- $ciphertext.= $iv;
1049
- $len-= $block_size;
1050
- $i+= $block_size;
1051
- }
1052
- if ($len) {
1053
- $iv = $this->_encryptBlock($iv);
1054
- $block = $iv ^ substr($plaintext, $i);
1055
- $iv = substr_replace($iv, $block, 0, $len);
1056
- $ciphertext.= $block;
1057
- $pos = $len;
1058
- }
1059
- break;
1060
- case CRYPT_MODE_OFB:
1061
- $xor = $this->encryptIV;
1062
- if (strlen($buffer['xor'])) {
1063
- for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
1064
- $block = substr($plaintext, $i, $block_size);
1065
- if (strlen($block) > strlen($buffer['xor'])) {
1066
- $xor = $this->_encryptBlock($xor);
1067
- $buffer['xor'].= $xor;
1068
- }
1069
- $key = $this->_string_shift($buffer['xor'], $block_size);
1070
- $ciphertext.= $block ^ $key;
1071
- }
1072
- } else {
1073
- for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
1074
- $xor = $this->_encryptBlock($xor);
1075
- $ciphertext.= substr($plaintext, $i, $block_size) ^ $xor;
1076
- }
1077
- $key = $xor;
1078
- }
1079
- if ($this->continuousBuffer) {
1080
- $this->encryptIV = $xor;
1081
- if ($start = strlen($plaintext) % $block_size) {
1082
- $buffer['xor'] = substr($key, $start) . $buffer['xor'];
1083
- }
1084
- }
1085
- break;
1086
- case CRYPT_MODE_STREAM:
1087
- $ciphertext = $this->_encryptBlock($plaintext);
1088
- break;
1089
- }
1090
-
1091
- return $ciphertext;
1092
- }
1093
-
1094
- /**
1095
- * Decrypts a message.
1096
- *
1097
- * If strlen($ciphertext) is not a multiple of the block size, null bytes will be added to the end of the string until
1098
- * it is.
1099
- *
1100
- * @see self::encrypt()
1101
- * @access public
1102
- * @param string $ciphertext
1103
- * @return string $plaintext
1104
- * @internal Could, but not must, extend by the child Crypt_* class
1105
- */
1106
- function decrypt($ciphertext)
1107
- {
1108
- if ($this->paddable) {
1109
- // we pad with chr(0) since that's what mcrypt_generic does. to quote from {@link http://www.php.net/function.mcrypt-generic}:
1110
- // "The data is padded with "\0" to make sure the length of the data is n * blocksize."
1111
- $ciphertext = str_pad($ciphertext, strlen($ciphertext) + ($this->block_size - strlen($ciphertext) % $this->block_size) % $this->block_size, chr(0));
1112
- }
1113
-
1114
- if ($this->engine === CRYPT_ENGINE_OPENSSL) {
1115
- if ($this->changed) {
1116
- $this->_clearBuffers();
1117
- $this->changed = false;
1118
- }
1119
- switch ($this->mode) {
1120
- case CRYPT_MODE_STREAM:
1121
- $plaintext = openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, $this->openssl_options);
1122
- break;
1123
- case CRYPT_MODE_ECB:
1124
- if (!defined('OPENSSL_RAW_DATA')) {
1125
- $ciphertext.= openssl_encrypt('', $this->cipher_name_openssl_ecb, $this->key, true);
1126
- }
1127
- $plaintext = openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, $this->openssl_options);
1128
- break;
1129
- case CRYPT_MODE_CBC:
1130
- if (!defined('OPENSSL_RAW_DATA')) {
1131
- $padding = str_repeat(chr($this->block_size), $this->block_size) ^ substr($ciphertext, -$this->block_size);
1132
- $ciphertext.= substr(openssl_encrypt($padding, $this->cipher_name_openssl_ecb, $this->key, true), 0, $this->block_size);
1133
- $offset = 2 * $this->block_size;
1134
- } else {
1135
- $offset = $this->block_size;
1136
- }
1137
- $plaintext = openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, $this->openssl_options, $this->decryptIV);
1138
- if ($this->continuousBuffer) {
1139
- $this->decryptIV = substr($ciphertext, -$offset, $this->block_size);
1140
- }
1141
- break;
1142
- case CRYPT_MODE_CTR:
1143
- $plaintext = $this->_openssl_ctr_process($ciphertext, $this->decryptIV, $this->debuffer);
1144
- break;
1145
- case CRYPT_MODE_CFB:
1146
- // cfb loosely routines inspired by openssl's:
1147
- // {@link http://cvs.openssl.org/fileview?f=openssl/crypto/modes/cfb128.c&v=1.3.2.2.2.1}
1148
- $plaintext = '';
1149
- if ($this->continuousBuffer) {
1150
- $iv = &$this->decryptIV;
1151
- $pos = &$this->buffer['pos'];
1152
- } else {
1153
- $iv = $this->decryptIV;
1154
- $pos = 0;
1155
- }
1156
- $len = strlen($ciphertext);
1157
- $i = 0;
1158
- if ($pos) {
1159
- $orig_pos = $pos;
1160
- $max = $this->block_size - $pos;
1161
- if ($len >= $max) {
1162
- $i = $max;
1163
- $len-= $max;
1164
- $pos = 0;
1165
- } else {
1166
- $i = $len;
1167
- $pos+= $len;
1168
- $len = 0;
1169
- }
1170
- // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $this->blocksize
1171
- $plaintext = substr($iv, $orig_pos) ^ $ciphertext;
1172
- $iv = substr_replace($iv, substr($ciphertext, 0, $i), $orig_pos, $i);
1173
- $ciphertext = substr($ciphertext, $i);
1174
- }
1175
- $overflow = $len % $this->block_size;
1176
- if ($overflow) {
1177
- $plaintext.= openssl_decrypt(substr($ciphertext, 0, -$overflow), $this->cipher_name_openssl, $this->key, $this->openssl_options, $iv);
1178
- if ($len - $overflow) {
1179
- $iv = substr($ciphertext, -$overflow - $this->block_size, -$overflow);
1180
- }
1181
- $iv = openssl_encrypt(str_repeat("\0", $this->block_size), $this->cipher_name_openssl, $this->key, $this->openssl_options, $iv);
1182
- $plaintext.= $iv ^ substr($ciphertext, -$overflow);
1183
- $iv = substr_replace($iv, substr($ciphertext, -$overflow), 0, $overflow);
1184
- $pos = $overflow;
1185
- } elseif ($len) {
1186
- $plaintext.= openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, $this->openssl_options, $iv);
1187
- $iv = substr($ciphertext, -$this->block_size);
1188
- }
1189
- break;
1190
- case CRYPT_MODE_OFB:
1191
- $plaintext = $this->_openssl_ofb_process($ciphertext, $this->decryptIV, $this->debuffer);
1192
- }
1193
-
1194
- return $this->paddable ? $this->_unpad($plaintext) : $plaintext;
1195
- }
1196
-
1197
- if ($this->engine === CRYPT_ENGINE_MCRYPT) {
1198
- $block_size = $this->block_size;
1199
- if ($this->changed) {
1200
- $this->_setupMcrypt();
1201
- $this->changed = false;
1202
- }
1203
- if ($this->dechanged) {
1204
- @mcrypt_generic_init($this->demcrypt, $this->key, $this->decryptIV);
1205
- $this->dechanged = false;
1206
- }
1207
-
1208
- if ($this->mode == CRYPT_MODE_CFB && $this->continuousBuffer) {
1209
- $iv = &$this->decryptIV;
1210
- $pos = &$this->debuffer['pos'];
1211
- $len = strlen($ciphertext);
1212
- $plaintext = '';
1213
- $i = 0;
1214
- if ($pos) {
1215
- $orig_pos = $pos;
1216
- $max = $block_size - $pos;
1217
- if ($len >= $max) {
1218
- $i = $max;
1219
- $len-= $max;
1220
- $pos = 0;
1221
- } else {
1222
- $i = $len;
1223
- $pos+= $len;
1224
- $len = 0;
1225
- }
1226
- // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize
1227
- $plaintext = substr($iv, $orig_pos) ^ $ciphertext;
1228
- $iv = substr_replace($iv, substr($ciphertext, 0, $i), $orig_pos, $i);
1229
- }
1230
- if ($len >= $block_size) {
1231
- $cb = substr($ciphertext, $i, $len - $len % $block_size);
1232
- $plaintext.= @mcrypt_generic($this->ecb, $iv . $cb) ^ $cb;
1233
- $iv = substr($cb, -$block_size);
1234
- $len%= $block_size;
1235
- }
1236
- if ($len) {
1237
- $iv = @mcrypt_generic($this->ecb, $iv);
1238
- $plaintext.= $iv ^ substr($ciphertext, -$len);
1239
- $iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len);
1240
- $pos = $len;
1241
- }
1242
-
1243
- return $plaintext;
1244
- }
1245
-
1246
- $plaintext = @mdecrypt_generic($this->demcrypt, $ciphertext);
1247
-
1248
- if (!$this->continuousBuffer) {
1249
- @mcrypt_generic_init($this->demcrypt, $this->key, $this->decryptIV);
1250
- }
1251
-
1252
- return $this->paddable ? $this->_unpad($plaintext) : $plaintext;
1253
- }
1254
-
1255
- if ($this->changed) {
1256
- $this->_setup();
1257
- $this->changed = false;
1258
- }
1259
- if ($this->use_inline_crypt) {
1260
- $inline = $this->inline_crypt;
1261
- return $inline('decrypt', $this, $ciphertext);
1262
- }
1263
-
1264
- $block_size = $this->block_size;
1265
-
1266
- $buffer = &$this->debuffer;
1267
- $plaintext = '';
1268
- switch ($this->mode) {
1269
- case CRYPT_MODE_ECB:
1270
- for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
1271
- $plaintext.= $this->_decryptBlock(substr($ciphertext, $i, $block_size));
1272
- }
1273
- break;
1274
- case CRYPT_MODE_CBC:
1275
- $xor = $this->decryptIV;
1276
- for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
1277
- $block = substr($ciphertext, $i, $block_size);
1278
- $plaintext.= $this->_decryptBlock($block) ^ $xor;
1279
- $xor = $block;
1280
- }
1281
- if ($this->continuousBuffer) {
1282
- $this->decryptIV = $xor;
1283
- }
1284
- break;
1285
- case CRYPT_MODE_CTR:
1286
- $xor = $this->decryptIV;
1287
- if (strlen($buffer['ciphertext'])) {
1288
- for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
1289
- $block = substr($ciphertext, $i, $block_size);
1290
- if (strlen($block) > strlen($buffer['ciphertext'])) {
1291
- $buffer['ciphertext'].= $this->_encryptBlock($xor);
1292
- $this->_increment_str($xor);
1293
- }
1294
- $key = $this->_string_shift($buffer['ciphertext'], $block_size);
1295
- $plaintext.= $block ^ $key;
1296
- }
1297
- } else {
1298
- for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
1299
- $block = substr($ciphertext, $i, $block_size);
1300
- $key = $this->_encryptBlock($xor);
1301
- $this->_increment_str($xor);
1302
- $plaintext.= $block ^ $key;
1303
- }
1304
- }
1305
- if ($this->continuousBuffer) {
1306
- $this->decryptIV = $xor;
1307
- if ($start = strlen($ciphertext) % $block_size) {
1308
- $buffer['ciphertext'] = substr($key, $start) . $buffer['ciphertext'];
1309
- }
1310
- }
1311
- break;
1312
- case CRYPT_MODE_CFB:
1313
- if ($this->continuousBuffer) {
1314
- $iv = &$this->decryptIV;
1315
- $pos = &$buffer['pos'];
1316
- } else {
1317
- $iv = $this->decryptIV;
1318
- $pos = 0;
1319
- }
1320
- $len = strlen($ciphertext);
1321
- $i = 0;
1322
- if ($pos) {
1323
- $orig_pos = $pos;
1324
- $max = $block_size - $pos;
1325
- if ($len >= $max) {
1326
- $i = $max;
1327
- $len-= $max;
1328
- $pos = 0;
1329
- } else {
1330
- $i = $len;
1331
- $pos+= $len;
1332
- $len = 0;
1333
- }
1334
- // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize
1335
- $plaintext = substr($iv, $orig_pos) ^ $ciphertext;
1336
- $iv = substr_replace($iv, substr($ciphertext, 0, $i), $orig_pos, $i);
1337
- }
1338
- while ($len >= $block_size) {
1339
- $iv = $this->_encryptBlock($iv);
1340
- $cb = substr($ciphertext, $i, $block_size);
1341
- $plaintext.= $iv ^ $cb;
1342
- $iv = $cb;
1343
- $len-= $block_size;
1344
- $i+= $block_size;
1345
- }
1346
- if ($len) {
1347
- $iv = $this->_encryptBlock($iv);
1348
- $plaintext.= $iv ^ substr($ciphertext, $i);
1349
- $iv = substr_replace($iv, substr($ciphertext, $i), 0, $len);
1350
- $pos = $len;
1351
- }
1352
- break;
1353
- case CRYPT_MODE_OFB:
1354
- $xor = $this->decryptIV;
1355
- if (strlen($buffer['xor'])) {
1356
- for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
1357
- $block = substr($ciphertext, $i, $block_size);
1358
- if (strlen($block) > strlen($buffer['xor'])) {
1359
- $xor = $this->_encryptBlock($xor);
1360
- $buffer['xor'].= $xor;
1361
- }
1362
- $key = $this->_string_shift($buffer['xor'], $block_size);
1363
- $plaintext.= $block ^ $key;
1364
- }
1365
- } else {
1366
- for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
1367
- $xor = $this->_encryptBlock($xor);
1368
- $plaintext.= substr($ciphertext, $i, $block_size) ^ $xor;
1369
- }
1370
- $key = $xor;
1371
- }
1372
- if ($this->continuousBuffer) {
1373
- $this->decryptIV = $xor;
1374
- if ($start = strlen($ciphertext) % $block_size) {
1375
- $buffer['xor'] = substr($key, $start) . $buffer['xor'];
1376
- }
1377
- }
1378
- break;
1379
- case CRYPT_MODE_STREAM:
1380
- $plaintext = $this->_decryptBlock($ciphertext);
1381
- break;
1382
- }
1383
- return $this->paddable ? $this->_unpad($plaintext) : $plaintext;
1384
- }
1385
-
1386
- /**
1387
- * OpenSSL CTR Processor
1388
- *
1389
- * PHP's OpenSSL bindings do not operate in continuous mode so we'll wrap around it. Since the keystream
1390
- * for CTR is the same for both encrypting and decrypting this function is re-used by both Crypt_Base::encrypt()
1391
- * and Crypt_Base::decrypt(). Also, OpenSSL doesn't implement CTR for all of it's symmetric ciphers so this
1392
- * function will emulate CTR with ECB when necessary.
1393
- *
1394
- * @see self::encrypt()
1395
- * @see self::decrypt()
1396
- * @param string $plaintext
1397
- * @param string $encryptIV
1398
- * @param array $buffer
1399
- * @return string
1400
- * @access private
1401
- */
1402
- function _openssl_ctr_process($plaintext, &$encryptIV, &$buffer)
1403
- {
1404
- $ciphertext = '';
1405
-
1406
- $block_size = $this->block_size;
1407
- $key = $this->key;
1408
-
1409
- if ($this->openssl_emulate_ctr) {
1410
- $xor = $encryptIV;
1411
- if (strlen($buffer['ciphertext'])) {
1412
- for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
1413
- $block = substr($plaintext, $i, $block_size);
1414
- if (strlen($block) > strlen($buffer['ciphertext'])) {
1415
- $result = openssl_encrypt($xor, $this->cipher_name_openssl_ecb, $key, $this->openssl_options);
1416
- $result = !defined('OPENSSL_RAW_DATA') ? substr($result, 0, -$this->block_size) : $result;
1417
- $buffer['ciphertext'].= $result;
1418
- }
1419
- $this->_increment_str($xor);
1420
- $otp = $this->_string_shift($buffer['ciphertext'], $block_size);
1421
- $ciphertext.= $block ^ $otp;
1422
- }
1423
- } else {
1424
- for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
1425
- $block = substr($plaintext, $i, $block_size);
1426
- $otp = openssl_encrypt($xor, $this->cipher_name_openssl_ecb, $key, $this->openssl_options);
1427
- $otp = !defined('OPENSSL_RAW_DATA') ? substr($otp, 0, -$this->block_size) : $otp;
1428
- $this->_increment_str($xor);
1429
- $ciphertext.= $block ^ $otp;
1430
- }
1431
- }
1432
- if ($this->continuousBuffer) {
1433
- $encryptIV = $xor;
1434
- if ($start = strlen($plaintext) % $block_size) {
1435
- $buffer['ciphertext'] = substr($key, $start) . $buffer['ciphertext'];
1436
- }
1437
- }
1438
-
1439
- return $ciphertext;
1440
- }
1441
-
1442
- if (strlen($buffer['ciphertext'])) {
1443
- $ciphertext = $plaintext ^ $this->_string_shift($buffer['ciphertext'], strlen($plaintext));
1444
- $plaintext = substr($plaintext, strlen($ciphertext));
1445
-
1446
- if (!strlen($plaintext)) {
1447
- return $ciphertext;
1448
- }
1449
- }
1450
-
1451
- $overflow = strlen($plaintext) % $block_size;
1452
- if ($overflow) {
1453
- $plaintext2 = $this->_string_pop($plaintext, $overflow); // ie. trim $plaintext to a multiple of $block_size and put rest of $plaintext in $plaintext2
1454
- $encrypted = openssl_encrypt($plaintext . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, $this->openssl_options, $encryptIV);
1455
- $temp = $this->_string_pop($encrypted, $block_size);
1456
- $ciphertext.= $encrypted . ($plaintext2 ^ $temp);
1457
- if ($this->continuousBuffer) {
1458
- $buffer['ciphertext'] = substr($temp, $overflow);
1459
- $encryptIV = $temp;
1460
- }
1461
- } elseif (!strlen($buffer['ciphertext'])) {
1462
- $ciphertext.= openssl_encrypt($plaintext . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, $this->openssl_options, $encryptIV);
1463
- $temp = $this->_string_pop($ciphertext, $block_size);
1464
- if ($this->continuousBuffer) {
1465
- $encryptIV = $temp;
1466
- }
1467
- }
1468
- if ($this->continuousBuffer) {
1469
- if (!defined('OPENSSL_RAW_DATA')) {
1470
- $encryptIV.= openssl_encrypt('', $this->cipher_name_openssl_ecb, $key, $this->openssl_options);
1471
- }
1472
- $encryptIV = openssl_decrypt($encryptIV, $this->cipher_name_openssl_ecb, $key, $this->openssl_options);
1473
- if ($overflow) {
1474
- $this->_increment_str($encryptIV);
1475
- }
1476
- }
1477
-
1478
- return $ciphertext;
1479
- }
1480
-
1481
- /**
1482
- * OpenSSL OFB Processor
1483
- *
1484
- * PHP's OpenSSL bindings do not operate in continuous mode so we'll wrap around it. Since the keystream
1485
- * for OFB is the same for both encrypting and decrypting this function is re-used by both Crypt_Base::encrypt()
1486
- * and Crypt_Base::decrypt().
1487
- *
1488
- * @see self::encrypt()
1489
- * @see self::decrypt()
1490
- * @param string $plaintext
1491
- * @param string $encryptIV
1492
- * @param array $buffer
1493
- * @return string
1494
- * @access private
1495
- */
1496
- function _openssl_ofb_process($plaintext, &$encryptIV, &$buffer)
1497
- {
1498
- if (strlen($buffer['xor'])) {
1499
- $ciphertext = $plaintext ^ $buffer['xor'];
1500
- $buffer['xor'] = substr($buffer['xor'], strlen($ciphertext));
1501
- $plaintext = substr($plaintext, strlen($ciphertext));
1502
- } else {
1503
- $ciphertext = '';
1504
- }
1505
-
1506
- $block_size = $this->block_size;
1507
-
1508
- $len = strlen($plaintext);
1509
- $key = $this->key;
1510
- $overflow = $len % $block_size;
1511
-
1512
- if (strlen($plaintext)) {
1513
- if ($overflow) {
1514
- $ciphertext.= openssl_encrypt(substr($plaintext, 0, -$overflow) . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, $this->openssl_options, $encryptIV);
1515
- $xor = $this->_string_pop($ciphertext, $block_size);
1516
- if ($this->continuousBuffer) {
1517
- $encryptIV = $xor;
1518
- }
1519
- $ciphertext.= $this->_string_shift($xor, $overflow) ^ substr($plaintext, -$overflow);
1520
- if ($this->continuousBuffer) {
1521
- $buffer['xor'] = $xor;
1522
- }
1523
- } else {
1524
- $ciphertext = openssl_encrypt($plaintext, $this->cipher_name_openssl, $key, $this->openssl_options, $encryptIV);
1525
- if ($this->continuousBuffer) {
1526
- $encryptIV = substr($ciphertext, -$block_size) ^ substr($plaintext, -$block_size);
1527
- }
1528
- }
1529
- }
1530
-
1531
- return $ciphertext;
1532
- }
1533
-
1534
- /**
1535
- * phpseclib <-> OpenSSL Mode Mapper
1536
- *
1537
- * May need to be overwritten by classes extending this one in some cases
1538
- *
1539
- * @return int
1540
- * @access private
1541
- */
1542
- function _openssl_translate_mode()
1543
- {
1544
- switch ($this->mode) {
1545
- case CRYPT_MODE_ECB:
1546
- return 'ecb';
1547
- case CRYPT_MODE_CBC:
1548
- return 'cbc';
1549
- case CRYPT_MODE_CTR:
1550
- return 'ctr';
1551
- case CRYPT_MODE_CFB:
1552
- return 'cfb';
1553
- case CRYPT_MODE_OFB:
1554
- return 'ofb';
1555
- }
1556
- }
1557
-
1558
- /**
1559
- * Pad "packets".
1560
- *
1561
- * Block ciphers working by encrypting between their specified [$this->]block_size at a time
1562
- * If you ever need to encrypt or decrypt something that isn't of the proper length, it becomes necessary to
1563
- * pad the input so that it is of the proper length.
1564
- *
1565
- * Padding is enabled by default. Sometimes, however, it is undesirable to pad strings. Such is the case in SSH,
1566
- * where "packets" are padded with random bytes before being encrypted. Unpad these packets and you risk stripping
1567
- * away characters that shouldn't be stripped away. (SSH knows how many bytes are added because the length is
1568
- * transmitted separately)
1569
- *
1570
- * @see self::disablePadding()
1571
- * @access public
1572
- */
1573
- function enablePadding()
1574
- {
1575
- $this->padding = true;
1576
- }
1577
-
1578
- /**
1579
- * Do not pad packets.
1580
- *
1581
- * @see self::enablePadding()
1582
- * @access public
1583
- */
1584
- function disablePadding()
1585
- {
1586
- $this->padding = false;
1587
- }
1588
-
1589
- /**
1590
- * Treat consecutive "packets" as if they are a continuous buffer.
1591
- *
1592
- * Say you have a 32-byte plaintext $plaintext. Using the default behavior, the two following code snippets
1593
- * will yield different outputs:
1594
- *
1595
- * <code>
1596
- * echo $rijndael->encrypt(substr($plaintext, 0, 16));
1597
- * echo $rijndael->encrypt(substr($plaintext, 16, 16));
1598
- * </code>
1599
- * <code>
1600
- * echo $rijndael->encrypt($plaintext);
1601
- * </code>
1602
- *
1603
- * The solution is to enable the continuous buffer. Although this will resolve the above discrepancy, it creates
1604
- * another, as demonstrated with the following:
1605
- *
1606
- * <code>
1607
- * $rijndael->encrypt(substr($plaintext, 0, 16));
1608
- * echo $rijndael->decrypt($rijndael->encrypt(substr($plaintext, 16, 16)));
1609
- * </code>
1610
- * <code>
1611
- * echo $rijndael->decrypt($rijndael->encrypt(substr($plaintext, 16, 16)));
1612
- * </code>
1613
- *
1614
- * With the continuous buffer disabled, these would yield the same output. With it enabled, they yield different
1615
- * outputs. The reason is due to the fact that the initialization vector's change after every encryption /
1616
- * decryption round when the continuous buffer is enabled. When it's disabled, they remain constant.
1617
- *
1618
- * Put another way, when the continuous buffer is enabled, the state of the Crypt_*() object changes after each
1619
- * encryption / decryption round, whereas otherwise, it'd remain constant. For this reason, it's recommended that
1620
- * continuous buffers not be used. They do offer better security and are, in fact, sometimes required (SSH uses them),
1621
- * however, they are also less intuitive and more likely to cause you problems.
1622
- *
1623
- * @see self::disableContinuousBuffer()
1624
- * @access public
1625
- * @internal Could, but not must, extend by the child Crypt_* class
1626
- */
1627
- function enableContinuousBuffer()
1628
- {
1629
- if ($this->mode == CRYPT_MODE_ECB) {
1630
- return;
1631
- }
1632
-
1633
- $this->continuousBuffer = true;
1634
-
1635
- $this->_setEngine();
1636
- }
1637
-
1638
- /**
1639
- * Treat consecutive packets as if they are a discontinuous buffer.
1640
- *
1641
- * The default behavior.
1642
- *
1643
- * @see self::enableContinuousBuffer()
1644
- * @access public
1645
- * @internal Could, but not must, extend by the child Crypt_* class
1646
- */
1647
- function disableContinuousBuffer()
1648
- {
1649
- if ($this->mode == CRYPT_MODE_ECB) {
1650
- return;
1651
- }
1652
- if (!$this->continuousBuffer) {
1653
- return;
1654
- }
1655
-
1656
- $this->continuousBuffer = false;
1657
- $this->changed = true;
1658
-
1659
- $this->_setEngine();
1660
- }
1661
-
1662
- /**
1663
- * Test for engine validity
1664
- *
1665
- * @see self::Crypt_Base()
1666
- * @param int $engine
1667
- * @access public
1668
- * @return bool
1669
- */
1670
- function isValidEngine($engine)
1671
- {
1672
- switch ($engine) {
1673
- case CRYPT_ENGINE_OPENSSL:
1674
- if ($this->mode == CRYPT_MODE_STREAM && $this->continuousBuffer) {
1675
- return false;
1676
- }
1677
- $this->openssl_emulate_ctr = false;
1678
- $result = $this->cipher_name_openssl &&
1679
- extension_loaded('openssl') &&
1680
- // PHP 5.3.0 - 5.3.2 did not let you set IV's
1681
- version_compare(PHP_VERSION, '5.3.3', '>=');
1682
- if (!$result) {
1683
- return false;
1684
- }
1685
-
1686
- // prior to PHP 5.4.0 OPENSSL_RAW_DATA and OPENSSL_ZERO_PADDING were not defined. instead of expecting an integer
1687
- // $options openssl_encrypt expected a boolean $raw_data.
1688
- if (!defined('OPENSSL_RAW_DATA')) {
1689
- $this->openssl_options = true;
1690
- } else {
1691
- $this->openssl_options = OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING;
1692
- }
1693
-
1694
- $methods = openssl_get_cipher_methods();
1695
- if (in_array($this->cipher_name_openssl, $methods)) {
1696
- return true;
1697
- }
1698
- // not all of openssl's symmetric cipher's support ctr. for those
1699
- // that don't we'll emulate it
1700
- switch ($this->mode) {
1701
- case CRYPT_MODE_CTR:
1702
- if (in_array($this->cipher_name_openssl_ecb, $methods)) {
1703
- $this->openssl_emulate_ctr = true;
1704
- return true;
1705
- }
1706
- }
1707
- return false;
1708
- case CRYPT_ENGINE_MCRYPT:
1709
- return $this->cipher_name_mcrypt &&
1710
- extension_loaded('mcrypt') &&
1711
- in_array($this->cipher_name_mcrypt, @mcrypt_list_algorithms());
1712
- case CRYPT_ENGINE_INTERNAL:
1713
- return true;
1714
- }
1715
-
1716
- return false;
1717
- }
1718
-
1719
- /**
1720
- * Sets the preferred crypt engine
1721
- *
1722
- * Currently, $engine could be:
1723
- *
1724
- * - CRYPT_ENGINE_OPENSSL [very fast]
1725
- *
1726
- * - CRYPT_ENGINE_MCRYPT [fast]
1727
- *
1728
- * - CRYPT_ENGINE_INTERNAL [slow]
1729
- *
1730
- * If the preferred crypt engine is not available the fastest available one will be used
1731
- *
1732
- * @see self::Crypt_Base()
1733
- * @param int $engine
1734
- * @access public
1735
- */
1736
- function setPreferredEngine($engine)
1737
- {
1738
- switch ($engine) {
1739
- //case CRYPT_ENGINE_OPENSSL:
1740
- case CRYPT_ENGINE_MCRYPT:
1741
- case CRYPT_ENGINE_INTERNAL:
1742
- $this->preferredEngine = $engine;
1743
- break;
1744
- default:
1745
- $this->preferredEngine = CRYPT_ENGINE_OPENSSL;
1746
- }
1747
-
1748
- $this->_setEngine();
1749
- }
1750
-
1751
- /**
1752
- * Returns the engine currently being utilized
1753
- *
1754
- * @see self::_setEngine()
1755
- * @access public
1756
- */
1757
- function getEngine()
1758
- {
1759
- return $this->engine;
1760
- }
1761
-
1762
- /**
1763
- * Sets the engine as appropriate
1764
- *
1765
- * @see self::Crypt_Base()
1766
- * @access private
1767
- */
1768
- function _setEngine()
1769
- {
1770
- $this->engine = null;
1771
-
1772
- $candidateEngines = array(
1773
- $this->preferredEngine,
1774
- CRYPT_ENGINE_OPENSSL,
1775
- CRYPT_ENGINE_MCRYPT
1776
- );
1777
- foreach ($candidateEngines as $engine) {
1778
- if ($this->isValidEngine($engine)) {
1779
- $this->engine = $engine;
1780
- break;
1781
- }
1782
- }
1783
- if (!$this->engine) {
1784
- $this->engine = CRYPT_ENGINE_INTERNAL;
1785
- }
1786
-
1787
- if ($this->engine != CRYPT_ENGINE_MCRYPT && $this->enmcrypt) {
1788
- // Closing the current mcrypt resource(s). _mcryptSetup() will, if needed,
1789
- // (re)open them with the module named in $this->cipher_name_mcrypt
1790
- @mcrypt_module_close($this->enmcrypt);
1791
- @mcrypt_module_close($this->demcrypt);
1792
- $this->enmcrypt = null;
1793
- $this->demcrypt = null;
1794
-
1795
- if ($this->ecb) {
1796
- @mcrypt_module_close($this->ecb);
1797
- $this->ecb = null;
1798
- }
1799
- }
1800
-
1801
- $this->changed = true;
1802
- }
1803
-
1804
- /**
1805
- * Encrypts a block
1806
- *
1807
- * @access private
1808
- * @param string $in
1809
- * @return string
1810
- * @internal Must be extended by the child Crypt_* class
1811
- */
1812
- function _encryptBlock($in)
1813
- {
1814
- user_error((version_compare(PHP_VERSION, '5.0.0', '>=') ? __METHOD__ : __FUNCTION__) . '() must extend by class ' . get_class($this), E_USER_ERROR);
1815
- }
1816
-
1817
- /**
1818
- * Decrypts a block
1819
- *
1820
- * @access private
1821
- * @param string $in
1822
- * @return string
1823
- * @internal Must be extended by the child Crypt_* class
1824
- */
1825
- function _decryptBlock($in)
1826
- {
1827
- user_error((version_compare(PHP_VERSION, '5.0.0', '>=') ? __METHOD__ : __FUNCTION__) . '() must extend by class ' . get_class($this), E_USER_ERROR);
1828
- }
1829
-
1830
- /**
1831
- * Setup the key (expansion)
1832
- *
1833
- * Only used if $engine == CRYPT_ENGINE_INTERNAL
1834
- *
1835
- * @see self::_setup()
1836
- * @access private
1837
- * @internal Must be extended by the child Crypt_* class
1838
- */
1839
- function _setupKey()
1840
- {
1841
- user_error((version_compare(PHP_VERSION, '5.0.0', '>=') ? __METHOD__ : __FUNCTION__) . '() must extend by class ' . get_class($this), E_USER_ERROR);
1842
- }
1843
-
1844
- /**
1845
- * Setup the CRYPT_ENGINE_INTERNAL $engine
1846
- *
1847
- * (re)init, if necessary, the internal cipher $engine and flush all $buffers
1848
- * Used (only) if $engine == CRYPT_ENGINE_INTERNAL
1849
- *
1850
- * _setup() will be called each time if $changed === true
1851
- * typically this happens when using one or more of following public methods:
1852
- *
1853
- * - setKey()
1854
- *
1855
- * - setIV()
1856
- *
1857
- * - disableContinuousBuffer()
1858
- *
1859
- * - First run of encrypt() / decrypt() with no init-settings
1860
- *
1861
- * @see self::setKey()
1862
- * @see self::setIV()
1863
- * @see self::disableContinuousBuffer()
1864
- * @access private
1865
- * @internal _setup() is always called before en/decryption.
1866
- * @internal Could, but not must, extend by the child Crypt_* class
1867
- */
1868
- function _setup()
1869
- {
1870
- $this->_clearBuffers();
1871
- $this->_setupKey();
1872
-
1873
- if ($this->use_inline_crypt) {
1874
- $this->_setupInlineCrypt();
1875
- }
1876
- }
1877
-
1878
- /**
1879
- * Setup the CRYPT_ENGINE_MCRYPT $engine
1880
- *
1881
- * (re)init, if necessary, the (ext)mcrypt resources and flush all $buffers
1882
- * Used (only) if $engine = CRYPT_ENGINE_MCRYPT
1883
- *
1884
- * _setupMcrypt() will be called each time if $changed === true
1885
- * typically this happens when using one or more of following public methods:
1886
- *
1887
- * - setKey()
1888
- *
1889
- * - setIV()
1890
- *
1891
- * - disableContinuousBuffer()
1892
- *
1893
- * - First run of encrypt() / decrypt()
1894
- *
1895
- * @see self::setKey()
1896
- * @see self::setIV()
1897
- * @see self::disableContinuousBuffer()
1898
- * @access private
1899
- * @internal Could, but not must, extend by the child Crypt_* class
1900
- */
1901
- function _setupMcrypt()
1902
- {
1903
- $this->_clearBuffers();
1904
- $this->enchanged = $this->dechanged = true;
1905
-
1906
- if (!isset($this->enmcrypt)) {
1907
- static $mcrypt_modes = array(
1908
- CRYPT_MODE_CTR => 'ctr',
1909
- CRYPT_MODE_ECB => MCRYPT_MODE_ECB,
1910
- CRYPT_MODE_CBC => MCRYPT_MODE_CBC,
1911
- CRYPT_MODE_CFB => 'ncfb',
1912
- CRYPT_MODE_OFB => MCRYPT_MODE_NOFB,
1913
- CRYPT_MODE_STREAM => MCRYPT_MODE_STREAM,
1914
- );
1915
-
1916
- $this->demcrypt = @mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], '');
1917
- $this->enmcrypt = @mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], '');
1918
-
1919
- // we need the $ecb mcrypt resource (only) in MODE_CFB with enableContinuousBuffer()
1920
- // to workaround mcrypt's broken ncfb implementation in buffered mode
1921
- // see: {@link http://phpseclib.sourceforge.net/cfb-demo.phps}
1922
- if ($this->mode == CRYPT_MODE_CFB) {
1923
- $this->ecb = @mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, '');
1924
- }
1925
- } // else should mcrypt_generic_deinit be called?
1926
-
1927
- if ($this->mode == CRYPT_MODE_CFB) {
1928
- @mcrypt_generic_init($this->ecb, $this->key, str_repeat("\0", $this->block_size));
1929
- }
1930
- }
1931
-
1932
- /**
1933
- * Pads a string
1934
- *
1935
- * Pads a string using the RSA PKCS padding standards so that its length is a multiple of the blocksize.
1936
- * $this->block_size - (strlen($text) % $this->block_size) bytes are added, each of which is equal to
1937
- * chr($this->block_size - (strlen($text) % $this->block_size)
1938
- *
1939
- * If padding is disabled and $text is not a multiple of the blocksize, the string will be padded regardless
1940
- * and padding will, hence forth, be enabled.
1941
- *
1942
- * @see self::_unpad()
1943
- * @param string $text
1944
- * @access private
1945
- * @return string
1946
- */
1947
- function _pad($text)
1948
- {
1949
- $length = strlen($text);
1950
-
1951
- if (!$this->padding) {
1952
- if ($length % $this->block_size == 0) {
1953
- return $text;
1954
- } else {
1955
- user_error("The plaintext's length ($length) is not a multiple of the block size ({$this->block_size})");
1956
- $this->padding = true;
1957
- }
1958
- }
1959
-
1960
- $pad = $this->block_size - ($length % $this->block_size);
1961
-
1962
- return str_pad($text, $length + $pad, chr($pad));
1963
- }
1964
-
1965
- /**
1966
- * Unpads a string.
1967
- *
1968
- * If padding is enabled and the reported padding length is invalid the encryption key will be assumed to be wrong
1969
- * and false will be returned.
1970
- *
1971
- * @see self::_pad()
1972
- * @param string $text
1973
- * @access private
1974
- * @return string
1975
- */
1976
- function _unpad($text)
1977
- {
1978
- if (!$this->padding) {
1979
- return $text;
1980
- }
1981
-
1982
- $length = ord($text[strlen($text) - 1]);
1983
-
1984
- if (!$length || $length > $this->block_size) {
1985
- return false;
1986
- }
1987
-
1988
- return substr($text, 0, -$length);
1989
- }
1990
-
1991
- /**
1992
- * Clears internal buffers
1993
- *
1994
- * Clearing/resetting the internal buffers is done everytime
1995
- * after disableContinuousBuffer() or on cipher $engine (re)init
1996
- * ie after setKey() or setIV()
1997
- *
1998
- * @access public
1999
- * @internal Could, but not must, extend by the child Crypt_* class
2000
- */
2001
- function _clearBuffers()
2002
- {
2003
- $this->enbuffer = $this->debuffer = array('ciphertext' => '', 'xor' => '', 'pos' => 0, 'enmcrypt_init' => true);
2004
-
2005
- // mcrypt's handling of invalid's $iv:
2006
- // $this->encryptIV = $this->decryptIV = strlen($this->iv) == $this->block_size ? $this->iv : str_repeat("\0", $this->block_size);
2007
- $this->encryptIV = $this->decryptIV = str_pad(substr($this->iv, 0, $this->block_size), $this->block_size, "\0");
2008
-
2009
- if (!$this->skip_key_adjustment) {
2010
- $this->key = str_pad(substr($this->key, 0, $this->key_length), $this->key_length, "\0");
2011
- }
2012
- }
2013
-
2014
- /**
2015
- * String Shift
2016
- *
2017
- * Inspired by array_shift
2018
- *
2019
- * @param string $string
2020
- * @param int $index
2021
- * @access private
2022
- * @return string
2023
- */
2024
- function _string_shift(&$string, $index = 1)
2025
- {
2026
- $substr = substr($string, 0, $index);
2027
- $string = substr($string, $index);
2028
- return $substr;
2029
- }
2030
-
2031
- /**
2032
- * String Pop
2033
- *
2034
- * Inspired by array_pop
2035
- *
2036
- * @param string $string
2037
- * @param int $index
2038
- * @access private
2039
- * @return string
2040
- */
2041
- function _string_pop(&$string, $index = 1)
2042
- {
2043
- $substr = substr($string, -$index);
2044
- $string = substr($string, 0, -$index);
2045
- return $substr;
2046
- }
2047
-
2048
- /**
2049
- * Increment the current string
2050
- *
2051
- * @see self::decrypt()
2052
- * @see self::encrypt()
2053
- * @param string $var
2054
- * @access private
2055
- */
2056
- function _increment_str(&$var)
2057
- {
2058
- for ($i = 4; $i <= strlen($var); $i+= 4) {
2059
- $temp = substr($var, -$i, 4);
2060
- switch ($temp) {
2061
- case "\xFF\xFF\xFF\xFF":
2062
- $var = substr_replace($var, "\x00\x00\x00\x00", -$i, 4);
2063
- break;
2064
- case "\x7F\xFF\xFF\xFF":
2065
- $var = substr_replace($var, "\x80\x00\x00\x00", -$i, 4);
2066
- return;
2067
- default:
2068
- $temp = unpack('Nnum', $temp);
2069
- $var = substr_replace($var, pack('N', $temp['num'] + 1), -$i, 4);
2070
- return;
2071
- }
2072
- }
2073
-
2074
- $remainder = strlen($var) % 4;
2075
-
2076
- if ($remainder == 0) {
2077
- return;
2078
- }
2079
-
2080
- $temp = unpack('Nnum', str_pad(substr($var, 0, $remainder), 4, "\0", STR_PAD_LEFT));
2081
- $temp = substr(pack('N', $temp['num'] + 1), -$remainder);
2082
- $var = substr_replace($var, $temp, 0, $remainder);
2083
- }
2084
-
2085
- /**
2086
- * Setup the performance-optimized function for de/encrypt()
2087
- *
2088
- * Stores the created (or existing) callback function-name
2089
- * in $this->inline_crypt
2090
- *
2091
- * Internally for phpseclib developers:
2092
- *
2093
- * _setupInlineCrypt() would be called only if:
2094
- *
2095
- * - $engine == CRYPT_ENGINE_INTERNAL and
2096
- *
2097
- * - $use_inline_crypt === true
2098
- *
2099
- * - each time on _setup(), after(!) _setupKey()
2100
- *
2101
- *
2102
- * This ensures that _setupInlineCrypt() has always a
2103
- * full ready2go initializated internal cipher $engine state
2104
- * where, for example, the keys allready expanded,
2105
- * keys/block_size calculated and such.
2106
- *
2107
- * It is, each time if called, the responsibility of _setupInlineCrypt():
2108
- *
2109
- * - to set $this->inline_crypt to a valid and fully working callback function
2110
- * as a (faster) replacement for encrypt() / decrypt()
2111
- *
2112
- * - NOT to create unlimited callback functions (for memory reasons!)
2113
- * no matter how often _setupInlineCrypt() would be called. At some
2114
- * point of amount they must be generic re-useable.
2115
- *
2116
- * - the code of _setupInlineCrypt() it self,
2117
- * and the generated callback code,
2118
- * must be, in following order:
2119
- * - 100% safe
2120
- * - 100% compatible to encrypt()/decrypt()
2121
- * - using only php5+ features/lang-constructs/php-extensions if
2122
- * compatibility (down to php4) or fallback is provided
2123
- * - readable/maintainable/understandable/commented and... not-cryptic-styled-code :-)
2124
- * - >= 10% faster than encrypt()/decrypt() [which is, by the way,
2125
- * the reason for the existence of _setupInlineCrypt() :-)]
2126
- * - memory-nice
2127
- * - short (as good as possible)
2128
- *
2129
- * Note: - _setupInlineCrypt() is using _createInlineCryptFunction() to create the full callback function code.
2130
- * - In case of using inline crypting, _setupInlineCrypt() must extend by the child Crypt_* class.
2131
- * - The following variable names are reserved:
2132
- * - $_* (all variable names prefixed with an underscore)
2133
- * - $self (object reference to it self. Do not use $this, but $self instead)
2134
- * - $in (the content of $in has to en/decrypt by the generated code)
2135
- * - The callback function should not use the 'return' statement, but en/decrypt'ing the content of $in only
2136
- *
2137
- *
2138
- * @see self::_setup()
2139
- * @see self::_createInlineCryptFunction()
2140
- * @see self::encrypt()
2141
- * @see self::decrypt()
2142
- * @access private
2143
- * @internal If a Crypt_* class providing inline crypting it must extend _setupInlineCrypt()
2144
- */
2145
- function _setupInlineCrypt()
2146
- {
2147
- // If, for any reason, an extending Crypt_Base() Crypt_* class
2148
- // not using inline crypting then it must be ensured that: $this->use_inline_crypt = false
2149
- // ie in the class var declaration of $use_inline_crypt in general for the Crypt_* class,
2150
- // in the constructor at object instance-time
2151
- // or, if it's runtime-specific, at runtime
2152
-
2153
- $this->use_inline_crypt = false;
2154
- }
2155
-
2156
- /**
2157
- * Creates the performance-optimized function for en/decrypt()
2158
- *
2159
- * Internally for phpseclib developers:
2160
- *
2161
- * _createInlineCryptFunction():
2162
- *
2163
- * - merge the $cipher_code [setup'ed by _setupInlineCrypt()]
2164
- * with the current [$this->]mode of operation code
2165
- *
2166
- * - create the $inline function, which called by encrypt() / decrypt()
2167
- * as its replacement to speed up the en/decryption operations.
2168
- *
2169
- * - return the name of the created $inline callback function
2170
- *
2171
- * - used to speed up en/decryption
2172
- *
2173
- *
2174
- *
2175
- * The main reason why can speed up things [up to 50%] this way are:
2176
- *
2177
- * - using variables more effective then regular.
2178
- * (ie no use of expensive arrays but integers $k_0, $k_1 ...
2179
- * or even, for example, the pure $key[] values hardcoded)
2180
- *
2181
- * - avoiding 1000's of function calls of ie _encryptBlock()
2182
- * but inlining the crypt operations.
2183
- * in the mode of operation for() loop.
2184
- *
2185
- * - full loop unroll the (sometimes key-dependent) rounds
2186
- * avoiding this way ++$i counters and runtime-if's etc...
2187
- *
2188
- * The basic code architectur of the generated $inline en/decrypt()
2189
- * lambda function, in pseudo php, is:
2190
- *
2191
- * <code>
2192
- * +----------------------------------------------------------------------------------------------+
2193
- * | callback $inline = create_function: |
2194
- * | lambda_function_0001_crypt_ECB($action, $text) |
2195
- * | { |
2196
- * | INSERT PHP CODE OF: |
2197
- * | $cipher_code['init_crypt']; // general init code. |
2198
- * | // ie: $sbox'es declarations used for |
2199
- * | // encrypt and decrypt'ing. |
2200
- * | |
2201
- * | switch ($action) { |
2202
- * | case 'encrypt': |
2203
- * | INSERT PHP CODE OF: |
2204
- * | $cipher_code['init_encrypt']; // encrypt sepcific init code. |
2205
- * | ie: specified $key or $box |
2206
- * | declarations for encrypt'ing. |
2207
- * | |
2208
- * | foreach ($ciphertext) { |
2209
- * | $in = $block_size of $ciphertext; |
2210
- * | |
2211
- * | INSERT PHP CODE OF: |
2212
- * | $cipher_code['encrypt_block']; // encrypt's (string) $in, which is always: |
2213
- * | // strlen($in) == $this->block_size |
2214
- * | // here comes the cipher algorithm in action |
2215
- * | // for encryption. |
2216
- * | // $cipher_code['encrypt_block'] has to |
2217
- * | // encrypt the content of the $in variable |
2218
- * | |
2219
- * | $plaintext .= $in; |
2220
- * | } |
2221
- * | return $plaintext; |
2222
- * | |
2223
- * | case 'decrypt': |
2224
- * | INSERT PHP CODE OF: |
2225
- * | $cipher_code['init_decrypt']; // decrypt sepcific init code |
2226
- * | ie: specified $key or $box |
2227
- * | declarations for decrypt'ing. |
2228
- * | foreach ($plaintext) { |
2229
- * | $in = $block_size of $plaintext; |
2230
- * | |
2231
- * | INSERT PHP CODE OF: |
2232
- * | $cipher_code['decrypt_block']; // decrypt's (string) $in, which is always |
2233
- * | // strlen($in) == $this->block_size |
2234
- * | // here comes the cipher algorithm in action |
2235
- * | // for decryption. |
2236
- * | // $cipher_code['decrypt_block'] has to |
2237
- * | // decrypt the content of the $in variable |
2238
- * | $ciphertext .= $in; |
2239
- * | } |
2240
- * | return $ciphertext; |
2241
- * | } |
2242
- * | } |
2243
- * +----------------------------------------------------------------------------------------------+
2244
- * </code>
2245
- *
2246
- * See also the Crypt_*::_setupInlineCrypt()'s for
2247
- * productive inline $cipher_code's how they works.
2248
- *
2249
- * Structure of:
2250
- * <code>
2251
- * $cipher_code = array(
2252
- * 'init_crypt' => (string) '', // optional
2253
- * 'init_encrypt' => (string) '', // optional
2254
- * 'init_decrypt' => (string) '', // optional
2255
- * 'encrypt_block' => (string) '', // required
2256
- * 'decrypt_block' => (string) '' // required
2257
- * );
2258
- * </code>
2259
- *
2260
- * @see self::_setupInlineCrypt()
2261
- * @see self::encrypt()
2262
- * @see self::decrypt()
2263
- * @param array $cipher_code
2264
- * @access private
2265
- * @return string (the name of the created callback function)
2266
- */
2267
- function _createInlineCryptFunction($cipher_code)
2268
- {
2269
- $block_size = $this->block_size;
2270
-
2271
- // optional
2272
- $init_crypt = isset($cipher_code['init_crypt']) ? $cipher_code['init_crypt'] : '';
2273
- $init_encrypt = isset($cipher_code['init_encrypt']) ? $cipher_code['init_encrypt'] : '';
2274
- $init_decrypt = isset($cipher_code['init_decrypt']) ? $cipher_code['init_decrypt'] : '';
2275
- // required
2276
- $encrypt_block = $cipher_code['encrypt_block'];
2277
- $decrypt_block = $cipher_code['decrypt_block'];
2278
-
2279
- // Generating mode of operation inline code,
2280
- // merged with the $cipher_code algorithm
2281
- // for encrypt- and decryption.
2282
- switch ($this->mode) {
2283
- case CRYPT_MODE_ECB:
2284
- $encrypt = $init_encrypt . '
2285
- $_ciphertext = "";
2286
- $_plaintext_len = strlen($_text);
2287
-
2288
- for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') {
2289
- $in = substr($_text, $_i, '.$block_size.');
2290
- '.$encrypt_block.'
2291
- $_ciphertext.= $in;
2292
- }
2293
-
2294
- return $_ciphertext;
2295
- ';
2296
-
2297
- $decrypt = $init_decrypt . '
2298
- $_plaintext = "";
2299
- $_text = str_pad($_text, strlen($_text) + ('.$block_size.' - strlen($_text) % '.$block_size.') % '.$block_size.', chr(0));
2300
- $_ciphertext_len = strlen($_text);
2301
-
2302
- for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') {
2303
- $in = substr($_text, $_i, '.$block_size.');
2304
- '.$decrypt_block.'
2305
- $_plaintext.= $in;
2306
- }
2307
-
2308
- return $self->_unpad($_plaintext);
2309
- ';
2310
- break;
2311
- case CRYPT_MODE_CTR:
2312
- $encrypt = $init_encrypt . '
2313
- $_ciphertext = "";
2314
- $_plaintext_len = strlen($_text);
2315
- $_xor = $self->encryptIV;
2316
- $_buffer = &$self->enbuffer;
2317
- if (strlen($_buffer["ciphertext"])) {
2318
- for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') {
2319
- $_block = substr($_text, $_i, '.$block_size.');
2320
- if (strlen($_block) > strlen($_buffer["ciphertext"])) {
2321
- $in = $_xor;
2322
- '.$encrypt_block.'
2323
- $self->_increment_str($_xor);
2324
- $_buffer["ciphertext"].= $in;
2325
- }
2326
- $_key = $self->_string_shift($_buffer["ciphertext"], '.$block_size.');
2327
- $_ciphertext.= $_block ^ $_key;
2328
- }
2329
- } else {
2330
- for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') {
2331
- $_block = substr($_text, $_i, '.$block_size.');
2332
- $in = $_xor;
2333
- '.$encrypt_block.'
2334
- $self->_increment_str($_xor);
2335
- $_key = $in;
2336
- $_ciphertext.= $_block ^ $_key;
2337
- }
2338
- }
2339
- if ($self->continuousBuffer) {
2340
- $self->encryptIV = $_xor;
2341
- if ($_start = $_plaintext_len % '.$block_size.') {
2342
- $_buffer["ciphertext"] = substr($_key, $_start) . $_buffer["ciphertext"];
2343
- }
2344
- }
2345
-
2346
- return $_ciphertext;
2347
- ';
2348
-
2349
- $decrypt = $init_encrypt . '
2350
- $_plaintext = "";
2351
- $_ciphertext_len = strlen($_text);
2352
- $_xor = $self->decryptIV;
2353
- $_buffer = &$self->debuffer;
2354
-
2355
- if (strlen($_buffer["ciphertext"])) {
2356
- for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') {
2357
- $_block = substr($_text, $_i, '.$block_size.');
2358
- if (strlen($_block) > strlen($_buffer["ciphertext"])) {
2359
- $in = $_xor;
2360
- '.$encrypt_block.'
2361
- $self->_increment_str($_xor);
2362
- $_buffer["ciphertext"].= $in;
2363
- }
2364
- $_key = $self->_string_shift($_buffer["ciphertext"], '.$block_size.');
2365
- $_plaintext.= $_block ^ $_key;
2366
- }
2367
- } else {
2368
- for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') {
2369
- $_block = substr($_text, $_i, '.$block_size.');
2370
- $in = $_xor;
2371
- '.$encrypt_block.'
2372
- $self->_increment_str($_xor);
2373
- $_key = $in;
2374
- $_plaintext.= $_block ^ $_key;
2375
- }
2376
- }
2377
- if ($self->continuousBuffer) {
2378
- $self->decryptIV = $_xor;
2379
- if ($_start = $_ciphertext_len % '.$block_size.') {
2380
- $_buffer["ciphertext"] = substr($_key, $_start) . $_buffer["ciphertext"];
2381
- }
2382
- }
2383
-
2384
- return $_plaintext;
2385
- ';
2386
- break;
2387
- case CRYPT_MODE_CFB:
2388
- $encrypt = $init_encrypt . '
2389
- $_ciphertext = "";
2390
- $_buffer = &$self->enbuffer;
2391
-
2392
- if ($self->continuousBuffer) {
2393
- $_iv = &$self->encryptIV;
2394
- $_pos = &$_buffer["pos"];
2395
- } else {
2396
- $_iv = $self->encryptIV;
2397
- $_pos = 0;
2398
- }
2399
- $_len = strlen($_text);
2400
- $_i = 0;
2401
- if ($_pos) {
2402
- $_orig_pos = $_pos;
2403
- $_max = '.$block_size.' - $_pos;
2404
- if ($_len >= $_max) {
2405
- $_i = $_max;
2406
- $_len-= $_max;
2407
- $_pos = 0;
2408
- } else {
2409
- $_i = $_len;
2410
- $_pos+= $_len;
2411
- $_len = 0;
2412
- }
2413
- $_ciphertext = substr($_iv, $_orig_pos) ^ $_text;
2414
- $_iv = substr_replace($_iv, $_ciphertext, $_orig_pos, $_i);
2415
- }
2416
- while ($_len >= '.$block_size.') {
2417
- $in = $_iv;
2418
- '.$encrypt_block.';
2419
- $_iv = $in ^ substr($_text, $_i, '.$block_size.');
2420
- $_ciphertext.= $_iv;
2421
- $_len-= '.$block_size.';
2422
- $_i+= '.$block_size.';
2423
- }
2424
- if ($_len) {
2425
- $in = $_iv;
2426
- '.$encrypt_block.'
2427
- $_iv = $in;
2428
- $_block = $_iv ^ substr($_text, $_i);
2429
- $_iv = substr_replace($_iv, $_block, 0, $_len);
2430
- $_ciphertext.= $_block;
2431
- $_pos = $_len;
2432
- }
2433
- return $_ciphertext;
2434
- ';
2435
-
2436
- $decrypt = $init_encrypt . '
2437
- $_plaintext = "";
2438
- $_buffer = &$self->debuffer;
2439
-
2440
- if ($self->continuousBuffer) {
2441
- $_iv = &$self->decryptIV;
2442
- $_pos = &$_buffer["pos"];
2443
- } else {
2444
- $_iv = $self->decryptIV;
2445
- $_pos = 0;
2446
- }
2447
- $_len = strlen($_text);
2448
- $_i = 0;
2449
- if ($_pos) {
2450
- $_orig_pos = $_pos;
2451
- $_max = '.$block_size.' - $_pos;
2452
- if ($_len >= $_max) {
2453
- $_i = $_max;
2454
- $_len-= $_max;
2455
- $_pos = 0;
2456
- } else {
2457
- $_i = $_len;
2458
- $_pos+= $_len;
2459
- $_len = 0;
2460
- }
2461
- $_plaintext = substr($_iv, $_orig_pos) ^ $_text;
2462
- $_iv = substr_replace($_iv, substr($_text, 0, $_i), $_orig_pos, $_i);
2463
- }
2464
- while ($_len >= '.$block_size.') {
2465
- $in = $_iv;
2466
- '.$encrypt_block.'
2467
- $_iv = $in;
2468
- $cb = substr($_text, $_i, '.$block_size.');
2469
- $_plaintext.= $_iv ^ $cb;
2470
- $_iv = $cb;
2471
- $_len-= '.$block_size.';
2472
- $_i+= '.$block_size.';
2473
- }
2474
- if ($_len) {
2475
- $in = $_iv;
2476
- '.$encrypt_block.'
2477
- $_iv = $in;
2478
- $_plaintext.= $_iv ^ substr($_text, $_i);
2479
- $_iv = substr_replace($_iv, substr($_text, $_i), 0, $_len);
2480
- $_pos = $_len;
2481
- }
2482
-
2483
- return $_plaintext;
2484
- ';
2485
- break;
2486
- case CRYPT_MODE_OFB:
2487
- $encrypt = $init_encrypt . '
2488
- $_ciphertext = "";
2489
- $_plaintext_len = strlen($_text);
2490
- $_xor = $self->encryptIV;
2491
- $_buffer = &$self->enbuffer;
2492
-
2493
- if (strlen($_buffer["xor"])) {
2494
- for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') {
2495
- $_block = substr($_text, $_i, '.$block_size.');
2496
- if (strlen($_block) > strlen($_buffer["xor"])) {
2497
- $in = $_xor;
2498
- '.$encrypt_block.'
2499
- $_xor = $in;
2500
- $_buffer["xor"].= $_xor;
2501
- }
2502
- $_key = $self->_string_shift($_buffer["xor"], '.$block_size.');
2503
- $_ciphertext.= $_block ^ $_key;
2504
- }
2505
- } else {
2506
- for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') {
2507
- $in = $_xor;
2508
- '.$encrypt_block.'
2509
- $_xor = $in;
2510
- $_ciphertext.= substr($_text, $_i, '.$block_size.') ^ $_xor;
2511
- }
2512
- $_key = $_xor;
2513
- }
2514
- if ($self->continuousBuffer) {
2515
- $self->encryptIV = $_xor;
2516
- if ($_start = $_plaintext_len % '.$block_size.') {
2517
- $_buffer["xor"] = substr($_key, $_start) . $_buffer["xor"];
2518
- }
2519
- }
2520
- return $_ciphertext;
2521
- ';
2522
-
2523
- $decrypt = $init_encrypt . '
2524
- $_plaintext = "";
2525
- $_ciphertext_len = strlen($_text);
2526
- $_xor = $self->decryptIV;
2527
- $_buffer = &$self->debuffer;
2528
-
2529
- if (strlen($_buffer["xor"])) {
2530
- for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') {
2531
- $_block = substr($_text, $_i, '.$block_size.');
2532
- if (strlen($_block) > strlen($_buffer["xor"])) {
2533
- $in = $_xor;
2534
- '.$encrypt_block.'
2535
- $_xor = $in;
2536
- $_buffer["xor"].= $_xor;
2537
- }
2538
- $_key = $self->_string_shift($_buffer["xor"], '.$block_size.');
2539
- $_plaintext.= $_block ^ $_key;
2540
- }
2541
- } else {
2542
- for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') {
2543
- $in = $_xor;
2544
- '.$encrypt_block.'
2545
- $_xor = $in;
2546
- $_plaintext.= substr($_text, $_i, '.$block_size.') ^ $_xor;
2547
- }
2548
- $_key = $_xor;
2549
- }
2550
- if ($self->continuousBuffer) {
2551
- $self->decryptIV = $_xor;
2552
- if ($_start = $_ciphertext_len % '.$block_size.') {
2553
- $_buffer["xor"] = substr($_key, $_start) . $_buffer["xor"];
2554
- }
2555
- }
2556
- return $_plaintext;
2557
- ';
2558
- break;
2559
- case CRYPT_MODE_STREAM:
2560
- $encrypt = $init_encrypt . '
2561
- $_ciphertext = "";
2562
- '.$encrypt_block.'
2563
- return $_ciphertext;
2564
- ';
2565
- $decrypt = $init_decrypt . '
2566
- $_plaintext = "";
2567
- '.$decrypt_block.'
2568
- return $_plaintext;
2569
- ';
2570
- break;
2571
- // case CRYPT_MODE_CBC:
2572
- default:
2573
- $encrypt = $init_encrypt . '
2574
- $_ciphertext = "";
2575
- $_plaintext_len = strlen($_text);
2576
-
2577
- $in = $self->encryptIV;
2578
-
2579
- for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') {
2580
- $in = substr($_text, $_i, '.$block_size.') ^ $in;
2581
- '.$encrypt_block.'
2582
- $_ciphertext.= $in;
2583
- }
2584
-
2585
- if ($self->continuousBuffer) {
2586
- $self->encryptIV = $in;
2587
- }
2588
-
2589
- return $_ciphertext;
2590
- ';
2591
-
2592
- $decrypt = $init_decrypt . '
2593
- $_plaintext = "";
2594
- $_text = str_pad($_text, strlen($_text) + ('.$block_size.' - strlen($_text) % '.$block_size.') % '.$block_size.', chr(0));
2595
- $_ciphertext_len = strlen($_text);
2596
-
2597
- $_iv = $self->decryptIV;
2598
-
2599
- for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') {
2600
- $in = $_block = substr($_text, $_i, '.$block_size.');
2601
- '.$decrypt_block.'
2602
- $_plaintext.= $in ^ $_iv;
2603
- $_iv = $_block;
2604
- }
2605
-
2606
- if ($self->continuousBuffer) {
2607
- $self->decryptIV = $_iv;
2608
- }
2609
-
2610
- return $self->_unpad($_plaintext);
2611
- ';
2612
- break;
2613
- }
2614
-
2615
- // Create the $inline function and return its name as string. Ready to run!
2616
- if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
2617
- eval('$func = function ($_action, &$self, $_text) { ' . $init_crypt . 'if ($_action == "encrypt") { ' . $encrypt . ' } else { ' . $decrypt . ' } };');
2618
- return $func;
2619
- }
2620
-
2621
- return create_function('$_action, &$self, $_text', $init_crypt . 'if ($_action == "encrypt") { ' . $encrypt . ' } else { ' . $decrypt . ' }');
2622
- }
2623
-
2624
- /**
2625
- * Holds the lambda_functions table (classwide)
2626
- *
2627
- * Each name of the lambda function, created from
2628
- * _setupInlineCrypt() && _createInlineCryptFunction()
2629
- * is stored, classwide (!), here for reusing.
2630
- *
2631
- * The string-based index of $function is a classwide
2632
- * unique value representing, at least, the $mode of
2633
- * operation (or more... depends of the optimizing level)
2634
- * for which $mode the lambda function was created.
2635
- *
2636
- * @access private
2637
- * @return array &$functions
2638
- */
2639
- function &_getLambdaFunctions()
2640
- {
2641
- static $functions = array();
2642
- return $functions;
2643
- }
2644
-
2645
- /**
2646
- * Generates a digest from $bytes
2647
- *
2648
- * @see self::_setupInlineCrypt()
2649
- * @access private
2650
- * @param $bytes
2651
- * @return string
2652
- */
2653
- function _hashInlineCryptFunction($bytes)
2654
- {
2655
- if (!defined('CRYPT_BASE_WHIRLPOOL_AVAILABLE')) {
2656
- define('CRYPT_BASE_WHIRLPOOL_AVAILABLE', (bool)(extension_loaded('hash') && in_array('whirlpool', hash_algos())));
2657
- }
2658
-
2659
- $result = '';
2660
- $hash = $bytes;
2661
-
2662
- switch (true) {
2663
- case CRYPT_BASE_WHIRLPOOL_AVAILABLE:
2664
- foreach (str_split($bytes, 64) as $t) {
2665
- $hash = hash('whirlpool', $hash, true);
2666
- $result .= $t ^ $hash;
2667
- }
2668
- return $result . hash('whirlpool', $hash, true);
2669
- default:
2670
- $len = strlen($bytes);
2671
- for ($i = 0; $i < $len; $i+=20) {
2672
- $t = substr($bytes, $i, 20);
2673
- $hash = pack('H*', sha1($hash));
2674
- $result .= $t ^ $hash;
2675
- }
2676
- return $result . pack('H*', sha1($hash));
2677
- }
2678
- }
2679
-
2680
- /**
2681
- * Convert float to int
2682
- *
2683
- * On 32-bit Linux installs running PHP < 5.3 converting floats to ints doesn't always work
2684
- *
2685
- * @access private
2686
- * @param string $x
2687
- * @return int
2688
- */
2689
- function safe_intval($x)
2690
- {
2691
- switch (true) {
2692
- case is_int($x):
2693
- // PHP 5.3, per http://php.net/releases/5_3_0.php, introduced "more consistent float rounding"
2694
- case version_compare(PHP_VERSION, '5.3.0') >= 0 && (php_uname('m') & "\xDF\xDF\xDF") != 'ARM':
2695
- // PHP_OS & "\xDF\xDF\xDF" == strtoupper(substr(PHP_OS, 0, 3)), but a lot faster
2696
- case (PHP_OS & "\xDF\xDF\xDF") === 'WIN':
2697
- return $x;
2698
- }
2699
- return (fmod($x, 0x80000000) & 0x7FFFFFFF) |
2700
- ((fmod(floor($x / 0x80000000), 2) & 1) << 31);
2701
- }
2702
-
2703
- /**
2704
- * eval()'able string for in-line float to int
2705
- *
2706
- * @access private
2707
- * @return string
2708
- */
2709
- function safe_intval_inline()
2710
- {
2711
- // on 32-bit linux systems with PHP < 5.3 float to integer conversion is bad
2712
- switch (true) {
2713
- case defined('PHP_INT_SIZE') && PHP_INT_SIZE == 8:
2714
- case version_compare(PHP_VERSION, '5.3.0') >= 0 && (php_uname('m') & "\xDF\xDF\xDF") != 'ARM':
2715
- case (PHP_OS & "\xDF\xDF\xDF") === 'WIN':
2716
- return '%s';
2717
- break;
2718
- default:
2719
- $safeint = '(is_int($temp = %s) ? $temp : (fmod($temp, 0x80000000) & 0x7FFFFFFF) | ';
2720
- return $safeint . '((fmod(floor($temp / 0x80000000), 2) & 1) << 31))';
2721
- }
2722
- }
2723
- }
2724
-
2725
- /**
2726
- * Random Number Generator
2727
- *
2728
- * The idea behind this function is that it can be easily replaced with your own crypt_random_string()
2729
- * function. eg. maybe you have a better source of entropy for creating the initial states or whatever.
2730
- *
2731
- * PHP versions 4 and 5
2732
- *
2733
- * Here's a short example of how to use this library:
2734
- * <code>
2735
- * <?php
2736
- * include 'Crypt/Random.php';
2737
- *
2738
- * echo bin2hex(crypt_random_string(8));
2739
- * ?>
2740
- * </code>
2741
- *
2742
- * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy
2743
- * of this software and associated documentation files (the "Software"), to deal
2744
- * in the Software without restriction, including without limitation the rights
2745
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2746
- * copies of the Software, and to permit persons to whom the Software is
2747
- * furnished to do so, subject to the following conditions:
2748
- *
2749
- * The above copyright notice and this permission notice shall be included in
2750
- * all copies or substantial portions of the Software.
2751
- *
2752
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2753
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2754
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2755
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2756
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2757
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2758
- * THE SOFTWARE.
2759
- *
2760
- * @category Crypt
2761
- * @package Crypt_Random
2762
- * @author Jim Wigginton <terrafrost@php.net>
2763
- * @copyright 2007 Jim Wigginton
2764
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
2765
- * @link http://phpseclib.sourceforge.net
2766
- */
2767
-
2768
- // laravel is a PHP framework that utilizes phpseclib. laravel workbenches may, independently,
2769
- // have phpseclib as a requirement as well. if you're developing such a program you may encounter
2770
- // a "Cannot redeclare crypt_random_string()" error.
2771
- if (!function_exists('crypt_random_string')) {
2772
- /**
2773
- * "Is Windows" test
2774
- *
2775
- * @access private
2776
- */
2777
- define('CRYPT_RANDOM_IS_WINDOWS', strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
2778
-
2779
- /**
2780
- * Generate a random string.
2781
- *
2782
- * Although microoptimizations are generally discouraged as they impair readability this function is ripe with
2783
- * microoptimizations because this function has the potential of being called a huge number of times.
2784
- * eg. for RSA key generation.
2785
- *
2786
- * @param int $length
2787
- * @return string
2788
- * @access public
2789
- */
2790
- function crypt_random_string($length)
2791
- {
2792
- if (!$length) {
2793
- return '';
2794
- }
2795
-
2796
- if (CRYPT_RANDOM_IS_WINDOWS) {
2797
- // method 1. prior to PHP 5.3, mcrypt_create_iv() would call rand() on windows
2798
- if (extension_loaded('mcrypt') && version_compare(PHP_VERSION, '5.3.0', '>=')) {
2799
- return @mcrypt_create_iv($length);
2800
- }
2801
- // method 2. openssl_random_pseudo_bytes was introduced in PHP 5.3.0 but prior to PHP 5.3.4 there was,
2802
- // to quote <http://php.net/ChangeLog-5.php#5.3.4>, "possible blocking behavior". as of 5.3.4
2803
- // openssl_random_pseudo_bytes and mcrypt_create_iv do the exact same thing on Windows. ie. they both
2804
- // call php_win32_get_random_bytes():
2805
- //
2806
- // https://github.com/php/php-src/blob/7014a0eb6d1611151a286c0ff4f2238f92c120d6/ext/openssl/openssl.c#L5008
2807
- // https://github.com/php/php-src/blob/7014a0eb6d1611151a286c0ff4f2238f92c120d6/ext/mcrypt/mcrypt.c#L1392
2808
- //
2809
- // php_win32_get_random_bytes() is defined thusly:
2810
- //
2811
- // https://github.com/php/php-src/blob/7014a0eb6d1611151a286c0ff4f2238f92c120d6/win32/winutil.c#L80
2812
- //
2813
- // we're calling it, all the same, in the off chance that the mcrypt extension is not available
2814
- if (extension_loaded('openssl') && version_compare(PHP_VERSION, '5.3.4', '>=')) {
2815
- return openssl_random_pseudo_bytes($length);
2816
- }
2817
- } else {
2818
- // method 1. the fastest
2819
- if (extension_loaded('openssl') && version_compare(PHP_VERSION, '5.3.0', '>=')) {
2820
- return openssl_random_pseudo_bytes($length);
2821
- }
2822
- // method 2
2823
- static $fp = true;
2824
- if ($fp === true) {
2825
- // warning's will be output unles the error suppression operator is used. errors such as
2826
- // "open_basedir restriction in effect", "Permission denied", "No such file or directory", etc.
2827
- $fp = @fopen('/dev/urandom', 'rb');
2828
- }
2829
- if ($fp !== true && $fp !== false) { // surprisingly faster than !is_bool() or is_resource()
2830
- return fread($fp, $length);
2831
- }
2832
- // method 3. pretty much does the same thing as method 2 per the following url:
2833
- // https://github.com/php/php-src/blob/7014a0eb6d1611151a286c0ff4f2238f92c120d6/ext/mcrypt/mcrypt.c#L1391
2834
- // surprisingly slower than method 2. maybe that's because mcrypt_create_iv does a bunch of error checking that we're
2835
- // not doing. regardless, this'll only be called if this PHP script couldn't open /dev/urandom due to open_basedir
2836
- // restrictions or some such
2837
- if (extension_loaded('mcrypt')) {
2838
- return @mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);
2839
- }
2840
- }
2841
- // at this point we have no choice but to use a pure-PHP CSPRNG
2842
-
2843
- // cascade entropy across multiple PHP instances by fixing the session and collecting all
2844
- // environmental variables, including the previous session data and the current session
2845
- // data.
2846
- //
2847
- // mt_rand seeds itself by looking at the PID and the time, both of which are (relatively)
2848
- // easy to guess at. linux uses mouse clicks, keyboard timings, etc, as entropy sources, but
2849
- // PHP isn't low level to be able to use those as sources and on a web server there's not likely
2850
- // going to be a ton of keyboard or mouse action. web servers do have one thing that we can use
2851
- // however, a ton of people visiting the website. obviously you don't want to base your seeding
2852
- // soley on parameters a potential attacker sends but (1) not everything in $_SERVER is controlled
2853
- // by the user and (2) this isn't just looking at the data sent by the current user - it's based
2854
- // on the data sent by all users. one user requests the page and a hash of their info is saved.
2855
- // another user visits the page and the serialization of their data is utilized along with the
2856
- // server envirnment stuff and a hash of the previous http request data (which itself utilizes
2857
- // a hash of the session data before that). certainly an attacker should be assumed to have
2858
- // full control over his own http requests. he, however, is not going to have control over
2859
- // everyone's http requests.
2860
- static $crypto = false, $v;
2861
- if ($crypto === false) {
2862
- // save old session data
2863
- $old_session_id = session_id();
2864
- $old_use_cookies = ini_get('session.use_cookies');
2865
- $old_session_cache_limiter = session_cache_limiter();
2866
- $_OLD_SESSION = isset($_SESSION) ? $_SESSION : false;
2867
- if ($old_session_id != '') {
2868
- session_write_close();
2869
- }
2870
-
2871
- session_id(1);
2872
- if (wp_is_ini_value_changeable('session.use_cookies'))
2873
- ini_set('session.use_cookies', 0);
2874
- session_cache_limiter('');
2875
- session_start();
2876
-
2877
- $v = $seed = $_SESSION['seed'] = pack('H*', sha1(
2878
- (isset($_SERVER) ? phpseclib_safe_serialize($_SERVER) : '') .
2879
- (isset($_POST) ? phpseclib_safe_serialize($_POST) : '') .
2880
- (isset($_GET) ? phpseclib_safe_serialize($_GET) : '') .
2881
- (isset($_COOKIE) ? phpseclib_safe_serialize($_COOKIE) : '') .
2882
- phpseclib_safe_serialize($GLOBALS) .
2883
- phpseclib_safe_serialize($_SESSION) .
2884
- phpseclib_safe_serialize($_OLD_SESSION)
2885
- ));
2886
- if (!isset($_SESSION['count'])) {
2887
- $_SESSION['count'] = 0;
2888
- }
2889
- $_SESSION['count']++;
2890
-
2891
- session_write_close();
2892
-
2893
- // restore old session data
2894
- if ($old_session_id != '') {
2895
- session_id($old_session_id);
2896
- session_start();
2897
- if (wp_is_ini_value_changeable('session.use_cookies'))
2898
- ini_set('session.use_cookies', $old_use_cookies);
2899
- session_cache_limiter($old_session_cache_limiter);
2900
- } else {
2901
- if ($_OLD_SESSION !== false) {
2902
- $_SESSION = $_OLD_SESSION;
2903
- unset($_OLD_SESSION);
2904
- } else {
2905
- unset($_SESSION);
2906
- }
2907
- }
2908
-
2909
- // in SSH2 a shared secret and an exchange hash are generated through the key exchange process.
2910
- // the IV client to server is the hash of that "nonce" with the letter A and for the encryption key it's the letter C.
2911
- // if the hash doesn't produce enough a key or an IV that's long enough concat successive hashes of the
2912
- // original hash and the current hash. we'll be emulating that. for more info see the following URL:
2913
- //
2914
- // http://tools.ietf.org/html/rfc4253#section-7.2
2915
- //
2916
- // see the is_string($crypto) part for an example of how to expand the keys
2917
- $key = pack('H*', sha1($seed . 'A'));
2918
- $iv = pack('H*', sha1($seed . 'C'));
2919
-
2920
- // ciphers are used as per the nist.gov link below. also, see this link:
2921
- //
2922
- // http://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator#Designs_based_on_cryptographic_primitives
2923
- switch (true) {
2924
- case phpseclib_resolve_include_path('Crypt/AES.php'):
2925
- /*
2926
- if (!class_exists('Crypt_AES')) {
2927
- include_once 'AES.php';
2928
- }
2929
- */
2930
- $crypto = new Crypt_AES(CRYPT_AES_MODE_CTR);
2931
- break;
2932
- case phpseclib_resolve_include_path('Crypt/Twofish.php'):
2933
- /*
2934
- if (!class_exists('Crypt_Twofish')) {
2935
- include_once 'Twofish.php';
2936
- }
2937
- */
2938
- $crypto = new Crypt_Twofish(CRYPT_TWOFISH_MODE_CTR);
2939
- break;
2940
- case phpseclib_resolve_include_path('Crypt/Blowfish.php'):
2941
- /*
2942
- if (!class_exists('Crypt_Blowfish')) {
2943
- include_once 'Blowfish.php';
2944
- }
2945
- */
2946
- $crypto = new Crypt_Blowfish(CRYPT_BLOWFISH_MODE_CTR);
2947
- break;
2948
- case phpseclib_resolve_include_path('Crypt/TripleDES.php'):
2949
- /*
2950
- if (!class_exists('Crypt_TripleDES')) {
2951
- include_once 'TripleDES.php';
2952
- }
2953
- */
2954
- $crypto = new Crypt_TripleDES(CRYPT_DES_MODE_CTR);
2955
- break;
2956
- case phpseclib_resolve_include_path('Crypt/DES.php'):
2957
- /*
2958
- if (!class_exists('Crypt_DES')) {
2959
- include_once 'DES.php';
2960
- }
2961
- */
2962
- $crypto = new Crypt_DES(CRYPT_DES_MODE_CTR);
2963
- break;
2964
- case phpseclib_resolve_include_path('Crypt/RC4.php'):
2965
- /*
2966
- if (!class_exists('Crypt_RC4')) {
2967
- include_once 'RC4.php';
2968
- }
2969
- */
2970
- $crypto = new Crypt_RC4();
2971
- break;
2972
- default:
2973
- user_error('crypt_random_string requires at least one symmetric cipher be loaded');
2974
- return false;
2975
- }
2976
-
2977
- $crypto->setKey($key);
2978
- $crypto->setIV($iv);
2979
- $crypto->enableContinuousBuffer();
2980
- }
2981
-
2982
- //return $crypto->encrypt(str_repeat("\0", $length));
2983
-
2984
- // the following is based off of ANSI X9.31:
2985
- //
2986
- // http://csrc.nist.gov/groups/STM/cavp/documents/rng/931rngext.pdf
2987
- //
2988
- // OpenSSL uses that same standard for it's random numbers:
2989
- //
2990
- // http://www.opensource.apple.com/source/OpenSSL/OpenSSL-38/openssl/fips-1.0/rand/fips_rand.c
2991
- // (do a search for "ANS X9.31 A.2.4")
2992
- $result = '';
2993
- while (strlen($result) < $length) {
2994
- $i = $crypto->encrypt(microtime()); // strlen(microtime()) == 21
2995
- $r = $crypto->encrypt($i ^ $v); // strlen($v) == 20
2996
- $v = $crypto->encrypt($r ^ $i); // strlen($r) == 20
2997
- $result.= $r;
2998
- }
2999
- return substr($result, 0, $length);
3000
- }
3001
- }
3002
-
3003
- if (!function_exists('phpseclib_safe_serialize')) {
3004
- /**
3005
- * Safely serialize variables
3006
- *
3007
- * If a class has a private __sleep() method it'll give a fatal error on PHP 5.2 and earlier.
3008
- * PHP 5.3 will emit a warning.
3009
- *
3010
- * @param mixed $arr
3011
- * @access public
3012
- */
3013
- function phpseclib_safe_serialize(&$arr)
3014
- {
3015
- if (is_object($arr)) {
3016
- return '';
3017
- }
3018
- if (!is_array($arr)) {
3019
- return serialize($arr);
3020
- }
3021
- // prevent circular array recursion
3022
- if (isset($arr['__phpseclib_marker'])) {
3023
- return '';
3024
- }
3025
- $safearr = array();
3026
- $arr['__phpseclib_marker'] = true;
3027
- foreach (array_keys($arr) as $key) {
3028
- // do not recurse on the '__phpseclib_marker' key itself, for smaller memory usage
3029
- if ($key !== '__phpseclib_marker') {
3030
- $safearr[$key] = phpseclib_safe_serialize($arr[$key]);
3031
- }
3032
- }
3033
- unset($arr['__phpseclib_marker']);
3034
- return serialize($safearr);
3035
- }
3036
- }
3037
-
3038
- if (!function_exists('phpseclib_resolve_include_path')) {
3039
- /**
3040
- * Resolve filename against the include path.
3041
- *
3042
- * Wrapper around stream_resolve_include_path() (which was introduced in
3043
- * PHP 5.3.2) with fallback implementation for earlier PHP versions.
3044
- *
3045
- * @param string $filename
3046
- * @return string|false
3047
- * @access public
3048
- */
3049
- function phpseclib_resolve_include_path($filename)
3050
- {
3051
- if (function_exists('stream_resolve_include_path')) {
3052
- return stream_resolve_include_path($filename);
3053
- }
3054
-
3055
- // handle non-relative paths
3056
- if (file_exists($filename)) {
3057
- return realpath($filename);
3058
- }
3059
-
3060
- $paths = PATH_SEPARATOR == ':' ?
3061
- preg_split('#(?<!phar):#', get_include_path()) :
3062
- explode(PATH_SEPARATOR, get_include_path());
3063
- foreach ($paths as $prefix) {
3064
- // path's specified in include_path don't always end in /
3065
- $ds = substr($prefix, -1) == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR;
3066
- $file = $prefix . $ds . $filename;
3067
- if (file_exists($file)) {
3068
- return realpath($file);
3069
- }
3070
- }
3071
-
3072
- return false;
3073
- }
3074
- }
3075
-
3076
- /**
3077
- * Pure-PHP implementation of Rijndael.
3078
- *
3079
- * Uses mcrypt, if available/possible, and an internal implementation, otherwise.
3080
- *
3081
- * PHP versions 4 and 5
3082
- *
3083
- * If {@link self::setBlockLength() setBlockLength()} isn't called, it'll be assumed to be 128 bits. If
3084
- * {@link self::setKeyLength() setKeyLength()} isn't called, it'll be calculated from
3085
- * {@link self::setKey() setKey()}. ie. if the key is 128-bits, the key length will be 128-bits. If it's
3086
- * 136-bits it'll be null-padded to 192-bits and 192 bits will be the key length until
3087
- * {@link self::setKey() setKey()} is called, again, at which point, it'll be recalculated.
3088
- *
3089
- * Not all Rijndael implementations may support 160-bits or 224-bits as the block length / key length. mcrypt, for example,
3090
- * does not. AES, itself, only supports block lengths of 128 and key lengths of 128, 192, and 256.
3091
- * {@link http://csrc.nist.gov/archive/aes/rijndael/Rijndael-ammended.pdf#page=10 Rijndael-ammended.pdf#page=10} defines the
3092
- * algorithm for block lengths of 192 and 256 but not for block lengths / key lengths of 160 and 224. Indeed, 160 and 224
3093
- * are first defined as valid key / block lengths in
3094
- * {@link http://csrc.nist.gov/archive/aes/rijndael/Rijndael-ammended.pdf#page=44 Rijndael-ammended.pdf#page=44}:
3095
- * Extensions: Other block and Cipher Key lengths.
3096
- * Note: Use of 160/224-bit Keys must be explicitly set by setKeyLength(160) respectively setKeyLength(224).
3097
- *
3098
- * {@internal The variable names are the same as those in
3099
- * {@link http://www.csrc.nist.gov/publications/fips/fips197/fips-197.pdf#page=10 fips-197.pdf#page=10}.}}
3100
- *
3101
- * Here's a short example of how to use this library:
3102
- * <code>
3103
- * <?php
3104
- * include 'Crypt/Rijndael.php';
3105
- *
3106
- * $rijndael = new Crypt_Rijndael();
3107
- *
3108
- * $rijndael->setKey('abcdefghijklmnop');
3109
- *
3110
- * $size = 10 * 1024;
3111
- * $plaintext = '';
3112
- * for ($i = 0; $i < $size; $i++) {
3113
- * $plaintext.= 'a';
3114
- * }
3115
- *
3116
- * echo $rijndael->decrypt($rijndael->encrypt($plaintext));
3117
- * ?>
3118
- * </code>
3119
- *
3120
- * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy
3121
- * of this software and associated documentation files (the "Software"), to deal
3122
- * in the Software without restriction, including without limitation the rights
3123
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3124
- * copies of the Software, and to permit persons to whom the Software is
3125
- * furnished to do so, subject to the following conditions:
3126
- *
3127
- * The above copyright notice and this permission notice shall be included in
3128
- * all copies or substantial portions of the Software.
3129
- *
3130
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3131
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3132
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3133
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3134
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3135
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3136
- * THE SOFTWARE.
3137
- *
3138
- * @category Crypt
3139
- * @package Crypt_Rijndael
3140
- * @author Jim Wigginton <terrafrost@php.net>
3141
- * @copyright 2008 Jim Wigginton
3142
- * @license http://www.opensource.org/licenses/mit-license.html MIT License
3143
- * @link http://phpseclib.sourceforge.net
3144
- */
3145
-
3146
-
3147
- /**#@+
3148
- * @access public
3149
- * @see self::encrypt()
3150
- * @see self::decrypt()
3151
- */
3152
- /**
3153
- * Encrypt / decrypt using the Counter mode.
3154
- *
3155
- * Set to -1 since that's what Crypt/Random.php uses to index the CTR mode.
3156
- *
3157
- * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Counter_.28CTR.29
3158
- */
3159
- define('CRYPT_RIJNDAEL_MODE_CTR', CRYPT_MODE_CTR);
3160
- /**
3161
- * Encrypt / decrypt using the Electronic Code Book mode.
3162
- *
3163
- * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Electronic_codebook_.28ECB.29
3164
- */
3165
- define('CRYPT_RIJNDAEL_MODE_ECB', CRYPT_MODE_ECB);
3166
- /**
3167
- * Encrypt / decrypt using the Code Book Chaining mode.
3168
- *
3169
- * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29
3170
- */
3171
- define('CRYPT_RIJNDAEL_MODE_CBC', CRYPT_MODE_CBC);
3172
- /**
3173
- * Encrypt / decrypt using the Cipher Feedback mode.
3174
- *
3175
- * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher_feedback_.28CFB.29
3176
- */
3177
- define('CRYPT_RIJNDAEL_MODE_CFB', CRYPT_MODE_CFB);
3178
- /**
3179
- * Encrypt / decrypt using the Cipher Feedback mode.
3180
- *
3181
- * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Output_feedback_.28OFB.29
3182
- */
3183
- define('CRYPT_RIJNDAEL_MODE_OFB', CRYPT_MODE_OFB);
3184
- /**#@-*/
3185
-
3186
- /**
3187
- * Pure-PHP implementation of Rijndael.
3188
- *
3189
- * @package Crypt_Rijndael
3190
- * @author Jim Wigginton <terrafrost@php.net>
3191
- * @access public
3192
- */
3193
- class Crypt_Rijndael extends Crypt_Base
3194
- {
3195
- /**
3196
- * The namespace used by the cipher for its constants.
3197
- *
3198
- * @see Crypt_Base::const_namespace
3199
- * @var string
3200
- * @access private
3201
- */
3202
- var $const_namespace = 'RIJNDAEL';
3203
-
3204
- /**
3205
- * The mcrypt specific name of the cipher
3206
- *
3207
- * Mcrypt is useable for 128/192/256-bit $block_size/$key_length. For 160/224 not.
3208
- * Crypt_Rijndael determines automatically whether mcrypt is useable
3209
- * or not for the current $block_size/$key_length.
3210
- * In case of, $cipher_name_mcrypt will be set dynamically at run time accordingly.
3211
- *
3212
- * @see Crypt_Base::cipher_name_mcrypt
3213
- * @see Crypt_Base::engine
3214
- * @see self::isValidEngine()
3215
- * @var string
3216
- * @access private
3217
- */
3218
- var $cipher_name_mcrypt = 'rijndael-128';
3219
-
3220
- /**
3221
- * The default salt used by setPassword()
3222
- *
3223
- * @see Crypt_Base::password_default_salt
3224
- * @see Crypt_Base::setPassword()
3225
- * @var string
3226
- * @access private
3227
- */
3228
- var $password_default_salt = 'phpseclib';
3229
-
3230
- /**
3231
- * The Key Schedule
3232
- *
3233
- * @see self::_setup()
3234
- * @var array
3235
- * @access private
3236
- */
3237
- var $w;
3238
-
3239
- /**
3240
- * The Inverse Key Schedule
3241
- *
3242
- * @see self::_setup()
3243
- * @var array
3244
- * @access private
3245
- */
3246
- var $dw;
3247
-
3248
- /**
3249
- * The Block Length divided by 32
3250
- *
3251
- * @see self::setBlockLength()
3252
- * @var int
3253
- * @access private
3254
- * @internal The max value is 256 / 32 = 8, the min value is 128 / 32 = 4. Exists in conjunction with $block_size
3255
- * because the encryption / decryption / key schedule creation requires this number and not $block_size. We could
3256
- * derive this from $block_size or vice versa, but that'd mean we'd have to do multiple shift operations, so in lieu
3257
- * of that, we'll just precompute it once.
3258
- */
3259
- var $Nb = 4;
3260
-
3261
- /**
3262
- * The Key Length (in bytes)
3263
- *
3264
- * @see self::setKeyLength()
3265
- * @var int
3266
- * @access private
3267
- * @internal The max value is 256 / 8 = 32, the min value is 128 / 8 = 16. Exists in conjunction with $Nk
3268
- * because the encryption / decryption / key schedule creation requires this number and not $key_length. We could
3269
- * derive this from $key_length or vice versa, but that'd mean we'd have to do multiple shift operations, so in lieu
3270
- * of that, we'll just precompute it once.
3271
- */
3272
- var $key_length = 16;
3273
-
3274
- /**
3275
- * The Key Length divided by 32
3276
- *
3277
- * @see self::setKeyLength()
3278
- * @var int
3279
- * @access private
3280
- * @internal The max value is 256 / 32 = 8, the min value is 128 / 32 = 4
3281
- */
3282
- var $Nk = 4;
3283
-
3284
- /**
3285
- * The Number of Rounds
3286
- *
3287
- * @var int
3288
- * @access private
3289
- * @internal The max value is 14, the min value is 10.
3290
- */
3291
- var $Nr;
3292
-
3293
- /**
3294
- * Shift offsets
3295
- *
3296
- * @var array
3297
- * @access private
3298
- */
3299
- var $c;
3300
-
3301
- /**
3302
- * Holds the last used key- and block_size information
3303
- *
3304
- * @var array
3305
- * @access private
3306
- */
3307
- var $kl;
3308
-
3309
- /**
3310
- * Sets the key.
3311
- *
3312
- * Keys can be of any length. Rijndael, itself, requires the use of a key that's between 128-bits and 256-bits long and
3313
- * whose length is a multiple of 32. If the key is less than 256-bits and the key length isn't set, we round the length
3314
- * up to the closest valid key length, padding $key with null bytes. If the key is more than 256-bits, we trim the
3315
- * excess bits.
3316
- *
3317
- * If the key is not explicitly set, it'll be assumed to be all null bytes.
3318
- *
3319
- * Note: 160/224-bit keys must explicitly set by setKeyLength(), otherwise they will be round/pad up to 192/256 bits.
3320
- *
3321
- * @see Crypt_Base:setKey()
3322
- * @see self::setKeyLength()
3323
- * @access public
3324
- * @param string $key
3325
- */
3326
- function setKey($key)
3327
- {
3328
- if (!$this->explicit_key_length) {
3329
- $length = strlen($key);
3330
- switch (true) {
3331
- case $length <= 16:
3332
- $this->key_size = 16;
3333
- break;
3334
- case $length <= 20:
3335
- $this->key_size = 20;
3336
- break;
3337
- case $length <= 24:
3338
- $this->key_size = 24;
3339
- break;
3340
- case $length <= 28:
3341
- $this->key_size = 28;
3342
- break;
3343
- default:
3344
- $this->key_size = 32;
3345
- }
3346
- }
3347
- parent::setKey($key);
3348
- }
3349
-
3350
- /**
3351
- * Sets the key length
3352
- *
3353
- * Valid key lengths are 128, 160, 192, 224, and 256. If the length is less than 128, it will be rounded up to
3354
- * 128. If the length is greater than 128 and invalid, it will be rounded down to the closest valid amount.
3355
- *
3356
- * Note: phpseclib extends Rijndael (and AES) for using 160- and 224-bit keys but they are officially not defined
3357
- * and the most (if not all) implementations are not able using 160/224-bit keys but round/pad them up to
3358
- * 192/256 bits as, for example, mcrypt will do.
3359
- *
3360
- * That said, if you want be compatible with other Rijndael and AES implementations,
3361
- * you should not setKeyLength(160) or setKeyLength(224).
3362
- *
3363
- * Additional: In case of 160- and 224-bit keys, phpseclib will/can, for that reason, not use
3364
- * the mcrypt php extension, even if available.
3365
- * This results then in slower encryption.
3366
- *
3367
- * @access public
3368
- * @param int $length
3369
- */
3370
- function setKeyLength($length)
3371
- {
3372
- switch (true) {
3373
- case $length <= 128:
3374
- $this->key_length = 16;
3375
- break;
3376
- case $length <= 160:
3377
- $this->key_length = 20;
3378
- break;
3379
- case $length <= 192:
3380
- $this->key_length = 24;
3381
- break;
3382
- case $length <= 224:
3383
- $this->key_length = 28;
3384
- break;
3385
- default:
3386
- $this->key_length = 32;
3387
- }
3388
-
3389
- parent::setKeyLength($length);
3390
- }
3391
-
3392
- /**
3393
- * Sets the block length
3394
- *
3395
- * Valid block lengths are 128, 160, 192, 224, and 256. If the length is less than 128, it will be rounded up to
3396
- * 128. If the length is greater than 128 and invalid, it will be rounded down to the closest valid amount.
3397
- *
3398
- * @access public
3399
- * @param int $length
3400
- */
3401
- function setBlockLength($length)
3402
- {
3403
- $length >>= 5;
3404
- if ($length > 8) {
3405
- $length = 8;
3406
- } elseif ($length < 4) {
3407
- $length = 4;
3408
- }
3409
- $this->Nb = $length;
3410
- $this->block_size = $length << 2;
3411
- $this->changed = true;
3412
- $this->_setEngine();
3413
- }
3414
-
3415
- /**
3416
- * Test for engine validity
3417
- *
3418
- * This is mainly just a wrapper to set things up for Crypt_Base::isValidEngine()
3419
- *
3420
- * @see Crypt_Base::Crypt_Base()
3421
- * @param int $engine
3422
- * @access public
3423
- * @return bool
3424
- */
3425
- function isValidEngine($engine)
3426
- {
3427
- switch ($engine) {
3428
- case CRYPT_ENGINE_OPENSSL:
3429
- if ($this->block_size != 16) {
3430
- return false;
3431
- }
3432
- $this->cipher_name_openssl_ecb = 'aes-' . ($this->key_length << 3) . '-ecb';
3433
- $this->cipher_name_openssl = 'aes-' . ($this->key_length << 3) . '-' . $this->_openssl_translate_mode();
3434
- break;
3435
- case CRYPT_ENGINE_MCRYPT:
3436
- $this->cipher_name_mcrypt = 'rijndael-' . ($this->block_size << 3);
3437
- if ($this->key_length % 8) { // is it a 160/224-bit key?
3438
- // mcrypt is not usable for them, only for 128/192/256-bit keys
3439
- return false;
3440
- }
3441
- }
3442
-
3443
- return parent::isValidEngine($engine);
3444
- }
3445
-
3446
- /**
3447
- * Encrypts a block
3448
- *
3449
- * @access private
3450
- * @param string $in
3451
- * @return string
3452
- */
3453
- function _encryptBlock($in)
3454
- {
3455
- static $tables;
3456
- if (empty($tables)) {
3457
- $tables = &$this->_getTables();
3458
- }
3459
- $t0 = $tables[0];
3460
- $t1 = $tables[1];
3461
- $t2 = $tables[2];
3462
- $t3 = $tables[3];
3463
- $sbox = $tables[4];
3464
-
3465
- $state = array();
3466
- $words = unpack('N*', $in);
3467
-
3468
- $c = $this->c;
3469
- $w = $this->w;
3470
- $Nb = $this->Nb;
3471
- $Nr = $this->Nr;
3472
-
3473
- // addRoundKey
3474
- $wc = $Nb - 1;
3475
- foreach ($words as $word) {
3476
- $state[] = $word ^ $w[++$wc];
3477
- }
3478
-
3479
- // fips-197.pdf#page=19, "Figure 5. Pseudo Code for the Cipher", states that this loop has four components -
3480
- // subBytes, shiftRows, mixColumns, and addRoundKey. fips-197.pdf#page=30, "Implementation Suggestions Regarding
3481
- // Various Platforms" suggests that performs enhanced implementations are described in Rijndael-ammended.pdf.
3482
- // Rijndael-ammended.pdf#page=20, "Implementation aspects / 32-bit processor", discusses such an optimization.
3483
- // Unfortunately, the description given there is not quite correct. Per aes.spec.v316.pdf#page=19 [1],
3484
- // equation (7.4.7) is supposed to use addition instead of subtraction, so we'll do that here, as well.
3485
-
3486
- // [1] http://fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.v316.pdf
3487
- $temp = array();
3488
- for ($round = 1; $round < $Nr; ++$round) {
3489
- $i = 0; // $c[0] == 0
3490
- $j = $c[1];
3491
- $k = $c[2];
3492
- $l = $c[3];
3493
-
3494
- while ($i < $Nb) {
3495
- $temp[$i] = $t0[$state[$i] >> 24 & 0x000000FF] ^
3496
- $t1[$state[$j] >> 16 & 0x000000FF] ^
3497
- $t2[$state[$k] >> 8 & 0x000000FF] ^
3498
- $t3[$state[$l] & 0x000000FF] ^
3499
- $w[++$wc];
3500
- ++$i;
3501
- $j = ($j + 1) % $Nb;
3502
- $k = ($k + 1) % $Nb;
3503
- $l = ($l + 1) % $Nb;
3504
- }
3505
- $state = $temp;
3506
- }
3507
-
3508
- // subWord
3509
- for ($i = 0; $i < $Nb; ++$i) {
3510
- $state[$i] = $sbox[$state[$i] & 0x000000FF] |
3511
- ($sbox[$state[$i] >> 8 & 0x000000FF] << 8) |
3512
- ($sbox[$state[$i] >> 16 & 0x000000FF] << 16) |
3513
- ($sbox[$state[$i] >> 24 & 0x000000FF] << 24);
3514
- }
3515
-
3516
- // shiftRows + addRoundKey
3517
- $i = 0; // $c[0] == 0
3518
- $j = $c[1];
3519
- $k = $c[2];
3520
- $l = $c[3];
3521
- while ($i < $Nb) {
3522
- $temp[$i] = ($state[$i] & 0xFF000000) ^
3523
- ($state[$j] & 0x00FF0000) ^
3524
- ($state[$k] & 0x0000FF00) ^
3525
- ($state[$l] & 0x000000FF) ^
3526
- $w[$i];
3527
- ++$i;
3528
- $j = ($j + 1) % $Nb;
3529
- $k = ($k + 1) % $Nb;
3530
- $l = ($l + 1) % $Nb;
3531
- }
3532
-
3533
- switch ($Nb) {
3534
- case 8:
3535
- return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4], $temp[5], $temp[6], $temp[7]);
3536
- case 7:
3537
- return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4], $temp[5], $temp[6]);
3538
- case 6:
3539
- return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4], $temp[5]);
3540
- case 5:
3541
- return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4]);
3542
- default:
3543
- return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3]);
3544
- }
3545
- }
3546
-
3547
- /**
3548
- * Decrypts a block
3549
- *
3550
- * @access private
3551
- * @param string $in
3552
- * @return string
3553
- */
3554
- function _decryptBlock($in)
3555
- {
3556
- static $invtables;
3557
- if (empty($invtables)) {
3558
- $invtables = &$this->_getInvTables();
3559
- }
3560
- $dt0 = $invtables[0];
3561
- $dt1 = $invtables[1];
3562
- $dt2 = $invtables[2];
3563
- $dt3 = $invtables[3];
3564
- $isbox = $invtables[4];
3565
-
3566
- $state = array();
3567
- $words = unpack('N*', $in);
3568
-
3569
- $c = $this->c;
3570
- $dw = $this->dw;
3571
- $Nb = $this->Nb;
3572
- $Nr = $this->Nr;
3573
-
3574
- // addRoundKey
3575
- $wc = $Nb - 1;
3576
- foreach ($words as $word) {
3577
- $state[] = $word ^ $dw[++$wc];
3578
- }
3579
-
3580
- $temp = array();
3581
- for ($round = $Nr - 1; $round > 0; --$round) {
3582
- $i = 0; // $c[0] == 0
3583
- $j = $Nb - $c[1];
3584
- $k = $Nb - $c[2];
3585
- $l = $Nb - $c[3];
3586
-
3587
- while ($i < $Nb) {
3588
- $temp[$i] = $dt0[$state[$i] >> 24 & 0x000000FF] ^
3589
- $dt1[$state[$j] >> 16 & 0x000000FF] ^
3590
- $dt2[$state[$k] >> 8 & 0x000000FF] ^
3591
- $dt3[$state[$l] & 0x000000FF] ^
3592
- $dw[++$wc];
3593
- ++$i;
3594
- $j = ($j + 1) % $Nb;
3595
- $k = ($k + 1) % $Nb;
3596
- $l = ($l + 1) % $Nb;
3597
- }
3598
- $state = $temp;
3599
- }
3600
-
3601
- // invShiftRows + invSubWord + addRoundKey
3602
- $i = 0; // $c[0] == 0
3603
- $j = $Nb - $c[1];
3604
- $k = $Nb - $c[2];
3605
- $l = $Nb - $c[3];
3606
-
3607
- while ($i < $Nb) {
3608
- $word = ($state[$i] & 0xFF000000) |
3609
- ($state[$j] & 0x00FF0000) |
3610
- ($state[$k] & 0x0000FF00) |
3611
- ($state[$l] & 0x000000FF);
3612
-
3613
- $temp[$i] = $dw[$i] ^ ($isbox[$word & 0x000000FF] |
3614
- ($isbox[$word >> 8 & 0x000000FF] << 8) |
3615
- ($isbox[$word >> 16 & 0x000000FF] << 16) |
3616
- ($isbox[$word >> 24 & 0x000000FF] << 24));
3617
- ++$i;
3618
- $j = ($j + 1) % $Nb;
3619
- $k = ($k + 1) % $Nb;
3620
- $l = ($l + 1) % $Nb;
3621
- }
3622
-
3623
- switch ($Nb) {
3624
- case 8:
3625
- return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4], $temp[5], $temp[6], $temp[7]);
3626
- case 7:
3627
- return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4], $temp[5], $temp[6]);
3628
- case 6:
3629
- return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4], $temp[5]);
3630
- case 5:
3631
- return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4]);
3632
- default:
3633
- return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3]);
3634
- }
3635
- }
3636
-
3637
- /**
3638
- * Setup the key (expansion)
3639
- *
3640
- * @see Crypt_Base::_setupKey()
3641
- * @access private
3642
- */
3643
- function _setupKey()
3644
- {
3645
- // Each number in $rcon is equal to the previous number multiplied by two in Rijndael's finite field.
3646
- // See http://en.wikipedia.org/wiki/Finite_field_arithmetic#Multiplicative_inverse
3647
- static $rcon = array(0,
3648
- 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000,
3649
- 0x20000000, 0x40000000, 0x80000000, 0x1B000000, 0x36000000,
3650
- 0x6C000000, 0xD8000000, 0xAB000000, 0x4D000000, 0x9A000000,
3651
- 0x2F000000, 0x5E000000, 0xBC000000, 0x63000000, 0xC6000000,
3652
- 0x97000000, 0x35000000, 0x6A000000, 0xD4000000, 0xB3000000,
3653
- 0x7D000000, 0xFA000000, 0xEF000000, 0xC5000000, 0x91000000
3654
- );
3655
-
3656
- if (isset($this->kl['key']) && $this->key === $this->kl['key'] && $this->key_length === $this->kl['key_length'] && $this->block_size === $this->kl['block_size']) {
3657
- // already expanded
3658
- return;
3659
- }
3660
- $this->kl = array('key' => $this->key, 'key_length' => $this->key_length, 'block_size' => $this->block_size);
3661
-
3662
- $this->Nk = $this->key_length >> 2;
3663
- // see Rijndael-ammended.pdf#page=44
3664
- $this->Nr = max($this->Nk, $this->Nb) + 6;
3665
-
3666
- // shift offsets for Nb = 5, 7 are defined in Rijndael-ammended.pdf#page=44,
3667
- // "Table 8: Shift offsets in Shiftrow for the alternative block lengths"
3668
- // shift offsets for Nb = 4, 6, 8 are defined in Rijndael-ammended.pdf#page=14,
3669
- // "Table 2: Shift offsets for different block lengths"
3670
- switch ($this->Nb) {
3671
- case 4:
3672
- case 5:
3673
- case 6:
3674
- $this->c = array(0, 1, 2, 3);
3675
- break;
3676
- case 7:
3677
- $this->c = array(0, 1, 2, 4);
3678
- break;
3679
- case 8:
3680
- $this->c = array(0, 1, 3, 4);
3681
- }
3682
-
3683
- $w = array_values(unpack('N*words', $this->key));
3684
-
3685
- $length = $this->Nb * ($this->Nr + 1);
3686
- for ($i = $this->Nk; $i < $length; $i++) {
3687
- $temp = $w[$i - 1];
3688
- if ($i % $this->Nk == 0) {
3689
- // according to <http://php.net/language.types.integer>, "the size of an integer is platform-dependent".
3690
- // on a 32-bit machine, it's 32-bits, and on a 64-bit machine, it's 64-bits. on a 32-bit machine,
3691
- // 0xFFFFFFFF << 8 == 0xFFFFFF00, but on a 64-bit machine, it equals 0xFFFFFFFF00. as such, doing 'and'
3692
- // with 0xFFFFFFFF (or 0xFFFFFF00) on a 32-bit machine is unnecessary, but on a 64-bit machine, it is.
3693
- $temp = (($temp << 8) & 0xFFFFFF00) | (($temp >> 24) & 0x000000FF); // rotWord
3694
- $temp = $this->_subWord($temp) ^ $rcon[$i / $this->Nk];
3695
- } elseif ($this->Nk > 6 && $i % $this->Nk == 4) {
3696
- $temp = $this->_subWord($temp);
3697
- }
3698
- $w[$i] = $w[$i - $this->Nk] ^ $temp;
3699
- }
3700
-
3701
- // convert the key schedule from a vector of $Nb * ($Nr + 1) length to a matrix with $Nr + 1 rows and $Nb columns
3702
- // and generate the inverse key schedule. more specifically,
3703
- // according to <http://csrc.nist.gov/archive/aes/rijndael/Rijndael-ammended.pdf#page=23> (section 5.3.3),
3704
- // "The key expansion for the Inverse Cipher is defined as follows:
3705
- // 1. Apply the Key Expansion.
3706
- // 2. Apply InvMixColumn to all Round Keys except the first and the last one."
3707
- // also, see fips-197.pdf#page=27, "5.3.5 Equivalent Inverse Cipher"
3708
- list($dt0, $dt1, $dt2, $dt3) = $this->_getInvTables();
3709
- $temp = $this->w = $this->dw = array();
3710
- for ($i = $row = $col = 0; $i < $length; $i++, $col++) {
3711
- if ($col == $this->Nb) {
3712
- if ($row == 0) {
3713
- $this->dw[0] = $this->w[0];
3714
- } else {
3715
- // subWord + invMixColumn + invSubWord = invMixColumn
3716
- $j = 0;
3717
- while ($j < $this->Nb) {
3718
- $dw = $this->_subWord($this->w[$row][$j]);
3719
- $temp[$j] = $dt0[$dw >> 24 & 0x000000FF] ^
3720
- $dt1[$dw >> 16 & 0x000000FF] ^
3721
- $dt2[$dw >> 8 & 0x000000FF] ^
3722
- $dt3[$dw & 0x000000FF];
3723
- $j++;
3724
- }
3725
- $this->dw[$row] = $temp;
3726
- }
3727
-
3728
- $col = 0;
3729
- $row++;
3730
- }
3731
- $this->w[$row][$col] = $w[$i];
3732
- }
3733
-
3734
- $this->dw[$row] = $this->w[$row];
3735
-
3736
- // Converting to 1-dim key arrays (both ascending)
3737
- $this->dw = array_reverse($this->dw);
3738
- $w = array_pop($this->w);
3739
- $dw = array_pop($this->dw);
3740
- foreach ($this->w as $r => $wr) {
3741
- foreach ($wr as $c => $wc) {
3742
- $w[] = $wc;
3743
- $dw[] = $this->dw[$r][$c];
3744
- }
3745
- }
3746
- $this->w = $w;
3747
- $this->dw = $dw;
3748
- }
3749
-
3750
- /**
3751
- * Performs S-Box substitutions
3752
- *
3753
- * @access private
3754
- * @param int $word
3755
- */
3756
- function _subWord($word)
3757
- {
3758
- static $sbox;
3759
- if (empty($sbox)) {
3760
- list(, , , , $sbox) = $this->_getTables();
3761
- }
3762
-
3763
- return $sbox[$word & 0x000000FF] |
3764
- ($sbox[$word >> 8 & 0x000000FF] << 8) |
3765
- ($sbox[$word >> 16 & 0x000000FF] << 16) |
3766
- ($sbox[$word >> 24 & 0x000000FF] << 24);
3767
- }
3768
-
3769
- /**
3770
- * Provides the mixColumns and sboxes tables
3771
- *
3772
- * @see Crypt_Rijndael:_encryptBlock()
3773
- * @see Crypt_Rijndael:_setupInlineCrypt()
3774
- * @see Crypt_Rijndael:_subWord()
3775
- * @access private
3776
- * @return array &$tables
3777
- */
3778
- function &_getTables()
3779
- {
3780
- static $tables;
3781
- if (empty($tables)) {
3782
- // according to <http://csrc.nist.gov/archive/aes/rijndael/Rijndael-ammended.pdf#page=19> (section 5.2.1),
3783
- // precomputed tables can be used in the mixColumns phase. in that example, they're assigned t0...t3, so
3784
- // those are the names we'll use.
3785
- $t3 = array_map('intval', array(
3786
- // with array_map('intval', ...) we ensure we have only int's and not
3787
- // some slower floats converted by php automatically on high values
3788
- 0x6363A5C6, 0x7C7C84F8, 0x777799EE, 0x7B7B8DF6, 0xF2F20DFF, 0x6B6BBDD6, 0x6F6FB1DE, 0xC5C55491,
3789
- 0x30305060, 0x01010302, 0x6767A9CE, 0x2B2B7D56, 0xFEFE19E7, 0xD7D762B5, 0xABABE64D, 0x76769AEC,
3790
- 0xCACA458F, 0x82829D1F, 0xC9C94089, 0x7D7D87FA, 0xFAFA15EF, 0x5959EBB2, 0x4747C98E, 0xF0F00BFB,
3791
- 0xADADEC41, 0xD4D467B3, 0xA2A2FD5F, 0xAFAFEA45, 0x9C9CBF23, 0xA4A4F753, 0x727296E4, 0xC0C05B9B,
3792
- 0xB7B7C275, 0xFDFD1CE1, 0x9393AE3D, 0x26266A4C, 0x36365A6C, 0x3F3F417E, 0xF7F702F5, 0xCCCC4F83,
3793
- 0x34345C68, 0xA5A5F451, 0xE5E534D1, 0xF1F108F9, 0x717193E2, 0xD8D873AB, 0x31315362, 0x15153F2A,
3794
- 0x04040C08, 0xC7C75295, 0x23236546, 0xC3C35E9D, 0x18182830, 0x9696A137, 0x05050F0A, 0x9A9AB52F,
3795
- 0x0707090E, 0x12123624, 0x80809B1B, 0xE2E23DDF, 0xEBEB26CD, 0x2727694E, 0xB2B2CD7F, 0x75759FEA,
3796
- 0x09091B12, 0x83839E1D, 0x2C2C7458, 0x1A1A2E34, 0x1B1B2D36, 0x6E6EB2DC, 0x5A5AEEB4, 0xA0A0FB5B,
3797
- 0x5252F6A4, 0x3B3B4D76, 0xD6D661B7, 0xB3B3CE7D, 0x29297B52, 0xE3E33EDD, 0x2F2F715E, 0x84849713,
3798
- 0x5353F5A6, 0xD1D168B9, 0x00000000, 0xEDED2CC1, 0x20206040, 0xFCFC1FE3, 0xB1B1C879, 0x5B5BEDB6,
3799
- 0x6A6ABED4, 0xCBCB468D, 0xBEBED967, 0x39394B72, 0x4A4ADE94, 0x4C4CD498, 0x5858E8B0, 0xCFCF4A85,
3800
- 0xD0D06BBB, 0xEFEF2AC5, 0xAAAAE54F, 0xFBFB16ED, 0x4343C586, 0x4D4DD79A, 0x33335566, 0x85859411,
3801
- 0x4545CF8A, 0xF9F910E9, 0x02020604, 0x7F7F81FE, 0x5050F0A0, 0x3C3C4478, 0x9F9FBA25, 0xA8A8E34B,
3802
- 0x5151F3A2, 0xA3A3FE5D, 0x4040C080, 0x8F8F8A05, 0x9292AD3F, 0x9D9DBC21, 0x38384870, 0xF5F504F1,
3803
- 0xBCBCDF63, 0xB6B6C177, 0xDADA75AF, 0x21216342, 0x10103020, 0xFFFF1AE5, 0xF3F30EFD, 0xD2D26DBF,
3804
- 0xCDCD4C81, 0x0C0C1418, 0x13133526, 0xECEC2FC3, 0x5F5FE1BE, 0x9797A235, 0x4444CC88, 0x1717392E,
3805
- 0xC4C45793, 0xA7A7F255, 0x7E7E82FC, 0x3D3D477A, 0x6464ACC8, 0x5D5DE7BA, 0x19192B32, 0x737395E6,
3806
- 0x6060A0C0, 0x81819819, 0x4F4FD19E, 0xDCDC7FA3, 0x22226644, 0x2A2A7E54, 0x9090AB3B, 0x8888830B,
3807
- 0x4646CA8C, 0xEEEE29C7, 0xB8B8D36B, 0x14143C28, 0xDEDE79A7, 0x5E5EE2BC, 0x0B0B1D16, 0xDBDB76AD,
3808
- 0xE0E03BDB, 0x32325664, 0x3A3A4E74, 0x0A0A1E14, 0x4949DB92, 0x06060A0C, 0x24246C48, 0x5C5CE4B8,
3809
- 0xC2C25D9F, 0xD3D36EBD, 0xACACEF43, 0x6262A6C4, 0x9191A839, 0x9595A431, 0xE4E437D3, 0x79798BF2,
3810
- 0xE7E732D5, 0xC8C8438B, 0x3737596E, 0x6D6DB7DA, 0x8D8D8C01, 0xD5D564B1, 0x4E4ED29C, 0xA9A9E049,
3811
- 0x6C6CB4D8, 0x5656FAAC, 0xF4F407F3, 0xEAEA25CF, 0x6565AFCA, 0x7A7A8EF4, 0xAEAEE947, 0x08081810,
3812
- 0xBABAD56F, 0x787888F0, 0x25256F4A, 0x2E2E725C, 0x1C1C2438, 0xA6A6F157, 0xB4B4C773, 0xC6C65197,
3813
- 0xE8E823CB, 0xDDDD7CA1, 0x74749CE8, 0x1F1F213E, 0x4B4BDD96, 0xBDBDDC61, 0x8B8B860D, 0x8A8A850F,
3814
- 0x707090E0, 0x3E3E427C, 0xB5B5C471, 0x6666AACC, 0x4848D890, 0x03030506, 0xF6F601F7, 0x0E0E121C,
3815
- 0x6161A3C2, 0x35355F6A, 0x5757F9AE, 0xB9B9D069, 0x86869117, 0xC1C15899, 0x1D1D273A, 0x9E9EB927,
3816
- 0xE1E138D9, 0xF8F813EB, 0x9898B32B, 0x11113322, 0x6969BBD2, 0xD9D970A9, 0x8E8E8907, 0x9494A733,
3817
- 0x9B9BB62D, 0x1E1E223C, 0x87879215, 0xE9E920C9, 0xCECE4987, 0x5555FFAA, 0x28287850, 0xDFDF7AA5,
3818
- 0x8C8C8F03, 0xA1A1F859, 0x89898009, 0x0D0D171A, 0xBFBFDA65, 0xE6E631D7, 0x4242C684, 0x6868B8D0,
3819
- 0x4141C382, 0x9999B029, 0x2D2D775A, 0x0F0F111E, 0xB0B0CB7B, 0x5454FCA8, 0xBBBBD66D, 0x16163A2C
3820
- ));
3821
-
3822
- foreach ($t3 as $t3i) {
3823
- $t0[] = (($t3i << 24) & 0xFF000000) | (($t3i >> 8) & 0x00FFFFFF);
3824
- $t1[] = (($t3i << 16) & 0xFFFF0000) | (($t3i >> 16) & 0x0000FFFF);
3825
- $t2[] = (($t3i << 8) & 0xFFFFFF00) | (($t3i >> 24) & 0x000000FF);
3826
- }
3827
-
3828
- $tables = array(
3829
- // The Precomputed mixColumns tables t0 - t3
3830
- $t0,
3831
- $t1,
3832
- $t2,
3833
- $t3,
3834
- // The SubByte S-Box
3835
- array(
3836
- 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76,
3837
- 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0,
3838
- 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15,
3839
- 0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75,
3840
- 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0, 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84,
3841
- 0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B, 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF,
3842
- 0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85, 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8,
3843
- 0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5, 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2,
3844
- 0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17, 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73,
3845
- 0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88, 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB,
3846
- 0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C, 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79,
3847
- 0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9, 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08,
3848
- 0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A,
3849
- 0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E, 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E,
3850
- 0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94, 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF,
3851
- 0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16
3852
- )
3853
- );
3854
- }
3855
- return $tables;
3856
- }
3857
-
3858
- /**
3859
- * Provides the inverse mixColumns and inverse sboxes tables
3860
- *
3861
- * @see Crypt_Rijndael:_decryptBlock()
3862
- * @see Crypt_Rijndael:_setupInlineCrypt()
3863
- * @see Crypt_Rijndael:_setupKey()
3864
- * @access private
3865
- * @return array &$tables
3866
- */
3867
- function &_getInvTables()
3868
- {
3869
- static $tables;
3870
- if (empty($tables)) {
3871
- $dt3 = array_map('intval', array(
3872
- 0xF4A75051, 0x4165537E, 0x17A4C31A, 0x275E963A, 0xAB6BCB3B, 0x9D45F11F, 0xFA58ABAC, 0xE303934B,
3873
- 0x30FA5520, 0x766DF6AD, 0xCC769188, 0x024C25F5, 0xE5D7FC4F, 0x2ACBD7C5, 0x35448026, 0x62A38FB5,
3874
- 0xB15A49DE, 0xBA1B6725, 0xEA0E9845, 0xFEC0E15D, 0x2F7502C3, 0x4CF01281, 0x4697A38D, 0xD3F9C66B,
3875
- 0x8F5FE703, 0x929C9515, 0x6D7AEBBF, 0x5259DA95, 0xBE832DD4, 0x7421D358, 0xE0692949, 0xC9C8448E,
3876
- 0xC2896A75, 0x8E7978F4, 0x583E6B99, 0xB971DD27, 0xE14FB6BE, 0x88AD17F0, 0x20AC66C9, 0xCE3AB47D,
3877
- 0xDF4A1863, 0x1A3182E5, 0x51336097, 0x537F4562, 0x6477E0B1, 0x6BAE84BB, 0x81A01CFE, 0x082B94F9,
3878
- 0x48685870, 0x45FD198F, 0xDE6C8794, 0x7BF8B752, 0x73D323AB, 0x4B02E272, 0x1F8F57E3, 0x55AB2A66,
3879
- 0xEB2807B2, 0xB5C2032F, 0xC57B9A86, 0x3708A5D3, 0x2887F230, 0xBFA5B223, 0x036ABA02, 0x16825CED,
3880
- 0xCF1C2B8A, 0x79B492A7, 0x07F2F0F3, 0x69E2A14E, 0xDAF4CD65, 0x05BED506, 0x34621FD1, 0xA6FE8AC4,
3881
- 0x2E539D34, 0xF355A0A2, 0x8AE13205, 0xF6EB75A4, 0x83EC390B, 0x60EFAA40, 0x719F065E, 0x6E1051BD,
3882
- 0x218AF93E, 0xDD063D96, 0x3E05AEDD, 0xE6BD464D, 0x548DB591, 0xC45D0571, 0x06D46F04, 0x5015FF60,
3883
- 0x98FB2419, 0xBDE997D6, 0x4043CC89, 0xD99E7767, 0xE842BDB0, 0x898B8807, 0x195B38E7, 0xC8EEDB79,
3884
- 0x7C0A47A1, 0x420FE97C, 0x841EC9F8, 0x00000000, 0x80868309, 0x2BED4832, 0x1170AC1E, 0x5A724E6C,
3885
- 0x0EFFFBFD, 0x8538560F, 0xAED51E3D, 0x2D392736, 0x0FD9640A, 0x5CA62168, 0x5B54D19B, 0x362E3A24,
3886
- 0x0A67B10C, 0x57E70F93, 0xEE96D2B4, 0x9B919E1B, 0xC0C54F80, 0xDC20A261, 0x774B695A, 0x121A161C,
3887
- 0x93BA0AE2, 0xA02AE5C0, 0x22E0433C, 0x1B171D12, 0x090D0B0E, 0x8BC7ADF2, 0xB6A8B92D, 0x1EA9C814,
3888
- 0xF1198557, 0x75074CAF, 0x99DDBBEE, 0x7F60FDA3, 0x01269FF7, 0x72F5BC5C, 0x663BC544, 0xFB7E345B,
3889
- 0x4329768B, 0x23C6DCCB, 0xEDFC68B6, 0xE4F163B8, 0x31DCCAD7, 0x63851042, 0x97224013, 0xC6112084,
3890
- 0x4A247D85, 0xBB3DF8D2, 0xF93211AE, 0x29A16DC7, 0x9E2F4B1D, 0xB230F3DC, 0x8652EC0D, 0xC1E3D077,
3891
- 0xB3166C2B, 0x70B999A9, 0x9448FA11, 0xE9642247, 0xFC8CC4A8, 0xF03F1AA0, 0x7D2CD856, 0x3390EF22,
3892
- 0x494EC787, 0x38D1C1D9, 0xCAA2FE8C, 0xD40B3698, 0xF581CFA6, 0x7ADE28A5, 0xB78E26DA, 0xADBFA43F,
3893
- 0x3A9DE42C, 0x78920D50, 0x5FCC9B6A, 0x7E466254, 0x8D13C2F6, 0xD8B8E890, 0x39F75E2E, 0xC3AFF582,
3894
- 0x5D80BE9F, 0xD0937C69, 0xD52DA96F, 0x2512B3CF, 0xAC993BC8, 0x187DA710, 0x9C636EE8, 0x3BBB7BDB,
3895
- 0x267809CD, 0x5918F46E, 0x9AB701EC, 0x4F9AA883, 0x956E65E6, 0xFFE67EAA, 0xBCCF0821, 0x15E8E6EF,
3896
- 0xE79BD9BA, 0x6F36CE4A, 0x9F09D4EA, 0xB07CD629, 0xA4B2AF31, 0x3F23312A, 0xA59430C6, 0xA266C035,
3897
- 0x4EBC3774, 0x82CAA6FC, 0x90D0B0E0, 0xA7D81533, 0x04984AF1, 0xECDAF741, 0xCD500E7F, 0x91F62F17,
3898
- 0x4DD68D76, 0xEFB04D43, 0xAA4D54CC, 0x9604DFE4, 0xD1B5E39E, 0x6A881B4C, 0x2C1FB8C1, 0x65517F46,
3899
- 0x5EEA049D, 0x8C355D01, 0x877473FA, 0x0B412EFB, 0x671D5AB3, 0xDBD25292, 0x105633E9, 0xD647136D,
3900
- 0xD7618C9A, 0xA10C7A37, 0xF8148E59, 0x133C89EB, 0xA927EECE, 0x61C935B7, 0x1CE5EDE1, 0x47B13C7A,
3901
- 0xD2DF599C, 0xF2733F55, 0x14CE7918, 0xC737BF73, 0xF7CDEA53, 0xFDAA5B5F, 0x3D6F14DF, 0x44DB8678,
3902
- 0xAFF381CA, 0x68C43EB9, 0x24342C38, 0xA3405FC2, 0x1DC37216, 0xE2250CBC, 0x3C498B28, 0x0D9541FF,
3903
- 0xA8017139, 0x0CB3DE08, 0xB4E49CD8, 0x56C19064, 0xCB84617B, 0x32B670D5, 0x6C5C7448, 0xB85742D0
3904
- ));
3905
-
3906
- foreach ($dt3 as $dt3i) {
3907
- $dt0[] = (($dt3i << 24) & 0xFF000000) | (($dt3i >> 8) & 0x00FFFFFF);
3908
- $dt1[] = (($dt3i << 16) & 0xFFFF0000) | (($dt3i >> 16) & 0x0000FFFF);
3909
- $dt2[] = (($dt3i << 8) & 0xFFFFFF00) | (($dt3i >> 24) & 0x000000FF);
3910
- };
3911
-
3912
- $tables = array(
3913
- // The Precomputed inverse mixColumns tables dt0 - dt3
3914
- $dt0,
3915
- $dt1,
3916
- $dt2,
3917
- $dt3,
3918
- // The inverse SubByte S-Box
3919
- array(
3920
- 0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB,
3921
- 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87, 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB,
3922
- 0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D, 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E,
3923
- 0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2, 0x76, 0x5B, 0xA2, 0x49, 0x6D, 0x8B, 0xD1, 0x25,
3924
- 0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92,
3925
- 0x6C, 0x70, 0x48, 0x50, 0xFD, 0xED, 0xB9, 0xDA, 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84,
3926
- 0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A, 0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06,
3927
- 0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02, 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B,
3928
- 0x3A, 0x91, 0x11, 0x41, 0x4F, 0x67, 0xDC, 0xEA, 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73,
3929
- 0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85, 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E,
3930
- 0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89, 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B,
3931
- 0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20, 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4,
3932
- 0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F,
3933
- 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF,
3934
- 0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0, 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61,
3935
- 0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D
3936
- )
3937
- );
3938
- }
3939
- return $tables;
3940
- }
3941
-
3942
- /**
3943
- * Setup the performance-optimized function for de/encrypt()
3944
- *
3945
- * @see Crypt_Base::_setupInlineCrypt()
3946
- * @access private
3947
- */
3948
- function _setupInlineCrypt()
3949
- {
3950
- // Note: _setupInlineCrypt() will be called only if $this->changed === true
3951
- // So here we are'nt under the same heavy timing-stress as we are in _de/encryptBlock() or de/encrypt().
3952
- // However...the here generated function- $code, stored as php callback in $this->inline_crypt, must work as fast as even possible.
3953
-
3954
- $lambda_functions =& Crypt_Rijndael::_getLambdaFunctions();
3955
-
3956
- // We create max. 10 hi-optimized code for memory reason. Means: For each $key one ultra fast inline-crypt function.
3957
- // (Currently, for Crypt_Rijndael/AES, one generated $lambda_function cost on php5.5@32bit ~80kb unfreeable mem and ~130kb on php5.5@64bit)
3958
- // After that, we'll still create very fast optimized code but not the hi-ultimative code, for each $mode one.
3959
- $gen_hi_opt_code = (bool)(count($lambda_functions) < 10);
3960
-
3961
- // Generation of a uniqe hash for our generated code
3962
- $code_hash = "Crypt_Rijndael, {$this->mode}, {$this->Nr}, {$this->Nb}";
3963
- if ($gen_hi_opt_code) {
3964
- $code_hash = str_pad($code_hash, 32) . $this->_hashInlineCryptFunction($this->key);
3965
- }
3966
-
3967
- if (!isset($lambda_functions[$code_hash])) {
3968
- switch (true) {
3969
- case $gen_hi_opt_code:
3970
- // The hi-optimized $lambda_functions will use the key-words hardcoded for better performance.
3971
- $w = $this->w;
3972
- $dw = $this->dw;
3973
- $init_encrypt = '';
3974
- $init_decrypt = '';
3975
- break;
3976
- default:
3977
- for ($i = 0, $cw = count($this->w); $i < $cw; ++$i) {
3978
- $w[] = '$w[' . $i . ']';
3979
- $dw[] = '$dw[' . $i . ']';
3980
- }
3981
- $init_encrypt = '$w = $self->w;';
3982
- $init_decrypt = '$dw = $self->dw;';
3983
- }
3984
-
3985
- $Nr = $this->Nr;
3986
- $Nb = $this->Nb;
3987
- $c = $this->c;
3988
-
3989
- // Generating encrypt code:
3990
- $init_encrypt.= '
3991
- static $tables;
3992
- if (empty($tables)) {
3993
- $tables = &$self->_getTables();
3994
- }
3995
- $t0 = $tables[0];
3996
- $t1 = $tables[1];
3997
- $t2 = $tables[2];
3998
- $t3 = $tables[3];
3999
- $sbox = $tables[4];
4000
- ';
4001
-
4002
- $s = 'e';
4003
- $e = 's';
4004
- $wc = $Nb - 1;
4005
-
4006
- // Preround: addRoundKey
4007
- $encrypt_block = '$in = unpack("N*", $in);'."\n";
4008
- for ($i = 0; $i < $Nb; ++$i) {
4009
- $encrypt_block .= '$s'.$i.' = $in['.($i + 1).'] ^ '.$w[++$wc].";\n";
4010
- }
4011
-
4012
- // Mainrounds: shiftRows + subWord + mixColumns + addRoundKey
4013
- for ($round = 1; $round < $Nr; ++$round) {
4014
- list($s, $e) = array($e, $s);
4015
- for ($i = 0; $i < $Nb; ++$i) {
4016
- $encrypt_block.=
4017
- '$'.$e.$i.' =
4018
- $t0[($'.$s.$i .' >> 24) & 0xff] ^
4019
- $t1[($'.$s.(($i + $c[1]) % $Nb).' >> 16) & 0xff] ^
4020
- $t2[($'.$s.(($i + $c[2]) % $Nb).' >> 8) & 0xff] ^
4021
- $t3[ $'.$s.(($i + $c[3]) % $Nb).' & 0xff] ^
4022
- '.$w[++$wc].";\n";
4023
- }
4024
- }
4025
-
4026
- // Finalround: subWord + shiftRows + addRoundKey
4027
- for ($i = 0; $i < $Nb; ++$i) {
4028
- $encrypt_block.=
4029
- '$'.$e.$i.' =
4030
- $sbox[ $'.$e.$i.' & 0xff] |
4031
- ($sbox[($'.$e.$i.' >> 8) & 0xff] << 8) |
4032
- ($sbox[($'.$e.$i.' >> 16) & 0xff] << 16) |
4033
- ($sbox[($'.$e.$i.' >> 24) & 0xff] << 24);'."\n";
4034
- }
4035
- $encrypt_block .= '$in = pack("N*"'."\n";
4036
- for ($i = 0; $i < $Nb; ++$i) {
4037
- $encrypt_block.= ',
4038
- ($'.$e.$i .' & '.((int)0xFF000000).') ^
4039
- ($'.$e.(($i + $c[1]) % $Nb).' & 0x00FF0000 ) ^
4040
- ($'.$e.(($i + $c[2]) % $Nb).' & 0x0000FF00 ) ^
4041
- ($'.$e.(($i + $c[3]) % $Nb).' & 0x000000FF ) ^
4042
- '.$w[$i]."\n";
4043
- }
4044
- $encrypt_block .= ');';
4045
-
4046
- // Generating decrypt code:
4047
- $init_decrypt.= '
4048
- static $invtables;
4049
- if (empty($invtables)) {
4050
- $invtables = &$self->_getInvTables();
4051
- }
4052
- $dt0 = $invtables[0];
4053
- $dt1 = $invtables[1];
4054
- $dt2 = $invtables[2];
4055
- $dt3 = $invtables[3];
4056
- $isbox = $invtables[4];
4057
- ';
4058
-
4059
- $s = 'e';
4060
- $e = 's';
4061
- $wc = $Nb - 1;
4062
-
4063
- // Preround: addRoundKey
4064
- $decrypt_block = '$in = unpack("N*", $in);'."\n";
4065
- for ($i = 0; $i < $Nb; ++$i) {
4066
- $decrypt_block .= '$s'.$i.' = $in['.($i + 1).'] ^ '.$dw[++$wc].';'."\n";
4067
- }
4068
-
4069
- // Mainrounds: shiftRows + subWord + mixColumns + addRoundKey
4070
- for ($round = 1; $round < $Nr; ++$round) {
4071
- list($s, $e) = array($e, $s);
4072
- for ($i = 0; $i < $Nb; ++$i) {
4073
- $decrypt_block.=
4074
- '$'.$e.$i.' =
4075
- $dt0[($'.$s.$i .' >> 24) & 0xff] ^
4076
- $dt1[($'.$s.(($Nb + $i - $c[1]) % $Nb).' >> 16) & 0xff] ^
4077
- $dt2[($'.$s.(($Nb + $i - $c[2]) % $Nb).' >> 8) & 0xff] ^
4078
- $dt3[ $'.$s.(($Nb + $i - $c[3]) % $Nb).' & 0xff] ^
4079
- '.$dw[++$wc].";\n";
4080
- }
4081
- }
4082
-
4083
- // Finalround: subWord + shiftRows + addRoundKey
4084
- for ($i = 0; $i < $Nb; ++$i) {
4085
- $decrypt_block.=
4086
- '$'.$e.$i.' =
4087
- $isbox[ $'.$e.$i.' & 0xff] |
4088
- ($isbox[($'.$e.$i.' >> 8) & 0xff] << 8) |
4089
- ($isbox[($'.$e.$i.' >> 16) & 0xff] << 16) |
4090
- ($isbox[($'.$e.$i.' >> 24) & 0xff] << 24);'."\n";
4091
- }
4092
- $decrypt_block .= '$in = pack("N*"'."\n";
4093
- for ($i = 0; $i < $Nb; ++$i) {
4094
- $decrypt_block.= ',
4095
- ($'.$e.$i. ' & '.((int)0xFF000000).') ^
4096
- ($'.$e.(($Nb + $i - $c[1]) % $Nb).' & 0x00FF0000 ) ^
4097
- ($'.$e.(($Nb + $i - $c[2]) % $Nb).' & 0x0000FF00 ) ^
4098
- ($'.$e.(($Nb + $i - $c[3]) % $Nb).' & 0x000000FF ) ^
4099
- '.$dw[$i]."\n";
4100
- }
4101
- $decrypt_block .= ');';
4102
-
4103
- $lambda_functions[$code_hash] = $this->_createInlineCryptFunction(
4104
- array(
4105
- 'init_crypt' => '',
4106
- 'init_encrypt' => $init_encrypt,
4107
- 'init_decrypt' => $init_decrypt,
4108
- 'encrypt_block' => $encrypt_block,
4109
- 'decrypt_block' => $decrypt_block
4110
- )
4111
- );
4112
- }
4113
- $this->inline_crypt = $lambda_functions[$code_hash];
4114
- }
4115
- }
4116
-
4117
  class DUPX_CSRF {
4118
 
4119
  /** Session var name
4120
  * @var string
4121
  */
4122
  public static $prefix = '_DUPX_CSRF';
4123
- private static $cipher;
4124
  private static $CSRFVars;
4125
 
4126
  public static function setKeyVal($key, $val) {
@@ -4152,10 +95,6 @@ class DUPX_CSRF {
4152
  $token = $existingToken;
4153
  } else {
4154
  $token = DUPX_CSRF::token() . DUPX_CSRF::fingerprint();
4155
- if (self::isCrypt()) {
4156
- // $keyName = self::encrypt($keyName);
4157
- $token = self::encrypt($token);
4158
- }
4159
  }
4160
 
4161
  self::setKeyVal($keyName, $token);
@@ -4169,14 +108,9 @@ class DUPX_CSRF {
4169
  */
4170
  public static function check($token, $form = NULL) {
4171
  $keyName = self::getKeyName($form);
4172
- // if (self::isCrypt()) {
4173
- // $keyName = self::decrypt($keyName);
4174
- // $token = self::decrypt($token);
4175
- // }
4176
  $CSRFVars = self::getCSRFVars();
4177
  if (isset($CSRFVars[$keyName]) && $CSRFVars[$keyName] == $token) { // token OK
4178
  return true;
4179
- // return (substr($token, -32) == DUPX_CSRF::fingerprint()); // fingerprint OK?
4180
  }
4181
  return FALSE;
4182
  }
@@ -4203,18 +137,6 @@ class DUPX_CSRF {
4203
  return DUPX_CSRF::$prefix . '_' . $form;
4204
  }
4205
 
4206
- private static function isCrypt() {
4207
- if (class_exists('DUPX_Bootstrap')) {
4208
- return DUPX_Bootstrap::CSRF_CRYPT;
4209
- } else {
4210
- return $GLOBALS['DUPX_AC']->csrf_crypt;
4211
- }
4212
- }
4213
-
4214
- private static function getCryptKey() {
4215
- return 'snapcreek-'.self::getPackageHash();
4216
- }
4217
-
4218
  private static function getPackageHash() {
4219
  if (class_exists('DUPX_Bootstrap')) {
4220
  return DUPX_Bootstrap::PACKAGE_HASH;
@@ -4260,27 +182,6 @@ class DUPX_CSRF {
4260
  $filePath = self::getFilePath();
4261
  file_put_contents($filePath, $contents);
4262
  }
4263
-
4264
- private static function getCipher() {
4265
- if (!isset(self::$cipher)) {
4266
- self::$cipher = new Crypt_Rijndael();
4267
- $cryptKey = self::getCryptKey();
4268
- self::$cipher->setKey($cryptKey);
4269
- }
4270
- return self::$cipher;
4271
- }
4272
-
4273
- private static function encrypt($val) {
4274
- $cipher = self::getCipher();
4275
- $val = $cipher->encrypt($val);
4276
- return base64_encode($val);
4277
- }
4278
-
4279
- private static function decrypt($val) {
4280
- $cipher = self::getCipher();
4281
- $val = base64_decode($val);
4282
- return $cipher->decrypt($val);
4283
- }
4284
  }
4285
 
4286
  /**
@@ -4318,7 +219,6 @@ class DUPX_Bootstrap
4318
  const ARCHIVE_SIZE = '@@ARCHIVE_SIZE@@';
4319
  const INSTALLER_DIR_NAME = 'dup-installer';
4320
  const PACKAGE_HASH = '@@PACKAGE_HASH@@';
4321
- const CSRF_CRYPT = @@CSRF_CRYPT@@;
4322
  const VERSION = '@@VERSION@@';
4323
 
4324
  public $hasZipArchive = false;
@@ -4415,6 +315,8 @@ class DUPX_Bootstrap
4415
  . "The archive file name must be the <u>exact</u> name of the archive file placed in the extraction path character for character.<br/><br/> "
4416
  . "If the file does not have the correct name then rename it to the <i>'Required File'</i> below. When downloading the package files make "
4417
  . "sure both files are from the same package line in the packages view. If the archive is not finished downloading please wait for it to complete.<br/><br/>"
 
 
4418
  . "<b>Required File:</b> <span class='file-info'>{$archive_filename}</span> <br/>"
4419
  . "<b>Extraction Path:</b> <span class='file-info'>{$this->installerExtractPath}/</span><br/><br/>"
4420
  . "Potential archives found at extraction path: <br/>{$candidate_html}<br/><br/>";
58
  if (wp_is_ini_value_changeable('default_socket_timeout'))
59
  @ini_set('default_socket_timeout', 3600);
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  class DUPX_CSRF {
62
 
63
  /** Session var name
64
  * @var string
65
  */
66
  public static $prefix = '_DUPX_CSRF';
 
67
  private static $CSRFVars;
68
 
69
  public static function setKeyVal($key, $val) {
95
  $token = $existingToken;
96
  } else {
97
  $token = DUPX_CSRF::token() . DUPX_CSRF::fingerprint();
 
 
 
 
98
  }
99
 
100
  self::setKeyVal($keyName, $token);
108
  */
109
  public static function check($token, $form = NULL) {
110
  $keyName = self::getKeyName($form);
 
 
 
 
111
  $CSRFVars = self::getCSRFVars();
112
  if (isset($CSRFVars[$keyName]) && $CSRFVars[$keyName] == $token) { // token OK
113
  return true;
 
114
  }
115
  return FALSE;
116
  }
137
  return DUPX_CSRF::$prefix . '_' . $form;
138
  }
139
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  private static function getPackageHash() {
141
  if (class_exists('DUPX_Bootstrap')) {
142
  return DUPX_Bootstrap::PACKAGE_HASH;
182
  $filePath = self::getFilePath();
183
  file_put_contents($filePath, $contents);
184
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  }
186
 
187
  /**
219
  const ARCHIVE_SIZE = '@@ARCHIVE_SIZE@@';
220
  const INSTALLER_DIR_NAME = 'dup-installer';
221
  const PACKAGE_HASH = '@@PACKAGE_HASH@@';
 
222
  const VERSION = '@@VERSION@@';
223
 
224
  public $hasZipArchive = false;
315
  . "The archive file name must be the <u>exact</u> name of the archive file placed in the extraction path character for character.<br/><br/> "
316
  . "If the file does not have the correct name then rename it to the <i>'Required File'</i> below. When downloading the package files make "
317
  . "sure both files are from the same package line in the packages view. If the archive is not finished downloading please wait for it to complete.<br/><br/>"
318
+ . "If this message continues even with a valid archive file, consider clearing your browsers cache and refreshing, trying another browser or change the browsers "
319
+ . "URL from http to https or vice versa.<br/><br/> "
320
  . "<b>Required File:</b> <span class='file-info'>{$archive_filename}</span> <br/>"
321
  . "<b>Extraction Path:</b> <span class='file-info'>{$this->installerExtractPath}/</span><br/><br/>"
322
  . "Potential archives found at extraction path: <br/>{$candidate_html}<br/><br/>";
lib/config/class.wp.config.tranformer.php CHANGED
@@ -275,9 +275,13 @@ class WPConfigTransformer {
275
  $new_src = implode( '', $new_parts );
276
  }
277
 
 
 
 
 
278
  $contents = preg_replace(
279
  sprintf( '/(?<=^|;|<\?php\s|<\?\s)(\s*?)%s/m', preg_quote( trim( $old_src ), '/' ) ),
280
- '$1' . str_replace( '$', '\$', trim( $new_src ) ),
281
  $this->wp_config_src
282
  );
283
 
@@ -429,4 +433,4 @@ class WPConfigTransformer {
429
 
430
  }
431
 
432
- endif;
275
  $new_src = implode( '', $new_parts );
276
  }
277
 
278
+ // regex: (^\$|^(?:\\\\)+|[^\\](?:\\\\)+|[^\\])\$
279
+ // subst: $1\\$
280
+ $safe_new_src = preg_replace('/(^\$|^(?:\\\\\\\\)+|[^\\\\](?:\\\\\\\\)+|[^\\\\])\$/m', '$1\\\\$' , trim($new_src));
281
+
282
  $contents = preg_replace(
283
  sprintf( '/(?<=^|;|<\?php\s|<\?\s)(\s*?)%s/m', preg_quote( trim( $old_src ), '/' ) ),
284
+ '$1' . $safe_new_src,
285
  $this->wp_config_src
286
  );
287
 
433
 
434
  }
435
 
436
+ endif;
lib/dup_archive/classes/class.duparchive.engine.php CHANGED
@@ -103,7 +103,7 @@ class DupArchiveEngine
103
  $archiveInfo = new DupArchiveInfo();
104
 
105
  DupArchiveUtil::log("archive size=" . filesize($filepath));
106
- $archiveHandle = SnapLibIOU::fopen($filepath, 'rb');
107
  $moreFiles = true;
108
 
109
  $archiveInfo->archiveHeader = DupArchiveHeader::readFromArchive($archiveHandle);
@@ -223,7 +223,7 @@ class DupArchiveEngine
223
 
224
  public static function createArchive($archivePath, $isCompressed)
225
  {
226
- $archiveHandle = SnapLibIOU::fopen($archivePath, 'w+b');
227
 
228
  /* @var $archiveHeader DupArchiveHeader */
229
  $archiveHeader = DupArchiveHeader::create($isCompressed);
@@ -232,7 +232,7 @@ class DupArchiveEngine
232
 
233
  // Intentionally do not write build state since if something goes wrong we went it to start over on the archive
234
 
235
- SnapLibIOU::fclose($archiveHandle);
236
  }
237
 
238
  public static function addItemsToArchive($createState, $scanFSInfo)
@@ -252,10 +252,10 @@ class DupArchiveEngine
252
  /* @var $createState DupArchiveCreateState */
253
  $basepathLength = strlen($createState->basePath);
254
 
255
- $archiveHandle = SnapLibIOU::fopen($createState->archivePath, 'r+b');
256
 
257
  DupArchiveUtil::tlog("Archive size=", filesize($createState->archivePath));
258
- DupArchiveUtil::tlog("Archive location is now " . SnapLibIOU::ftell($archiveHandle));
259
 
260
  $archiveHeader = DupArchiveHeader::readFromArchive($archiveHandle);
261
 
@@ -263,10 +263,10 @@ class DupArchiveEngine
263
 
264
  if ($createState->archiveOffset == filesize($createState->archivePath)) {
265
  DupArchiveUtil::tlog("Seeking to end of archive location because of offset {$createState->archiveOffset} for file size " . filesize($createState->archivePath));
266
- SnapLibIOU::fseek($archiveHandle, 0, SEEK_END);
267
  } else {
268
  DupArchiveUtil::tlog("Seeking archive offset {$createState->archiveOffset} for file size " . filesize($createState->archivePath));
269
- SnapLibIOU::fseek($archiveHandle, $createState->archiveOffset);
270
  }
271
 
272
  while (($createState->currentDirectoryIndex < $directoryCount) && (!$createState->timedOut())) {
@@ -310,7 +310,7 @@ class DupArchiveEngine
310
  }
311
  }
312
 
313
- $createState->archiveOffset = SnapLibIOU::ftell($archiveHandle);
314
 
315
  $workTimestamp = time();
316
  while (($createState->currentFileIndex < $fileCount) && (!$createState->timedOut())) {
@@ -365,7 +365,7 @@ class DupArchiveEngine
365
  $createState->working = ($createState->currentDirectoryIndex < $directoryCount) || ($createState->currentFileIndex < $fileCount);
366
  $createState->save();
367
 
368
- SnapLibIOU::fclose($archiveHandle);
369
 
370
  if (!$createState->working) {
371
  DupArchiveUtil::log("compress done");
@@ -383,9 +383,9 @@ class DupArchiveEngine
383
  /* @var $expandState DupArchiveExpandState */
384
  $expandState->startTimer();
385
 
386
- $archiveHandle = SnapLibIOU::fopen($expandState->archivePath, 'rb');
387
 
388
- SnapLibIOU::fseek($archiveHandle, $expandState->archiveOffset);
389
 
390
  if ($expandState->archiveOffset == 0) {
391
 
@@ -393,7 +393,7 @@ class DupArchiveEngine
393
 
394
  $expandState->archiveHeader = DupArchiveHeader::readFromArchive($archiveHandle);
395
  $expandState->isCompressed = $expandState->archiveHeader->isCompressed;
396
- $expandState->archiveOffset = SnapLibIOU::ftell($archiveHandle);
397
 
398
  $expandState->save();
399
  } else {
@@ -412,7 +412,7 @@ class DupArchiveEngine
412
  $expandState->working = $moreItems;
413
  $expandState->save();
414
 
415
- SnapLibIOU::fclose($archiveHandle, false);
416
 
417
  if (!$expandState->working) {
418
 
@@ -478,14 +478,14 @@ class DupArchiveEngine
478
  // Not setting timeout timestamp so it will never timeout
479
  DupArchiveUtil::tlog("opening archive {$archiveFilePath}");
480
 
481
- $archiveHandle = SnapLibIOU::fopen($archiveFilePath, 'r');
482
 
483
  /* @var $expandState DupArchiveSimpleExpandState */
484
  $expandState = new DupArchiveSimpleExpandState();
485
 
486
  $expandState->archiveHeader = DupArchiveHeader::readFromArchive($archiveHandle);
487
  $expandState->isCompressed = $expandState->archiveHeader->isCompressed;
488
- $expandState->archiveOffset = SnapLibIOU::ftell($archiveHandle);
489
  $expandState->includedFiles = $relativeFilePaths;
490
  $expandState->filteredDirectories = array('*');
491
  $expandState->filteredFiles = array('*');
@@ -523,7 +523,7 @@ class DupArchiveEngine
523
 
524
  // Reset things - skip over this file within the archive.
525
 
526
- SnapLibIOU::fseek($archiveHandle, $expandState->lastHeaderOffset);
527
 
528
  self::skipToNextHeader($archiveHandle, $expandState->currentFileHeader);
529
 
103
  $archiveInfo = new DupArchiveInfo();
104
 
105
  DupArchiveUtil::log("archive size=" . filesize($filepath));
106
+ $archiveHandle = DupLiteSnapLibIOU::fopen($filepath, 'rb');
107
  $moreFiles = true;
108
 
109
  $archiveInfo->archiveHeader = DupArchiveHeader::readFromArchive($archiveHandle);
223
 
224
  public static function createArchive($archivePath, $isCompressed)
225
  {
226
+ $archiveHandle = DupLiteSnapLibIOU::fopen($archivePath, 'w+b');
227
 
228
  /* @var $archiveHeader DupArchiveHeader */
229
  $archiveHeader = DupArchiveHeader::create($isCompressed);
232
 
233
  // Intentionally do not write build state since if something goes wrong we went it to start over on the archive
234
 
235
+ DupLiteSnapLibIOU::fclose($archiveHandle);
236
  }
237
 
238
  public static function addItemsToArchive($createState, $scanFSInfo)
252
  /* @var $createState DupArchiveCreateState */
253
  $basepathLength = strlen($createState->basePath);
254
 
255
+ $archiveHandle = DupLiteSnapLibIOU::fopen($createState->archivePath, 'r+b');
256
 
257
  DupArchiveUtil::tlog("Archive size=", filesize($createState->archivePath));
258
+ DupArchiveUtil::tlog("Archive location is now " . DupLiteSnapLibIOU::ftell($archiveHandle));
259
 
260
  $archiveHeader = DupArchiveHeader::readFromArchive($archiveHandle);
261
 
263
 
264
  if ($createState->archiveOffset == filesize($createState->archivePath)) {
265
  DupArchiveUtil::tlog("Seeking to end of archive location because of offset {$createState->archiveOffset} for file size " . filesize($createState->archivePath));
266
+ DupLiteSnapLibIOU::fseek($archiveHandle, 0, SEEK_END);
267
  } else {
268
  DupArchiveUtil::tlog("Seeking archive offset {$createState->archiveOffset} for file size " . filesize($createState->archivePath));
269
+ DupLiteSnapLibIOU::fseek($archiveHandle, $createState->archiveOffset);
270
  }
271
 
272
  while (($createState->currentDirectoryIndex < $directoryCount) && (!$createState->timedOut())) {
310
  }
311
  }
312
 
313
+ $createState->archiveOffset = DupLiteSnapLibIOU::ftell($archiveHandle);
314
 
315
  $workTimestamp = time();
316
  while (($createState->currentFileIndex < $fileCount) && (!$createState->timedOut())) {
365
  $createState->working = ($createState->currentDirectoryIndex < $directoryCount) || ($createState->currentFileIndex < $fileCount);
366
  $createState->save();
367
 
368
+ DupLiteSnapLibIOU::fclose($archiveHandle);
369
 
370
  if (!$createState->working) {
371
  DupArchiveUtil::log("compress done");
383
  /* @var $expandState DupArchiveExpandState */
384
  $expandState->startTimer();
385
 
386
+ $archiveHandle = DupLiteSnapLibIOU::fopen($expandState->archivePath, 'rb');
387
 
388
+ DupLiteSnapLibIOU::fseek($archiveHandle, $expandState->archiveOffset);
389
 
390
  if ($expandState->archiveOffset == 0) {
391
 
393
 
394
  $expandState->archiveHeader = DupArchiveHeader::readFromArchive($archiveHandle);
395
  $expandState->isCompressed = $expandState->archiveHeader->isCompressed;
396
+ $expandState->archiveOffset = DupLiteSnapLibIOU::ftell($archiveHandle);
397
 
398
  $expandState->save();
399
  } else {
412
  $expandState->working = $moreItems;
413
  $expandState->save();
414
 
415
+ DupLiteSnapLibIOU::fclose($archiveHandle, false);
416
 
417
  if (!$expandState->working) {
418
 
478
  // Not setting timeout timestamp so it will never timeout
479
  DupArchiveUtil::tlog("opening archive {$archiveFilePath}");
480
 
481
+ $archiveHandle = DupLiteSnapLibIOU::fopen($archiveFilePath, 'r');
482
 
483
  /* @var $expandState DupArchiveSimpleExpandState */
484
  $expandState = new DupArchiveSimpleExpandState();
485
 
486
  $expandState->archiveHeader = DupArchiveHeader::readFromArchive($archiveHandle);
487
  $expandState->isCompressed = $expandState->archiveHeader->isCompressed;
488
+ $expandState->archiveOffset = DupLiteSnapLibIOU::ftell($archiveHandle);
489
  $expandState->includedFiles = $relativeFilePaths;
490
  $expandState->filteredDirectories = array('*');
491
  $expandState->filteredFiles = array('*');
523
 
524
  // Reset things - skip over this file within the archive.
525
 
526
+ DupLiteSnapLibIOU::fseek($archiveHandle, $expandState->lastHeaderOffset);
527
 
528
  self::skipToNextHeader($archiveHandle, $expandState->currentFileHeader);
529
 
lib/dup_archive/classes/class.duparchive.mini.expander.php CHANGED
@@ -127,7 +127,7 @@ class DupArchiveMiniGlobHeader //extends HeaderBase
127
  fread($archiveHandle, 4);
128
 
129
  if ($skipGlob) {
130
- // SnapLibIOU::fseek($archiveHandle, $instance->storedSize, SEEK_CUR);
131
  if(fseek($archiveHandle, $instance->storedSize, SEEK_CUR) === -1)
132
  {
133
  throw new Exception("Can't fseek when skipping glob at location:".ftell($archiveHandle));
127
  fread($archiveHandle, 4);
128
 
129
  if ($skipGlob) {
130
+ // DupLiteSnapLibIOU::fseek($archiveHandle, $instance->storedSize, SEEK_CUR);
131
  if(fseek($archiveHandle, $instance->storedSize, SEEK_CUR) === -1)
132
  {
133
  throw new Exception("Can't fseek when skipping glob at location:".ftell($archiveHandle));
lib/dup_archive/classes/headers/class.duparchive.header.directory.php CHANGED
@@ -26,7 +26,7 @@ class DupArchiveDirectoryHeader// extends HeaderBase
26
  // $instance = new DupArchiveDirectoryHeader();
27
  //
28
  // $instance->permissions = substr(sprintf('%o', fileperms($directoryPath)), -4);
29
- // $instance->mtime = SnapLibIOU::filemtime($directoryPath);
30
  // $instance->relativePath = $relativePath;
31
  // $instance->relativePathLength = strlen($instance->relativePath);
32
  //
@@ -86,7 +86,7 @@ class DupArchiveDirectoryHeader// extends HeaderBase
86
 
87
  $headerString = '<D><MT>'.$this->mtime.'</MT><P>'.$this->permissions.'</P><RPL>'.$this->relativePathLength.'</RPL><RP>'.$this->relativePath.'</RP></D>';
88
 
89
- //SnapLibIOU::fwrite($archiveHandle, $headerString);
90
  $bytes_written = @fwrite($archiveHandle, $headerString);
91
 
92
  if ($bytes_written === false) {
26
  // $instance = new DupArchiveDirectoryHeader();
27
  //
28
  // $instance->permissions = substr(sprintf('%o', fileperms($directoryPath)), -4);
29
+ // $instance->mtime = DupLiteSnapLibIOU::filemtime($directoryPath);
30
  // $instance->relativePath = $relativePath;
31
  // $instance->relativePathLength = strlen($instance->relativePath);
32
  //
86
 
87
  $headerString = '<D><MT>'.$this->mtime.'</MT><P>'.$this->permissions.'</P><RPL>'.$this->relativePathLength.'</RPL><RP>'.$this->relativePath.'</RP></D>';
88
 
89
+ //DupLiteSnapLibIOU::fwrite($archiveHandle, $headerString);
90
  $bytes_written = @fwrite($archiveHandle, $headerString);
91
 
92
  if ($bytes_written === false) {
lib/dup_archive/classes/headers/class.duparchive.header.file.php CHANGED
@@ -29,7 +29,7 @@ class DupArchiveFileHeader// extends HeaderBase
29
 
30
  // RSR TODO Populate fields based on file already on system
31
  // profile ok
32
- $instance->fileSize = SnapLibIOU::filesize($filepath);
33
  // end profile ok
34
 
35
  // profile ok
@@ -37,7 +37,7 @@ class DupArchiveFileHeader// extends HeaderBase
37
  // end profile ok
38
 
39
  // profile ok
40
- $instance->mtime = SnapLibIOU::filemtime($filepath);
41
  // end profile ok
42
 
43
  if($instance->fileSize > DupArchiveConstants::$MaxFilesizeForHashing) {
@@ -132,7 +132,7 @@ class DupArchiveFileHeader// extends HeaderBase
132
  {
133
  $headerString = '<F><FS>'.$this->fileSize.'</FS><MT>'.$this->mtime.'</MT><P>'.$this->permissions.'</P><HA>'.$this->hash.'</HA><RPL>'.$this->relativePathLength.'</RPL><RP>'.$this->relativePath.'</RP></F>';
134
 
135
- //SnapLibIOU::fwrite($archiveHandle, $headerString);
136
  $bytes_written = @fwrite($archiveHandle, $headerString);
137
 
138
  if ($bytes_written === false) {
29
 
30
  // RSR TODO Populate fields based on file already on system
31
  // profile ok
32
+ $instance->fileSize = DupLiteSnapLibIOU::filesize($filepath);
33
  // end profile ok
34
 
35
  // profile ok
37
  // end profile ok
38
 
39
  // profile ok
40
+ $instance->mtime = DupLiteSnapLibIOU::filemtime($filepath);
41
  // end profile ok
42
 
43
  if($instance->fileSize > DupArchiveConstants::$MaxFilesizeForHashing) {
132
  {
133
  $headerString = '<F><FS>'.$this->fileSize.'</FS><MT>'.$this->mtime.'</MT><P>'.$this->permissions.'</P><HA>'.$this->hash.'</HA><RPL>'.$this->relativePathLength.'</RPL><RP>'.$this->relativePath.'</RP></F>';
134
 
135
+ //DupLiteSnapLibIOU::fwrite($archiveHandle, $headerString);
136
  $bytes_written = @fwrite($archiveHandle, $headerString);
137
 
138
  if ($bytes_written === false) {
lib/dup_archive/classes/headers/class.duparchive.header.glob.php CHANGED
@@ -41,7 +41,7 @@ class DupArchiveGlobHeader //extends HeaderBase
41
  fread($archiveHandle, 4);
42
 
43
  if ($skipGlob) {
44
- SnapLibIOU::fseek($archiveHandle, $instance->storedSize, SEEK_CUR);
45
  }
46
 
47
  return $instance;
@@ -53,7 +53,7 @@ class DupArchiveGlobHeader //extends HeaderBase
53
 
54
  $headerString = '<G><OS>'.$this->originalSize.'</OS><SS>'.$this->storedSize.'</SS><HA>'.$this->hash.'</HA></G>';
55
 
56
- //SnapLibIOU::fwrite($archiveHandle, $headerString);
57
  $bytes_written = @fwrite($archiveHandle, $headerString);
58
 
59
  if ($bytes_written === false) {
41
  fread($archiveHandle, 4);
42
 
43
  if ($skipGlob) {
44
+ DupLiteSnapLibIOU::fseek($archiveHandle, $instance->storedSize, SEEK_CUR);
45
  }
46
 
47
  return $instance;
53
 
54
  $headerString = '<G><OS>'.$this->originalSize.'</OS><SS>'.$this->storedSize.'</SS><HA>'.$this->hash.'</HA></G>';
55
 
56
+ //DupLiteSnapLibIOU::fwrite($archiveHandle, $headerString);
57
  $bytes_written = @fwrite($archiveHandle, $headerString);
58
 
59
  if ($bytes_written === false) {
lib/dup_archive/classes/headers/class.duparchive.header.php CHANGED
@@ -67,8 +67,8 @@ class DupArchiveHeader// extends HeaderBase
67
  {
68
  $isCompressedString = DupArchiveUtil::boolToString($this->isCompressed);
69
 
70
- //SnapLibIOU::fwrite($archiveHandle, "<A><V>{$this->version}</V><C>{$isCompressedString}</C></A>");
71
- SnapLibIOU::fwrite($archiveHandle, '<A><V>'.$this->version.'</V><C>'.$isCompressedString.'</C></A>');
72
  }
73
  }
74
  }
67
  {
68
  $isCompressedString = DupArchiveUtil::boolToString($this->isCompressed);
69
 
70
+ //DupLiteSnapLibIOU::fwrite($archiveHandle, "<A><V>{$this->version}</V><C>{$isCompressedString}</C></A>");
71
+ DupLiteSnapLibIOU::fwrite($archiveHandle, '<A><V>'.$this->version.'</V><C>'.$isCompressedString.'</C></A>');
72
  }
73
  }
74
  }
lib/dup_archive/classes/headers/class.duparchive.header.u.php CHANGED
@@ -22,7 +22,7 @@ class DupArchiveHeaderU
22
  throw new Exception("Invalid starting element. Was expecting {$expectedStart} but got {$startingElement}");
23
  }
24
 
25
- //return SnapLibStreamU::streamGetLine($archiveHandle, self::MaxStandardHeaderFieldLength, $expectedEnd);
26
 
27
  $headerString = stream_get_line($archiveHandle, self::MaxStandardHeaderFieldLength, $expectedEnd);
28
 
22
  throw new Exception("Invalid starting element. Was expecting {$expectedStart} but got {$startingElement}");
23
  }
24
 
25
+ //return DupLiteSnapLibStreamU::streamGetLine($archiveHandle, self::MaxStandardHeaderFieldLength, $expectedEnd);
26
 
27
  $headerString = stream_get_line($archiveHandle, self::MaxStandardHeaderFieldLength, $expectedEnd);
28
 
lib/dup_archive/classes/processors/class.duparchive.processor.directory.php CHANGED
@@ -12,7 +12,7 @@ class DupArchiveDirectoryProcessor
12
  $directoryHeader = new DupArchiveDirectoryHeader();
13
 
14
  $directoryHeader->permissions = substr(sprintf('%o', fileperms($sourceDirectoryPath)), -4);
15
- $directoryHeader->mtime = SnapLibIOU::filemtime($sourceDirectoryPath);
16
  $directoryHeader->relativePath = $relativeDirectoryPath;
17
  $directoryHeader->relativePathLength = strlen($directoryHeader->relativePath);
18
 
12
  $directoryHeader = new DupArchiveDirectoryHeader();
13
 
14
  $directoryHeader->permissions = substr(sprintf('%o', fileperms($sourceDirectoryPath)), -4);
15
+ $directoryHeader->mtime = DupLiteSnapLibIOU::filemtime($sourceDirectoryPath);
16
  $directoryHeader->relativePath = $relativeDirectoryPath;
17
  $directoryHeader->relativePathLength = strlen($directoryHeader->relativePath);
18
 
lib/dup_archive/classes/processors/class.duparchive.processor.file.php CHANGED
@@ -29,7 +29,7 @@ class DupArchiveFileProcessor
29
 
30
  if($sourceHandle === false)
31
  {
32
- $createState->archiveOffset = SnapLibIOU::ftell($archiveHandle);
33
  $createState->currentFileIndex++;
34
  $createState->currentFileOffset = 0;
35
  $createState->skippedFileCount++;
@@ -41,7 +41,7 @@ class DupArchiveFileProcessor
41
  if ($createState->currentFileOffset > 0) {
42
  DupArchiveUtil::tlog("Continuing {$sourceFilepath} so seeking to {$createState->currentFileOffset}");
43
 
44
- SnapLibIOU::fseek($sourceHandle, $createState->currentFileOffset);
45
  } else {
46
  DupArchiveUtil::tlog("Starting new file entry for {$sourceFilepath}");
47
 
@@ -79,11 +79,11 @@ class DupArchiveFileProcessor
79
 
80
  DupArchiveUtil::tlog("Need to keep writing {$sourceFilepath} to archive");
81
  $createState->currentFileOffset += $createState->globSize;
82
- $createState->archiveOffset = SnapLibIOU::ftell($archiveHandle); //??
83
  } else {
84
 
85
  DupArchiveUtil::tlog("Completed writing {$sourceFilepath} to archive");
86
- $createState->archiveOffset = SnapLibIOU::ftell($archiveHandle);
87
  $createState->currentFileIndex++;
88
  $createState->currentFileOffset = 0;
89
  }
@@ -99,7 +99,7 @@ class DupArchiveFileProcessor
99
  }
100
 
101
  // profile ok
102
- SnapLibIOU::fclose($sourceHandle);
103
  // end profile ok
104
  }
105
 
@@ -115,20 +115,20 @@ class DupArchiveFileProcessor
115
 
116
  if (!file_exists($parentDir)) {
117
 
118
- SnapLibIOU::mkdir($parentDir, 0755, true);
119
  }
120
 
121
  if ($expandState->currentFileHeader->fileSize > 0) {
122
 
123
  if ($expandState->currentFileOffset > 0) {
124
- $destFileHandle = SnapLibIOU::fopen($destFilepath, 'r+b');
125
 
126
  DupArchiveUtil::tlog('Continuing '.$destFilepath.' so seeking to '.$expandState->currentFileOffset);
127
 
128
- SnapLibIOU::fseek($destFileHandle, $expandState->currentFileOffset);
129
  } else {
130
  DupArchiveUtil::tlog('Starting to write new file '.$destFilepath);
131
- $destFileHandle = SnapLibIOU::fopen($destFilepath, 'w+b');
132
  }
133
 
134
  DupArchiveUtil::tlog('writeToFile for '.$destFilepath.', size '.$expandState->currentFileHeader->fileSize);
@@ -151,7 +151,7 @@ class DupArchiveFileProcessor
151
  DupArchiveUtil::tlog('After glob write');
152
 
153
  $expandState->currentFileOffset = ftell($destFileHandle);
154
- $expandState->archiveOffset = SnapLibIOU::ftell($archiveHandle);
155
 
156
  $moreGlobstoProcess = $expandState->currentFileOffset < $expandState->currentFileHeader->fileSize;
157
 
@@ -304,7 +304,7 @@ class DupArchiveFileProcessor
304
  $expandState->currentFileOffset += $globHeader->originalSize;
305
 
306
  // profile ok
307
- $expandState->archiveOffset = SnapLibIOU::ftell($archiveHandle);
308
 
309
 
310
  $moreGlobstoProcess = $expandState->currentFileOffset < $expandState->currentFileHeader->fileSize;
29
 
30
  if($sourceHandle === false)
31
  {
32
+ $createState->archiveOffset = DupLiteSnapLibIOU::ftell($archiveHandle);
33
  $createState->currentFileIndex++;
34
  $createState->currentFileOffset = 0;
35
  $createState->skippedFileCount++;
41
  if ($createState->currentFileOffset > 0) {
42
  DupArchiveUtil::tlog("Continuing {$sourceFilepath} so seeking to {$createState->currentFileOffset}");
43
 
44
+ DupLiteSnapLibIOU::fseek($sourceHandle, $createState->currentFileOffset);
45
  } else {
46
  DupArchiveUtil::tlog("Starting new file entry for {$sourceFilepath}");
47
 
79
 
80
  DupArchiveUtil::tlog("Need to keep writing {$sourceFilepath} to archive");
81
  $createState->currentFileOffset += $createState->globSize;
82
+ $createState->archiveOffset = DupLiteSnapLibIOU::ftell($archiveHandle); //??
83
  } else {
84
 
85
  DupArchiveUtil::tlog("Completed writing {$sourceFilepath} to archive");
86
+ $createState->archiveOffset = DupLiteSnapLibIOU::ftell($archiveHandle);
87
  $createState->currentFileIndex++;
88
  $createState->currentFileOffset = 0;
89
  }
99
  }
100
 
101
  // profile ok
102
+ DupLiteSnapLibIOU::fclose($sourceHandle);
103
  // end profile ok
104
  }
105
 
115
 
116
  if (!file_exists($parentDir)) {
117
 
118
+ DupLiteSnapLibIOU::mkdir($parentDir, 0755, true);
119
  }
120
 
121
  if ($expandState->currentFileHeader->fileSize > 0) {
122
 
123
  if ($expandState->currentFileOffset > 0) {
124
+ $destFileHandle = DupLiteSnapLibIOU::fopen($destFilepath, 'r+b');
125
 
126
  DupArchiveUtil::tlog('Continuing '.$destFilepath.' so seeking to '.$expandState->currentFileOffset);
127
 
128
+ DupLiteSnapLibIOU::fseek($destFileHandle, $expandState->currentFileOffset);
129
  } else {
130
  DupArchiveUtil::tlog('Starting to write new file '.$destFilepath);
131
+ $destFileHandle = DupLiteSnapLibIOU::fopen($destFilepath, 'w+b');
132
  }
133
 
134
  DupArchiveUtil::tlog('writeToFile for '.$destFilepath.', size '.$expandState->currentFileHeader->fileSize);
151
  DupArchiveUtil::tlog('After glob write');
152
 
153
  $expandState->currentFileOffset = ftell($destFileHandle);
154
+ $expandState->archiveOffset = DupLiteSnapLibIOU::ftell($archiveHandle);
155
 
156
  $moreGlobstoProcess = $expandState->currentFileOffset < $expandState->currentFileHeader->fileSize;
157
 
304
  $expandState->currentFileOffset += $globHeader->originalSize;
305
 
306
  // profile ok
307
+ $expandState->archiveOffset = DupLiteSnapLibIOU::ftell($archiveHandle);
308
 
309
 
310
  $moreGlobstoProcess = $expandState->currentFileOffset < $expandState->currentFileHeader->fileSize;
lib/dup_archive/classes/util/class.duparchive.u.json.php CHANGED
@@ -14,16 +14,8 @@ class DupArchiveJsonU
14
 
15
  public static function customEncode($value, $iteration = 1)
16
  {
17
- if (function_exists('wp_json_encode')) {
18
- $encoded = wp_json_encode($value);
19
- } else {
20
- if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
21
- $encoded = json_encode($value, JSON_PRETTY_PRINT);
22
- } else {
23
- $encoded = json_encode($value);
24
- }
25
- }
26
-
27
  switch (json_last_error()) {
28
  case JSON_ERROR_NONE:
29
  return $encoded;
@@ -49,7 +41,7 @@ class DupArchiveJsonU
49
 
50
  public static function encode($value, $options = 0)
51
  {
52
- $result = json_encode($value, $options);
53
 
54
  if ($result !== FALSE) {
55
 
14
 
15
  public static function customEncode($value, $iteration = 1)
16
  {
17
+ $encoded = DupLiteSnapLibUtil::wp_json_encode($value);
18
+
 
 
 
 
 
 
 
 
19
  switch (json_last_error()) {
20
  case JSON_ERROR_NONE:
21
  return $encoded;
41
 
42
  public static function encode($value, $options = 0)
43
  {
44
+ $result = DupLiteSnapLibUtil::wp_json_encode($value, $options);
45
 
46
  if ($result !== FALSE) {
47
 
lib/dup_archive/classes/util/class.duparchive.util.php CHANGED
@@ -122,7 +122,7 @@ class DupArchiveUtil
122
  {
123
  if($callingFunctionName === null)
124
  {
125
- $callingFunctionName = SnapLibUtil::getCallingFunctionName();
126
  }
127
 
128
  self::$logger->log($s, $flush, $callingFunctionName);
@@ -140,7 +140,7 @@ class DupArchiveUtil
140
 
141
  if($callingFunctionName === null)
142
  {
143
- $callingFunctionName = SnapLibUtil::getCallingFunctionName();
144
  }
145
 
146
  self::log("####{$s}", $flush, $callingFunctionName);
@@ -167,7 +167,7 @@ class DupArchiveUtil
167
 
168
  if($callingFunctionName === null)
169
  {
170
- $callingFunctionName = SnapLibUtil::getCallingFunctionName();
171
  }
172
 
173
  self::tlog($s, $flush, $callingFunctionName);
@@ -180,7 +180,7 @@ class DupArchiveUtil
180
 
181
  if($callingFunctionName === null)
182
  {
183
- $callingFunctionName = SnapLibUtil::getCallingFunctionName();
184
  }
185
 
186
  self::log($s, $flush, $callingFunctionName);
122
  {
123
  if($callingFunctionName === null)
124
  {
125
+ $callingFunctionName = DupLiteSnapLibUtil::getCallingFunctionName();
126
  }
127
 
128
  self::$logger->log($s, $flush, $callingFunctionName);
140
 
141
  if($callingFunctionName === null)
142
  {
143
+ $callingFunctionName = DupLiteSnapLibUtil::getCallingFunctionName();
144
  }
145
 
146
  self::log("####{$s}", $flush, $callingFunctionName);
167
 
168
  if($callingFunctionName === null)
169
  {
170
+ $callingFunctionName = DupLiteSnapLibUtil::getCallingFunctionName();
171
  }
172
 
173
  self::tlog($s, $flush, $callingFunctionName);
180
 
181
  if($callingFunctionName === null)
182
  {
183
+ $callingFunctionName = DupLiteSnapLibUtil::getCallingFunctionName();
184
  }
185
 
186
  self::log($s, $flush, $callingFunctionName);
lib/dup_archive/daws/class.daws.state.expand.php CHANGED
@@ -18,7 +18,7 @@ class DAWSExpandState extends DupArchiveExpandState
18
  {
19
  $stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
20
 
21
- SnapLibIOU::rm($stateFilepath, false);
22
  }
23
 
24
  public static function getInstance($reset = false)
@@ -29,9 +29,9 @@ class DAWSExpandState extends DupArchiveExpandState
29
  self::$instance = new DAWSExpandState();
30
 
31
  if (file_exists($stateFilepath)) {
32
- $stateHandle = SnapLibIOU::fopen($stateFilepath, 'rb');
33
 
34
- // RSR we shouldn't need read locks and it seems to screw up on some boxes anyway.. SnapLibIOU::flock($stateHandle, LOCK_EX);
35
 
36
  $stateString = fread($stateHandle, filesize($stateFilepath));
37
 
@@ -41,9 +41,9 @@ class DAWSExpandState extends DupArchiveExpandState
41
 
42
  self::$instance->fileRenames = (array)(self::$instance->fileRenames);
43
 
44
- // SnapLibIOU::flock($stateHandle, LOCK_UN);
45
 
46
- SnapLibIOU::fclose($stateHandle);
47
  } else {
48
  $reset = true;
49
  }
@@ -88,33 +88,33 @@ class DAWSExpandState extends DupArchiveExpandState
88
  {
89
  $stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
90
 
91
- $stateHandle = SnapLibIOU::fopen($stateFilepath, 'w');
92
 
93
- SnapLibIOU::flock($stateHandle, LOCK_EX);
94
 
95
  $this->initMembers();
96
 
97
- SnapLibIOU::fwrite($stateHandle, json_encode($this));
98
 
99
- SnapLibIOU::flock($stateHandle, LOCK_UN);
100
 
101
- SnapLibIOU::fclose($stateHandle);
102
  }
103
 
104
  public function save()
105
  {
106
  $stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
107
 
108
- $stateHandle = SnapLibIOU::fopen($stateFilepath, 'w');
109
 
110
- SnapLibIOU::flock($stateHandle, LOCK_EX);
111
 
112
  DupArchiveUtil::tlog("saving state");
113
- SnapLibIOU::fwrite($stateHandle, json_encode($this));
114
 
115
- SnapLibIOU::flock($stateHandle, LOCK_UN);
116
 
117
- SnapLibIOU::fclose($stateHandle);
118
  }
119
 
120
  private function initMembers()
18
  {
19
  $stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
20
 
21
+ DupLiteSnapLibIOU::rm($stateFilepath, false);
22
  }
23
 
24
  public static function getInstance($reset = false)
29
  self::$instance = new DAWSExpandState();
30
 
31
  if (file_exists($stateFilepath)) {
32
+ $stateHandle = DupLiteSnapLibIOU::fopen($stateFilepath, 'rb');
33
 
34
+ // RSR we shouldn't need read locks and it seems to screw up on some boxes anyway.. DupLiteSnapLibIOU::flock($stateHandle, LOCK_EX);
35
 
36
  $stateString = fread($stateHandle, filesize($stateFilepath));
37
 
41
 
42
  self::$instance->fileRenames = (array)(self::$instance->fileRenames);
43
 
44
+ // DupLiteSnapLibIOU::flock($stateHandle, LOCK_UN);
45
 
46
+ DupLiteSnapLibIOU::fclose($stateHandle);
47
  } else {
48
  $reset = true;
49
  }
88
  {
89
  $stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
90
 
91
+ $stateHandle = DupLiteSnapLibIOU::fopen($stateFilepath, 'w');
92
 
93
+ DupLiteSnapLibIOU::flock($stateHandle, LOCK_EX);
94
 
95
  $this->initMembers();
96
 
97
+ DupLiteSnapLibIOU::fwrite($stateHandle, DupLiteSnapLibUtil::wp_json_encode($this));
98
 
99
+ DupLiteSnapLibIOU::flock($stateHandle, LOCK_UN);
100
 
101
+ DupLiteSnapLibIOU::fclose($stateHandle);
102
  }
103
 
104
  public function save()
105
  {
106
  $stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
107
 
108
+ $stateHandle = DupLiteSnapLibIOU::fopen($stateFilepath, 'w');
109
 
110
+ DupLiteSnapLibIOU::flock($stateHandle, LOCK_EX);
111
 
112
  DupArchiveUtil::tlog("saving state");
113
+ DupLiteSnapLibIOU::fwrite($stateHandle, DupLiteSnapLibUtil::wp_json_encode($this));
114
 
115
+ DupLiteSnapLibIOU::flock($stateHandle, LOCK_UN);
116
 
117
+ DupLiteSnapLibIOU::fclose($stateHandle);
118
  }
119
 
120
  private function initMembers()
lib/dup_archive/daws/daws.php CHANGED
@@ -10,7 +10,7 @@
10
  */
11
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
12
 
13
- if (SnapLibUtil::wp_is_ini_value_changeable('display_errors')) {
14
  @ini_set('display_errors', 1);
15
  }
16
  error_reporting(E_ALL);
@@ -31,7 +31,7 @@ class DAWS_Logger extends DupArchiveLoggerBase
31
  {
32
  public function log($s, $flush = false, $callingFunctionOverride = null)
33
  {
34
- SnapLibLogger::log($s, $flush, $callingFunctionOverride);
35
  }
36
  }
37
 
@@ -44,7 +44,7 @@ class DAWS
44
  {
45
  date_default_timezone_set('UTC'); // Some machines don’t have this set so just do it here.
46
 
47
- SnapLibLogger::init(DAWSConstants::$LOG_FILEPATH);
48
 
49
  DupArchiveEngine::init(new DAWS_Logger());
50
  }
@@ -52,75 +52,75 @@ class DAWS
52
  public function processRequest()
53
  {
54
  try {
55
- SnapLibLogger::log('process request');
56
  $retVal = new StdClass();
57
 
58
  $retVal->pass = false;
59
 
60
  if (isset($_REQUEST['action'])) {
61
  $params = $_REQUEST;
62
- SnapLibLogger::log('b');
63
  } else {
64
  $json = file_get_contents('php://input');
65
  $params = json_decode($json, true);
66
  }
67
 
68
- SnapLibLogger::logObject('params', $params);
69
- SnapLibLogger::logObject('keys', array_keys($params));
70
 
71
  $action = $params['action'];
72
 
73
  $initializeState = false;
74
 
75
- $isClientDriven = SnapLibUtil::getArrayValue($params, 'client_driven', false);
76
 
77
  if ($action == 'start_expand') {
78
 
79
  $initializeState = true;
80
 
81
  DAWSExpandState::purgeStatefile();
82
- SnapLibLogger::clearLog();
83
 
84
- SnapLibIOU::rm(DAWSConstants::$PROCESS_CANCEL_FILEPATH);
85
- $archiveFilepath = SnapLibUtil::getArrayValue($params, 'archive_filepath');
86
- $restoreDirectory = SnapLibUtil::getArrayValue($params, 'restore_directory');
87
- $workerTime = SnapLibUtil::getArrayValue($params, 'worker_time', false, DAWSConstants::$DEFAULT_WORKER_TIME);
88
- $filteredDirectories = SnapLibUtil::getArrayValue($params, 'filtered_directories', false, array());
89
- $filteredFiles = SnapLibUtil::getArrayValue($params, 'filtered_files', false, array());
90
- $fileRenames = SnapLibUtil::getArrayValue($params, 'file_renames', false, array());
91
 
92
  $action = 'expand';
93
 
94
- SnapLibLogger::log('startexpand->expand');
95
  } else if($action == 'start_create') {
96
 
97
- $archiveFilepath = SnapLibUtil::getArrayValue($params, 'archive_filepath');
98
- $workerTime = SnapLibUtil::getArrayValue($params, 'worker_time', false, DAWSConstants::$DEFAULT_WORKER_TIME);
99
 
100
  $createState->basePath = $dataDirectory;
101
  $createState->isCompressed = $isCompressed;
102
 
103
- $sourceDirectory = SnapLibUtil::getArrayValue($params, 'source_directory');
104
- $isCompressed = SnapLibUtil::getArrayValue($params, 'is_compressed') === 'true' ? true : false;
105
  }
106
 
107
- $throttleDelayInMs = SnapLibUtil::getArrayValue($params, 'throttle_delay', false, 0);
108
 
109
  if ($action == 'expand') {
110
 
111
- SnapLibLogger::log('expand action');
112
 
113
  /* @var $expandState DAWSExpandState */
114
  $expandState = DAWSExpandState::getInstance($initializeState);
115
 
116
- $this->lock_handle = SnapLibIOU::fopen(DAWSConstants::$PROCESS_LOCK_FILEPATH, 'c+');
117
- SnapLibIOU::flock($this->lock_handle, LOCK_EX);
118
 
119
  if($initializeState || $expandState->working) {
120
 
121
  if ($initializeState) {
122
 
123
- SnapLibLogger::logObject('file renames', $fileRenames);
124
 
125
  $expandState->archivePath = $archiveFilepath;
126
  $expandState->working = true;
@@ -138,7 +138,7 @@ class DAWS
138
 
139
  $expandState->throttleDelayInUs = 1000 * $throttleDelayInMs;
140
 
141
- SnapLibLogger::logObject('Expand State In', $expandState);
142
 
143
  DupArchiveEngine::expandArchive($expandState);
144
  }
@@ -146,43 +146,43 @@ class DAWS
146
  if (!$expandState->working) {
147
 
148
  $deltaTime = time() - $expandState->startTimestamp;
149
- SnapLibLogger::log("###### Processing ended. Seconds taken:$deltaTime");
150
 
151
  if (count($expandState->failures) > 0) {
152
- SnapLibLogger::log('Errors detected');
153
 
154
  foreach ($expandState->failures as $failure) {
155
- SnapLibLogger::log("{$failure->subject}:{$failure->description}");
156
  }
157
  } else {
158
- SnapLibLogger::log('Expansion done, archive checks out!');
159
  }
160
  }
161
  else {
162
- SnapLibLogger::log("Processing will continue");
163
  }
164
 
165
 
166
- SnapLibIOU::flock($this->lock_handle, LOCK_UN);
167
 
168
  $retVal->pass = true;
169
  $retVal->status = $this->getStatus($expandState);
170
  } else if ($action == 'create') {
171
 
172
- SnapLibLogger::log('create action');
173
 
174
  /* @var $expandState DAWSExpandState */
175
  $createState = DAWSCreateState::getInstance($initializeState);
176
 
177
- $this->lock_handle = SnapLibIOU::fopen(DAWSConstants::$PROCESS_LOCK_FILEPATH, 'c+');
178
- SnapLibIOU::flock($this->lock_handle, LOCK_EX);
179
 
180
  if($initializeState || $createState->working) {
181
 
182
  DupArchiveEngine::createArchive($archiveFilepath, $isCompressed);
183
 
184
  $createState->archivePath = $archiveFilepath;
185
- $createState->archiveOffset = SnapLibIOU::filesize($archiveFilepath);
186
  $createState->working = true;
187
  $createState->timeSliceInSecs = $workerTime;
188
  $createState->basePath = $dataDirectory;
@@ -201,23 +201,23 @@ class DAWS
201
  if (!$createState->working) {
202
 
203
  $deltaTime = time() - $createState->startTimestamp;
204
- SnapLibLogger::log("###### Processing ended. Seconds taken:$deltaTime");
205
 
206
  if (count($createState->failures) > 0) {
207
- SnapLibLogger::log('Errors detected');
208
 
209
  foreach ($createState->failures as $failure) {
210
- SnapLibLogger::log("{$failure->subject}:{$failure->description}");
211
  }
212
  } else {
213
- SnapLibLogger::log('Creation done, archive checks out!');
214
  }
215
  }
216
  else {
217
- SnapLibLogger::log("Processing will continue");
218
  }
219
 
220
- SnapLibIOU::flock($this->lock_handle, LOCK_UN);
221
 
222
  $retVal->pass = true;
223
  $retVal->status = $this->getStatus($createState);
@@ -228,7 +228,7 @@ class DAWS
228
  $retVal->pass = true;
229
  $retVal->status = $this->getStatus($expandState);
230
  } else if ($action == 'cancel') {
231
- SnapLibIOU::touch(DAWSConstants::$PROCESS_CANCEL_FILEPATH);
232
  $retVal->pass = true;
233
  } else {
234
  throw new Exception('Unknown command.');
@@ -239,16 +239,16 @@ class DAWS
239
  } catch (Exception $ex) {
240
  $error_message = "Error Encountered:" . $ex->getMessage() . '<br/>' . $ex->getTraceAsString();
241
 
242
- SnapLibLogger::log($error_message);
243
 
244
  $retVal->pass = false;
245
  $retVal->error = $error_message;
246
  }
247
 
248
- SnapLibLogger::logObject("before json encode retval", $retVal);
249
 
250
- $jsonRetVal = json_encode($retVal);
251
- SnapLibLogger::logObject("json encoded retval", $jsonRetVal);
252
  echo $jsonRetVal;
253
  }
254
 
@@ -289,8 +289,8 @@ function generateCallTrace()
289
 
290
  function terminate_missing_variables($errno, $errstr, $errfile, $errline)
291
  {
292
- SnapLibLogger::log("ERROR $errno, $errstr, {$errfile}:{$errline}");
293
- SnapLibLogger::log(generateCallTrace());
294
  // DaTesterLogging::clearLog();
295
 
296
  /**
10
  */
11
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
12
 
13
+ if (DupLiteSnapLibUtil::wp_is_ini_value_changeable('display_errors')) {
14
  @ini_set('display_errors', 1);
15
  }
16
  error_reporting(E_ALL);
31
  {
32
  public function log($s, $flush = false, $callingFunctionOverride = null)
33
  {
34
+ DupLiteSnapLibLogger::log($s, $flush, $callingFunctionOverride);
35
  }
36
  }
37
 
44
  {
45
  date_default_timezone_set('UTC'); // Some machines don’t have this set so just do it here.
46
 
47
+ DupLiteSnapLibLogger::init(DAWSConstants::$LOG_FILEPATH);
48
 
49
  DupArchiveEngine::init(new DAWS_Logger());
50
  }
52
  public function processRequest()
53
  {
54
  try {
55
+ DupLiteSnapLibLogger::log('process request');
56
  $retVal = new StdClass();
57
 
58
  $retVal->pass = false;
59
 
60
  if (isset($_REQUEST['action'])) {
61
  $params = $_REQUEST;
62
+ DupLiteSnapLibLogger::log('b');
63
  } else {
64
  $json = file_get_contents('php://input');
65
  $params = json_decode($json, true);
66
  }
67
 
68
+ DupLiteSnapLibLogger::logObject('params', $params);
69
+ DupLiteSnapLibLogger::logObject('keys', array_keys($params));
70
 
71
  $action = $params['action'];
72
 
73
  $initializeState = false;
74
 
75
+ $isClientDriven = DupLiteSnapLibUtil::getArrayValue($params, 'client_driven', false);
76
 
77
  if ($action == 'start_expand') {
78
 
79
  $initializeState = true;
80
 
81
  DAWSExpandState::purgeStatefile();
82
+ DupLiteSnapLibLogger::clearLog();
83
 
84
+ DupLiteSnapLibIOU::rm(DAWSConstants::$PROCESS_CANCEL_FILEPATH);
85
+ $archiveFilepath = DupLiteSnapLibUtil::getArrayValue($params, 'archive_filepath');
86
+ $restoreDirectory = DupLiteSnapLibUtil::getArrayValue($params, 'restore_directory');
87
+ $workerTime = DupLiteSnapLibUtil::getArrayValue($params, 'worker_time', false, DAWSConstants::$DEFAULT_WORKER_TIME);
88
+ $filteredDirectories = DupLiteSnapLibUtil::getArrayValue($params, 'filtered_directories', false, array());
89
+ $filteredFiles = DupLiteSnapLibUtil::getArrayValue($params, 'filtered_files', false, array());
90
+ $fileRenames = DupLiteSnapLibUtil::getArrayValue($params, 'file_renames', false, array());
91
 
92
  $action = 'expand';
93
 
94
+ DupLiteSnapLibLogger::log('startexpand->expand');
95
  } else if($action == 'start_create') {
96
 
97
+ $archiveFilepath = DupLiteSnapLibUtil::getArrayValue($params, 'archive_filepath');
98
+ $workerTime = DupLiteSnapLibUtil::getArrayValue($params, 'worker_time', false, DAWSConstants::$DEFAULT_WORKER_TIME);
99
 
100
  $createState->basePath = $dataDirectory;
101
  $createState->isCompressed = $isCompressed;
102
 
103
+ $sourceDirectory = DupLiteSnapLibUtil::getArrayValue($params, 'source_directory');
104
+ $isCompressed = DupLiteSnapLibUtil::getArrayValue($params, 'is_compressed') === 'true' ? true : false;
105
  }
106
 
107
+ $throttleDelayInMs = DupLiteSnapLibUtil::getArrayValue($params, 'throttle_delay', false, 0);
108
 
109
  if ($action == 'expand') {
110
 
111
+ DupLiteSnapLibLogger::log('expand action');
112
 
113
  /* @var $expandState DAWSExpandState */
114
  $expandState = DAWSExpandState::getInstance($initializeState);
115
 
116
+ $this->lock_handle = DupLiteSnapLibIOU::fopen(DAWSConstants::$PROCESS_LOCK_FILEPATH, 'c+');
117
+ DupLiteSnapLibIOU::flock($this->lock_handle, LOCK_EX);
118
 
119
  if($initializeState || $expandState->working) {
120
 
121
  if ($initializeState) {
122
 
123
+ DupLiteSnapLibLogger::logObject('file renames', $fileRenames);
124
 
125
  $expandState->archivePath = $archiveFilepath;
126
  $expandState->working = true;
138
 
139
  $expandState->throttleDelayInUs = 1000 * $throttleDelayInMs;
140
 
141
+ DupLiteSnapLibLogger::logObject('Expand State In', $expandState);
142
 
143
  DupArchiveEngine::expandArchive($expandState);
144
  }
146
  if (!$expandState->working) {
147
 
148
  $deltaTime = time() - $expandState->startTimestamp;
149
+ DupLiteSnapLibLogger::log("###### Processing ended. Seconds taken:$deltaTime");
150
 
151
  if (count($expandState->failures) > 0) {
152
+ DupLiteSnapLibLogger::log('Errors detected');
153
 
154
  foreach ($expandState->failures as $failure) {
155
+ DupLiteSnapLibLogger::log("{$failure->subject}:{$failure->description}");
156
  }
157
  } else {
158
+ DupLiteSnapLibLogger::log('Expansion done, archive checks out!');
159
  }
160
  }
161
  else {
162
+ DupLiteSnapLibLogger::log("Processing will continue");
163
  }
164
 
165
 
166
+ DupLiteSnapLibIOU::flock($this->lock_handle, LOCK_UN);
167
 
168
  $retVal->pass = true;
169
  $retVal->status = $this->getStatus($expandState);
170
  } else if ($action == 'create') {
171
 
172
+ DupLiteSnapLibLogger::log('create action');
173
 
174
  /* @var $expandState DAWSExpandState */
175
  $createState = DAWSCreateState::getInstance($initializeState);
176
 
177
+ $this->lock_handle = DupLiteSnapLibIOU::fopen(DAWSConstants::$PROCESS_LOCK_FILEPATH, 'c+');
178
+ DupLiteSnapLibIOU::flock($this->lock_handle, LOCK_EX);
179
 
180
  if($initializeState || $createState->working) {
181
 
182
  DupArchiveEngine::createArchive($archiveFilepath, $isCompressed);
183
 
184
  $createState->archivePath = $archiveFilepath;
185
+ $createState->archiveOffset = DupLiteSnapLibIOU::filesize($archiveFilepath);
186
  $createState->working = true;
187
  $createState->timeSliceInSecs = $workerTime;
188
  $createState->basePath = $dataDirectory;
201
  if (!$createState->working) {
202
 
203
  $deltaTime = time() - $createState->startTimestamp;
204
+ DupLiteSnapLibLogger::log("###### Processing ended. Seconds taken:$deltaTime");
205
 
206
  if (count($createState->failures) > 0) {
207
+ DupLiteSnapLibLogger::log('Errors detected');
208
 
209
  foreach ($createState->failures as $failure) {
210
+ DupLiteSnapLibLogger::log("{$failure->subject}:{$failure->description}");
211
  }
212
  } else {
213
+ DupLiteSnapLibLogger::log('Creation done, archive checks out!');
214
  }
215
  }
216
  else {
217
+ DupLiteSnapLibLogger::log("Processing will continue");
218
  }
219
 
220
+ DupLiteSnapLibIOU::flock($this->lock_handle, LOCK_UN);
221
 
222
  $retVal->pass = true;
223
  $retVal->status = $this->getStatus($createState);
228
  $retVal->pass = true;
229
  $retVal->status = $this->getStatus($expandState);
230
  } else if ($action == 'cancel') {
231
+ DupLiteSnapLibIOU::touch(DAWSConstants::$PROCESS_CANCEL_FILEPATH);
232
  $retVal->pass = true;
233
  } else {
234
  throw new Exception('Unknown command.');
239
  } catch (Exception $ex) {
240
  $error_message = "Error Encountered:" . $ex->getMessage() . '<br/>' . $ex->getTraceAsString();
241
 
242
+ DupLiteSnapLibLogger::log($error_message);
243
 
244
  $retVal->pass = false;
245
  $retVal->error = $error_message;
246
  }
247
 
248
+ DupLiteSnapLibLogger::logObject("before json encode retval", $retVal);
249
 
250
+ $jsonRetVal = DupLiteSnapLibUtil::wp_json_encode($retVal);
251
+ DupLiteSnapLibLogger::logObject("json encoded retval", $jsonRetVal);
252
  echo $jsonRetVal;
253
  }
254
 
289
 
290
  function terminate_missing_variables($errno, $errstr, $errfile, $errline)
291
  {
292
+ DupLiteSnapLibLogger::log("ERROR $errno, $errstr, {$errfile}:{$errline}");
293
+ DupLiteSnapLibLogger::log(generateCallTrace());
294
  // DaTesterLogging::clearLog();
295
 
296
  /**
lib/dup_archive/tester/classes/class.datester.state.create.php CHANGED
@@ -28,9 +28,9 @@ class DaTesterCreateState extends DupArchiveCreateState
28
  self::$instance = new DaTesterCreateState();
29
 
30
  if (file_exists($stateFilepath)) {
31
- $stateHandle = SnapLibIOU::fopen($stateFilepath, 'r');
32
 
33
- SnapLibIOU::flock($stateHandle, LOCK_EX);
34
 
35
  $stateString = fread($stateHandle, filesize($stateFilepath));
36
 
@@ -38,9 +38,9 @@ class DaTesterCreateState extends DupArchiveCreateState
38
 
39
  self::$instance->setFromData($data);
40
 
41
- SnapLibIOU::flock($stateHandle, LOCK_UN);
42
 
43
- SnapLibIOU::fclose($stateHandle);
44
  } else {
45
  $reset = true;
46
  }
@@ -75,29 +75,29 @@ class DaTesterCreateState extends DupArchiveCreateState
75
  {
76
  $stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
77
 
78
- $stateHandle = SnapLibIOU::fopen($stateFilepath, 'w');
79
 
80
- SnapLibIOU::flock($stateHandle, LOCK_EX);
81
 
82
  $this->initMembers();
83
 
84
- SnapLibIOU::fwrite($stateHandle, json_encode($this));
85
 
86
- SnapLibIOU::fclose($stateHandle);
87
  }
88
 
89
  public function save()
90
  {
91
  $stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
92
 
93
- $stateHandle = SnapLibIOU::fopen($stateFilepath, 'w');
94
 
95
- SnapLibIOU::flock($stateHandle, LOCK_EX);
96
 
97
  DupArchiveUtil::tlog("saving state");
98
- SnapLibIOU::fwrite($stateHandle, json_encode($this));
99
 
100
- SnapLibIOU::fclose($stateHandle);
101
  }
102
 
103
  private function initMembers()
28
  self::$instance = new DaTesterCreateState();
29
 
30
  if (file_exists($stateFilepath)) {
31
+ $stateHandle = DupLiteSnapLibIOU::fopen($stateFilepath, 'r');
32
 
33
+ DupLiteSnapLibIOU::flock($stateHandle, LOCK_EX);
34
 
35
  $stateString = fread($stateHandle, filesize($stateFilepath));
36
 
38
 
39
  self::$instance->setFromData($data);
40
 
41
+ DupLiteSnapLibIOU::flock($stateHandle, LOCK_UN);
42
 
43
+ DupLiteSnapLibIOU::fclose($stateHandle);
44
  } else {
45
  $reset = true;
46
  }
75
  {
76
  $stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
77
 
78
+ $stateHandle = DupLiteSnapLibIOU::fopen($stateFilepath, 'w');
79
 
80
+ DupLiteSnapLibIOU::flock($stateHandle, LOCK_EX);
81
 
82
  $this->initMembers();
83
 
84
+ DupLiteSnapLibIOU::fwrite($stateHandle, json_encode($this));
85
 
86
+ DupLiteSnapLibIOU::fclose($stateHandle);
87
  }
88
 
89
  public function save()
90
  {
91
  $stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
92
 
93
+ $stateHandle = DupLiteSnapLibIOU::fopen($stateFilepath, 'w');
94
 
95
+ DupLiteSnapLibIOU::flock($stateHandle, LOCK_EX);
96
 
97
  DupArchiveUtil::tlog("saving state");
98
+ DupLiteSnapLibIOU::fwrite($stateHandle, json_encode($this));
99
 
100
+ DupLiteSnapLibIOU::fclose($stateHandle);
101
  }
102
 
103
  private function initMembers()
lib/dup_archive/tester/classes/class.datester.state.expand.php CHANGED
@@ -22,9 +22,9 @@ class DaTesterExpandState extends DupArchiveExpandState
22
  self::$instance = new DaTesterExpandState();
23
 
24
  if (file_exists($stateFilepath)) {
25
- $stateHandle = SnapLibIOU::fopen($stateFilepath, 'r');
26
 
27
- SnapLibIOU::flock($stateHandle, LOCK_EX);
28
 
29
  $stateString = fread($stateHandle, filesize($stateFilepath));
30
 
@@ -32,9 +32,9 @@ class DaTesterExpandState extends DupArchiveExpandState
32
 
33
  self::$instance->setFromData($data);
34
 
35
- SnapLibIOU::flock($stateHandle, LOCK_UN);
36
 
37
- SnapLibIOU::fclose($stateHandle);
38
  } else {
39
  $reset = true;
40
  }
@@ -74,29 +74,29 @@ class DaTesterExpandState extends DupArchiveExpandState
74
  {
75
  $stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
76
 
77
- $stateHandle = SnapLibIOU::fopen($stateFilepath, 'w');
78
 
79
- SnapLibIOU::flock($stateHandle, LOCK_EX);
80
 
81
  $this->initMembers();
82
 
83
- SnapLibIOU::fwrite($stateHandle, json_encode($this));
84
 
85
- SnapLibIOU::fclose($stateHandle);
86
  }
87
 
88
  public function save()
89
  {
90
  $stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
91
 
92
- $stateHandle = SnapLibIOU::fopen($stateFilepath, 'w');
93
 
94
- SnapLibIOU::flock($stateHandle, LOCK_EX);
95
 
96
  DupArchiveUtil::tlog("saving state");
97
- SnapLibIOU::fwrite($stateHandle, json_encode($this));
98
 
99
- SnapLibIOU::fclose($stateHandle);
100
  }
101
 
102
  private function initMembers()
22
  self::$instance = new DaTesterExpandState();
23
 
24
  if (file_exists($stateFilepath)) {
25
+ $stateHandle = DupLiteSnapLibIOU::fopen($stateFilepath, 'r');
26
 
27
+ DupLiteSnapLibIOU::flock($stateHandle, LOCK_EX);
28
 
29
  $stateString = fread($stateHandle, filesize($stateFilepath));
30
 
32
 
33
  self::$instance->setFromData($data);
34
 
35
+ DupLiteSnapLibIOU::flock($stateHandle, LOCK_UN);
36
 
37
+ DupLiteSnapLibIOU::fclose($stateHandle);
38
  } else {
39
  $reset = true;
40
  }
74
  {
75
  $stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
76
 
77
+ $stateHandle = DupLiteSnapLibIOU::fopen($stateFilepath, 'w');
78
 
79
+ DupLiteSnapLibIOU::flock($stateHandle, LOCK_EX);
80
 
81
  $this->initMembers();
82
 
83
+ DupLiteSnapLibIOU::fwrite($stateHandle, json_encode($this));
84
 
85
+ DupLiteSnapLibIOU::fclose($stateHandle);
86
  }
87
 
88
  public function save()
89
  {
90
  $stateFilepath = dirname(__FILE__).'/'.self::StateFilename;
91
 
92
+ $stateHandle = DupLiteSnapLibIOU::fopen($stateFilepath, 'w');
93
 
94
+ DupLiteSnapLibIOU::flock($stateHandle, LOCK_EX);
95
 
96
  DupArchiveUtil::tlog("saving state");
97
+ DupLiteSnapLibIOU::fwrite($stateHandle, json_encode($this));
98
 
99
+ DupLiteSnapLibIOU::fclose($stateHandle);
100
  }
101
 
102
  private function initMembers()
lib/dup_archive/tester/datester.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
3
- if (SnapLibUtil::wp_is_ini_value_changeable('display_errors'))
4
  ini_set('display_errors', 1);
5
  error_reporting(E_ALL);
6
  error_reporting(E_ALL);
@@ -146,9 +146,9 @@ class DaTester
146
  public function processRequest()
147
  {
148
  try {
149
- $this->lockHandle = SnapLibIOU::fopen($this->paths->processLockFilepath, 'c+');
150
 
151
- SnapLibIOU::flock($this->lockHandle, LOCK_EX);
152
 
153
  $this->logger = new DaTesterLogging($this->paths->logFilepath);
154
 
@@ -202,7 +202,7 @@ class DaTester
202
  DupArchiveEngine::createArchive($this->paths->archiveFilepath, $this->params->compress);
203
 
204
  $daTesterCreateState->archivePath = $this->paths->archiveFilepath;
205
- $daTesterCreateState->archiveOffset = SnapLibIOU::filesize($this->paths->archiveFilepath);
206
  $daTesterCreateState->working = true;
207
  $daTesterCreateState->timeSliceInSecs = $this->params->workerTime;
208
  $daTesterCreateState->basePath = $this->paths->dataDirectory;
@@ -417,7 +417,7 @@ class DaTester
417
  exit(1);
418
  }
419
 
420
- SnapLibIOU::flock($this->lockHandle, LOCK_UN);
421
 
422
  $this->logger->log("Unlocked file");
423
 
@@ -430,7 +430,7 @@ class DaTester
430
 
431
  $this->logger->logObject("SPAWNING CUSTOM WORKER AT $url FOR ACTION {$this->params->action}", $data);
432
 
433
- SnapLibNetU::postWithoutWait($url, $data);
434
 
435
  $this->logger->log('After post without wait');
436
  } else {
@@ -477,8 +477,8 @@ class DaTester
477
  @unlink($this->paths->scanFilepath);
478
  }
479
 
480
- $handle = SnapLibIOU::fopen($this->paths->archiveFilepath, 'w');
481
- SnapLibIOU::fclose($handle);
482
 
483
  //$this->logger->clearLog();
484
  }
@@ -486,11 +486,11 @@ class DaTester
486
  private function clearExpandFiles()
487
  {
488
  if (file_exists($this->paths->restoreDirectory)) {
489
- SnapLibIOU::rrmdir($this->paths->restoreDirectory);
490
  }
491
 
492
  if (file_exists($this->paths->tempDirectory)) {
493
- SnapLibIOU::rrmdir($this->paths->tempDirectory);
494
  }
495
 
496
  mkdir($this->paths->restoreDirectory);
1
  <?php
2
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
3
+ if (DupLiteSnapLibUtil::wp_is_ini_value_changeable('display_errors'))
4
  ini_set('display_errors', 1);
5
  error_reporting(E_ALL);
6
  error_reporting(E_ALL);
146
  public function processRequest()
147
  {
148
  try {
149
+ $this->lockHandle = DupLiteSnapLibIOU::fopen($this->paths->processLockFilepath, 'c+');
150
 
151
+ DupLiteSnapLibIOU::flock($this->lockHandle, LOCK_EX);
152
 
153
  $this->logger = new DaTesterLogging($this->paths->logFilepath);
154
 
202
  DupArchiveEngine::createArchive($this->paths->archiveFilepath, $this->params->compress);
203
 
204
  $daTesterCreateState->archivePath = $this->paths->archiveFilepath;
205
+ $daTesterCreateState->archiveOffset = DupLiteSnapLibIOU::filesize($this->paths->archiveFilepath);
206
  $daTesterCreateState->working = true;
207
  $daTesterCreateState->timeSliceInSecs = $this->params->workerTime;
208
  $daTesterCreateState->basePath = $this->paths->dataDirectory;
417
  exit(1);
418
  }
419
 
420
+ DupLiteSnapLibIOU::flock($this->lockHandle, LOCK_UN);
421
 
422
  $this->logger->log("Unlocked file");
423
 
430
 
431
  $this->logger->logObject("SPAWNING CUSTOM WORKER AT $url FOR ACTION {$this->params->action}", $data);
432
 
433
+ DupLiteSnapLibNetU::postWithoutWait($url, $data);
434
 
435
  $this->logger->log('After post without wait');
436
  } else {
477
  @unlink($this->paths->scanFilepath);
478
  }
479
 
480
+ $handle = DupLiteSnapLibIOU::fopen($this->paths->archiveFilepath, 'w');
481
+ DupLiteSnapLibIOU::fclose($handle);
482
 
483
  //$this->logger->clearLog();
484
  }
486
  private function clearExpandFiles()
487
  {
488
  if (file_exists($this->paths->restoreDirectory)) {
489
+ DupLiteSnapLibIOU::rrmdir($this->paths->restoreDirectory);
490
  }
491
 
492
  if (file_exists($this->paths->tempDirectory)) {
493
+ DupLiteSnapLibIOU::rrmdir($this->paths->tempDirectory);
494
  }
495
 
496
  mkdir($this->paths->restoreDirectory);
lib/snaplib/class.snaplib.exceptions.php CHANGED
@@ -5,14 +5,17 @@
5
  * Standard: PSR-2
6
  * @link http://www.php-fig.org/psr/psr-2
7
  *
8
- * @package SnapLib
9
  * @copyright (c) 2017, Snapcreek LLC
10
  * @license https://opensource.org/licenses/GPL-3.0 GNU Public License
11
  *
12
  */
13
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
14
 
15
- class SnapLib_32BitSizeLimitException extends Exception
16
- {
17
 
 
 
 
 
18
  }
5
  * Standard: PSR-2
6
  * @link http://www.php-fig.org/psr/psr-2
7
  *
8
+ * @package DupLiteSnapLib
9
  * @copyright (c) 2017, Snapcreek LLC
10
  * @license https://opensource.org/licenses/GPL-3.0 GNU Public License
11
  *
12
  */
13
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
14
 
15
+ if (!class_exists('DupLiteSnapLib_32BitSizeLimitException', false)) {
 
16
 
17
+ class DupLiteSnapLib_32BitSizeLimitException extends Exception
18
+ {
19
+
20
+ }
21
  }
lib/snaplib/class.snaplib.logger.php CHANGED
@@ -5,105 +5,108 @@
5
  * Standard: PSR-2
6
  * @link http://www.php-fig.org/psr/psr-2
7
  *
8
- * @package SnapLib
9
  * @copyright (c) 2017, Snapcreek LLC
10
  * @license https://opensource.org/licenses/GPL-3.0 GNU Public License
11
  *
12
  */
13
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
14
 
15
- class SnapLibLogger
16
- {
17
- public static $logFilepath = null;
18
- static $logHandle = null;
19
 
20
- public static function init($logFilepath)
21
  {
22
- self::$logFilepath = $logFilepath;
23
- }
24
 
25
- public static function clearLog()
26
- {
27
- if (file_exists(self::$logFilepath)) {
28
- if (self::$logHandle !== null) {
29
- fflush(self::$logHandle);
30
- fclose(self::$logHandle);
31
- self::$logHandle = null;
32
- }
33
- @unlink(self::$logFilepath);
34
  }
35
- }
36
 
37
- public static function logObject($s, $o, $flush = false)
38
- {
39
- self::log($s, $flush);
40
- self::log(print_r($o, true), $flush);
41
- }
42
-
43
- public static function log($s, $flush = false, $callingFunctionOverride = null)
44
- {
45
- // echo "{$s}<br/>";
46
- $lfp = self::$logFilepath;
47
- // echo "logging $s to {$lfp}<br/>";
48
- if (self::$logFilepath === null) {
49
- throw new Exception('Logging not initialized');
50
  }
51
 
52
- if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
53
- $timepart = $_SERVER['REQUEST_TIME_FLOAT'];
54
- } else {
55
- $timepart = $_SERVER['REQUEST_TIME'];
56
  }
57
 
58
- $thread_id = sprintf("%08x", abs(crc32($_SERVER['REMOTE_ADDR'].$timepart.$_SERVER['REMOTE_PORT'])));
 
 
 
 
 
 
 
59
 
60
- $s = $thread_id.' '.date('h:i:s').":$s";
 
 
 
 
61
 
62
- if (self::$logHandle === null) {
63
 
64
- self::$logHandle = fopen(self::$logFilepath, 'a');
65
- }
66
 
67
- fwrite(self::$logHandle, "$s\n");
68
 
69
- if ($flush) {
70
- fflush(self::$logHandle);
71
 
72
- fclose(self::$logHandle);
73
 
74
- self::$logHandle = fopen(self::$logFilepath, 'a');
75
- }
76
- }
77
- private static $profileLogArray = null;
78
- private static $prevTS = -1;
79
 
80
- public static function initProfiling()
81
- {
82
- self::$profileLogArray = array();
83
- }
84
 
85
- public static function writeToPLog($s)
86
- {
87
- throw new exception('not implemented');
88
- $currentTime = microtime(true);
89
-
90
- if (array_key_exists($s, self::$profileLogArray)) {
91
- $dSame = $currentTime - self::$profileLogArray[$s];
92
- $dSame = number_format($dSame, 7);
93
- } else {
94
- $dSame = 'N/A';
95
  }
 
 
96
 
97
- if (self::$prevTS != -1) {
98
- $dPrev = $currentTime - self::$prevTS;
99
- $dPrev = number_format($dPrev, 7);
100
- } else {
101
- $dPrev = 'N/A';
102
  }
103
 
104
- self::$profileLogArray[$s] = $currentTime;
105
- self::$prevTS = $currentTime;
 
 
 
 
 
 
 
 
 
106
 
107
- self::log(" {$dPrev} : {$dSame} : {$currentTime} : {$s}");
 
 
 
 
 
 
 
 
 
 
 
108
  }
109
  }
5
  * Standard: PSR-2
6
  * @link http://www.php-fig.org/psr/psr-2
7
  *
8
+ * @package DupLiteSnapLib
9
  * @copyright (c) 2017, Snapcreek LLC
10
  * @license https://opensource.org/licenses/GPL-3.0 GNU Public License
11
  *
12
  */
13
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
14
 
15
+ if (!class_exists('DupLiteSnapLibLogger', false)) {
 
 
 
16
 
17
+ class DupLiteSnapLibLogger
18
  {
19
+ public static $logFilepath = null;
20
+ static $logHandle = null;
21
 
22
+ public static function init($logFilepath)
23
+ {
24
+ self::$logFilepath = $logFilepath;
 
 
 
 
 
 
25
  }
 
26
 
27
+ public static function clearLog()
28
+ {
29
+ if (file_exists(self::$logFilepath)) {
30
+ if (self::$logHandle !== null) {
31
+ fflush(self::$logHandle);
32
+ fclose(self::$logHandle);
33
+ self::$logHandle = null;
34
+ }
35
+ @unlink(self::$logFilepath);
36
+ }
 
 
 
37
  }
38
 
39
+ public static function logObject($s, $o, $flush = false)
40
+ {
41
+ self::log($s, $flush);
42
+ self::log(print_r($o, true), $flush);
43
  }
44
 
45
+ public static function log($s, $flush = false, $callingFunctionOverride = null)
46
+ {
47
+ // echo "{$s}<br/>";
48
+ $lfp = self::$logFilepath;
49
+ // echo "logging $s to {$lfp}<br/>";
50
+ if (self::$logFilepath === null) {
51
+ throw new Exception('Logging not initialized');
52
+ }
53
 
54
+ if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
55
+ $timepart = $_SERVER['REQUEST_TIME_FLOAT'];
56
+ } else {
57
+ $timepart = $_SERVER['REQUEST_TIME'];
58
+ }
59
 
60
+ $thread_id = sprintf("%08x", abs(crc32($_SERVER['REMOTE_ADDR'].$timepart.$_SERVER['REMOTE_PORT'])));
61
 
62
+ $s = $thread_id.' '.date('h:i:s').":$s";
 
63
 
64
+ if (self::$logHandle === null) {
65
 
66
+ self::$logHandle = fopen(self::$logFilepath, 'a');
67
+ }
68
 
69
+ fwrite(self::$logHandle, "$s\n");
70
 
71
+ if ($flush) {
72
+ fflush(self::$logHandle);
 
 
 
73
 
74
+ fclose(self::$logHandle);
 
 
 
75
 
76
+ self::$logHandle = fopen(self::$logFilepath, 'a');
77
+ }
 
 
 
 
 
 
 
 
78
  }
79
+ private static $profileLogArray = null;
80
+ private static $prevTS = -1;
81
 
82
+ public static function initProfiling()
83
+ {
84
+ self::$profileLogArray = array();
 
 
85
  }
86
 
87
+ public static function writeToPLog($s)
88
+ {
89
+ throw new exception('not implemented');
90
+ $currentTime = microtime(true);
91
+
92
+ if (array_key_exists($s, self::$profileLogArray)) {
93
+ $dSame = $currentTime - self::$profileLogArray[$s];
94
+ $dSame = number_format($dSame, 7);
95
+ } else {
96
+ $dSame = 'N/A';
97
+ }
98
 
99
+ if (self::$prevTS != -1) {
100
+ $dPrev = $currentTime - self::$prevTS;
101
+ $dPrev = number_format($dPrev, 7);
102
+ } else {
103
+ $dPrev = 'N/A';
104
+ }
105
+
106
+ self::$profileLogArray[$s] = $currentTime;
107
+ self::$prevTS = $currentTime;
108
+
109
+ self::log(" {$dPrev} : {$dSame} : {$currentTime} : {$s}");
110
+ }
111
  }
112
  }
lib/snaplib/class.snaplib.u.io.php CHANGED
@@ -5,331 +5,334 @@
5
  * Standard: PSR-2
6
  * @link http://www.php-fig.org/psr/psr-2
7
  *
8
- * @package SnapLib
9
  * @copyright (c) 2017, Snapcreek LLC
10
  * @license https://opensource.org/licenses/GPL-3.0 GNU Public License
11
  *
12
  */
13
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
14
 
15
- require_once(dirname(__FILE__).'/class.snaplib.u.string.php');
16
- require_once(dirname(__FILE__).'/class.snaplib.u.os.php');
17
 
18
- class SnapLibIOU
19
- {
20
- // Real upper bound of a signed int is 214748364.
21
- // The value chosen below, makes sure we have a buffer of ~4.7 million.
22
- const FileSizeLimit32BitPHP = 1900000000;
23
 
24
- public static function rmPattern($filePathPattern)
25
  {
26
- @array_map('unlink', glob($filePathPattern));
27
- }
 
28
 
29
- public static function chmodPattern($filePathPattern, $mode)
30
- {
31
- $filePaths = glob($filePathPattern);
 
 
 
 
 
32
 
33
- $modes = array();
34
 
35
- foreach ($filePaths as $filePath) {
36
- $modes[] = $mode;
 
 
 
37
  }
38
 
39
- @array_map('chmod', $filePaths, $modes);
40
- }
 
 
 
 
 
 
 
41
 
42
- public static function copy($source, $dest, $overwriteIfExists = true)
43
- {
44
- if (file_exists($dest)) {
45
- if ($overwriteIfExists) {
46
- self::rm($dest);
47
- } else {
48
- throw new Exception("Can't copy {$source} to {$dest} because {$dest} already exists!");
49
  }
50
  }
51
 
52
- if (copy($source, $dest) === false) {
53
- throw new Exception("Error copying {$source} to {$dest}");
54
- }
55
- }
 
56
 
57
- public static function safePath($path, $real = false)
58
- {
59
- if ($real) {
60
- $path = realpath($path);
61
  }
62
 
63
- return str_replace("\\", "/", $path);
64
- }
 
65
 
66
- public static function massMove($fileSystemObjects, $destination, $exclusions = null, $exceptionOnError = true)
67
- {
68
- $failures = array();
69
 
70
- $destination = rtrim($destination, '/\\');
71
-
72
- if (!file_exists($destination)) {
73
- self::mkdir($destination);
74
- }
75
 
76
- foreach ($fileSystemObjects as $fileSystemObject) {
77
- $shouldMove = true;
78
 
79
- if ($exclusions != null) {
80
 
81
- foreach ($exclusions as $exclusion) {
82
- if (preg_match($exclusion, $fileSystemObject) === 1) {
83
- $shouldMove = false;
84
- break;
 
85
  }
86
  }
87
- }
88
 
89
- if ($shouldMove) {
90
 
91
- $newName = $destination.'/'.basename($fileSystemObject);
92
 
93
- if (!file_exists($fileSystemObject)) {
94
- $failures[] = "Tried to move {$fileSystemObject} to {$newName} but it didn't exist!";
95
- } else if (!@rename($fileSystemObject, $newName)) {
96
- $failures[] = "Couldn't move {$fileSystemObject} to {$newName}";
 
97
  }
98
  }
99
- }
100
 
101
- if ($exceptionOnError && count($failures) > 0) {
102
- throw new Exception(implode(',', $failures));
103
- }
104
 
105
- return $failures;
106
- }
107
 
108
- public static function rename($oldname, $newname, $removeIfExists = false)
109
- {
110
- if ($removeIfExists) {
111
- if (file_exists($newname)) {
112
- if (is_dir($newname)) {
113
- self::rmdir($newname);
114
- } else {
115
- self::rm($newname);
 
116
  }
117
  }
118
- }
119
 
120
- if (!@rename($oldname, $newname)) {
121
- throw new Exception("Couldn't rename {$oldname} to {$newname}");
 
122
  }
123
- }
124
 
125
- public static function fopen($filepath, $mode, $throwOnError = true)
126
- {
127
- if (SnapLibOSU::$isWindows) {
128
 
129
- if (strlen($filepath) > SnapLibOSU::WindowsMaxPathLength) {
130
- throw new Exception("Skipping a file that exceeds allowed Windows path length. File: {$filepath}");
 
131
  }
132
- }
133
 
134
- if (SnapLibStringU::startsWith($mode, 'w') || SnapLibStringU::startsWith($mode, 'c') || file_exists($filepath)) {
135
- $file_handle = @fopen($filepath, $mode);
136
- } else {
137
- if ($throwOnError) {
138
- throw new Exception("$filepath doesn't exist");
139
  } else {
140
- return false;
 
 
 
 
141
  }
142
- }
143
 
144
- if ($file_handle === false) {
145
- if ($throwOnError) {
146
- throw new Exception("Error opening $filepath");
 
 
 
147
  } else {
148
- return false;
149
  }
150
- } else {
151
- return $file_handle;
152
  }
153
- }
154
 
155
- public static function touch($filepath, $time = null)
156
- {
157
- if ($time === null) {
158
- $time = time();
159
- }
160
 
161
- if (@touch($filepath, $time) === null) {
162
- throw new Exception("Couldn't update time on {$filepath}");
 
163
  }
164
- }
165
 
166
- public static function rmdir($dirname, $mustExist = false)
167
- {
168
- if (file_exists($dirname)) {
169
- @chmod($dirname, 0755);
170
- if (@rmdir($dirname) === false) {
171
- throw new Exception("Couldn't remove {$dirname}");
 
 
 
172
  }
173
- } else if ($mustExist) {
174
- throw new Exception("{$dirname} doesn't exist");
175
  }
176
- }
177
 
178
- public static function rm($filepath, $mustExist = false)
179
- {
180
- if (file_exists($filepath)) {
181
- @chmod($filepath, 0644);
182
- if (@unlink($filepath) === false) {
183
- throw new Exception("Couldn't remove {$filepath}");
 
 
 
184
  }
185
- } else if ($mustExist) {
186
- throw new Exception("{$filepath} doesn't exist");
187
  }
188
- }
189
 
190
- public static function fwrite($handle, $string)
191
- {
192
- $bytes_written = @fwrite($handle, $string);
193
 
194
- if ($bytes_written === false) {
195
- throw new Exception('Error writing to file.');
196
- } else {
197
- return $bytes_written;
 
198
  }
199
- }
200
 
201
- public static function fgets($handle, $length)
202
- {
203
- $line = fgets($handle, $length);
204
 
205
- if ($line === false) {
206
- throw new Exception('Error reading line.');
207
- }
208
 
209
- return $line;
210
- }
211
 
212
- public static function fclose($handle, $exception_on_fail = true)
213
- {
214
- if ((@fclose($handle) === false) && $exception_on_fail) {
215
- throw new Exception("Error closing file");
 
216
  }
217
- }
218
 
219
- public static function flock($handle, $operation)
220
- {
221
- if (@flock($handle, $operation) === false) {
222
- throw new Exception("Error locking file");
 
223
  }
224
- }
225
 
226
- public static function ftell($file_handle)
227
- {
228
- $position = @ftell($file_handle);
229
 
230
- if ($position === false) {
231
- throw new Exception("Couldn't retrieve file offset for $filepath");
232
- } else {
233
- return $position;
 
234
  }
235
- }
236
 
237
- public static function rrmdir($dir)
238
- {
239
- if (is_dir($dir)) {
240
- $objects = scandir($dir);
241
- foreach ($objects as $object) {
242
- if ($object != "." && $object != "..") {
243
- if (is_dir($dir."/".$object)) {
244
- SnapLibIOU::rrmdir($dir."/".$object);
245
- } else {
246
- //unlink($dir."/".$object);
247
- self::rm($dir."/".$object);
 
248
  }
249
  }
 
250
  }
251
- rmdir($dir);
252
  }
253
- }
254
 
255
- public static function filesize($filename)
256
- {
257
- $file_size = @filesize($filename);
258
 
259
- if ($file_size === false) {
260
- throw new Exception("Error retrieving file size of $filename");
 
 
 
261
  }
262
 
263
- return $file_size;
264
- }
 
265
 
266
- public static function fseek($handle, $offset, $whence = SEEK_SET)
267
- {
268
- $ret_val = @fseek($handle, $offset, $whence);
269
-
270
- if ($ret_val !== 0) {
271
- $filepath = stream_get_meta_data($handle);
272
- $filepath = $filepath["uri"];
273
- $filesize = self::filesize($filepath);
274
- if ($ret_val === false) {
275
- throw new Exception("Trying to fseek($offset, $whence) and came back false");
276
- }
277
- //This check is not strict, but in most cases 32 Bit PHP will be the issue
278
- else if (abs($offset) > self::FileSizeLimit32BitPHP || $filesize > self::FileSizeLimit32BitPHP || ($offset < 0 && $whence == SEEK_SET)) {
279
- throw new SnapLib_32BitSizeLimitException("Trying to seek on a file beyond the capability of 32 bit PHP. offset=$offset filesize=$filesize");
280
- } else {
281
- throw new Exception("Error seeking to file offset $offset. Retval = $ret_val");
282
  }
283
  }
284
- }
285
 
286
- public static function filemtime($filename)
287
- {
288
- $mtime = filemtime($filename);
 
 
 
 
289
 
290
- if ($mtime === E_WARNING) {
291
- throw new Exception("Cannot retrieve last modified time of $filename");
292
  }
293
 
294
- return $mtime;
295
- }
 
296
 
297
- public static function mkdir($pathname, $mode = 0755, $recursive = false)
298
- {
299
- if (SnapLibOSU::$isWindows) {
 
300
 
301
- if (strlen($pathname) > SnapLibOSU::WindowsMaxPathLength) {
302
- throw new Exception("Skipping creating directory that exceeds allowed Windows path length. File: {$pathname}");
 
 
 
 
 
 
303
  }
304
  }
305
 
306
- if (!file_exists($pathname)) {
307
- if (@mkdir($pathname, $mode, $recursive) === false) {
308
- throw new Exception("Error creating directory {$pathname}");
309
- }
310
- } else {
311
- if (@chmod($pathname, $mode) === false) {
312
- throw new Exception("Error setting mode on directory {$pathname}");
313
  }
314
  }
315
- }
316
 
317
- public static function filePutContents($filename, $data)
318
- {
319
- if (file_put_contents($filename, $data) === false) {
320
- throw new Exception("Couldn't write data to {$filename}");
321
  }
322
- }
323
-
324
- public static function getFileName($file_path)
325
- {
326
- $info = new SplFileInfo($file_path);
327
- return $info->getFilename();
328
- }
329
 
330
- public static function getPath($file_path)
331
- {
332
- $info = new SplFileInfo($file_path);
333
- return $info->getPath();
 
334
  }
335
  }
5
  * Standard: PSR-2
6
  * @link http://www.php-fig.org/psr/psr-2
7
  *
8
+ * @package DupLiteSnapLib
9
  * @copyright (c) 2017, Snapcreek LLC
10
  * @license https://opensource.org/licenses/GPL-3.0 GNU Public License
11
  *
12
  */
13
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
14
 
15
+ if (!class_exists('DupLiteSnapLibIOU', false)) {
 
16
 
17
+ require_once(dirname(__FILE__).'/class.snaplib.u.string.php');
18
+ require_once(dirname(__FILE__).'/class.snaplib.u.os.php');
 
 
 
19
 
20
+ class DupLiteSnapLibIOU
21
  {
22
+ // Real upper bound of a signed int is 214748364.
23
+ // The value chosen below, makes sure we have a buffer of ~4.7 million.
24
+ const FileSizeLimit32BitPHP = 1900000000;
25
 
26
+ public static function rmPattern($filePathPattern)
27
+ {
28
+ @array_map('unlink', glob($filePathPattern));
29
+ }
30
+
31
+ public static function chmodPattern($filePathPattern, $mode)
32
+ {
33
+ $filePaths = glob($filePathPattern);
34
 
35
+ $modes = array();
36
 
37
+ foreach ($filePaths as $filePath) {
38
+ $modes[] = $mode;
39
+ }
40
+
41
+ @array_map('chmod', $filePaths, $modes);
42
  }
43
 
44
+ public static function copy($source, $dest, $overwriteIfExists = true)
45
+ {
46
+ if (file_exists($dest)) {
47
+ if ($overwriteIfExists) {
48
+ self::rm($dest);
49
+ } else {
50
+ throw new Exception("Can't copy {$source} to {$dest} because {$dest} already exists!");
51
+ }
52
+ }
53
 
54
+ if (copy($source, $dest) === false) {
55
+ throw new Exception("Error copying {$source} to {$dest}");
 
 
 
 
 
56
  }
57
  }
58
 
59
+ public static function safePath($path, $real = false)
60
+ {
61
+ if ($real) {
62
+ $path = realpath($path);
63
+ }
64
 
65
+ return str_replace("\\", "/", $path);
 
 
 
66
  }
67
 
68
+ public static function massMove($fileSystemObjects, $destination, $exclusions = null, $exceptionOnError = true)
69
+ {
70
+ $failures = array();
71
 
72
+ $destination = rtrim($destination, '/\\');
 
 
73
 
74
+ if (!file_exists($destination)) {
75
+ self::mkdir($destination);
76
+ }
 
 
77
 
78
+ foreach ($fileSystemObjects as $fileSystemObject) {
79
+ $shouldMove = true;
80
 
81
+ if ($exclusions != null) {
82
 
83
+ foreach ($exclusions as $exclusion) {
84
+ if (preg_match($exclusion, $fileSystemObject) === 1) {
85
+ $shouldMove = false;
86
+ break;
87
+ }
88
  }
89
  }
 
90
 
91
+ if ($shouldMove) {
92
 
93
+ $newName = $destination.'/'.basename($fileSystemObject);
94
 
95
+ if (!file_exists($fileSystemObject)) {
96
+ $failures[] = "Tried to move {$fileSystemObject} to {$newName} but it didn't exist!";
97
+ } else if (!@rename($fileSystemObject, $newName)) {
98
+ $failures[] = "Couldn't move {$fileSystemObject} to {$newName}";
99
+ }
100
  }
101
  }
 
102
 
103
+ if ($exceptionOnError && count($failures) > 0) {
104
+ throw new Exception(implode(',', $failures));
105
+ }
106
 
107
+ return $failures;
108
+ }
109
 
110
+ public static function rename($oldname, $newname, $removeIfExists = false)
111
+ {
112
+ if ($removeIfExists) {
113
+ if (file_exists($newname)) {
114
+ if (is_dir($newname)) {
115
+ self::rmdir($newname);
116
+ } else {
117
+ self::rm($newname);
118
+ }
119
  }
120
  }
 
121
 
122
+ if (!@rename($oldname, $newname)) {
123
+ throw new Exception("Couldn't rename {$oldname} to {$newname}");
124
+ }
125
  }
 
126
 
127
+ public static function fopen($filepath, $mode, $throwOnError = true)
128
+ {
129
+ if (DupLiteSnapLibOSU::$isWindows) {
130
 
131
+ if (strlen($filepath) > DupLiteSnapLibOSU::WindowsMaxPathLength) {
132
+ throw new Exception("Skipping a file that exceeds allowed Windows path length. File: {$filepath}");
133
+ }
134
  }
 
135
 
136
+ if (DupLiteSnapLibStringU::startsWith($mode, 'w') || DupLiteSnapLibStringU::startsWith($mode, 'c') || file_exists($filepath)) {
137
+ $file_handle = @fopen($filepath, $mode);
 
 
 
138
  } else {
139
+ if ($throwOnError) {
140
+ throw new Exception("$filepath doesn't exist");
141
+ } else {
142
+ return false;
143
+ }
144
  }
 
145
 
146
+ if ($file_handle === false) {
147
+ if ($throwOnError) {
148
+ throw new Exception("Error opening $filepath");
149
+ } else {
150
+ return false;
151
+ }
152
  } else {
153
+ return $file_handle;
154
  }
 
 
155
  }
 
156
 
157
+ public static function touch($filepath, $time = null)
158
+ {
159
+ if ($time === null) {
160
+ $time = time();
161
+ }
162
 
163
+ if (@touch($filepath, $time) === null) {
164
+ throw new Exception("Couldn't update time on {$filepath}");
165
+ }
166
  }
 
167
 
168
+ public static function rmdir($dirname, $mustExist = false)
169
+ {
170
+ if (file_exists($dirname)) {
171
+ @chmod($dirname, 0755);
172
+ if (@rmdir($dirname) === false) {
173
+ throw new Exception("Couldn't remove {$dirname}");
174
+ }
175
+ } else if ($mustExist) {
176
+ throw new Exception("{$dirname} doesn't exist");
177
  }
 
 
178
  }
 
179
 
180
+ public static function rm($filepath, $mustExist = false)
181
+ {
182
+ if (file_exists($filepath)) {
183
+ @chmod($filepath, 0644);
184
+ if (@unlink($filepath) === false) {
185
+ throw new Exception("Couldn't remove {$filepath}");
186
+ }
187
+ } else if ($mustExist) {
188
+ throw new Exception("{$filepath} doesn't exist");
189
  }
 
 
190
  }
 
191
 
192
+ public static function fwrite($handle, $string)
193
+ {
194
+ $bytes_written = @fwrite($handle, $string);
195
 
196
+ if ($bytes_written === false) {
197
+ throw new Exception('Error writing to file.');
198
+ } else {
199
+ return $bytes_written;
200
+ }
201
  }
 
202
 
203
+ public static function fgets($handle, $length)
204
+ {
205
+ $line = fgets($handle, $length);
206
 
207
+ if ($line === false) {
208
+ throw new Exception('Error reading line.');
209
+ }
210
 
211
+ return $line;
212
+ }
213
 
214
+ public static function fclose($handle, $exception_on_fail = true)
215
+ {
216
+ if ((@fclose($handle) === false) && $exception_on_fail) {
217
+ throw new Exception("Error closing file");
218
+ }
219
  }
 
220
 
221
+ public static function flock($handle, $operation)
222
+ {
223
+ if (@flock($handle, $operation) === false) {
224
+ throw new Exception("Error locking file");
225
+ }
226
  }
 
227
 
228
+ public static function ftell($file_handle)
229
+ {
230
+ $position = @ftell($file_handle);
231
 
232
+ if ($position === false) {
233
+ throw new Exception("Couldn't retrieve file offset for $filepath");
234
+ } else {
235
+ return $position;
236
+ }
237
  }
 
238
 
239
+ public static function rrmdir($dir)
240
+ {
241
+ if (is_dir($dir)) {
242
+ $objects = scandir($dir);
243
+ foreach ($objects as $object) {
244
+ if ($object != "." && $object != "..") {
245
+ if (is_dir($dir."/".$object)) {
246
+ DupLiteSnapLibIOU::rrmdir($dir."/".$object);
247
+ } else {
248
+ //unlink($dir."/".$object);
249
+ self::rm($dir."/".$object);
250
+ }
251
  }
252
  }
253
+ rmdir($dir);
254
  }
 
255
  }
 
256
 
257
+ public static function filesize($filename)
258
+ {
259
+ $file_size = @filesize($filename);
260
 
261
+ if ($file_size === false) {
262
+ throw new Exception("Error retrieving file size of $filename");
263
+ }
264
+
265
+ return $file_size;
266
  }
267
 
268
+ public static function fseek($handle, $offset, $whence = SEEK_SET)
269
+ {
270
+ $ret_val = @fseek($handle, $offset, $whence);
271
 
272
+ if ($ret_val !== 0) {
273
+ $filepath = stream_get_meta_data($handle);
274
+ $filepath = $filepath["uri"];
275
+ $filesize = self::filesize($filepath);
276
+ if ($ret_val === false) {
277
+ throw new Exception("Trying to fseek($offset, $whence) and came back false");
278
+ }
279
+ //This check is not strict, but in most cases 32 Bit PHP will be the issue
280
+ else if (abs($offset) > self::FileSizeLimit32BitPHP || $filesize > self::FileSizeLimit32BitPHP || ($offset < 0 && $whence == SEEK_SET)) {
281
+ throw new DupLiteSnapLib_32BitSizeLimitException("Trying to seek on a file beyond the capability of 32 bit PHP. offset=$offset filesize=$filesize");
282
+ } else {
283
+ throw new Exception("Error seeking to file offset $offset. Retval = $ret_val");
284
+ }
 
 
 
285
  }
286
  }
 
287
 
288
+ public static function filemtime($filename)
289
+ {
290
+ $mtime = filemtime($filename);
291
+
292
+ if ($mtime === E_WARNING) {
293
+ throw new Exception("Cannot retrieve last modified time of $filename");
294
+ }
295
 
296
+ return $mtime;
 
297
  }
298
 
299
+ public static function mkdir($pathname, $mode = 0755, $recursive = false)
300
+ {
301
+ if (DupLiteSnapLibOSU::$isWindows) {
302
 
303
+ if (strlen($pathname) > DupLiteSnapLibOSU::WindowsMaxPathLength) {
304
+ throw new Exception("Skipping creating directory that exceeds allowed Windows path length. File: {$pathname}");
305
+ }
306
+ }
307
 
308
+ if (!file_exists($pathname)) {
309
+ if (@mkdir($pathname, $mode, $recursive) === false) {
310
+ throw new Exception("Error creating directory {$pathname}");
311
+ }
312
+ } else {
313
+ if (@chmod($pathname, $mode) === false) {
314
+ throw new Exception("Error setting mode on directory {$pathname}");
315
+ }
316
  }
317
  }
318
 
319
+ public static function filePutContents($filename, $data)
320
+ {
321
+ if (file_put_contents($filename, $data) === false) {
322
+ throw new Exception("Couldn't write data to {$filename}");
 
 
 
323
  }
324
  }
 
325
 
326
+ public static function getFileName($file_path)
327
+ {
328
+ $info = new SplFileInfo($file_path);
329
+ return $info->getFilename();
330
  }
 
 
 
 
 
 
 
331
 
332
+ public static function getPath($file_path)
333
+ {
334
+ $info = new SplFileInfo($file_path);
335
+ return $info->getPath();
336
+ }
337
  }
338
  }
lib/snaplib/class.snaplib.u.net.php CHANGED
@@ -5,58 +5,61 @@
5
  * Standard: PSR-2
6
  * @link http://www.php-fig.org/psr/psr-2
7
  *
8
- * @package SnapLib
9
  * @copyright (c) 2017, Snapcreek LLC
10
  * @license https://opensource.org/licenses/GPL-3.0 GNU Public License
11
  *
12
  */
13
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
14
 
15
- class SnapLibNetU
16
- {
17
 
18
- public static function postWithoutWait($url, $params)
19
  {
20
- foreach ($params as $key => &$val) {
21
- if (is_array($val)) {
22
- $val = implode(',', $val);
 
 
 
 
 
23
  }
24
- $post_params[] = $key.'='.urlencode($val);
25
- }
26
 
27
- $post_string = implode('&', $post_params);
28
 
29
- $parts = parse_url($url);
30
 
31
- $fp = fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : 80, $errno, $errstr, 60);
32
 
33
- $out = "POST ".$parts['path']." HTTP/1.1\r\n";
34
- $out .= "Host: ".$parts['host']."\r\n";
35
- $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
36
- $out .= "Content-Length: ".strlen($post_string)."\r\n";
37
- $out .= "Connection: Close\r\n\r\n";
38
 
39
- if (isset($post_string)) {
40
- $out .= $post_string;
41
- }
42
 
43
- fwrite($fp, $out);
44
 
45
- fclose($fp);
46
- }
47
 
48
- public static function getRequestValue($paramName, $isRequired = true, $default = null)
49
- {
50
- if (isset($_REQUEST[$paramName])) {
51
 
52
- return $_REQUEST[$paramName];
53
- } else {
54
 
55
- if ($isRequired) {
56
- throw new Exception("Parameter $paramName not present");
57
- }
58
 
59
- return $default;
 
60
  }
61
  }
62
  }
5
  * Standard: PSR-2
6
  * @link http://www.php-fig.org/psr/psr-2
7
  *
8
+ * @package DupLiteSnapLib
9
  * @copyright (c) 2017, Snapcreek LLC
10
  * @license https://opensource.org/licenses/GPL-3.0 GNU Public License
11
  *
12
  */
13
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
14
 
15
+ if (!class_exists('DupLiteSnapLibNetU', false)) {
 
16
 
17
+ class DupLiteSnapLibNetU
18
  {
19
+
20
+ public static function postWithoutWait($url, $params)
21
+ {
22
+ foreach ($params as $key => &$val) {
23
+ if (is_array($val)) {
24
+ $val = implode(',', $val);
25
+ }
26
+ $post_params[] = $key.'='.urlencode($val);
27
  }
 
 
28
 
29
+ $post_string = implode('&', $post_params);
30
 
31
+ $parts = parse_url($url);
32
 
33
+ $fp = fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : 80, $errno, $errstr, 60);
34
 
35
+ $out = "POST ".$parts['path']." HTTP/1.1\r\n";
36
+ $out .= "Host: ".$parts['host']."\r\n";
37
+ $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
38
+ $out .= "Content-Length: ".strlen($post_string)."\r\n";
39
+ $out .= "Connection: Close\r\n\r\n";
40
 
41
+ if (isset($post_string)) {
42
+ $out .= $post_string;
43
+ }
44
 
45
+ fwrite($fp, $out);
46
 
47
+ fclose($fp);
48
+ }
49
 
50
+ public static function getRequestValue($paramName, $isRequired = true, $default = null)
51
+ {
52
+ if (isset($_REQUEST[$paramName])) {
53
 
54
+ return $_REQUEST[$paramName];
55
+ } else {
56
 
57
+ if ($isRequired) {
58
+ throw new Exception("Parameter $paramName not present");
59
+ }
60
 
61
+ return $default;
62
+ }
63
  }
64
  }
65
  }
lib/snaplib/class.snaplib.u.os.php CHANGED
@@ -5,25 +5,26 @@
5
  * Standard: PSR-2
6
  * @link http://www.php-fig.org/psr/psr-2
7
  *
8
- * @package SnapLib
9
  * @copyright (c) 2017, Snapcreek LLC
10
  * @license https://opensource.org/licenses/GPL-3.0 GNU Public License
11
  *
12
  */
13
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
14
 
15
- class SnapLibOSU
16
- {
17
- const WindowsMaxPathLength = 259;
18
 
19
- public static $isWindows;
20
-
21
- public static function init()
22
  {
 
23
 
24
- self::$isWindows = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
25
- }
26
- }
27
- SnapLibOSU::init();
28
 
 
 
29
 
 
 
 
 
 
5
  * Standard: PSR-2
6
  * @link http://www.php-fig.org/psr/psr-2
7
  *
8
+ * @package DupLiteSnapLib
9
  * @copyright (c) 2017, Snapcreek LLC
10
  * @license https://opensource.org/licenses/GPL-3.0 GNU Public License
11
  *
12
  */
13
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
14
 
15
+ if (!class_exists('DupLiteSnapLibOSU', false)) {
 
 
16
 
17
+ class DupLiteSnapLibOSU
 
 
18
  {
19
+ const WindowsMaxPathLength = 259;
20
 
21
+ public static $isWindows;
 
 
 
22
 
23
+ public static function init()
24
+ {
25
 
26
+ self::$isWindows = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
27
+ }
28
+ }
29
+ DupLiteSnapLibOSU::init();
30
+ }
lib/snaplib/class.snaplib.u.stream.php CHANGED
@@ -5,24 +5,27 @@
5
  * Standard: PSR-2
6
  * @link http://www.php-fig.org/psr/psr-2
7
  *
8
- * @package SnapLib
9
  * @copyright (c) 2017, Snapcreek LLC
10
  * @license https://opensource.org/licenses/GPL-3.0 GNU Public License
11
  *
12
  */
13
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
14
 
15
- class SnapLibStreamU
16
- {
17
 
18
- public static function streamGetLine($handle, $length, $ending)
19
  {
20
- $line = stream_get_line($handle, $length, $ending);
21
 
22
- if ($line === false) {
23
- throw new Exception('Error reading line.');
24
- }
 
 
 
 
25
 
26
- return $line;
 
27
  }
28
  }
5
  * Standard: PSR-2
6
  * @link http://www.php-fig.org/psr/psr-2
7
  *
8
+ * @package DupLiteSnapLib
9
  * @copyright (c) 2017, Snapcreek LLC
10
  * @license https://opensource.org/licenses/GPL-3.0 GNU Public License
11
  *
12
  */
13
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
14
 
15
+ if (!class_exists('DupLiteSnapLibStreamU', false)) {
 
16
 
17
+ class DupLiteSnapLibStreamU
18
  {
 
19
 
20
+ public static function streamGetLine($handle, $length, $ending)
21
+ {
22
+ $line = stream_get_line($handle, $length, $ending);
23
+
24
+ if ($line === false) {
25
+ throw new Exception('Error reading line.');
26
+ }
27
 
28
+ return $line;
29
+ }
30
  }
31
  }
lib/snaplib/class.snaplib.u.string.php CHANGED
@@ -5,75 +5,58 @@
5
  * Standard: PSR-2
6
  * @link http://www.php-fig.org/psr/psr-2
7
  *
8
- * @package SnapLib
9
  * @copyright (c) 2017, Snapcreek LLC
10
  * @license https://opensource.org/licenses/GPL-3.0 GNU Public License
11
  *
12
  */
13
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
14
 
15
- class SnapLibStringU
16
- {
17
 
18
- public static function boolToString($b)
19
  {
20
- return ($b ? 'true' : 'false');
21
- }
22
 
23
- public static function truncateString($s, $maxWidth)
24
- {
25
- if (strlen($s) > $maxWidth) {
26
- $s = substr($s, 0, $maxWidth - 3).'...';
27
  }
28
 
29
- return $s;
30
- }
31
-
32
- /**
33
- * Returns true if the $haystack string starts with the $needle
34
- *
35
- * @param string $haystack The full string to search in
36
- * @param string $needle The string to for
37
- *
38
- * @return bool Returns true if the $haystack string starts with the $needle
39
- */
40
- public static function startsWith($haystack, $needle)
41
- {
42
- $length = strlen($needle);
43
- return (substr($haystack, 0, $length) === $needle);
44
- }
45
-
46
- public static function jsonEncode($value)
47
- {
48
- $retVal = json_encode($value);
49
 
50
- if ($retVal === false) {
51
- throw new Exception("Error JSON encoding data");
52
  }
53
 
54
- return $retVal;
55
- }
56
-
57
- public static function jsonDecode($json, $assoc = true)
58
- {
59
- $retVal = json_decode($json, $assoc);
60
-
61
- if ($retVal === null) {
62
- throw new Exception("Error decoding JSON");
 
 
 
63
  }
64
- }
65
 
66
- /**
67
- * Returns true if the $needle is found in the $haystack
68
- *
69
- * @param string $haystack The full string to search in
70
- * @param string $needle The string to for
71
- *
72
- * @return bool
73
- */
74
- public static function contains($haystack, $needle)
75
- {
76
- $pos = strpos($haystack, $needle);
77
- return ($pos !== false);
 
78
  }
79
  }
5
  * Standard: PSR-2
6
  * @link http://www.php-fig.org/psr/psr-2
7
  *
8
+ * @package DupLiteSnapLib
9
  * @copyright (c) 2017, Snapcreek LLC
10
  * @license https://opensource.org/licenses/GPL-3.0 GNU Public License
11
  *
12
  */
13
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
14
 
15
+ if (!class_exists('DupLiteSnapLibStringU', false)) {
 
16
 
17
+ class DupLiteSnapLibStringU
18
  {
 
 
19
 
20
+ public static function boolToString($b)
21
+ {
22
+ return ($b ? 'true' : 'false');
 
23
  }
24
 
25
+ public static function truncateString($s, $maxWidth)
26
+ {
27
+ if (strlen($s) > $maxWidth) {
28
+ $s = substr($s, 0, $maxWidth - 3).'...';
29
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
+ return $s;
 
32
  }
33
 
34
+ /**
35
+ * Returns true if the $haystack string starts with the $needle
36
+ *
37
+ * @param string $haystack The full string to search in
38
+ * @param string $needle The string to for
39
+ *
40
+ * @return bool Returns true if the $haystack string starts with the $needle
41
+ */
42
+ public static function startsWith($haystack, $needle)
43
+ {
44
+ $length = strlen($needle);
45
+ return (substr($haystack, 0, $length) === $needle);
46
  }
 
47
 
48
+ /**
49
+ * Returns true if the $needle is found in the $haystack
50
+ *
51
+ * @param string $haystack The full string to search in
52
+ * @param string $needle The string to for
53
+ *
54
+ * @return bool
55
+ */
56
+ public static function contains($haystack, $needle)
57
+ {
58
+ $pos = strpos($haystack, $needle);
59
+ return ($pos !== false);
60
+ }
61
  }
62
  }
lib/snaplib/class.snaplib.u.ui.php CHANGED
@@ -4,43 +4,46 @@
4
  * Standard: PSR-2
5
  * @link http://www.php-fig.org/psr/psr-2
6
  *
7
- * @package SnapLib
8
  * @copyright (c) 2017, Snapcreek LLC
9
  * @license https://opensource.org/licenses/GPL-3.0 GNU Public License
10
  *
11
  */
12
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
13
 
14
- class SnapLibUIU
15
- {
16
 
17
- public static function echoBoolean($val)
18
  {
19
- echo $val ? 'true' : 'false';
20
- }
21
 
22
- public static function echoChecked($val)
23
- {
24
- // filter_var is available in >= php 5.2
25
- if (function_exists('filter_var') && defined('FILTER_VALIDATE_BOOLEAN')) {
26
- echo filter_var($val, FILTER_VALIDATE_BOOLEAN) ? 'checked' : '';
27
- } else {
28
- echo $val ? 'checked' : '';
29
  }
30
- }
31
 
32
- public static function echoDisabled($val)
33
- {
34
- echo $val ? 'disabled' : '';
35
- }
 
 
 
 
 
36
 
37
- public static function echoSelected($val)
38
- {
39
- echo $val ? 'selected' : '';
40
- }
41
 
42
- public static function getSelected($val)
43
- {
44
- return ($val ? 'selected' : '');
 
 
 
 
 
 
45
  }
46
  }
4
  * Standard: PSR-2
5
  * @link http://www.php-fig.org/psr/psr-2
6
  *
7
+ * @package DupLiteSnapLib
8
  * @copyright (c) 2017, Snapcreek LLC
9
  * @license https://opensource.org/licenses/GPL-3.0 GNU Public License
10
  *
11
  */
12
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
13
 
14
+ if (!class_exists('DupLiteSnapLibUIU', false)) {
 
15
 
16
+ class DupLiteSnapLibUIU
17
  {
 
 
18
 
19
+ public static function echoBoolean($val)
20
+ {
21
+ echo $val ? 'true' : 'false';
 
 
 
 
22
  }
 
23
 
24
+ public static function echoChecked($val)
25
+ {
26
+ // filter_var is available in >= php 5.2
27
+ if (function_exists('filter_var') && defined('FILTER_VALIDATE_BOOLEAN')) {
28
+ echo filter_var($val, FILTER_VALIDATE_BOOLEAN) ? 'checked' : '';
29
+ } else {
30
+ echo $val ? 'checked' : '';
31
+ }
32
+ }
33
 
34
+ public static function echoDisabled($val)
35
+ {
36
+ echo $val ? 'disabled' : '';
37
+ }
38
 
39
+ public static function echoSelected($val)
40
+ {
41
+ echo $val ? 'selected' : '';
42
+ }
43
+
44
+ public static function getSelected($val)
45
+ {
46
+ return ($val ? 'selected' : '');
47
+ }
48
  }
49
  }
lib/snaplib/class.snaplib.u.url.php CHANGED
@@ -5,55 +5,58 @@
5
  * Standard: PSR-2
6
  * @link http://www.php-fig.org/psr/psr-2
7
  *
8
- * @package SnapLib
9
  * @copyright (c) 2017, Snapcreek LLC
10
  * @license https://opensource.org/licenses/GPL-3.0 GNU Public License
11
  *
12
  */
13
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
14
 
15
- class SnapLibURLU
16
- {
17
 
18
- /**
19
- * Append a new query value to the end of a URL
20
- *
21
- * @param string $url The URL to append the new value to
22
- * @param string $key The new key name
23
- * @param string $value The new key name value
24
- *
25
- * @return string Returns the new URL with with the query string name and value
26
- */
27
- public static function appendQueryValue($url, $key, $value)
28
  {
29
- $separator = (parse_url($url, PHP_URL_QUERY) == NULL) ? '?' : '&';
30
- $modified_url = $url."$separator$key=$value";
31
 
32
- return $modified_url;
33
- }
 
 
 
 
 
 
 
 
 
 
 
34
 
35
- /**
36
- * Fetches current URL via php
37
- *
38
- * @param bool $queryString If true the query string will also be returned.
39
- *
40
- * @returns The current page url
41
- */
42
- public static function getCurrentUrl($queryString = true)
43
- {
44
- $protocol = 'http';
45
- if ($_SERVER['SERVER_PORT'] == 443 || (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')) {
46
- $protocol .= 's';
47
- $protocolPort = $_SERVER['SERVER_PORT'];
48
- } else {
49
- $protocolPort = 80;
50
  }
51
- $host = $_SERVER['HTTP_HOST'];
52
- $port = $_SERVER['SERVER_PORT'];
53
- $request = $_SERVER['PHP_SELF'];
54
 
55
- $query = ($queryString === TRUE) ? $_SERVER['QUERY_STRING'] : "";
56
- $url = $protocol.'://'.$host.($port == $protocolPort ? '' : ':'.$port).$request.(empty($query) ? '' : '?'.$query);
57
- return $url;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  }
59
  }
5
  * Standard: PSR-2
6
  * @link http://www.php-fig.org/psr/psr-2
7
  *
8
+ * @package DupLiteSnapLib
9
  * @copyright (c) 2017, Snapcreek LLC
10
  * @license https://opensource.org/licenses/GPL-3.0 GNU Public License
11
  *
12
  */
13
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
14
 
15
+ if (!class_exists('DupLiteSnapLibURLU', false)) {
 
16
 
17
+ class DupLiteSnapLibURLU
 
 
 
 
 
 
 
 
 
18
  {
 
 
19
 
20
+ /**
21
+ * Append a new query value to the end of a URL
22
+ *
23
+ * @param string $url The URL to append the new value to
24
+ * @param string $key The new key name
25
+ * @param string $value The new key name value
26
+ *
27
+ * @return string Returns the new URL with with the query string name and value
28
+ */
29
+ public static function appendQueryValue($url, $key, $value)
30
+ {
31
+ $separator = (parse_url($url, PHP_URL_QUERY) == NULL) ? '?' : '&';
32
+ $modified_url = $url."$separator$key=$value";
33
 
34
+ return $modified_url;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  }
 
 
 
36
 
37
+ /**
38
+ * Fetches current URL via php
39
+ *
40
+ * @param bool $queryString If true the query string will also be returned.
41
+ *
42
+ * @returns The current page url
43
+ */
44
+ public static function getCurrentUrl($queryString = true)
45
+ {
46
+ $protocol = 'http';
47
+ if ($_SERVER['SERVER_PORT'] == 443 || (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')) {
48
+ $protocol .= 's';
49
+ $protocolPort = $_SERVER['SERVER_PORT'];
50
+ } else {
51
+ $protocolPort = 80;
52
+ }
53
+ $host = $_SERVER['HTTP_HOST'];
54
+ $port = $_SERVER['SERVER_PORT'];
55
+ $request = $_SERVER['PHP_SELF'];
56
+
57
+ $query = ($queryString === TRUE) ? $_SERVER['QUERY_STRING'] : "";
58
+ $url = $protocol.'://'.$host.($port == $protocolPort ? '' : ':'.$port).$request.(empty($query) ? '' : '?'.$query);
59
+ return $url;
60
+ }
61
  }
62
  }
lib/snaplib/class.snaplib.u.util.php CHANGED
@@ -32,427 +32,452 @@ if (!interface_exists('JsonSerializable')) {
32
  }
33
  }
34
 
35
- class SnapLibUtil
36
- {
37
 
38
- public static function getArrayValue(&$array, $key, $required = true, $default = null)
39
  {
40
- if (array_key_exists($key, $array)) {
41
- return $array[$key];
42
- } else {
43
- if ($required) {
44
- throw new Exception("Key {$key} not present in array");
45
  } else {
46
- return $default;
 
 
 
 
47
  }
48
  }
49
- }
50
 
51
- public static function getCallingFunctionName()
52
- {
53
- $callers = debug_backtrace();
54
- $functionName = $callers[2]['function'];
55
- $className = isset($callers[2]['class']) ? $callers[2]['class'] : '';
56
 
57
- return "{$className}::{$functionName}";
58
- }
59
-
60
- public static function getWorkPercent($startingPercent, $endingPercent, $totalTaskCount, $currentTaskCount)
61
- {
62
- if ($totalTaskCount > 0) {
63
- $percent = floor($startingPercent + (($endingPercent - $startingPercent) * ($currentTaskCount / (float) $totalTaskCount)));
64
- } else {
65
- $percent = 0;
66
  }
67
 
68
- return $percent;
69
- }
70
-
71
- public static function make_hash()
72
- {
73
- // IMPORTANT! Be VERY careful in changing this format - the FTP delete logic requires 3 segments with the last segment to be the date in YmdHis format.
74
- try {
75
- if (function_exists('random_bytes') && self::PHP53()) {
76
- return bin2hex(random_bytes(8)).mt_rand(1000, 9999).'_'.date("YmdHis");
77
  } else {
78
- return strtolower(md5(uniqid(rand(), true))).'_'.date("YmdHis");
79
  }
80
- } catch (Exception $exc) {
81
- return strtolower(md5(uniqid(rand(), true))).'_'.date("YmdHis");
82
  }
83
- }
84
 
85
- public static function PHP53()
86
- {
87
- return version_compare(PHP_VERSION, '5.3.2', '>=');
88
- }
 
 
 
 
 
 
 
 
 
89
 
90
- /**
91
- * Groups an array into arrays by a given key, or set of keys, shared between all array members.
92
- *
93
- * Based on {@author Jake Zatecky}'s {@link https://github.com/jakezatecky/array_group_by array_group_by()} function.
94
- * This variant allows $key to be closures.
95
- *
96
- * @param array $array The array to have grouping performed on.
97
- * @param mixed $key,... The key to group or split by. Can be a _string_, an _integer_, a _float_, or a _callable_.
98
- * - If the key is a callback, it must return a valid key from the array.
99
- * - If the key is _NULL_, the iterated element is skipped.
100
- * - string|int callback ( mixed $item )
101
- *
102
- * @return array|null Returns a multidimensional array or `null` if `$key` is invalid.
103
- */
104
- public static function arrayGroupBy(array $array, $key)
105
- {
106
- if (!is_string($key) && !is_int($key) && !is_float($key) && !is_callable($key)) {
107
- trigger_error('array_group_by(): The key should be a string, an integer, or a callback', E_USER_ERROR);
108
- return null;
109
  }
110
- $func = (!is_string($key) && is_callable($key) ? $key : null);
111
- $_key = $key;
112
- // Load the new array, splitting by the target key
113
- $grouped = array();
114
- foreach ($array as $value) {
115
- $key = null;
116
- if (is_callable($func)) {
117
- $key = call_user_func($func, $value);
118
- } elseif (is_object($value) && isset($value->{$_key})) {
119
- $key = $value->{$_key};
120
- } elseif (isset($value[$_key])) {
121
- $key = $value[$_key];
 
 
 
 
 
 
 
 
122
  }
123
- if ($key === null) {
124
- continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  }
126
- $grouped[$key][] = $value;
127
- }
128
- // Recursively build a nested grouping if more parameters are supplied
129
- // Each grouped array value is grouped according to the next sequential key
130
- if (func_num_args() > 2) {
131
- $args = func_get_args();
132
- foreach ($grouped as $key => $value) {
133
- $params = array_merge(array($value), array_slice($args, 2, func_num_args()));
134
- $grouped[$key] = call_user_func_array('SnapLibUtil::arrayGroupBy', $params);
135
  }
 
136
  }
137
- return $grouped;
138
- }
139
 
140
- /**
141
- * Converts human readable types (10GB) to bytes
142
- *
143
- * @param string $from A human readable byte size such as 100MB
144
- *
145
- * @return int Returns and integer of the byte size
146
- */
147
- public static function convertToBytes($from)
148
- {
149
- if (is_numeric($from)) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  return $from;
151
  }
152
 
153
- $number = substr($from, 0, -2);
154
- switch (strtoupper(substr($from, -2))) {
155
- case "KB": return $number * 1024;
156
- case "MB": return $number * pow(1024, 2);
157
- case "GB": return $number * pow(1024, 3);
158
- case "TB": return $number * pow(1024, 4);
159
- case "PB": return $number * pow(1024, 5);
 
 
 
160
  }
161
 
162
- $number = substr($from, 0, -1);
163
- switch (strtoupper(substr($from, -1))) {
164
- case "K": return $number * 1024;
165
- case "M": return $number * pow(1024, 2);
166
- case "G": return $number * pow(1024, 3);
167
- case "T": return $number * pow(1024, 4);
168
- case "P": return $number * pow(1024, 5);
169
- }
170
- return $from;
171
- }
 
 
 
 
 
 
 
172
 
173
- /**
174
- * Sanitize input for XSS code
175
- *
176
- * @param string $val The value to sanitize
177
- *
178
- * @return string Returns the input value cleaned up.
179
- */
180
- public static function sanitize($input)
181
- {
182
- return filter_var($input, FILTER_SANITIZE_STRING);
183
- }
184
 
185
- /**
186
- * Determines whether a PHP ini value is changeable at runtime.
187
- *
188
- * @since 4.6.0
189
- *
190
- * @staticvar array $ini_all
191
- *
192
- * @link https://secure.php.net/manual/en/function.ini-get-all.php
193
- *
194
- * @param string $setting The name of the ini setting to check.
195
- * @return bool True if the value is changeable at runtime. False otherwise.
196
- */
197
- public static function wp_is_ini_value_changeable($setting)
198
- {
199
- if (function_exists('wp_is_ini_value_changeable')) {
200
- return wp_is_ini_value_changeable($setting);
201
- }
202
 
203
- static $ini_all;
 
 
 
204
 
205
- if (!isset($ini_all)) {
206
- $ini_all = false;
207
- // Sometimes `ini_get_all()` is disabled via the `disable_functions` option for "security purposes".
208
- if (function_exists('ini_get_all')) {
209
- $ini_all = ini_get_all();
210
  }
211
- }
212
 
213
- // Bit operator to workaround https://bugs.php.net/bug.php?id=44936 which changes access level to 63 in PHP 5.2.6 - 5.2.17.
214
- if (isset($ini_all[$setting]['access']) && ( INI_ALL === ( $ini_all[$setting]['access'] & 7 ) || INI_USER === ( $ini_all[$setting]['access'] & 7 ) )) {
215
- return true;
216
  }
217
 
218
- // If we were unable to retrieve the details, fail gracefully to assume it's changeable.
219
- if (!is_array($ini_all)) {
220
- return true;
221
- }
 
 
 
 
 
 
 
 
 
 
 
 
222
 
223
- return false;
224
- }
 
 
 
 
 
 
 
 
 
 
225
 
226
- /**
227
- * Encode a variable into JSON, with some sanity checks.
228
- *
229
- * @since 4.1.0
230
- *
231
- * @param mixed $data Variable (usually an array or object) to encode as JSON.
232
- * @param int $options Optional. Options to be passed to json_encode(). Default 0.
233
- * @param int $depth Optional. Maximum depth to walk through $data. Must be
234
- * greater than 0. Default 512.
235
- * @return string|false The JSON encoded string, or false if it cannot be encoded.
236
- */
237
- public static function wp_json_encode($data, $options = 0, $depth = 512)
238
- {
239
- /*
240
- * json_encode() has had extra params added over the years.
241
- * $options was added in 5.3, and $depth in 5.5.
242
- * We need to make sure we call it with the correct arguments.
243
- */
244
- if (version_compare(PHP_VERSION, '5.5', '>=')) {
245
- $args = array($data, $options, $depth);
246
- } elseif (version_compare(PHP_VERSION, '5.3', '>=')) {
247
- $args = array($data, $options);
248
- } else {
249
- $args = array($data);
250
- }
251
 
252
- // Prepare the data for JSON serialization.
253
- $args[0] = self::_wp_json_prepare_data($data);
254
 
255
- $json = @call_user_func_array('json_encode', $args);
 
 
 
 
 
256
 
257
- // If json_encode() was successful, no need to do more sanity checking.
258
- // ... unless we're in an old version of PHP, and json_encode() returned
259
- // a string containing 'null'. Then we need to do more sanity checking.
260
- if (false !== $json && ( version_compare(PHP_VERSION, '5.5', '>=') || false === strpos($json, 'null') )) {
261
- return $json;
262
- }
263
 
264
- try {
265
- $args[0] = self::_wp_json_sanity_check($data, $depth);
266
- } catch (Exception $e) {
267
- return false;
268
  }
269
 
270
- return call_user_func_array('json_encode', $args);
271
- }
272
-
273
- /**
274
- * Prepares response data to be serialized to JSON.
275
- *
276
- * This supports the JsonSerializable interface for PHP 5.2-5.3 as well.
277
- *
278
- * @ignore
279
- * @since 4.4.0
280
- * @access private
281
- *
282
- * @param mixed $data Native representation.
283
- * @return bool|int|float|null|string|array Data ready for `json_encode()`.
284
- */
285
- private static function _wp_json_prepare_data($data)
286
- {
287
- if (!defined('SNAP_WP_JSON_SERIALIZE_COMPATIBLE') || SNAP_WP_JSON_SERIALIZE_COMPATIBLE === false || !defined('WP_JSON_SERIALIZE_COMPATIBLE') || WP_JSON_SERIALIZE_COMPATIBLE === false) {
288
- return $data;
289
  }
290
 
291
- switch (gettype($data)) {
292
- case 'boolean':
293
- case 'integer':
294
- case 'double':
295
- case 'string':
296
- case 'NULL':
297
- // These values can be passed through.
 
 
 
 
 
 
 
 
298
  return $data;
 
299
 
300
- case 'array':
301
- // Arrays must be mapped in case they also return objects.
302
- return array_map('self::_wp_json_prepare_data', $data);
303
-
304
- case 'object':
305
- // If this is an incomplete object (__PHP_Incomplete_Class), bail.
306
- if (!is_object($data)) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  return null;
308
- }
309
-
310
- if ($data instanceof JsonSerializable) {
311
- $data = $data->jsonSerialize();
312
- } else {
313
- $data = get_object_vars($data);
314
- }
315
-
316
- // Now, pass the array (or whatever was returned from jsonSerialize through).
317
- return self::_wp_json_prepare_data($data);
318
-
319
- default:
320
- return null;
321
  }
322
- }
323
 
324
- /**
325
- * Perform sanity checks on data that shall be encoded to JSON.
326
- *
327
- * @ignore
328
- * @since 4.1.0
329
- * @access private
330
- *
331
- * @see wp_json_encode()
332
- *
333
- * @param mixed $data Variable (usually an array or object) to encode as JSON.
334
- * @param int $depth Maximum depth to walk through $data. Must be greater than 0.
335
- * @return mixed The sanitized data that shall be encoded to JSON.
336
- */
337
- private static function _wp_json_sanity_check($data, $depth)
338
- {
339
- if ($depth < 0) {
340
- throw new Exception('Reached depth limit');
341
- }
342
 
343
- if (is_array($data)) {
344
- $output = array();
345
- foreach ($data as $id => $el) {
346
- // Don't forget to sanitize the ID!
347
- if (is_string($id)) {
348
- $clean_id = self::_wp_json_convert_string($id);
349
- } else {
350
- $clean_id = $id;
 
 
 
 
 
 
 
 
 
 
351
  }
352
-
353
- // Check the element type, so that we're only recursing if we really have to.
354
- if (is_array($el) || is_object($el)) {
355
- $output[$clean_id] = self::_wp_json_sanity_check($el, $depth - 1);
356
- } elseif (is_string($el)) {
357
- $output[$clean_id] = self::_wp_json_convert_string($el);
358
- } else {
359
- $output[$clean_id] = $el;
 
 
 
 
 
 
 
 
360
  }
 
 
 
 
361
  }
362
- } elseif (is_object($data)) {
363
- $output = new stdClass;
364
- foreach ($data as $id => $el) {
365
- if (is_string($id)) {
366
- $clean_id = self::_wp_json_convert_string($id);
367
- } else {
368
- $clean_id = $id;
369
- }
370
 
371
- if (is_array($el) || is_object($el)) {
372
- $output->$clean_id = self::_wp_json_sanity_check($el, $depth - 1);
373
- } elseif (is_string($el)) {
374
- $output->$clean_id = self::_wp_json_convert_string($el);
375
- } else {
376
- $output->$clean_id = $el;
377
- }
378
- }
379
- } elseif (is_string($data)) {
380
- return self::_wp_json_convert_string($data);
381
- } else {
382
- return $data;
383
  }
384
 
385
- return $output;
386
- }
387
-
388
- private static function _wp_json_convert_string($string)
389
- {
390
- static $use_mb = null;
391
- if (is_null($use_mb)) {
392
- $use_mb = function_exists('mb_convert_encoding');
393
- }
394
 
395
- if ($use_mb) {
396
- $encoding = mb_detect_encoding($string, mb_detect_order(), true);
397
- if ($encoding) {
398
- return mb_convert_encoding($string, 'UTF-8', $encoding);
 
 
 
399
  } else {
400
- return mb_convert_encoding($string, 'UTF-8', 'UTF-8');
401
  }
402
- } else {
403
- return self::wp_check_invalid_utf8($string, true);
404
  }
405
- }
406
 
407
- /**
408
- * Checks for invalid UTF8 in a string.
409
- *
410
- * @since 2.8.0
411
- *
412
- * @staticvar bool $is_utf8
413
- * @staticvar bool $utf8_pcre
414
- *
415
- * @param string $string The text which is to be checked.
416
- * @param bool $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false.
417
- * @return string The checked text.
418
- */
419
- public static function wp_check_invalid_utf8($string, $strip = false)
420
- {
421
- $string = (string) $string;
422
 
423
- if (0 === strlen($string)) {
424
- return '';
425
- }
426
 
427
- // Store the site charset as a static to avoid multiple calls to get_option()
428
- static $is_utf8 = null;
429
- if (!isset($is_utf8)) {
430
- $is_utf8 = in_array(get_option('blog_charset'), array('utf8', 'utf-8', 'UTF8', 'UTF-8'));
431
- }
432
- if (!$is_utf8) {
433
- return $string;
434
- }
435
 
436
- // Check for support for utf8 in the installed PCRE library once and store the result in a static
437
- static $utf8_pcre = null;
438
- if (!isset($utf8_pcre)) {
439
- $utf8_pcre = @preg_match('/^./u', 'a');
440
- }
441
- // We can't demand utf8 in the PCRE installation, so just return the string in those cases
442
- if (!$utf8_pcre) {
443
- return $string;
444
- }
445
 
446
- // preg_match fails when it encounters invalid UTF8 in $string
447
- if (1 === @preg_match('/^./us', $string)) {
448
- return $string;
449
- }
450
 
451
- // Attempt to strip the bad chars if requested (not recommended)
452
- if ($strip && function_exists('iconv')) {
453
- return iconv('utf-8', 'utf-8', $string);
454
- }
455
 
456
- return '';
 
457
  }
458
  }
32
  }
33
  }
34
 
35
+ if (!class_exists('DupLiteSnapLibUtil', false)) {
 
36
 
37
+ class DupLiteSnapLibUtil
38
  {
39
+
40
+ public static function getArrayValue(&$array, $key, $required = true, $default = null)
41
+ {
42
+ if (array_key_exists($key, $array)) {
43
+ return $array[$key];
44
  } else {
45
+ if ($required) {
46
+ throw new Exception("Key {$key} not present in array");
47
+ } else {
48
+ return $default;
49
+ }
50
  }
51
  }
 
52
 
53
+ public static function getCallingFunctionName()
54
+ {
55
+ $callers = debug_backtrace();
56
+ $functionName = $callers[2]['function'];
57
+ $className = isset($callers[2]['class']) ? $callers[2]['class'] : '';
58
 
59
+ return "{$className}::{$functionName}";
 
 
 
 
 
 
 
 
60
  }
61
 
62
+ public static function getWorkPercent($startingPercent, $endingPercent, $totalTaskCount, $currentTaskCount)
63
+ {
64
+ if ($totalTaskCount > 0) {
65
+ $percent = floor($startingPercent + (($endingPercent - $startingPercent) * ($currentTaskCount / (float) $totalTaskCount)));
 
 
 
 
 
66
  } else {
67
+ $percent = 0;
68
  }
69
+
70
+ return $percent;
71
  }
 
72
 
73
+ public static function make_hash()
74
+ {
75
+ // IMPORTANT! Be VERY careful in changing this format - the FTP delete logic requires 3 segments with the last segment to be the date in YmdHis format.
76
+ try {
77
+ if (function_exists('random_bytes') && self::PHP53()) {
78
+ return bin2hex(random_bytes(8)).mt_rand(1000, 9999).'_'.date("YmdHis");
79
+ } else {
80
+ return strtolower(md5(uniqid(rand(), true))).'_'.date("YmdHis");
81
+ }
82
+ } catch (Exception $exc) {
83
+ return strtolower(md5(uniqid(rand(), true))).'_'.date("YmdHis");
84
+ }
85
+ }
86
 
87
+ public static function PHP53()
88
+ {
89
+ return version_compare(PHP_VERSION, '5.3.2', '>=');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  }
91
+
92
+ /**
93
+ * Groups an array into arrays by a given key, or set of keys, shared between all array members.
94
+ *
95
+ * Based on {@author Jake Zatecky}'s {@link https://github.com/jakezatecky/array_group_by array_group_by()} function.
96
+ * This variant allows $key to be closures.
97
+ *
98
+ * @param array $array The array to have grouping performed on.
99
+ * @param mixed $key,... The key to group or split by. Can be a _string_, an _integer_, a _float_, or a _callable_.
100
+ * - If the key is a callback, it must return a valid key from the array.
101
+ * - If the key is _NULL_, the iterated element is skipped.
102
+ * - string|int callback ( mixed $item )
103
+ *
104
+ * @return array|null Returns a multidimensional array or `null` if `$key` is invalid.
105
+ */
106
+ public static function arrayGroupBy(array $array, $key)
107
+ {
108
+ if (!is_string($key) && !is_int($key) && !is_float($key) && !is_callable($key)) {
109
+ trigger_error('array_group_by(): The key should be a string, an integer, or a callback', E_USER_ERROR);
110
+ return null;
111
  }
112
+ $func = (!is_string($key) && is_callable($key) ? $key : null);
113
+ $_key = $key;
114
+ // Load the new array, splitting by the target key
115
+ $grouped = array();
116
+ foreach ($array as $value) {
117
+ $key = null;
118
+ if (is_callable($func)) {
119
+ $key = call_user_func($func, $value);
120
+ } elseif (is_object($value) && isset($value->{$_key})) {
121
+ $key = $value->{$_key};
122
+ } elseif (isset($value[$_key])) {
123
+ $key = $value[$_key];
124
+ }
125
+ if ($key === null) {
126
+ continue;
127
+ }
128
+ $grouped[$key][] = $value;
129
  }
130
+ // Recursively build a nested grouping if more parameters are supplied
131
+ // Each grouped array value is grouped according to the next sequential key
132
+ if (func_num_args() > 2) {
133
+ $args = func_get_args();
134
+ foreach ($grouped as $key => $value) {
135
+ $params = array_merge(array($value), array_slice($args, 2, func_num_args()));
136
+ $grouped[$key] = call_user_func_array('DupLiteSnapLibUtil::arrayGroupBy', $params);
137
+ }
 
138
  }
139
+ return $grouped;
140
  }
 
 
141
 
142
+ /**
143
+ * Converts human readable types (10GB) to bytes
144
+ *
145
+ * @param string $from A human readable byte size such as 100MB
146
+ *
147
+ * @return int Returns and integer of the byte size
148
+ */
149
+ public static function convertToBytes($from)
150
+ {
151
+ if (is_numeric($from)) {
152
+ return $from;
153
+ }
154
+
155
+ $number = substr($from, 0, -2);
156
+ switch (strtoupper(substr($from, -2))) {
157
+ case "KB": return $number * 1024;
158
+ case "MB": return $number * pow(1024, 2);
159
+ case "GB": return $number * pow(1024, 3);
160
+ case "TB": return $number * pow(1024, 4);
161
+ case "PB": return $number * pow(1024, 5);
162
+ }
163
+
164
+ $number = substr($from, 0, -1);
165
+ switch (strtoupper(substr($from, -1))) {
166
+ case "K": return $number * 1024;
167
+ case "M": return $number * pow(1024, 2);
168
+ case "G": return $number * pow(1024, 3);
169
+ case "T": return $number * pow(1024, 4);
170
+ case "P": return $number * pow(1024, 5);
171
+ }
172
  return $from;
173
  }
174
 
175
+ /**
176
+ * Sanitize input for XSS code
177
+ *
178
+ * @param string $val The value to sanitize
179
+ *
180
+ * @return string Returns the input value cleaned up.
181
+ */
182
+ public static function sanitize($input)
183
+ {
184
+ return filter_var($input, FILTER_SANITIZE_STRING);
185
  }
186
 
187
+ /**
188
+ * Determines whether a PHP ini value is changeable at runtime.
189
+ *
190
+ * @since 4.6.0
191
+ *
192
+ * @staticvar array $ini_all
193
+ *
194
+ * @link https://secure.php.net/manual/en/function.ini-get-all.php
195
+ *
196
+ * @param string $setting The name of the ini setting to check.
197
+ * @return bool True if the value is changeable at runtime. False otherwise.
198
+ */
199
+ public static function wp_is_ini_value_changeable($setting)
200
+ {
201
+ if (function_exists('wp_is_ini_value_changeable')) {
202
+ return wp_is_ini_value_changeable($setting);
203
+ }
204
 
205
+ static $ini_all;
 
 
 
 
 
 
 
 
 
 
206
 
207
+ if (!isset($ini_all)) {
208
+ $ini_all = false;
209
+ // Sometimes `ini_get_all()` is disabled via the `disable_functions` option for "security purposes".
210
+ if (function_exists('ini_get_all')) {
211
+ $ini_all = ini_get_all();
212
+ }
213
+ }
 
 
 
 
 
 
 
 
 
 
214
 
215
+ // Bit operator to workaround https://bugs.php.net/bug.php?id=44936 which changes access level to 63 in PHP 5.2.6 - 5.2.17.
216
+ if (isset($ini_all[$setting]['access']) && ( INI_ALL === ( $ini_all[$setting]['access'] & 7 ) || INI_USER === ( $ini_all[$setting]['access'] & 7 ) )) {
217
+ return true;
218
+ }
219
 
220
+ // If we were unable to retrieve the details, fail gracefully to assume it's changeable.
221
+ if (!is_array($ini_all)) {
222
+ return true;
 
 
223
  }
 
224
 
225
+ return false;
 
 
226
  }
227
 
228
+ /**
229
+ * Encode a variable into JSON, with some sanity checks.
230
+ *
231
+ * @since 4.1.0
232
+ *
233
+ * @param mixed $data Variable (usually an array or object) to encode as JSON.
234
+ * @param int $options Optional. Options to be passed to json_encode(). Default 0.
235
+ * @param int $depth Optional. Maximum depth to walk through $data. Must be
236
+ * greater than 0. Default 512.
237
+ * @return string|false The JSON encoded string, or false if it cannot be encoded.
238
+ */
239
+ public static function wp_json_encode($data, $options = 0, $depth = 512)
240
+ {
241
+ if (function_exists('wp_json_encode')) {
242
+ return wp_json_encode($data, $options, $depth);
243
+ }
244
 
245
+ /*
246
+ * json_encode() has had extra params added over the years.
247
+ * $options was added in 5.3, and $depth in 5.5.
248
+ * We need to make sure we call it with the correct arguments.
249
+ */
250
+ if (version_compare(PHP_VERSION, '5.5', '>=')) {
251
+ $args = array($data, $options, $depth);
252
+ } elseif (version_compare(PHP_VERSION, '5.3', '>=')) {
253
+ $args = array($data, $options);
254
+ } else {
255
+ $args = array($data);
256
+ }
257
 
258
+ // Prepare the data for JSON serialization.
259
+ $args[0] = self::_wp_json_prepare_data($data);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
 
261
+ $json = @call_user_func_array('json_encode', $args);
 
262
 
263
+ // If json_encode() was successful, no need to do more sanity checking.
264
+ // ... unless we're in an old version of PHP, and json_encode() returned
265
+ // a string containing 'null'. Then we need to do more sanity checking.
266
+ if (false !== $json && ( version_compare(PHP_VERSION, '5.5', '>=') || false === strpos($json, 'null') )) {
267
+ return $json;
268
+ }
269
 
270
+ try {
271
+ $args[0] = self::_wp_json_sanity_check($data, $depth);
272
+ } catch (Exception $e) {
273
+ return false;
274
+ }
 
275
 
276
+ return call_user_func_array('json_encode', $args);
 
 
 
277
  }
278
 
279
+ /**
280
+ * wp_json_encode with pretty print if define exists
281
+ *
282
+ * @param mixed $data Variable (usually an array or object) to encode as JSON.
283
+ * @param int $options Optional. Options to be passed to json_encode(). Default 0.
284
+ * @param int $depth Optional. Maximum depth to walk through $data. Must be
285
+ * greater than 0. Default 512.
286
+ * @return string|false The JSON encoded string, or false if it cannot be encoded.
287
+ */
288
+ public static function wp_json_encode_pprint($data, $options = 0, $depth = 512)
289
+ {
290
+ if (defined('JSON_PRETTY_PRINT')) {
291
+ return self::wp_json_encode($data, JSON_PRETTY_PRINT | $options, $depth);
292
+ } else {
293
+ return self::wp_json_encode($data, $options, $depth);
294
+ }
 
 
 
295
  }
296
 
297
+ /**
298
+ * Prepares response data to be serialized to JSON.
299
+ *
300
+ * This supports the JsonSerializable interface for PHP 5.2-5.3 as well.
301
+ *
302
+ * @ignore
303
+ * @since 4.4.0
304
+ * @access private
305
+ *
306
+ * @param mixed $data Native representation.
307
+ * @return bool|int|float|null|string|array Data ready for `json_encode()`.
308
+ */
309
+ private static function _wp_json_prepare_data($data)
310
+ {
311
+ if (!defined('SNAP_WP_JSON_SERIALIZE_COMPATIBLE') || SNAP_WP_JSON_SERIALIZE_COMPATIBLE === false || !defined('WP_JSON_SERIALIZE_COMPATIBLE') || WP_JSON_SERIALIZE_COMPATIBLE === false) {
312
  return $data;
313
+ }
314
 
315
+ switch (gettype($data)) {
316
+ case 'boolean':
317
+ case 'integer':
318
+ case 'double':
319
+ case 'string':
320
+ case 'NULL':
321
+ // These values can be passed through.
322
+ return $data;
323
+
324
+ case 'array':
325
+ // Arrays must be mapped in case they also return objects.
326
+ return array_map('self::_wp_json_prepare_data', $data);
327
+
328
+ case 'object':
329
+ // If this is an incomplete object (__PHP_Incomplete_Class), bail.
330
+ if (!is_object($data)) {
331
+ return null;
332
+ }
333
+
334
+ if ($data instanceof JsonSerializable) {
335
+ $data = $data->jsonSerialize();
336
+ } else {
337
+ $data = get_object_vars($data);
338
+ }
339
+
340
+ // Now, pass the array (or whatever was returned from jsonSerialize through).
341
+ return self::_wp_json_prepare_data($data);
342
+
343
+ default:
344
  return null;
345
+ }
 
 
 
 
 
 
 
 
 
 
 
 
346
  }
 
347
 
348
+ /**
349
+ * Perform sanity checks on data that shall be encoded to JSON.
350
+ *
351
+ * @ignore
352
+ * @since 4.1.0
353
+ * @access private
354
+ *
355
+ * @see wp_json_encode()
356
+ *
357
+ * @param mixed $data Variable (usually an array or object) to encode as JSON.
358
+ * @param int $depth Maximum depth to walk through $data. Must be greater than 0.
359
+ * @return mixed The sanitized data that shall be encoded to JSON.
360
+ */
361
+ private static function _wp_json_sanity_check($data, $depth)
362
+ {
363
+ if ($depth < 0) {
364
+ throw new Exception('Reached depth limit');
365
+ }
366
 
367
+ if (is_array($data)) {
368
+ $output = array();
369
+ foreach ($data as $id => $el) {
370
+ // Don't forget to sanitize the ID!
371
+ if (is_string($id)) {
372
+ $clean_id = self::_wp_json_convert_string($id);
373
+ } else {
374
+ $clean_id = $id;
375
+ }
376
+
377
+ // Check the element type, so that we're only recursing if we really have to.
378
+ if (is_array($el) || is_object($el)) {
379
+ $output[$clean_id] = self::_wp_json_sanity_check($el, $depth - 1);
380
+ } elseif (is_string($el)) {
381
+ $output[$clean_id] = self::_wp_json_convert_string($el);
382
+ } else {
383
+ $output[$clean_id] = $el;
384
+ }
385
  }
386
+ } elseif (is_object($data)) {
387
+ $output = new stdClass;
388
+ foreach ($data as $id => $el) {
389
+ if (is_string($id)) {
390
+ $clean_id = self::_wp_json_convert_string($id);
391
+ } else {
392
+ $clean_id = $id;
393
+ }
394
+
395
+ if (is_array($el) || is_object($el)) {
396
+ $output->$clean_id = self::_wp_json_sanity_check($el, $depth - 1);
397
+ } elseif (is_string($el)) {
398
+ $output->$clean_id = self::_wp_json_convert_string($el);
399
+ } else {
400
+ $output->$clean_id = $el;
401
+ }
402
  }
403
+ } elseif (is_string($data)) {
404
+ return self::_wp_json_convert_string($data);
405
+ } else {
406
+ return $data;
407
  }
 
 
 
 
 
 
 
 
408
 
409
+ return $output;
 
 
 
 
 
 
 
 
 
 
 
410
  }
411
 
412
+ private static function _wp_json_convert_string($string)
413
+ {
414
+ static $use_mb = null;
415
+ if (is_null($use_mb)) {
416
+ $use_mb = function_exists('mb_convert_encoding');
417
+ }
 
 
 
418
 
419
+ if ($use_mb) {
420
+ $encoding = mb_detect_encoding($string, mb_detect_order(), true);
421
+ if ($encoding) {
422
+ return mb_convert_encoding($string, 'UTF-8', $encoding);
423
+ } else {
424
+ return mb_convert_encoding($string, 'UTF-8', 'UTF-8');
425
+ }
426
  } else {
427
+ return self::wp_check_invalid_utf8($string, true);
428
  }
 
 
429
  }
 
430
 
431
+ /**
432
+ * Checks for invalid UTF8 in a string.
433
+ *
434
+ * @since 2.8.0
435
+ *
436
+ * @staticvar bool $is_utf8
437
+ * @staticvar bool $utf8_pcre
438
+ *
439
+ * @param string $string The text which is to be checked.
440
+ * @param bool $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false.
441
+ * @return string The checked text.
442
+ */
443
+ public static function wp_check_invalid_utf8($string, $strip = false)
444
+ {
445
+ $string = (string) $string;
446
 
447
+ if (0 === strlen($string)) {
448
+ return '';
449
+ }
450
 
451
+ // Store the site charset as a static to avoid multiple calls to get_option()
452
+ static $is_utf8 = null;
453
+ if (!isset($is_utf8)) {
454
+ $is_utf8 = in_array(get_option('blog_charset'), array('utf8', 'utf-8', 'UTF8', 'UTF-8'));
455
+ }
456
+ if (!$is_utf8) {
457
+ return $string;
458
+ }
459
 
460
+ // Check for support for utf8 in the installed PCRE library once and store the result in a static
461
+ static $utf8_pcre = null;
462
+ if (!isset($utf8_pcre)) {
463
+ $utf8_pcre = @preg_match('/^./u', 'a');
464
+ }
465
+ // We can't demand utf8 in the PCRE installation, so just return the string in those cases
466
+ if (!$utf8_pcre) {
467
+ return $string;
468
+ }
469
 
470
+ // preg_match fails when it encounters invalid UTF8 in $string
471
+ if (1 === @preg_match('/^./us', $string)) {
472
+ return $string;
473
+ }
474
 
475
+ // Attempt to strip the bad chars if requested (not recommended)
476
+ if ($strip && function_exists('iconv')) {
477
+ return iconv('utf-8', 'utf-8', $string);
478
+ }
479
 
480
+ return '';
481
+ }
482
  }
483
  }
lib/snaplib/class.snaplib.u.wp.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
- defined('ABSPATH') || defined('DUPXABSPATH') || exit;
3
  /**
4
  * Wordpress utility functions
5
  *
@@ -14,118 +13,121 @@ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
14
  */
15
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
16
 
17
- /**
18
- * Wordpress utility functions
19
- */
20
- class SnapLibUtilWp
21
- {
22
- const PATH_FULL = 0;
23
- const PATH_RELATIVE = 1;
24
- const PATH_AUTO = 2;
25
-
26
- private static $corePathList = null;
27
- private static $safeAbsPath = null;
28
 
29
  /**
30
- * return safe ABSPATH without last /
31
- * perform safe function only one time
32
- *
33
- * @return string
34
  */
35
- public static function getSafeAbsPath()
36
  {
37
- if (is_null(self::$safeAbsPath)) {
38
- if (defined('ABSPATH')) {
39
- self::$safeAbsPath = rtrim(SnapLibIOU::safePath(ABSPATH), '/');
40
- } else {
41
- self::$safeAbsPath = '';
42
- }
43
- }
44
 
45
- return self::$safeAbsPath;
46
- }
47
 
48
- /**
49
- * check if path is in wordpress core list
50
- *
51
- * @param string $path
52
- * @param int $fullPath // if PATH_AUTO check if is a full path or relative path
53
- * if PATH_FULL remove ABSPATH len without check
54
- * if PATH_RELATIVE consider path a relative path
55
- * @param bool $isSafe // if false call rtrim(SnapLibIOU::safePath( PATH ), '/')
56
- * if true consider path a safe path without check
57
- *
58
- * PATH_FULL and PATH_RELATIVE is better optimized and perform less operations
59
- *
60
- * @return boolean
61
- */
62
- public static function isWpCore($path, $fullPath = self::PATH_AUTO, $isSafe = false)
63
- {
64
- if ($isSafe == false) {
65
- $path = rtrim(SnapLibIOU::safePath($path), '/');
66
  }
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
 
70
- switch ($fullPath) {
71
- case self::PATH_FULL:
72
- $absPath = self::getSafeAbsPath();
73
- if (strlen($path) < strlen($absPath)) {
74
- return false;
75
- }
76
- $relPath = ltrim(substr($path, strlen($absPath)), '/');
77
- break;
78
- case self::PATH_RELATIVE:
79
- $relPath = ltrim($path, '/');
80
- break;
81
- case self::PATH_AUTO:
82
- default:
83
- $absPath = self::getSafeAbsPath();
84
- if (strpos($path, $absPath) === 0) {
85
  $relPath = ltrim(substr($path, strlen($absPath)), '/');
86
- } else {
 
87
  $relPath = ltrim($path, '/');
88
- }
89
- }
 
 
 
 
 
 
 
 
90
 
91
- // if rel path is empty is consider root path so is a core folder.
92
- if (empty($relPath)) {
93
- return true;
94
- }
95
 
96
- $pExploded = explode('/', $relPath);
97
- $corePaths = self::getCorePathsList();
98
 
99
- foreach ($pExploded as $current) {
100
- if (!isset($corePaths[$current])) {
101
- return false;
102
- }
103
 
104
- $corePaths = $corePaths[$current];
 
 
105
  }
106
- return true;
107
- }
108
 
109
- /**
110
- * get core path list from relative abs path
111
- * [
112
- * 'folder' => [
113
- * 's-folder1' => [
114
- * file1 => [],
115
- * file2 => [],
116
- * ],
117
- * 's-folder2' => [],
118
- * file1 => []
119
- * ]
120
- * ]
121
- *
122
- * @return array
123
- */
124
- public static function getCorePathsList()
125
- {
126
- if (is_null(self::$corePathList)) {
127
- require_once(dirname(__FILE__).'/wordpress.core.files.php');
 
 
128
  }
129
- return self::$corePathList;
130
  }
131
  }
1
  <?php
 
2
  /**
3
  * Wordpress utility functions
4
  *
13
  */
14
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
15
 
16
+ if (!class_exists('DupLiteSnapLibUtilWp', false)) {
 
 
 
 
 
 
 
 
 
 
17
 
18
  /**
19
+ * Wordpress utility functions
 
 
 
20
  */
21
+ class DupLiteSnapLibUtilWp
22
  {
23
+ const PATH_FULL = 0;
24
+ const PATH_RELATIVE = 1;
25
+ const PATH_AUTO = 2;
 
 
 
 
26
 
27
+ private static $corePathList = null;
28
+ private static $safeAbsPath = null;
29
 
30
+ /**
31
+ * return safe ABSPATH without last /
32
+ * perform safe function only one time
33
+ *
34
+ * @return string
35
+ */
36
+ public static function getSafeAbsPath()
37
+ {
38
+ if (is_null(self::$safeAbsPath)) {
39
+ if (defined('ABSPATH')) {
40
+ self::$safeAbsPath = rtrim(DupLiteSnapLibIOU::safePath(ABSPATH), '/');
41
+ } else {
42
+ self::$safeAbsPath = '';
43
+ }
44
+ }
45
+
46
+ return self::$safeAbsPath;
 
47
  }
48
 
49
+ /**
50
+ * check if path is in wordpress core list
51
+ *
52
+ * @param string $path
53
+ * @param int $fullPath // if PATH_AUTO check if is a full path or relative path
54
+ * if PATH_FULL remove ABSPATH len without check
55
+ * if PATH_RELATIVE consider path a relative path
56
+ * @param bool $isSafe // if false call rtrim(DupLiteSnapLibIOU::safePath( PATH ), '/')
57
+ * if true consider path a safe path without check
58
+ *
59
+ * PATH_FULL and PATH_RELATIVE is better optimized and perform less operations
60
+ *
61
+ * @return boolean
62
+ */
63
+ public static function isWpCore($path, $fullPath = self::PATH_AUTO, $isSafe = false)
64
+ {
65
+ if ($isSafe == false) {
66
+ $path = rtrim(DupLiteSnapLibIOU::safePath($path), '/');
67
+ }
68
 
69
 
70
+
71
+ switch ($fullPath) {
72
+ case self::PATH_FULL:
73
+ $absPath = self::getSafeAbsPath();
74
+ if (strlen($path) < strlen($absPath)) {
75
+ return false;
76
+ }
 
 
 
 
 
 
 
 
77
  $relPath = ltrim(substr($path, strlen($absPath)), '/');
78
+ break;
79
+ case self::PATH_RELATIVE:
80
  $relPath = ltrim($path, '/');
81
+ break;
82
+ case self::PATH_AUTO:
83
+ default:
84
+ $absPath = self::getSafeAbsPath();
85
+ if (strpos($path, $absPath) === 0) {
86
+ $relPath = ltrim(substr($path, strlen($absPath)), '/');
87
+ } else {
88
+ $relPath = ltrim($path, '/');
89
+ }
90
+ }
91
 
92
+ // if rel path is empty is consider root path so is a core folder.
93
+ if (empty($relPath)) {
94
+ return true;
95
+ }
96
 
97
+ $pExploded = explode('/', $relPath);
98
+ $corePaths = self::getCorePathsList();
99
 
100
+ foreach ($pExploded as $current) {
101
+ if (!isset($corePaths[$current])) {
102
+ return false;
103
+ }
104
 
105
+ $corePaths = $corePaths[$current];
106
+ }
107
+ return true;
108
  }
 
 
109
 
110
+ /**
111
+ * get core path list from relative abs path
112
+ * [
113
+ * 'folder' => [
114
+ * 's-folder1' => [
115
+ * file1 => [],
116
+ * file2 => [],
117
+ * ],
118
+ * 's-folder2' => [],
119
+ * file1 => []
120
+ * ]
121
+ * ]
122
+ *
123
+ * @return array
124
+ */
125
+ public static function getCorePathsList()
126
+ {
127
+ if (is_null(self::$corePathList)) {
128
+ require_once(dirname(__FILE__).'/wordpress.core.files.php');
129
+ }
130
+ return self::$corePathList;
131
  }
 
132
  }
133
  }
lib/snaplib/snaplib.all.php CHANGED
@@ -13,16 +13,20 @@
13
  */
14
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
15
 
16
- $dir = dirname(__FILE__);
 
17
 
18
- require_once($dir.'/class.snaplib.exceptions.php');
19
- require_once($dir.'/class.snaplib.logger.php');
20
- require_once($dir.'/class.snaplib.u.util.php');
21
- require_once($dir.'/class.snaplib.u.io.php');
22
- require_once($dir.'/class.snaplib.u.net.php');
23
- require_once($dir.'/class.snaplib.u.os.php');
24
- require_once($dir.'/class.snaplib.u.stream.php');
25
- require_once($dir.'/class.snaplib.u.string.php');
26
- require_once($dir.'/class.snaplib.u.ui.php');
27
- require_once($dir.'/class.snaplib.u.url.php');
28
- require_once($dir.'/class.snaplib.u.wp.php');
 
 
 
13
  */
14
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
15
 
16
+ if (!defined('DUPLITE_SNAPLIB_INCLUDE_ALL')) {
17
+ define('DUPLITE_SNAPLIB_INCLUDE_ALL', true);
18
 
19
+ $dir = dirname(__FILE__);
20
+
21
+ require_once($dir.'/class.snaplib.exceptions.php');
22
+ require_once($dir.'/class.snaplib.logger.php');
23
+ require_once($dir.'/class.snaplib.u.util.php');
24
+ require_once($dir.'/class.snaplib.u.io.php');
25
+ require_once($dir.'/class.snaplib.u.net.php');
26
+ require_once($dir.'/class.snaplib.u.os.php');
27
+ require_once($dir.'/class.snaplib.u.stream.php');
28
+ require_once($dir.'/class.snaplib.u.string.php');
29
+ require_once($dir.'/class.snaplib.u.ui.php');
30
+ require_once($dir.'/class.snaplib.u.url.php');
31
+ require_once($dir.'/class.snaplib.u.wp.php');
32
+ }
lib/snaplib/wordpress.core.files.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
- defined('ABSPATH') || defined('DUPXABSPATH') || exit;
3
  /**
4
  * >>>>>> THIS FILE IS AUTOGENERATED DON'T MODIFY THIS DIRECTLY <<<<<
5
  * >>>>>> USE THE GENERATOR SCRIPT <<<<<
1
  <?php
 
2
  /**
3
  * >>>>>> THIS FILE IS AUTOGENERATED DON'T MODIFY THIS DIRECTLY <<<<<
4
  * >>>>>> USE THE GENERATOR SCRIPT <<<<<
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: corylamleorg, bobriley
3
  Tags: migration, backup, restore, move, migrate, duplicate, transfer, clone, automate, copy site
4
  Requires at least: 4.0
5
- Tested up to: 5.1
6
  Requires PHP: 5.2.17
7
- Stable tag: 1.3.12
8
  License: GPLv2
9
 
10
  WordPress migration and backups are much easier with Duplicator! Clone, backup, move and transfer an entire site from one location to another.
2
  Contributors: corylamleorg, bobriley
3
  Tags: migration, backup, restore, move, migrate, duplicate, transfer, clone, automate, copy site
4
  Requires at least: 4.0
5
+ Tested up to: 5.2
6
  Requires PHP: 5.2.17
7
+ Stable tag: 1.3.14
8
  License: GPLv2
9
 
10
  WordPress migration and backups are much easier with Duplicator! Clone, backup, move and transfer an entire site from one location to another.
uninstall.php CHANGED
@@ -52,6 +52,10 @@ if (DUP_Settings::Get('uninstall_files')) {
52
  if (strstr($file, '_scan.json'))
53
  @unlink("{$file}");
54
  }
 
 
 
 
55
  foreach (glob("{$ssdir}/*.log") as $file) {
56
  if (strstr($file, '.log'))
57
  @unlink("{$file}");
52
  if (strstr($file, '_scan.json'))
53
  @unlink("{$file}");
54
  }
55
+ foreach (glob("{$ssdir}/*_wp-config.txt") as $file) {
56
+ if (strstr($file, '_wp-config.txt'))
57
+ @unlink("{$file}");
58
+ }
59
  foreach (glob("{$ssdir}/*.log") as $file) {
60
  if (strstr($file, '.log'))
61
  @unlink("{$file}");
views/packages/details/detail.php CHANGED
@@ -202,7 +202,7 @@ STORAGE -->
202
  <img src="<?php echo esc_url(DUPLICATOR_PLUGIN_URL."assets/img/ftp-64.png"); ?>" />
203
  <?php echo sprintf(esc_html__('%1$s, %2$s, %3$s, %4$s, %5$s and other storage options available in', 'duplicator'), 'Amazon', 'Dropbox', 'Google Drive', 'OneDrive', 'FTP/SFTP'); ?>
204
  <a href="https://snapcreek.com/duplicator/?utm_source=duplicator_free&utm_medium=wordpress_plugin&utm_content=free_storage_detail&utm_campaign=duplicator_pro" target="_blank"><?php esc_html_e('Duplicator Pro', 'duplicator');?></a>
205
- <i class="fa fa-lightbulb-o"
206
  data-tooltip-title="<?php esc_attr_e('Additional Storage:', 'duplicator'); ?>"
207
  data-tooltip="<?php esc_attr_e('Duplicator Pro allows you to create a package and then store it at a custom location on this server or to a cloud '
208
  . 'based location such as Google Drive, Amazon, Dropbox or FTP.', 'duplicator'); ?>">
202
  <img src="<?php echo esc_url(DUPLICATOR_PLUGIN_URL."assets/img/ftp-64.png"); ?>" />
203
  <?php echo sprintf(esc_html__('%1$s, %2$s, %3$s, %4$s, %5$s and other storage options available in', 'duplicator'), 'Amazon', 'Dropbox', 'Google Drive', 'OneDrive', 'FTP/SFTP'); ?>
204
  <a href="https://snapcreek.com/duplicator/?utm_source=duplicator_free&utm_medium=wordpress_plugin&utm_content=free_storage_detail&utm_campaign=duplicator_pro" target="_blank"><?php esc_html_e('Duplicator Pro', 'duplicator');?></a>
205
+ <i class="far fa-lightbulb"
206
  data-tooltip-title="<?php esc_attr_e('Additional Storage:', 'duplicator'); ?>"
207
  data-tooltip="<?php esc_attr_e('Duplicator Pro allows you to create a package and then store it at a custom location on this server or to a cloud '
208
  . 'based location such as Google Drive, Amazon, Dropbox or FTP.', 'duplicator'); ?>">
views/packages/main/packages.php CHANGED
@@ -1,15 +1,17 @@
1
  <?php
2
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
3
- /* @var $Package DUP_Package */
4
 
5
- $packages = DUP_Package::get_all();
6
- $totalElements = count($packages);
7
- $statusCount = 0; // total packages completed
8
- $active_package_present = DUP_Package::is_active_package_present();
9
 
10
- $package_debug = DUP_Settings::Get('package_debug');
11
- $ui_create_frmt = is_numeric(DUP_Settings::Get('package_ui_created')) ? DUP_Settings::Get('package_ui_created') : 1;
12
- $package_running = false;
 
 
 
 
13
  ?>
14
 
15
  <style>
@@ -156,130 +158,86 @@ TOOL-BAR -->
156
  </td>
157
  </tr>
158
  <?php
159
- $rowCount = 0;
160
  //$totalSize = 0;
161
- $txt_dbonly = __('Database Only', 'duplicator');
162
- $txt_mode_zip = __('Archive created as zip file', 'duplicator');
163
- $txt_mode_daf = __('Archive created as daf file', 'duplicator');
164
  //$rows = $qryResult;
165
 
166
-
167
- foreach ($packages as $Package) {
168
- $is_running_package = $Package->isRunning();
169
-
170
- // Never display incomplete packages and purge those that are no longer active
171
- if(!$is_running_package && $Package->Status >= 0 && $Package->Status < 100) {
172
- $Package->delete();
173
-
174
- if ($rowCount <= 1 && $totalElements == 1) {
175
- $package_running = true;
176
- }
177
-
178
- continue;
179
- }
180
-
181
-
182
- $pack_dbonly = false;
183
-
184
- if (is_object($Package)) {
185
- $pack_name = $Package->Name;
186
- $pack_archive_size = $Package->getArchiveSize();
187
- $pack_perc = $Package->Status;
188
- $pack_storeurl = $Package->StoreURL;
189
- $pack_namehash = $Package->NameHash;
190
- $pack_dbonly = $Package->Archive->ExportOnlyDB;
191
- $pack_build_mode = ($Package->Archive->Format === 'ZIP') ? true : false;
192
- } else {
193
- $pack_archive_size = 0;
194
- $pack_perc = 0;
195
- $pack_storeurl = 'unknown';
196
- $pack_name = 'unknown';
197
- $pack_namehash = 'unknown';
198
- $pack_build_mode = false;
199
- }
200
-
201
- //Links
202
- $uniqueid = $Package->Name.'_'.$Package->Hash;
203
-
204
-
205
- $packagepath = $pack_storeurl . $Package->Archive->File;
206
-
207
- $installerpath = $pack_storeurl . "{$uniqueid}_installer.php";
208
- $installfilelink = "{$installerpath}?get=1&file={$uniqueid}_installer.php";
209
- $css_alt = ($rowCount % 2 != 0) ? '' : 'alternate';
210
- ?>
211
-
212
- <!-- COMPLETE -->
213
-
214
- <?php
215
-
216
- if ($Package->Status >= 100 || $is_running_package) :
217
- $statusCount ++;
218
  ?>
219
- <tr class="dup-pack-info <?php echo esc_attr($css_alt); ?> <?php echo $is_running_package ? 'is-running' : ''; ?>">
220
- <td class="pass"><input name="delete_confirm" type="checkbox" id="<?php echo absint($Package->ID); ?>" /></td>
221
- <td>
222
- <?php
223
- echo DUP_Package::getCreatedDateFormat( $Package->Created , $ui_create_frmt);
224
- echo ($pack_build_mode) ? " <sup title='{$txt_mode_zip}'>zip</sup>" : " <sup title='{$txt_mode_daf}'>daf</sup>";
225
- ?>
226
- </td>
227
- <td class="pack-size"><?php echo DUP_Util::byteSize($pack_archive_size); ?></td>
228
- <td class='pack-name'>
229
- <?php echo ($pack_dbonly) ? "{$pack_name} <sup title='".esc_attr($txt_dbonly)."'>DB</sup>" : esc_html($pack_name); ?><br/>
230
- <span class="building-info" >
231
- <i class="fa fa-cog fa-sm fa-spin"></i> <b>Building Package</b> <span class="perc"><?php echo $pack_perc; ?></span>%
232
- &nbsp; <i class="fas fa-question-circle fa-sm" style="color:#2C8021"
233
- data-tooltip-title="<?php esc_attr_e("Package Build Running", 'duplicator'); ?>"
234
- data-tooltip="<?php esc_attr_e('To stop or reset this package build goto Settings > Advanced > Reset Packages', 'duplicator'); ?>"></i>
235
- </span>
236
- </td>
237
- <td class="get-btns">
238
- <button id="<?php echo esc_attr("{$uniqueid}_installer.php"); ?>" class="button no-select" onclick="Duplicator.Pack.DownloadPackageFile(0, <?php echo absint($Package->ID); ?>); return false;">
239
- <i class="fa fa-bolt fa-sm"></i> <?php esc_html_e("Installer", 'duplicator') ?>
240
- </button>
241
- <button id="<?php echo esc_attr("{$uniqueid}_archive.zip"); ?>" class="button no-select" onclick="Duplicator.Pack.DownloadFile('<?php echo esc_js($Package->Archive->File); ?>', '<?php echo esc_js($packagepath); ?>'); return false;">
242
- <i class="far fa-file-archive"></i> <?php esc_html_e("Archive", 'duplicator') ?>
243
- </button>
244
- <button type="button" class="button no-select" title="<?php esc_attr_e("Package Details", 'duplicator') ?>" onclick="Duplicator.Pack.OpenPackageDetails(<?php echo "{$Package->ID}"; ?>);">
245
- <i class="fa fa-archive fa-sm" ></i>
246
- </button>
247
- </td>
248
- </tr>
249
-
250
- <!-- NOT COMPLETE -->
251
- <?php else : ?>
252
-
253
- <?php
254
- /*$size = 0;
255
- $tmpSearch = glob(DUPLICATOR_SSDIR_PATH_TMP . "/{$pack_namehash}_*");
256
- if (is_array($tmpSearch)) {
257
- $result = array_map('filesize', $tmpSearch);
258
- $size = array_sum($result);
259
- }
260
- $pack_archive_size = $size;*/
261
- $error_url = "?page=duplicator&action=detail&tab=detail&id={$Package->ID}";
262
- ?>
263
- <tr class="dup-pack-info <?php echo esc_attr($css_alt); ?>">
264
- <td class="fail"><input name="delete_confirm" type="checkbox" id="<?php echo absint($Package->ID); ?>" /></td>
265
- <td><?php echo DUP_Package::getCreatedDateFormat($Package->Created, $ui_create_frmt);?></td>
266
- <td class="pack-size"><?php echo DUP_Util::byteSize($pack_archive_size); ?></td>
267
- <td class='pack-name'><?php echo esc_html($pack_name); ?></td>
268
- <td class="get-btns error-msg" colspan="2">
269
- <span>
270
- <i class="fa fa-exclamation-triangle fa-sm"></i>
271
- <a href="<?php echo esc_url($error_url); ?>"><?php esc_html_e("Error Processing", 'duplicator') ?></a>
272
- </span>
273
- <a class="button no-select" title="<?php esc_attr_e("Package Details", 'duplicator') ?>" href="<?php echo esc_url($error_url); ?>">
274
- <i class="fa fa-archive fa-sm"></i>
275
- </a>
276
- </td>
277
- </tr>
278
- <?php endif; ?>
279
- <?php
280
- //$totalSize = $totalSize + $pack_archive_size;
281
- $rowCount++;
282
- }
283
  ?>
284
  <tfoot>
285
  <tr>
@@ -326,8 +284,8 @@ $confirm1->jscallback = 'Duplicator.Pack.Delete()';
326
  $confirm1->initConfirm();
327
 
328
  $alert3 = new DUP_UI_Dialog();
329
- $alert3->height = 355;
330
- $alert3->width = 350;
331
  $alert3->title = __('Duplicator Help', 'duplicator');
332
  $alert3->message = "<div id='dup-help-dlg'></div>";
333
  $alert3->initAlert();
@@ -349,9 +307,9 @@ DIALOG: HELP DIALOG -->
349
 
350
  <b><?php esc_html_e("Other Resources:", 'duplicator') ?></b><hr size='1'/>
351
  <i class="fas fa-question-circle fa-sm"></i> <a href="https://snapcreek.com/ticket?utm_source=duplicator_free&utm_medium=wordpress_plugin&utm_content=help_btn_ticket&utm_campaign=duplicator_free" target="_blank"><?php esc_html_e("Need help with the plugin?", 'duplicator') ?></a> <br/>
352
- <i class="fa fa-lightbulb-o"></i> <a href="https://snapcreek.com/support?idea=1&utm_source=duplicator_free&utm_medium=wordpress_plugin&utm_content=help_btn_idea&utm_campaign=duplicator_free" target="_blank"><?php esc_html_e("Have an idea for the plugin?", 'duplicator') ?></a> <br/>
353
- <?php if($statusCount >= 3) : ?>
354
- <i class="fa fa-star-o"></i> <a href="https://wordpress.org/support/plugin/duplicator/reviews/?filter=5" target="vote-wp"><?php esc_html_e("Help review the plugin!", 'duplicator') ?></a>
355
  <?php endif; ?>
356
  </div>
357
 
1
  <?php
2
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
3
+ /* @var $Package DUP_Package */
4
 
5
+ // Never display incomplete packages and purge those that are no longer active
6
+ DUP_Package::purge_incomplete_package();
 
 
7
 
8
+ $totalElements = DUP_Package::count_by_status();
9
+ $completeCount = DUP_Package::count_by_status(array(array('op' => '>=', 'status' => DUP_PackageStatus::COMPLETE))); // total packages completed
10
+ $active_package_present = DUP_Package::is_active_package_present();
11
+
12
+ $package_running = false;
13
+ global $packageTablerowCount;
14
+ $packageTablerowCount = 0;
15
  ?>
16
 
17
  <style>
158
  </td>
159
  </tr>
160
  <?php
 
161
  //$totalSize = 0;
 
 
 
162
  //$rows = $qryResult;
163
 
164
+ function tablePackageRow($Package) {
165
+ global $packageTablerowCount;
166
+
167
+ $is_running_package = $Package->isRunning();
168
+ $pack_name = $Package->Name;
169
+ $pack_archive_size = $Package->getArchiveSize();
170
+ $pack_perc = $Package->Status;
171
+ $pack_storeurl = $Package->StoreURL;
172
+ $pack_dbonly = $Package->Archive->ExportOnlyDB;
173
+ $pack_build_mode = ($Package->Archive->Format === 'ZIP') ? true : false;
174
+
175
+ //Links
176
+ $uniqueid = $Package->NameHash;
177
+ $packagepath = $pack_storeurl.$Package->Archive->File;
178
+
179
+ $css_alt = ($packageTablerowCount % 2 != 0) ? '' : 'alternate';
180
+
181
+ if ($Package->Status >= 100 || $is_running_package) :
182
+ ?>
183
+ <tr class="dup-pack-info <?php echo esc_attr($css_alt); ?> <?php echo $is_running_package ? 'is-running' : ''; ?>">
184
+ <td class="pass"><input name="delete_confirm" type="checkbox" id="<?php echo absint($Package->ID); ?>" /></td>
185
+ <td>
186
+ <?php
187
+ echo DUP_Package::getCreatedDateFormat( $Package->Created , DUP_Settings::get_create_date_format());
188
+ echo ' '.($pack_build_mode ?
189
+ "<sup title='".__('Archive created as zip file', 'duplicator')."'>zip</sup>" :
190
+ "<sup title='".__('Archive created as daf file', 'duplicator')."'>daf</sup>");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  ?>
192
+ </td>
193
+ <td class="pack-size"><?php echo DUP_Util::byteSize($pack_archive_size); ?></td>
194
+ <td class='pack-name'>
195
+ <?php echo ($pack_dbonly) ? "{$pack_name} <sup title='".esc_attr(__('Database Only', 'duplicator'))."'>DB</sup>" : esc_html($pack_name); ?><br/>
196
+ <span class="building-info" >
197
+ <i class="fa fa-cog fa-sm fa-spin"></i> <b>Building Package</b> <span class="perc"><?php echo $pack_perc; ?></span>%
198
+ &nbsp; <i class="fas fa-question-circle fa-sm" style="color:#2C8021"
199
+ data-tooltip-title="<?php esc_attr_e("Package Build Running", 'duplicator'); ?>"
200
+ data-tooltip="<?php esc_attr_e('To stop or reset this package build goto Settings > Advanced > Reset Packages', 'duplicator'); ?>"></i>
201
+ </span>
202
+ </td>
203
+ <td class="get-btns">
204
+ <button id="<?php echo esc_attr("{$uniqueid}_installer.php"); ?>" class="button no-select" onclick="Duplicator.Pack.DownloadPackageFile(0, <?php echo absint($Package->ID); ?>); return false;">
205
+ <i class="fa fa-bolt fa-sm"></i> <?php esc_html_e("Installer", 'duplicator') ?>
206
+ </button>
207
+ <button id="<?php echo esc_attr("{$uniqueid}_archive.zip"); ?>" class="button no-select" onclick="Duplicator.Pack.DownloadFile('<?php echo esc_js($Package->Archive->File); ?>', '<?php echo esc_js($packagepath); ?>'); return false;">
208
+ <i class="far fa-file-archive"></i> <?php esc_html_e("Archive", 'duplicator') ?>
209
+ </button>
210
+ <button type="button" class="button no-select" title="<?php esc_attr_e("Package Details", 'duplicator') ?>" onclick="Duplicator.Pack.OpenPackageDetails(<?php echo "{$Package->ID}"; ?>);">
211
+ <i class="fa fa-archive fa-sm" ></i>
212
+ </button>
213
+ </td>
214
+ </tr>
215
+ <?php else :
216
+ $error_url = "?page=duplicator&action=detail&tab=detail&id={$Package->ID}";
217
+ ?>
218
+ <tr class="dup-pack-info <?php echo esc_attr($css_alt); ?>">
219
+ <td class="fail"><input name="delete_confirm" type="checkbox" id="<?php echo absint($Package->ID); ?>" /></td>
220
+ <td><?php echo DUP_Package::getCreatedDateFormat($Package->Created, DUP_Settings::get_create_date_format());?></td>
221
+ <td class="pack-size"><?php echo DUP_Util::byteSize($pack_archive_size); ?></td>
222
+ <td class='pack-name'><?php echo esc_html($pack_name); ?></td>
223
+ <td class="get-btns error-msg" colspan="2">
224
+ <span>
225
+ <i class="fa fa-exclamation-triangle fa-sm"></i>
226
+ <a href="<?php echo esc_url($error_url); ?>"><?php esc_html_e("Error Processing", 'duplicator') ?></a>
227
+ </span>
228
+ <a class="button no-select" title="<?php esc_attr_e("Package Details", 'duplicator') ?>" href="<?php echo esc_url($error_url); ?>">
229
+ <i class="fa fa-archive fa-sm"></i>
230
+ </a>
231
+ </td>
232
+ </tr>
233
+ <?php endif; ?>
234
+ <?php
235
+ //$totalSize = $totalSize + $pack_archive_size;
236
+ $packageTablerowCount ++;
237
+ }
238
+
239
+ DUP_Package::by_status_callback('tablePackageRow', array(), false, 0, '`id` DESC');
240
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  ?>
242
  <tfoot>
243
  <tr>
284
  $confirm1->initConfirm();
285
 
286
  $alert3 = new DUP_UI_Dialog();
287
+ $alert3->height = 400;
288
+ $alert3->width = 450;
289
  $alert3->title = __('Duplicator Help', 'duplicator');
290
  $alert3->message = "<div id='dup-help-dlg'></div>";
291
  $alert3->initAlert();
307
 
308
  <b><?php esc_html_e("Other Resources:", 'duplicator') ?></b><hr size='1'/>
309
  <i class="fas fa-question-circle fa-sm"></i> <a href="https://snapcreek.com/ticket?utm_source=duplicator_free&utm_medium=wordpress_plugin&utm_content=help_btn_ticket&utm_campaign=duplicator_free" target="_blank"><?php esc_html_e("Need help with the plugin?", 'duplicator') ?></a> <br/>
310
+ <i class="fa fa-lightbulb"></i> <a href="https://snapcreek.com/support?idea=1&utm_source=duplicator_free&utm_medium=wordpress_plugin&utm_content=help_btn_idea&utm_campaign=duplicator_free" target="_blank"><?php esc_html_e("Have an idea for the plugin?", 'duplicator') ?></a> <br/>
311
+ <?php if($completeCount >= 3) : ?>
312
+ <i class="fa fa-star"></i> <a href="https://wordpress.org/support/plugin/duplicator/reviews/?filter=5" target="vote-wp"><?php esc_html_e("Help review the plugin!", 'duplicator') ?></a>
313
  <?php endif; ?>
314
  </div>
315
 
views/packages/main/s1.setup2.php CHANGED
@@ -118,7 +118,7 @@ STORAGE -->
118
  <img src="<?php echo esc_url(DUPLICATOR_PLUGIN_URL."assets/img/ftp-64.png"); ?>" />
119
  <?php echo sprintf(__('%1$s, %2$s, %3$s, %4$s, %5$s and other storage options available in', 'duplicator'), 'Amazon', 'Dropbox', 'Google Drive', 'OneDrive', 'FTP/SFTP'); ?>
120
  <a href="https://snapcreek.com/duplicator/?utm_source=duplicator_free&utm_medium=wordpress_plugin&utm_content=free_storage&utm_campaign=duplicator_pro" target="_blank"><?php esc_html_e('Duplicator Pro', 'duplicator');?></a>
121
- <i class="fa fa-lightbulb-o"
122
  data-tooltip-title="<?php esc_attr_e("Additional Storage:", 'duplicator'); ?>"
123
  data-tooltip="<?php esc_attr_e('Duplicator Pro allows you to create a package and then store it at a custom location on this server or to a cloud '
124
  . 'based location such as Google Drive, Amazon, Dropbox or FTP.', 'duplicator'); ?>">
118
  <img src="<?php echo esc_url(DUPLICATOR_PLUGIN_URL."assets/img/ftp-64.png"); ?>" />
119
  <?php echo sprintf(__('%1$s, %2$s, %3$s, %4$s, %5$s and other storage options available in', 'duplicator'), 'Amazon', 'Dropbox', 'Google Drive', 'OneDrive', 'FTP/SFTP'); ?>
120
  <a href="https://snapcreek.com/duplicator/?utm_source=duplicator_free&utm_medium=wordpress_plugin&utm_content=free_storage&utm_campaign=duplicator_pro" target="_blank"><?php esc_html_e('Duplicator Pro', 'duplicator');?></a>
121
+ <i class="far fa-lightbulb"
122
  data-tooltip-title="<?php esc_attr_e("Additional Storage:", 'duplicator'); ?>"
123
  data-tooltip="<?php esc_attr_e('Duplicator Pro allows you to create a package and then store it at a custom location on this server or to a cloud '
124
  . 'based location such as Google Drive, Amazon, Dropbox or FTP.', 'duplicator'); ?>">
views/packages/main/s2.scan3.php CHANGED
@@ -133,7 +133,7 @@ TOTAL SIZE -->
133
  <div class="directory">
134
  <i class="fa fa-caret-right fa-lg dup-nav" onclick="Duplicator.Pack.toggleDirPath(this)"></i> &nbsp;
135
  {{#if directory.iscore}}
136
- <i class="fa fa-window-close-o chk-off" title="<?php esc_attr_e('Core WordPress directories should not be filtered. Use caution when excluding files.', 'duplicator'); ?>"></i>
137
  {{else}}
138
  <input type="checkbox" name="dir_paths[]" value="{{directory.dir}}" id="lf_dir_{{@index}}" onclick="Duplicator.Pack.filesOff(this)" />
139
  {{/if}}
@@ -273,7 +273,7 @@ FILE NAME CHECKS -->
273
  {{/if}}
274
 
275
  {{#if directory.iscore}}
276
- <i class="fa fa-window-close-o chk-off" title="<?php esc_attr_e('Core WordPress directories should not be filtered. Use caution when excluding files.', 'duplicator'); ?>"></i>
277
  {{else}}
278
  <input type="checkbox" name="dir_paths[]" value="{{directory.dir}}" id="nc1_dir_{{@index}}" onclick="Duplicator.Pack.filesOff(this)" />
279
  {{/if}}
133
  <div class="directory">
134
  <i class="fa fa-caret-right fa-lg dup-nav" onclick="Duplicator.Pack.toggleDirPath(this)"></i> &nbsp;
135
  {{#if directory.iscore}}
136
+ <i class="far fa-window-close chk-off" title="<?php esc_attr_e('Core WordPress directories should not be filtered. Use caution when excluding files.', 'duplicator'); ?>"></i>
137
  {{else}}
138
  <input type="checkbox" name="dir_paths[]" value="{{directory.dir}}" id="lf_dir_{{@index}}" onclick="Duplicator.Pack.filesOff(this)" />
139
  {{/if}}
273
  {{/if}}
274
 
275
  {{#if directory.iscore}}
276
+ <i class="far fa-window-close chk-off" title="<?php esc_attr_e('Core WordPress directories should not be filtered. Use caution when excluding files.', 'duplicator'); ?>"></i>
277
  {{else}}
278
  <input type="checkbox" name="dir_paths[]" value="{{directory.dir}}" id="nc1_dir_{{@index}}" onclick="Duplicator.Pack.filesOff(this)" />
279
  {{/if}}
views/settings/about-info.php CHANGED
@@ -19,13 +19,13 @@ table.dup-support-hlp-hdrs td {
19
  }
20
  table.dup-support-hlp-hdrs td img{margin-left:7px}
21
  div.dup-support-hlp-txt{padding:10px 4px 4px 4px; text-align:center}
22
- div.dup-support-give-area {width:400px; height:165px; float:left; border:1px solid #dfdfdf; border-radius:4px; margin:10px; line-height:18px;box-shadow: 0 8px 6px -6px #ccc;}
23
  div.dup-spread-word {display:inline-block; border:1px solid red; text-align:center}
24
 
25
  img#dup-support-approved { -webkit-animation:approve-keyframe 12s 1s infinite alternate backwards}
26
  img#dup-img-5stars {opacity:0.7;}
27
  img#dup-img-5stars:hover {opacity:1.0;}
28
- div.social-item {float:right; width: 170px; padding:10px 10px 20px 0px; border:0px solid red; text-align: left; font-size:20px}
29
 
30
  /* EMAIL AREA */
31
  div.dup-support-email-area {width:825px; height:355px; border:1px solid #dfdfdf; border-radius:4px; margin:10px; line-height:18px;box-shadow: 0 8px 6px -6px #ccc;}
@@ -38,130 +38,140 @@ div#mce-responses {margin: auto; padding: 10px; width:500px; font-weight: bold;}
38
 
39
 
40
  <div class="wrap dup-wrap dup-support-all">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
- <div style="width:850px; margin:auto; margin-top: 20px">
43
- <table style="width:825px">
44
- <tr>
45
- <td style="width:90px">
46
- <img src="<?php echo esc_url(DUPLICATOR_PLUGIN_URL."assets/img/logo-box.png"); ?>" style='text-align:top; margin:0' />
47
- </td>
48
- <td valign="top" style="padding-top:10px;">
49
- <?php
50
- esc_html_e("Duplicator can streamline your workflow and quickly clone/migrate a WordPress site. The plugin helps admins, designers and developers speed up the "
51
- . "migration process of moving a WordPress site. Please help us continue development by giving this plugin a 5 star.", 'duplicator');
52
- ?>
53
- </td>
54
- </tr>
55
- </table><br/>
56
-
57
- <!-- PARTNER WITH US -->
58
- <div class="dup-support-give-area">
59
- <table class="dup-support-hlp-hdrs">
60
- <tr >
61
- <td style="height:30px; text-align: center;">
62
- <span style="display: inline-block; margin-top: 5px"><?php esc_html_e('Rate Duplicator', 'duplicator') ?></span>
63
- </td>
64
- </tr>
65
- </table>
66
- <table style="text-align: center;width:100%; font-size:11px; font-style:italic; margin-top:25px">
67
- <tr>
68
- <td valign="top">
69
- <a href="https://wordpress.org/support/plugin/duplicator/reviews/?filter=5" target="vote-wp"><img id="dup-img-5stars" src="<?php echo DUPLICATOR_PLUGIN_URL ?>assets/img/5star.png" /></a>
70
- <div style=" font-size: 16px; font-weight: bold">
71
- <a href="https://wordpress.org/support/plugin/duplicator/reviews/?filter=5" target="vote-wp"><?php esc_html_e('Support us with a 5 star review!', 'duplicator') ?></a>
72
  </div>
73
- </td>
74
- </tr>
75
- </table>
76
- </div>
77
-
78
- <!-- SPREAD THE WORD -->
79
- <div class="dup-support-give-area">
80
- <table class="dup-support-hlp-hdrs">
81
- <tr>
82
- <td style="height:30px; text-align: center;">
83
- <span style="display: inline-block; margin-top: 5px"><?php esc_html_e('Spread the Word', 'duplicator') ?></span>
84
- </td>
85
- </tr>
86
- </table>
87
- <div class="dup-support-hlp-txt">
88
- <div class="social-images">
89
- <a href="https://www.facebook.com/sharer/sharer.php?u=https%3A//snapcreek.com/duplicator/duplicator-free/" target="_blank">
90
- <div class="social-item"><i class="fab fa-facebook-square fa-lg"></i> <?php esc_html_e('Facebook', 'duplicator') ?></div>
91
- </a>
92
- <a href="https://twitter.com/home?status=Checkout%20the%20WordPress%20Duplicator%20plugin!%20%0Ahttps%3A//snapcreek.com/duplicator/duplicator-free/" target="_blank">
93
- <div class="social-item"><i class="fab fa-twitter-square fa-lg"></i> <?php esc_html_e('Twitter', 'duplicator') ?></div>
94
- </a>
95
- <a href="https://www.linkedin.com/shareArticle?mini=true&url=https%3A//snapcreek.com/duplicator/duplicator-free/&title=WordPress%20Duplicator%20Plugin&summary=&source=" target="_blank">
96
- <div class="social-item"><i class="fab fa-linkedin fa-lg"></i> <?php esc_html_e('LinkedIn', 'duplicator') ?></div>
97
- </a>
98
- <a href="https://plus.google.com/share?url=https%3A//snapcreek.com/duplicator/duplicator-free/" target="_blank">
99
- <div class="social-item"><i class="fab fa-google-plus-g fa-lg"></i> <?php esc_html_e('Google+', 'duplicator') ?></div>
100
- </a>
101
  </div>
102
- </div>
103
- </div>
104
- <br style="clear:both" /><br/>
105
-
106
- <!-- STAY IN THE LOOP -->
107
- <div class="dup-support-email-area">
108
- <table class="dup-support-hlp-hdrs">
109
- <tr>
110
- <td style="height:30px; text-align: center;">
111
- <span style="display: inline-block; margin-top: 5px"><?php esc_html_e('Stay in the Loop', 'duplicator') ?></span>
112
- </td>
113
- </tr>
114
- </table>
115
- <div class="dup-support-hlp-txt">
116
- <div class="email-box">
117
- <div class="email-area">
118
- <!-- Begin MailChimp Signup Form -->
119
- <div class="email-form">
120
- <div style="width:425px; padding: 5px 0 15px 0; text-align: center; font-style: italic; margin: auto">
121
- <?php esc_html_e('Subscribe to the Duplicator newsletter and stay on top of great ideas, tutorials, and better ways to improve your workflows', 'duplicator') ?>...
122
- </div>
123
-
124
-
125
- <div id="mc_embed_signup">
126
- <form action="//snapcreek.us11.list-manage.com/subscribe/post?u=e2a9a514bfefa439bf2b7cf16&amp;id=1270a169c1" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
127
- <div id="mc_embed_signup_scroll">
128
- <div class="mc-field-group">
129
- <input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" placeholder="Your Best Email *">
130
- </div>
131
- <div id="mce-responses" class="clear">
132
- <div class="response" id="mce-error-response" style="display:none"></div>
133
- <div class="response" id="mce-success-response" style="display:none"></div>
134
- </div>
135
- <div style="position:absolute; left:-5000px;"><input type="text" name="b_e2a9a514bfefa439bf2b7cf16_1270a169c1" tabindex="-1" value=""></div>
136
- <div style="margin: auto; text-align: center">
137
- <input disabled="disabled" type="submit" class="button-primary button-large" value="Sign me up!" name="subscribe" id="mc-embedded-subscribe" >
138
- </div>
139
- <!-- Forces the submission to use Duplicator group -->
140
- <input style="display:none" checked="checked" type="checkbox" value="1" name="group[15741][1]" id="mce-group[15741]-15741-0">
141
- </div>
142
- <div style="margin-top:10px; margin-left:100px; width: 650px;text-align:left">
143
- <small>
144
- <input type="checkbox" name="privacy" id="privacy-checkbox" />
145
- <label for="privacy-checkbox" style="padding-left:5px; display:block; margin-top:-20px; margin-left:20px;">Check box this box if you would like us to contact you by email with helpful information about Duplicator and other Snap Creek products.<br/></br> We will process your data in accordance with our <a target="_blank" href="//snapcreek.com/privacy-policy">privacy policy</a>. You may withdraw this consent at any time by <a target="_blank" href="mailto:admin@snapcreek.com">emailing us</a> or updating your information by clicking the unsubscribe link in the emails you receive.</span></label>
146
- </small>
147
-
148
- </div>
149
- </form>
150
- </div>
151
  </div>
152
 
153
- <script type='text/javascript' src='//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js'></script>
154
- <script type='text/javascript'>(function($) {window.fnames = new Array(); window.ftypes = new Array();fnames[0]='EMAIL';ftypes[0]='email';fnames[1]='FNAME';ftypes[1]='text';fnames[2]='LNAME';ftypes[2]='text';}(jQuery));var $mcj = jQuery.noConflict(true);</script>
155
- <!--End mc_embed_signup-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  </div>
 
 
 
 
157
  </div>
 
 
158
 
159
 
 
 
 
160
 
161
- </div>
162
- </div>
163
- <br style="clear:both" /><br/>
164
- </div>
165
  </div><br/><br/><br/><br/>
166
  <script>
167
  jQuery(document).ready(function($)
19
  }
20
  table.dup-support-hlp-hdrs td img{margin-left:7px}
21
  div.dup-support-hlp-txt{padding:10px 4px 4px 4px; text-align:center}
22
+ div.dup-support-give-area {width:250px; height:225px; float:left; border:1px solid #dfdfdf; border-radius:4px; margin:10px; line-height:18px;box-shadow: 0 8px 6px -6px #ccc;}
23
  div.dup-spread-word {display:inline-block; border:1px solid red; text-align:center}
24
 
25
  img#dup-support-approved { -webkit-animation:approve-keyframe 12s 1s infinite alternate backwards}
26
  img#dup-img-5stars {opacity:0.7;}
27
  img#dup-img-5stars:hover {opacity:1.0;}
28
+ div.social-item {float:right; width: 170px; padding:10px; border:0px solid red; text-align: left; font-size:20px}
29
 
30
  /* EMAIL AREA */
31
  div.dup-support-email-area {width:825px; height:355px; border:1px solid #dfdfdf; border-radius:4px; margin:10px; line-height:18px;box-shadow: 0 8px 6px -6px #ccc;}
38
 
39
 
40
  <div class="wrap dup-wrap dup-support-all">
41
+ <div style="width:850px; margin:auto; margin-top: 20px">
42
+ <table style="width:825px">
43
+ <tr>
44
+ <td style="width:90px">
45
+ <img src="<?php echo esc_url(DUPLICATOR_PLUGIN_URL."assets/img/logo-box.png"); ?>" style='text-align:top; margin:0' />
46
+ </td>
47
+ <td valign="top" style="padding-top:10px; font-size:14px">
48
+ <?php
49
+ esc_html_e("Duplicator can streamline your workflow and quickly clone/migrate a WordPress site. The plugin helps admins, designers and developers speed up the "
50
+ . "migration process of moving a WordPress site. Please help us continue development by giving the plugin a 5 star.", 'duplicator');
51
+ ?>
52
+
53
+ <!-- PARTNER WITH US -->
54
+ <div class="dup-support-give-area">
55
+ <table class="dup-support-hlp-hdrs">
56
+ <tr >
57
+ <td style="height:30px; text-align: center;">
58
+ <span style="display: inline-block; margin-top: 5px"><?php esc_html_e('Rate Duplicator', 'duplicator') ?></span>
59
+ </td>
60
+ </tr>
61
+ </table>
62
+ <table style="text-align: center;width:100%; font-size:11px; font-style:italic; margin-top:35px">
63
+ <tr>
64
+ <td valign="top">
65
+ <a href="https://wordpress.org/support/plugin/duplicator/reviews/?filter=5" target="vote-wp"><img id="dup-img-5stars" src="<?php echo DUPLICATOR_PLUGIN_URL ?>assets/img/5star.png" /></a>
66
+ <div style=" font-size: 16px; font-weight: bold; line-height: 22px">
67
+ <a href="https://wordpress.org/support/plugin/duplicator/reviews/?filter=5" target="vote-wp">
68
+ <?php
69
+ esc_html_e('Support Duplicator', 'duplicator');
70
+ echo '<br/>';
71
+ esc_html_e('with a 5 star review!', 'duplicator')
72
+ ?>
73
+ </a>
74
+ </div>
75
+ </td>
76
+ </tr>
77
+ </table>
78
+ </div>
79
 
80
+ <!-- SPREAD THE WORD -->
81
+ <div class="dup-support-give-area">
82
+ <table class="dup-support-hlp-hdrs">
83
+ <tr>
84
+ <td style="height:30px; text-align: center;">
85
+ <span style="display: inline-block; margin-top: 5px"><?php esc_html_e('Spread the Word', 'duplicator') ?></span>
86
+ </td>
87
+ </tr>
88
+ </table>
89
+ <div class="dup-support-hlp-txt">
90
+ <div class="social-images">
91
+ <a href="https://www.facebook.com/sharer/sharer.php?u=https%3A//snapcreek.com/duplicator/duplicator-free/" target="_blank">
92
+ <div class="social-item"><i class="fab fa-facebook-square fa-lg"></i> <?php esc_html_e('Facebook', 'duplicator') ?></div>
93
+ </a>
94
+ <a href="https://twitter.com/home?status=Checkout%20the%20WordPress%20Duplicator%20plugin!%20%0Ahttps%3A//snapcreek.com/duplicator/duplicator-free/" target="_blank">
95
+ <div class="social-item"><i class="fab fa-twitter-square fa-lg"></i> <?php esc_html_e('Twitter', 'duplicator') ?></div>
96
+ </a>
97
+ <a href="https://www.linkedin.com/shareArticle?mini=true&url=https%3A//snapcreek.com/duplicator/duplicator-free/&title=WordPress%20Duplicator%20Plugin&summary=&source=" target="_blank">
98
+ <div class="social-item"><i class="fab fa-linkedin fa-lg"></i> <?php esc_html_e('LinkedIn', 'duplicator') ?></div>
99
+ </a>
100
+ <a href="https://plus.google.com/share?url=https%3A//snapcreek.com/duplicator/duplicator-free/" target="_blank">
101
+ <div class="social-item"><i class="fab fa-google-plus-g fa-lg"></i> <?php esc_html_e('Google+', 'duplicator') ?></div>
102
+ </a>
 
 
 
 
 
 
 
103
  </div>
104
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  </div>
106
+ <br style="clear:both" /><br/>
107
+
108
+
109
+ </td>
110
+ </tr>
111
+ </table><br/>
112
+
113
+
114
+
115
+ <!-- STAY IN THE LOOP -->
116
+ <div class="dup-support-email-area">
117
+ <table class="dup-support-hlp-hdrs">
118
+ <tr>
119
+ <td style="height:30px; text-align: center;">
120
+ <span style="display: inline-block; margin-top: 5px"><?php esc_html_e('Stay in the Loop', 'duplicator') ?></span>
121
+ </td>
122
+ </tr>
123
+ </table>
124
+ <div class="dup-support-hlp-txt">
125
+ <div class="email-box">
126
+ <div class="email-area">
127
+ <!-- Begin MailChimp Signup Form -->
128
+ <div class="email-form">
129
+ <div style="width:425px; padding: 5px 0 15px 0; text-align: center; font-style: italic; margin: auto">
130
+ <?php esc_html_e('Subscribe to the Duplicator newsletter and stay on top of great ideas, tutorials, and better ways to improve your workflows', 'duplicator') ?>...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  </div>
132
 
133
+
134
+ <div id="mc_embed_signup">
135
+ <form action="//snapcreek.us11.list-manage.com/subscribe/post?u=e2a9a514bfefa439bf2b7cf16&amp;id=1270a169c1" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
136
+ <div id="mc_embed_signup_scroll">
137
+ <div class="mc-field-group">
138
+ <input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" placeholder="Your Best Email *">
139
+ </div>
140
+ <div id="mce-responses" class="clear">
141
+ <div class="response" id="mce-error-response" style="display:none"></div>
142
+ <div class="response" id="mce-success-response" style="display:none"></div>
143
+ </div>
144
+ <div style="position:absolute; left:-5000px;"><input type="text" name="b_e2a9a514bfefa439bf2b7cf16_1270a169c1" tabindex="-1" value=""></div>
145
+ <div style="margin: auto; text-align: center">
146
+ <input disabled="disabled" type="submit" class="button-primary button-large" value="Sign me up!" name="subscribe" id="mc-embedded-subscribe" >
147
+ </div>
148
+ <!-- Forces the submission to use Duplicator group -->
149
+ <input style="display:none" checked="checked" type="checkbox" value="1" name="group[15741][1]" id="mce-group[15741]-15741-0">
150
+ </div>
151
+ <div style="margin-top:10px; margin-left:100px; width: 650px;text-align:left">
152
+ <small>
153
+ <input type="checkbox" name="privacy" id="privacy-checkbox" />
154
+ <label for="privacy-checkbox" style="padding-left:5px; display:block; margin-top:-20px; margin-left:20px;">Check box this box if you would like us to contact you by email with helpful information about Duplicator and other Snap Creek products.<br/></br> We will process your data in accordance with our <a target="_blank" href="//snapcreek.com/privacy-policy">privacy policy</a>. You may withdraw this consent at any time by <a target="_blank" href="mailto:admin@snapcreek.com">emailing us</a> or updating your information by clicking the unsubscribe link in the emails you receive.</span></label>
155
+ </small>
156
+
157
+ </div>
158
+ </form>
159
+ </div>
160
  </div>
161
+
162
+ <script type='text/javascript' src='//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js'></script>
163
+ <script type='text/javascript'>(function($) {window.fnames = new Array(); window.ftypes = new Array();fnames[0]='EMAIL';ftypes[0]='email';fnames[1]='FNAME';ftypes[1]='text';fnames[2]='LNAME';ftypes[2]='text';}(jQuery));var $mcj = jQuery.noConflict(true);</script>
164
+ <!--End mc_embed_signup-->
165
  </div>
166
+ </div>
167
+
168
 
169
 
170
+ </div>
171
+ </div>
172
+ <br style="clear:both" /><br/>
173
 
174
+ </div>
 
 
 
175
  </div><br/><br/><br/><br/>
176
  <script>
177
  jQuery(document).ready(function($)
views/settings/gopro.php CHANGED
@@ -35,9 +35,9 @@ require_once(DUPLICATOR_PLUGIN_PATH . '/views/inc.header.php');
35
 
36
  <div class="dup-pro-area">
37
  <img src="<?php echo esc_url(DUPLICATOR_PLUGIN_URL."assets/img/logo-dpro-300x50.png"); ?>" />
38
- <div style="font-size:18px; font-style:italic; color:gray">
39
  <?php esc_html_e('The simplicity of Duplicator', 'duplicator') ?>
40
- <?php esc_html_e('with power for the professional.', 'duplicator') ?>
41
  </div>
42
 
43
  <table id="comparison-table">
@@ -212,7 +212,12 @@ require_once(DUPLICATOR_PLUGIN_PATH . '/views/inc.header.php');
212
  <td class="check-column"><i class="fa fa-check"></i></td>
213
  </tr>
214
  <tr>
215
- <td class="feature-column"><?php esc_html_e('Active Customer Support', 'duplicator') ?></td>
 
 
 
 
 
216
  <td class="check-column"></td>
217
  <td class="check-column"><i class="fa fa-check"></i></td>
218
  </tr>
35
 
36
  <div class="dup-pro-area">
37
  <img src="<?php echo esc_url(DUPLICATOR_PLUGIN_URL."assets/img/logo-dpro-300x50.png"); ?>" />
38
+ <div style="font-size:18px; font-style:italic; color:gray; border-bottom: 1px solid silver; padding-bottom:10px; margin-bottom: -30px">
39
  <?php esc_html_e('The simplicity of Duplicator', 'duplicator') ?>
40
+ <?php esc_html_e('with power for everyone.', 'duplicator') ?>
41
  </div>
42
 
43
  <table id="comparison-table">
212
  <td class="check-column"><i class="fa fa-check"></i></td>
213
  </tr>
214
  <tr>
215
+ <td class="feature-column">
216
+ <?php esc_html_e('Active Customer Support', 'duplicator') ?>
217
+ <sup><i class="fa fa-question-circle dup-gopro-help"
218
+ data-tooltip-title="<?php esc_attr_e("Support", 'duplicator'); ?>"
219
+ data-tooltip="<?php esc_attr_e('Pro users get top priority for any requestst to our support desk. In most cases responses will be answered in under 24 hours.', 'duplicator'); ?>"/></i></sup>
220
+ </td>
221
  <td class="check-column"></td>
222
  <td class="check-column"><i class="fa fa-check"></i></td>
223
  </tr>
views/settings/license.php CHANGED
@@ -14,7 +14,7 @@ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
14
  <?php esc_html_e('Duplicator Free'); ?>
15
  <div style="padding: 10px">
16
  <i class="far fa-check-square"></i> <?php esc_html_e('Basic Features'); ?> <br/>
17
- <i class="fa fa-square-o"></i> <a href="admin.php?page=duplicator-gopro"><?php esc_html_e('Pro Features'); ?></a><br>
18
  </div>
19
  </td>
20
  </tr>
14
  <?php esc_html_e('Duplicator Free'); ?>
15
  <div style="padding: 10px">
16
  <i class="far fa-check-square"></i> <?php esc_html_e('Basic Features'); ?> <br/>
17
+ <i class="far fa-square"></i> <a href="admin.php?page=duplicator-gopro"><?php esc_html_e('Pro Features'); ?></a><br>
18
  </div>
19
  </td>
20
  </tr>
views/settings/packages.php CHANGED
@@ -103,7 +103,7 @@ $archive_build_mode = DUP_Settings::Get('archive_build_mode')
103
  <i style="cursor: pointer"
104
  data-tooltip-title="<?php esc_html_e("Host Recommendation:", 'duplicator'); ?>"
105
  data-tooltip="<?php esc_html_e('Duplicator recommends going with the high performance pro plan or better from our recommended list', 'duplicator'); ?>">
106
- <i class="fa fa-lightbulb-o" aria-hidden="true"></i>
107
  <?php
108
  printf("%s <a target='_blank' href='//snapcreek.com/wordpress-hosting/'>%s</a> %s",
109
  __("Please visit our recommended", 'duplicator'),
103
  <i style="cursor: pointer"
104
  data-tooltip-title="<?php esc_html_e("Host Recommendation:", 'duplicator'); ?>"
105
  data-tooltip="<?php esc_html_e('Duplicator recommends going with the high performance pro plan or better from our recommended list', 'duplicator'); ?>">
106
+ <i class="far fa-lightbulb" aria-hidden="true"></i>
107
  <?php
108
  printf("%s <a target='_blank' href='//snapcreek.com/wordpress-hosting/'>%s</a> %s",
109
  __("Please visit our recommended", 'duplicator'),
views/tools/diagnostics/logging.php CHANGED
@@ -169,7 +169,7 @@ jQuery(document).ready(function($)
169
  <i style="cursor: pointer"
170
  data-tooltip-title="<?php esc_attr_e("Host Recommendation:", 'duplicator'); ?>"
171
  data-tooltip="<?php esc_attr_e('Duplicator recommends going with the high performance pro plan or better from our recommended list', 'duplicator'); ?>">
172
- <i class="fa fa-lightbulb-o" aria-hidden="true"></i>
173
  <?php
174
  printf("%s <a target='_blank' href='//snapcreek.com/wordpress-hosting/'>%s</a> %s",
175
  esc_html__("Consider our recommended", 'duplicator'),
169
  <i style="cursor: pointer"
170
  data-tooltip-title="<?php esc_attr_e("Host Recommendation:", 'duplicator'); ?>"
171
  data-tooltip="<?php esc_attr_e('Duplicator recommends going with the high performance pro plan or better from our recommended list', 'duplicator'); ?>">
172
+ <i class="far fa-lightbulb" aria-hidden="true"></i>
173
  <?php
174
  printf("%s <a target='_blank' href='//snapcreek.com/wordpress-hosting/'>%s</a> %s",
175
  esc_html__("Consider our recommended", 'duplicator'),