Changing CDONT (asp) to PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
WebSpirit
Forum Newbie
Posts: 3
Joined: Mon Mar 01, 2010 2:57 am

Changing CDONT (asp) to PHP

Post by WebSpirit »

Hey There

I have a small problem, I have to change all my CDONT asp files to PHP because my new hosting does not support ASP, and I have to convert them to PHP, but I'm really stuck. Even if you can only give me a link to tutorials or something I need to get this done :banghead:

Thank you very much :D

this is one of the asp files (code) that I need to convert:

Code: Select all

<%@ Language=VBScript LCID=2057%>
<% Option Explicit %>
<!-- #include file="db.asp" -->
<!-- #include file="adovbs.inc" -->
<%
Dim FTimeZoneID, FTimeDif, FTimeDifH, FTimeDifM, FTimeDifML
FTimeZoneID = CInt(Request.QueryString("TimeZoneID"))
Session("TimeZoneID") = FTimeZoneID
 
Const DefaultTimeDifH = - 2
Const DefaultTimeDifM = 0
 
 
CorrectDate
%>
<meta http-equiv=" pragma" content=" no-cache" > 
<style type="text/css">
<!--
body,td,th {
    font-family: Arial, Helvetica, sans-serif;
    color: #1E2B7A;
    font-size: 12px;
}
body {
    background-color: #FFFFFF;
}
.style2 {
    color: #1E2B7A;
    font-style: italic;
}
.style4 {color: #FFFFFF}
a:link {
    color: #1E2B7A;
    text-decoration: none;
}
a:visited {
    color: #1E2B7A;
    text-decoration: none;
}
a:hover {
    color: #1E2B7A;
    text-decoration: underline;
}
a:active {
    color: #1E2B7A;
    text-decoration: none;
}
.style12 {color: #FFFFFF; font-size: 10px; }
.style17 {font-size: 10px; font-weight: bold; color: #FFFFFF; }
.style20 {color: #1E2B7A; font-size: 10px; }
.style21 {color: #1E2B7A; font-weight: bold; }
.style22 {color: #1E2B7A; }
-->
</style>
 
<% IF Session("Refresh") <> 1 THEN %>
<script>
<!--
/*
Auto Refresh Page with Time script
By JavaScript Kit (javascriptkit.com)
Over 200+ free scripts here!
*/
 
//enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
var limit="1:00"
 
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}
function beginrefresh(){
if (!document.images)
return
if (parselimit==1)
window.location.reload()
else{ 
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"
else
curtime=cursec+" seconds left until page refresh!"
window.status=curtime
setTimeout("beginrefresh()",1000)
}
}
 
window.onload=beginrefresh
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
 
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
 
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<% END IF%>
<title>Channel Schedule</title><body onLoad="MM_preloadImages('../../Images/DateRange_over.gif','../../Images/ViewDate_over.gif','../../Images/Search_over.gif','../../Images/Print_over.gif')">
<table width="200" border="0">
  <tr>
    <td><img src="Images/Channel_Schedule.jpg" width="660" height="90" /></td>
  </tr>
  <tr>
    <td><img src="../BANNERS/Sml Banners/Sml_Schedule.jpg" width="660" height="18"></td>
  </tr>
</table>
<br>
<table width="664" border="0">
  <tr>
    <td colspan="3">Welcome to our up-to-date active schedule. </td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="3">&nbsp;</td>
    <td width="142"><div align="right" class="style21">
      <div align="right">Today's Date:</div>
    </div></td>
    <td width="123"><div align="left" class="style2">
        <% Response.Write FormatDateTime(AccDate,1) %>
    &nbsp;</div></td>
  </tr>
  <tr>
    <td colspan="3">&nbsp;</td>
    <td><div align="right" class="style21">Time:</div></td>
    <td><div align="left" class="style22"><em>
      <% Response.Write FormatDateTime(AccTime, 4) %>
    </em>(CAT)</div></td>
  </tr>
  <tr bgcolor="">
    <td width="146"><span class="style4">
      <label>
      <div align="center" class="style4"><a href="Search_W.asp" target="_self" ><img src="Images/Search.gif" alt="Search a programme/title" name="Search" width="100" height="40" border="0" id="Search" /></a>
        </label>
    </div></td>
    <td width="208" bgcolor=""><div align="center" class="style4"><a href="ViewDate_W.asp" target="_self"><a href="ViewDate_W.asp" target="_self"><a href="ViewDate_W.asp" target="_self"></a><a href="ViewDate_W.asp" target="_self" ><img src="Images/ViewDate.gif" alt="View a specific date" name="ViewDate" width="115" height="40" border="0" id="ViewDate" /></a></div></td>
    <td colspan="2" bgcolor=""><div align="center" class="style4"><a href="ViewPeriod_W.asp" target="_self" ><img src="Images/DateRange.gif" alt="View a certain Date Range" name="ViewDateRange" width="115" height="40" border="0" id="ViewDateRange" /></a></div></td>
    <td bgcolor=""><div align="center" class="style4"><a href="ViewPeriod_Print.asp" target="_self" ><img src="Images/Print.gif" alt="Print the schedule" name="Print" width="115" height="40" border="0" id="Print" /></a></div></td>
  </tr>
</table>
<p>
  <%
Dim strSQL, Conn, objRS, strSQL2, Conn2, objRS2
 
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open objConn
 
strSQL = "SELECT * FROM TimeZone ORDER BY TimeDif, Country ASC" 
        Set objRS = Server.CreateObject("ADODB.Recordset")
        objRS.Open strSQL, objConn, adOpenStatic, adLockReadOnly 
%>
</p>
<form name="form1">
<input name="FTimeZoneID" type="hidden" value="<%  Response.Write(FTimeZoneID)%>" />
  <p>You may select your Time Zone here:
   <select name="TimeZone" style="font-family: Verdana; font-size: 8pt; border-style: solid; border-width: 1px; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px" onChange="location=document.form1.TimeZone.options[document.form1.TimeZone.selectedIndex].value;" 
value="GO">
  <%
        DO WHILE NOT objRS.EOF
            IF objRS("TimeZoneID") = FTimeZoneID THEN %>
      <option value="LineUps_W.asp?TimeZoneID=<% Response.Write(objRS("TimeZoneID"))%>" selected>
      <% Response.Write(objRS("Country")) %>
      <% FTimeDif = objRS("TimeDif") %>
      </option> 
      <%
            ELSE %>
      <option value="LineUps_W.asp?TimeZoneID=<% Response.Write(objRS("TimeZoneID")) %>">
      <% Response.Write("[" & Left(objRS("TimeDif"),6) & "] " & objRS("Country")) %>
      </option>
      <%END IF
            objRS.MoveNext
        Loop
FTimeDifH = Left(FTimeDif, 3)
FTimeDifML = Left(FTimeDifH, 1)
FTimeDifM = Right(FTimeDif, 5)
FTimeDifM = (FTimeDifML & Left(FTimeDifM, 2))
%>
    </select>
   
</form>
<table width="664" border="0" cellpadding="0" cellspacing="0">
  <tr bgcolor="#1E2B7A" >
    <td width="6%" ><span class="style17">Time Zone:</span></td>
    <td width="6%" ><span class="style17"> CAT:</span></td>
    <td width="24%" ><span class="style17">Line-Up Info (A): </span></td>
    <td width="19%" align="center"><div align="left" class="style17"><strong>Line-Up Info (B)</strong>:</div></td>
    <td width="32%"  align="center"><div align="left" class="style17"><strong>Title/Description:</strong></div></td>
    <td width="13%"  align="center"><span class="style17">      More Info: <br />
      (if available) </span></td>
  </tr>
</table>
Up Next:
<%  
    CorrectDate
    Dim AValue, TDay, TMonth, TYear
    TDay = Day(AccDate)
    TMonth = Month(AccDate)
    TYear = Year(AccDate)
    AValue = (TMonth & "/" & TDay & "/" & TYear)
    strSQL2 = "SELECT * FROM Schedule WHERE CDate(AirDate) = CDate('"&AValue&"') AND CDate(LineUpTime) >= CDate('"&AccTime&"') ORDER BY LineUpTime" 
        Set objRS2 = Server.CreateObject("ADODB.Recordset")
        objRS2.Open strSQL2, objConn, adOpenStatic, adLockReadOnly 
        
        %>
<%    
DO WHILE NOT objRS2.EOF      
Dim FAirDate, FLineUpTime, FProgram, FTitle, FHost, FReference, FTimeZoneTime
%>
<table width="664" border="0" cellpadding="0" cellspacing="0">
  <tr bgcolor="#FFFFFF" onMouseOver="bgColor='#CCCCCC'" onMouseOut="bgColor='#FFFFFF'">
    <td width="6%" bgcolor="#FF0000" ><span class="style12"><font face="Verdana, Arial, Helvetica, sans-serif">
      <%
 
 
        'If no records
        IF objRS2.EOF THEN
            Response.Write("No programs found - Please visit again to view updated information!")
        'Collect the info on found record
        ELSE
            FAirDate = objRS2("AirDate")
            FLineUpTime = objRS2("LineUpTime")
            FProgram = objRS2("InfoFieldA")
            FTitle = objRS2("InfoFieldB")
            FHost = objRS2("InfoFieldC")
            FReference = objRS2("Reference")
            FTimeZoneTime = DateAdd("h", DefaultTimeDifH, FLineUpTime)
            FTimeZoneTime = DateAdd("n", DefaultTimeDifM, FTimeZoneTime)
            FTimeZoneTime = DateAdd("h", FTimeDifH, FTimeZoneTime)
            FTimeZoneTime = DateAdd("n", FTimeDifM, FTimeZoneTime)
            %>
    <%=  FormatDateTime(FTimeZoneTime, 4 )%></font> </span></td>
    <td width="6%" ><span class="style20"><font face="Verdana, Arial, Helvetica, sans-serif"><%= Left(FLineUpTime, 5)%></font> </span></td>
    <td width="24%" ><span class="style20"><font face="Verdana, Arial, Helvetica, sans-serif"><%= FProgram%></font> </span></td>
    <td width="19%" align="center"><div align="left" class="style20"><font face="Verdana, Arial, Helvetica, sans-serif"><%= FTitle%></font></div></td>
    <td width="32%"  align="center"><div align="left" class="style20"><font face="Verdana, Arial, Helvetica, sans-serif"><%= FHost%></font></div></td>
    <td width="13%"  align="center"><span class="style20">
      <a href="MoreInfo.asp?LineUpID=<% Response.Write objRS2("LineUpID") %>" target="_self" class="style4"><img src="Images/MoreInfo.gif" alt="More information on ' <% =FProgram%> '" width="11" height="17" border="0" /></a>
 
    </span></td>
  </tr>
</table>
<%
        END IF
        objRS2.MoveNext
    Loop    
 
objRS.Close
Set objRS = Nothing  
objRS2.Close
Set objRS = Nothing
Conn.Close
Set Conn = Nothing
%>
 
WebSpirit
Forum Newbie
Posts: 3
Joined: Mon Mar 01, 2010 2:57 am

Re: Changing CDONT (asp) to PHP

Post by WebSpirit »

okay, can it even be done then :?:
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Changing CDONT (asp) to PHP

Post by Eran »

Won't it be simpler to change hosting?
WebSpirit
Forum Newbie
Posts: 3
Joined: Mon Mar 01, 2010 2:57 am

Re: Changing CDONT (asp) to PHP

Post by WebSpirit »

Our Online Shopping is all in PHP and therefore we changed to this new hosting (linux) but now our asp files won't work. So yes I really need to change it to PHP.
Post Reply