File manager - Edit - /home/justdoit/.trash/lib.php
Back
<?php /** * install/lib.php — pure helpers used by the setup wizard. * Kept separate so they can be unit-tested without running the UI. */ function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); } function write_file($path, $contents){ return @file_put_contents($path, $contents) !== false; } function db_credentials_php($d){ return "<?php\n// Generated by the installer.\nreturn " . var_export([ 'host' => $d['host'], 'name' => $d['name'], 'user' => $d['user'], 'pass' => $d['pass'], ], true) . ";\n"; } function mail_config_php($m){ $L = function($k,$v){ return " define(" . var_export($k,true) . ", " . var_export($v,true) . ");\n"; }; return "<?php\n// Generated by the installer.\nif (!defined('SMTP_HOST')) {\n" . $L('SMTP_HOST',$m['host']) . $L('SMTP_PORT',(int)$m['port']) . $L('SMTP_SECURE',$m['secure']) . $L('SMTP_USERNAME',$m['username']) . $L('SMTP_PASSWORD',$m['password']) . $L('SMTP_FROM_EMAIL',$m['from_email']) . $L('SMTP_FROM_NAME',$m['from_name']) . $L('SMTP_REPLY_EMAIL',$m['reply_email']) . "}\n"; } function site_config_php($s){ $L = function($k,$v){ return " define(" . var_export($k,true) . ", " . var_export($v,true) . ");\n"; }; return "<?php\n// Generated by the installer.\nif (!defined('SITE_NAME')) {\n" . $L('SITE_NAME',$s['name']) . $L('SUPPORT_EMAIL',$s['email']) . $L('SUPPORT_PHONE',$s['phone']) . "}\n"; } /* Quote-aware SQL splitter so phpMyAdmin dumps import reliably */ function split_sql($sql){ $out = []; $buf = ''; $inS = false; $inD = false; $n = strlen($sql); for ($i = 0; $i < $n; $i++){ $c = $sql[$i]; $buf .= $c; if ($c === "'" && !$inD){ $bs=0;$j=$i-1; while($j>=0 && $sql[$j]==='\\'){$bs++;$j--;} if($bs%2==0)$inS=!$inS; } elseif ($c === '"' && !$inS){ $bs=0;$j=$i-1; while($j>=0 && $sql[$j]==='\\'){$bs++;$j--;} if($bs%2==0)$inD=!$inD; } elseif ($c === ';' && !$inS && !$inD){ $out[] = $buf; $buf=''; } } if (trim($buf) !== '') $out[] = $buf; return $out; } /* Run a full SQL dump through a PDO connection. Returns the statement count. */ function run_sql_dump(PDO $pdo, $sql){ // Strip full-line comments first. In phpMyAdmin dumps every statement is // preceded by "-- ..." comment lines; if we don't remove them the comment // gets glued to the statement and the whole thing looks like a comment. $lines = preg_split('/\r\n|\r|\n/', $sql); $kept = []; foreach ($lines as $ln){ $t = ltrim($ln); if ($t !== '' && (strpos($t, '--') === 0 || $t[0] === '#')) continue; // line comment $kept[] = $ln; } $sql = implode("\n", $kept); $count = 0; foreach (split_sql($sql) as $stmt){ if (trim($stmt) === '') continue; $pdo->exec($stmt); $count++; } return $count; } function rrmdir($dir){ if (!is_dir($dir)) return; foreach (array_diff(scandir($dir), ['.','..']) as $f){ $p = $dir . '/' . $f; is_dir($p) ? rrmdir($p) : @unlink($p); } @rmdir($dir); }
| ver. 1.4 |
Github
|
.
| PHP 7.0.33 | Generation time: 1.01 |
proxy
|
phpinfo
|
Settings