Advertisement
Garrix

Fix

Jul 13th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.03 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * This software is distributed under the GNU GPL v3.0 license.
  5. * @author Gemorroj
  6. * @copyright 2008-2012 http://wapinet.ru
  7. * @license http://www.gnu.org/licenses/gpl-3.0.txt
  8. * @link http://wapinet.ru/gmanager/
  9. * @version 0.8
  10. *
  11. * PHP version >= 5.2.1
  12. *
  13. */
  14.  
  15.  
  16. if (isset($_POST['get'])) {
  17. header('Location: http://' . str_replace(array('\\', '//'), '/', $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/change.php?get=' . rawurlencode($_GET['c'] . ($_GET['f'] ? '&f=' . $_GET['f'] : ''))));
  18. exit;
  19. }
  20.  
  21. $_GET['f'] = isset($_GET['f']) ? $_GET['f'] : '';
  22. $_GET['go'] = isset($_GET['go']) ? $_GET['go'] : '';
  23. $_GET['c'] = isset($_GET['c']) ? $_GET['c'] : '';
  24. $_GET['charset'] = isset($_GET['charset']) ? $_GET['charset'] : '';
  25. $_GET['beautify'] = isset($_GET['beautify']) ? $_GET['beautify'] : '';
  26.  
  27. if ($_GET['charset'] || $_GET['beautify']) {
  28. $_GET['c'] = rawurldecode($_GET['c']);
  29. if ($_GET['f'] != '') {
  30. $_GET['f'] = rawurldecode($_GET['f']);
  31. }
  32. }
  33.  
  34. if (isset($_POST['editorLine']) || isset($_POST['editorReplace'])) {
  35. $_GET['go'] = '';
  36. }
  37.  
  38. require 'bootstrap.php';
  39. ///////////////////////////////////////////
  40. //B?o v? nhung cรณ v? du th?a
  41. if(!isset($admincpok)){ header("location: index.php"); chmt(0,'index.php'); exit;}
  42. //KT
  43. /////////////////////////////////////////////
  44.  
  45. $charset = array('', '');
  46. $full_charset = '';
  47.  
  48. if ($_GET['charset'] && $_GET['charset'] != 'default') {
  49. list($charset[0], $charset[1]) = explode(' -> ', $_GET['charset']);
  50. $full_charset = 'charset=' . htmlspecialchars($charset[0], ENT_COMPAT, 'UTF-8') . '&amp;';
  51. }
  52.  
  53. Gmanager::getInstance()->sendHeader();
  54.  
  55. echo str_replace('%title%', Registry::get('hCurrent'), Registry::get('top')) . '<div class="w2">' . Language::get('title_edit') . '<br/></div>' . Gmanager::getInstance()->head();
  56.  
  57. $archive = Helper_Archive::isArchive(Helper_System::getType(Helper_System::basename(Registry::get('hCurrent'))));
  58. ?>
  59. if($settruphu=='ok')
  60. {
  61. <script language="javascript" type="text/javascript" src="./data/editarea/edit_area_full.js"></script>
  62. <script language="javascript" type="text/javascript">
  63. editAreaLoader.init({
  64. id : "content"
  65. ,syntax: "php"
  66. ,start_highlight: true
  67. ,min_height: 500
  68. ,font_size: "12"
  69. ,toolbar: "search, go_to_line, |, undo, redo, |, select_font, |, syntax_selection, |, change_smooth_selection, highlight, reset_highlight"
  70. ,syntax_selection_allow: "css,html,txt,info,js,php,python,vb,xml,xhtml,c,cpp,sql,basic,pas,brainfuck"
  71. });
  72. </script>
  73. }
  74. <?php
  75. switch (isset($_POST['editorSave']) ? 'save' : $_GET['go']) {
  76. case 'save':
  77. if (Registry::get('lineEditor') && isset($_POST['start']) && isset($_POST['end'])) {
  78. $fill = array_fill($_POST['start'] - 1, $_POST['end'], 1);
  79. if ($archive == Archive::FORMAT_ZIP) {
  80. $obj = new Archive;
  81. $tmp = explode("\n", $obj->setFormat(Archive::FORMAT_ZIP)->setFile(Registry::get('current'))->factory()->lookFile($_GET['f'], true));
  82. } else {
  83. $tmp = explode("\n", Gmanager::getInstance()->file_get_contents(Registry::get('current')));
  84. }
  85.  
  86.  
  87. $all = sizeof($tmp);
  88. for ($i = 0; $i <= $all; ++$i) {
  89. if (isset($fill[$i])) {
  90. if (isset($_POST['line'][$i])) {
  91. $tmp[$i] = (is_array($_POST['line'][$i]) ? implode("\n", $_POST['line'][$i]) : $_POST['line'][$i] . "\n");
  92. } else {
  93. unset($tmp[$i]);
  94. }
  95. }
  96. }
  97. $_POST['text'] = implode("\n", $tmp);
  98. }
  99.  
  100. if ($_POST['charset'] != 'utf-8') {
  101. $_POST['text'] = mb_convert_encoding($_POST['text'], $_POST['charset'], 'UTF-8');
  102. }
  103.  
  104. if ($archive == Archive::FORMAT_ZIP) {
  105. $obj = new Archive;
  106. echo $obj->setFormat(Archive::FORMAT_ZIP)->setFile(Registry::get('current'))->factory()->setEditFile($_GET['f'], $_POST['text']);
  107. } else {
  108. echo Gmanager::getInstance()->createFile(Registry::get('current'), $_POST['text'], $_POST['chmod']);
  109. }
  110. break;
  111.  
  112.  
  113. case 'syntax':
  114. if ($archive == Archive::FORMAT_ZIP) {
  115. $obj = new Archive;
  116. $content = $obj->setFormat(Archive::FORMAT_ZIP)->setFile(Registry::get('current'))->factory()->getEditFile($_GET['f']);
  117. $content = $content['text'];
  118. } else {
  119. $content = Gmanager::getInstance()->file_get_contents(Registry::get('current'));
  120. }
  121.  
  122. if (Config::get('Gmanager', 'syntax') == Config::SYNTAX_WAPINET) {
  123. echo Gmanager::getInstance()->syntaxWapinet($content, $charset);
  124. } else {
  125. echo Gmanager::getInstance()->syntax($content, $charset);
  126. }
  127. break;
  128.  
  129.  
  130. case 'validator':
  131. echo Gmanager::getInstance()->validator(Registry::get('current'), $charset);
  132. break;
  133.  
  134.  
  135. default:
  136. if (Registry::get('currentType') != 'file') {
  137. echo Helper_View::message(Language::get('not_found'), Helper_View::MESSAGE_ERROR);
  138. break;
  139. }
  140. $start = isset($_POST['start']) ? intval($_POST['start']) - 1 : 0;
  141. $end = isset($_POST['end']) ? intval($_POST['end']) : Config::get('LineEditor', 'lines');
  142.  
  143. if (isset($_POST['editorReplace']) && isset($_POST['from']) && isset($_POST['to'])) {
  144. if ($archive == Archive::FORMAT_ZIP) {
  145. $data = Gmanager::getInstance()->replaceZip(Registry::get('current'), $_GET['f'], $_POST['from'], $_POST['to'], isset($_POST['regexp']), isset($_POST['case']));
  146. } else {
  147. $data = Gmanager::getInstance()->replace(Registry::get('current'), $_POST['from'], $_POST['to'], isset($_POST['regexp']), isset($_POST['case']));
  148. }
  149. echo $data['message'];
  150. unset($data['message']);
  151. } else {
  152. $data = array();
  153. if ($archive == Archive::FORMAT_ZIP) {
  154. $obj = new Archive;
  155. $archData = $obj->setFormat(Archive::FORMAT_ZIP)->setFile(Registry::get('current'))->factory()->getEditFile($_GET['f']);
  156. $data['content'] = $archData['text'];
  157. } else {
  158. $data['content'] = Gmanager::getInstance()->file_get_contents(Registry::get('current'));
  159. }
  160. }
  161.  
  162. if ($archive == Archive::FORMAT_ZIP) {
  163. $f = '&amp;f=' . rawurlencode($_GET['f']);
  164. } else {
  165. $f = '';
  166. }
  167.  
  168. if ($charset[0] && $data['content']) {
  169. $data['content'] = mb_convert_encoding($data['content'], $charset[1], $charset[0]);
  170. }
  171.  
  172. if ($_GET['beautify']) {
  173. $data['content'] = Gmanager::getInstance()->beautify($data['content']);
  174. }
  175.  
  176. $quotes = defined('ENT_IGNORE') ? ENT_COMPAT | ENT_IGNORE : ENT_COMPAT;
  177.  
  178. $data['size'] = Helper_View::formatSize(strlen($data['content']));
  179. $data['lines'] = mb_substr_count($data['content'], "\n") + 1;
  180.  
  181. $path = mb_substr(Gmanager::getInstance()->realpath(Registry::get('current')), mb_strlen(IOWrapper::get($_SERVER['DOCUMENT_ROOT'])));
  182.  
  183. if (Config::get('Gmanager', 'mode') == 'HTTP' && $path) {
  184. $http = '<div class="rb"><a href="http://' . $_SERVER['HTTP_HOST'] . str_replace('//', '/', '/' . Helper_View::getRawurl(str_replace('\\', '/', $path))) . '">' . Language::get('look') . '</a><br/></div>';
  185. } else {
  186. $http = '';
  187. }
  188.  
  189. if (Registry::get('lineEditor') && $data['lines'] > Config::get('LineEditor', 'minLines')) {
  190. $isLineEditor = true;
  191. $i = $start;
  192. $j = 0;
  193.  
  194. $edit = '<table class="pedit"><tbody id="pedit">';
  195.  
  196. foreach (array_slice(explode("\n", $data['content']), $start, $end) as $var) {
  197. $j++;
  198. $i++;
  199. $edit .= '<tr id="i' . $j . '"><td class="pedit_l">' . $i . '</td><td class="pedit_c"><input name="line[' . ($i - 1) . '][]" type="text" value="' . htmlspecialchars($var, $quotes, 'UTF-8') . '"/></td><td class="pedit_r"><a title="' . Language::get('add') . '" href="javascript:void(0);" onclick="Gmanager.editAdd(this);">[+]</a> / <a title="' . Language::get('dl') . '" href="javascript:void(0);" onclick="Gmanager.editDel(this);">[-]</a></td></tr>';
  200. }
  201. if ($end > $i) {
  202. $j++;
  203. $edit .= '<tr id="i' . $j . '"><td class="pedit_l">' . ($i + 1) . '+</td><td class="pedit_c"><input name="line[' . $i . '][]" type="text"/></td><td class="pedit_r"><a title="' . Language::get('add') . '" href="javascript:void(0);" onclick="Gmanager.editAdd(this);">[+]</a> / <a title="' . Language::get('dl') . '" href="javascript:void(0);" onclick="Gmanager.editDel(this);">[-]</a></td></tr>';
  204. }
  205.  
  206. $edit .= '</tbody></table>';
  207. $appendEdit = '<input onkeypress="return Gmanager.number(event)" style="-wap-input-format:\'*N\';width:24pt;" type="text" value="' . ($start + 1) . '" name="start" /> - <input onkeypress="return Gmanager.number(event)" style="-wap-input-format:\'*N\';width:24pt;" type="text" value="' . $end . '" name="end"/> <input name="editorLine" type="submit" value="' . Language::get('look') . '"/><br/>';
  208. } else {
  209. $isLineEditor = false;
  210. $edit = '<textarea id="content" style="width: 100%;" name="text" rows="18" cols="64" wrap="' . (Config::get('Editor', 'wrap') ? 'on' : 'off') . '">' . htmlspecialchars($data['content'], $quotes, 'UTF-8') . '</textarea><br/>';
  211. $appendEdit = '';
  212. }
  213.  
  214. echo '<div class="input">' . $data['lines'] . ' ' . Language::get('lines') . ' / ' . $data['size'] . '<form action="edit.php?c=' . Registry::get('rCurrent') . $f . '" method="post"><div class="edit">' . $edit . '</div><fieldset class="edit">' . $appendEdit . '<input name="editorSave" type="submit" value="' . Language::get('save') . '"/><select name="charset"><option value="utf-8">utf-8</option><option value="windows-1251"' . ($charset[1] == 'windows-1251'? ' selected="selected"' : '') . '>windows-1251</option><option value="iso-8859-1"' . ($charset[1] == 'iso-8859-1'? ' selected="selected"' : '') . '>iso-8859-1</option><option value="cp866"' . ($charset[1] == 'cp866'? ' selected="selected"' : '') . '>cp866</option><option value="koi8-r"' . ($charset[1] == 'koi8-r'? ' selected="selected"' : '') . '>koi8-r</option></select><br/>' . Language::get('chmod') . ' <input onkeypress="return Gmanager.number(event)" type="text" name="chmod" value="' . Gmanager::getInstance()->lookChmod(Registry::get('current')) . '" size="4" maxlength="4" style="-wap-input-format:\'4N\';width:28pt;"/><br/><input type="submit" name="get" value="' . Language::get('get') . '"/><br/>' . ($isLineEditor ? '<a href="edit.php?lineEditor=0&amp;c=' . Registry::get('rCurrent') . $f . '">' . Language::get('basic_editor') . '</a>' : Language::get('basic_editor')) . ' / ' . ($isLineEditor ? Language::get('line_editor') : '<a href="edit.php?lineEditor=1&amp;c=' . Registry::get('rCurrent') . $f . '">' . Language::get('line_editor') . '</a>') . '</fieldset><fieldset class="edit">' . Language::get('replace_from') . '<br/><input type="text" name="from" value="' . (isset($_POST['from']) ? htmlspecialchars($_POST['from']) : '') . '" style="width:128pt;"/>' . Language::get('replace_to') . '<input type="text" name="to" value="' . (isset($_POST['to']) ? htmlspecialchars($_POST['to']) : '') . '" style="width:128pt;"/><br/><input type="checkbox" name="regexp" id="regexp" value="1"' . (isset($_POST['regexp']) ? ' checked="checked"' : '') . '/><label for="regexp">' . Language::get('regexp') . '</label><br/><input type="checkbox" name="case" id="case" value="1"' . (isset($_POST['case']) ? ' checked="checked"' : '') . '/><label for="case">' . Language::get('register') . '</label><br/><input type="submit" name="editorReplace" value="' . Language::get('replace') . '"/></fieldset></form></div>' . $http . '<div class="rb"><a href="edit.php?c=' . Registry::get('rCurrent') . $f . '&amp;' . $full_charset . 'go=syntax">' . Language::get('syntax') . '</a><br/></div>';
  215.  
  216.  
  217. if ($archive == '' && extension_loaded('xml')) {
  218. echo '<div class="rb"><a href="edit.php?c=' . Registry::get('rCurrent') . '&amp;' . $full_charset . 'go=validator">' . Language::get('validator') . '</a><br/></div>';
  219. }
  220.  
  221. echo '<div class="rb">' . Language::get('charset') . '<form action="edit.php?" style="padding:0;margin:0;"><div><input type="hidden" name="c" value="' . Registry::get('rCurrent') . '"/><input type="hidden" name="f" value="' . rawurlencode($_GET['f']) . '"/>' . ($isLineEditor ? '<input type="hidden" name="start" value="' . ($start + 1) . '"/><input type="hidden" name="end" value="' . $end . '"/>' : '') . '<select name="charset"><option value="default">' . Language::get('charset_no') . '</option><optgroup label="UTF-8"><option value="utf-8 -&gt; windows-1251"' . ($_GET['charset'] == 'utf-8 -> windows-1251' ? ' selected="selected"' : '') . '>utf-8 -&gt; windows-1251</option><option value="utf-8 -&gt; iso-8859-1"' . ($_GET['charset'] == 'utf-8 -> iso-8859-1' ? ' selected="selected"' : '') . '>utf-8 -&gt; iso-8859-1</option><option value="utf-8 -&gt; cp866"' . ($_GET['charset'] == 'utf-8 -> cp866' ? ' selected="selected"' : '') . '>utf-8 -&gt; cp866</option><option value="utf-8 -&gt; koi8-r"' . ($_GET['charset'] == 'utf-8 -> koi8-r' ? ' selected="selected"' : '') . '>utf-8 -&gt; koi8-r</option></optgroup><optgroup label="Windows-1251"><option value="windows-1251 -&gt; utf-8"' . ($_GET['charset'] == 'windows-1251 -> utf-8' ? ' selected="selected"' : '') . '>windows-1251 -&gt; utf-8</option><option value="windows-1251 -&gt; iso-8859-1"' . ($_GET['charset'] == 'windows-1251 -> iso-8859-1' ? ' selected="selected"' : '') . '>windows-1251 -&gt; iso-8859-1</option><option value="windows-1251 -&gt; cp866"' . ($_GET['charset'] == 'windows-1251 -> cp866' ? ' selected="selected"' : '') . '>windows-1251 -&gt; cp866</option><option value="windows-1251 -&gt; koi8-r"' . ($_GET['charset'] == 'windows-1251 -> koi8-r' ? ' selected="selected"' : '') . '>windows-1251 -&gt; koi8-r</option></optgroup><optgroup label="ISO-8859-1"><option value="iso-8859-1 -&gt; utf-8"' . ($_GET['charset'] == 'iso-8859-1 -> utf-8' ? ' selected="selected"' : '') . '>iso-8859-1 -&gt; utf-8</option><option value="iso-8859-1 -&gt; windows-1251"' . ($_GET['charset'] == 'iso-8859-1 -> windows-1251' ? ' selected="selected"' : '') . '>iso-8859-1 -&gt; windows-1251</option><option value="iso-8859-1 -&gt; cp866"' . ($_GET['charset'] == 'iso-8859-1 -> cp866' ? ' selected="selected"' : '') . '>iso-8859-1 -&gt; cp866</option><option value="iso-8859-1 -&gt; koi8-r"' . ($_GET['charset'] == 'iso-8859-1 -> koi8-r' ? ' selected="selected"' : '') . '>iso-8859-1 -&gt; koi8-r</option></optgroup><optgroup label="CP866"><option value="cp866 -&gt; utf-8"' . ($_GET['charset'] == 'cp866 -> utf-8' ? ' selected="selected"' : '') . '>cp866 -&gt; utf-8</option><option value="cp866 -&gt; windows-1251"' . ($_GET['charset'] == 'cp866 -> windows-1251' ? ' selected="selected"' : '') . '>cp866 -&gt; windows-1251</option><option value="cp866 -&gt; iso-8859-1"' . ($_GET['charset'] == 'cp866 -> iso-8859-1' ? ' selected="selected"' : '') . '>cp866 -&gt; iso-8859-1</option><option value="cp866 -&gt; koi8-r"' . ($_GET['charset'] == 'cp866 -> koi8-r' ? ' selected="selected"' : '') . '>cp866 -&gt; koi8-r</option></optgroup><optgroup label="KOI8-R"><option value="koi8-r -&gt; utf-8"' . ($_GET['charset'] == 'koi8-r -> utf-8' ? ' selected="selected"' : '') . '>koi8-r -&gt; utf-8</option><option value="koi8-r -&gt; windows-1251"' . ($_GET['charset'] == 'koi8-r -> windows-1251' ? ' selected="selected"' : '') . '>koi8-r -&gt; windows-1251</option><option value="koi8-r -&gt; iso-8859-1"' . ($_GET['charset'] == 'koi8-r -> iso-8859-1' ? ' selected="selected"' : '') . '>koi8-r -&gt; iso-8859-1</option><option value="koi8-r -&gt; cp866"' . ($_GET['charset'] == 'koi8-r -> cp866' ? ' selected="selected"' : '') . '>koi8-r -&gt; cp866</option></optgroup></select> <input type="submit" value="' . Language::get('ch') . '"/></div></form></div><div class="rb">' . Language::get('beautifier') . ' (alpha)<form action="edit.php?" style="padding:0;margin:0;"><div><input type="hidden" name="beautify" value="1"/><input type="hidden" name="c" value="' . Registry::get('rCurrent') . '"/><input type="hidden" name="f" value="' . rawurlencode($_GET['f']) . '"/><input type="hidden" name="f" value="' . rawurlencode($_GET['f']) . '"/>' . ($isLineEditor ? '<input type="hidden" name="start" value="' . ($start + 1) . '"/><input type="hidden" name="end" value="' . $end . '"/>' : '') . '<input type="submit" value="' . Language::get('beautify') . '" /></div></form></div>';
  222. break;
  223. }
  224.  
  225.  
  226. echo '<div class="rb">' . round(microtime(true) - GMANAGER_START, 4) . ' / ' . Helper_View::formatSize(memory_get_peak_usage()) . '<br/></div>' . Registry::get('foot');
  227.  
  228. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement