Convert PHP Code to ASP.NET

General discussions related to php

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Mon Mar 10, 2014 8:28 pm

Convert PHP Code to ASP.NET

Postby giaspirit » Mon Mar 10, 2014 8:34 pm

hi every body
i have tow PHP Pages and i want convert to ASP.NET.
Demo Page:

Code: Select all

// Error reporting:
// Including the DB connection file:
require 'connect.php';
$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;
/* Sorting the files alphabetically */
$result = mysql_query("SELECT * FROM download_manager");
    /*     The key of the $file_downloads array will be the name of the file,
        and will contain the number of downloads: */
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="">
<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=""></script>
<script type="text/javascript" src="script.js"></script>
<h1>PHP &amp; MySQL File Download Counter</h1>
<h2>Go back <a href="">to the tutorial &raquo;</a></h2>
<div id="file-manager">
    <ul class="manager">
        foreach($files_array as $key=>$val)
            echo '<li><a href="download.php?file='.urlencode($val).'">'.$va  l.'
                    <span class="download-count" title="Times Downloaded">'.(int)$file_downloads[$val].'</span> <span class="download-label">download</span></a>
<p class="tutInfo">This is a tutorialzine demo. View the <a href="">original tutorial</a>, or download the <a href="">source files</a>.</p>

Download Page:

Code: Select all

// Error reporting:
// Including the connection file:
if(!$_GET['file']) error('Missing parameter!');
if($_GET['file']{0}=='.') error('Wrong file!');
    /* If the visitor is not a search engine, count the downoad: */
    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']);
else error("This file does not exist!");
/* Helper functions: */
function error($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", "", "Googlebot", "Scooter", "Slurp",
    "msnbot", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz",
    "Baiduspider", "Feedfetcher-Google", "TechnoratiSnoop", "Rankivabot",
    "Mediapartners-Google", "Sogou web spider", "WebAlta Crawler","TweetmemeBot",
    foreach($botlist as $bot)
        return true;    // Is a bot
    return false;    // Not a bot

*: attach the file too
thanks very much
(2.18 KiB) Downloaded 49 times

Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 7 guests