Jump to content

[Grafik] [Space] [Grafik], but I don't want [Space] !


fielmann
 Share

Recommended Posts

#Include <Web.au3>
$srcfile = @Scriptdir &"\script\tmpfile.au3"
If Not FileExists($srcfile) Then
    FileWrite($srcfile, ";Beginning code"&@CRLF)
EndIf
_StartWebApp_Session("test")
If _Post("code") Then
    FileWrite($srcfile, _Post("code"))
EndIf
for $i=1 to 10
echo('<img src="grafik\planet.png" width="14" height="14" hspace="0" vspace="0" alt="Test">')
next
echo('</body>')
echo('</html>')

the upper code brings as result: [Grafik] [space] [Grafik], but I don't want [space] ! :o

#Include <Web.au3>
$srcfile = @Scriptdir &"\script\tmpfile.au3"
If Not FileExists($srcfile) Then
    FileWrite($srcfile, ";Beginning code"&@CRLF)
EndIf
_StartWebApp_Session("test")
If _Post("code") Then
    FileWrite($srcfile, _Post("code"))
EndIf
$test=""
for $i=1 to 10
$test = $test & '<img src="grafik\planet.png" width="14" height="14" hspace="0" vspace="0" alt="Test">'
next
echo ($test)
echo('</body>')
echo('</html>')

Here I get back the correct result: [Grafik] [Grafik]!

But where is the problem in the first code??? :)

Link to comment
Share on other sites

  • Developers

It prints out HTML :) see also web.au3

sure... but I don't think that web.au3 is a standard include.

When you want help it helps when you post stuff that we are able to run and replicate your problem.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

sure... but I don't think that web.au3 is a standard include.

When you want help it helps when you post stuff that we are able to run and replicate your problem.

Jos

here is the source of web.au3:

#region start
#include-once
#include <Array.au3>

$AuCGI_version = EnvGet ("AUCGI_VERS")

Global $session = 0
Global $is_rss = False
Global $_MULTIPART = False

$PostContentLength = EnvGet ("CONTENT_LENGTH")
If $PostContentLength <> "" Then
    Global $_POST_raw = ConsoleRead ($PostContentLength)
EndIf
Global $_GET_raw = EnvGet("QUERY_STRING")
Global $_Cookie_Raw = EnvGet("HTTP_COOKIE")
#endregion

#region useful vars
Global $_REMOTE_ADDR = EnvGet ('REMOTE_ADDR')
Global $_ACCEPT_LANGUAGE = EnvGet ('HTTP_ACCEPT_LANGUAGE')
Global $_HOST = EnvGet ('HTTP_HOST')
Global $_ACCEPT_CHARSET = EnvGet ('HTTP_ACCEPT_CHARSET')
Global $_USER_AGENT = EnvGet ('HTTP_USER_AGENT')
Global $_SERVER_SOFTWARE = EnvGet ('SERVER_SOFTWARE')
Global $_SERVER_NAME = EnvGet ('SERVER_NAME')
Global $_SERVER_PROTOCOL = EnvGet ('SERVER_PROTOCOL')
Global $_SERVER_PORT = EnvGet ('SERVER_PORT')
Global $_SCRIPT_NAME = EnvGet ('SCRIPT_NAME')
Global $_HTTPS = EnvGet ('HTTPS')
Global $_DOCUMENT_ROOT = EnvGet('DOCUMENT_ROOT'); The root directory of your server
Global $_HTTP_REFERER = EnvGet('HTTP_REFERER'); The URL of the page that called your program
Global $_PATH = EnvGet('PATH'); The system path your server is running under
Global $_REMOTE_HOST = EnvGet('REMOTE_HOST'); The hostname of the visitor (if your server has reverse-name-lookups on; otherwise this is the IP address again)
Global $_REMOTE_PORT = EnvGet('REMOTE_PORT'); The port the visitor is connected to on the web server
Global $_REMOTE_USER = EnvGet('REMOTE_USER'); The visitor's username (for .htaccess-protected pages)
Global $_REQUEST_METHOD = EnvGet('REQUEST_METHOD'); GET or POST
Global $_REQUEST_URI = EnvGet('REQUEST_URI'); The interpreted pathname of the requested document or CGI (relative to the document root)
Global $_SCRIPT_FILENAME = EnvGet('SCRIPT_FILENAME'); The full pathname of the current CGI
Global $_SERVER_ADMIN = EnvGet('SERVER_ADMIN'); The email address for your server's webmaster
#endregion

