Şifre Zorluğu Gösterimi

<html>
<head>
<style>
body
{
	/*ie needs this*/
	margin:0px;
	padding:0px;
	/*set global font settings*/
	font-size:10px;
	font-family:Tahoma,Verdana,Arial;
}
a:hover
{
	color:#fff;
}

#user_registration
{
	border:1px solid #cccccc;
	margin:auto auto;
	margin-top:100px;
	width:400px;
}


#user_registration label
{
        display: block;  /* block float the labels to left column, set a width */
	float: left; 
	width: 70px;
	margin: 0px 10px 0px 5px; 
	text-align: right; 
	line-height:1em;
	font-weight:bold;
}

#user_registration input
{
	width:250px;
}

#user_registration p
{
	clear:both;
}

#submit
{
	border:1px solid #cccccc;
	width:100px !important;
	margin:10px;
}

h1
{
	text-align:center;
}

#passwordStrength
{
	height:10px;
	display:block;
	float:left;
}

.strength0
{
	width:250px;
	background:#cccccc;
}

.strength1
{
	width:50px;
	background:#ff0000;
}

.strength2
{
	width:100px;	
	background:#ff5f5f;
}

.strength3
{
	width:150px;
	background:#56e500;
}

.strength4
{
	background:#4dcd00;
	width:200px;
}

.strength5
{
	background:#399800;
	width:250px;
}


</style>
</style>

<script>
function passwordStrength(password)
{
	var desc = new Array();
	desc[0] = "Çok Zayıf";
	desc[1] = "Zayıf";
	desc[2] = "İdare Eder";
	desc[3] = "Orta";
	desc[4] = "Güçlü";
	desc[5] = "Çok Güçlü";

	var score   = 0;

	//if password bigger than 6 give 1 point
	if (password.length > 6) score++;

	//if password has both lower and uppercase characters give 1 point	
	if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++;

	//if password has at least one number give 1 point
	if (password.match(/d+/)) score++;

	//if password has at least one special caracther give 1 point
	if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) )	score++;

	//if password bigger than 12 give another 1 point
	if (password.length > 12) score++;

	 document.getElementById("passwordDescription").innerHTML = desc[score];
	 document.getElementById("passwordStrength").className = "strength" + score;
}
</script>
</head>
<body>

<form method="post" action="" id="user_registration" name="user_registration">
		<p><h1>Kayıt Formu</h1></p>
		<p>	
		<label for="user">Kullanıcı Adı</label><input type="text" name="user" id="user"/>
		</p>
		<p>	
			<label for="pass">Şifre</label><input type="password" name="pass" id="pass" onkeyup="passwordStrength(this.value)"/>
		</p>
		<p>
			<label for="passwordStrength">Şifre Zorluğu</label>
			<div id="passwordDescription">Şifre Girilmedi</div>
			<div id="passwordStrength" class="strength0"></div>
		</p>
		<p>	
		<input type="submit" name="submit" id="submit" value="Kayıt Ol">
		</p>
</form>	

</body>
</html>

 

E-Mail Adresi Doğruluğunu Kontrol Etmek

<?php

function mailKontrol($mail) {
	if ( filter_var($mail, FILTER_VALIDATE_EMAIL) ) {
		echo "Doğru email adresi"; 
	} else {
		echo "Hatalı email adresi"; 
	}
} 
if($_POST){
	mailKontrol($_POST["email"]);
}
?>
<form method="post" action="">
	<input type="email" name="email"/>
	<button type="submit">Kontrol Et</button>
</form>

 

Php Dosyalarını Düzenlemek

Boş bir dosya.php oluşturun. index.php içerisine aşağıdaki kodları ekleyerek dosya.php içeriğini düzenleyebilirsiniz.

