Parsi Coders

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

اینم از اولیش
جلوگیری از ip /مشخص به سایت :
کد:
<script type="text/javascript">

//اي پي مورد نظرتان را اينجا وارد كنيد var bannedips=["23.23.23.23", "11.11.11.11"]  var ip = '<!--#echo var="REMOTE_ADDR"-->'  var handleips=bannedips.join("|") handleips=new RegExp(handleips, "i")

if (ip.search(handleips)!=-1){  alert("شما به هيچ وجه حق ورود به اين مكان را نداريد") window.location.replace("http://www.google.com") }  </script>
فقط کدهای جاوااسکریپ رو؟

اینم دومین کد دیگه واسه استفاده تو صفحات HTML !!!

Browser Detalis (اطلاعات مرورگر)

کد:
<!-- THREE STEPS TO INSTALL BROWSER DETAILS:

   1.  Paste the final coding into the HEAD of your HTML document
   2.  Add the onLoad event handler to the BODY of your HTML document
   3.  Copy the last code into the BODY of your HTML document  -->

<!-- STEP ONE: Copy this code into the HEAD of your HTML document  -->

<HEAD>

<SCRIPT>

<! >
<! >

<!-- Begin
function whatBrowser() {
document.Browser.Name.value=navigator.appName;
document.Browser.Version.value=navigator.appVersion;
document.Browser.Code.value=navigator.appCodeName;
document.Browser.Agent.value=navigator.userAgent;
}
// End -->
</SCRIPT>

<!-- STEP TWO:  Add the onLoad event handler to the BODY of your HTML document  -->

<BODY onLoad="whatBrowser()">

<!-- STEP THREE:  Add this last code into the BODY of your HTML document  -->

<CENTER>
<TABLE BORDER>
<FORM NAME="Browser">
<TR>
<TD> Browser Name: </TD>
<TD> <INPUT TYPE="txt" NAME="Name" Size="45"></TD>
</TR>
<TR>
<TD> Browser Version: </TD>
<TD> <INPUT TYPE="txt" NAME="Version" Size="45"></TD>
</TR>
<TR>
<TD> Browser Code Name: </TD>
<TD> <INPUT TYPE="txt" NAME="Code" Size="45"></TD>
</TR>
<TR>
<TD> User-Agent: </TD>
<TD> <INPUT TYPE="txt" NAME="Agent" Size="45"></TD>
</TR>
</FORM>
</TABLE>
</CENTER>



<!-- Script Size:  1.40 KB  -->

سوالی نیست؟
درود:
خیر دوست عزیز کد php java html ajax و...رو هم بزارین هدف درست کردن یک تایپک برای دسترسی اسان انجمن به کد ها اسکریپت برای ساخت سایت هست و

باز شدن وب دیگر به همراه لود وب شما

کد:
<body onload="window.open('http://www.parsicoders.com')"> </body>

چک کردن پسورد از نظر مشکل بودن (strong/short/long/weak)
کد:
[LEFT]<?php

$pwd = $_POST['pwd'];

if( strlen($pwd) < 8 ) {
    $error .= "Password too short! <br />";
}

if( strlen($pwd) > 20 ) {
    $error .= "Password too long! <br />";
}

if( strlen($pwd) < 8 ) {
    $error .= "Password too short! <br />";
}

if( !preg_match("#[0-9]+#", $pwd) ) {
    $error .= "Password must include at least one number! <br />";
}


if( !preg_match("#[a-z]+#", $pwd) ) {
    $error .= "Password must include at least one letter! <br />";
}


if( !preg_match("#[A-Z]+#", $pwd) ) {
    $error .= "Password must include at least one CAPS! <br />";
}



if( !preg_match("#\W+#", $pwd) ) {
    $error .= "Password must include at least one symbol! <br />";
}