#region funcs
;===============================================================================
;
; Description:    Sends the http header to the browser for web-based applications.
; Parameter(s):  $sTitle          - The title of the web page to start.
;                  $sCookie      - If you want to specify a cookie, do it here.
;                               Use the format name=value. "" by default.
;                  $sContent_type   - lets you specify a different content type
;                               other than text/html.
; Requirement(s):   None
; Return Value(s):  On Success - 0
;                  On Failure - 0  and Set @error to 1 if unable to ConsoleWrite
; Author(s):        Matt Roth (theguy0000) <theguy0000@gmail.com>
; Note(s):        Must go at the top of all web-based applications.
;
;===============================================================================
Func _StartWebApp ($sTitle="", $sCookie = "", $sContent_type="text/html")
    Local $error = 0
    if $sCookie <> "" then
        ConsoleWrite("Content-Type: "&$sContent_type & Chr(13) & Chr(10) & "Set-Cookie: " & $sCookie & Chr(13) & Chr(10) & Chr(13) & Chr(10))
        If @error then $error = 1
    else
        ConsoleWrite("Content-Type: "&$sContent_type & Chr(13) & Chr(10) & Chr(13) & Chr(10))
        If @error then $error = 1
    endif
   ;If $sTitle <> "" Then ConsoleWrite("<html><head><title>"&$sTitle&"</title></head><body bgcolor=#FAFAFA>")
    If $sTitle <> "" Then ConsoleWrite("<html><head><title>"&$sTitle&"</title></head><body>")
    If @error then $error = 1
    SetError ($error)
    Return 0
EndFunc

;===============================================================================
;
; Description:    Sends text to be displayed in the web browser.
; Parameter(s):  $sText        - The text to display.
; Requirement(s):   None
; Return Value(s):  On Success - 0
;                  On Failure - 0  and Set @error to 1 if unable to ConsoleWrite
; Author(s):        Matt Roth (theguy0000) <theguy0000@gmail.com>
; Note(s):        The text can include html.
;
;===============================================================================
Func echo($sText, $sTag="")
    Local $error
    Local $tagsplit = StringSplit ($sTag, " ")
    If $sTag <> "" Then
        ConsoleWrite("<"&$sTag&">"&$sText&"</"&$tagsplit[1]&">" & @crlf)
    Else
        ConsoleWrite ($sText & @crlf)
    EndIf
    If @error then $error = 1
    SetError ($error)
    Return 0
EndFunc

Func echol($sText, $sTag="")
    Local $error
    Local $tagsplit = StringSplit ($sTag, " ")
    If $sTag <> "" Then
        ConsoleWrite("<"&$sTag&">"&$sText&"</"&$tagsplit[1]&"><br />" & @crlf)
    Else
        ConsoleWrite ($sText&"<br />" & @crlf)
    EndIf
    If @error then $error = 1
    SetError ($error)
    Return 0
EndFunc

;===============================================================================
;
; Description:    Gets the value of a POST variable sent to the page.
; Parameter(s):  $sVar          - The name of the variable to retrieve
; Requirement(s):   None
; Return Value(s):  On Success - The value of the requested variable.
;                  On Failure - "" if the requested variable doesn't exist.
; Author(s):        Matt Roth (theguy0000) <theguy0000@gmail.com>
; Note(s):        None.
;
;===============================================================================
Func _Post($sVar)
    Local $varstring, $num, $vars, $var_array
    $varstring = $_POST_raw
    If Not StringInStr($varstring, $sVar&"=") Then Return ""
    $num = __StringFindOccurances($varstring, "=")
    Local $vars[$num+1]
    $vars = StringSplit ($varstring, "&")
    For $i=1 To $vars[0]
        $var_array = StringSplit ($vars[$i], "=")
        If $var_array[0] < 2 Then Return "error"
        If $var_array[1] = $sVar Then Return _URLDecode($var_array[2])
    Next
    Return ""
EndFunc

