| 1 |
<?php |
| 2 |
|
| 3 |
////////////////////////////////////////////////////////////// |
| 4 |
//=========================================================== |
| 5 |
// givejs.php |
| 6 |
//=========================================================== |
| 7 |
// PAGELAYER |
| 8 |
// Inspired by the DESIRE to be the BEST OF ALL |
| 9 |
// ---------------------------------------------------------- |
| 10 |
// Started by: Pulkit Gupta |
| 11 |
// Date: 23rd Jan 2017 |
| 12 |
// Time: 23:00 hrs |
| 13 |
// Site: http://pagelayer.com/wordpress (PAGELAYER) |
| 14 |
// ---------------------------------------------------------- |
| 15 |
// Please Read the Terms of use at http://pagelayer.com/tos |
| 16 |
// ---------------------------------------------------------- |
| 17 |
//=========================================================== |
| 18 |
// (c)Pagelayer Team |
| 19 |
//=========================================================== |
| 20 |
////////////////////////////////////////////////////////////// |
| 21 |
|
| 22 |
if(!empty($_REQUEST['test'])){ |
| 23 |
echo 1; |
| 24 |
die(); |
| 25 |
} |
| 26 |
|
| 27 |
// Read the file |
| 28 |
$data = ''; |
| 29 |
$data_premium = ''; |
| 30 |
$self_path = dirname(__FILE__); |
| 31 |
$plugins_path = dirname(dirname($self_path)); |
| 32 |
$files = array( |
| 33 |
// Admin JS |
| 34 |
'pagelayer-editor.js', |
| 35 |
'widgets.js', |
| 36 |
'premium.js', |
| 37 |
'properties.js', |
| 38 |
'base-64.min.js', |
| 39 |
'slimscroll.js', |
| 40 |
'vanilla-picker.min.js', |
| 41 |
'tlite.min.js', |
| 42 |
'pagelayer-pen.js', |
| 43 |
// Enduser JS |
| 44 |
'imagesloaded.min.js', |
| 45 |
'nivo-lightbox.min.js', |
| 46 |
'owl.carousel.min.js', |
| 47 |
'pagelayer-frontend.js', |
| 48 |
'premium-frontend.js', |
| 49 |
'wow.min.js', |
| 50 |
'jquery-numerator.js', |
| 51 |
'simpleParallax.min.js', |
| 52 |
'chart.min.js', |
| 53 |
'shuffle.min.js' |
| 54 |
); |
| 55 |
|
| 56 |
// What files to give |
| 57 |
$give = @$_REQUEST['give']; |
| 58 |
|
| 59 |
// Premium |
| 60 |
$premium = !empty($_REQUEST['premium']) ? $_REQUEST['premium'] : ''; |
| 61 |
$premium_path = $plugins_path.'/pagelayer-pro/js'; |
| 62 |
|
| 63 |
if(!empty($give)){ |
| 64 |
|
| 65 |
$give = explode(',', $give); |
| 66 |
|
| 67 |
// Check all files are in the supported list |
| 68 |
foreach($give as $file){ |
| 69 |
if(in_array($file, $files)){ |
| 70 |
$final[md5($file)] = $file; |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
} |
| 75 |
|
| 76 |
if(!empty($premium)){ |
| 77 |
|
| 78 |
$premium = explode(',', trim($premium, ',')); |
| 79 |
|
| 80 |
// Check all files are in the supported list |
| 81 |
foreach($premium as $file){ |
| 82 |
if(in_array($file, $files)){ |
| 83 |
$final_premium[md5($file)] = $file; |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
} |
| 88 |
|
| 89 |
// Give all |
| 90 |
if(empty($final)){ |
| 91 |
$final = $files; |
| 92 |
} |
| 93 |
|
| 94 |
foreach($final as $k => $v){ |
| 95 |
//echo $k.'<br>'; |
| 96 |
$data .= file_get_contents($self_path.'/'.$v)."\n\n"; |
| 97 |
} |
| 98 |
|
| 99 |
if(!empty($final_premium)){ |
| 100 |
|
| 101 |
foreach($final_premium as $k => $v){ |
| 102 |
//echo $k.'<br>'; |
| 103 |
$data_premium .= file_get_contents($premium_path.'/'.$v)."\n\n"; |
| 104 |
} |
| 105 |
|
| 106 |
} |
| 107 |
|
| 108 |
// We are zipping if possible |
| 109 |
if(function_exists('ob_gzhandler') && !ini_get('zlib.output_compression')){ |
| 110 |
ob_start('ob_gzhandler'); |
| 111 |
} |
| 112 |
|
| 113 |
// Type javascript |
| 114 |
header("Content-type: text/javascript; charset: UTF-8"); |
| 115 |
|
| 116 |
// Set a zero Mtime |
| 117 |
$filetime = filemtime($self_path.'/pagelayer-editor.js'); |
| 118 |
|
| 119 |
// Are we to also serve Shortcodes ? |
| 120 |
if(!empty($pagelayer->shortcodes)){ |
| 121 |
$data .= 'pagelayer_shortcodes = '.json_encode($pagelayer->shortcodes).';'."\n\n"; |
| 122 |
$data .= 'pagelayer_styles = '.json_encode($pagelayer->styles).';'."\n\n"; |
| 123 |
$data .= 'pagelayer_groups = '.json_encode($pagelayer->groups).';'."\n\n"; |
| 124 |
} |
| 125 |
|
| 126 |
// Add the langs as well |
| 127 |
preg_match_all('/pagelayer_l\([\'"](\w*)[\'"]\)/is', $data, $matches); |
| 128 |
if(!empty($matches[1]) && function_exists('__pl')){ |
| 129 |
foreach($matches[1] as $lk => $lv){ |
| 130 |
$export_langs[$lv] = __pl($lv); |
| 131 |
} |
| 132 |
} |
| 133 |
|
| 134 |
// Also add the fonts |
| 135 |
if(!empty($pagelayer->fonts)){ |
| 136 |
$export_langs['pl_fonts_list'] = $pagelayer->fonts; |
| 137 |
} |
| 138 |
|
| 139 |
// And lang string ? |
| 140 |
if(!empty($export_langs)){ |
| 141 |
$data .= 'pagelayer_lang = '.json_encode($export_langs).';'."\n\n"; |
| 142 |
} |
| 143 |
|
| 144 |
// Cache Control |
| 145 |
header("Cache-Control: must-revalidate"); |
| 146 |
|
| 147 |
// Checking if the client is validating his cache and if it is current. |
| 148 |
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $filetime)) { |
| 149 |
|
| 150 |
// Client's cache IS current, so we just respond '304 Not Modified'. |
| 151 |
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $filetime).' GMT', true, 304); |
| 152 |
|
| 153 |
return; |
| 154 |
|
| 155 |
}else{ |
| 156 |
|
| 157 |
// Image not cached or cache outdated, we respond '200 OK' and output the image. |
| 158 |
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $filetime).' GMT', true, 200); |
| 159 |
|
| 160 |
} |
| 161 |
|
| 162 |
echo $data; |
| 163 |
echo $data_premium; |
| 164 |
|
| 165 |
// Write if we are front-end only then |
| 166 |
$dev = dirname(dirname(__FILE__)).'/dev.php'; |
| 167 |
if(!empty($_REQUEST['write']) && file_exists($dev)){ |
| 168 |
include_once($dev); |
| 169 |
write_js(); |
| 170 |
} |
| 171 |
|
| 172 |
|
| 173 |
|