Giriş
Sayt bölmələri
Xəbərlər
Qonaq dəftəri
Forum
Bloqlar
Musiqi
Foto
Video
Yükləmələr
İcmalar
Lotereyalar
İstifadəçilər Onlayn oyunlar
Onlayn kinoteatr
Mağaza
Şərhlər 12
Əməliyyatlar
faylların qovluqdan vaxt ilə silinməsi üçün funksiya.
---
[code=php]<?
function old($papka,$times){
$old_time = time()-60*$times;
$dir = opendir ($papka);
while ($file = readdir ($dir)) {
if (( $file != ".") && ($file != ".."))
$files[]="$papka/$file";
$time[]=filemtime("$papka/$file" );
}
closedir ($dir);
$count_files = count($files);
for($i = 1; $i< $count_files; $i++){
if($time[$i] <= $old_time){
@unlink($files[$i]);
}
}
}
?>[/code]
---
[code=php]<?
old('papka',30);//// 30 dəqiqədən çox müddətə serverdə olan faylları silir, "papka" bizim yaratdığımız qovluqdur?>[/code]
----
bazanın həcminin göstərilməsi.
---
[code=php]<?php
function formatfilesize( $data ) {
if( $data < 1024 ) {
return $data . " bytes";
}else if( $data < 1024000 ) {
return round( ( $data / 1024 ), 1 ) . " KB";
}
else {
return round( ( $data / 1024000 ), 1 ) . " MB";}
}
$db = mysql_connect ("localhost","user","pass");
mysql_select_db("dbname",$db);
$result = mysql_query( "SHOW TABLE STATUS" );
$dbsize = 0;
while( $row = mysql_fetch_array( $result ) ) {
$dbsize += $row[ "Data_length" ] + $row[ "Index_length" ];
}
echo "Bazanın ümumi həcmi " . formatfilesize( $dbsize );
?>[/code]
9 May 2020, 19:43
---
[code=php]<?
function old($papka,$times){
$old_time = time()-60*$times;
$dir = opendir ($papka);
while ($file = readdir ($dir)) {
if (( $file != ".") && ($file != ".."))
$files[]="$papka/$file";
$time[]=filemtime("$papka/$file" );
}
closedir ($dir);
$count_files = count($files);
for($i = 1; $i< $count_files; $i++){
if($time[$i] <= $old_time){
@unlink($files[$i]);
}
}
}
?>[/code]
---
[code=php]<?
old('papka',30);//// 30 dəqiqədən çox müddətə serverdə olan faylları silir, "papka" bizim yaratdığımız qovluqdur?>[/code]
----
bazanın həcminin göstərilməsi.
---
[code=php]<?php
function formatfilesize( $data ) {
if( $data < 1024 ) {
return $data . " bytes";
}else if( $data < 1024000 ) {
return round( ( $data / 1024 ), 1 ) . " KB";
}
else {
return round( ( $data / 1024000 ), 1 ) . " MB";}
}
$db = mysql_connect ("localhost","user","pass");
mysql_select_db("dbname",$db);
$result = mysql_query( "SHOW TABLE STATUS" );
$dbsize = 0;
while( $row = mysql_fetch_array( $result ) ) {
$dbsize += $row[ "Data_length" ] + $row[ "Index_length" ];
}
echo "Bazanın ümumi həcmi " . formatfilesize( $dbsize );
?>[/code]
0
Əməliyyatlar
[code=php]
<?php
class aze{
function aze1(){
echo "Ewq olsun Azerbaycan xalqina";
}
}
$goster=new aze();
$goster=$goster->aze1();
?>
numune: Ewq olsun Azerbaycan xalqina
[/code]
9 May 2020, 19:27
<?php
class aze{
function aze1(){
echo "Ewq olsun Azerbaycan xalqina";
}
}
$goster=new aze();
$goster=$goster->aze1();
?>
numune: Ewq olsun Azerbaycan xalqina
[/code]
0
Əməliyyatlar
Sessionla admin panel
Index.php ya bunu atin [code=php]<?php
session_start();
$adminlogin = "admin";
$adminshifre = 12345;
if(@$_SESSION["girish"] == true){
if($_SESSION["login"] != $adminlogin or $_SESSION["shifre"] !=$adminsifre){
$_SESSION["girish"] = false;
}
echo 'admin panel';
echo '<a href="chisix.php">Cixis et</div>';
}else{
if($_POST){
$login = $_POST["login"];
$shifre = $_POST["shifre"];
if($login != $adminlogin or $shifre != $adminshifre){
echo 'Login ve ya parol sehvdir!';
die();
}
$_SESSION["login"] = $login;
$_SESSION["shifre"] = $shifre;
$_SESSION["girish"] = true;
}
echo '<form method = "post">
Login<br/>
<input type ="text" name = "login" placeholder = "Logininiz"><br/>
Parol<br/>
<input type ="text" name = "shifre" placeholder = "Shifreniz"><br/>
<input type ="submit" value = "Girish"><br/>
</form>';
}
?>[/code]
Chisix.php ya da bunu atin[code=php]<?php
session_start();
session_destroy();
header("Location:index.php");
?>[/code]
9 May 2020, 15:32
Index.php ya bunu atin [code=php]<?php
session_start();
$adminlogin = "admin";
$adminshifre = 12345;
if(@$_SESSION["girish"] == true){
if($_SESSION["login"] != $adminlogin or $_SESSION["shifre"] !=$adminsifre){
$_SESSION["girish"] = false;
}
echo 'admin panel';
echo '<a href="chisix.php">Cixis et</div>';
}else{
if($_POST){
$login = $_POST["login"];
$shifre = $_POST["shifre"];
if($login != $adminlogin or $shifre != $adminshifre){
echo 'Login ve ya parol sehvdir!';
die();
}
$_SESSION["login"] = $login;
$_SESSION["shifre"] = $shifre;
$_SESSION["girish"] = true;
}
echo '<form method = "post">
Login<br/>
<input type ="text" name = "login" placeholder = "Logininiz"><br/>
Parol<br/>
<input type ="text" name = "shifre" placeholder = "Shifreniz"><br/>
<input type ="submit" value = "Girish"><br/>
</form>';
}
?>[/code]
Chisix.php ya da bunu atin[code=php]<?php
session_start();
session_destroy();
header("Location:index.php");
?>[/code]
0
Əməliyyatlar
şəkillərə saytınızın logosunu vurun.
bir (logo.png) saytınızın logosunu yaradın (img.php) faylı yaradın və aşağıdakı kodu əlavə edin.
---
[code=php]<?php
$img = $_GET['img'];
$im = imagecreatefromjpeg($img);
$lg = imagecreatefrompng('logo.png');
$img_x = imagesx($im);
$img_y = imagesy($im);
$img_x_copy = imagesx($lg);
$img_y_copy = imagesy($lg);
imagecopy($im, $lg, $img_x-$img_x_copy, $img_y-$img_y_copy, 0, 0, $img_x_copy, $img_y_copy);
header('Content-Type: image/jpeg');
imagejpeg($im);
imagedestroy($im);
imagedestroy($lg);
?>[/code]
göstərmək üçün.
---
[code=php]echo '<img src="img.php?img='.$sekil_id['id'].'& width=80& height=80" alt="img"/>';[/code]
7 May 2020, 22:34
bir (logo.png) saytınızın logosunu yaradın (img.php) faylı yaradın və aşağıdakı kodu əlavə edin.
---
[code=php]<?php
$img = $_GET['img'];
$im = imagecreatefromjpeg($img);
$lg = imagecreatefrompng('logo.png');
$img_x = imagesx($im);
$img_y = imagesy($im);
$img_x_copy = imagesx($lg);
$img_y_copy = imagesy($lg);
imagecopy($im, $lg, $img_x-$img_x_copy, $img_y-$img_y_copy, 0, 0, $img_x_copy, $img_y_copy);
header('Content-Type: image/jpeg');
imagejpeg($im);
imagedestroy($im);
imagedestroy($lg);
?>[/code]
göstərmək üçün.
---
[code=php]echo '<img src="img.php?img='.$sekil_id['id'].'& width=80& height=80" alt="img"/>';[/code]
0
Əməliyyatlar
Funksiyadan söhbət gedirsə
funksiya, funksiyasi. Deməli belə izah edim
Nümunədə olan kimi php içində bir
'head' adli funksiya yaradiriq və bu isdifadə
qaydası isə belədir. Harda göstərmək istəyiriksə
orda nə adindadirsa onu yaziriq misal yuxarı();
kodda head funksuyasi yaratdim deyə head yazilib koda.
[code=php]<style>
.title { background: #ff4500;
color: #ffffff; }
</style>
<?php
function head() {
echo '<div class="title">Saytadi.Az</div>';
}
head();
?>[/code]
Neticede qirmizi fon icinde Saytadi.Az yazacaq
[code=php]<?php
function deneme(){
$ad ='b4h3r4id';
}
deneme();
echo $ad;
?>[/code]
Eger bele etsek xeta verer sebebi ise
Bele $ad adli deyisen olmamasidi.
Buna gore global ifsdesin isletmek olar.
[code=php]<?php
$ad ="b4h3r4id";
function header() {
global $ad;
echo 'xos geldin'. $ad;
}
header();
?>[/code]
Burda ise neticede xos geldin b4h3r4id yazacaq.
7 May 2020, 19:36
funksiya, funksiyasi. Deməli belə izah edim
Nümunədə olan kimi php içində bir
'head' adli funksiya yaradiriq və bu isdifadə
qaydası isə belədir. Harda göstərmək istəyiriksə
orda nə adindadirsa onu yaziriq misal yuxarı();
kodda head funksuyasi yaratdim deyə head yazilib koda.
[code=php]<style>
.title { background: #ff4500;
color: #ffffff; }
</style>
<?php
function head() {
echo '<div class="title">Saytadi.Az</div>';
}
head();
?>[/code]
Neticede qirmizi fon icinde Saytadi.Az yazacaq
[code=php]<?php
function deneme(){
$ad ='b4h3r4id';
}
deneme();
echo $ad;
?>[/code]
Eger bele etsek xeta verer sebebi ise
Bele $ad adli deyisen olmamasidi.
Buna gore global ifsdesin isletmek olar.
[code=php]<?php
$ad ="b4h3r4id";
function header() {
global $ad;
echo 'xos geldin'. $ad;
}
header();
?>[/code]
Burda ise neticede xos geldin b4h3r4id yazacaq.
0
Əməliyyatlar
yəqinki bilməyənlər var, (php funksiyalar)
---
ziyarətçinin hansı ölkədə yaşadığını görürük.
[code=php]<?php
$host=gethostbyaddr($_SERVER['REMOTE_ADDR']);
$countrys=array(
az => Azərbaycan,
tr => Türkiyə,
ru => Rusiya
);
$array=array_reverse(explode('.',$host));
if(isset($countrys[$array[0]])){
echo 'Sizin ölkə: '.$countrys[$array[0]];
}else{
echo 'Siz haradan daxil olmusunuz - Bilinmir :( ';
?>[/code]
7 May 2020, 15:55
---
ziyarətçinin hansı ölkədə yaşadığını görürük.
[code=php]<?php
$host=gethostbyaddr($_SERVER['REMOTE_ADDR']);
$countrys=array(
az => Azərbaycan,
tr => Türkiyə,
ru => Rusiya
);
$array=array_reverse(explode('.',$host));
if(isset($countrys[$array[0]])){
echo 'Sizin ölkə: '.$countrys[$array[0]];
}else{
echo 'Siz haradan daxil olmusunuz - Bilinmir :( ';
?>[/code]
0
Bağışlayın, sizin üçün şərh yazmaq əlçatan deyil
Geriyə