;===============================================================================
;
; Description:    Gets the value of a GET variable sent to the page.
; Parameter(s):  $sVar          - The name of the variable to retrieve
; Requirement(s):   None
; Return Value(s):  On Success - The value of the requested variable. (or returns True. see notes)
;                  On Failure - "" if the requested variable doesn't exist.
; Author(s):        Matt Roth (theguy0000) <theguy0000@gmail.com>
; Note(s):        If $iVarType is 1, it uses variables without values, like script.auw?myvar
;                      then you could use _Get("myvar", 1) and it would return true.
;
;===============================================================================
Func _Get($sVar, $iVarType=0)
    Local $varstring, $num, $vars, $var_array
    $varstring = $_GET_raw
    If Not StringInStr($varstring, $sVar&"=") Then Return ""
    $num = __StringFindOccurances($varstring, "=")
    Local $vars[$num+1]
    $vars = StringSplit ($varstring, "&")
    For $i=1 To $vars[0]
        If $iVarType Then
            If $vars[$i] = $sVar Then Return True
        Else
            $var_array = StringSplit ($vars[$i], "=")
            If $var_array[0] < 2 Then Return "error"
            If $var_array[1] = $sVar Then Return _URLDecode($var_array[2])
        EndIf
    Next
    If $iVarType Then Return False
    Return True
EndFunc

;===============================================================================
;
; Description:    Gets the value of a cookie.
; Parameter(s):  $sVar          - The name of the variable to retrieve
; Requirement(s):   None
; Return Value(s):  On Success - The value of the requested cookie.
;                  On Failure - "" if the requested cookie doesn't exist.
; Author(s):        Matt Roth (theguy0000) <theguy0000@gmail.com>
; Note(s):        None.
;
;===============================================================================
Func _Cookie($sVar)
    Local $varstring, $num, $vars, $var_array
    $varstring = $_Cookie_Raw
    If Not StringInStr($varstring, $sVar&"=") Then Return ""
    $num = __StringFindOccurances($varstring, "=")
    Local $vars[$num+1]
    $vars = StringSplit ($varstring, "&")
    For $i=1 To $vars[0]
        $var_array = StringSplit ($vars[$i], "=")
        If $var_array[0] < 2 Then Return "error"
        If $var_array[1] = $sVar Then Return $var_array[2]
    Next
    Return ""
EndFunc

;===============================================================================
;
; Description:    Gets a file that was submitted form, or the value of an input
;                      in a multipart form.
; Parameter(s):  $sVar          - The name of the input where the file was
;                                         submitted.
; Requirement(s):   None
; Return Value(s):  On Success -
;                          IF THE REQUESTED VARIABLE IS A FILE:
;                               An array:
;                                  [0] - Name of the file - example: hello.txt
;                                  [1] - Content type of the retrieved file - Example: text/plain
;                                  [2] - Contents of the file.
;                          IF THE REQUESTED VARIABLE IS NOT A FILE:
;                              Value of the variable
;                  On Failure - 0
; Author(s):        Matt Roth (theguy0000) <theguy0000@gmail.com>
; Note(s):        None.
;
;===============================================================================
Func _PostMultipart ($sVar)
    Local $ret[3]
    $split = StringSplit ($_POST_raw, "-----------------------------", 1)
    For $i = 1 To $split[0]
        $temp_split = StringSplit ($split[$i], @CRLF, 1)
        If $temp_split[0] < 4 Then ContinueLoop
;~   _ArrayDisplay ($temp_split, "")
        _ArrayDelete ($temp_split, 0)
;~   _ArrayDisplay ($temp_split, "")
        If StringInStr ($temp_split[1], '; filename="') Then
            $name_pos = StringInStr ($temp_split[1], '; name="')
            $name = StringRight ($temp_split[1], StringLen($temp_split[1])-($name_pos+7))
            $quote_pos = StringInStr ($name, '"')
            $name = StringLeft ($name, (StringLen($name)-(StringLen($name)-$quote_pos))-1)