if($error){
    echo "Password validation failure(your choise is weak): $error";
} else {
    echo "Your password is strong.";
}
[/LEFT]
س !!!!!!!!!!!!!!!!!!! چند کد ساعت !!!
این کد واسه نمایش ساعت بکار می ره که کاربر می تونه اونه به 12 ساعت یا 24 ساعت تغییر بده.
کد:
<!-- THREE STEPS TO INSTALL CLOCK TYPE:

   1.  Paste the first code in the HEAD of your HTML document
   2.  Copy the onLoad event handler into the BODY tag
   3.  Add the last code in the BODY of your HTML document  -->

<!-- STEP ONE: Paste the first code in the HEAD of your HTML document  -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">




<!-- Begin
function showMilitaryTime() {
if (document.form.showMilitary[0].checked) {
return true;
}
return false;
}
function showTheHours(theHour) {
if (showMilitaryTime() || (theHour > 0 && theHour < 13)) {
if (theHour == "0") theHour = 12;
return (theHour);
}
if (theHour == 0) {
return (12);
}
return (theHour-12);
}
function showZeroFilled(inValue) {
if (inValue > 9) {
return "" + inValue;
}
return "0" + inValue;
}
function showAmPm() {
if (showMilitaryTime()) {
return ("");
}
if (now.getHours() < 12) {
return (" am");
}
return (" pm");
}
function showTheTime() {
now = new Date
document.form.showTime.value = showTheHours(now.getHours()) + ":" + showZeroFilled(now.getMinutes()) + ":" + showZeroFilled(now.getSeconds()) + showAmPm()
setTimeout("showTheTime()",1000)
}
// End -->
</script>

<BODY onLoad="showTheTime()">

<!-- STEP THREE: Add the last code in the BODY of your HTML document  -->

<BODY>

<center><form name=form>
<input type=text name=showTime size=11><p>
<input type=radio name=showMilitary checked>Military Time<br>
<input type=radio name=showMilitary>12 Hour Time<br>
</form></center>



</table>
</form>
</FONT>
</CENTER>


</center>
</body></html>

اینم یه کد دیگه واسه نمایش ساعت در دکمه.

کد:
<!-- ONE STEP TO INSTALL BUTTON TIME:

   1.  Put the coding into the BODY of your HTML document  -->

<!-- STEP ONE: Add this code into the BODY of your HTML document  -->

<BODY>

<SCRIPT LANGUAGE="JavaScript">

<!-- Original: Michael Tartaglia <stonedstan@hotmail.com> -->
<!-- Web Site:  http://www.geocities.com/SiliconValley/Horizon/5235 -->

<! >
<! >

<!-- Begin
day = new Date();
miVisit = day.getTime();
function clock() {
dayTwo = new Date();
hrNow = dayTwo.getHours();
mnNow = dayTwo.getMinutes();    
scNow = dayTwo.getSeconds();
miNow = dayTwo.getTime();
if (hrNow == 0) {
hour = 12;
ap = " AM";
} else if(hrNow <= 11) {
ap = " AM";
hour = hrNow;
} else if(hrNow == 12) {
ap = " PM";
hour = 12;
} else if (hrNow >= 13) {
hour = (hrNow - 12);
ap = " PM";
}
if (hrNow >= 13) {
hour = hrNow - 12;
}
if (mnNow <= 9) {
min = "0" + mnNow;
}
else (min = mnNow)
if (scNow <= 9) {
secs = "0" + scNow;
} else {
secs = scNow;
}
time = hour + ":" + min + ":" + secs + ap;
document.form.button.value = time;
self.status = time;
setTimeout('clock()', 1000);
}
function timeInfo() {
milliSince = miNow;
milliNow = miNow - miVisit;
secsVisit = Math.round(milliNow / 1000);
minsVisit = Math.round((milliNow / 1000) / 60);
alert("There have been " + milliSince + " milliseconds since midnight, January 1, 1970.  "
+ "You have spent " + milliNow + " of those milliseconds on this page.  "
+ ".... About " + minsVisit + " minutes, and "
+ secsVisit + " seconds.");
}
document.write("<form name=\"form\">"
+ "<input type=button value=\"Click for info!\""
+ " name=button onClick=\"timeInfo()\"></form>");
onError = null;
clock();
// End -->
</SCRIPT>



