Não entendo nada de PHP, será que alguém poderia dar uma força, redigitando o código (PHP) abaixo em ASP?
Obrigado
<?php include_once("php/dbconfig.php"); include_once("php/functions.php"); function getCalendarByRange($id){ try{ $db = new DBConnection(); $db->getConnection(); $sql = "select * from `jqcalendar` where `id` = " . $id; $handle = mysql_query($sql); //echo $sql; $row = mysql_fetch_object($handle); }catch(Exception $e){ } return $row; } if($_GET["id"]){ $event = getCalendarByRange($_GET["id"]); } ?>
<?php class DBConnection{ function getConnection(){ //change to your database server/user name/password mysql_connect("localhost","root","") or die("Could not connect: " . mysql_error()); //change to your database name mysql_select_db("jqcalendar") or die("Could not select database: " . mysql_error()); } } ?>
<?php function js2PhpTime($jsdate){ if(preg_match('@(\d+)/(\d+)/(\d+)\s+(\d+):(\d+)@', $jsdate, $matches)==1){ $ret = mktime($matches[4], $matches[5], 0, $matches[1], $matches[2], $matches[3]); //echo $matches[4] ."-". $matches[5] ."-". 0 ."-". $matches[1] ."-". $matches[2] ."-". $matches[3]; }else if(preg_match('@(\d+)/(\d+)/(\d+)@', $jsdate, $matches)==1){ $ret = mktime(0, 0, 0, $matches[1], $matches[2], $matches[3]); //echo 0 ."-". 0 ."-". 0 ."-". $matches[1] ."-". $matches[2] ."-". $matches[3]; } return $ret; } function php2JsTime($phpDate){ //echo $phpDate; //return "/Date(" . $phpDate*1000 . ")/"; return date("m/d/Y H:i", $phpDate); } function php2MySqlTime($phpDate){ return date("Y-m-d H:i:s", $phpDate); } function mySql2PhpTime($sqlDate){ $arr = date_parse($sqlDate); return mktime($arr["hour"],$arr["minute"],$arr["second"],$arr["month"],$arr["day"],$arr["year"]); } ?>
<?php include_once("dbconfig.php"); include_once("functions.php"); function addCalendar($st, $et, $sub, $ade){ $ret = array(); $ret['IsSuccess'] = true; $ret['Msg'] = 'add success'; $ret['Data'] =rand(); return $ret; } function addDetailedCalendar($st, $et, $sub, $ade, $dscr, $loc, $color, $tz){ $ret = array(); $ret['IsSuccess'] = true; $ret['Msg'] = 'add success'; $ret['Data'] = rand(); return $ret; } function listCalendarByRange($sd, $ed, $cnt){ $ret = array(); $ret['events'] = array(); $ret["issort"] =true; $ret["start"] = php2JsTime($sd); $ret["end"] = php2JsTime($ed); $ret['error'] = null; $title = array('team meeting', 'remote meeting', 'project plan review', 'annual report', 'go to dinner'); $location = array('Lodan', 'Newswer', 'Belion', 'Moore', 'Bytelin'); for($i=0; $i<$cnt; $i++) { $rsd = rand($sd, $ed); $red = rand(3600, 10800); if(rand(0,10) > 8){ $alld = 1; }else{ $alld=0; } $ret['events'][] = array( rand(10000, 99999), $title[rand(0,4)], php2JsTime($rsd), php2JsTime($red), rand(0,1), $alld, //more than one day event 0,//Recurring event rand(-1,13), 1, //editable $location[rand(0,4)], ''//$attends ); } return $ret; } function listCalendar($day, $type){ $phpTime = js2PhpTime($day); //echo $phpTime . "+" . $type; switch($type){ case "month": $st = mktime(0, 0, 0, date("m", $phpTime), 1, date("Y", $phpTime)); $et = mktime(0, 0, -1, date("m", $phpTime)+1, 1, date("Y", $phpTime)); $cnt = 50; break; case "week": //suppose first day of a week is monday $monday = date("d", $phpTime) - date('N', $phpTime) + 1; //echo date('N', $phpTime); $st = mktime(0,0,0,date("m", $phpTime), $monday, date("Y", $phpTime)); $et = mktime(0,0,-1,date("m", $phpTime), $monday+7, date("Y", $phpTime)); $cnt = 20; break; case "day": $st = mktime(0, 0, 0, date("m", $phpTime), date("d", $phpTime), date("Y", $phpTime)); $et = mktime(0, 0, -1, date("m", $phpTime), date("d", $phpTime)+1, date("Y", $phpTime)); $cnt = 5; break; } //echo $st . "--" . $et; return listCalendarByRange($st, $et, $cnt); } function updateCalendar($id, $st, $et){ $ret = array(); $ret['IsSuccess'] = true; $ret['Msg'] = 'Succefully'; return $ret; } function updateDetailedCalendar($id, $st, $et, $sub, $ade, $dscr, $loc, $color, $tz){ $ret = array(); $ret['IsSuccess'] = true; $ret['Msg'] = 'Succefully'; return $ret; } function removeCalendar($id){ $ret = array(); $ret['IsSuccess'] = true; $ret['Msg'] = 'Succefully'; return $ret; } header('Content-type:text/javascript;charset=UTF-8'); $method = $_GET["method"]; switch ($method) { case "add": $ret = addCalendar($_POST["CalendarStartTime"], $_POST["CalendarEndTime"], $_POST["CalendarTitle"], $_POST["IsAllDayEvent"]); break; case "list": $ret = listCalendar($_POST["showdate"], $_POST["viewtype"]); break; case "update": $ret = updateCalendar($_POST["calendarId"], $_POST["CalendarStartTime"], $_POST["CalendarEndTime"]); break; case "remove": $ret = removeCalendar( $_POST["calendarId"]); break; case "adddetails": $id = $_GET["id"]; $st = $_POST["stpartdate"] . " " . $_POST["stparttime"]; $et = $_POST["etpartdate"] . " " . $_POST["etparttime"]; if($id){ $ret = updateDetailedCalendar($id, $st, $et, $_POST["Subject"], $_POST["IsAllDayEvent"]?1:0, $_POST["Description"], $_POST["Location"], $_POST["colorvalue"], $_POST["timezone"]); }else{ $ret = addDetailedCalendar($st, $et, $_POST["Subject"], $_POST["IsAllDayEvent"]?1:0, $_POST["Description"], $_POST["Location"], $_POST["colorvalue"], $_POST["timezone"]); } break; } echo json_encode($ret); ?>