帮我转成php
——————————————————————————————
require ('ucookie.pl');
&checkCookie;
ReadParse();use Win32::ODBC;
$npx_odbcmax = 687200;
$db = new Win32::ODBC("DSN=$dbname;UID=sa;PWD=$dbpass");
$npx_tmp = $db->SetMaxBufSize($npx_odbcmax);# check for pkey (edit mode)
$pkey = $cgi{pkey};######### CHECKING SECURITY TOKENS ######################
# general access       = 1
# corporate access     = 2
# project admin access = 1 or 2
# site admin access    = 3
#
# DEFAULT SETTINGS
$access = 0;
$access{internal} = 0;
$access{add} = 0;
$access{edit} = 0;
$access{delete} = 0;
#
# CHECKING IF SITE ADMIN
if ($access == 0) {
$sql = "SELECT id FROM users WHERE id = $authenticated AND enabled=3";
$rc = $db->Sql($sql);
if ($db->FetchRow()) {
$access = 3;
$access{internal} = 1;
$access{add} = 1;
$access{edit} = 1;
$access{delete} = 1;
}
}
#
# CHECKING IF CORPORATE USER
if ($access == 0) {
$sql = "SELECT id,emptype FROM users WHERE id = $authenticated AND enabled=2";
$rc = $db->Sql($sql);
if ($db->FetchRow()) {
$emptype = $db->Data("emptype");
$access = 2;
$access{internal} = $emptype;
$access{add} = 1;
$access{edit} = 0;
$access{delete} = 0;
}
}
#
# CHECKING IF PROJECT ADMIN
if ($access == 0) {
$psql = "SELECT * FROM users,projectAccess WHERE userid=id AND userid=$authenticated AND enabled > 0 AND writable=3";
$prc = $db->Sql($psql);
if ($db->FetchRow()) {
$emptype = $db->Data("emptype");
$enabled = $db->Data("enabled");
$access = $enabled;
$access{internal} = $emptype;
$access{add} = 1;
$access{edit} = 1;
$access{delete} = 1;
}
}
#
# CHECKING IF GENERAL USER WITH ACCESS
if ($access == 0) {
$psql = "SELECT * FROM users,projectAccess WHERE userid=id AND userid=$authenticated AND enabled > 0 AND writable > 0";
$prc = $db->Sql($psql); if ($db->FetchRow()) {
$emptype = $db->Data("emptype");
$enabled = $db->Data("enabled");
$access = $enabled;
$access{internal} = $emptype;
$access{add} = 0;
$access{edit} = 0;
$access{delete} = 0;
}
}
#
# IF ACCESS IS DENIED
if ($access < 2) {
&deniedAccess;
}
#
############ END SECURITY TOKEN SECTION ###########################

解决方案 »

  1.   


    if ($pkey ne "") {
    $mode = "edit";
    # non-numeric pkey causes db error
    if (!($pkey =~ /^\d+$/)) { $pkey = "-1"; }
    $sql = "SELECT * FROM projects WHERE pkey = " . $pkey;
    $rc = $db->Sql($sql);
    if ($db->FetchRow()) { %proj = $db->DataHash(); }
    else {
    print "Content-type: text/html\n\n";
    print "<h2>Project not found ($pkey)</h2><br>\n";
    exit;
    }
    %proj = $db->DataHash();
    }else {
    # only site admins can add a project
    if ($access{add} != 1) {
    print "Content-type: text/html\n\n";
    print "<body><center><br><br><table border=1 cellpadding=20><tr><td valign=top><font face=verdana><b>You do not have access to this section of the website.</font></b></td></tr></table></center></body>";
    exit;
    }
    $mode = "add";
    $pkey = -1;
    $proj{displaymap} = "1";
    $proj{displayweather} = "1";
    $proj{displayschedule} = "0";
    }
    print "Content-type: text/html\n\n";
    print "<html>
    <head>
    <title>$titleheader :: Add/Edit Project</title>
    <script>"; print "var headcompid = new Array();\n";
    print "var headcomp = new Array();\n"; $sql = "SELECT compid,company FROM company WHERE parentid=0 ORDER BY displayorder,company";
    $rc = $db->Sql($sql);
    $headnum =0;
    while ($db->FetchRow()) {
    print "headcompid[$headnum] = \"" . $db->Data("compid") . "\";\n";
    print "headcomp[$headnum] = \"" . $db->Data("company") . "\";\n";
    $headnum = $headnum + 1;
    } print "\n
    numHeadComp = \"$headnum\";\n"; print "var parentid = new Array();\n";
    print "var companyid = new Array();\n";
    print "var companyname = new Array();\n"; $num = 0;
    $sql = "SELECT company,compid,parentid FROM company WHERE parentid>0 ORDER BY parentid,displayorder"; $rc = $db->Sql($sql); $num = 0;
    if ($db->FetchRow()) {
    print "parentid[$num] = \"" . $db->Data("parentid") . "\";\n";
    print "companyid[$num] = \"" . $db->Data("compid") . "\";\n";
    print "companyname[$num] = \"" . $db->Data("company") . "\";\n";
    $num = $num + 1;
    while ($db->FetchRow()) {
    print "parentid[$num] = \"" . $db->Data("parentid") . "\";\n";
    print "companyid[$num] = \"" . $db->Data("compid") . "\";\n";
    print "companyname[$num] = \"" . $db->Data("company") . "\";\n";
    $num = $num + 1;
    }
    } else {
    print "parentid[$num] = \"0\";\n";
    print "companyid[$num] = \"0\";\n";
    print "companyname[$num] = \"&nbsp;\";\n";
    $num = $num + 1;
    }
    print "\n"; print "\n
    numSubComp = \"$num\";\n
      

  2.   

    function showRSF() {
    rsf = document.forms[\"the_form\"].rsf;
    showrsf = document.forms[\"the_form\"].showrsf; showrsf.value = \"\"; showrsf.value = rsf.value;
    } function showCity() {
    city = document.forms[\"the_form\"].city;
    showcity = document.forms[\"the_form\"].showcity; showcity.value = \"\"; showcity.value = city.value;
    } function showRegion() {
    region = document.forms[\"the_form\"].region;
    showreg = document.forms[\"the_form\"].showreg; showreg.value = \"\"; showreg.value = region.value;
    }