<!-- Script Size:  1.72 KB  -->

اینم به کد دیگه واسه نمایش ساعت در تکست باکس.

کد:
<!-- THREE STEPS TO INSTALL CURRENT TIME:

   1.  Paste the specified coding into the HEAD of your HTML document
   2.  Add the onLoad event handler to the BODY tag
   2.  Put the last code into the BODY of your HTML document  -->

<!-- STEP ONE: Copy this code into the HEAD of your HTML document  -->
          
<HEAD>

<SCRIPT LANGUAGE="JavaScript">

<! >
<! >

<!-- Begin
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function showtime () {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" + ((hours >12) ? hours -12 :hours)
if (timeValue == "0") timeValue = 12;
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " P.M." : " A.M."
document.clock.face.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
function startclock() {
stopclock();
showtime();
}
// End -->
</SCRIPT>

<!-- STEP TWO: Add this onLoad event handler to the BODY tag  -->

<BODY onLoad="startclock()">

<!-- STEP THREE: Copy this code into the BODY of your HTML document  -->

<CENTER>
<FORM name="clock">
<input type="text" name="face" size=13 value="">
</FORM>
</CENTER>



<!-- Script Size:  1.45 KB  -->

سوالی نیست؟
س !!!!!!!!!!!! چند کد جاوااسکریپ دیگه !!!!!!!!!!!!!

با کد زیر می توانید یک تکست باکس قرار دهید که توسط دو دکمه مقدار آن کم و زیاد می شود.
کد:
<!-- ONE STEP TO INSTALL UP & DOWN BOX:

  1.  Copy the coding into the BODY of your HTML document  -->

<!-- STEP ONE: Paste this code into the BODY of your HTML document  -->

<BODY>

<center>
<form>
<input type=text name=amount value=5>
<input type=button value="up" onClick="javascript:this.form.amount.value++;">
<input type=button value="down" onClick="javascript:this.form.amount.value--;">
</form>
</center>


<!-- Script Size:  0.45 KB -->
در کد زیر می توانید با وارد کردن RGB مورد نظر، Hex آن را رنگ را نیز بدست آورید.
کد:
<!-- TWO STEPS TO INSTALL HEX-RGB CONVERTER:

  1.  Copy the coding into the HEAD of your HTML document
  2.  Add the last code into the BODY of your HTML document  -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Original:  Ryan Sokol -->
<!-- Web Site:  http://www.logicode.net -->

<! >
<! >

<!-- Begin
function NumToHex(num1,num2) {
strNum=document.forms[0].elements[num1].value;
for(i = 0; i < strNum.length; i++) {
chr=strNum.substring(i, i + 1);        
if((isNaN(chr))||(chr == ' ')) {
alert('You must enter a digit between 0 and 9!');
document.forms[0].elements[num1].select();
document.forms[0].elements[num2].value='';
return false;
   }
}
if(strNum > 255) {
alert('You must enter a number between 0 and 255!');
document.forms[0].elements[num1].select();
document.forms[0].elements[num2].value='';
return false;
}
else {
base = strNum / 16;
rem = strNum % 16;
base = base - (rem / 16);
baseS = MakeHex(base);
remS = MakeHex(rem);
document.forms[0].elements[num2].value=baseS + '' + remS;
ChangeBackground(3, 4, 5);
return true;
   }
}
function MakeHex(x) {
if((x >= 0) && (x <= 9))
return x;
else {
switch(x) {
case 10: return "A";
case 11: return "B";  
case 12: return "C";  
case 13: return "D";  
case 14: return "E";  
case 15: return "F";  
      }
   }
}
function HexToNum(num1,num2) {
numberS = document.forms[0].elements[num1].value;
tens = MakeNum(numberS.substring(0,1));
if(tens == 'X') {
document.forms[0].elements[num1].select();
document.forms[0].elements[num2].value='';
return false;
}
ones = 0;
if(numberS.length > 1) // means two characters entered
ones=MakeNum(numberS.substring(1,2));
if(ones == 'X') {
document.forms[0].elements[num1].select();
document.forms[0].elements[num2].value='';
return false;
}
document.forms[0].elements[num2].value = (tens * 16) + (ones * 1);
document.forms[0].elements[num1].value = document.forms[0].elements[num1].value.toUpperCase();
ChangeBackground(3, 4, 5);
return true;
}
function MakeNum(str) {
if((str >= 0) && (str <= 9))
return str;
switch(str.toUpperCase()) {
case "A": return 10;
case "B": return 11;
case "C": return 12;
case "D": return 13;
case "E": return 14;
case "F": return 15;
default:  alert('You must choose a number between 0 and 9 or a letter between A and F!');
return 'X';
   }
}
function ChangeBackground(num1, num2, num3) {
document.bgColor = '#'+document.forms[0].elements[num1].value + document.forms[0].elements[num2].value + document.forms[0].elements[num3].value;
}
//  End -->
</script>

</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document  -->

<BODY>

<form>
<table border=1 align=center cellpadding=10 bgcolor=white>
<tr>
<th>Color/Code</th>
<th>Red</th>
<th>Green</th>
<th>Blue</th>
</tr>
<tr>
<th>0-255</th>
<td><input type=text name=rr_num size=4 maxlength=3 onKeyUp="return NumToHex(0,3);"></td>
<td><input type=text name=gg_num size=4 maxlength=3 onKeyUp="return NumToHex(1,4);"></td>
<td><input type=text name=bb_num size=4 maxlength=3 onKeyUp="return NumToHex(2,5);"></td>
</tr>
<tr>
<th>HEX</th>
<td><input type=text name=rr_hex size=4 maxlength=2 onKeyUp="return HexToNum(3,0);"></td>
<td><input type=text name=gg_hex size=4 maxlength=2 onKeyUp="return HexToNum(4,1);"></td>
<td><input type=text name=bb_hex size=4 maxlength=2 onKeyUp="return HexToNum(5,2);"></td>
</tr>
</table>
</form>


<!-- Script Size:  3.91 KB -->
با کد زیر می توانید KB را به MB تبدیل کنید.
کد:
<!-- TWO STEPS TO INSTALL KB TO MB:

  1.  Copy the coding into the HEAD of your HTML document
  2.  Add the last code into the BODY of your HTML document  -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Original:  Gerald Schafer -->
<!-- Web Site:  http://www.robandger.com -->

<! >
<! >

<!-- Begin
function convert() {
if(document.KBtoMB.KB.value) {
document.KBtoMB.MB.value = eval(document.KBtoMB.KB.value / 1024);
}
else {
if(document.KBtoMB.MB.value) {
document.KBtoMB.KB.value = eval(document.KBtoMB.MB.value * 1024);
      }
   }
}
//  End -->
</script>

</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document  -->

<BODY>

<center>
<form name="KBtoMB">
<input type=text name="KB" size="16">KB
<input type=button name="KBtoMBgo"  value=" < = > " onClick="convert()">
<input type=text name="MB" size="16">MB
<input type=reset value=" Clear ">
</form>
</center>

<!-- Script Size:  1.25 KB -->
سوالی نیست؟
درود:
الگوریتم و برنامه تشخیص صحت کد ملی

کد ملی یک شناسه ی 10 رقمی است که اعداد آن به سه دسته تقسیم می شوند:

1- 3 رقم اول کد محل زندگی

2- 6 رقم بعدی کد منحصر به فرد شخص

3- رقم آخر عدد کنترل (Validation Number)

الگوریتم Validation کد ملی بصورت ساده به این شرح است:

از سمت چپ هر عدد ضربدر ارزش مکانی معکوس خود می شود.

حاصل ضرب ها با هم جمع می شود.

باقیمانده تقسیم حاصل جمع ها بر عدد 11 را بدست می آوریم.

اگر عدد بدست آمده در باقیمانده ی تقسیم، کوچکتر مساوی 2 بود، همان عدد باید با Validation Number (عدد آخر کد ملی) برابر باشد.

اگر عدد بدست آمده در باقیمانده ی تقسیم، بزرگتر از 2 بود، عدد را منهای 11 می کنیم و نتیجه باید برابر Validation Number (عدد آخر کد ملی) باشد.


کد:
//www.parsicoders.com by amir

<?php
function CheckNationalCode($code)
**
      if(strlen($code) <> 10)**
          echo 'کد ملی باید ده رقم باشد';
      }
      else
      **
          $codeArray = str_split($code);
          $AllEq ;
          foreach($codeArray as $item => $value)
          **
              if($codeArray[0] <> $value)
              **
                  $AllEq = false;
                  break;
              }
               else{ $AllEq = true;}
          }
          if($AllEq == true) die('اعداد کد ملی نمی توانند برابر هم باشند');
          $j = 10;
          $sum = 0;
          for($i=0; $i<=8; $i++)
            **
                 $sum +=((int)($codeArray[$i])) * $j;
                 --$j;
            }
          $divid = $sum % 11;
            if ($divid <= 2)
            **
               if($codeArray[9]  == $divid)
               **
                   echo "کد ملی معتبر است";
               }
                   echo "کد ملی معتبر نیست";
            }
            else
            **
                $divid1 = 11 - $divid;
                if ($codeArray[9]  == $divid1)
                **
                      echo "کد ملی معتبر است";
                }
                else
                **
                      echo "کد ملی معتبر نیست";
                }  
            }
        }       
}     

