PDA

View Full Version : سوال: تبدیل کد PHP به ASP.NET



giaspirit
چهارشنبه 14 اسفند 1392, 21:35 عصر
با سلام خدمت همه دوستان
من 2 تا صفحه کد PHP دارم که میخوام به کد ASP.NET تبدیل کنم، اگر کسی از دوستان میتونه کمک کنه ممنونش میشم. راستی کد ها در مورد نمایش تعداد دانلود یک فایل با jQuery هستش.
*: متاسفانه بخش آپلود فایل سایت مشکل داشت.
صفحه Demo


<?php

// Error reporting:
error_reporting(E_ALL^E_NOTICE);

// Including the DB connection file:
require 'connect.php';

$extension='';
$files_array = array();


/* Opening the thumbnail directory and looping through all the thumbs: */

$dir_handle = @opendir($directory) or die("There is an error with your file directory!");

while ($file = readdir($dir_handle))
{
/* Skipping the system files: */
if($file{0}=='.') continue;

/* end() returns the last element of the array generated by the explode() function: */
$extension = strtolower(end(explode('.',$file)));

/* Skipping the php files: */
if($extension == 'php') continue;

$files_array[]=$file;
}

/* Sorting the files alphabetically */
sort($files_array,SORT_STRING);

$file_downloads=array();

$result = mysql_query("SELECT * FROM download_manager");

if(mysql_num_rows($result))
while($row=mysql_fetch_assoc($result))
{
/* The key of the $file_downloads array will be the name of the file,
and will contain the number of downloads: */

$file_downloads[$row['filename']]=$row['downloads'];
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP &amp; MySQL File Download Counter | Tutorialzine demo</title>

<link rel="stylesheet" type="text/css" href="styles.css" />
<link rel="stylesheet" type="text/css" href="fancybox/jquery.fancybox-1.2.6.css" media="screen" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="script.js"></script>

</head>

<body>

<h1>PHP &amp; MySQL File Download Counter</h1>
<h2>Go back <a href="http://tutorialzine.com/2010/02/php-mysql-download-counter/">to the tutorial &raquo;</a></h2>


<div id="file-manager">

<ul class="manager">
<?php

foreach($files_array as $key=>$val)
{
echo '<li><a href="download.php?file='.urlencode($val).'">'.$val.'
<span class="download-count" title="Times Downloaded">'.(int)$file_downloads[$val].'</span> <span class="download-label">download</span></a>
</li>';
}

?>
</ul>

</div>


<p class="tutInfo">This is a tutorialzine demo. View the <a href="http://tutorialzine.com/2010/02/php-mysql-download-counter/">original tutorial</a>, or download the <a href="demo.zip">source files</a>.</p>

</body>
</html>


صفحه Download


<?php

// Error reporting:
error_reporting(E_ALL^E_NOTICE);

// Including the connection file:
require('connect.php');

if(!$_GET['file']) error('Missing parameter!');
if($_GET['file']{0}=='.') error('Wrong file!');

if(file_exists($directory.'/'.$_GET['file']))
{
/* If the visitor is not a search engine, count the downoad: */
if(!is_bot())
mysql_query(" INSERT INTO download_manager SET filename='".mysql_real_escape_string($_GET['file'])."'
ON DUPLICATE KEY UPDATE downloads=downloads+1");

header("Location: ".$directory."/".$_GET['file']);
exit;
}
else error("This file does not exist!");


/* Helper functions: */

function error($str)
{
die($str);
}


function is_bot()
{
/* This function will check whether the visitor is a search engine robot */

$botlist = array("Teoma", "alexa", "froogle", "Gigabot", "inktomi",
"looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory",
"Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot",
"crawler", "www.galaxy.com", "Googlebot", "Scooter", "Slurp",
"msnbot", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz",
"Baiduspider", "Feedfetcher-Google", "TechnoratiSnoop", "Rankivabot",
"Mediapartners-Google", "Sogou web spider", "WebAlta Crawler","TweetmemeBot",
"Butterfly","Twitturls","Me.dium","Twiceler");

foreach($botlist as $bot)
{
if(strpos($_SERVER['HTTP_USER_AGENT'],$bot)!==false)
return true; // Is a bot
}

return false; // Not a bot
}
?>


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

omidabedi
چهارشنبه 14 اسفند 1392, 23:13 عصر
توی انجمن asp مطرح کنید برادر من