<?php session_start();
if(!isset($_SESSION["login"])){
echo "Bu sayfayı görüntüleme yetkiniz yoktur.";
}else{

$dizin = "";
$uzanti = "php"; //hangi uzantı?

//Uzantı alma fonksiyonu
function ext($text)  {
    $text = strtolower(pathinfo($text, PATHINFO_EXTENSION));
    return $text;  }

echo 'Lütfen Bir Sayfa Seçin:';
echo '<hr>';

if ($handle = opendir("$dizin") or die ("Dizin acilamadi!")) {

    while (false !== ($file = readdir($handle))) {
    $filetype = ext($file);

        if(is_file($dizin."/".$file) && $filetype == "$uzanti") { //eger bir dosya ise ve bizim belirlediğimiz uzantıya sahipse

        $class = ($css % 2) ? "satir1" : "satir2"; // her satira farklı class

        echo '
        <div class="'.$class.'"><a href="edit.php,$sayfa='.$file.'">'.$file.'</a> </div>';

        $css++;

        }

    } //while end

    closedir($handle);

}
}
////////////////////////////////////////
$sayfa="dosya.php";


if(!empty($_POST['icerik']))
{
  $yazdir = file_put_contents($sayfa, $_POST['icerik']);
  if(!$yazdir)
    echo 'yazdırılamadı';
  else
    echo 'başarıyla yazdırıldı';

  exit;
}

$icerik = file_get_contents($sayfa);

echo '
<form action="" method="post">
<textarea style="width: 800px; height: 600px;" name="icerik">', $icerik, '</textarea>
<br />
<input type="submit" value="Yayınla" />
<a href="index.php">İptal</a>
</form>';    
?>

 

Onaya Göre İsim Listelemek

Veritabanımızı oluşturalım

CREATE TABLE uretim
	(
     id int auto_increment primary key, 
     musteri varchar(255), 
     adet int(11),
     onay int(1)
    );

INSERT INTO uretim (id,musteri,adet,onay)
VALUES
(1, '1.Müşteri',5,0),
(2, '2.Müşteri',8,1),
(3, '3.Müşteri',2,2),
(4, '4.Müşteri',7,3);

baglan.php adlı dosyamızdan veritabanı bağlantımızı oluşturmuş varsayıp, kodlarımızı ekliyoruz.

<?php include "baglan.php"; 
?>
	<table border="1"  bordercolor="#111111" width="100%">
      <tr>
        <td width="25%" >
			<table border="1"  bordercolor="#111111" width="100%">
				<tbody>
					<th>Bekleyen</th>
				</tbody>
				<thead>
					<tr>
						<td>Müşteri Adı</td><td>Adet</td>
					</tr>
					<?php
					$veri=mysql_query("select * table uretim Where onay = 1");
					while($v=mysql_fetch_array($veri)){
						echo '<tr><td>'.$v["musteri"].'</td><td>'.$v["adet"].'</td>';
					}
					?>
					</tr>
				</thead>
			</table>
        </td>
        <td width="25%" >
			<table border="1"  bordercolor="#111111" width="100%">
				<tbody>
					<th>Kaplama</th>
				</tbody>
				<thead>
					<tr>
						<td>Müşteri Adı</td><td>Adet</td>
					</tr>
					<?php
					$veri=mysql_query("select * table uretim Where onay = 2");
					while($v=mysql_fetch_array($veri)){
						echo '<tr><td>'.$v["musteri"].'</td><td>'.$v["adet"].'</td>';
					}
					?>
					</tr>
				</thead>
			</table>
        </td>
        <td width="25%" >
			<table border="1"  bordercolor="#111111" width="100%">
				<tbody>
					<th>Taşlama</th>
				</tbody>
				<thead>
					<tr>
						<td>Müşteri Adı</td><td>Adet</td>
					</tr>
					<?php
					$veri=mysql_query("select * table uretim Where onay = 3");
					while($v=mysql_fetch_array($veri)){
						echo '<tr><td>'.$v["musteri"].'</td><td>'.$v["adet"].'</td>';
					}
					?>
					</tr>
				</thead>
			</table>
        </td>
        <td width="25%" >
			<table border="1"  bordercolor="#111111" width="100%">
				<tbody>
					<th>Sevkiyat</th>
				</tbody>
				<thead>
					<tr>
						<td>Müşteri Adı</td><td>Adet</td>
					</tr>
					<?php
					$veri=mysql_query("select * table uretim Where onay = 1");
					while($v=mysql_fetch_array($veri)){
						echo '<tr><td>'.$v["musteri"].'</td><td>'.$v["adet"].'</td>';
					}
					?>
					</tr>
				</thead>
			</table>
        </td>
      </tr>
    </table>

 

Excel Dosyası Oluşturmak