?>

thank the mute
اینم چند کد واسه سایت یا ... به زبان جاوااسکریپ برای استفاده دوستان !!!
Scroll Box Message
با این کد می شه نوشته ساخت که کلمه به کلمه از سمت چپ به راست نمایش داده می شود !!!
کد:
<!-- THREE STEPS TO INSTALL BOX MESSAGE:

  1.  Copy the coding into the HEAD of your HTML document
  2.  Add the onLoad event handler into the BODY tag
  3.  Put the last coding into the BODY of your HTML document  -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Original:  Keith Swerling (keiths@topixonline.com) -->
<!-- Web Site:  http://www.TopiXonline.com -->

<! >
<! >

<!-- Begin
ScrollSpeed = 200;
ScrollChars = 1;

function ScrollMarquee() {
window.setTimeout('ScrollMarquee()', ScrollSpeed);
var msg = document.scrollform.box.value;
document.scrollform.box.value = msg.substring(ScrollChars) + msg.substring(0, ScrollChars);
}
//  End -->
</script>
</HEAD>

<!-- STEP TWO: Insert the onLoad event handler into your BODY tag  -->

<BODY OnLoad="javascript:ScrollMarquee()">

<!-- STEP THREE: Copy this code into the BODY of your HTML document  -->

<center>
<form method=get name=scrollform>
<input name=box type="text" size="15" value="                       Click Here To Search                  " onFocus="javascript:this.value='';ScrollSpeed=99999;">
</form>
</center>



<!-- Script Size:  1.31 KB -->
سوالی نیست؟؟؟
درود:
اسکریپت ip graber
مترجم : خودم

کد:
<?php
header('Content-type: image/jpeg');
readfile('image.jpg');
$log = "log.txt";
$grab = "Connection from:".$_SERVER['REMOTE_ADDR']." at ".date("r",time())."\n";
if ($handle = fopen($log, 'a')) **
fwrite($handle, $grab);
fclose($handle);
}
?>


یک فایل پی اچ پی ذخیره و آپلود کنیدو یک عکس با نام image.jpg اپلود کنید
یک فایل txt یا متنی با نام log بسازید و اپلود کنید
زمانی که کسی وارد صفحه سایت بشه IP در log.txt ذخیره میشه
پوزش به دلیل ترجمه بدم