Download as pdf or txt
Download as pdf or txt
You are on page 1of 58

PHP

PHP


... :
, www.phpx3.com

...
%100 ...
:
... , .

... ...

.
( ).
php .
. Function
( php ).
$_GET . $_POST
)if , else ( php
. include
IP .
. MySql
.
( ).
. Session
. php
. mkdir
str_replace .
. php
( OOP).
( ) .
. php
.

>=

PHP

PHP

. php
php .
: ( ) Rasmus Lerdorf . 1994
, .

# PHP
- 1 .
-2 .
-3 .
-4 ( - ) .
-5 .
-6 .

# PHP
-1 .
-2 .
-3 .
-3 ( ) ...HTML - CSS - Ajax - Js
...

# php
:
.HTML -1
.Js -2
.Ajax -3
.CSS -4
# php
MySQL ...
# php
http://php.net

PHP

PHP


AppServ 2.5.9
,
... ..
.
, http://prdownloads.sourceforge.net/appserv/appserv-win32- :
2.5.9.exe?download
. 14.
7 , :
http://kent.dl.sourceforge.net/sourceforge/appserv/appserv-win32-2.5.8.exe
...
:

( )

PHP

PHP

, , Next IAgree Next .

Next :

PHP

PHP

, , localhost .
.
, .

. . . Next root
, phpmyadmin ,
, 12345 .
Install
. . . , .

,Finish , ..
C:\AppServ\www

http://localhost/file
= file ...

PHP

PHP

PHP

, , AppServ
.
.
...
, notepad , ,
:
- DzSoft .
- Notepad ++.
- Zend_Studio .
.
:
AppServ www , ... p1
http://localhost/p1/
php , index.php
===========
, index php , html , asp ,
indexdefault .
===== ====
index.php php .
.

<?php
>?

?> <?php ...


php .

PHP

PHP

, , echo , : print
:

<?php
;" " print
>?
echo :
<?php
;" " echo
>?

http://localhost/p1/index.php , " " .


( .)

, , :

<?php
;"" = $name
>?

, name , :-
$ = .
name " " , ,
:

<?php
;"" = $name
;print $name
>?

<?php
;"$url = "http://phpx3.com
;print $url
>?

url , .
, ,
, ,:

PHP

PHP

<?php
//
;"" = $name
;print $name
>?
"" name .
" , , , "
:

<?php
//
;"" = $name
//
;"$age = "17
//
;" " = $hopy
//
;"" = $verb1
//

;" : $name"
;" : $age"
;" : $hopy"
;" : $verb1 , "

print
print
print
print
>?

PHP

PHP

function ... )( mysql_connect ,


.
:

<?php
{)(function fahad
;" fahad " print
}
>?
, , 3 :
?<
;)"go("fahad","xp","IE6
>?
:

<?php
{)go($name,$sys,$browser
;" : $name"
;" : $sys"
;" : $browser"

function
print
print
print
}

//
;)'','Windows','Explorer'(go
>?

function ,
, , , , {
} .
: Class
OOP .
, php.net .

PHP

PHP

PHP

... .
filesize.php
... :

<?php
;)"print filesize("files/script.zip
>?

php ?<
print , .
;)(filesize
Byte .
" PHP.NET ".
, ,.. ....
?>

10

PHP

PHP

$_GET $_POST
$_POST , $_GET php .


$_GET , id
http://www.montadaphp.net/showthread.php?t=222
...
() .php
$_GET t .
t , , get.php :

<?php
;]'$t = $_GET['t
;" t : $t" echo
>?
http://localhost/get.php?t=555 , ... t 555
.

$_GET , :
http://localhost/file.php?step=1
http://localhost/file.php?step=2
http://localhost/file.php?step=admin
... " " 1 2 3 ... 4

...
;)(intval
:

<?php
;)]'$id = intval($_GET['id
>?
... strip_tags ...addslashes

<?php
;)]'$id = addslashes($_GET['id
//

;)]'$id = strip_tags($_GET['id
>?

11

PHP

PHP

, $_POST
$_POST forms , ,
" " , , .

,
HTML , , , , :

>"<form method="POST" action="index.php?show=2


