Link Düzenleyici

<?php if (! defined(‘BASEPATH’)) exit(‘No direct script access allowed’); function link($q) { $q = str_replace(”,’&#32;’,$q); $q = str_replace(‘!’,’&#33;’,$q); $q = str_replace(“‘”,’&#34;’,$q); $q = str_replace(‘#’,’&#35;’,$q); $q = str_replace(‘$’,’&#36;’,$q); $q = str_replace(‘%’,’&#37;’,$q); $q = str_replace(‘&’,’&#38;’,$q); $q = str_replace(“‘”,’&#39;’,$q); $q = str_replace(‘(‘,’&#40;’,$q); $q = str_replace(‘)’,’&#41;’,$q); $q = str_replace(‘*’,’&#42;’,$q); $q = str_replace(‘+’,’&#43;’,$q); $q = str_replace(‘,’,’&#44;’,$q); $q = str_replace(‘-’,’&#45;’,$q); $q […]

Read More

Linux Kullanıcı Hesabı İşlemleri

<?php $groupname = “”; $username = “”; $password = “”; $home = “”; // /var/www/$username function createUser($groupname, $username, $home, $password){ exec(“mkdir ” . $home); exec(“useradd ” . $username); exec(“groupadd ” . $groupname); exec(“passwd ” . $username); exec(“gpasswd -a ” . $username . “” . $groupname); exec(“chown –R ” . $username . “” . $home); exec(“chgrp […]

Read More

Random Parola Oluşturucu

<?php if (! defined(‘BASEPATH’)) exit(‘No direct script access allowed’); function pass_generator($amount) { $keyset = “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789″; $randkey = “”; for ($i=0; $i<$amount; $i++){ $randkey .= substr($keyset, rand(0, strlen($keyset)-1), 1); } return $randkey; } ?>

Read More

Domain Ping

<?php $ping = exec(“ping 127.0.0.1″); print($ping); ?> Eğer, exec komutu çalışmazsa şu yöntemi de kullanabilirsiniz: <?php function pingDomain($domain, $port, $timeout, &$message){ $file = fsockopen ($domain, $port, $errno, $errstr, $timeout); $status = 0; $message = $message == null ? $message = array() : $message; if (!$file){ $status = -1; $m = “ping $domain:$port -> status:$status (errno:$errno […]

Read More

Associative Array Sum

<?php $data = array( 0 => array( ‘event’ => ‘Conference’, ‘budget’ => 3700, ), 1 => array( ‘event’ => ‘Conference’, ‘budget’ => 500, ), 2 => array( ‘event’ => ‘Showroom’, ‘budget’ => 1000, ), 3 => array( ‘event’ => ‘Mission Chez client’, ‘budget’ => 2000, ), 4 => array( ‘event’ => ‘Séminaire’, ‘budget’ => 700, […]

Read More

Timezone

<?php function get_time($zone_key){ $tz = new DateTimeZone($zone_key); $data = new DateTime(date(“Y-m-d H:i:s”)); $data->setTimezone($tz); //$data = new DateTime(date(“Y-m-d 00:00:00″),$tz); return $data->format(“r”); } if (!empty($_POST)){ echo get_time($_POST["timezone"]); } $zones = timezone_identifiers_list(); ?> <form action=”” method=”post”> <select name=”timezone”> <?php foreach ($zones as $key) { ?> <option value=”<?=$key;?>”><?=$key;?></option> <?php } ?> </select> <input type=”submit” value=”Select” /> </form>

Read More

cURL Nedir?

En basit anlamda cURL PHP’de daha sayfa işlenirken sayfaya veri çekmeye yarar. Örnek olarak bunu bot veya webservis yapımında kullanabiliriz. Tabi bu özelliği kullanabilmek için php.ini dosyanızda php_curl.php özelliği aktif olmak zorunda. Kod Örneği: $temp = array(“a”=&gt;1, “b”=&gt;2); $postdata = http_build_query($temp); $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, true); //POST Metoduyla verileri g&ouml;nder curl_setopt($ch, CURLOPT_HEADER, false); //Serverdan […]

Read More

Sef Link Fonksiyonu

function permalink($string) { $find = array(‘&Ccedil;’, ‘Ş’, ‘Ğ’, ‘&Uuml;’, ‘İ’, ‘&Ouml;’, ‘&ccedil;’, ‘ş’, ‘ğ’, ‘&uuml;’, ‘&ouml;’, ‘ı’, ‘+’, ‘#’); $replace = array(‘c’, ‘s’, ‘g’, ‘u’, ‘i’, ‘o’, ‘c’, ‘s’, ‘g’, ‘u’, ‘o’, ‘i’, ‘plus’, ‘sharp’); $string = strtolower(str_replace($find, $replace, $string)); $string = preg_replace(“@[^A-Za-z0-9\-_\.\+]@i”, ‘ ‘, $string); $string = trim(preg_replace(‘/\s+/’, ‘ ‘, $string)); $string = str_replace(‘ […]

Read More

Tükçe Karakter Düzeltme Fonksiyonu

function duzelt($metin) { $metin = trim($metin); $metin = strtolower($metin); $bul = array(“&Auml;&plusmn;”,”&Aring;?”,”&Atilde;&frac14;”,”&Atilde;&sect;”,”&Atilde;&para;”,”&Auml;?”,”&Aring;&Yuml;”,”&Atilde;&Dagger;”,”&Auml;&deg;”,”&Auml;&Yuml;”,”&Aring;z”,”&Atilde;&ndash;”,”&Atilde;&oelig;”,”&Auml;&plusmn;”,”&Aring;?”,”&Atilde;&sect;”,”&Atilde;&para;”,”&Auml;?”,”&Aring;&Yuml;”,”&Atilde;&Dagger;”,”&Auml;&deg;”,”&Auml;&Yuml;”,”&Aring;z”,”&Atilde;&ndash;”,”&Atilde;&oelig;”,”&Atilde;&frac14;”,”&Auml;&Yuml;”); $duzelt = array(“ı”,”ş”,”&uuml;”,”&ccedil;”,”&ouml;”,”ğ”,”ş”,”&Ccedil;”,”i”,”ğ”,”Ş”,”&Ouml;”,”&Uuml;”,”ı”, “ş”, “&ccedil;”, “&ouml;”, “ğ”, “ş”, “&Ccedil;”, “i”, “ğ”, “Ş”, “&Ouml;”, “&Uuml;”, “&uuml;”, “ğ”); $metin = str_replace($bul, $duzelt, $metin ); return $metin; }

Read More

MySql Yedek Alma Dosyası

define(‘DB_HOST’, ‘localhost’); define(‘DB_NAME’, ‘veritabani_adi’); define(‘DB_USER’, ‘veritabani_kullaniciadi’); define(‘DB_PASSWORD’, ‘parola’); define(‘BACKUP_SAVE_TO’, ‘yedek_alinacak_dizin’); $time = time(); $day = date(‘j’, $time); if ($day == 1) { $date = date(‘Y-m-d’, $time); } else { $date = $day; } $backupFile = BACKUP_SAVE_TO . ‘/’ . DB_NAME . ‘_’ . $date . ‘.gz’; if (file_exists($backupFile)) { unlink($backupFile); } $command = ‘mysqldump –opt […]

Read More