;~  MsgBox (0, "", $name)
            If $name <> $sVar Then ContinueLoop
            $pos = StringInStr ($temp_split[1], '; filename="')
            $ret[0] = StringRight ($temp_split[1], StringLen($temp_split[1])-($pos+11))
            $ret[0] = StringTrimRight ($ret[0], 1)
            _ArrayDelete ($temp_split, 1)
            $ret[1] = StringRight($temp_split[1], StringLen($temp_split[1])-14)
            _ArrayDelete ($temp_split, 1)
            _ArrayDelete ($temp_split, 1)
            _ArrayDelete ($temp_split, 0)
            _ArrayDelete ($temp_split, UBound($temp_split)-1)
            $ret[2] = _ArrayToString($temp_split, @CRLF)
;~  _ArrayDisplay ($temp_split, "")
            Return $ret
        Else
            $name_pos = StringInStr ($temp_split[1], '; name="')
            $name = StringRight ($temp_split[1], StringLen($temp_split[1])-($name_pos+7))
            $quote_pos = StringInStr ($name, '"')
            $name = StringLeft ($name, (StringLen($name)-(StringLen($name)-$quote_pos))-1)
;~  MsgBox (0, "", $name)
            If $name <> $sVar Then ContinueLoop
            Return $temp_split[3]
        EndIf
    Next
    Return 0
EndFunc

;===============================================================================
;
; Description:    echo's a string telling the user their visitor number.
; Parameter(s):  $sCounterMsg    - The text to be echo'd. % will be replaced
;                               with the visitor number.
;                  $sCounter        - Optional path to the file where the visitor
;                               number will be stored/retrieved.
; Requirement(s):   None
; Return Value(s):  On Success - the visitor number
; Author(s):        Matt Roth (theguy0000) <theguy0000@gmail.com>
; Note(s):        None.
;
;===============================================================================
Func _WebCounter($sCounterMsg='You are Visitor Number % to this page', $sCounter='')
    If $sCounter = '' Then $sCounter = "C:\count_"&$_SCRIPT_NAME&".txt"
    If Not FileExists ($sCounter) Then FileWriteLine ($sCounter, 0)
    Dim $i
    Dim $line = FileRead($sCounter)
    Dim $ending
    $i = $line + $i
    If $i = 1 Then
        $ending = "st"
    ElseIf $i = 2 Then
        $ending = "nd"
    ElseIf $i = 3 Then
        $ending = "rd"
    Else
        $ending = "th"
    EndIf

    echo (StringReplace (StringReplace($sCounterMsg,"!",$ending), "%", $i))

    FileDelete($sCounter)
    FileWriteLine($sCounter,$i)
    Return $i
EndFunc

Func __StringFindOccurances($sStr1, $sStr2); NOT BY ME
    For $i = 1 to StringLen($sStr1)
        If not StringInStr($sStr1, $sStr2, 1, $i) Then ExitLoop
    Next
    Return $i
EndFunc

;===============================================================================
;
; Description:    Displays a message box on the user's computer.
; Parameter(s):  $sCounterMsg    - The text to be echo'd. % will be replaced
;                               with the visitor number.
;                  $sCounter        - Optional path to the file where the visitor
;                               number will be stored/retrieved.
; Requirement(s):   Javascript enabled on the user's browser
; Return Value(s):  On Success - the visitor number
; Author(s):        Matt Roth (theguy0000) <theguy0000@gmail.com>
; Note(s):        None.
;
;===============================================================================
Func _MsgBox($sText)
    echo('<script language="javascript" type="text/javascript">')
    echo('alert("'& $sText &'")')
    echo("</script>")
EndFunc

;===============================================================================
;
; Description:    optionally echo's a string of text then exits the script.
; Parameter(s):  $sText  - The optional text to be echo'd before exiting.
; Requirement(s):   None
; Return Value(s):  0
; Author(s):        Matt Roth (theguy0000) <theguy0000@gmail.com>
; Note(s):        None.
;
;===============================================================================
Func die ($sText="")
    echo ($sText)
    Exit
EndFunc