>" : <input type="text" name="name" size="20
><br /
>" : <input type="text" name="age" size="20
><br /
><br /
>"" name="B1"=<input type="submit" value
>"" name="B2 <input type="reset" value="
></form

...

>"<form method="POST" action="index.php?show=2


, ... action
" " ...

>"<input type="text" name="age" size="20


, type , text .
name , , ... $_POST
... .
index.php?show=2 ,
,;][$_GET

12

PHP

PHP

: , , index.php ,

>"form method="POST" action="index.php?show=2<


>"input type="text" name="name" size="20< :
>/ br

<

>"input type="text" name="age" size="20< :


>/ br

<

>/ br

<

>"name="B1 "="input type="submit" value

<

>"name="B2 "=" input type="reset" value

<
>form/<

.
: show=2 ,

<?php
if($_GET['show'] == 2){
}
?>
:

<form method="POST" action="index.php?show=2">


: <input type="text" name="name" size="20">
<br />
: <input type="text" name="age" size="20">
<br />
<br />
<input type="submit" value=" "name="B1">
<input type="reset" value=" " name="B2">
</form>
<?php
if($_GET['show'] == 2){
}

13

PHP

PHP

>?
, } { ? ;][$_POST
:

;]'= $_POST['name

$name

name ,
;]'$_POST['name
name ] [ , age name
:

;]'= $_POST['name
;]'= $_POST['age

$name
$age

$_POST
, " : $name , : $age ... "
:

>"<form method="POST" action="index.php?show=2


>" : <input type="text" name="name" size="20
><br /
>" : <input type="text" name="age" size="20
><br /
><br /
>"" name="B1"=<input type="submit" value
>"" name="B2 "=<input type="reset" value
></form
<?php
{)if($_GET['show'] == 2
$name
;]'= $_POST['name
$age
;]'= $_POST['age
< : <b>$age <b> $name </b> , " print
;" >/b
}
>?
========= ============
> </b> <b HTML .
========= ============
, ,

, :
( ) ...

14

PHP

PHP

<form method="POST" action="index.php?show=2">


: <input type="text" name="name" size="20">
<br />
: <input type="text" name="age" size="20">
<br />
<br />
<input type="submit" value=" "name="B1">
<input type="reset" value=" " name="B2">
</form>
<?php
if($_GET['show'] == 2){
$username = $_POST['name'];
$age = $_POST['age'];
if($name == ""){
print ";"
}else{
if($age == ""){
print ";"
}else{
print " < b> $name </b> , : <b>$
age</b> ";
}
}
}
?>

) ... else if (

15

PHP

PHP

, PHP ELSE IF

else if , :
" " "name 95 { } {
} ".95
:

<?php
;"$username = "admin
{)"if($username == "admin
;" admin ... " print
{}else
, " print
;"
}
>?
else : if

?<
)"" == if($verb
{
}
else
{
}
>?
if ( , == "=" ,
,
< , < .
, ...
) { } else
{ } ...
, "
$_GET ", $_POST ...
: if

( ) ...

16

PHP

PHP

<?php
//
$username = "xp11";
?>
<html>
<head><title> < /title></head>
<body>
<form method="POST" action="index.php?login=1">
: <input type="text" name="login" size="20">
<br />
<input type="submit" value=" ">= name="B1">
</form>
<?
if($_GET['login'] == 1){
$user = strip_tags($_POST['login']);
if($user == $username) {
print "
, ;"
}else{
print ";"
}
}
?>
</body>
</html>

<?php
$ID = "788";
if($ID == '750'){
print ";"
}else{
print " $ID ;"
}
?>
session else if .......

17

PHP

PHP

INCLUDE

include , , ...
config ... , ,
:
.. . . . :

<? php
//
" = $site_name
;"
//
;"$url = "http://www.phpx3.com
//
;"" = $admin_username
//
;"" = $admin_password
//
;"$conn = http://phpx3.com/connect/index.html
>?
,

17 ,

17

)( include :

<?php
;)"include("config.php
>?
!
config index.php , :
( )

18

PHP

PHP

<?php
include("config.php");
?>
<html>
<head>
<title> <? print "$site_name"; ?> </title>
</head>
<body>
<div align="center">
<font face="Tahoma" style="font-size:10pt">
: <b><? print "$site_name"; ?></b>
<br />
: <b> <? print "$site_url"; ?> </b>
<br />
: <b> <? print "$conn"; ?> </b>
</body>
</html>
header.htm , , include ,
. , ,
.

