کدهای کاربردی زبان پی اچ پی(php Code)

نویسنده Amir Shahbazzadeh, بعد از ظهر 23:00:54 - 07/24/11

« آموزش جامع ++c | آژاکس چیست؟ *Ajax* »

0 اعضا و 1 مهمان درحال دیدن موضوع.

Amir Shahbazzadeh

یک منوی متنی دیگر واقعا جالبه این یکی . جای کم می گیره و مفیده .

<?php
echo "<head>
n"

echo 
"<style type="text/css">
n"

echo 
"
n"

echo 
"#popitmenu{
n"

echo 
"position: absolute;
n"

echo 
"background-color: white;
n"

echo 
"border:1px solid black;
n"

echo 
"font: normal 12px Verdana;
n"

echo 
"line-height: 18px;
n"

echo 
"z-index: 100;
n"

echo 
"visibility: hidden;
n"

echo 
"}
n"

echo 
"
n"

echo 
"#popitmenu a{
n"

echo 
"text-decoration: none;
n"

echo 
"padding-left: 6px;
n"

echo 
"color: black;
n"

echo 
"display: block;
n"

echo 
"}
n"

echo 
"
n"

echo 
"#popitmenu a:hover{ /*hover background color*/
n"

echo 
"background-color: #CCFF9D;
n"

echo 
"}
n"

echo 
"
n"

echo 
"</style>
n"

echo 
"
n"

echo 
"<script type="text/javascript">
n"

echo 
"
n"

echo 
"/***********************************************
n"

echo 
"* Pop-it menu- © Dynamic Drive ([url=http://www.dynamicdrive.com]www.dynamicdrive.com[/url])
n"

echo 
"* This notice MUST stay intact for legal use
n"

echo 
"* Visit [url]http://www.dynamicdrive.com/[/url] for full source code
n"

echo 
"***********************************************/
n"

echo 
"
n"

echo 
"var defaultMenuWidth="150px" //set default menu width.
n"

echo 
"
n"

echo 
"var linkset=new Array()
n"

echo 
"//SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT
n"

echo 
"
n"

