123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- <?php
- class Afunc extends Controller{
- public static function resimgoster($icerik) {
- $resimbir = '';
- ob_start();
- ob_end_clean();
- $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', htmlspecialchars_decode($icerik), $matches);
- if($output){$resimbir = $matches['1']['0'] ;}
- if(empty($resimbir)){ //Eğer resim eklememişseniz
- $resimbir = baseUrl().'uploads/images/eagle.png';
- }
- return $resimbir;
- }//resimgoster
- public static function kelimedenbol($metin, $karaktersayisi){
- $icerik = htmlspecialchars_decode($metin);
- $icerik = strip_tags($icerik);
- $icerik = str_replace(array("\t","\r","\n"), ' ',$icerik);
- $icerik_bol = explode(' ', $icerik); // metini bosluklara gore bolduk
- $icerik = '';
- for($i = 0; $i < count($icerik_bol); $i++) {
- if ($icerik_bol[$i] != '') // veri yok mu? Atla, varsa ekle
- $icerik .= trim($icerik_bol[$i]).' ';
- }
- if( preg_match('/(.*?)\s/i', substr($icerik, $karaktersayisi), $dizi) )
- return $icerik = substr($icerik, 0, $karaktersayisi+strlen($dizi[0])).'...';
- } //kelimedenbol
- public static function decode($deger){ echo htmlspecialchars_decode($deger);}//decode
- /* sonsuz menu fonksiyonu */
- public static function katmenu($parent = '0') {
- $sql = DB::get('kategori')->result();
- foreach($sql AS $key){
- $diziler[$key->id] = [
- 'kat_seo' => $key->kat_seo,
- 'kategori' => $key->kategori,
- 'ust_kategori_id' => $key->ust_kategori_id,
- 'id' => $key->id
- ];
- }
- $has_childs = false;
- foreach($diziler as $key => $value) {
- if ($value['ust_kategori_id'] == $parent) {
- if ($has_childs === false){
- $has_childs = true;
- echo '<ul>';
- }
- echo '<li><a href="'.baseUrl().'kategori/'.$value['id'].'-'.$value['kat_seo'].'.html">'.$value['kategori'].'</a>';
- Afunc::katmenu($key);
- echo '</li>';
- }
- }
- if ($has_childs === true) echo "</ul>";
- }//katmenu
- public static function breadcrumbs($text = 'Buradasınız: ', $sep = ' » ', $home = 'Anasayfa') {
- $bc = '<div xmlns:v="http://rdf.data-vocabulary.org/#" id="crums">'.$text;
- $site = 'http://'.$_SERVER['HTTP_HOST'];
- $crumbs = array_filter( explode("/",$_SERVER["REQUEST_URI"]) );
- $bc .= '<span typeof="v:Breadcrumb"><a href="'.$site.'" rel="v:url" property="v:title">'.$home.'</a>'.$sep.'</span>';
- $nm = count($crumbs);
- $i = 1;
- foreach($crumbs as $crumb){
- $link = ucfirst( str_replace( array(".html","-","_"), array(""," "," ") ,$crumb) );
- $sep = $i==$nm?'':$sep;
- $site .= '/'.$crumb;
- $bc .= '<span typeof="v:Breadcrumb"><a href="'.$site.'" rel="v:url" property="v:title">'.$link.'</a>'.$sep.'</span>';
- $i++;
- }
- $bc .= '</div>';
- return $bc;
- }//breadcrumbs
- public static function catname($d = '',$seo = ''){
- if($seo){
- return DB::select('kat_seo')->where('id',$d)->get('kategori')->value();
- }else{
- return DB::select('kategori')->where('id',$d)->get('kategori')->value();
- }
- }
- public static function tcevir($tarih) {
- $bosluk = explode(' ', $tarih);
- $tr = explode("-",$bosluk['0']);
- $tarih1 = $tr['2']."-".$tr['1']."-".$tr['0'];
- return $tarih1;
- } //tcevir
- public static function jalert($p){echo '<script>alert("'.$p.'")</script>';}//jalert
- public static function git($link = ''){
- if($link){
- echo '<meta http-equiv="refresh" content="0; url='.baseUrl().'/'.$link.'">';
- }else{
- echo '<meta http-equiv="refresh" content="0; url='.baseUrl().'">';
- }
- }//git
-
- public static function sifreuret($uzunluk){
- $pwd = '';
- if(!is_numeric($uzunluk) || $uzunluk <= 0){$uzunluk = 8; }
- if($uzunluk > 32){$uzunluk = 32;}
- $karakter = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
- mt_srand(microtime() * 1000000);
- for($i = 0; $i < $uzunluk; $i++){
- $key = mt_rand(0,strlen($karakter)-1);
- $pwd = $pwd . $karakter{$key};
- }
- for($i = 0; $i < $uzunluk; $i++){
- $key1 = mt_rand(0,strlen($pwd)-1);
- $key2 = mt_rand(0,strlen($pwd)-1);
- $tmp = $pwd{$key1};
- $pwd{$key1} = $pwd{$key2};
- $pwd{$key2} = $tmp;
- }
- return $pwd;
- }// şifreüret
- }
|