19

PHP

PHP

IP

IP ...
:

?<
;]'$ip = $_SERVER['REMOTE_ADDR
>?
:

?<
;]'$ip = $_SERVER['REMOTE_ADDR
;" > :<b> $ip </b " print
>?
, " 127.0.0.1".

if , :

<?php
;]'$ip = $_SERVER['REMOTE_ADDR
{)'if($ip == '127.0.0.1
, " print
;" !
{}else
" print
;" ,
}
>?

... :D

20

PHP

PHP

MYSQL

....
.

*
, ... ...
, ,

http://phpx3.com/drs/show2-1.html
... ID 2 , 1 ...
* id
, drs 5 6 ...
drs_text ,


>>id -

>>text -

>>date -

>>mail-
...
http://phpx3.com/drs/show2-1.html mod_rewrite , :
http://phpx3.com/drs/show.php?id=1&pag=1
id .

" : $_GET ".

id , id , ...
, id , $_GET id ,
...
" - - - - --
.
:
" id ".
- $_GET
".
" - $_POST
".
" )(- include

21

PHP

PHP


...
phpmyadmin ...
...
http://localhost/phpmyadmin mydb .
root "
AppServ ".
:

<?php
"( mysql_connect ("localhost","root","12345") or die
;) )( : ". mysql_error , ,
:".mysq "( mysql_select_db ("mydb") or die
;) )(l_error
>?
:

<?php
//
;"$host = "localhost
//
;"$user = "root
//
;"$pass = "12345
//
;"$db_name = "mydb
//
"( mysql_connect ("$host","$user","$pass") or die
;) )( : ". mysql_error , ,
" : "( mysql_select_db ("$db_name") or die
;) )(.mysql_error
>?

45 ,

! include , config.php ...
:
( )

22

PHP

PHP
<?php
;)"include("config.php
>?

config.php.

install.php ...
, .

23

PHP

PHP


...
mysql_query()

<?
mysql_query(";)"
?>

<?
$sql = mysql_query("SELECT * FROM table_name");
?>

...
... 5

<?
$sql = mysql_query("SELECT * FROM text WHERE id='5'");
?>

mysql_fetch_array(); ...

<?
$sql = mysql_query("SELECT * FROM text WHERE id='5'");
$rows = mysql_fetch_array($sql);
$subject = $rows['subject'];
print " : $subject";
?>
... , 5

: while()

<?
include("config.php");
$sql = mysql_query("SELECT * FROM text");
while( $rows = mysql_fetch_array($sql))
{
print $rows['subject'];

24

PHP

PHP

}
?>

id
ORDER BY id DESC :

<?
include("config.php");
$sql = mysql_query("SELECT * FROM text ORDER BY id DESC");
while( $rows = mysql_fetch_array($sql))
{
print $rows['subject'];
}
?>
... id
. = DESC
. = ASC

<?
$sql = mysql_query("SELECT * FROM text ORDER BY id ASC");
?>
...: ...

<?
include ("config.php");
$insert = mysql_query("INSERT INTO text (`subject`) VALUES ('$subject')")
;
?>

... subject
...(`subject`,`text`,`username`)
.

<?
include ("config.php");
$subject = $_POST['subject'];
$text = $_POST['text'];

25

PHP

PHP

$insert = mysql_query("INSERT INTO text (`subject`,`text`) VALUES ('$subject'


,'$text')");
?>

26

PHP

PHP

...

<?php
include ("config.php");
$subject = $_POST['subject'];
$text = $_POST['text'];
$insert = mysql_query("INSERT INTO text (`subject`,`text`) VALUES ('".$subjec
t."','".$text."')");
?>
...

<?
include ("config.php");
$subject = $_POST['subject'];
$text = $_POST['text'];
$update = mysql_query("UPDATE text SET `subject`='$subject',`text`='$text WHE
RE `id`='1'");
?>

...
...
...
else ... if
$_GET .

27

PHP

PHP


, , ... .
?<
;)"'$query = mysql_query("DELETE FROM table WHERE id='$id
>?

... id $_GET .

28

PHP

PHP

SESSION
session ...
, ...
... ... ..... ..

... :

<?php
;)(session_start

//
>?

html

... ,
admin .
" , "
:
info.php .

?<
//
;"$admin_username = "admin
//
;"$admin_password = "11220
>?
...
login.php :
( )

29

PHP

PHP

<?
session_start();
?>
<html dir="rtl">
<head>
<title> / < /title>
</head>
<body><font face="tahoma" style="font-size:8pt">
<div align="center">
<?
include("info.php");
if($_GET['log'] == 1){
?>
<form method="POST" action="login.php?log=2">
: <input type="text" name="username" size="20">
<br>
: <input type="text" name="password" size="20">
<br>
<br>
<input type="submit" value=" "name="B1"></p>
</form>
<?
}
if($_GET['log'] == 2){
//
$user = $_POST['username'];
$pass = $_POST['password'];
//

if($user == ""){
print " ;"
}else{
//


if($pass==""){
print ";"
}else{
//
if($user == $admin_username && $pass == $admin_password){
$_SESSION['admin_session'] = "$admin_username";
print " < br /> $user <br />
< a href='index_admin.php'> < /a>";

print "<a href=index_admin.php>


</a><BR>
..<meta httpequiv = refresh content=1;url=index_admin.php> ";
}else{
print" ,
< /a> ";
}
}
}
}
?>

<a href='index.php'>

30

PHP

PHP

...
HTML .
, info.php )( include .
$_GET ,
$_GET['log'] == 2
" $_POST "
" if "

{)if($user == $admin_username && $pass == $admin_password


" $user "
info.php .... "&&"...
:
- .

;"$_SESSION['admin_session'] = "$admin_username
]'$_SESSION['admin_session
admin_session ...

else " ... " ,
.
.
index.php , http://localhost/admin
... :

?<
;)(session_start
>?
>"<html dir="rtl
><head
> | Control Panel -</title ><title
></head
><body
?<
{ ) )]'if (isset($_SESSION['admin_session
></a >echo "<a href=index_admin.php
...<meta http <BR> ,.;">equiv = refresh content=1;url=index_admin.php> </font
{}else
;)'include ('login.php
}
>?
( ) ...