echo 
"linkset[0]='<a href="http://dynamicdrive.com">Dynamic Drive</a>'
n"; 
echo "
linkset[0] ='<hr>' //Optional Separator
n"; 
echo "
linkset[0] ='<a href="http://www.javascriptkit.com">JavaScript Kit</a>'
n"; 
echo "
linkset[0] ='<a href="http://www.codingforums.com">Coding Forums</a>'
n"; 
echo "
linkset[0] ='<a href="http://www.cssdrive.com">CSS Drive</a>'
n"; 
echo "
linkset[0] ='<a href="http://freewarejava.com">Freewarejava</a>'
n"; 
echo "
n"; 
echo "
linkset[1]='<a href="http://msnbc.com">MSNBC</a>'
n"; 
echo "
linkset[1] ='<a href="http://cnn.com">CNN</a>'
n"; 
echo "
linkset[1] ='<a href="http://news.bbc.co.uk">BBC News</a>'
n"; 
echo "
linkset[1] ='<a href="http://www.washingtonpost.com">Washington Post</a>'
n"; 
echo "
n"; 
echo "
////No need to edit beyond here
n"; 
echo "
n"; 
echo "
var ie5=document.all && !window.opera
n
"; 
echo "
var ns6=document.getElementById
n
"; 
echo "
n"; 
echo "
if (ie5||ns6)
n"; 
echo "
document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>')
n"; 
echo "
n"; 
echo "
function iecompattest(){
n"; 
echo "
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement document.body
n
"; 
echo "
}
n"; 
echo "
n"; 
echo "
function showmenu(ewhichoptWidth){
n"; 
echo "
if (!document.all&&!document.getElementById)
n"; 
echo "
return
n"; 
echo "
clearhidemenu()
n"; 
echo "
menuobj=ie5document.all.popitmenu document.getElementById("popitmenu")
n"; 
echo "
menuobj.innerHTML=which
n
"; 
echo "
menuobj.style.width=(typeof optWidth!="undefined")? optWidth defaultMenuWidth
n
"; 
echo "
menuobj.contentwidth=menuobj.offsetWidth
n
"; 
echo "
menuobj.contentheight=menuobj.offsetHeight
n
"; 
echo "
eventX=ie5event.clientX e.clientX
n
"; 
echo "
eventY=ie5event.clientY e.clientY
n
"; 
echo "
//Find out how close the mouse is to the corner of the window
n"; 
echo "
var rightedge=ie5iecompattest().clientWidth-eventX window.innerWidth-eventX
n
"; 
echo "
var bottomedge=ie5iecompattest().clientHeight-eventY window.innerHeight-eventY
n
"; 
echo "
//if the horizontal distance isn't enough to accomodate the width of the context menu
n"; 
echo "
if (rightedge<menuobj.contentwidth)
n"; 
echo "
//move the horizontal position of the menu to the left by it's width
n"; 
echo "
menuobj.style.left=ie5iecompattest().scrollLeft eventX-menuobj.contentwidth "px" window.pageXOffset eventX-menuobj.contentwidth "px"
n"; 
echo "
else
n"; 
echo "
//position the horizontal position of the menu where the mouse was clicked
n"; 
echo "
menuobj.style.left=ie5iecompattest().scrollLeft eventX "px" window.pageXOffset eventX "px"
n"; 
echo "
//same concept with the vertical position
n"; 
echo "
if (bottomedge<menuobj.contentheight)
n"; 
echo "
menuobj.style.top=ie5iecompattest().scrollTop eventY-menuobj.contentheight "px" window.pageYOffset eventY-menuobj.contentheight "px"
n"; 
echo "
else
n"; 
echo "
menuobj.style.top=ie5iecompattest().scrollTop event.clientY "px" window.pageYOffset eventY "px"
n"; 
echo "
menuobj.style.visibility="visible"
n"; 
echo "
return false
n
"; 
echo "
}
n"; 
echo "
n"; 
echo "
function contains_ns6(ab) {
n"; 
echo "
//Determines if 1 element in contained in another- by Brainjar.com
n"; 
echo "
while (b.parentNode)
n"; 
echo "
if ((b.parentNode) == a)
n"; 
echo "
return true;
n"; 
echo "
return false;
n"; 
echo "
}
n"; 
echo "
n"; 
echo "
function hidemenu(){
n"; 
echo "
if (window.menuobj)
n"; 
echo "
menuobj.style.visibility="hidden"
n"; 
echo "
}
n"; 
echo "
n"; 
echo "
function dynamichide(e){
n"; 
echo "
if (ie5&&!menuobj.contains(e.toElement))
n"; 
echo "
hidemenu()
n"; 
echo "
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTargete.relatedTarget))
n"; 
echo "
hidemenu()
n"; 
echo "
}
n"; 
echo "
n"; 
echo "
function delayhidemenu(){
n"; 
echo "
delayhide=setTimeout("hidemenu()",500)
n"; 
echo "
}
n"; 
echo "
n"; 
echo "
function clearhidemenu(){
n"; 
echo "
if (window.delayhide)
n"; 
echo "
clearTimeout(delayhide)
n"; 
echo "
}
n"; 
echo "
n"; 
echo "
if (ie5||ns6)
n"; 
echo "
document.onclick=hidemenu
n
"; 
echo "
n"; 
echo "
</script>
n"; 
echo "
<a href="#" onMouseover="showmenu(event,linkset[0])" onMouseout="delayhidemenu()">Webmaster Links</a><br>
n"; 
echo "
<a href="#" onMouseover="showmenu(event,linkset[1], '180px')" onMouseout="delayhidemenu()">News sites</a>n";
?>

Amir Shahbazzadeh

نوری به دنبال موس شما .

<?php
echo "<BODY>
n"

echo 
"<script language="JavaScript">
n"

echo 
"
n"

echo 
"//Comment trail script- By Kurt (kurt.grigg@virgin.net)
n"

echo 
"//Script featured on Dynamic Drive
n"

echo 
"//Visit http://www.dynamicdrive.com for this script and more
n"

echo 
"
n"

echo 
"colours=new Array('#ff0000','#00ff00','#ffffff','#ff00ff','#ffa500','#ffff00','#00ff00','#ffffff','ff00ff')
n"

echo 
"n = 10;
n"

echo 
"y = 0;
n"

echo 
"x = 0;
n"

echo 
"n6=(document.getElementById&&!document.all);
n"

echo 
"ns=(document.layers);
n"

echo 
"ie=(document.all);
n"

echo 
"d=(ns||ie)?'document.':'document.getElementById("';
n"; 
echo "a=(ns||n6)?'':'
all.';
n"; 
echo "n6r=(n6)?'")':'';
n"

echo 
"s=(ns)?'':'.style';
n"

echo 
"if (ns){
n"

echo 
"for (i = 0; i < n; i  )
n"

echo 
"document.write('<layer name="dots' i '" top=0 left=0 width=' i/2 ' height=' i/2 ' bgcolor=#ff0000></layer>');
n"

echo 
"}
n"

