This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function table_exists($table) { | |
global $db; | |
$sql = "SHOW TABLES LIKE '$table' "; | |
$result = $db->query($sql); | |
$num = 0; | |
$num = mysqli_num_rows($result); | |
if($num > 0) { | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
var imageList=[<?php | |
$dir='uploads'; | |
$files = scandir($dir); | |
foreach((array)$files as $file){ | |
if($file=='.'||$file=='..') continue; | |
$fileList[]=$file; | |
} | |
echo "'".implode("','", $fileList)."'"; | |
?>]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<form action="upload_img.php" method="post" enctype="multipart/form-data"> | |
<input type="file" name="imgupload" /><br> | |
<input type="submit" value="Upload to Imgur" /> | |
</form> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* list db structure */ | |
function show_all_db() { | |
global $db; | |
global $db_name; | |
$out = ""; | |
$sql = "SELECT table_name, column_name | |
FROM INFORMATION_SCHEMA.COLUMNS | |
WHERE table_schema = '$db_name' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function time_diff_days($your_date) { | |
$now = time(); // or your date as well | |
$your_date = strtotime($your_date); | |
$datediff = $now - $your_date; | |
return floor($datediff/(60*60*24)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function rand_color() { | |
return '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function httpPost($url,$params) | |
{ | |
$postData = ''; | |
//create name value pairs seperated by & | |
foreach($params as $k => $v) | |
{ | |
$postData .= $k . '='.$v.'&'; | |
} | |
rtrim($postData, '&'); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// find links from plain text and link them. | |
function find_links($text) { | |
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; // The Regular Expression filter | |
if(preg_match($reg_exUrl, $text, $url)) { // Check if there is a url in the text | |
$url[0] = rtrim($url[0], ','); // remove trailing comma if there is one. | |
$text = preg_replace($reg_exUrl, "<a href=".$url[0]." target='_blank'>{$url[0]}</a> ", $text); // make the urls hyper links | |
return $text; | |
} else { | |
return $text; // if no urls in the text just return the text | |
} |
OlderNewer