;===============================================================================
;
; Description:    Sends the http header to the browser with session variables enabled.
; Parameter(s):  $sTitle          - The title of the web page to start.
;                  $sContent_type   - lets you specify a different content type
;                               other than text/html.
; Requirement(s):   Javascript enabled on the user's browser
; Return Value(s):  0
; Author(s):        Matt Roth (theguy0000) <theguy0000@gmail.com>
; Note(s):        If you want to use session variables, you should use this instead
;                         of _StartWebApp
;
;===============================================================================
Func _StartWebApp_Session ($sTitle="", $sContent_type="text/html")
    $session = 1
    If _GetSID()>11110 Then
        ConsoleWrite("Content-Type: " & $sContent_type & Chr(13) & Chr(10) & "Set-Cookie: sid="&_GenerateSID() & Chr(13) & Chr(10) & Chr(13) & Chr(10))
        If $sTitle <> "" Then ConsoleWrite("<html><head><title>"&$sTitle&"</title></head><body>")
        $_Cookie_Raw = EnvGet ("HTTP_COOKIE")
    Else
        _StartWebApp ($sTitle)
    EndIf
EndFunc

Func _GenerateSID ()
    Local $ret
    Do
        $ret = Random (11111, 99999, 1)
    Until IniRead ("sessions.ini", "list", $ret, "no") = "no"
    IniWrite ("sessions.ini", "list", $ret, "yes")
    Return $ret
EndFunc

;===============================================================================
;
; Description:    gets the current user's Session ID.
; Parameter(s):  None
; Requirement(s):   None
; Return Value(s):  On Success - The user's SID
;                  On Failure - ""
; Author(s):        Matt Roth (theguy0000) <theguy0000@gmail.com>
; Note(s):        None.
;
;===============================================================================
Func _GetSID ( )
    Return _Cookie ("sid")
EndFunc

;===============================================================================
;
; Description:    Sets a session variable
; Parameter(s):  $sName - The name of the variable to set
;                  $sValue - The value of the new variable.
; Requirement(s):   _StartWebApp_Session at the beginning of the script
; Return Value(s):  On Success - 1
;                  On Failure - 0 If the ini file is read-only or sessions aren't enabled.
; Author(s):        Matt Roth (theguy0000) <theguy0000@gmail.com>
; Note(s):        None.
;
;===============================================================================
Func _Session_set ($sName, $sValue)
    If Not $session Then Return 0
    Return IniWrite ("sessions.ini", _GetSID (), $sName, $sValue)
EndFunc

;===============================================================================
;
; Description:    gets the value of a session variable.
; Parameter(s):  $sName - the name of the variable to retrieve.
; Requirement(s):   _StartWebApp_Session at the beginning of the script
; Return Value(s):  On Success - The value of
;                  On Failure - ""
; Author(s):        Matt Roth (theguy0000) <theguy0000@gmail.com>
; Note(s):        None.
;
;===============================================================================
Func _Session ($sName)
    If Not $session Then Return 0
    Return IniRead ("sessions.ini", _GetSID(), $sName, "")
EndFunc

;===============================================================================
;
; Description:    Create an ActiveX Object for use later.
; Parameter(s):  $sObj - the object to create, for example, SAPI.SpVoice
;                  $sObjName - could be anything to identify it to you, but must
;                    adhere to the following standards
;                        -they cannot be any of the words found here: http://www.javascriptkit.com/jsref/reserved.shtml
;                        -they are case sensitive
;                        -they can begin with a letter or underscore, NOT a numeral
;                        -no spaces...
; Requirement(s):   _StartWebApp_Session at the beginning of the script
; Return Value(s):  On Success - The value of
;                  On Failure - ""
; Author(s):        Matt Roth (theguy0000) <theguy0000@gmail.com>
; Note(s):        Does not work if javascript is not enabled, and even if it is,
;                    security settings sometimes stop it.
;
;===============================================================================
Func WebObjCreate($sObj, $sObjName)
    Local $out='<script language="javascript" type="text/javascript">'&@CRLF
    $out &= 'var '&$sObjName&' = ActiveXObj ('&$sObj&');'&@crlf
    $out &= '</script>'&@CRLF
    echo ($out)
    return $out
EndFunc

