$data = explode( ',', $base64_string );
// we could add validation here with ensuring count( $data ) > 1
fwrite( $ifp, base64_decode( $data[ 1 ] ) );
// clean up the file resource
fclose( $ifp );
return $output_file;
}
function admin_delete($id) {
?>
level=="Admin") {
?>
where("slug",$slug)->first("title");
if($sorgu) {
return $sorgu->title;
} else {
return $slug;
}
}
function encoder($icerik) {
// $icerik = utf8_encode($icerik);
$icerik = strtr($icerik, array(
'•' => '•',
'“' => '“',
'â€' => '”',
'‘' => '‘',
'’' => '’',
'ݾ' => 'İ',
'Ý' => 'İ',
'İ' => 'İ',
'Ã' => 'İ',
'‹' => 'İ',
'Ý' => 'İ',
'ý' => 'ı',
'ı' => 'ı',
'±' => 'ı',
'ý' => 'ı',
'Û' => 'ı',
'›' => 'ı',
'ý' => 'ı',
'Þ' => 'Ş',
'Åž' => 'Ş',
'ÅŸ' => 'Ş',
'åÿ' => 'Ş',
'Þ' => 'Ş',
'þ' => 'ş',
'Å?' => 'ş',
'ÅŸ' => 'ş',
'þ' => 'ş',
'Ð' => 'Ğ',
'Äž' => 'Ğ',
'ð' => 'ğ',
'Ä?' => 'ğ',
'ÄŸ' => 'ğ',
'ð' => 'ğ',
'Ç' => 'Ç',
'Ã?' => 'Ç',
'Ç' => 'Ç',
'ç' => 'ç',
'ç' => 'ç',
'Ö' => 'Ö',
'Ö' => 'Ö',
'ö' => 'ö',
'ö' => 'ö',
'Ü' => 'Ü',
'Ü' => 'Ü',
'ü' => 'ü',
'ã¼' => 'ü',
'ü' => 'ü',
'ü' => 'ü',
));
return $icerik;
}
function trk($icerik) {
// $icerik = iconv("ISO-8859-1", "UTF-8//TRANSLIT", $icerik);
$encode = mb_detect_encoding($icerik);
//echo $encode;
// $icerik = mb_convert_encoding($icerik, "windows-1254", $encode);
$icerik = @iconv('windows-1254','UTF-8',$icerik);
$icerik = encoder($icerik);
return $icerik;
}
function zf($d2){
$d1 = date('Y-m-d H:i:s');
//$d1= date('Y-m-d H:i:s', strtotime($d1. "$zaman_dilimi hour"));
//e($d1);
if(!is_int($d1)) $d1=strtotime($d1);
if(!is_int($d2)) $d2=strtotime($d2);
$d=abs($d1-$d2);
if ($d1-$d2<0) {
$ifade = "sonra";
} else {
$ifade = "önce";
}
$once = " ";
if($d>=(60*60*24*365)) $sonuc = $once . floor($d/(60*60*24*365)) . " yıl $ifade";
else if($d>=(60*60*24*30)) $sonuc = $once . floor($d/(60*60*24*30)) . " ay $ifade";
else if($d>=(60*60*24*7)) $sonuc = $once . floor($d/(60*60*24*7)) . " hafta $ifade";
else if($d>=(60*60*24)) $sonuc = $once . floor($d/(60*60*24)) . " gün $ifade";
else if($d>=(60*60)) $sonuc = $once . floor($d/(60*60)) . " saat $ifade";
else if($d>=60) $sonuc = $once . floor($d/60) . " dakika $ifade";
else $sonuc = "Az $ifade";
return $sonuc;
}
function cfg($slug) {
$c = db("contents")
->Where("kid","configuration-".$slug)
->get();
$cikti = array();
foreach($c AS $s) {
array_push($cikti,$s->title);
}
return $cikti;
}
function logo($size="128",$style="") {
?>
" width="" style=" width: px;" alt="">

" width="48" style=" width: 40px;
vertical-align: middle" alt="">
where($col,$val)->get($col);
return count($sorgu);
}
function variable($title) {
$s = db("contents")->where("title",$title)->first();
return $s->html;
}
function df($date,$format="d.m.Y") {
return date($format,strtotime($date));
}
function mailSend($to="",$subject="",$html="") {
//VBgDMfu6L5kksh noreply@truncgil.com
$data = array(
'html'=>$html,
"subject" => $subject,
"to" => $to
);
$title = env("APP_NAME");
try {
Mail::send("mail-template", $data, function($message) use($to, $subject,$title){
$message->from(env("MAIL_USERNAME"), $title);
$message->to($to);
$message->subject($subject);
});
} catch (\Throwable $th) {
// dump($th);
}
}
function alert($text,$type="success") {
?>
country == "United States") {
$j->country = "USA";
}
return $j;
}
function ed($text,$elsetext) {
if($text=="") return $elsetext;
else return $text;
}
function sales_status($y="") {
if($y=="") {
return explode(",","Under Negotiate,Due to Payment,Payment Complete,Booking,Shipment,Sold");
}
}
function status_color($y) {
$color = array("danger","warning","success");
return $color[$y];
}
function picture($f,$type="large") {
$f = str_replace("storage/app/files/","",$f);
$f = url("cache/$type/".$f);
return $f;
}
function picture2($f,$size,$storage=1) {
if($storage==1) {
$f = "storage/app/files/$f";
}
$f = url("r.php?p=$f&w=$size");
return $f;
}
function picture3($f,$size) {
$f = url("r.php?p=$f&w=$size");
return $f;
}
function price($price,$type="¥") {
$price = str_replace(",","",$price);
$price = str_replace(".","",$price);
$price = str_replace("$","",$price);
$price = str_replace(" ","",$price);
// echo $price;
$price = @number_format($price, 0, ',', '.');
return "$type $price";
}
function nf($price,$type="KG") {
/*
$price = str_replace(",","",$price);
$price = str_replace(".","",$price);
$price = str_replace("$","",$price);
$price = str_replace(" ","",$price);
*/
// echo $price;
$price = @number_format($price, 2, ',', '.');
return "$price $type";
}
function clean_price($price) {
$price = str_replace(",","",$price);
$price = str_replace(".","",$price);
$price = str_replace("$","",$price);
$price = str_replace("¥","",$price);
$price = str_replace("€","",$price);
$price = str_replace(" ","",$price);
// echo $price;
// $price = @number_format($price, 0, ',', '.');
return (float) $price;
}
function price2($price,$type="¥") {
//$price = str_replace(".","",$price);
$price = @number_format($price, 0, ',', '.');
return "$type $price";
}
function mile($mile,$type="KM") {
$type = strtoupper($type);
$mile = str_replace(".","",$mile);
$mile = @number_format($mile, 0, ',', '.');
return "$mile $type";
}
function currency() {
return explode(",","Dolar,Euro");
}
function simdi() {
return date("Y-m-d H:i:s");
}
function fob($price) {
$fob = str_replace("$ ","",$price);
$fob = str_replace(",","",$fob);
return $fob;
}
function curr($type) {
$kur = cfg3("currency-settings");
return $kur[$type];
}
function cfg2($slug) {
$c = db("contents")
->Where("kid","configuration-".$slug)
->get();
$cikti = array();
foreach($c AS $s) {
array_push($cikti,$s);
}
return $cikti;
}
function cfg3($slug)
{
$c = Contents::where("slug", $slug)->orWhere("type", $slug)->orderBy("id","DESC")->first();
if($c) {
$c = json_decode($c->json,true);
} else {
$c = array();
}
return $c;
}
function pic($pic,$type) {
$pic = str_replace("storage/app/files/","",$pic);
return url("cache/$type/$pic");
}
function product($c) {
//bu fonk. bir ürün blok tasarımını örnekler
?>
{title}
Style: VA33TXRJ5
The Vans All-Weather MTE Collection features footwear and apparel designed to withstand the elements whilst still looking cool.
where("kid", "configuration-planning-column-mapping")
->where("title", $title)
->first();
if ($sorgu) {
if ($sorgu->title2 != "") {
return $sorgu->title2;
} else {
return $title;
}
} else {
return $title;
}
}
function is_json($string)
{
json_decode($string);
return (json_last_error() == JSON_ERROR_NONE);
}
function whereJ($db, $col, $isaret, $val, $fonk = "")
{
$db = $db->whereRaw("$fonk(JSON_UNQUOTE(json_extract(json, '$.\"$col\"'))) $isaret $val");
return $db;
}
function orWhereJ($db, $col, $isaret, $val, $fonk = "")
{
$db = $db->orWhereRaw("$fonk(JSON_UNQUOTE(json_extract(json, '$.\"$col\"'))) $isaret $val");
return $db;
}
function tirnakli($text) {
return "'$text'";
}
function chartsByData($db,$labelGroup,$title="",$type="bar",$colorItem="1",$columnSize="col-md-6") {
$array = array();
$db = db($db)->get();
foreach($db AS $d) {
if($labelGroup=="date") {
$label = date("d.m.Y",strtotime($d->created_at));
} else {
$label = $d->{$labelGroup};
}
if(!isset($array[$label])) $array[$label] = 0;
$array[$label]++;
}
$values = implode(",",$array);
$labels = implode_key(",",$array);
?>
getClientOriginalExtension();
if($name=="") {
$name = str_slug($request[$file]->getClientOriginalName()) . "." . $ext;
} else {
$name = $name . "." . $ext;
}
$path = $request[$file]->storeAs("files/$folder", $name);
return "storage/documents/$path";
} else {
return null;
}
}
function uploadDocument($file, $folder = "", $name = "")
{
$request = \Request::all();
if(isset($request[$file])) {
$ext = $request[$file]->getClientOriginalExtension();
if($name=="") {
$name = str_slug($request[$file]->getClientOriginalName()) . "." . $ext;
} else {
$name = $name . "." . $ext;
}
// Dosyayı Storage::put ile kaydet
$path = Storage::putFileAs($folder, $request[$file], $name);
return $path;
} else {
return null;
}
}
// Loglama fonksiyonu
function logAction($message) {
$logMessage = $message;
Log::info($logMessage); // Log dosyasına yaz
}
function upload2($file, $folder = "")
{
$u = u();
$dizin = str_slug($u->name." ". $u->surname);
$request = \Request::all();
@mkdir("storage/app/$dizin/$folder",true);
$ext = $request[$file]->getClientOriginalExtension();
$name = str_slug($request[$file]->getClientOriginalName());
$path = $request[$file]->storeAs("files/$dizin/$folder", $name.".".$ext);
return "storage/app/$path";
}
function file_get_contents_utf8($fn) {
$content = file_get_contents($fn);
return iconv("ISO-8859-1","UTF-8",$content);
}
function correct_encoding($text) {
$current_encoding = mb_detect_encoding($text, 'auto');
$text = iconv($current_encoding, 'UTF-8', $text);
return $text;
}
function varmi($dizi)
{
if (count($dizi) > 0) {
return true;
} else {
return false;
}
}
function vehicles() {
$s = db("vehicles");
$s = $s->where("y","1");
$s = $s->take(10);
return $s;
}
function slugtotitle($slug)
{
$slug = str_replace("-", " ", $slug);
$slug = ucwords($slug);
return $slug;
}
function seri()
{
?>
orWhere("id", $slug)->first();
return $c;
}
function contents($type)
{
return db("contents")
->where("kid", $type)
->orWhere("type", $type)
// ->orWhere("title",$type)
->get();
}
function contents2($type)
{
return db("contents")
->where("kid", $type)
->orWhere("type", $type);
// ->orWhere("title",$type)
}
function kd()
{
return 0;
}
function user() {
global $_SESSION;
oturumAc();
if(oturumisset("uid")) {
$u = (Array) db("users")->where("id",oturum("uid"))->first();
unset($u['id']);
unset($u['password']);
unset($u['password_hash']);
unset($u['recover']);
unset($u['remember_token']);
unset($u['permissions']);
unset($u['created_at']);
unset($u['updated_at']);
return $u;
} else {
return false;
}
}
function usersArray() {
$users = db("users")
->get();
$users = dbArray($users,"id");
return $users;
}
function users($level)
{
return User::where("level", $level)->get();
}
function who($uid)
{
return User::where("id", $uid)->first();
}
function ksorgu()
{
return 0;
}
function createTranslate($key) {
if($key!="") {
$translate = db("translate")->where([
'dil'=> App::getLocale(),
'icerik' => $key
])->first();
if(is_null($translate)) {
db("translate")->insert([
'dil'=> App::getLocale(),
'icerik' => $key
]);
}
}
}
function e2($text, $array = [])
{
if(oturumisset("create-translate")) {
createTranslate($text);
}
return __($text, $array);
}
function set($text)
{
echo __($text);
}
function set_return($text)
{
return __($text);
}
function permission() {
oturumAc();
if(!oturumisset("uid")) {
echo("Bu sayfayı görmek için yetkiniz bulunmamaktadır");
exit();
}
}
function u()
{
oturumAc();
// Try to get user from session first
$sessionKey = 'cached_user';
$cachedUser = Session::get($sessionKey);
if ($cachedUser) {
return $cachedUser;
}
if(Auth::check()) {
$u = Auth::user();
$alias = alias_to_ids($u->alias);
$u['alias_ids'] = $alias;
// Store user data in session
Session::put($sessionKey, $u);
return $u;
} elseif(oturumisset("uid")) {
$uid = db("users")->where("id",oturum("uid"))->first();
// Store user data in session
Session::put($sessionKey, $uid);
return $uid;
}
return null;
}
function u2($id)
{
$uid = db("users")->where("id",$id)->first();
return $uid;
}
function alias_to_ids($alias) { //aynı etki alanına sahip kullanıcıların id listesini döndürür.
$sorgu = db("users")->where("alias",$alias)->get();
$ids = array();
foreach($sorgu AS $s) {
array_push($ids,$s->id);
}
return $ids;
}
function ekle($dizi, $tablo = "contents")
{
oturumAc();
$uid = "";
if(isset(u()->id)) {
$uid = u()->id;
}
if($uid=="") $uid = oturum("uid");
$dizi['created_at'] = date("Y-m-d H:i:s");
$dizi['uid'] = $uid;
if($dizi['uid']=="") unset($dizi['uid']);
//print_r($dizi);
return DB::table($tablo)->insertGetId($dizi);
}
function ekle2($dizi, $tablo = "contents") //uid siz ekleme yapar
{
oturumAc();
$dizi['created_at'] = date("Y-m-d H:i:s");
// $dizi['uid'] = "";
return DB::table($tablo)->insertGetId($dizi);
}
function login() {
oturumAc();
global $_SESSION;
if(oturumisset("uid")) {
return true;
} else {
return false;
}
}
function kripto($text) {
return Hash::make($text);
}
function guncelle($dizi, $tablo = "contents")
{
oturumAc();
$dizi['updated_at'] = date("Y-m-d H:i:s");
$dizi['uid'] = u()->id;
// print_r($dizi);
return DB::table($tablo)->update($dizi);
}
function dbFirst($tablo, $id)
{
return $s = DB::table($tablo)->where("id", $id)->first();
}
function db($tablo)
{
$s = DB::table($tablo);
return $s;
}
function db2($tablo)
{
$u = u();
// $alias_id = implode(",",$u->alias_ids);
$s = DB::table($tablo)->whereIn("uid",$u->alias_ids);
return $s;
}
function sorgu($tablo, $where = "", $order = "")
{
$s = DB::table($tablo);
if (strpos("%", $where) !== false) {
$s = $s->where("json", "like", "$where");
} else {
if ($where != "") {
$where = explode(",", $where);
foreach ($where as $w) {
$w2 = explode("=", $w);
if (count($w2) > 1) {
$s = $s->whereJsonContains("json->" . $w2[0], $w2[1]);
}
$w2 = explode("%", $w);
if (count($w2) > 1) {
$s = $s->where("json", "like", $w2[1]);
}
}
}
}
if ($order != "") $s = $s->orderByRaw($order);
$cache = array();
$sorgu = $s->simplePaginate(15);
$col = array();
$row = array();
$cache['col'] = array();
$cache['row'] = array();
$cache['links'] = "";
if (count($sorgu) > 0) {
foreach ($sorgu as $s) {
$j = json_decode($s->json);
$j->id = $s->id;
$j->Create_Date = $s->created_at;
unset($j->_token);
array_push($cache, $j);
}
foreach ($cache as $a => $d) {
array_push($row, $d);
}
foreach ($cache[0] as $a => $d) {
array_push($col, str_replace("_", " ", $a));
}
$cache['col'] = $col;
$cache['row'] = $row;
$cache['row'] = array_filter($cache['row']);
$cache['links'] = $sorgu->links();
$cache['table'] = $tablo;
}
return $cache;
}
function dbArray($db,$key) {
$dizi = array();
foreach($db AS $d) {
$dizi[$d->$key] = $d;
}
return $dizi;
}
function table_to_array($table,$key="id") {
$dizi = array();
$db = db($table)->get();
foreach($db AS $d) {
$dizi[$d->$key] = $d;
}
return $dizi;
}
function table_to_array2($table,$key="id") {
$dizi = array();
if($table=="users") {
$db = db($table)->where("alias",u()->alias)->get();
} else {
$db = db2($table)->get();
}
foreach($db AS $d) {
$dizi[$d->$key] = $d;
}
return $dizi;
}
function contents_to_array($type,$key="id") {
$dizi = array();
$db = db("contents")->where("type",$type)
->whereNotNull("title")
->get();
foreach($db AS $d) {
$dizi[$d->$key] = $d;
}
return $dizi;
}
function dbJson($db, $tablo = "")
{ //db oluşturulmuş bir sorguyu json cache çıktısını verir.
$cache = array();
$sorgu = $db;
$col = array();
$row = array();
$cache['col'] = array();
$cache['row'] = array();
$cache['links'] = "";
if (count($sorgu) > 0) {
foreach ($sorgu as $s) {
$j = json_decode($s->json);
$j->id = $s->id;
$j->Create_Date = $s->created_at;
unset($j->_token);
array_push($cache, $j);
}
foreach ($cache as $a => $d) {
array_push($row, $d);
}
foreach ($cache[0] as $a => $d) {
array_push($col, str_replace("_", " ", $a));
}
$cache['col'] = $col;
$cache['row'] = $row;
$cache['row'] = array_filter($cache['row']);
$cache['links'] = $sorgu->links();
$cache['table'] = $tablo;
}
return $cache;
}
function bilgi($text,$type="success", $array = [])
{
if($type == "danger") $type = "error";
?>
Swal.fire(
'',
'',
''
)
to($url);
?>
explode(",", $r['values']),
"type" => $r['input_type']
);
}
}
$fields = $fields2;
/*
if(isset($ct->fields)) {
$content_fields = explode(",",$ct->fields); // içerik alanları
}
*/
return $fields;
}
function json_field($json, $field)
{ //bir json içinde girilmiş alanı bulur bu aslında post ederken boşluk içeren alanlarda otomatik oluşan _ karakteri sorunundan dolayı üretildi
return @$json[str_replace(" ", "_", $field)];
}
function validBase64($string)
{
$decoded = base64_decode($string, true);
// Check if there is no invalid character in string
if (!preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $string)) return false;
// Decode the string in strict mode and send the response
if (!base64_decode($string, true)) return false;
// Encode and compare it to original one
if (base64_encode($decoded) != $string) return false;
return true;
}
function isJSON($string)
{
return is_string($string) && is_array(json_decode($string, true)) && (json_last_error() == JSON_ERROR_NONE) ? true : false;
}
function getLangFile($lang)
{
$path = "resources/lang/$lang" . ".json";
if (file_exists($path)) {
return file_get_contents($path);
} else {
$json = json_encode(array());
file_put_contents($path, $json);
return file_get_contents($path);
}
}
function putLangFile($lang, $json)
{
if (isJSON($json)) {
return file_put_contents("resources/lang/$lang" . ".json", $json);
} else {
return null;
}
}
function is_html($string)
{
return preg_match("/<[^<]+>/", $string, $m) != 0;
}
function print2($array) {
?>