<?php
header("Content-type:application/vnd.ms-excel; charset=utf-8");
header("Cache-Control: no-store, no-cache");
header('Content-Disposition: inline; filename="dosya.xls"');
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Sayfa</title></head>
<body>
<table>
  <tr>
    <td align="left">BAŞLIK 1</td>
    <td align="left">BAŞKIK 2</td>
    <td align="left">BAŞLIK 3</td>
  </tr>
  <tr>
    <td align="left">içerik</td>
    <td align="left">içerik</td>
    <td align="left">içerik</td>
  </tr>
</table>
</body></html>

 

Array Column ile Dizi Verilerini Anahtar ve Değer Olarak Birleştirme

Dizi girdilerinde istenilen sütundaki değerleri döndürür.
array_column($veri, $anahtar);

<?php
if (version_compare(phpversion(), '5.5.0', '<')) {//5.5.0'dan eski sürümler için
if (!function_exists('array_column')) {
    function array_column($input = null, $columnKey = null, $indexKey = null)
    {
        $argc = func_num_args();
        $params = func_get_args();

        if ($argc < 2) {
            trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING);
            return null;
        }

        if (!is_array($params[0])) {
            trigger_error(
                'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given',
                E_USER_WARNING
            );
            return null;
        }

        if (!is_int($params[1])
            && !is_float($params[1])
            && !is_string($params[1])
            && $params[1] !== null
            && !(is_object($params[1]) && method_exists($params[1], '__toString'))
        ) {
            trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING);
            return false;
        }

        if (isset($params[2])
            && !is_int($params[2])
            && !is_float($params[2])
            && !is_string($params[2])
            && !(is_object($params[2]) && method_exists($params[2], '__toString'))
        ) {
            trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING);
            return false;
        }

        $paramsInput = $params[0];
        $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;

        $paramsIndexKey = null;
        if (isset($params[2])) {
            if (is_float($params[2]) || is_int($params[2])) {
                $paramsIndexKey = (int) $params[2];
            } else {
                $paramsIndexKey = (string) $params[2];
            }
        }

        $resultArray = array();

        foreach ($paramsInput as $row) {
            $key = $value = null;
            $keySet = $valueSet = false;

            if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) {
                $keySet = true;
                $key = (string) $row[$paramsIndexKey];
            }

            if ($paramsColumnKey === null) {
                $valueSet = true;
                $value = $row;
            } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) {
                $valueSet = true;
                $value = $row[$paramsColumnKey];
            }

            if ($valueSet) {
                if ($keySet) {
                    $resultArray[$key] = $value;
                } else {
                    $resultArray[] = $value;
                }
            }

        }

        return $resultArray;
    }

}
$liste = array( 
 array( 'no' => 246, 'adi' => 'Ahmet', 'soyadi' => 'Deniz', ), 
 array( 'no' => 358, 'adi' => 'Mehmet', 'soyadi' => 'Gök', ), 
 array( 'no' => 479, 'adi' => 'Mahmut', 'soyadi' => 'Kara', ) 
); 
$soyadlari = array_column($liste, 'soyadi', 'no'); 
print_r($soyadlari);

Çıktısı

Array(
 [246] => Deniz
 [358] => Gök
 [479] => Kara
)

Referans: https://raw.githubusercontent.com/ramsey/array_column

Password Hash ve Password Verify Kullanımı

<?php //php5.5 sürümü ile gelen şifreleme fonksiyonu

//şifre oluşturma///////////////////////////////////////////
echo password_hash("rasmuslerdorf", PASSWORD_DEFAULT);
//çıktısı
//$2y$10$.vGA1O9wmRjrwAVXD98HNOgsNpDczlqm3Jq7KnEd1rVAGv3Fykk1a
//veya
$options = ['cost' => 12,];
echo password_hash("rasmuslerdorf", PASSWORD_BCRYPT, $options);
//çıktısı
//$2y$12$QjSH496pcT5CEbzjD/vtVeH03tfHKFy36d4J0Ltp3lRtee9HDxY3K

//şifre doğrulama/////////////////////////////////////////////////////
$hash = '$2y$07$BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq';
if (password_verify('rasmuslerdorf', $hash)) {
    echo 'Doğru Şifre!';
} else {
    echo 'Hatalı Şifre.';
}
?>