;===============================================================================
;
; Description:    starts a web page that will be used as an RSS Feed.
; Parameter(s):  $sTitle - The name of the channel. It's how people refer to
;                        your service. If you have an HTML website that
;                        contains the same information as your RSS file, the
;                        title of your channel should be the same as the title
;                        of your website.
;                  $sLink - The URL to the HTML website corresponding to the channel.
;                  $sDescription - Phrase or sentence describing the channel.
;                  $sLanguage - [optional] the language your RSS feed is in. Default is en-us. Set as an empty string to omit.
;                  $sCopyright - [optional] Copyright notice for content in the channel. Default is a blank string
;                  $sEditor - [optional] Email address for person responsible for editorial content. Default is a blank string.
;                  $sMaster - [optional] Email address for person responsible for technical issues relating to channel.
; Requirement(s):   None.
; Return Value(s):  On Success - True
;                  On Failure - False
; Author(s):        Matt Roth (theguy0000) <theguy0000@gmail.com>
; Note(s):        If you use this, do not use _StartWebApp () or _StartWebApp_Session ()
;
;===============================================================================
Func _StartRssFeed ($sTitle, $sLink, $sDescription, $sLanguage="en-us", $sCopyright="", $sEditor="", $sMaster="")
    $error = False
    Global $is_rss = True
    _StartWebApp ()
    If @error Then Return SetError (1, @error, False)
   
    echo ('<?xml version="1.0"?>')
    If @error Then Return SetError (2, @error, False)
    echo ('<rss version="2.0">')
    If @error Then Return SetError (3, @error, False)
    echo ('<channel>')
    If @error Then Return SetError (4, @error, False)
    echo ('<title>'&$sTitle&'</title>')
    If @error Then Return SetError (5, @error, False)
    echo ('<link>'&$sLink&'</link>')
    If @error Then Return SetError (6, @error, False)
    echo ('<description>'&$sDescription&'</description>')
    If @error Then Return SetError (7, @error, False)
    If $sLanguage <> "" Then echo ('<language>'&$sLanguage&'</language>')
    If @error Then Return SetError (8, @error, False)
    If $sCopyright <> "" Then echo ('<copyright>'&$sCopyright&'</copyright>')
    If @error Then Return SetError (9, @error, False)
    If $sEditor <> "" Then echo ('<managingEditor>'&$sEditor&'</managingEditor>')
    If @error Then Return SetError (10, @error, False)
    If $sMaster <> "" Then echo ('<webMaster>'&$sMaster&'</webMaster>')
    If @error Then Return SetError (11, @error, False)
    echo ('<generator>AutoIt '&@AutoItVersion&'</generator>')
    If @error Then Return SetError (12, @error, False)
    echo ('<docs>http://validator.w3.org/feed/docs/rss2.html</docs>')
    If @error Then Return SetError (13, @error, False)
   
    Return True
EndFunc

;===============================================================================
;
; Description:    Adds an Item to the current RSS Feed
; Parameter(s):  $sTitle - The title of the item.
;                  $sDescription - The item synopsis.
;                  $sLink - [optional] The URL of the item. Leave blank to omit.
;                  $sAuthor - [optional] Email address of the author of the item.
;                         Leave blank to omit.
;                  $sCategory - [optional] Includes the item in one or more
;                           categories. Leave blank to omit.
;                  $sGuid - [optional] A string that uniquely identifies the item.
;                          There are no syntax rules. Leave blank to omit.
;                  $sPubDate - [optional] Indicates when the item was published.
;                          Leave blank to omit. Must be in the format:
;                          WWW, DD MMM YYYY HH:MM:SS GMT
;                          Example:
;                          Sun, 19 Aug 2002 15:21:36 GMT
; Requirement(s):   _StartRssFeed ()
; Return Value(s):  On Success - True
;                  On Failure - False
; Author(s):        Matt Roth (theguy0000) <theguy0000@gmail.com>
; Note(s):        None.
;
;===============================================================================
Func _RssAddItem ($sTitle, $sDescription, $sLink="", $sAuthor="", $sCategory="", $sGuid="", $sPubDate="")
    If Not $is_rss Then Return SetError( -1, "", False)
    echo ('<item>')
    If @error Then Return SetError (1, @error, False)
    echo ('<title>'&$sTitle&'</title>')
    If @error Then Return SetError (2, @error, False)
    echo ('<description>'&$sDescription&'</description>')
    If @error Then Return SetError (3, @error, False)
    If $sLink <> "" then echo ('<link>'&$sLink&'</link>')
    If @error Then Return SetError (4, @error, False)
    If $sAuthor <> "" then echo ('<author>'&$sAuthor&'</author>')
    If @error Then Return SetError (5, @error, False)
    If $sCategory <> "" then echo ('<category>'&$sCategory&'</category>')
    If @error Then Return SetError (6, @error, False)
    If $sGuid <> "" then echo ('<guid>'&$sGuid&'</guid>')
    If @error Then Return SetError (7, @error, False)
    If $sPubDate <> "" then echo ('<pubDate>'&$sPubDate&'</pubDate>')
    If @error Then Return SetError (8, @error, False)
    echo ('</item>')
    If @error Then Return SetError (9, @error, False)
   
    Return True
