[ale] PHP question

scottb at pixel-group.com scottb at pixel-group.com
Wed Nov 21 16:07:06 EST 2001


I am new to php I usually use asp but I am trying to port over is am triong
to use an " if then " how do I go about doing that in php here are my
samples
////////////////////////asp/////////////////////////////////////////////////
/
<% 

    Dim objFSO, objFolder, objFiles, objFile, strFile, Title, CurLine,
LCaseLine, TitlePos, PageCount, FontColour

    Private Sub GetTitle(FileName)
        Dim fso, file, strPhysicalPath

        Title = ""
        set fso = Server.Createobject("Scripting.FileSystemObject") 
        strPhysicalPath = Server.MapPath(FileName) 
        set file = fso.opentextfile(strPhysicalPath, 1)
        do until file.AtEndOfStream or Len(Title) > 0
            CurLine = file.ReadLine
            LCaseLine = LCase(CurLine)
            TitlePos = InStr(LCaseLine, "<title>")
  
            if TitlePos then
                Title = Right(CurLine, Len(CurLine) - TitlePos - 6)
                'Title = Right(CurLine, Len(CurLine))
                Title = Left(Title, InStr(LCaseLine, "</title>"))
            end if
        loop
        file.close
    End Sub

    Set objFSO = Server.CreateObject("Scripting.FileSystemObject") 
    Set objFolder = objFSO.GetFolder(Server.MapPath("."))
    Set objFiles = objFolder.Files
    PageCount = 0
    For Each objFile in objFiles 
        strFile = LCase(objFile.Name) 
        If (strFile) = (strFile) then
            GetTitle(objFile.Name)
            
            'if Len(Title) < 0 or Title = instr(1,Title,"*") then
            'PageCount = PageCount + 0
            'end if
            
            'if Len(Title) > 0 or Title = instr(1,Title,"*") then
            
            if Len(Title) > 0 and instr(1,title,"*") = 0 then
                PageCount = PageCount + 1
                if objFile.DateLastModified >= Date - 7 then
                    FontColour = "<FONT COLOR=#FF0000>"
                else
                    FontColour = "<FONT COLOR=#000000>"
                end if
                Response.Write("<TR><TD><A HREF=""" & strFile & """>" & _
                    strFile & "</A></TD><TD ALIGN=""RIGHT"">" & _
                    FontColour & DateValue(objFile.DateLastModified) &
"</FONT>" & _
                    "</TD><TD>" & Title & "</TD></TR>")
            end if
        end if
    next
    Response.Write("<TR><TD> </TD><TD> </TD><TD><B>Total pages: " &
PageCount & "</B></TD></TR>")
%>
////////////////////////////////////////////////////////////////////////////
//////////////////

///////////////////////////////php//////////////////////////////////////////
/////////////////

<? 


$Private$SubGetTitle($FileName);

$Title="";
// $fso is of type "Scripting.FileSystemObject"

$strPhysicalPath=($FileName);
// asp2php says 'huh'?: $opentextfile[$strPhysicalPath,1];
while(!($file$AtEndOfStream || strlen($Title)>0))
{

  $CurLine=$file.$ReadLine;
  $LCaseLine=strtolower($CurLine);
  $TitlePos=(strpos($LCaseLine,"<title>") ? strpos($LCaseLine,"<title>")+1 :
0);

  if ($TitlePos)
  {

    $Title=substr($CurLine,strlen($CurLine)-(strlen($CurLine)-$TitlePos-6));
//Title = Right(CurLine, Len(CurLine))
    $Title=substr($Title,0,(strpos($LCaseLine,"</title>") ?
strpos($LCaseLine,"</title>")+1 : 0));
  } 

} 
$file.$close;
$End$Sub;

// $objFSO is of type "Scripting.FileSystemObject"

$GetFolder("."));
;
}
  else
{

$FontColour="<FONT COLOR=#000000>";
;
}
;
}
[// asp2php says 'huh'?:
$objFolder.$Files$PageCount=0$For$Each$objFile$in$objFiles$strFile=strtolowe
r($objFile.$Name)$If[$strFile]=($strFile)$thenGetTitle($objFile.$Name)$ifstr
len($Title)>0&(strpos(1,$title,"*") ? strpos(1,$title,"*")+1 :
0)=0$then$PageCount=$PageCount+1$if$objFile.$DateLastModified>=strftime("%m/
%d/%Y")-7$then$FontColour="<FONT
COLOR=#FF0000>"$if$Response.$Write["<TR><TD><A
HREF=\"".$strFile."\">".$strFile."</A></TD><TD
ALIGN=\"RIGHT\">".$FontColour.$DateValue[$objFile.$DateLastModified]."</FONT
>"."</TD><TD>".$Title."</TD></TR>"]$next$Response.$Write["<TR><TD> </TD><TD>
</TD><TD><B>Total pages: ".$PageCount."</B></TD></TR>"]]

---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list