31

PHP

PHP

if (isset($_SESSION['admin_session']) ) {
... , $_SESSION['admin_session']
... ... " "
. login.php
: index.php ... index_admin
<?
session_start();
?>
<html dir="rtl">
<head>
<TITLE> | Control Panel -</title>
</head>
<body>
<?
if (isset($_SESSION['admin_session']) ) {
?>
<table border="1" width="100%" id="table1" cellspacing="1" bgcolor="#ECE9D8" style="bo
rder-collapse: collapse" bordercolor="#C0C0C0">
<tr>
<td>
<p align="center"><b><font face="Tahoma" size="2">
<a href="index_admin.php"><span style="textdecoration: none"></span></a>
| <a href="#top"><span style="textdecoration: none">< /span></a>
| <a href="#top"><span style="textdecoration: none">< /span></a>
|<a href="#top"><span style="textdecoration: none"> < /span></a>
| <a href="logout.php"><span style="text-decoration: none">
</span></a></font></b></td>
</tr>
</table>
<br>
<table border="1" width="100%" id="table2" cellspacing="1" style="bordercollapse: collapse" bordercolor="#C0C0C0">
<tr>
<td>
<p align="center"><b><font face="Tahoma" size="2">< /font></b></td>
</tr>
<tr>
<td>
<p align="center"><font face="Tahoma" style="font-size: 9pt">
,
...
.</font></td>
</tr>
</table>
<?
}else{
include ('login.php');
}
?>

32

PHP

PHP

: , logout.php

<?
session_start();
?>
<html dir="rtl">
<head>
<title> . . . </title>
</head>
<body>
<font face="Tahoma" style="font-size: 8pt">
<div align="center">
<?
if (isset($_SESSION['admin_session']) ) {
unset( $_SESSION['admin_session']);
session_destroy();
echo " ;" echo "<br><a href='index.php'>
< /a>";
}else{
print " <font face='tahoma' style='fontsize:8pt'> ;"
include ('index.php');
}
?>
...:

unset( $_SESSION['admin_session']);
session_destroy();
... ... , ... unset()
session_destroy();
,

.
:
http://www.phpx3.com/drs/download/3530session.rar

http://www.phpx3.com/drs/download/566session.zip

33

PHP

PHP

( )

PHP

;]"print $_SERVER["HTTP_HOST
..............
( $_SERVER >
.) http://php.net/manual/en/reserved.variables.server.php