EndFunc

;===============================================================================
;
; Description:    ends the RSS Feed
; Parameter(s):  None.
; Requirement(s):   None.
; Return Value(s):  On Success - True
;                  On Failure - False
; Author(s):        Matt Roth (theguy0000) <theguy0000@gmail.com>
; Note(s):        This will exit the script. You cannot do anything else after using this function.
;
;===============================================================================

Func _EndRssFeed ()
    If Not $is_rss Then Return SetError( -1, "", False)
   
    echo ('</channel>')
    If @error Then Return SetError (1, @error, False)
    echo ('</rss>')
    If @error Then Return SetError (2, @error, False)
   
    Return True
EndFunc

#endregion

#region helper funcs

;===============================================================================
; _URLEncode()
; Description: : Encodes a string to be URL-friendly
; Parameter(s): : $toEncode - The String to Encode
; : $encodeType = 0 - Practical Encoding (Encode only what is necessary)
; : = 1 - Encode everything
; : = 2 - RFC 1738 Encoding - http://www.ietf.org/rfc/rfc1738.txt
; Return Value(s): : The URL encoded string
; Author(s): : nfwu
; Note(s): : -
;
;===============================================================================
Func _URLEncode($toEncode, $encodeType = 0)
    Local $strHex = "", $iDec
    Local $aryChar = StringSplit($toEncode, "")
    If $encodeType = 1 Then;;Encode EVERYTHING
        For $i = 1 To $aryChar[0]
            $strHex = $strHex & "%" & Hex(Asc($aryChar[$i]), 2)
        Next
        Return $strHex
    ElseIf $encodeType = 0 Then;;Practical Encoding
        For $i = 1 To $aryChar[0]
            $iDec = Asc($aryChar[$i])
            if $iDec <= 32 Or $iDec = 37 Then
                $strHex = $strHex & "%" & Hex($iDec, 2)
            Else
                $strHex = $strHex & $aryChar[$i]
            EndIf
        Next
        Return $strHex
    ElseIf $encodeType = 2 Then;;RFC 1738 Encoding
        For $i = 1 To $aryChar[0]
            If Not StringInStr("$-_.+!*'(),;/?:@=&abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", $aryChar[$i]) Then
                $strHex = $strHex & "%" & Hex(Asc($aryChar[$i]), 2)
            Else
                $strHex = $strHex & $aryChar[$i]
            EndIf
        Next
        Return $strHex
    EndIf
EndFunc

;===============================================================================
; _URLDecode()
; Description: : Tranlates a URL-friendly string to a normal string
; Parameter(s): : $toDecode - The URL-friendly string to decode
; Return Value(s): : The URL decoded string
; Author(s): : nfwu
; Note(s): : -
;
;===============================================================================
Func _URLDecode($toDecode)
    local $strChar = "", $iOne, $iTwo
    Local $aryHex = StringSplit($toDecode, "")
    For $i = 1 to $aryHex[0]
        If $aryHex[$i] = "%" Then
            $i = $i + 1
            $iOne = $aryHex[$i]
            $i = $i + 1
            $iTwo = $aryHex[$i]
            $strChar = $strChar & Chr(Dec($iOne & $iTwo))
        Else
            $strChar = $strChar & $aryHex[$i]
        EndIf
    Next
    Return StringReplace($strChar, "+", " ")
EndFunc
#endregion
Link to comment
Share on other sites

  • Developers

The difference seems to be that each ECHO() command sends an extra @CRLF:

ConsoleWrite ($sText & @crlf)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...