Archive | December, 2005

URL Tool

15 Dec

All links at one place

#include <GUIConstants.au3>
#include <file.au3>
#include <Process.au3>

Global $Handle = ""
$ListItems = ""
$CountLines = ""
$File = ""
$OldFile = ""
$OpenedFile = ""

GUICreate("URLs", 500, 500)

$FileMenu = GUICtrlCreateMenu ("&File")
$NewID = GUICtrlCreateMenuitem ("New",$FileMenu)
$OpenID = GUICtrlCreateMenuitem ("Open",$FileMenu)

$ListBoxID=GUICtrlCreateList ("", 10,35,480,415)
$AddID  = GUICtrlCreateButton("Add", 10, 5, 50, 20)
$DeleteID = GUICtrlCreateButton("Delete", 70, 5, 50, 20)
$EditLinkID = GUICtrlCreateButton("Edit Link", 130, 5, 70, 20)
$EditMemoID = GUICtrlCreateButton("Edit Memo", 210, 5, 70, 20)
$MoveID = GUICtrlCreateButton("Move", 290, 5, 70, 20)
$SurfID = GUICtrlCreateButton("Surf", 370, 5, 50, 20)

GUISetState ()

ButtonActive($GUI_DISABLE)
Do
 $msg = GUIGetMsg()
 Select
  Case $msg= $OpenID
   $Run = 0
   $OldFile = $OpenedFile
   $message = "Open What File?"
   $OpenedFile = FileOpenDialog($message, @ScriptDir & "\List\", "All (*.lst)")

   If @error Then
        MsgBox(4096,"","No file chosen")
    $OpenedFile = $OldFile
   Else
        $OpenedFile = StringReplace($OpenedFile, "|", @CRLF)
    $Run = 1
   EndIf

   If $Run = 1 Then
    RefreshListBox()
    ButtonActive($GUI_ENABLE)
   EndIf
   GUICtrlCreateLabel ("",  15, 450, 480, 100)

  Case $msg= $NewID
   $NewFile = InputBox("Add New File", "Type File Name", "", "", 200, 100)
   $OpenedFile = @ScriptDir & "\List\" & $NewFile & ".lst"
   FileWriteLine($OpenedFile, "")
   $NewDesFile = @ScriptDir & "\List\" & $NewFile & ".lst.des"
   FileWriteLine($NewDesFile, "")

   ButtonActive($GUI_ENABLE)
   GUICtrlSetData($ListBoxID,"")
   GUICtrlCreateLabel ("",  15, 450, 480, 100)

  Case $msg= $AddID
   $AddItem = InputBox("Add", "Type The Link", "", "", 200, 100)
   FileWrite($OpenedFile, $AddItem & @LF)

   $File = $OpenedFile & ".des"
   $AddDes = InputBox("Add", "Type The Memo", "", "", 200, 100)
   If $AddDes = "" Then
    FileWrite($File, $AddItem & @LF)
   Else
    FileWrite($File, $AddDes & @LF)
   EndIf

   RefreshListBox()
  
  Case $msg= $DeleteID
   $File = $OpenedFile & ".des"
   $CountLines = _FileCountLines($File)
   $SelectedList = GUICtrlRead($ListBoxID)
   DeleteDesLine ($File, $SelectedList)

   $CountLines = _FileCountLines($OpenedFile)
   $Handle = FileOpen($OpenedFile, 0)
   If $Handle = -1 Then
        MsgBox(0x10, 'Error', 'Could not open the file:' & @LF & $OpenedFile)
   EndIf
   $SelectedList = GUICtrlRead($ListBoxID)
   $Index = FindLineIndex($SelectedList)
   FileClose($Handle)
   DeleteTheLine ($Index)

   $CountLines = _FileCountLines($File)
   RefreshListBox()

   GUICtrlCreateLabel ("",  15, 450, 480, 100)

  Case $msg= $EditLinkID
   $File = $OpenedFile & ".des"
   $CountLines = _FileCountLines($File)
   $Handle = FileOpen($File, 0)
   If $Handle = -1 Then
        MsgBox(0x10, 'Error', 'Could not open the file:' & @LF & $File)
   EndIf
   $SelectedList = GUICtrlRead($ListBoxID)
   $Index = FindLineIndex($SelectedList)
   FileClose($Handle)

   $CountLines = _FileCountLines($OpenedFile)
   $Handle = FileOpen($OpenedFile, 0)
   If $Handle = -1 Then
        MsgBox(0x10, 'Error', 'Could not open the file:' & @LF & $OpenedFile)
   EndIf
   $Link=FindLineMessage($Index)
   FileClose($Handle)

   $NewLink = InputBox("New Link", "Type New Link", $Link, "", 200, 100)
   ReplaceTheLine ($OpenedFile, $Index, $NewLink)
  
   GUICtrlCreateLabel ($NewLink,  15, 450, 480, 100)

  Case $msg= $EditMemoID
   $File = $OpenedFile & ".des"
   $CountLines = _FileCountLines($File)
   $SelectedList = GUICtrlRead($ListBoxID)
   $NewDes = InputBox("New Label", "Type Messages", $SelectedList, "", 200, 100)
   ReplaceTheLine ($File, $Index, $NewDes)

   RefreshListBox()

  Case $msg= $MoveID
   $message = "Move To Which File?"
   $MoveFile = FileOpenDialog($message, @ScriptDir & "\List\", "All (*.lst)")
   If $MoveFile = $OpenedFile Then
    MsgBox(0, "???", "Do Not Select Same File!")
   Else
    ;get memo
    $MoveDes = GUICtrlRead($ListBoxID)

    ;get link
    $CountLines = _FileCountLines($OpenedFile)
    $Handle = FileOpen($OpenedFile, 0)
    If $Handle = -1 Then
         MsgBox(0x10, 'Error', 'Could not open the file:' & @LF & $OpenedFile)
    EndIf
    $SelectedList = GUICtrlRead($ListBoxID)
    $Index = FindLineIndex($SelectedList)
    FileClose($Handle)

    $CountLines = _FileCountLines($OpenedFile)
    $Handle = FileOpen($OpenedFile, 0)
    If $Handle = -1 Then
         MsgBox(0x10, 'Error', 'Could not open the file:' & @LF & $OpenedFile)
    EndIf
    $MoveItem=FindLineMessage($Index)
    FileClose($Handle)

    FileWrite($MoveFile, $MoveItem & @LF)
    $File = $MoveFile & ".des"
    FileWrite($File, $MoveDes & @LF)

    ;same delete function
    $File = $OpenedFile & ".des"
    $CountLines = _FileCountLines($File)
    $SelectedList = GUICtrlRead($ListBoxID)
    DeleteDesLine ($File, $SelectedList)

    $CountLines = _FileCountLines($OpenedFile)
    $Handle = FileOpen($OpenedFile, 0)
    If $Handle = -1 Then
         MsgBox(0x10, 'Error', 'Could not open the file:' & @LF & $OpenedFile)
    EndIf
    $SelectedList = GUICtrlRead($ListBoxID)
    $Index = FindLineIndex($SelectedList)
    FileClose($Handle)
    DeleteTheLine ($Index)

    $CountLines = _FileCountLines($File)
    RefreshListBox()

    GUICtrlCreateLabel ("",  15, 450, 480, 100)

   EndIf

  Case $msg= $SurfID
   $File = $OpenedFile & ".des"
   $CountLines = _FileCountLines($File)
   $Handle = FileOpen($File, 0)
   If $Handle = -1 Then
        MsgBox(0x10, 'Error', 'Could not open the file:' & @LF & $File)
   EndIf
   $SelectedList = GUICtrlRead($ListBoxID)
   $Index = FindLineIndex($SelectedList)
   FileClose($Handle)

   $CountLines = _FileCountLines($OpenedFile)
   $Handle = FileOpen($OpenedFile, 0)
   If $Handle = -1 Then
        MsgBox(0x10, 'Error', 'Could not open the file:' & @LF & $OpenedFile)
   EndIf
   $Link=FindLineMessage($Index)
   FileClose($Handle)
 
   $rc = _RunDos("start " & $Link)

  Case $msg= $ListBoxID
   $CountLines = _FileCountLines($File)

   $Handle = FileOpen($File, 0)
   If $Handle = -1 Then
        MsgBox(0x10, 'Error', 'Could not open the file:' & @LF & $OpenedFile)
   EndIf

   $SelectedList = GUICtrlRead($ListBoxID)
   $Index = FindLineIndex($SelectedList)
   FileClose($Handle)

   $Handle = FileOpen($OpenedFile, 0)
   If $Handle = -1 Then
       MsgBox(0x10, 'Error', 'Could not open the file:' & @LF & $OpenedFile)
   EndIf
   $LineRead = FileReadLine($Handle, $Index)
   FileClose($Handle)
   GUICtrlCreateLabel ($LineRead,  15, 450, 480, 100)
 
 EndSelect
Until $msg = $GUI_EVENT_CLOSE

Func FindLineIndex($x)
    For $i = 1 to $CountLines Step 1
     $NextLine = FileReadLine($Handle)
        If @Error Then  ;The end of the file has been reached.
         Done()
        EndIf
    If $NextLine == $x Then
  ;MsgBox(0x10, 'Error', $i)
  $Index = $i
    EndIf
    Next
    Return $Index
EndFunc

Func FindLineMessage($x)
    For $i = 1 to $CountLines Step 1
     $NextLine = FileReadLine($Handle)
        If @Error Then  ;The end of the file has been reached.
         Done()
        EndIf
    If $i == $x Then 
  $Memo = $NextLine        
    EndIf
    Next
    Return $Memo
EndFunc

Func DeleteTheLine ($x)
    FileCopy($OpenedFile, "Temp.txt")
    FileDelete($OpenedFile)
    For $i = 1 to $CountLines Step 1
    $Text = FileReadLine("Temp.txt", $i)
    If $i <> $x Then
        FileWriteLine($OpenedFile, $Text)
    EndIf
    Next
    FileDelete("Temp.txt")
EndFunc

Func DeleteDesLine ($File, $x)
    FileCopy($File, "Temp.txt")
    FileDelete($File)
    For $i = 1 to $CountLines Step 1
    $Text = FileReadLine("Temp.txt", $i)
    If $Text <> $x Then
        FileWriteLine($File, $Text)
    EndIf
    Next
    FileDelete("Temp.txt")
EndFunc

Func ReplaceTheLine ($File, $x, $NewDes)
    FileCopy($File, "Temp.txt")
    FileDelete($File)
    For $i = 1 to $CountLines Step 1
    $Text = FileReadLine("Temp.txt", $i)
    If $i == $x Then
        FileWriteLine($File, $NewDes)
 Else
     FileWriteLine($File, $Text)
    EndIf
    Next
    FileDelete("Temp.txt")
EndFunc

Func Done()
    FileClose($Handle)
    $myLoop = 0
EndFunc

Func ButtonActive($ENABLE_DISABLE)
 GUICtrlSetState ($AddID, $ENABLE_DISABLE)
 GUICtrlSetState ($DeleteID, $ENABLE_DISABLE)
 GUICtrlSetState ($EditLinkID, $ENABLE_DISABLE)
 GUICtrlSetState ($EditMemoID, $ENABLE_DISABLE)
 GUICtrlSetState ($MoveID, $ENABLE_DISABLE)
 GUICtrlSetState ($SurfID, $ENABLE_DISABLE)
EndFunc

Func RefreshListBox()
 $myLoop = 1
 $File = $OpenedFile & ".des"
 $Handle = FileOpen($File, 0)
 If $Handle = -1 Then
      MsgBox(0x10, 'Error', 'Could not open the file:' & @LF & $File)
      $myLoop = 0
 EndIf

 GUICtrlSetData($ListBoxID,"")
 $ListItems = ""
 while $myLoop == 1
      $NextLine = FileReadLine($Handle)
      If @Error Then ;The end of the file has been reached.
   GUICtrlSetData($ListBoxID, $ListItems)
   GUISetState ()
       $myLoop = 0
      EndIf
     $ListItems = $ListItems & $NextLine & "|"
 WEnd
     FileClose($Handle)
EndFunc

Auto Defrag

14 Dec

Msgbox(0,"Info by Joe. R","Auto Defrag All Harddisks & Shutdown PC")

If (@OSVersion <> "WIN_XP") AND (@OSVersion <> "WIN_2000") Then
 Msgbox(0,"Info  by X-Guy",@OSVersion & " Not Tested!")
EndIf

BlockInput(1)
Run("defrag.bat")
WinWait("Disk Defragmenter")

$var = DriveGetDrive( "FIXED" )

$bLoop = 0
While $bLoop <> $var[0]

 WinActivate("Disk Defragmenter", "")
 Send("!A")
 Send("d")
 BlockInput(0)

 If @OSVersion == "WIN_XP" Then
  WinWait("Disk Defragmenter", "Defragmentation is complete")
 Else
  WinWait("Defragmentation Complete")
 EndIf

 BlockInput(1)
 If @OSVersion == "WIN_XP" Then
  WinActivate("Disk Defragmenter", "")
 Else
  WinActivate("Defragmentation Complete", "")
  ControlClick("Defragmentation Complete", "", "")
 EndIf
 Send("{TAB}")
 Send("{ENTER}")
 WinActivate("Disk Defragmenter", "")
 ControlSend ( "Disk Defragmenter", "", "SysListView321", "{DOWN}")

 $bLoop = $bLoop + 1
WEnd

WinActivate("Disk Defragmenter", "")
Send("!{F4}")
BlockInput(0)

Shutdown(8)

;0 = Logoff
;1 = Shutdown
;2 = Reboot
;4 = Force
;8 = Power down
;32= Suspend
;64= Hibernate

CD Open

13 Dec

#include <GUIConstants.au3>

$Drive = ""
GUICreate("Drive Tool by Joe. R", 240, 40)

$n1=GUICtrlCreateCombo ("", 7, 10, 40)
$var = DriveGetDrive( "CDROM" )

$all=""
For $i = 1 to $var[0]
    $all = $all & $var[$i] & "|"
Next

GUICtrlSetData(-1, $all, $var[1])

$OpenID  = GUICtrlCreateButton("Open", 60, 10, 50, 20)
$CloseID = GUICtrlCreateButton("Close", 120, 10, 50, 20)
$ExitID = GUICtrlCreateButton("Exit", 180, 10, 50, 20)

GUISetState ()       ; will display an empty dialog box with a combo control with focus on

Do
 $msg = GUIGetMsg()
        $Drive = GUICtrlRead($n1)
 Select
  Case $msg= $OpenID
   CDTray($Drive, "open")
  Case $msg= $CloseID
   CDTray($Drive, "close")
 EndSelect

Until $msg = $GUI_EVENT_CLOSE or $msg = $ExitID

Edit Blogspot Comments

12 Dec

<span class="item-control admin-XXXXXXXXXX pid-YYYYYYYYYY"><a href="http://www.blogger.com/post-edit.g?blogID=<$BlogID$>&postID=<$BlogCommentNumber$>&quickEdit=true&quot; title="Edit Comment"><span class="quick-edit-icon"> </span></a></span>

Script from Blogger-Templates

No of Images

11 Dec

<?php
$handle=opendir('.');
$strSought = "gif";
$num = 0;

while ($file = readdir($handle)) {
if ($strSought == substr($file, -3)) {
$num = $num + 1;
}
}
closedir($handle);

$handle=opendir('.');
echo "There are $num files!<br><br>";

echo"<table>";
echo "<tr><td colspan = 5>Files:</td></tr>";

while ($file = readdir($handle)) {
if ($strSought == substr($file, -3)) {
$size = GetImageSize($file);
$fullsize = intval(filesize($file)*.001);
echo "<tr><td><a href=$file>$file</a></td><td>  <b>$size[0]</b></td><td> by</td><td> <b>$size[1]</b>:</td><td> $fullsize kb</td></tr>";
}
}
closedir($handle);
echo"</table>";
?>

Redirect To Another Site

10 Dec

Redirect your site to another. 

<?php

// Change to the URL you want to redirect to
$URL="http://www.freepgs.com/sitinurhaliza/v2/&quot;;

header ("Location: $URL");

?>

Php Info

9 Dec

Get the PHP server infomations 

<?php

// Show all information, defaults to INFO_ALL
phpinfo();

// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_ALL);

?>