34

PHP

PHP

PHP

php mkdir() , :
;)mkdir('style',0755
, , , , , ,
, ,
:

<?php
//
;"$dir_name = "images1
// 777
;)$add_dir = mkdir($dir_name,0755
{)if($add_dir
;" ... $dir_name " print
{ } else
;" $dir_name " print
}
>?

35

PHP

PHP

HTML )(STRIP_TAGS

... ..
strip_tags.
, ! .
$_POST ... $_POST
...
!
... $_POST ...
strip_Tags() :

<?php
;)]'$text = strip_tags($_POST['text
>?
... ...

HTML BBCodes ...
...
... :

<?php
$text = strip_tags($_POST['text'],'<b>,<font>,<h1>,<h2>,<h3>,<img>,<a>,<table
;)'>
>?
strip_tags
Download StripTags Function Example RAR File strip_tags zip .

36

PHP

PHP

IS_ARRAY

is_array ...

?<
;)"$names = array("fahad","Khaled","Mohamed","Mhmod
{ ))if(is_array($names
;" " print
{}else
, " print
;"!
}
>?
, if names
)(is_array
, .

37

PHP

PHP

STR_REPLACE

, ,
> <script.
.
str_replace() , :
?<
//
;)""","", "", "($ban_words = array
//

;" ***** " = $mark
//
// $text1
;" " = $text1
//
// $text
str_replace //
. ,
;)$text = str_replace($ban_words,$mark,$text1
//
;"print "$text
;">print "<br
//
;"print "$text1
>?

38

PHP

PHP

PHP

...
, $_POST ! php

...
:
* =
= /
= = +
.... :

<?php
;) print ( 5 + 1
>?
1 + 5 ... 6 ... :

<?php
//
;"$num_one = "7
//
;"$num_two = "6
;" = print "$num_one+$num_two
;)print ($num_one + $num_two
>?
...,
, ..
+ = ...
... ...
:

( )

39

PHP

PHP

<?
//
$num_one = "7";
//
$num_two = "6";
print "$num_one * $num_two = ";
print ($num_one * $num_two);
?>

<?
//
$num_one = "7";
//
$num_two = "6";
print "$num_one / $num_two = ";
print ($num_one / $num_two);
?>

<?
//
$num_one = "7";
//
$num_two = "6";
print "$num_one - $num_two = ";
print ($num_one - $num_two);
?>
... , ... ,
.

40

PHP

PHP

( OOP)

Class ... ,.
, , .

:
<?php
text , , //
{class text
); font , , //
{)function font($text
//
print "<div align='center'><B><font face='Tahoma' color='red' style='font;">size:10pt'> $text </font></B></div
//
}
//
}
: //
;)($class = new text
;)" "($class->font
>?
...
,
;)($verb = new class_name
:

;)"$verb->function("xxx
... Smarty ,
, ,
;)"$smarty->display("xx.html

, , , "
" word
, , phpclasses ...

..

41

PHP

PHP

,

, pt .10 Tahoma

:
<?php
class text{
function font($text)
{
print "<div align='center'><B><font face='Tahoma' color='red' style='fontsize:10pt'> $text </font></B></div>";
}
}
$class = new text();
$class->font(";)"
?>

<?php
class text{
{ text , class ,
function font($text)
{
print "<div align='center'><B><font face='Tahoma' color='red' style='fontsize:10pt'> $text </font></B></div>";
}
text font , , , ,
. ,
: , ,
print "<div align='center'><B><font face='Tahoma' color='red' style='fontsize:10pt'> $text </font></B></div>";
HTML , print
< font> , < b> , < div align='center'>
...
HTML . , $text

42

PHP

PHP



}
}

font.php
,
, , ...
:

<?php
;)"include("font.php
;)($class = new text
;)" "($class->font
>?

include ,

;)($class = new text


, class , :
;)($text = new text

, font
)function font($text :D

, , " " ,,,


.
, , :

43

PHP

PHP

<?php
class text{
function font($text){
print "<div align='center'><B><font face='Tahoma' color='red' sty
le='font-size:10pt'> $text </font></B></div>";
}
}
$class = new text();
$class->font(";)"
?>

!
:

<?php
class image{
function show_image($URL){
print "<img src='$URL' border='0'>";
}
}
$img = new image();
$img->show_image("http://phpx3.com/images/center.gif");
?>
:D :
<?php
class image{
function (_$URL){
print "<img src='$URL' border='0'>";
}
}
$img = new image();
$img->"(_http://phpx3.com/images/center.gif");
?>
:D . ,

44

PHP

PHP


... ...

:
...
... upload ,
:

Uploaded

Includes

Style
( ") Small "
includes cache .
style template .

:
...
MOF Template Engine ...

) 1.4.0.1
(

, moftemplate-engine.php ,
moftemplate-engine.php includes .
.

(mof-define.php) :
,
mof_define.php includes , :-

<?php
;'include 'moftemplate-engine.php
$tpl
=
;new moftemplate
$tpl->tempdir
=
;''style/template
$tpl->cachedir
=
;''includes/cache
>?

45

.
.
.
.

PHP

PHP

(config.php) :
, :

<?php
#
;" " = $sitename
#
;" " = $msg
www.name.com/upload */
http://
/
*/
;"$site_url ="localhost/upload

keywords #
;" " = $meta_open
meta description #
;" , , ," = $meta_desc
//
150 //

;"$maxsize = "153600
//
$alemtdadat = array('.gif','.jpg','.jpeg','.zip','.rar','.png','.swf','.psd',
;)''.txt','.bmp
>?
, ... ...
config.php includes ,
includes !

46

PHP

PHP

:
,
!
content_up.php , :
, , config.php , ...
content_down.php ...
!
, .
, )if-else-elseif( ....

{ } .

: content_up.php
:

<?php
;)'include('includes/config.php
;)'include('includes/mof_define.php
;)'echo $tpl->show('header.htm
>?
config.php .
.
.

47

PHP

PHP

: index.php
index.php :

<?php
;)'include('content_up.php
;)$max_size = ($maxsize/1024
;)$allowed_file_types = implode(", ", $alemtdadat
;'$upload_path = 'uploaded
;)'echo $tpl->show('upload.htm
;)'echo $tpl->show('footer.htm
>?
content_up.php ...
1024 .
implode ,
php.net .
, uploaded .
upload.htm .
...

header,upload,footer upload.php...
, ,
:) .

HTML CSS , !.

48

PHP

PHP

: header.htm
<html dir="rtl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<meta http-equiv="Content-Language" content="ar-sa">
<meta name="keywords" content="{meta_open}">
<meta name="description" content="{meta_desc}">
<title>{sitename}</title>
</head>
<body style="margin:0">
<div align="center">
<table style="border:1px dotted #C0C0C0;width:100%">
<tr>
<td style="background-color:#FFFFDB;padding: 0;height:50px">
<p align="center" style="color:maroon;font-size:15pt;font-family:Tahoma">
{sitename}</td>
</tr>
<tr>
<td style="background-color:#808080;color:white;border:0px">
<p align="center">
<b>
<a href="index.php">
<span style="color:white;font-size:10pt;font-family:Tahoma;text-decoration:
none"></span></a> <a href="http://phpx3.com"><span style="color:white;font-size:10pt;font-family:Tahoma;textdecoration: none">
< /span></a></b></td>
</tr>
</table>
</div>

..
HTML . . right to left rtl , direction = dir
, css title HEAD .
. }meta_desc{ }meta_open{ , . config.php ,
-. config.php sitename , . HEAD
. body . }sitename{ .

49

PHP

PHP

: footer.htm

,:
><br
>"<div align="center
>"<span style="font-family:Tahoma;font-size:8pt;color:teal
} &copy; {sitename
></span
></div
></body></html
sitename ...
header .

: upload.htm

, ....

50

PHP

PHP

<div align="center">
<BR>
<table width="760" cellspacing="1" style="border:1px dotted #C0C0C0">
<tr>
<td style="background:gray;color:white;height:24px;text-align:center">
<font face="Tahoma" style="font-size: 10pt; font-weight:700" color="#FFFFFF">{sitename}</font></td>
</tr>
<tr>
<td style="background:silver;padding-top:2px;padding-bottom:2px;height:19px;text-align:center;">
<font face="Tahoma" style="font-size: 9pt; font-weight: 700">&nbsp;{msg}</font></td>
</tr>
<tr>
<td>
<table border="1" width="100%" cellpadding="0" style="border-collapse: collapse" bordercolor="#CCCCCC">
<tr>
<td width="50%" bgcolor="#ECE9D8"><font face="Tahoma" style="font-size: 9pt">
<span lang="ar-sa">&nbsp; : </span>
<font color="#FF0000">{max_size}</font> <span lang="ar-sa">
.</span></font></td>
<td bgcolor="#ECE9D8" width="50%">
<font face="Tahoma" style="font-size: 9pt">
<span lang="ar-sa">&nbsp; :<br>
&nbsp;</span></font><font color="#FF0000" style="font-size: 8pt"
face="Tahoma">{allowed_file_types}</font><font face="Tahoma" style="font-size: 9pt">
.</font></td>
</tr>
</table>
</td>
</tr>
</table>
<form action="upload.php" method="post" enctype="multipart/form-data" name="form1" id="fileup">
<table width="760" border="1" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF" bordercolor="#C0C0C0"
style="border:1px dotted #C0C0C0; border-collapse: collapse" id="table5">
<tr>
<th bgcolor="#80A5E7">
<font face="Tahoma" style="font-size: 9pt" color="#FFFFFF">
<strong><span lang="ar-sa">< /span></strong></font></th>
</tr>
<tr>
<td>
<p align="center"><font face="Tahoma">
<b>
<span style="font-size: 9pt" lang="ar-sa"> :</span></b><span style="font-size: 9pt"><b>
</b>
<input name="fileup" type="file" id="fileup0" size="50" style="text-decoration: underline; font-family: Tahoma;
font-size: 9pt; border: 1px groove #C0C0C0; padding: 2px; font-weight:700;
cursor:hand"></span></font></td></tr><tr>
<td align="center" bgcolor="#ECE9D8">
<font face="Tahoma"><span style="font-size: 9pt">
<input type="submit" name="Submit" value=" / Upload" style="font-family: Tahoma; color: #FFFFFF;
font-variant: small-caps; font-size: 9pt; vertical-align: baseline; border: 1px dotted #C0C0C0; padding: 4px;
background-color: #81A7E8; font-weight:700;cursor:hand"> </span>
</font>
</td>
</tr>
</table>
<BR>

index.php , HTML ,
...

51

PHP

PHP

upload.php :
, :-
( ) ...

?<
//
;)'include('content_up.php
//
;'$upload_path = 'uploaded

, //
$_FILES //
php.net //
;]'$file_name = $_FILES['fileup']['name
;]'$fileup = $_FILES['fileup']['tmp_name
//
//
;)$rand = rand(000,999
//
;$new_file_name=$rand.'_'.$file_name

//
{)'' == if($fileup
print "<span style='font , >'family:Tahoma'><p align='center
;"> </p></span
;)'echo $tpl->show('upload.htm
;)'echo $tpl->show('footer.htm
;exit
{}else
//
;))'$att = strtolower(strrchr($file_name,'.
//
// filesize
//
;)$file_size = filesize($fileup
//
{))if(! in_array($att,$alemtdadat
print "<span style='font , >'family:Tahoma'><p align='center
;"> </p></span
;)"echo $tpl->show("upload.htm
;)'echo $tpl->show('footer.htm
;exit

52

PHP

PHP
}

//
)elseif($file_size > $maxsize
{
//
;)$max_size = ($maxsize/1024
print "<span style='font , >'family:Tahoma'><p align='center
> $max_size </p></span
;"
;)"echo $tpl->show("upload.htm
;exit
{}else
//

;$path= $upload_path.'/'.$new_file_name
//
move_uploaded_file //
//
, //
;)$Upload = move_uploaded_file($fileup,$path
//
)if($Upload
{
//
//

,
!

;)"$images = array(".jpg",".jpeg",".gif",".png",".bmp
//
) )if ( in_array($att,$images
{
???? ??? ???????? ?????? ??? //
????? ?? ???????
" // mime type
getimagesize //
GD //
//
@
//
;)$image = @getimagesize($path
//
))'if(!stristr($image['mime'],'image
{
//
;)$delete = @unlink($path
)if($delete
{
print "<span style='font , >'family:Tahoma'><p align='center
;"> </p></span
;)"echo $tpl->show("upload.htm
;)'echo $tpl->show('footer.htm

53

PHP

PHP

exit;
}
}
}
//


//
$size= ($_FILES['fileup']['size']/1024);
//
$type = $_FILES['fileup']['type'];
//
echo $tpl->show("file-was-upload.htm");
echo $tpl->show('footer.htm');

}else{
//
print "<span style='fontfamily:Tahoma'><p align='center'>
, ,
< /p></
span>";
echo $tpl->show("upload.htm");
echo $tpl->show('footer.htm');
}
}
}
?>

54

PHP

PHP

file-was-upload.htm
:
<div align="center">
<table style="border:1px dotted silver;width:600px" id="table1"> <tr>
<td style="text-align:center;font-size:10pt;font-family:Tahoma;background:black;color:white">
:<br>
<a href="http://{site_url}/{path}" style="color:white;textdecoration:none">http://{site_url}/{path}</a></td></tr>
<tr><td style="font-family:Tahoma;color:silver;font-size:9pt;text-align:center">
: <b>{size} </b>.<BR/>
:<b>{type}.</b><BR/>
</td></tr>
<tr>
<TD align="center" bgcolor="#ECE9D8" height="19">
<font color="#808080" style="font-size: 9pt" face="Tahoma">
: </font> </td>
</tr> <tr>
<td style="font-family:Tahoma;background:white" align="center"> <font face="Tahoma"
size="2"> < /font><font face="Tahoma" style="font-size: 10pt"> (
)</font><font face="Tahoma"><font size="2">:
</font>
<input size='100' value=' [url=http://{site_url}][img]http://{site_url}/{path} [/img][/url]'
name="T3"><font size="2">
<br /></font></font></td>
</tr>
<tr>
<td class='thead' align="center"> <font face="Tahoma" size="2">
</font><font face="Tahoma" style="font-size: 10pt"> (
<)/font><font face="Tahoma"><font size="2">:
</font>
<input size='100' value=' [url=http://{site_url}/{path}] [ /url] '
name="T4"><font size="2">
</font></font>
</td>
</tr>
<tr><td style="font-family:Tahoma;background:silver" align="center"> <font face="Tahoma"
size="2">
<b> HTML &nbsp;:</b></font></td></tr>
<br /><tr><td class='thead' align="center"> <font face="Tahoma"><font size="2">
< span lang="en-us">HTML</span> : </font>
<input size='100' value='<a href="http://{site_url}" target="_blank"><img
src="http://{site_url}/{path}"></a>' name="T1"><font size="2">
<br /></font></font></td></tr><tr><td class='thead' align="center">
<font face="Tahoma"><font size="2">
<span lang="en-us">HTML </span>: </font>
<input size='100' value='&lt;a href="http://{site_url}/{path}" target="_blank"&gt;
&lt;/a&gt;' name="T2"><font size="2">
</font></font>
</td></tr><tr><td class="tcat" align="center"> <form method="POST" action="index.php">
<input type="submit" value=" "style="font-weight: 700"></form> </td></tr>
</table>
</div>

55

PHP

PHP

!
:D ...
() http://phpx3.com/drs/download/4641uploads_lesson.zip
MySimpleFileUpload ) http://phpx3.com/files/show71-1.html( ,
:D .
, .

56

PHP

PHP


...
.
( .. )

/http://www.freeforarab.com

( )
.

http://forum.montadaphp.net/forum.php

,
,

http://blog.abdullaheid.net/?cat=9


...

/http://www.arabteam2000-forum.com

http://swalif.net/softs

,
php

/http://www.traidnt.net/vb

/http://prog.arccn.net

, ,
php

...
!

57

PHP

PHP


, ...
...
phpx3.com
, .
. 2010 / 6 / 13 1431/7/1.

...

...
http://phpx3.com/connect/
faha1ad2@hotmail.com

... :D
http://phpx3.com
http://templaty.com

58

You might also like