`// ************************************************************************************************************************************************************************************************
`// ALL COPYRIGHT NOTICES AND COMMENTS MUST REMAIN UNALTERED WITHIN THIS SOURCE CODE
`// ************************************************************************************************************************************************************************************************
`// AntiPhorm (Lite)
`// Signal To Noise
`// Intelligent Surfing Simulator
`// Version 1.33
`// www.AntiPhorm.com
`// COPYRIGHT 2008 AntiPhorm.com
`// General : info@antiphormm.com
`// Bugs : bugs@antiphorm.com
`// Press : pr@antiform.com
`// Compiled in DarkBasic Professional Version 1.066
`// Running in Windowed Mode 640x480
`// =======================================================================================================================================================
`// RELEASE NOTES VERSION 1.33 FULL RELEASE
`// =======================================================================================================================================================
remstart
AntiPhorm Lite 1.33 FULL RELEASE (source and build available at WWW.ANTIPHORM.COM)
25th May 2008
Bugs & Improvements:
- Fixed a problem where Hidden mode in rev 1.32 had failed to hide window, due to simple commented out code - COMPLETE
- added key input command functions to extend functionality - COMPLETE
- added pause state to pause and resume application when required (in hidden or browser modes only) - COMPLETE
- Fixed a problem that caused some Firefox browsers to open new windows - COMPLETE
- Fixed a few bad homelinks in the database (typos) - COMPLETE
- Added browser on/off mode when in either browser or text only modes.
`// ================================================================================================================================================================================================
`// RELEASE NOTES VERSION 1.32 FULL RELEASE
`// ================================================================================================================================================================================================
AntiPhorm Lite 1.32 FULL RELEASE (source and build available at WWW.ANTIPHORM.COM)(ARCHIVED)
19th May 2008
Bugs & Improvements:
- Fixed tabbed browsing for Firefox users 1.4+ XP Only Now runs in a single tab. You can also open new tabs to switch focus. - COMPLETE
- For Internet Explorer Users go to Tools>Internet Options>Tab Settings> and set Open Links from other programs to "The Current tab or window" option. - COMPLETE
- Zero entries in the HomeSearch and Home Link database crashed the app - FIXED
- Re-written a more robust function for selecting home or search criteria in the NewHomeUrl() - FIXED
- While reading the caption file tags, html formating tags where corrupting the log files - FIXED
- Added default data entries to databases in case the file was not found or contained empty entries - COMPLETE
- Added a feature to exit the application if exclusion or caption databases are empty or missing - COMPLETE
- Added color formating to output console for easier reading. - COMPLETE
- Added a feature to replace some special characters to help with parsing of some sites - COMPLETE
- Added ini settings on startup. (Customize these settings in the AntiPhormLite.ini file using notepad.) - COMPLETE
- Added more entries to the HomeLinks.txt file for extended diversity. Remember - You can edit these txt files yourself and add and remove any link. The more diverse the better. - COMPLETE
- Added ignore page on pages that fail to load or are missing (404 errors)
CleanUp:
- Removed a few lines of redundant code. - COMPLETE
- Fixed some comments to explain the code a little better. - COMPLETE
To Do
- Fix tabbed browsing issue for Mozilla Vista Users. - IN PROGRESS
=======================================================================================================================================================
Release Notes. 1.31 - Original Public Beta Release
=======================================================================================================================================================
AntiPhormLite Beta 1.31 (source and build available at WWW.ANTIPHORM.COM)(ARCHIVED)
15th May 2008
...
...
...
Thanks to everyone for reporting your bugs (bugs@antiphorm.com) and supporting us. We value your reports and we will endevour to fix as many reported bugs in a timely manner.
Enjoy
- AntiPhorm
remend
`// ================================================================================================================================================================================================
`// COPYRIGHT NOTICE
`// ================================================================================================================================================================================================
`// COPYRIGHT 2008 ANTIPHORM.COM. ALL RIGHTS RESERVED
`// WE (ANTIPHORM.COM) HAVE PUBLISHED THIS SOURCE TO ALLOW ANYONE TO REVIEW OR RECOMPILE ANTIPHORMLITE FOR THEIR OWN PERSONAL USE
`// HOWEVER YOU AGREE THAT YOU MAY NOT USE ANY MODIFIED VERSIONS IN PART OR FULL FOR COMMERCIAL OR DISTRIBUTABLE PURPOSES WITHOUT
`// PRIOR PERMISSION FROM ANTIPHORM.COM AND YOU MAY NOT USE ANY OF THIS SOURCE CODE OR COMPILED EXECUTABLES FOR NEFARIOUS OR ILLEGAL PURPOSES.
`// ALL FUTURE VERSIONS WILL ALSO BE PUBLISHED WITH FULL SOURCE CODE AS WE CONTINUE TO IMPROVE AND BUG FIX ANTIPHORMLITE
`// DISCLAIMER: BY COMPILING THIS SOURCE CODE AND USING THE BUILD YOU ALSO AGREE TO THESE TERMS AS WELL AS THE TERMS
`// OF OUR END USER LICENSE AGREEMENT THAT ACCOMPANIES THE DISTRIBUTABLE VERSIONS
`//
`// For Instructions on using AntiPhorm Lite, plesae read the readme.txt file that comes with redistributable build
`//
`// ================================================================================================================================================================================================
`// ANTIPHORM LITE USES THE FOLLOWING DLL UNDER LICENSE: rgt_stringlib.dll
`// ================================================================================================================================================================================================
`// RGT_StringLib v1.01 === Nov. 8, 2002
`// (String Parser) - Commands: strpos$,replace$,substring$
`// Copyright © 2002
`// Real Game Tools
`// Distribution Notice
`// This is a private distribution for Real Game Tools customers. Do not distribute this command plugin to other users without express
`// written permission from Real Game Tools. You have the right to use and distribute applications compiled with this plugin in any
`// and all programs you create.
`// ================================================================================================================================================================================================
`// ================================================================================================================================================================================================
`// **** INITIALIZE APPLICATION
`// ================================================================================================================================================================================================
`// ================================================================================================================================================================================================
sync sleep 1 `// windows compliant setting - froces a sleep(1) command within the windows message pump
`//-----------------------------------------------------------------------------------------------------------------------
`// SYSTEM CONSTANTS
`//-----------------------------------------------------------------------------------------------------------------------
#constant TRUE 1 `// TRUE
#constant FALSE 0 `// FALSE
#constant VOID 0 `// FALSE VARIANT
#constant NULL 0 `// FALSE VARIANT
`//-----------------------------------------------------------------------------------------------------------------------
`// ASCII CONSTANTS
`//-----------------------------------------------------------------------------------------------------------------------
#constant ASCII_LF 10 `// LineFeed. NewLine
#constant ASCII_CR 13 `// Carraige Return
`//-----------------------------------------------------------------------------------------------------------------------
`// STATE CONSTANTS
`//-----------------------------------------------------------------------------------------------------------------------
#constant STATE_INIT 0 `// Initialization
#constant STATE_SURF 1 `// Surfing
#constant STATE_EXIT 2 `// Exiting Application
#constant STATE_PAUSE 3 `// Pause
`//-----------------------------------------------------------------------------------------------------------------------
`// WHAT TO DO NEXT CONSTANTS
`//-----------------------------------------------------------------------------------------------------------------------
#constant DO_NEWURL 1 `// Completely new search or home link
#constant DO_GOBACK 2 `// Go back one step in history
#constant DO_SURFLINKS 3 `// Surf one of the links from this page
#constant DO_BACKHOME 4 `// Go back to HomeUrl
`//-----------------------------------------------------------------------------------------------------------------------
`// URL TYPE CONSTANTS
`//-----------------------------------------------------------------------------------------------------------------------
#constant URL_LINK "URL LINK TYPE" `// App.HomeUrlType
#constant URL_SEARCH "URL SEARCH TYPE" `// App.HomeUrlType
`//-----------------------------------------------------------------------------------------------------------------------
`// URL TYPE CONSTANTS
`//-----------------------------------------------------------------------------------------------------------------------
#constant LINK_DB_ENTRIES 1 `// determines if a LINK database has entries
#constant SEARCH_DB_ENTRIES 2 `// determines if a SEARCH database has entries
#constant SEARCHLINK_DB_ENTRIES 3 `// determines if SEARCH AND LINK databases have entries
`//-----------------------------------------------------------------------------------------------------------------------
`// FILE NUMBER CONSTANTS
`//-----------------------------------------------------------------------------------------------------------------------
#constant FILE_DEBUG 1 `// Debug output
#constant FILE_LINKS 2 `// List of links found on a page
#constant FILE_HTML 3 `// HTML File downloaded
#constant FILE_DATABASE 4 `// Temp data base array file
#constant FILE_INI 5 `// Ini File
#constant FILE_UPDATE 6 `// Update File
`//-----------------------------------------------------------------------------------------------------------------------
`// DEBUG OUTPUT CONSTANTS
`//-----------------------------------------------------------------------------------------------------------------------
#constant DEBUG_OFF 0 `// No Debug Messages recorded
#constant DEBUG_WINDOW 1 `// Sends messages to the debug window only
#constant DEBUG_FILE 2 `// Sends messages to the debug file only
#constant DEBUG_WINDOW_AND_FILE 3 `// Sends messages to both the debug window and debug file
#constant DEBUG_DIV "
"`// divider for debug
#constant DEBUG_BRIEF 0 `// Only show in brief debog mode
#constant DEBUG_VERBOSE 1 `// Only show in verbose debog mode
`//-----------------------------------------------------------------------------------------------------------------------
`// DEBUG OUTPUT CONSTANTS
`//-----------------------------------------------------------------------------------------------------------------------
#constant HTML_NEWLINE 0 `// Creates a new line in an HTML document
#constant HTML_NEWPAR 1 `// Creates a new paragraph
#constant HTML_INIT 2 `// Creates a new initialization of an HTML doc
#constant HTML_HEADER 3 `// Creates a new subject heading
#constant HTML_LINK 4 `// Creates a new hyperlink to an internet file including subject title and path
`//-----------------------------------------------------------------------------------------------------------------------
`// MEMORYBLOCK CONSTANTS
`//-----------------------------------------------------------------------------------------------------------------------
#constant MEMBLOCK_HTMLFILE 1 `// Memoryblock containing downloaded HTML file to use for scanning
#constant MEMBLOCK_DBASEFILE 2 `// Memoryblock used for loading databases to extract entries from
`//-----------------------------------------------------------------------------------------------------------------------
`// MICROSOFT CONSTANTS
`//-----------------------------------------------------------------------------------------------------------------------
#constant CSIDL_PROFILE 0x0028 `// Folder to Documents and Settings to set Mozilla Application settings.
#constant MAX_PATH 0x200 `// Max path size for CSIDL strings
`//-----------------------------------------------------------------------------------------------------------------------
`// KEY CONSTANTS
`//-----------------------------------------------------------------------------------------------------------------------
#constant KEY_PAUSE 25 `// Scancode
#constant KEY_SPACE 57 `// Scancode
`//-----------------------------------------------------------------------------------------------------------------------
`// COLOR CONSTANTS
`//-----------------------------------------------------------------------------------------------------------------------
#constant RGB_WHITE rgb(255,255,255)
#constant RGB_BLACK rgb(0,0,0)
#constant RGB_GREY rgb(127,127,127)
#constant RGB_RED rgb(255,0,0)
#constant RGB_GREEN rgb(0,255,0)
#constant RGB_BLUE rgb(0,0,255)
#constant RGB_CYAN rgb(0,255,255)
#constant RGB_PURPLE rgb(255,0,255)
#constant RGB_YELLOW rgb(255,255,0)
#constant RGB_ORANGE rgb(255,128,0)
#constant RGB_LIME rgb(128,255,50)
#constant RGB_LEMON rgb(255,255,50)
#constant RGB_DEF rgb(255,255,255)
`//-----------------------------------------------------------------------------------------------------------------------
`// DLL CONSTANTS
`//-----------------------------------------------------------------------------------------------------------------------
#constant DLL_URLMON 1 `// M$ Windows Url Monitor DLL used for downloading content from the internet
#constant DLL_SHELL32 2 `// M$ Windows dll Shell Services
`//-----------------------------------------------------------------------------------------------------------------------
`// URL TYPE CONSTANTS
`//-----------------------------------------------------------------------------------------------------------------------
type App
State as byte `// Which application state we are currently in (Controlled by state manager)
PrevState as byte `// Which application state were we in previously
Hidden as boolean `// is the application hidden or shown in a window
HideMode as boolean `// the application hide mode setting TRUE or FALSE
Debug as byte `// determines where to output debug text or turn it off
HomeUrl as string `// the start of a new surf thread
HomeUrlType as string `// search page or standard link
SearchPhrase as string `// search phrase used when using a search link
CurrentUrl as string `// where we are right now (which page)
CurrentCaption as string `// the caption, if any, of the current link
CurrentHeader as string `// header for sub links from the current url
TextSize as integer `// Text size for debug window
TextFont as string `// Text font for debug window
Path as string `// File path to directory application is run from
HTMLFile as string `// Filename of HTML file downloaded for scanning
DebugFolder as string `// folder name
DebugFile as string `// Filename of Debug file to write to
UpdateFile as string `// Filename of the update file that checks version numbers
DebugFileOld as string `// Filename of Previous Debug file
DebugVerbose as boolean `// Verbose or brief output of debug messages
HomeLinkFile as string `// Filename of file containing list of home links
HomeSearchFile as string `// Filename of file containing list of search engines
AdjectivesFile as string `// Filename of file containing list of adjectives
NounsFile as string `// Filename of file containing list of nouns
FirstnamesFile as string `// Filename of file containing list of firstnames
SurnamesFile as string `// Filename of file containing list of surnames
FilterFile as string `// Filename of file containing list of filters to use when determining valid links
ExclusionFile as string `// Filename of file containing list of exclusion extensions to ignore when searching for links
CaptionTagFile as string `// Filename of file containing list of caption format tags to ignore when searching for captions
RawLinks as integer `// counts the number of raw links for comparison after filtering and duplicates
DuplicateLinks as integer `// counts the number of duplicate links found for comparison and determining best caption
FilteredLinks as integer `// counts the number of filtered links and characters found within the link tag
OverflowLinks as integer `// counts the number of links that are over a certain byte count and are discounted
JavaLinks as integer `// counts the number of javascript links found from the raw tag - none of these are to be added in this rev
UserLog as string `// Application User, used only to place the Browser falgs to turn off tabbed browsing
Title as string `// Application Title
Version as integer `// Application Version
Revision as integer `// Application Revisions for this version
Copyright as string `// Application Copyright
Website as string `// Application Website
Ping as string `// The website to ping for establishing an open network connection
NextClickTime as dword `// The ClockTime delay to surf to next link to 1000th of second
LastDuration as dword `// The ClockTime between surfing from last link to 1000th of second
CurrentTime as dword `// derived from the internal clock
Delay as dword `// The delay time to hold a link for
MinSurfTime as integer `// The minimum time between each surf decision in seconds
MaxSurfTime as integer `// The maximum time between each surf decision in seconds
MaxLinkLength as integer `// the time maximum length a url can be before it is cut to prevent overflow issues
TotalLinks as integer `// total count of links from current URL
BrowserOn as boolean `// turns on your browser for viewing
Ini as string `// Ini file variables
Filesize as dword `// filesize of html memblock
MinLinks as integer `// the minumum number of links on page before the Ai decides to stop connecting to any of these link on the current page
Date as string `// stores date application was last launched
Time as string `// stores time application was last launched
AutoUpdate as boolean `// Check for auto updates
SystemPath as string `// Windows Documents and Settings path
MozillaConfig as string `// Mozilla Path for user Settings (to set tab browsing settings)
MozillaFile as string `// Mozilla Path for user Settings (to set tab browsing settings)
MozillaPath as string `// Mozilla Path for user Settings (to set tab browsing settings)
PageFail as boolean `// Page Fail
KeyPress as integer `// key press
PrevKeyPress as integer `// previous key press (buffer)
endtype
`//-----------------------------------------------------------------------------------------------------------------------
`// GLOBAL DECLERATIONS
`//-----------------------------------------------------------------------------------------------------------------------
global App as App `// Stores all aplication variables
global dim TempDatabase() as string `// Temp Database array for reading string files from a memblock super fast for copying thereafter
global dim LinkList() as string `// Stores all links found on current page search
global dim CaptionList() as string `// Stores all Captions for each link found
global dim ImageList() as string `// Stores all Image for each link found
global dim MediaList() as string `// stores all other media for the link
global dim History() as string `// Stores shortest history navigation from home page to current url
global dim Filters() as string `// Stores filtered words and characters to return clean and unwanted results
global dim Exclusions() as string `// Stores exclusion file extensions
global dim CaptionTags() as string `// Stores caption formatting tags for stripping out of caption searches
global dim HomeLinks() as string `// Stores home page links to start from
global dim HomeSearch() as string `// Stores home page seach links to start from
global dim Adjectives() as string `// Stores stores adjectives for use in building a search phrase
global dim Nouns() as string `// Stores stores nouns for use in building a search phrase
global dim Firstnames() as string `// Stores stores firstnames for use in building a search phrase
global dim Surnames() as string `// Stores stores surnames for use in building a search phrase
`//-----------------------------------------------------------------------------------------------------------------------
`// SYSTEM INITIALIZATION
`//-----------------------------------------------------------------------------------------------------------------------
App.State = STATE_INIT
`// ================================================================================================================================================================================================
`// ================================================================================================================================================================================================
`// **** MAIN LOOP
`// ================================================================================================================================================================================================
`// ================================================================================================================================================================================================
do
`// --------------------------------------------------------------------------------
`// KEY INPUT
`// --------------------------------------------------------------------------------
CheckKeyStates()
`// --------------------------------------------------------------------------------
`// STATE MANAGEMENT
`// --------------------------------------------------------------------------------
select App.State
case STATE_INIT :StateInit() :endcase
case STATE_SURF :StateSurf() :endcase
case STATE_EXIT :StateExit() :endcase
case STATE_PAUSE :StatePause() :endcase
endselect
loop
`// ================================================================================================================================================================================================
`// ================================================================================================================================================================================================
`// **** FUNCTIONS
`// ================================================================================================================================================================================================
`// ================================================================================================================================================================================================
`// FUNCTION - CHECK KEY STATES
`// ================================================================================================================================================================================================
function CheckKeyStates()
`// --------------------------------------------------------------------------------
`// Update keyBuffer
`// --------------------------------------------------------------------------------
App.PrevKeyPress = App.KeyPress
App.KeyPress = scancode()
`// --------------------------------------------------------------------------------
`// Single key press branching
`// --------------------------------------------------------------------------------
if App.PrevKeyPress <> App.KeyPress
SingleKeyActions()
endif
endfunction
`// ================================================================================================================================================================================================
`// FUNCTION - SINGLE KEY ACTIONS
`// ================================================================================================================================================================================================
function SingleKeyActions()
`// --------------------------------------------------------------------------------
`// Key action mapper
`// --------------------------------------------------------------------------------
Select App.Keypress
`// --------------------------------------------------------------------------------
`// PAUSE/RESUME
`// --------------------------------------------------------------------------------
case KEY_PAUSE
if App.State = STATE_PAUSE
App.State = App.PrevState
Debug(RGB_LIME,DEBUG_BRIEF,HTML_NEWLINE,"Resuming from Pause Mode","")
else
App.PrevState = App.State
App.State = STATE_PAUSE
Debug(RGB_LIME,DEBUG_BRIEF,HTML_NEWLINE,"Paused","")
endif
endcase
`// --------------------------------------------------------------------------------
`// TOGGLE BROWSER ON/OFF
`// --------------------------------------------------------------------------------
case KEY_SPACE
if App.HideMode = FALSE
if App.BrowserOn = FALSE
App.BrowserOn = TRUE
Debug(RGB_LIME,DEBUG_BRIEF,HTML_NEWLINE,"Turning Browser Mode ON","")
execute file App.CurrentUrl,"","",1
else
App.BrowserOn = FALSE
Debug(RGB_LIME,DEBUG_BRIEF,HTML_NEWLINE,"Turning Browser Mode OFF","")
endif
endif
endcase
endselect
endfunction
`// ================================================================================================================================================================================================
`// FUNCTION - STATE PAUSE
`// ================================================================================================================================================================================================
function StatePause()
`// do nothing
endfunction
`// ================================================================================================================================================================================================
`// FUNCTION - STATE INITIALIZE APPLICATION
`// ================================================================================================================================================================================================
function StateInit()
`// --------------------------------------------------------------------------------
`// Initialize Application Variables
`// --------------------------------------------------------------------------------
App.Debug = DEBUG_WINDOW_AND_FILE
App.TextSize = 14
App.TextFont = "Arial"
App.Path = get dir$() + "\"
App.HTMLFile = App.Path + "html.dat"
App.DebugFolder = "sessionlogs"
App.DebugFile = App.Path + App.DebugFolder + "\" + "log_"
App.DebugFileOld = App.Path + "previous_logfile.txt"
App.UpdateFile = "version.dat"
App.HomeLinkFile = App.Path + "database\homelinks.txt"
App.HomeSearchFile = App.Path + "database\homesearch.txt"
App.AdjectivesFile = App.Path + "database\adjectives.txt"
App.NounsFile = App.Path + "database\nouns.txt"
App.FirstnamesFile = App.Path + "database\firstnames.txt"
App.SurnamesFile = App.Path + "database\surnames.txt"
App.FilterFile = App.Path + "database\filters.txt"
App.ExclusionFile = App.Path + "database\exclusions.txt"
App.CaptionTagFile = App.Path + "database\captiontags.txt"
App.MozillaConfig = App.Path + "mozillasettings\"
App.MozillaFile = "user.js"
App.MozillaPath = "Application Data\Mozilla\Firefox\Profiles"
App.Ini = App.Path + "AntiPhormLite.ini"
App.Title = "AntiPhorm (Lite) - Signal to Noise"
App.Version = 1
App.Revision = 33
App.Copyright = "AntiPhorm.com"
App.Website = "http://www.antiphorm.com"
App.Ping = App.Website + "/ping.dat"
App.MinSurfTime = 5
App.MaxSurfTime = 25
App.MaxLinkLength = 253
App.MinLinks = 6
App.Time = get time$()
App.Date = get date$()
App.DebugVerbose = DEBUG_BRIEF `// set this to DEBUG_VERBOSE for detailed debugging - can also be set in ini file
App.AutoUpdate = FALSE `// Auto Update Chek set to OFF by default. Can be changed to '1' in the INI file if you want to be notified of updated versions
App.Hidden = FALSE `// application is curently visible
`// --------------------------------------------------------------------------------
`// Initialize Debug file and window
`// --------------------------------------------------------------------------------
set text font App.TextFont
set text size App.TextSize
App.Date = replace$(App.Date,"/","_")
App.Time = replace$(App.Time,":","_")
App.DebugFile = App.DebugFile + App.Date + "_" + App.Time + ".html"
if file exist(App.DebugFolder) = 0 then make directory App.DebugFolder
if file exist(App.DebugFile) then delete file App.DebugFile
open to write FILE_DEBUG,App.DebugFile
`// --------------------------------------------------------------------------------
`// Load DLL's
`// --------------------------------------------------------------------------------
load dll "urlmon.dll" , DLL_URLMON
load dll "shell32.dll" , DLL_SHELL32
`// --------------------------------------------------------------------------------
`// Welcome Message
`// --------------------------------------------------------------------------------
Debug(RGB_LIME,DEBUG_BRIEF,HTML_INIT,"","")
Debug(RGB_LIME,DEBUG_BRIEF,HTML_HEADER,App.Title + " Version:" + str$(App.Version) + "." + str$(App.Revision),"")
Debug(RGB_LIME,DEBUG_BRIEF,HTML_NEWLINE,"Copyright 2008 " + App.Copyright + " Website: " + App.Website,"")
Debug(RGB_LIME,DEBUG_BRIEF,HTML_NEWLINE,"Today's Date: " + get date$() + " & Time: " + get time$(),"")
Debug(RGB_ORANGE,DEBUG_BRIEF,HTML_NEWLINE,"Please read the readme file for release notes and instructions. " + App.Path + "readme.txt","")
Debug(RGB_LIME,DEBUG_BRIEF,HTML_NEWLINE,DEBUG_DIV,"")
`// --------------------------------------------------------------------------------
`// READ INI FILE - Overwrites system variables IF present
`// --------------------------------------------------------------------------------
if file exist(App.Ini)
open to read FILE_INI,App.Ini
if file open(FILE_INI)
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,"[Inifile found]: " + App.Ini + " :[Checking custom settings]","")
while file end(FILE_INI)=0
read string FILE_INI,a$
Ini$ = left$(a$,strpos("=",a$) - 1)
Ini$ = lower$(Ini$)
select Ini$
`// --------------------------------------------------------------------------------
`// MIN SURF TIME
`// --------------------------------------------------------------------------------
case "[minsurftime]"
IniDataPos=strpos("=",a$)
IniData$ = right$(a$,len(a$)-IniDataPos)
IniData = val(IniData$)
App.MinSurfTime = IniData
if App.MinSurfTime < 4 then App.MinSurfTime = 5 `// throttle values
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"[Ini][MinSurftime]=" + str$(App.MinSurfTime),"")
endcase
`// --------------------------------------------------------------------------------
`// MAX SURF TIME
`// --------------------------------------------------------------------------------
case "[maxsurftime]"
IniDataPos=strpos("=",a$)
IniData$ = right$(a$,len(a$)-IniDataPos)
IniData = val(IniData$)
App.MaxSurfTime = IniData
if App.MaxSurfTime > 65000 then App.MaxSurfTime = 65000 `// cap values
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"[Ini][MaxSurftime]=" + str$(App.MaxSurfTime),"")
endcase
`// --------------------------------------------------------------------------------
`// MIN LINKS
`// --------------------------------------------------------------------------------
case "[minlinks]"
IniDataPos=strpos("=",a$)
IniData$ = right$(a$,len(a$)-IniDataPos)
IniData = val(IniData$)
App.MaxSurfTime = IniData
if App.MinLinks < 7 then App.MinLinks = 7 `// prevent negative values
if App.MinLinks > 200 then App.MinLinks = 200 `// cap values
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"[Ini][MinLinks]=" + str$(App.MinLinks),"")
endcase
`// --------------------------------------------------------------------------------
`// LOG VERBOSITY
`// --------------------------------------------------------------------------------
case "[logverbosity]"
IniDataPos=strpos("=",a$)
IniData$ = right$(a$,len(a$)-IniDataPos)
IniData = val(IniData$)
App.DebugVerbose = IniData
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"[Ini][LogVerbosity]=" + str$(App.DebugVerbose),"")
endcase
`// --------------------------------------------------------------------------------
`// PingCheck
`// --------------------------------------------------------------------------------
case "[pingcheck]"
IniDataPos=strpos("=",a$)
IniData$ = right$(a$,len(a$)-IniDataPos)
App.Ping = IniData$
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"[Ini][PingCheck]=" + App.Ping,"")
endcase
`// --------------------------------------------------------------------------------
`// UPDATE CHECK (to announce any updates from AntiPhorm.com) Set to 0 By default - OFF
`// --------------------------------------------------------------------------------
case "[updatecheck]"
IniDataPos=strpos("=",a$)
IniData$ = right$(a$,len(a$)-IniDataPos)
IniData = val(IniData$)
App.AutoUpdate = IniData
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"[Ini][UpdateCheck]=" + str$(App.AutoUpdate),"")
endcase
endselect
if Ini$ > ""
endif
endwhile
close file FILE_INI
endif
endif
`// --------------------------------------------------------------------------------
`// CHECK WEB CONNECTION
`// --------------------------------------------------------------------------------
App.State = STATE_EXIT `// default to exit application in case we can't find the ping.
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,DEBUG_DIV,"")
Retry = 0
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,"Checking for an active internet connection","") `// pings an empty file to test connection
while Retry < 3 `// 3 retry attempts
x=CALL DLL(DLL_URLMON,"URLDownloadToFileA",0,App.Ping,"",0,0) `// just return if the file exits, if so, we have a connection
if x <> 0
inc Retry,1
print
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"Attempting to check again for an active internet connection: Retry Attempts " + str$(Retry) ,"")
for i = 1 to 50
print ".";
wait 150 `// enough time to allow a retry delay
next i
else
Retry = 999 `// found or failed
endif
endwhile
`// --------------------------------------------------------------------------------
`// DID WE FIND A CONNECTION?
`// --------------------------------------------------------------------------------
if x <> 0
Print
Debug(RGB_RED,DEBUG_BRIEF,HTML_NEWLINE,"FAILED TO FIND AN ACTIVE CONNECTION","")
Debug(RGB_RED,DEBUG_BRIEF,HTML_NEWLINE,"NETWORK DID NOT RESPOND","")
Debug(RGB_RED,DEBUG_BRIEF,HTML_NEWLINE," *** Exiting Application ***","")
Debug(RGB_RED,DEBUG_BRIEF,HTML_NEWLINE,"Check your internet connection settings and try again","")
Debug(RGB_RED,DEBUG_BRIEF,HTML_NEWLINE,"Press Any Key","")
wait key
end
else
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"OK","")
App.State = STATE_INIT
endif
`// --------------------------------------------------------------------------------
`// --------------------------------------------------------------------------------
if App.State = STATE_EXIT then end
`// --------------------------------------------------------------------------------
`// CHECK FOR AUTO UPDATES
`// --------------------------------------------------------------------------------
if App.AutoUpdate = TRUE
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,DEBUG_DIV,"")
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,"Update Check: ENABLED: Checking for available updates","")
Debug(RGB_ORANGE,DEBUG_BRIEF,HTML_NEWLINE,"You can Turn Update Checking OFF by editing [UpdateCheck]=0 in the AntiphormLite.ini file","")
Debug(RGB_ORANGE,DEBUG_BRIEF,HTML_NEWLINE,"For your security update checking will not download any files for you.","")
Debug(RGB_ORANGE,DEBUG_BRIEF,HTML_NEWLINE,"This feature is simply to inform you if a newer version is available for download","")
x=CALL DLL(DLL_URLMON,"URLDownloadToFileA",0,App.Website + "/" + App.UpdateFile ,App.Path + App.UpdateFile,0,0)
if x <> 0
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,"No Update Files Found","")
else
open to read FILE_UPDATE,App.Path + App.UpdateFile
read string FILE_UPDATE,version$
version = val(version$)
AppVersionNo$ = str$(App.Version) + str$(App.Revision)
AppVersionNo = val(AppVersionNo$)
if version > AppVersionNo
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,DEBUG_DIV,"")
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"UPDATE NOTICE: A new version of " + App.Title + " is available for download at " + App.Website,"")
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"Check the website for further details if you want to update.","")
else
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,DEBUG_DIV,"")
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,"You are currently running the latest version : V" + str$(App.Version) + "." + str$(App.Revision),"")
endif
close file FILE_UPDATE
endif
else
Debug(RGB_ORANGE,DEBUG_BRIEF,HTML_NEWLINE,"Update Check: DISABLED: Skipping Check","")
Debug(RGB_ORANGE,DEBUG_BRIEF,HTML_NEWLINE,"You can Turn Update Checking ON by editing [UpdateCheck]=1 in the AntiphormLite.ini file","")
endif
`// --------------------------------------------------------------------------------
`// ASk user about debug settings they want
`// --------------------------------------------------------------------------------
Debug(RGB_WHITE,DEBUG_BRIEF,HTML_NEWLINE,DEBUG_DIV,"")
Debug(RGB_WHITE,DEBUG_BRIEF,HTML_NEWLINE,"AntiphormLite gives you 3 ways to view your Signal to Noise surfing","")
Debug(RGB_WHITE,DEBUG_BRIEF,HTML_NEWLINE,"Select one of the following","")
Debug(RGB_WHITE,DEBUG_BRIEF,HTML_NEWLINE,DEBUG_DIV,"")
Debug(RGB_WHITE,DEBUG_BRIEF,HTML_NEWLINE,"1 - Hidden","")
Debug(RGB_WHITE,DEBUG_BRIEF,HTML_NEWLINE,"2 - Console View - Text Only","")
Debug(RGB_WHITE,DEBUG_BRIEF,HTML_NEWLINE,"3 - Console View with Browser Viewer (Beta)","")
Debug(RGB_WHITE,DEBUG_BRIEF,HTML_NEWLINE,DEBUG_DIV,"")
Debug(RGB_RED,DEBUG_BRIEF,HTML_NEWLINE,"Please Note:","")
Debug(RGB_RED,DEBUG_BRIEF,HTML_NEWLINE,"When in Hidden Mode to exit app use Task Manager and kill process 'AntiPhormLite.exe","")
Debug(RGB_ORANGE,DEBUG_BRIEF,HTML_NEWLINE,"You can now press the P key to pause/resume while surfing","")
Debug(RGB_ORANGE,DEBUG_BRIEF,HTML_NEWLINE,"You can now press the SPACE key to switch between browser and text only modes","")
Debug(RGB_WHITE,DEBUG_BRIEF,HTML_NEWLINE,DEBUG_DIV,"")
`// --------------------------------------------------------------------------------
`// Wrong answer - try again.
`// --------------------------------------------------------------------------------
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,"Press 1,2 or 3 to select your option or press escape to exit","")
while ViewSelected = FALSE
a = scancode()
if a > 0
select a
`// ----------------------------------------------------------------------------------------------------------
case 2
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,DEBUG_DIV,"")
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"SELECTION 1 - Hidden","")
ViewSelected = TRUE
App.Debug = DEBUG_WINDOW_AND_FILE
App.HideMode = TRUE
App.BrowserOn = FALSE
endcase
`// ----------------------------------------------------------------------------------------------------------
case 3
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,DEBUG_DIV,"")
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"SELECTION 2 - Console View - Text Only","")
ViewSelected = TRUE
App.Debug = DEBUG_WINDOW_AND_FILE
App.HideMode = FALSE
App.BrowserOn = FALSE
endcase
`// ----------------------------------------------------------------------------------------------------------
case 4
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,DEBUG_DIV,"")
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"SELECTION 3 - Console & Browser View - your default browser - Beta Bug, creates multiple tabs, fix in progress","")
ViewSelected = TRUE
App.Debug = DEBUG_WINDOW_AND_FILE
App.HideMode = FALSE
App.BrowserOn = TRUE
endcase
`// ----------------------------------------------------------------------------------------------------------
endselect
endif
endwhile
`// --------------------------------------------------------------------------------
`// Hidden Mode - Run sin the background - need to add a task tray item to control opening
`// and closing this better, rather than ctr,alt + del kill method
`// --------------------------------------------------------------------------------
if App.HideMode = TRUE
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,"Going into HIDDEN MODE: Hidding Window","")
Debug(RGB_ORANGE,DEBUG_BRIEF,HTML_NEWLINE,"To Exit HIDDEN MODE - ctrl+alt+del and kill process AntiPhorm_Lite.exe","")
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"Press Any Key to Continue or Esc to exit Application","")
App.Debug = DEBUG_FILE `// switch to FILE only debug
wait key
hide window
endif
`// --------------------------------------------------------------------------------
`// Chec for Mozilla Browser Settingd
`// --------------------------------------------------------------------------------
if App.BrowserOn = TRUE
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,DEBUG_DIV,"")
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,"Checking Browser Settings","")
MozillaExist = MozillaSettings() `// Call Mozilla browser search
if MozillaExist = 1 `// if found
Source$ = App.MozillaConfig + App.MozillaFile
Destination$ = App.MozillaPath + App.MozillaFile
OldUser$ = App.MozillaPath + "old_user.js"
`// clean up user settings files
if file exist(Destination$)
copy file Destination$, OldUser$
delete file Destination$
endif
copy file Source$,Destination$ `// copy Mozilla non tab user preference file to mozilla settings folder
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"[Mozilla Browser Found] Creating User Settings - Turned OFF Tab Browsing","")
else
Debug(RGB_ORANGE,DEBUG_BRIEF,HTML_NEWLINE,"[Mozilla Browser Not Found] - Using to default browser - tab browsing may be ON (fix coming soon)","")
endif
endif
`// --------------------------------------------------------------------------------
`// Launch into Main APP
`// --------------------------------------------------------------------------------
`// --------------------------------------------------------------------------------
`// READ DATABASE ENTRIES
`// --------------------------------------------------------------------------------
`// --------------------------------------------------------------------------------
`// Read exclusion file - Create the database then copy it
`// --------------------------------------------------------------------------------
CreateDatabaseArray(App.ExclusionFile,"EXCLUSIONS")
add to stack Exclusions() `// to start it from base 1(as base 0 has a bug)
for i = 1 to array count(TempDatabase())
add to stack Exclusions()
Exclusions(i) = TempDatabase(i)
next i
`// If database file is empty then create a default entry
if array count(Exclusions()) = 0
`// exiting application if not found (inform user by unhidding window)
if App.HideMode = TRUE
show window
App.HideMode = FALSE
App.Debug = DEBUG_WINDOW_AND_FILE
endif
Debug(RGB_RED,DEBUG_BRIEF,HTML_NEWLINE,"[*** WARNING - EXCLUSION ENTRIES FOUND]","")
Debug(RGB_RED,DEBUG_BRIEF,HTML_NEWLINE,"[*** WARNING - EXITING APPLICATION]","")
Debug(RGB_RED,DEBUG_BRIEF,HTML_NEWLINE,"[PRESS ANY KEY]","")
wait key
end
endif
`// --------------------------------------------------------------------------------
`// Read Caption Format Tags file - Create the database then copy it
`// --------------------------------------------------------------------------------
CreateDatabaseArray(App.CaptionTagFile,"URL CAPTIONS")
add to stack CaptionTags() `// to start it from base 1(as base 0 has a bug)
for i = 1 to array count(TempDatabase())
add to stack CaptionTags()
CaptionTags(i) = TempDatabase(i)
next i
`// If database file is empty then create a default entry
if array count(CaptionTags()) = 0
`// exiting application if not found (inform user by unhidding window)
if App.HideMode = TRUE
show window
App.HideMode = FALSE
App.Debug = DEBUG_WINDOW_AND_FILE
endif
Debug(RGB_RED,DEBUG_BRIEF,HTML_NEWLINE,"[*** WARNING - NO CAPTION TAG ENTRIES FOUND]","")
Debug(RGB_RED,DEBUG_BRIEF,HTML_NEWLINE,"[*** WARNING - EXITING APPLICATION]","")
Debug(RGB_RED,DEBUG_BRIEF,HTML_NEWLINE,"[PRESS ANY KEY]","")
wait key
end
endif
`// --------------------------------------------------------------------------------
`// Read Home Link word list - Create the database then copy it
`// --------------------------------------------------------------------------------
CreateDatabaseArray(App.HomeLinkFile,"HOME LINKS")
add to stack HomeLinks() `// to start it from base 1(as base 0 has a bug)
for i = 1 to array count(TempDatabase())
add to stack HomeLinks()
`// make sure we have a forward slash at the end of a home link as this may not have been included in the database file
if right$(TempDatabase(i),1) <> "/"
TempDatabase(i) = TempDatabase(i) + "/"
endif
HomeLinks(i) = TempDatabase(i)
next i
`// If database file is empty then create a default entry
if array count(HomeLinks()) = 0
add to stack HomeLinks()
a$ = App.Website
if right$(a$,1) <> "/"
a$ = a$ + "/"
endif
HomeLinks() = a$
Debug(RGB_RED,DEBUG_BRIEF,HTML_NEWLINE,"[SELECTING DEFAULT URL AS NO DATABASE ENTRIES EXIST] = " + a$,"")
endif
`// --------------------------------------------------------------------------------
`// Read Home Search file - Create the database then copy it
`// --------------------------------------------------------------------------------
CreateDatabaseArray(App.HomeSearchFile,"HOME SEARCH ENGINES")
add to stack HomeSearch() `// to start it from base 1(as base 0 has a bug)
for i = 1 to array count(TempDatabase())
add to stack HomeSearch()
HomeSearch(i) = TempDatabase(i)
next i
`// if zero search entries are found then we ignore these from the browsing experience
`// --------------------------------------------------------------------------------
`// Read Adjectives file - Create the database then copy it
`// --------------------------------------------------------------------------------
CreateDatabaseArray(App.AdjectivesFile,"ADJECTIVES")
add to stack Adjectives() `// to start it from base 1(as base 0 has a bug)
for i = 1 to array count(TempDatabase())
add to stack Adjectives()
Adjectives(i) = TempDatabase(i)
next i
`// if zero adjective entries are found then we ignore these from the browsing experience
`// --------------------------------------------------------------------------------
`// Read Nouns file - Create the database then copy it
`// --------------------------------------------------------------------------------
CreateDatabaseArray(App.NounsFile,"NOUNS")
add to stack Nouns() `// to start it from base 1(as base 0 has a bug)
for i = 1 to array count(TempDatabase())
add to stack Nouns()
Nouns(i) = TempDatabase(i)
next i
`// If database file is empty then create a default entry
if array count(Nouns()) = 0
add to stack Nouns()
a$ = "news"
Nouns() = a$
Debug(RGB_RED,DEBUG_BRIEF,HTML_NEWLINE,"[SELECTING DEFAULT NOUN AS NO DATABASE ENTRIES EXIST] = " + a$,"")
endif
`// --------------------------------------------------------------------------------
`// Read Firstnames file - Create the database then copy it
`// --------------------------------------------------------------------------------
CreateDatabaseArray(App.FirstnamesFile,"FIRST NAMES")
add to stack Firstnames() `// to start it from base 1(as base 0 has a bug)
for i = 1 to array count(TempDatabase())
add to stack Firstnames()
Firstnames(i) = TempDatabase(i)
next i
`// if zero adjective entries are found then we ignore these from the browsing experience
`// --------------------------------------------------------------------------------
`// Read Surnames file - Create the database then copy it
`// --------------------------------------------------------------------------------
CreateDatabaseArray(App.SurnamesFile,"SURNAMES")
add to stack Surnames() `// to start it from base 1(as base 0 has a bug)
for i = 1 to array count(TempDatabase())
add to stack Surnames()
Surnames(i) = TempDatabase(i)
next i
`// if zero adjective entries are found then we ignore these from the browsing experience
`// --------------------------------------------------------------------------------
`// Read filter file - Create the database then copy it
`// --------------------------------------------------------------------------------
CreateDatabaseArray(App.FilterFile,"FILTERS")
add to stack Filters() `// to start it from base 1(as base 0 has a bug)
for i = 1 to array count(TempDatabase())
add to stack Filters()
Filters(i) = TempDatabase(i)
next i
`// --------------------------------------------------------------------------------
`// Initialize timers
`// --------------------------------------------------------------------------------
randomize timer()
App.CurrentTime = timer()
App.NextClickTime = App.CurrentTime
`// --------------------------------------------------------------------------------
`// Change App State
`// --------------------------------------------------------------------------------
App.State = STATE_SURF
endfunction
`// ================================================================================================================================================================================================
`// FUNCTION - STATE EXIT APPLICATION
`// ================================================================================================================================================================================================
function StateExit
`// --------------------------------------------------------------------------------
`// Close open files
`// --------------------------------------------------------------------------------
if file open(FILE_DEBUG) then close file FILE_DEBUG
end
endfunction
`// ================================================================================================================================================================================================
`// FUNCTION - STATE SURF
`// Find a URL from the list provided either a link or a search (with a random phrase)
`// ================================================================================================================================================================================================
function StateSurf()
App.CurrentTime = timer()
`// --------------------------------------------------------------------------------
`// If time delay has passed - surf to next link
`// --------------------------------------------------------------------------------
if App.CurrentTime > App.NextClickTime
Duration# = (App.CurrentTime-App.LastDuration)/1000.0
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,DEBUG_DIV,"")
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,"[SURF AI]","")
Debug(RGB_CYAN,DEBUG_VERBOSE,HTML_NEWLINE,DEBUG_DIV,"")
`// --------------------------------------------------------------------------------
`// --------------------------------------------------------------------------------
`// LOGIC CONTROL CENTER
`// The brain of the surfing enging
`// This is where all the logic decisions are taken regarding which link to surf
`// to surf to next. Including going back in history, boredom, revisiting
`// search entries and much more. Everything else is generic to finding
`// a list of links from a particular page. The LCC decides what to do with that info.
`// it returns App.CurrentUrl so the program can continue to the next link.
`// --------------------------------------------------------------------------------
`// Click on a link (based on quantity of links) - recursive
`// First fallback - Back a page
`// Next fallback - Home Page
`// Final fallback - New Home Page
if App.TotalLinks > App.MinLinks
`// default
WhatToDoNext = DO_SURFLINKS
`// some random probabilities
hmm = rnd(30)
if hmm > 23 then WhatToDoNext = DO_GOBACK
if hmm > 26 then WhatToDoNext = DO_BACKHOME
if hmm > 28 then WhatToDoNext = DO_NEWURL
else
`// default
WhatToDoNext = DO_GOBACK
`// some random probabilities
hmm = rnd(30)
if hmm > 22 then WhatToDoNext = DO_BACKHOME
if hmm > 26 then WhatToDoNext = DO_NEWURL
endif
`// --------------------------------------------------------------------------------
`// WHAT TO DO NEXT
`// Pretty Obvious Really
`// Just find out what the new currentUrl is
`// --------------------------------------------------------------------------------
Select WhatToDoNext
`// --------------------------------------------------------------------------------
`// NEW URL
`// --------------------------------------------------------------------------------
Case DO_NEWURL
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,DEBUG_DIV,"")
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,"[CHOOSING A NEW HOME URL]","")
NewHomeUrl()
endcase
`// --------------------------------------------------------------------------------
`// GO BACK TO LAST PAGE
`// --------------------------------------------------------------------------------
Case DO_GOBACK
if array count(History()) > 1
App.CurrentUrl = History()
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,"[GOING BACK IN HISTORY]","")
remove from stack History()
else
`// --------------------------------------------------------------------------------
`// Initialize a new History
`// --------------------------------------------------------------------------------
empty array History()
add to stack History() `// to bypass the base 0 bug
`// --------------------------------------------------------------------------------
`// NewHomeUrl
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,"[CHOOSING A NEW HOME URL]","")
NewHomeUrl()
endif
endcase
`// --------------------------------------------------------------------------------
`// SURF DEEPER FROM A LINK ON CURRENT PAGE
`// --------------------------------------------------------------------------------
Case DO_SURFLINKS
`// --------------------------------------------------------------------------------
`// Add last Url to History
`// --------------------------------------------------------------------------------
add to stack History()
History() = App.CurrentUrl
`// --------------------------------------------------------------------------------
`// Pick a new currentUrl from the ones on this page
`// --------------------------------------------------------------------------------
x = rnd(array count(LinkList())-1)+1
App.CurrentUrl = LinkList(x)
App.CurrentCaption = CaptionList(x)
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,"[SURFING DEEPER - FOUND PAGE LINK] ID:" + str$(x),"")
endcase
`// --------------------------------------------------------------------------------
`// GO BACK TO HOME URL
`// --------------------------------------------------------------------------------
Case DO_BACKHOME
`// --------------------------------------------------------------------------------
`// Initialize a new History
`// --------------------------------------------------------------------------------
empty array History()
add to stack History() `// to bypass the base 0 bug
`// --------------------------------------------------------------------------------
`// Go Back to Home URL
`// --------------------------------------------------------------------------------
if App.HomeUrl > ""
if App.HomeUrlType = URL_LINK
App.CurrentUrl = App.HomeUrl
else
App.CurrentUrl = App.HomeUrl + App.SearchPhrase
endif
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,"[BACK TO HOME URL]","")
else
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,"[CHOOSING A NEW HOME URL]","")
NewHomeUrl()
endif
endcase
endselect
`// --------------------------------------------------------------------------------
`// --------------------------------------------------------------------------------
if App.HomeUrlType = URL_LINK
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"[URL] = " + App.CurrentUrl,"")
else
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"[URL] = " + App.CurrentUrl,"")
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"[SEARCH] = " + App.SearchPhrase,"")
endif
`// --------------------------------------------------------------------------------
`// Clickable link in log file
`// --------------------------------------------------------------------------------
Debug(RGB_DEF,DEBUG_BRIEF,HTML_LINK,App.CurrentUrl,App.CurrentCaption)
`// --------------------------------------------------------------------------------
`// Find links
`// --------------------------------------------------------------------------------
App.PageFail = FALSE
FindCurrentHeader(App.CurrentUrl)
ScanForLinks(App.CurrentUrl)
App.TotalLinks = array count(LinkList())
`// --------------------------------------------------------------------------------
`// Browser Preview
`// --------------------------------------------------------------------------------
if App.PageFail = FALSE
if App.BrowserOn = TRUE
execute file App.CurrentUrl,"","",1
endif
endif
`// --------------------------------------------------------------------------------
`// print every single link and associated tag that we have captured
`// --------------------------------------------------------------------------------
for i = 1 to array count(LinkList())
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,DEBUG_DIV,"")
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,str$(i) + "[LinkList()] : " + LinkList(i),"")
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,str$(i) + "[CaptionList()] : " + CaptionList(i),"")
next i
`// --------------------------------------------------------------------------------
`// Some important debug information
`// --------------------------------------------------------------------------------
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,"Raw Links Found = " + str$(App.RawLinks),"")
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,"Duplicates Removed = " + str$(App.DuplicateLinks),"")
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,"Filtered words removed = " + str$(App.FilteredLinks),"")
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,"Overflows excluded = " + str$(App.OverflowLinks),"")
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,"Javascript excluded = " + str$(App.JavaLinks),"")
Debug(RGB_ORANGE,DEBUG_BRIEF,HTML_NEWLINE,"Total Valid Links = " + str$(App.TotalLinks),"")
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,"Time: " + get time$(),"")
`// --------------------------------------------------------------------------------
`// Generate a new time stamp to next delay
`// --------------------------------------------------------------------------------
App.CurrentTime = timer()
if App.MinSurfTime < 4 then App.MinSurfTime = 4 `// throttle values (second backup in case app is hacked)
if App.MaxSurfTime > 65000 then App.MaxSurfTime = 65000 `// cap values (second backup in case app is hacked)
if App.MinSurfTime > App.MaxSurfTime then App.MinSurfTime = App.MaxSurfTime `// make sure we don't get negative values
App.Delay = (rnd(App.MaxSurfTime-App.MinSurfTime)+App.MinSurfTime) * 1000 `// calculate surf delay time
App.Delay = App.Delay + ((((App.TotalLinks)/30) + (App.Filesize/10000))*1000) `// add extra delays based on number of links and page size
`// --------------------------------------------------------------------------------
`// Bathroom break
`// --------------------------------------------------------------------------------
x=rnd(911)
if x = 7
App.Delay = App.Delay + ((rnd(240)+60) * 1000) `// a 1 in 911 chance of holding for 1 to 4 minutes while you answer the phone or go to the bathroom
Debug(RGB_ORANGE,DEBUG_BRIEF,HTML_NEWLINE,"[Taking a break....]","")
Debug(RGB_ORANGE,DEBUG_BRIEF,HTML_NEWLINE,"[Simulating you are dealing with some other matter for a little while]","")
endif
`// --------------------------------------------------------------------------------
`// Apply delay settings
`// --------------------------------------------------------------------------------
App.NextClickTime = App.CurrentTime + App.Delay
App.LastDuration = App.CurrentTime
if App.PageFail = TRUE then App.Delay = 1000 `// reduce the surf time to 1 second if there are no links found
if App.TotalLinks < App.MinLinks then App.Delay = 1000 `// reduce the surf time to 1 second if there are no links found
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,DEBUG_DIV,"")
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,"[AI] Surf delay for " + str$(App.Delay/1000) + " secs ]","")
Debug(RGB_CYAN,DEBUG_BRIEF,HTML_NEWLINE,DEBUG_DIV,"")
endif
endfunction
`// ================================================================================================================================================================================================
`// FUNCTION - NEW HOME URL
`// ================================================================================================================================================================================================
function NewHomeUrl()
`// --------------------------------------------------------------------------------
`// Check to see if any links exist in the databases
`// --------------------------------------------------------------------------------
NewUrlLinkOptions = 0 `// start off by presuming we have neither search or home links in our database
if array count(HomeSearch()) > 0
inc NewUrlLinkOptions,SEARCH_DB_ENTRIES `// Add Search Database entry to options
else
Debug(RGB_ORANGE,DEBUG_BRIEF,HTML_NEWLINE,"[EXCLUDING SEARCH LINKS AS NO SEARCH LINKS EXIST IN THE DATABASE]","")
endif
if array count(HomeLinks()) > 0
inc NewUrlLinkOptions,LINK_DB_ENTRIES `// Add Link Database entry to options
else
Debug(RGB_ORANGE,DEBUG_BRIEF,HTML_NEWLINE,"[EXCLUDING HOME LINKS AS NO HOME LINKS EXIST IN THE DATABASE]","")
endif
`// special case. If we have search links and we only have the default home link, then ignore the default home link as the search is available
if array count(HomeLinks()) = 1 and HomeLinks(1) = App.Website + "/"
if array count(HomeSearch()) > 0
NewUrlLinkOptions = SEARCH_DB_ENTRIES
endif
endif
`// --------------------------------------------------------------------------------
`// Select either a search link with a phrase or a home link (equally random) :=D
`// --------------------------------------------------------------------------------
select NewUrlLinkOptions
`// --------------------------------------------------------------------------------
`// There are only home links in the database
`// --------------------------------------------------------------------------------
case LINK_DB_ENTRIES
x = 1 `// select only links
endcase
`// --------------------------------------------------------------------------------
`// There are only search links in the database
`// --------------------------------------------------------------------------------
case SEARCH_DB_ENTRIES
x = 0 `// select only search
endcase
`// --------------------------------------------------------------------------------
`// There are both home links and search links in the database
`// --------------------------------------------------------------------------------
case SEARCHLINK_DB_ENTRIES
x = rnd(1) `// select either search or link
endcase
`// --------------------------------------------------------------------------------
`// There are neither home or search links in the database
`// --------------------------------------------------------------------------------
case default
x = 999 `// select neither (we'll need a fall back solution)
endcase
endselect
`// --------------------------------------------------------------------------------
`// Select x Setting (Search or Link) or neither
`// --------------------------------------------------------------------------------
select x
`// --------------------------------------------------------------------------------
`// Search Links
`// --------------------------------------------------------------------------------
case 0
a = rnd(array count(HomeSearch())-1)+1
App.HomeUrl = HomeSearch(a)
App.HomeUrlType = URL_SEARCH
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,"[NEW SEARCH URL] = " + App.HomeUrl,"")
`// --------------------------------------------------------------------------------
`// randomize search phrase between searching for general interest subjects or people
`// --------------------------------------------------------------------------------
if array count(Firstnames()) > 0 and array count(Surnames()) > 0
`// search for either
SearchType = rnd(1)
else
`// only search for subject
SearchType = 0
endif
if SearchType = 0
`// --------------------------------------------------------------------------------
`// general interest
`// decide if the search phrase also has an adjective or is just a single word
`// --------------------------------------------------------------------------------
AddAdjective = rnd(1)
if AddAdjective
if array count(Adjectives()) > 0 `// only add an adjective if there are entries
Adjective = rnd(array count(Adjectives())-1)+1
endif
Noun = rnd(array count(Nouns())-1)+1
App.SearchPhrase = Adjectives(Adjective) + " " + Nouns(Noun)
else
Noun = rnd(array count(Nouns())-1)+1
App.SearchPhrase = Nouns(Noun)
endif
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,"[NEW SUBJECT SEARCH PHRASE] = " + upper$(App.SearchPhrase),"")
else
`// --------------------------------------------------------------------------------
`// person
`// --------------------------------------------------------------------------------
Firstname = rnd(array count(Firstnames())-1)+1
Surnname = rnd(array count(Surnames())-1)+1
App.SearchPhrase = Firstnames(Firstname) + " " + Surnames(Surnname)
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,"[NEW PERSON SEARCH PHRASE] = " + upper$(App.SearchPhrase),"")
endif
`// --------------------------------------------------------------------------------
`// build search link
`// --------------------------------------------------------------------------------
App.SearchPhrase = lower$(App.SearchPhrase)
App.CurrentUrl = App.HomeUrl + App.SearchPhrase
endcase
`// --------------------------------------------------------------------------------
`// Home Links
`// --------------------------------------------------------------------------------
case 1
a = rnd(array count(HomeLinks())-1)+1
App.HomeUrl = HomeLinks(a)
if right$(App.HomeUrl,1) <> "/" then App.HomeUrl = App.HomeUrl + "/"
App.HomeUrlType = URL_LINK
App.CurrentUrl = App.HomeUrl
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,"[NEW HOME URL] = " + App.HomeUrl,"")
endcase
endselect
endfunction
`// ================================================================================================================================================================================================
`// ================================================================================================================================================================================================
`// ================================================================================================================================================================================================
`// FUNCTION - FIND CURRENT HEADER
`// ================================================================================================================================================================================================
function FindCurrentHeader(Url$)
`// --------------------------------------------------------------------------------
`// Look for a header that only contains the intial portion of the url
`// i.e. http://www.something.com/images/cats/index.com
`// will return: http://www.something.com/
`// --------------------------------------------------------------------------------
slashcount = 0
UrlCropLength = 0
x = len(Url$)
for q = 1 to x
if mid$(Url$,q)= "/"
inc slashcount,1
endif
if slashcount = 3
UrlCropLength = q
slashcount = 4 `// stop counting length
endif
next q
App.CurrentHeader = left$(Url$,UrlCropLength)
if right$(App.CurrentHeader,1) <> "/"
App.CurrentHeader = App.CurrentHeader +"/"
endif
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,"[LINKHEADER] = " + App.CurrentHeader,"")
endfunction
`// ================================================================================================================================================================================================
`// FUNCTION - SCAN FOR LINKS
`// ================================================================================================================================================================================================
function ScanForLinks(Url$)
a as byte `// used for reading single characters from memblock when scanning for links
last as byte `// used for reading single characters from memblock when scanning for links
`// --------------------------------------------------------------------------------
`// clean up old temp file ready for a new one
`// --------------------------------------------------------------------------------
if file exist(App.HTMLFile)
delete file App.HTMLFile
endif
App.RawLinks = 0
App.DuplicateLinks = 0
App.FilteredLinks = 0
App.OverflowLinks = 0
App.JavaLinks = 0
App.TotalLinks = 0
`// --------------------------------------------------------------------------------
`// Clear out previous link and caption lists
`// --------------------------------------------------------------------------------
empty array LinkList()
empty array CaptionList()
empty array ImageList()
`// --------------------------------------------------------------------------------
`// Start all lists at base 1 (bug reading count so it HAS to start 1-> count)
`// --------------------------------------------------------------------------------
add to stack LinkList()
LinkList(array count(LinkList())) = link$
add to stack CaptionList()
CaptionList(array count(CaptionList())) = caption$
add to stack ImageList()
ImageList(array count(ImageList())) = image$
`// --------------------------------------------------------------------------------
`// Exlude any file formats we don't want to search for links such as media files
`// --------------------------------------------------------------------------------
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,DEBUG_DIV,"")
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,"[SEARCHING FOR EXCLUSIONS IN URL] = " + Url$,"")
DownloadTempFile = TRUE
a$ = lower$(right$(Url$,7)) `// end portion of the url we want to search for exclusion extensions
for i = 1 to array count(Exclusions())
if strpos(Exclusions(i),a$) > 0
DownloadTempFile = FALSE
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,"[FOUND FILE EXCLUSION] = " + Exclusions(i) + "[IN URL] = " + Url$,"" )
endif
next i
`// --------------------------------------------------------------------------------
`// Download the html file of the site currently browsing
`// --------------------------------------------------------------------------------
if DownloadTempFile = TRUE
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,"[NO EXLUSION FOUND]","")
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,"[DOWNLOADING TEMP HTML FILE = " + App.HTMLFile + " from = " + Url$ + "]","")
x=CALL DLL(DLL_URLMON,"URLDownloadToFileA",0,Url$,App.HTMLFile,0,0)
`// --------------------------------------------------------------------------------
`// Create a list of links
`// --------------------------------------------------------------------------------
if x = 0 `// if file downloaded
if file exist(App.HTMLFile)
`// --------------------------------------------------------------------------------
`// read temp file into memory
`// --------------------------------------------------------------------------------
open to read FILE_HTML,App.HTMLFile
make memblock from file MEMBLOCK_HTMLFILE,FILE_HTML
close file FILE_HTML
App.Filesize = get memblock size(MEMBLOCK_HTMLFILE) - 12
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,"DOWNLOADING RAW HTML ONLY - SAVING AS " + App.HTMLFile,"")
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,"OPENING FILE:" + App.HTMLFile + " :SIZE = " + str$(App.Filesize) + " bytes","")
`// --------------------------------------------------------------------------------
`// Scan file for
`// --------------------------------------------------------------------------------
for i = 1 to App.Filesize
`// read next character from memory block
last = a
a = memblock byte(MEMBLOCK_HTMLFILE,i)
AddToString = TRUE
`// --------------------------------------------------------------------------------
`// do not include any long spaces,line feeds or tabs (i.e. eliminate double spaces when they occur to reduce string length and get better results)
`// --------------------------------------------------------------------------------
if last = 32 and a = 32 then AddToString = FALSE `// double spaces
if a = 0 then AddToString = FALSE `// null
if a = 9 then AddToString = FALSE `//
if a = 10 then AddToString = FALSE `//
if a = 11 then AddToString = FALSE `//
if a = 12 then AddToString = FALSE `//
if a = 13 then AddToString = FALSE `//
`// --------------------------------------------------------------------------------
`// add another character to the string if the character is valid
`// --------------------------------------------------------------------------------
if AddToString = TRUE
temp$ = temp$ + chr$(memblock byte(MEMBLOCK_HTMLFILE,i))
endif
`// --------------------------------------------------------------------------------
`// prevent overflows
`// --------------------------------------------------------------------------------
if len(temp$) > App.MaxLinkLength
temp$ = ""
HTMLLinkTagStart = 0
inc App.OverflowLinks,1
endif
`// --------------------------------------------------------------------------------
`// find begining of link tag ",temp$)
`// Validate and add link
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,DEBUG_DIV,"")
inc App.RawLinks,1
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,str$(App.RawLinks) + "[RAW LINK TAG FOUND] = " + temp$,"")
ValidateLink(temp$,App.RawLinks)
HTMLLinkTagStart = 0
endif
endif
next i
`// --------------------------------------------------------------------------------
`// clean up memory
`// --------------------------------------------------------------------------------
if memblock exist(MEMBLOCK_HTMLFILE) then delete memblock MEMBLOCK_HTMLFILE
else
Debug(RGB_RED,DEBUG_BRIEF,HTML_NEWLINE,"**** WARNING - FILE NOT FOUND = :" + App.HTMLFile,"")
endif
else
Debug(RGB_RED,DEBUG_BRIEF,HTML_NEWLINE,"**** WARNING - HTML DID NOT DOWNLOAD FROM = :" + Url$,"")
App.PageFail = TRUE
endif
endif
endfunction
`// ================================================================================================================================================================================================
`// FUNCTION - VALIDATE LINK
`// ================================================================================================================================================================================================
function ValidateLink(html$,RawLinkID)
`// do not proceed if javascript is found in raw html
if strpos("javascript",html$)
inc App.JavaLinks,1
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,"[JAVASCRIPT FOUND IN LINK - NOT VALID IN THIS REVISION]","")
link$ = ""
else
`// search for all other valid links
link$ = FindLinkOnly(html$,RawLinkID)
endif
if link$ > ""
`// if a link is found then go get it's caption
caption$ = FindCaptionOnly(html$,link$,RawLinkID)
`// + 1 becasue they haven't been added to the stack yet so this keeps there reference number in alignment for now
if link$ > "" then Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,str$(array count(LinkList())+1) + "[LINK FOUND] = " + link$,"")
if caption$ > "" then Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,str$(array count(CaptionList())+1) + "[CAPTION FOUND] = " + caption$,"")
`// --------------------------------------------------------------------------------
`// look for duplicate links before adding
`// --------------------------------------------------------------------------------
for i = 1 to array count(LinkList())
if LinkList(i) = Link$
DuplicateLinkFound = TRUE
`// if this duplicate has a better caption then use this instead. i.e. if the previous link only has a http string as no caption was previously found
inc App.DuplicateLinks,1
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,"[DUPLICATE LINK IN USE AT:" + str$(i) + "[LINK]" + link$,"")
if left$(CaptionList(i),4) = "http:"
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,"Caption copied into previous link: " + CaptionList(i) + " [replaced with] " + caption$,"")
CaptionList(i) = caption$
endif
endif
next i
`// --------------------------------------------------------------------------------
`// ADD LINKS AND CAPTIONS TO LINK LISTS
`// --------------------------------------------------------------------------------
if DuplicateLinkFound = FALSE
add to stack LinkList()
LinkList(array count(LinkList())) = link$
add to stack CaptionList()
CaptionList(array count(CaptionList())) = caption$
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_LINK, link$,caption$)
endif
else
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,"No useful link found","")
endif
endfunction
`// ================================================================================================================================================================================================
`// FUNCTION - FIND LINK ONLY
`// ================================================================================================================================================================================================
function FindLinkOnly(html$,RawLinkID)
`// --------------------------------------------------------------------------------
`// NOW WE HAVE A VALID ENOUGH LINKT WE WANT TO FIND JUST THE LINK
`// --------------------------------------------------------------------------------
`// (1) - Crop string to href=
`// --------------------------------------------------------------------------------
href$ = substring$(html$,strpos("href=",html$)+5,65536)
`// --------------------------------------------------------------------------------
`// (2) - check first character for ' or " and delete it
`// --------------------------------------------------------------------------------
if left$(href$,1) = chr$(34) or left$(href$,1) = "'"
link$ = right$(href$,len(href$)-1)
else
link$ = href$
endif
`// --------------------------------------------------------------------------------
`// (3) - look for the closing quotation marks and other string end conditions
`// --------------------------------------------------------------------------------
a = strpos(chr$(34),link$)
if a > 0
link$ = left$(link$,a-1)
endif
`// --------------------------------------------------------------------------------
a = strpos("'",link$)
if a > 0
link$ = left$(link$,a-1)
endif
`// --------------------------------------------------------------------------------
a = strpos(">",link$)
if a > 0
link$ = left$(link$,a-1)
endif
`// --------------------------------------------------------------------------------
a = strpos(" ",link$)
if a > 0
link$ = left$(link$,a-1)
endif
`// --------------------------------------------------------------------------------
`// look for an http header
`// --------------------------------------------------------------------------------
a = strpos("http:",link$)
if a > 0
link$ = right$(link$,len(link$)-(a-1))
endif
`// --------------------------------------------------------------------------------
`// replace some special characters to help with parsing some sites (still buggy, excluding for now)
`// --------------------------------------------------------------------------------
`link$ = replace$(link$,"%3a",":")
`link$ = replace$(link$,"%2f","/")
`link$ = replace$(link$,"%5f","_")
`link$ = replace$(link$,"%3f","?")
`link$ = replace$(link$,"%26","&")
`link$ = replace$(link$,"%3d","=")
`// --------------------------------------------------------------------------------
`// Scan Filtered words - reset link if any found
`// --------------------------------------------------------------------------------
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,str$(RawLinkID) + "[SEARCHING FOR FILTER WORDS AND CHARACTERS IN URL] = " + link$,"")
for i = 1 to array count(Filters())
if strpos(Filters(i),link$) > 0
DownloadTempFile = FALSE
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,"[FOUND FILTER EXCLUSION IN LINK] = " + Filters(i) + "[IN LINK] = " + link$ ,"")
link$ = ""
inc App.FilteredLinks,1
endif
next i
`// --------------------------------------------------------------------------------
`// If link found
`// --------------------------------------------------------------------------------
if Link$ > ""
`// --------------------------------------------------------------------------------
`// add link header if required
`// --------------------------------------------------------------------------------
if strpos("http:",link$)
else
`// prevent double forward slash links
if left$(link$,1) = "/"
link$ = right$(link$,len(link$)-1)
endif
link$ = App.CurrentHeader + link$
endif
endif
endfunction link$
`// ================================================================================================================================================================================================
`// FUNCTION - FIND CAPTION ONLY
`// ================================================================================================================================================================================================
function FindCaptionOnly(html$,link$,RawLinkID)
`// --------------------------------------------------------------------------------
`// Strip out caption formating tags
`// --------------------------------------------------------------------------------
caption$ = html$
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,str$(RawLinkID) + "[SEARCHING FOR CAPTION FORMAT TAGS TO STRIP OUT]","")
for i = 1 to array count(CaptionTags())
if strpos(CaptionTags(i),caption$) > 0
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,"[STRIPPING CAPTION TAG] = " + CaptionTags(i),"")
caption$ = replace$(caption$,CaptionTags(i),"")
endif
next i
`// --------------------------------------------------------------------------------
`// Find Caption
`// go to the end of the string and work backwrds to find the caption
`// --------------------------------------------------------------------------------
for i = len(caption$) to 1 step -1
if CaptionStartFound = 0
if mid$(caption$,i) = ">"
CaptionStartFound = i
captionfound$ = right$(caption$,len(caption$)-i)
` Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,"[CAPTION]= " + captionfound$,"")
endif
endif
next i
`// --------------------------------------------------------------------------------
`// find title string
`// --------------------------------------------------------------------------------
x = strpos("title=",html$)
if x > 0
title$ = right$(html$,len(html$)-(x+5))
`// find any leading quotation marks
if left$(title$,1) = chr$(34)
title$ = right$(html$,len(title$)-1)
endif
`// find any ending quotation marks
x = strpos(chr$(34),title$)
if x > 0
titlefound$ = left$(title$,x-1)
`Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,"[TITLE]= " + title$,"")
endif
endif
`// --------------------------------------------------------------------------------
`// copy the title into caption or vice versa to make sure we have captured it somewhere
`// --------------------------------------------------------------------------------
if titlefound$ = ""
if captionfound$ > ""
titlefound$ = captionfound$
endif
else
if captionfound$ = ""
captionfound$ = titlefound$
endif
endif
`// --------------------------------------------------------------------------------
`// if neither caption or title are found then use the link as a caption and title
`// --------------------------------------------------------------------------------
if titlefound$ = "" and captionfound$ = ""
CroppedCaption$ = left$(link$,29) + "..."
titlefound$ = CroppedCaption$
captionfound$ = CroppedCaption$
endif
endfunction titlefound$
`// ================================================================================================================================================================================================
`// FUNCTION - CREATE TEMP DATA BASE ARRAY
`// Creates a generic string based array from any string file which can then be copied to any other array thereafter
`// makes the whole operation of reading text files into arrays super fast
`// ================================================================================================================================================================================================
function CreateDatabaseArray(File$,Caption$)
membyte as byte
filesize as dword
empty array TempDatabase() `// clear previous temp database array
add to stack TempDatabase() `// to start it from base 1(as base 0 has a bug)
if file exist(File$)
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,DEBUG_DIV,"")
Debug(RGB_DEF,DEBUG_BRIEF,HTML_NEWLINE,"[READING " + Caption$ + " FILE] = " + File$,"")
Debug(RGB_DEF,DEBUG_BRIEF,HTML_LINK,"file:///" + File$, Caption$ + " DATABASE" )
DataFileSize = file size(File$)
if DataFileSize > 15 `// ensure file has at least 1 line of text to read, otherwise skip it....as file is basically empty.
open to read FILE_DATABASE,File$
make memblock from file MEMBLOCK_DBASEFILE,FILE_DATABASE
close file FILE_DATABASE
MemBlockSize = get memblock size(MEMBLOCK_DBASEFILE)
a$ = ""
for i = 0 to (MemBlockSize-1)
membyte = memblock byte(MEMBLOCK_DBASEFILE,i)
if membyte = ASCII_CR or membyte = ASCII_LF
if a$ <> ""
add to stack TempDatabase()
TempDatabase(array count(TempDatabase())) = a$
if Caption$ <> "URL CAPTIONS" `// add a special case for when reading HTML formating tags to prevent log file format corrpution
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,"[ADDING " + Caption$ + " ] = " + TempDatabase(array count(TempDatabase())),"")
else
Debug(RGB_DEF,DEBUG_VERBOSE,HTML_NEWLINE,"[ADDING " + Caption$ + " ] = " + "HTML FORMATING TAG","")
endif
endif
a$ = ""
else
a$ = a$ + chr$(memblock byte(MEMBLOCK_DBASEFILE,i))
endif
next i
`// delete temp memory
if memblock exist(MEMBLOCK_DBASEFILE) then delete memblock MEMBLOCK_DBASEFILE
else
Debug(RGB_RED,DEBUG_BRIEF,HTML_NEWLINE," **** WARNING - FILE IS BELOW MINIMUM DATA REQUIREMENTS (16 bytes) = " + File$,"")
endif
else
Debug(RGB_RED,DEBUG_BRIEF,HTML_NEWLINE," **** WARNING - FILE NOT FOUND = " + File$,"")
endif
`// --------------------------------------------------------------------------------
`// Filesize and total entries returned
`// --------------------------------------------------------------------------------
if memblock exist(MEMBLOCK_DBASEFILE) then delete memblock MEMBLOCK_DBASEFILE `// delete temp memory
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"FILESIZE = " + str$(DataFileSize) + " bytes","")
Debug(RGB_YELLOW,DEBUG_BRIEF,HTML_NEWLINE,"TOTAL " + Caption$ + " = " + str$(array count(TempDatabase())),"")
endfunction
`// ================================================================================================================================================================================================
`// MOZILLA SETTINGS
`// ================================================================================================================================================================================================
function MozillaSettings()
ptr as dword
tmpByte as byte
PathSize as dword
ID as dword
`// --------------------------------------------------------------------------------
`// Temp buffers
`// --------------------------------------------------------------------------------
PathSize = Make Memory(MAX_PATH)
ID = Make Memory(16)
`// --------------------------------------------------------------------------------
`// Find the current users documents and settings folder so we can find Mozilla settings
`// --------------------------------------------------------------------------------
if (0 = call dll(DLL_SHELL32 , "SHGetFolderLocation","", CSIDL_PROFILE, "", 0, ID))
if (call dll(DLL_SHELL32 ,"SHGetPathFromIDList", *ID, PathSize))
for b = 0 to (MAX_PATH-1)
ptr = PathSize + b
tmpByte = *ptr
if tmpByte <> 0
App.SystemPath = App.SystemPath + chr$(tmpByte)
else
exit
endif
next b
endif
endif
`// --------------------------------------------------------------------------------
`// Clean Up Memory
`// --------------------------------------------------------------------------------
if dll exist(DLL_SHELL32) then delete dll DLL_SHELL32
Delete Memory PathSize
Delete Memory ID
`// --------------------------------------------------------------------------------
`// Find Mozilla Settings Path
`// --------------------------------------------------------------------------------
App.MozillaPath = App.SystemPath + "\" + App.MozillaPath + "\"
if path exist(App.MozillaPath)
set dir App.MozillaPath
`// find the directory inside this one (name unknown, but we know its longer than 2 char ansd that there is only folder inside here
perform checklist for files
find first
while get file type()>-1
FolderName$ = get file name$()
isFolder = get file type()
if isFolder = 1
if len(FolderName$) > 3 `// eliminate . and ..
MozillaFolder$ = FolderName$
endif
endif
find next
endwhile
App.MozillaPath = App.MozillaPath + MozillaFolder$ + "\" `// add last directory
set dir App.Path `// set working directory back to original
x = 1 `// flag as path found
endif
endfunction x
`// ================================================================================================================================================================================================
`// FUNCTION - DEBUG LOG - COMPREHENSIVE & PER SESSION GENERATION - SEE \sessionlogs\ FOLDER IN INSTALL DIRECTORY FOR DEBUG AND HISTORY REVIEW
`// Recieves messages from the program and determines where to print them (if at all)
`// ================================================================================================================================================================================================
function Debug(InkColor,VerbosityMode,HTML_Tag,Message$,Caption$)
`// --------------------------------------------------------------------------------
`// NO CASE = NO OUTPUT
`// --------------------------------------------------------------------------------
ink InkColor ,RGB_BLACK
`// if caption is missing for htmllink then use the message as the caption
if Caption$ = "" then Caption$ = Message$
`// --------------------------------------------------------------------------------
`// OUTPUT TO CONSOLE AND LOG FILE
`// --------------------------------------------------------------------------------
if App.Debug
if App.DebugVerbose => VerbosityMode
`// prepare console formating as it may contain html tags as well as require a leading space to make it more readable
if Message$ = "
"
Console$ = "----------------------------------------------------------------------------------------------------------------------------"
else
Console$ = " " + Message$
endif
Select HTML_Tag
`// --------------------------------------------------
case HTML_NEWLINE
Log$ = "
" + Message$
endcase
`// --------------------------------------------------
case HTML_NEWPAR
Log$ = "" + Message$ + "
"
endcase
`// --------------------------------------------------
case HTML_INIT
Log$ = "" + "" + App.Title + " Version:" + str$(App.Version) + "." + str$(App.Revision) + "" + ""
endcase
`// --------------------------------------------------
case HTML_HEADER
Log$ = "" + Message$ + "
"
endcase
`// --------------------------------------------------
case HTML_LINK
Log$ = "
" + " Click on link " + "" + Caption$ + ""
endcase
endselect
`// --------------------------------------------------------------------------------
`// --------------------------------------------------------------------------------
select App.Debug
case DEBUG_WINDOW
if HTML_LINK <> HTML_Tag then print Console$
endcase
case DEBUG_FILE
write string FILE_DEBUG,Log$
endcase
case DEBUG_WINDOW_AND_FILE
if HTML_LINK <> HTML_Tag then print Console$
write string FILE_DEBUG,Log$
endcase
endselect
if App.DebugVerbose = DEBUG_BRIEF then wait 1
endif
endif
endfunction
`// ================================================================================================================================================================================================
`// COPYRIGHT 2008 ANTIPHORM.COM. ALL RIGHTS RESERVED.
`// ================================================================================================================================================================================================