echo 
"if (ie)
n"

echo 
"document.write('<div id="con" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
n"

echo 
"if (ie||n6){
n"

echo 
"for (i = 0; i < n; i  )
n"

echo 
"document.write('<div id="dots' i '" style="position:absolute;top:0px;left:0px;width:' i/2 'px;height:' i/2 'px;background:#ff0000;font-size:' i/2 '"></div>');
n"; 
echo "
}
n"; 
echo "
if (ie)
n"; 
echo "
document.write('</div></div>');
n"; 
echo "
(ns||n6)?window.captureEvents(Event.MOUSEMOVE):0;
n"; 
echo "
function Mouse(evnt){
n"; 
echo "
= (ns||n6)?evnt.pageY 4 window.pageYOffset:event.y 4;
n"; 
echo "
= (ns||n6)?evnt.pageX 1:event.x 1;
n"; 
echo "
}
n"; 
echo "
(ns)?window.onMouseMove=Mouse:document.onmousemove=Mouse;
n"; 
echo "
function animate(){
n"; 
echo "
o=(ns||n6)?window.pageYOffset:0;
n"; 
echo "
if (ie)con.style.top=document.body.scrollTop;
n"; 
echo "
for (0ni  ){
n"; 
echo "
var temp1 = eval(d a "dots" i n6r s);
n"; 
echo "
n"; 
echo "
randcolours colours[Math.floor(Math.random()*colours.length)];
n"; 
echo "
(ns)?temp1.bgColor randcolours:temp1.background randcolours
n"; 
echo "
if (n-1){
n"; 
echo " 
var temp2 = eval(d a "dots" (i 1n6r s);
n"; 
echo " 
temp1.top parseInt(temp2.top);
n"; 
echo " 
temp1.left parseInt(temp2.left);
n"; 
echo " 

n"; 
echo "
else{
n"; 
echo " 
temp1.top y o;
n"; 
echo " 
temp1.left x;
n"; 
echo " 
}
n"; 
echo "
}
n"; 
echo "
setTimeout("animate()",10);
n"; 
echo "
}
n"; 
echo "
animate();
n"; 
echo "
// -->
n"; 
echo "
</script>n";
?>

Amir Shahbazzadeh

پنهان کردن اسکريپتهاي جاوا از دست مرورگرهاي قديمي...

<?php
echo " <html> 
n"

echo 
"<head>
n"

echo 
"</head>
n"

echo 

n"

echo 
"<body>
n"

echo 

n"

echo 
"<h1>
n"

echo 

n"

echo 
"<!-- hide script from old browsers -->
n"

echo 

n"

echo 
"<script language="javascript" type="text/javascript">
n"

echo 

n"

echo 
"document.write("IranJavaScript")
n"

echo 

n"

echo 
"//end hiding script from old browsers -->
n"

echo 
"</script>
n"

echo 
"</h1>
n"

echo 

n"

echo 
"</body>
n"

echo 
"</html>n";
?>

maxim354

<?php
// Load the stamp and the photo to apply the watermark to
$stamp imagecreatefrompng('stamp.png');
$im imagecreatefromjpeg('photo.jpeg');

// Set the margins for the stamp and get the height/width of the stamp image
$marge_right 10;
$marge_bottom 10;
$sx imagesx($stamp);
$sy imagesy($stamp);

// Copy the stamp image onto our photo using the margin offsets and the photo 
// width to calculate positioning of the stamp. 
imagecopy($im$stampimagesx($im) - $sx $marge_rightimagesy($im) - $sy $marge_bottom00imagesx($stamp), imagesy($stamp));

// Output and free memory
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>


Amir Shahbazzadeh

برای خواندن یک فید کافی هست که function get_feed رو صدا کنید . البته این کد در یک کلاس بوده بنابراین اگه قصد استفاده از این فانکشن رو در یک کلاس ندارید پس $this رو حذف کنید .

public function delTree($dir) {
            $files = glob( $dir . '*', GLOB_MARK );
            if(count($files) > 0)
            {
                foreach( $files as $file ){
                    if( substr( $file, -1 ) == '/' )
                        $this->delTree( $file );
                    else
                        unlink( $file );
                }
            }
        }
        public function get_feed($feed_url)
        {
            $today = date('Y-m-d') ;
             
            if(!file_exists('rss/currency/'.$today.'.xml'))
            {
                //delete everything in directory
                $dir = 'rss/currency/' ;
                $this->delTree($dir) ; 
                 
                 
                //create new file
                //$fp = fopen('rss/currency/'.$today.'.txt', "w") or die("Couldn't create new file");
                $fxml = fopen('rss/currency/'.$today.'.xml', "w") or die("Couldn't create new file");
                $content = file_get_contents($feed_url);
                 
                //write xml file and keep in server
                $xml = fwrite($fxml, $content);
                 
                fclose($fxml);
                 
                return $content ;
                 
            }else{
                 
                //cach file found
                //read the file
                 
                $fp = fopen('rss/currency/'.$today.'.xml', "r");
                $data = fread($fp, filesize('rss/currency/'.$today.'.xml'));
                 
                return $data;
                 
            }
             
        }

Amir Shahbazzadeh

Handler (مدیر خطا) پیش فرض PHP بسیار کارآمد است اما صرفا فقط از بروز خطا ما را با خبر می سازد و در مواجهه با یک خطا عمل دیگری انجام نمی دهد. اما خوشبختانه این تمهید که در PHP شما بتوانید خطاها را خودتان مدیریت کنید دیده شده است و تابع set_error_handler به این منظور نوشته شده است.

Set_error_handler($error_handler) ;

این تابع فقط یک آرگومان دارد که این آرگومان نام تابعی است که شما برای به دست گیری و مدیریت خطا می نویسید.
توجه : در صورتی که از عدد 0 به عنوان آرگومان تابع فوق استفاده شود بدست گیری و مدیریت خطا به حالت پیش فرض PHP باز می گردد.


set_error_handler(0) ;

برای این که بیشتر ملموس باشد مثالی می زنیم:

<?php
error_reporting
(E_ALL);
function 
my_error_handler($number$string$file$line)
{
        echo (
"Error ($number) on line $line in file $file. The error was \"$string\"\n") ;
        
// You Can do Any Code Here Like Error Logging Or e-mail The error to a email address or ...
}
ini_set('display_errors',0);
set_error_handler("my_error_handler");
$mysky fopen('file1',1024);
?>

Tags:

Share via facebook Share via linkedin Share via telegram Share via twitter Share via whatsapp

https://www.meta4u.com/forum/Themes/Comet/images/post/clip.png
دانلود مود کاربردی Yahoo and MSN Search BBC Tag برای SMF, بخش BBC CODE

نویسنده Amir Shahbazzadeh در افزونه های اس ام اف

0 ارسال
1942 مشاهده
آخرین ارسال: قبل از ظهر 11:17:33 - 10/29/11
توسط
Amir Shahbazzadeh
https://www.meta4u.com/forum/Themes/Comet/images/post/xx.png
کد های کاربردی زبان XML

نویسنده Amir Shahbazzadeh در زبان های برنامه نویسی

0 ارسال
1634 مشاهده
آخرین ارسال: قبل از ظهر 10:11:10 - 08/11/11
توسط
Amir Shahbazzadeh
https://www.meta4u.com/forum/Themes/Comet/images/post/xx.png
دانلود پروژه فروشگاه اینترنتی با زبان php

نویسنده Zohreh Gholami در دانلود سنتر بخش کامپیوتر

0 ارسال
4236 مشاهده
آخرین ارسال: قبل از ظهر 08:57:25 - 12/03/11
توسط
Zohreh Gholami
https://www.meta4u.com/forum/Themes/Comet/images/post/xx.png
سورس کدهای زبان c

نویسنده mohammad a در زبان های برنامه نویسی

10 ارسال
4344 مشاهده
آخرین ارسال: بعد از ظهر 13:45:22 - 12/25/11
توسط
aria_com63
https://www.meta4u.com/forum/Themes/Comet/images/post/xx.png
ارسال ایمیل - خطای X-PHP-Originating-Script: Subs-Post.php

نویسنده lakap در مدیریت محتوای Simple Machines

1 ارسال
3480 مشاهده
آخرین ارسال: بعد از ظهر 14:36:37 - 08/11/17
توسط
متا
https://www.meta4u.com/forum/Themes/Comet/images/post/xx.png
php چیست؟ و php چه کارهایی می تواند انجام دهد؟

نویسنده parsaw در مقالات کامپیوتر, Computer Articles

0 ارسال
1310 مشاهده
آخرین ارسال: بعد از ظهر 14:31:12 - 12/08/16
توسط
parsaw
https://www.meta4u.com/forum/Themes/Comet/images/post/clip.png
خطای Code 0xc0000098 در ویندوز ۱۰

نویسنده متا در سیستم عامل ویندوز 10 و 8 Windows

0 ارسال
1453 مشاهده
آخرین ارسال: بعد از ظهر 18:04:40 - 07/07/17
توسط
متا