Permalink
Browse files

Added login.vbs script

  • Loading branch information...
1 parent 2516234 commit 9130d94abb92dee2b5795a892ccaa86227100864 @Arcath committed Jun 4, 2010
View
4 app/controllers/scripts_controller.rb
@@ -0,0 +1,4 @@
+class ScriptsController < ApplicationController
+ def login
+ end
+end
View
3 app/controllers/wallpapers_controller.rb
@@ -13,13 +13,14 @@ def index
#Text Variables
if Setting.find_by_key("ps").value == "true" then
computer="Computer: #{params[:computer]}"
- user="Username: #{params[:user]}"
+ user="Username: #{params[:user].gsub("&dot;",".")}"
else
computer=params[:computer]
user=params[:user]
end
#Write the Text
wallpaper.heading(Setting.find_by_key("n").value,Setting.find_by_key("fc").value,36)
+ wallpaper.text(Time.now.strftime(Setting.find_by_key("ts").value),Setting.find_by_key("fc").value)
wallpaper.text(computer,Setting.find_by_key("fc").value)
wallpaper.text(user,Setting.find_by_key("fc").value)
View
2 app/views/layouts/application.html.erb
@@ -7,7 +7,7 @@
<div id="main">
<h1>rWallpaper</h1>
<% if current_user then %>
- <a href="/wallpapers/Computer10/<%= current_user.username %>/1024/768.png">1024x768 Wallpaper</a> - <%= link_to "Settings", settings_path %>
+ <a href="/wallpapers/Computer10/<%= current_user.username %>/1024/768.png">1024x768 Wallpaper</a> - <%= link_to "Messages", messages_path %> - <%= link_to "Settings", settings_path %>
<% end %>
<%= yield %>
</div>
View
88 app/views/scripts/login.vbs.erb
@@ -0,0 +1,88 @@
+'rWallpaper VBS Script
+' Written by Adam "Arcath" Laycock
+' June 2010
+' Generate by rWallpaper <%= Time.now %>
+
+'Objects and Variables
+screen = ScreenResolution
+Set WshNetwork = WScript.CreateObject("WScript.Network")
+uname=Replace(WshNetwork.UserName,".","&dot;")
+Set objFS=CreateObject("Scripting.FileSystemObject")
+
+'Functions
+'Screen Resolution
+Function ScreenResolution()
+ Set oIE = CreateObject("InternetExplorer.Application")
+ With oIE
+ .Navigate("about:blank")
+ Do Until .readyState = 4: wscript.sleep 100: Loop
+ width = .document.ParentWindow.screen.width
+ height = .document.ParentWindow.screen.height
+ End With
+ oIE.Quit
+ ScreenResolution = array(width,height)
+End Function
+
+'Downloader
+Sub HTTPDownload( myURL, myPath )
+' This Sub downloads the FILE specified in myURL to the path specified in myPath.
+'
+' myURL must always end with a file name
+' myPath may be a directory or a file name; in either case the directory must exist
+'
+' Written by Rob van der Woude
+' http://www.robvanderwoude.com
+'
+' Based on a script found on the Thai Visa forum
+' http://www.thaivisa.com/forum/index.php?showtopic=21832
+
+ ' Standard housekeeping
+ Dim i, objFile, objFSO, objHTTP, strFile, strMsg
+ Const ForReading = 1, ForWriting = 2, ForAppending = 8
+
+ ' Create a File System Object
+ Set objFSO = CreateObject( "Scripting.FileSystemObject" )
+
+ ' Check if the specified target file or folder exists,
+ ' and build the fully qualified path of the target file
+ If objFSO.FolderExists( myPath ) Then
+ strFile = objFSO.BuildPath( myPath, Mid( myURL, InStrRev( myURL, "/" ) + 1 ) )
+ ElseIf objFSO.FolderExists( Left( myPath, InStrRev( myPath, "\" ) - 1 ) ) Then
+ strFile = myPath
+ Else
+ WScript.Echo "ERROR: Target folder not found."
+ Exit Sub
+ End If
+
+ ' Create or open the target file
+ Set objFile = objFSO.OpenTextFile( strFile, ForWriting, True )
+
+ ' Create an HTTP object
+ Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )
+
+ ' Download the specified URL
+ objHTTP.Open "GET", myURL, False
+ objHTTP.Send
+
+ ' Write the downloaded byte stream to the target file
+ For i = 1 To LenB( objHTTP.ResponseBody )
+ objFile.Write Chr( AscB( MidB( objHTTP.ResponseBody, i, 1 ) ) )
+ Next
+
+ ' Close the target file
+ objFile.Close( )
+End Sub
+
+'Set the URL
+url = "<%= Setting.find_by_key("ru").value %>wallpapers/" & WshNetwork.ComputerName & "/" & uname & "/" & screen(0) & "/" & screen(1) & ".png"
+
+'Create the rWallpaper Folder if it doesnt exist
+if objFS.FolderExists("C:\rWallpaper") Then
+ 'Folder Exists Do Nothing
+else
+ 'Create the Folder
+ objFS.CreateFolder("C:\rWallpaper")
+end if
+
+'Download the Wallpaper
+HTTPDownload url, "C:\rWallpaper\wallpaper.png"
View
1 config/routes.rb
@@ -1,5 +1,6 @@
ActionController::Routing::Routes.draw do |map|
map.wallpapers "/wallpapers/:computer/:user/:width/:height.:format", :controller => "wallpapers"
+ map.scripts "/scripts/:action.:format", :controller => "scripts"
map.resources :user_sessions
map.resources :users
map.resources :messages
View
4 db/seeds.rb
@@ -4,7 +4,9 @@
["l","Layout","{Full Size Image}|Centered Image","choice","Choose how the image is displayed"],
["bgc","Background Colour","calculate","string","The Background colour for when using \"Centered Image\" wallpapers. If set to \"calculate\" instead of a HEX value rWallpaper will use the colour of the edge of the logo"],
["img","Image","rails.png","string","The path to an image, relative to \"#{RAILS_ROOT}/public/images/\""],
- ["fc","Font Color","#FFFFFF","string","The color of the text on the image"]
+ ["fc","Font Color","#FFFFFF","string","The color of the text on the image"],
+ ["ts","Date Format","%d/%m/%Y","string","The format of the date on the wallpaper, see the <a href=\"http://ruby-doc.org/core/classes/Time.html#M000298\" target=\"_BLANK\">Ruby Docs</a> for characters"],
+ ["ru","Root URL","http://localhost/","string","The root URL of rWallpaper, to get this take \"settings\" off the current url."]
].each do |sa|
setting=Setting.find_or_create_by_key(sa[0])
setting.name=sa[1]

0 comments on commit 9130d94

Please sign in to comment.