Guest User

Untitled

a guest
Aug 6th, 2020
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.65 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 4.1.0.0
  8. * @ Author : DeZender
  9. * @ Release on : 15.05.2020
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. namespace PhpMyAdmin;
  15.  
  16. class Util
  17. {
  18. /**
  19. * Checks whether configuration value tells to show icons.
  20. *
  21. * @param string $value Configuration option name
  22. *
  23. * @return boolean Whether to show icons.
  24. */
  25. static public function showIcons($value)
  26. {
  27. return in_array($GLOBALS['cfg'][$value], ['icons', 'both']);
  28. }
  29.  
  30. /**
  31. * Checks whether configuration value tells to show text.
  32. *
  33. * @param string $value Configuration option name
  34. *
  35. * @return boolean Whether to show text.
  36. */
  37. static public function showText($value)
  38. {
  39. return in_array($GLOBALS['cfg'][$value], ['text', 'both']);
  40. }
  41.  
  42. /**
  43. * Returns an HTML IMG tag for a particular icon from a theme,
  44. * which may be an actual file or an icon from a sprite.
  45. * This function takes into account the ActionLinksMode
  46. * configuration setting and wraps the image tag in a span tag.
  47. *
  48. * @param string $icon name of icon file
  49. * @param string $alternate alternate text
  50. * @param boolean $force_text whether to force alternate text to be displayed
  51. * @param boolean $menu_icon whether this icon is for the menu bar or not
  52. * @param string $control_param which directive controls the display
  53. *
  54. * @return string an html snippet
  55. */
  56. static public function getIcon($icon, $alternate = '', $force_text = false, $menu_icon = false, $control_param = 'ActionLinksMode')
  57. {
  58. $include_icon = $include_text = false;
  59.  
  60. if (self::showIcons($control_param)) {
  61. $include_icon = true;
  62. }
  63. if ($force_text || self::showText($control_param)) {
  64. $include_text = true;
  65. }
  66.  
  67. $button = ($menu_icon ? '' : '<span class="nowrap">');
  68.  
  69. if ($include_icon) {
  70. $button .= self::getImage($icon, $alternate);
  71. }
  72. if ($include_icon && $include_text) {
  73. $button .= '&nbsp;';
  74. }
  75.  
  76. if ($include_text) {
  77. $button .= $alternate;
  78. }
  79.  
  80. $button .= ($menu_icon ? '' : '</span>');
  81. return $button;
  82. }
  83.  
  84. /**
  85. * Returns an HTML IMG tag for a particular image from a theme
  86. *
  87. * The image name should match CSS class defined in icons.css.php
  88. *
  89. * @param string $image The name of the file to get
  90. * @param string $alternate Used to set 'alt' and 'title' attributes
  91. * of the image
  92. * @param array $attributes An associative array of other attributes
  93. *
  94. * @return string an html IMG tag
  95. */
  96. static public function getImage($image, $alternate = '', array $attributes = [])
  97. {
  98. $alternate = htmlspecialchars($alternate);
  99.  
  100. if (isset($attributes['class'])) {
  101. $attributes['class'] = 'icon ic_' . $image . ' ' . $attributes['class'];
  102. }
  103. else {
  104. $attributes['class'] = 'icon ic_' . $image;
  105. }
  106.  
  107. $attr_str = '';
  108.  
  109. foreach ($attributes as $key => $value) {
  110. if (!in_array($key, ['alt', 'title'])) {
  111. $attr_str .= ' ' . $key . '="' . $value . '"';
  112. }
  113. }
  114.  
  115. if (isset($attributes['alt'])) {
  116. $alt = $attributes['alt'];
  117. }
  118. else {
  119. $alt = $alternate;
  120. }
  121.  
  122. if (isset($attributes['title'])) {
  123. $title = $attributes['title'];
  124. }
  125. else {
  126. $title = $alternate;
  127. }
  128.  
  129. $template = '<img src="themes/dot.gif" title="%s" alt="%s"%s>';
  130. return sprintf($template, $title, $alt, $attr_str);
  131. }
  132.  
  133. /**
  134. * Returns the formatted maximum size for an upload
  135. *
  136. * @param integer $max_upload_size the size
  137. *
  138. * @return string the message
  139. *
  140. * @access public
  141. */
  142. static public function getFormattedMaximumUploadSize($max_upload_size)
  143. {
  144. list($max_size, $max_unit) = self::formatByteDown($max_upload_size, 4);
  145. return '(' . sprintf(__('Max: %s%s'), $max_size, $max_unit) . ')';
  146. }
  147.  
  148. /**
  149. * Generates a hidden field which should indicate to the browser
  150. * the maximum size for upload
  151. *
  152. * @param integer $max_size the size
  153. *
  154. * @return string the INPUT field
  155. *
  156. * @access public
  157. */
  158. static public function generateHiddenMaxFileSize($max_size)
  159. {
  160. return '<input type="hidden" name="MAX_FILE_SIZE" value="' . $max_size . '">';
  161. }
  162.  
  163. /**
  164. * Add slashes before "_" and "%" characters for using them in MySQL
  165. * database, table and field names.
  166. * Note: This function does not escape backslashes!
  167. *
  168. * @param string $name the string to escape
  169. *
  170. * @return string the escaped string
  171. *
  172. * @access public
  173. */
  174. static public function escapeMysqlWildcards($name)
  175. {
  176. return strtr($name, ['_' => '\\_', '%' => '\\%']);
  177. }
  178.  
  179. /**
  180. * removes slashes before "_" and "%" characters
  181. * Note: This function does not unescape backslashes!
  182. *
  183. * @param string $name the string to escape
  184. *
  185. * @return string the escaped string
  186. *
  187. * @access public
  188. */
  189. static public function unescapeMysqlWildcards($name)
  190. {
  191. return strtr($name, ['\\_' => '_', '\\%' => '%']);
  192. }
  193.  
  194. /**
  195. * removes quotes (',",`) from a quoted string
  196. *
  197. * checks if the string is quoted and removes this quotes
  198. *
  199. * @param string $quoted_string string to remove quotes from
  200. * @param string $quote type of quote to remove
  201. *
  202. * @return string unqoted string
  203. */
  204. static public function unQuote($quoted_string, $quote = NULL)
  205. {
  206. $quotes = [];
  207.  
  208. if ($quote === NULL) {
  209. $quotes[] = '`';
  210. $quotes[] = '"';
  211. $quotes[] = '\'';
  212. }
  213. else {
  214. $quotes[] = $quote;
  215. }
  216.  
  217. foreach ($quotes as $quote) {
  218. if ((mb_substr($quoted_string, 0, 1) === $quote) && (mb_substr($quoted_string, -1, 1) === $quote)) {
  219. $unquoted_string = mb_substr($quoted_string, 1, -1);
  220. $unquoted_string = str_replace($quote . $quote, $quote, $unquoted_string);
  221. return $unquoted_string;
  222. }
  223. }
  224.  
  225. return $quoted_string;
  226. }
  227.  
  228. /**
  229. * format sql strings
  230. *
  231. * @param string $sqlQuery raw SQL string
  232. * @param boolean $truncate truncate the query if it is too long
  233. *
  234. * @return string the formatted sql
  235. *
  236. * @global array $cfg the configuration array
  237. *
  238. * @access public
  239. * @todo move into PMA_Sql
  240. */
  241. static public function formatSql($sqlQuery, $truncate = false)
  242. {
  243. global $cfg;
  244. if ($truncate && ($cfg['MaxCharactersInDisplayedSQL'] < mb_strlen($sqlQuery))) {
  245. .....................................................................
  246. .........................................
  247. ...............
Add Comment
Please, Sign In to add comment