Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.97 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ALL);
  4. ini_set('error_reporting', E_ALL);
  5. ini_set('display_errors', 1);
  6. ini_set('memory_limit', "2048M");
  7. ini_set('max_execution_time', 300);
  8.  
  9. date_default_timezone_set("Asia/Ho_Chi_Minh");
  10.  
  11. /**-------------------------------------------------------------*/
  12. // $db = new dbdump('localhost', 'user', 'pass', 'dbname');
  13.  
  14. $db->multi = 0;
  15. $db->sql_gz = 1;
  16. $db->sql_nomal = 0;
  17. $db->ins_length = 200;
  18. // magento
  19. $db->dir = 'media';
  20. // wordpress
  21. // $db->dir = 'wp-content/uploads';
  22.  
  23. //magento
  24. $db->tables_dis = array(
  25. 'adminnotification_inbox',
  26. 'aw_core_logger',
  27.  
  28. /* Cache tables */
  29. 'core_cache',
  30. 'core_cache_tag',
  31.  
  32. /* Session tables */
  33. 'core_session',
  34.  
  35. 'catalog_product_flat',
  36. 'catalog_compare_item',
  37. 'catalogindex_aggregation',
  38. 'catalogindex_aggregation_tag',
  39. 'catalogindex_aggregation_to_tag',
  40.  
  41. /* Dataflow tables */
  42. 'dataflow_batch_export',
  43. 'dataflow_batch_import',
  44.  
  45. /* Admin logs */
  46. 'enterprise_logging_event',
  47. 'enterprise_logging_event_changes',
  48.  
  49. /*Support tables*/
  50. 'enterprise_support_backup',
  51. 'enterprise_support_backup_item',
  52.  
  53. /* Index tables */
  54. 'index_event',
  55. 'index_process_event',
  56.  
  57. /*Log tables*/
  58. 'log_customer',
  59. 'log_quote',
  60. 'log_summary',
  61. 'log_summary_type',
  62. 'log_url',
  63. 'log_url_info',
  64. 'log_visitor',
  65. 'log_visitor_info',
  66. 'log_visitor_online',
  67.  
  68. /* Report tables */
  69. 'report_viewed_product_index',
  70. 'report_compared_product_index',
  71. 'report_event',
  72.  
  73. /* More report tables */
  74. 'report_viewed_product_aggregated_daily',
  75. 'report_viewed_product_aggregated_monthly',
  76. 'report_viewed_product_aggregated_yearly',
  77. );
  78.  
  79. $db->tables_limit = array(
  80. 'sales_flat_quote' => 'WHERE updated_at >= DATE_SUB(Now(),INTERVAL 30 DAY)',
  81. 'sales_flat_quote_address' => 'WHERE updated_at >= DATE_SUB(Now(),INTERVAL 30 DAY)',
  82. 'sales_flat_quote_address_item' => 'WHERE updated_at >= DATE_SUB(Now(),INTERVAL 30 DAY)',
  83. 'sales_flat_quote_item' => 'WHERE updated_at >= DATE_SUB(Now(),INTERVAL 30 DAY)',
  84. 'sales_flat_quote_item_option' => 'WHERE updated_at >= DATE_SUB(Now(),INTERVAL 30 DAY)',
  85. 'sales_flat_quote_payment' => 'WHERE updated_at >= DATE_SUB(Now(),INTERVAL 30 DAY)',
  86. 'sales_flat_quote_shipping_rate' => 'WHERE updated_at >= DATE_SUB(Now(),INTERVAL 30 DAY)',
  87. 'enterprise_customer_sales_flat_quote' => 'WHERE updated_at >= DATE_SUB(Now(),INTERVAL 30 DAY)',
  88.  
  89. /* only for developer */
  90. 'core_url_rewrite' => 'WHERE is_system = 1',
  91. 'enterprise_url_rewrite' => 'WHERE is_system = 1',
  92. );
  93.  
  94.  
  95. //wordpress
  96. // $db->tables_dis = array();
  97.  
  98. // $db->tables_limit = array();
  99.  
  100. $db->tables_en = array();
  101. // $db->tables_en = $db->tables_dis;
  102. // $db->tables_en = array(
  103. // // 'wishlist_item_option',
  104. // 'catalogsearch_fulltext',
  105. // 'catalog_product_entity_text',
  106. // );
  107.  
  108. // $db->table_from = 'sales_flat_quote';
  109.  
  110. $db->dumb();
  111.  
  112. // $db->clean();
  113. // $db->file_delete('media' . DIRECTORY_SEPARATOR . 'lacoqueta');
  114. // $db->file_delete('media' . DIRECTORY_SEPARATOR . 'orange');
  115.  
  116. // $db->file_chmod('media');
  117. // $db->file_chmod('orange-box' . DIRECTORY_SEPARATOR . 'media');
  118.  
  119.  
  120. /**-------------------------------------------------------------*/
  121.  
  122. /**
  123. *
  124. */
  125. class dbdump extends stdClass {
  126.  
  127. var $host = '';
  128. var $user = '';
  129. var $pass = '';
  130. var $name = '';
  131.  
  132.  
  133. var $multi = 0;
  134. var $dir = 'media';
  135. var $ins_length = 100;
  136. var $sql_gz = 1;
  137. var $sql_nomal = 1;
  138.  
  139. var $tables_en = array();
  140. var $tables_dis = array();
  141. var $tables_limit = array();
  142. var $table_from = '';
  143.  
  144. protected $tables = array();
  145.  
  146.  
  147. protected $mysql_data_type_hash = array(
  148. 'number' => array(
  149. 1 => 'tinyint',
  150. 2 => 'smallint',
  151. 3 => 'int',
  152. 4 => 'float',
  153. 5 => 'double',
  154. 5 => 'real',
  155. 7 => 'timestamp',
  156. 8 => 'bigint',
  157. 8 => 'serial',
  158. 9 => 'mediumint',
  159. 16 => 'bit',
  160. 246 => 'decimal',
  161. ),
  162. 'time' => array(
  163. 10 => 'date',
  164. 11 => 'time',
  165. 12 => 'datetime',
  166. 13 => 'year',
  167. ),
  168. 'bool' => array(
  169. 1 => 'boolean',
  170. 16 => 'bit',
  171. ),
  172. 'blob' => array(
  173. 252 => 'text',
  174. 252 => 'tinyblob',
  175. 252 => 'blob',
  176. 252 => 'mediumblob',
  177. 252 => 'longblob',
  178. 254 => 'binary',
  179. 253 => 'varbinary',
  180. 16 => 'bit',
  181. ),
  182. 'text' => array(
  183. 246 => 'decimal',
  184. 252 => 'text', /* is currently mapped to all text and blob types (MySQL 5.0.51a) */
  185. 253 => 'varchar',
  186. 254 => 'char',
  187. ),
  188. );
  189.  
  190. function __construct($host = '', $user = '', $pass = '', $name = '', $dir = 'media', $ins_length = 100) {
  191. $this->host = $host;
  192. $this->user = $user;
  193. $this->pass = $pass;
  194. $this->name = $name;
  195. $this->dir = $dir;
  196. $this->ins_length = $ins_length;
  197.  
  198. // $this->dumb();
  199. }
  200.  
  201. function dumb() {
  202.  
  203. $this->data_connect();
  204. $this->dumb_tables();
  205. $this->data_close();
  206.  
  207. echo 'successfull!!'. PHP_EOL;;
  208. // echo $this->filename . PHP_EOL;
  209. // echo "$this->filename.gz" . PHP_EOL;
  210. }
  211.  
  212. function clean() {
  213.  
  214. $this->data_connect();
  215. $this->clean_tables();
  216. $this->data_close();
  217.  
  218. echo 'successfull!!'. PHP_EOL;;
  219. }
  220.  
  221. function in_array_match($regex, $array) {
  222.  
  223. if ( !isset($regex) || !isset($array) || !is_string($regex) || !is_array($array)) {
  224. return false;
  225. }
  226. $regex = '/(.*)' . $regex . '(.*)/';
  227. foreach ($array as $v) {
  228. $match = preg_match($regex, $v);
  229. if ($match === 1) {
  230. return true;
  231. }
  232. }
  233. return false;
  234. }
  235.  
  236. function dumb_tables() {
  237. try {
  238.  
  239. $sql = 'SHOW TABLES;';
  240. if (!$res_tables = $this->mysqli->query($sql)) {
  241. throw new Exception("MySQL Error: " . $this->mysqli->error . 'SQL: '.$sql);
  242. }
  243.  
  244. while($row = $res_tables->fetch_array()) {
  245. $this->tables[] = $row[0];
  246. }
  247.  
  248. /* clean */
  249. $this->data_free($res_tables);
  250.  
  251. if( !$this->multi ) {
  252. $this->filename = $this->file_name();
  253. $this->file_open();
  254. $this->dumb_header();
  255. }
  256.  
  257. $start = empty($this->table_from);
  258. foreach($this->tables as $table) {
  259. if(!$start) {
  260. $start = strcmp($table, $this->table_from) >= 0;
  261. }
  262. if( $start ) {
  263. if( !empty($this->tables_en) ) {
  264. if($this->in_array_match($table, $this->tables_en)) {
  265. $this->dumb_table($table);
  266. }
  267. } else {
  268. $this->dumb_table($table);
  269. }
  270. }
  271. }
  272.  
  273. if( !$this->multi ) {
  274. $this->dumb_footer();
  275. $this->file_close();
  276. }
  277.  
  278. } catch (Exception $e) {
  279. echo $e->getMessage();
  280. }
  281. }
  282.  
  283. function clean_tables() {
  284. try {
  285.  
  286. foreach($this->tables_dis as $table) {
  287. // TRUNCATE TABLE books;
  288. // $this->mysqli
  289. $sql = "TRUNCATE TABLE $table;";
  290. // echo $sql;
  291. $this->mysqli->query($sql);
  292. }
  293.  
  294. } catch (Exception $e) {
  295. echo $e->getMessage();
  296. }
  297. }
  298.  
  299. function dumb_table($table = '') {
  300. if( $this->multi ) {
  301. $this->filename = $this->file_name($table);
  302. $this->file_open();
  303. $this->dumb_header();
  304. }
  305.  
  306. $this->table_create($table);
  307. if( !$this->in_array_match($table, $this->tables_dis) ) {
  308. $this->table_insert($table);
  309. }
  310.  
  311. if( $this->multi ) {
  312. $this->dumb_footer();
  313. $this->file_close();
  314. }
  315. }
  316.  
  317. function table_create($table='') {
  318. try {
  319.  
  320. $sql = 'SHOW CREATE TABLE '.$table;
  321. if (!$res_create = $this->mysqli->query($sql)) {
  322. throw new Exception("MySQL Error: " . $this->mysqli->error . 'SQL: '.$sql);
  323. }
  324. $row_create = $res_create->fetch_assoc();
  325.  
  326. /* clean */
  327. $this->data_free($res_create);
  328.  
  329. $this->file_write("-- " . PHP_EOL);
  330. $this->file_write("-- Table structure for table `". $table."`" . PHP_EOL);
  331. $this->file_write("-- " . PHP_EOL);
  332. $this->file_write(PHP_EOL);
  333. $this->file_write('DROP TABLE IF EXISTS `'.$table.'`;' . PHP_EOL);
  334. $this->file_write("/*!40101 SET @saved_cs_client = @@character_set_client */;" . PHP_EOL);
  335. $this->file_write("/*!40101 SET character_set_client = utf8 */;" . PHP_EOL);
  336.  
  337. $this->file_write($row_create['Create Table'].";" . PHP_EOL);
  338.  
  339. $this->file_write("/*!40101 SET character_set_client = @saved_cs_client */;" . PHP_EOL);
  340. $this->file_write(PHP_EOL);
  341.  
  342. unset($row_create);
  343.  
  344. } catch (Exception $e) {
  345. echo $e->getMessage();
  346. }
  347. }
  348.  
  349. function table_insert($table='') {
  350. $this->file_write("-- " . PHP_EOL);
  351. $this->file_write('-- Dump Data for `'. $table."`" . PHP_EOL);
  352. $this->file_write("-- " . PHP_EOL . PHP_EOL);
  353.  
  354. $this->file_write("LOCK TABLES `$table` WRITE;" . PHP_EOL);
  355. $this->file_write("/*!40000 ALTER TABLE `$table` DISABLE KEYS */;" . PHP_EOL);
  356.  
  357. try {
  358.  
  359. $sql = "SELECT * FROM `$table` LIMIT 1;";
  360. if (!$res_select = $this->mysqli->query($sql)) {
  361. throw new Exception("MySQL Error: " . $this->mysqli->error . 'SQL: '.$sql);
  362. }
  363.  
  364. $fields_info = $res_select->fetch_fields();
  365.  
  366. /* clean */
  367. $this->data_free($res_select);
  368.  
  369. $strFields = '';
  370. foreach ($fields_info as $field) {
  371. if ($strFields != '') $strFields .= ',';
  372. $strFields .= "`".$field->name."`";
  373. }
  374.  
  375. $sql = "SELECT * FROM `$table`";
  376. if(array_key_exists($table, $this->tables_limit)) {
  377. $where = $this->tables_limit[$table];
  378. $sql .= " $where";
  379. }
  380. $sql .= ";";
  381. if (!$res_select = $this->mysqli->query($sql)) {
  382. throw new Exception("MySQL Error: " . $this->mysqli->error . 'SQL: '.$sql);
  383. }
  384. $_ins_max = $res_select->num_rows;
  385. $_ins_number = 1;
  386. $_ins_length = 0;
  387. $_ins_str_length = 0;
  388. do {
  389. try {
  390. $values = $res_select->fetch_assoc();
  391. $strValues = '';
  392. foreach ($fields_info as $field) {
  393. if ($strValues != '') $strValues .= ',';
  394.  
  395. $val = $values[$field->name];
  396. if (is_null($val)) {
  397. $val = "NULL";
  398. } elseif (in_array($field->type, array_keys($this->mysql_data_type_hash['text'])) ) {
  399. $val = $this->sql_escape($val);
  400. $val = "'$val'";
  401. } elseif (is_numeric($val) && in_array($field->type, array_keys($this->mysql_data_type_hash['number'])) ) {
  402. $val = $val;
  403. } elseif (in_array($field->type, array_keys($this->mysql_data_type_hash['bool'])) ) {
  404. $val = "0x$val";
  405. } elseif (in_array($field->type, array_keys($this->mysql_data_type_hash['blob'])) ) {
  406. $val = "0x$val";
  407. } else {
  408. // $val = addslashes($val);
  409. // $val = preg_replace('/[^(\x20-\x7F)\x0A\x0D]*/','',$val);
  410. // $val = preg_replace('/[^(\x20-\x7F)\x0A]*/','',$val);
  411. // $val = str_replace('"', '\\"', $val);
  412. // $val = str_replace("'", '\\\'', $val);
  413. // $val = str_replace("\0", '\\0', $val);
  414. // $val = preg_replace("/\n/", "\\n", $val);
  415. // $val = preg_replace("/\r/", "\\r", $val);
  416. // $val = $this->mysqli->real_escape_string($val);
  417. $val = $this->sql_escape($val);
  418. $val = "'$val'";
  419. }
  420.  
  421. $strValues .= "$val";
  422.  
  423. }
  424.  
  425. if($strValues && !empty($strValues)) {
  426.  
  427. if ($_ins_length >= $this->ins_length || $_ins_str_length >= $this->ins_length * 50) {
  428. $_ins_length = 0;
  429. $_ins_str_length = 0;
  430. $this->file_write(";" . PHP_EOL);
  431. $_out = "INSERT IGNORE INTO `$table` ($strFields) VALUES ($strValues)";
  432. $this->file_write($_out);
  433. $_ins_str_length += strlen($_out);
  434. } elseif ($_ins_length == 0) {
  435. $_out = "INSERT IGNORE INTO `$table` ($strFields) VALUES ($strValues)";
  436. $this->file_write($_out);
  437. $_ins_str_length += strlen($_out);
  438. } else {
  439. $_out = ",($strValues)";
  440. $this->file_write($_out);
  441. $_ins_str_length += strlen($_out);
  442. }
  443.  
  444. }
  445. } catch (Exception $e) {
  446. echo $e->getMessage();
  447. }
  448. $_ins_length += 1;
  449. $_ins_number += 1;
  450. } while ($_ins_number <= $_ins_max);
  451.  
  452. /* clean */
  453. $this->data_free($res_select);
  454.  
  455. if($_ins_length >= 1) {
  456. $this->file_write(";" . PHP_EOL);
  457. }
  458.  
  459. } catch (Exception $e) {
  460. echo $e->getMessage();
  461. }
  462.  
  463. $this->file_write("/*!40000 ALTER TABLE `$table` ENABLE KEYS */;" . PHP_EOL);
  464. $this->file_write("UNLOCK TABLES;" . PHP_EOL);
  465.  
  466. /**-------------------------------------------------------------*/
  467.  
  468. $this->file_write(PHP_EOL);
  469. }
  470.  
  471. function dumb_header() {
  472. $this->file_write("-- [DB] SQL Dump" . PHP_EOL);
  473. $this->file_write("-- " . PHP_EOL);
  474. $this->file_write("-- Server version:".$this->mysqli->server_info . PHP_EOL);
  475. $this->file_write("-- Generated: ".date('Y-m-d h:i:s') . PHP_EOL);
  476. $this->file_write("-- " . PHP_EOL);
  477. $this->file_write('-- Current PHP version: '.phpversion() . PHP_EOL);
  478. $this->file_write('-- Host: '. $this->host . PHP_EOL);
  479. $this->file_write('-- Database:' . $this->name . PHP_EOL);
  480. $this->file_write("-- ------------------------------------------------------" . PHP_EOL . PHP_EOL);
  481.  
  482. $this->file_write("/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;" . PHP_EOL);
  483. $this->file_write("/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;" . PHP_EOL);
  484. $this->file_write("/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;" . PHP_EOL);
  485. $this->file_write("/*!40101 SET NAMES utf8 */;" . PHP_EOL);
  486. $this->file_write("/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;" . PHP_EOL);
  487. $this->file_write("/*!40103 SET TIME_ZONE='+00:00' */;" . PHP_EOL);
  488. $this->file_write("/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;" . PHP_EOL);
  489. $this->file_write("/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;" . PHP_EOL);
  490. $this->file_write("/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;" . PHP_EOL);
  491. $this->file_write("/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;" . PHP_EOL);
  492. $this->file_write(PHP_EOL . PHP_EOL);
  493. }
  494.  
  495. function dumb_footer() {
  496. $this->file_write(PHP_EOL . PHP_EOL);
  497. $this->file_write("/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;" . PHP_EOL . PHP_EOL);
  498. $this->file_write("/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;" . PHP_EOL);
  499. $this->file_write("/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;" . PHP_EOL);
  500. $this->file_write("/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;" . PHP_EOL);
  501. $this->file_write("/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;" . PHP_EOL);
  502. $this->file_write("/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;" . PHP_EOL);
  503. $this->file_write("/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;" . PHP_EOL);
  504. $this->file_write("/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;" . PHP_EOL);
  505. }
  506.  
  507. function data_connect() {
  508. try {
  509. if( ! function_exists('mysqli_connect') ) {
  510. throw new Exception(' This scripts need mysql extension to be running properly ! please resolve!!');
  511. }
  512.  
  513. $this->mysqli = new mysqli($this->host, $this->user, $this->pass, $this->name);
  514. if ($this->mysqli->connect_errno) {
  515. throw new Exception("Failed to connect to MySQL: " . $this->mysqli->connect_error);
  516. }
  517.  
  518. $this->mysqli->set_charset("utf8");
  519. } catch (Exception $e) {
  520. echo $e->getMessage();
  521. }
  522. }
  523.  
  524. function data_close() {
  525. try {
  526. $this->mysqli->close();
  527. } catch (Exception $e) {
  528. echo $e->getMessage();
  529. }
  530. }
  531.  
  532. function data_free(&$res) {
  533. try {
  534. $res->free_result();
  535. // $res->free();
  536. // $res->close();
  537. unset($res);
  538. } catch (Exception $e) {
  539. echo $e->getMessage();
  540. }
  541. }
  542.  
  543. function file_name($table='') {
  544. if (!file_exists($this->dir . DIRECTORY_SEPARATOR)) {
  545. mkdir($this->dir . DIRECTORY_SEPARATOR, 0777, true);
  546. }
  547. if( !empty($table) ) {
  548. if (!file_exists($this->dir . DIRECTORY_SEPARATOR . $this->name . DIRECTORY_SEPARATOR)) {
  549. mkdir($this->dir . DIRECTORY_SEPARATOR . $this->name . DIRECTORY_SEPARATOR, 0777, true);
  550. }
  551. $this->filename = sprintf("%s%s%s%s%s_%s_%s.sql", $this->dir, DIRECTORY_SEPARATOR, $this->name, DIRECTORY_SEPARATOR, $this->name, $table, date('Y-m-d--H-i-s'));
  552. return $this->filename;
  553. } else {
  554. $this->filename = sprintf("%s%s%s_%s.sql", $this->dir, DIRECTORY_SEPARATOR, $this->name, date('Y-m-d--H-i-s'));
  555. return $this->filename;
  556. }
  557. }
  558.  
  559. function file_open() {
  560. if($this->sql_nomal) {
  561. $this->handle = fopen($this->filename, 'w');
  562. stream_set_blocking($this->handle, 0);
  563. }
  564. if( $this->sql_gz ) {
  565. $this->handle_gz = gzopen("$this->filename.gz", 'w9');
  566. }
  567. ob_start();
  568. }
  569.  
  570. function file_write($buffer = '') {
  571. usleep(50);
  572. if($this->sql_nomal) {
  573. if (flock($this->handle, LOCK_EX)) {
  574. fwrite($this->handle, $buffer);
  575. }
  576. flock($this->handle, LOCK_UN);
  577. }
  578. if( $this->sql_gz ) {
  579. gzwrite($this->handle_gz, $buffer);
  580. }
  581. return;
  582. }
  583.  
  584. function file_close() {
  585. $this->file_write(ob_get_clean());
  586. if($this->sql_nomal) {
  587. fclose($this->handle);
  588. }
  589. if( $this->sql_gz ) {
  590. gzclose($this->handle_gz);
  591. }
  592. }
  593.  
  594. function file_delete($path = '') {
  595. if (is_dir($path) === true) {
  596. $files = array_diff(scandir($path), array('.', '..'));
  597.  
  598. foreach ($files as $file) {
  599. $this->file_delete(realpath($path) . DIRECTORY_SEPARATOR . $file);
  600. }
  601.  
  602. return rmdir($path);
  603. }
  604.  
  605. else if (is_file($path) === true) {
  606. return unlink($path);
  607. }
  608.  
  609. return false;
  610. }
  611.  
  612. function file_chmod ( $path = '.', $permission = 0777 ) {
  613.  
  614. $ignore = array( 'cgi-bin', '.', '..' );
  615.  
  616. if (is_dir($path) === true) {
  617. $files = array_diff(scandir($path), $ignore);
  618. if (@chmod($path, $permission)) {
  619. // echo 'Folder permissions changed';
  620. } else {
  621. // echo 'Failed to change permissions';
  622. }
  623.  
  624. foreach ($files as $file) {
  625. $this->file_chmod(realpath($path) . DIRECTORY_SEPARATOR . $file);
  626. }
  627. }
  628.  
  629. else if (is_file($path) === true) {
  630. chmod($path, $permission);
  631. if (@chmod($path, $permission)) {
  632. // echo 'Folder permissions changed';
  633. } else {
  634. // echo 'Failed to change permissions';
  635. }
  636. }
  637.  
  638. return false;
  639. }
  640.  
  641. function sql_escape($sql) {
  642. if(@isset($sql)) {
  643. // $sql = @trim($sql);
  644. // $sql = @addslashes($sql);
  645. // if(get_magic_quotes_gpc()) {
  646. // $sql = @stripslashes($sql);
  647. // }
  648. // $sql = str_replace('www.wemakefootballers.com', 'local.dev/wmf', $sql);
  649. // $sql = str_replace('int.evolveretail.com/~', 'local.dev/', $sql);
  650. $sql = $this->mysqli->real_escape_string($sql);
  651. } else {
  652. $sql = 'NULL';
  653. }
  654. return $sql;
  655. }
  656.  
  657. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement