Coloring Batch Files! – within one file!

I wanted colored batch files and I managed to achieve this with someones solution which I modified and made my own, it is now quite different to his but I cannot find who it was to give them credit, anyway, here is the code!

 

@echo off
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)
title Startup Assist - Handler
call :ColorText 08 "["
call :ColorText 08 "Service"
call :ColorText 08 "]"
call :ColorText 08 " Startup Assist - HANDLER - RUNNING "
echo.
call :ColorText 08 "["
call :ColorText 0E "WARNING"
call :ColorText 08 "]"
call :ColorText 08 " Startup Assist will stop if a server startup file is not found this is because of windows MS DOS functionality, Sorry "
echo.
call :ColorText 08 "["
call :ColorText 08 "Minecraft Service"
call :ColorText 08 "]"
call :ColorText 0A " Minecraft Server "
call :ColorText 0C " Nexion"
call :ColorText 0A " Started"
echo.
start "launch.bat" "C:UsersNexionDocumentsMinecraft ServersNexionlaunch.bat"
echo(
call :ColorText 79 "This window will now await user input!"
echo.
)
PAUSE
exit
goto :eof

:ColorText
echo off
“%~2”
findstr /v /a:%1 /R “^$” “%~2” nul
del “%~2” > nul 2>&1
goto :eof

which looks something like this

Capture

As you can tell, this is for my minecraft server ūüôā (Nexion.co.uk)

and that’s all there is to it! you can use any standard colors that you could already within batch files. (Note: When running without user, i.e. started by another process, the colors requite administrative privileges!)

edit: http://stackoverflow.com/questions/7290434/how-can-i-make-a-multi-functional-batch-program

Using Hashlib to Securely store user passwords and credentials.

What is hashing?

Hashing a password means that users cannot have their passwords compromised when a database engineer is reading cleartext in user databases (to a degree, the passwords could be decoded, but hashing them makes them illegible to someone who is not doing anything extensive). And also prevents hackers from reading passwords in plain text and can be compromised by collision attacks.

Additionally when hashing a password a salt may be added to the password, this prevents a database from being attacked by dictionary attacks.

Why Hash Passwords?

Storing User credentials in Plain Text is generally as bad practice as it allows anyone who reads the file (or computer) to see the password, username or any other credential without any sort of protection, In some cases it is against the law, such as PCI SSC Data Security Standards which handles debit and other card types. The solution to this is to Obfuscation in the form of hashing. Hashing a password makes a standard password seem completely random.

How hashing works

When a user signs up for a website or any other form that requires secure credentials, such as a password, username, email address or address, that user will fill in a form that will ask these credentials, then the web server will both hash and store the hash, the server will ‘throw away’ the original password and keep the hash. In a more secure environment the user may also be given a salt, this may be unique to the user or unique to the application (The user will not know the salt, the salt is owned by the server and will be kept secret.). When hashing both the password and salt will be combined and hashed.

Raspberry Pi – PHP permission File Problems Solved!

I recently installed php, but when I was unable to save files, I was very stuck, and that’s why I’m posting it here, I want to tell anyone who Googles this problem to find this solution.

 

The problem was when I used an fopen and fsave within php, the file would always ‘die’ as in the open or die within php. The solution is below

Firstly I looked for the Environment user in phpinfo() in my case it was
[box type=”shadow”]www-data[/box]
and then I simply typed this
[box type=”shadow”]chmod 777 -R¬†www-data /var/www[/box]
that, in its simplicity is the solution, but I am thankful that I have found the solution!

To create a phpinfo you need to create a file in your root and insert the following code

and save it as phpinfo.php or whatever you choose, I saved it in my root but you can save it wherever you want, then I browsed to the environments section and that gave me the necessary information for me to create the solution.

Why this works

The problem was that php did not have enough permissions to write to the folder. by giving the user www-data full permission i.e. 777 it can now read write and execute without a problem!

here is what php looks like when you do phpinfo

phpinfo() user sample on Raspberry Pi
phpinfo() user sample on Raspberry Pi

you can check a file exits and is editable with this code http://stackoverflow.com/a/13297218

Now you’ve finished you can celebrate! here is a song (this is mainly so i can test embedding :P)

Structuring your Harddrive

A habit worth looking into is to structure your hard-drive and here is some notes.

  • Your hard-drive root (C:) should just be folders, nothing else, and it shouldn’t have any of YOUR folders that you keep stuff in that your not sharing on a network, thats what your user folder is for.
  • Share folders on a drive root. Long names for files will eventually fill the limit and you cant store anything, so I keep all my shared folders in root in organised folders, but don’t clutter your HDD, it should be a thing of beauty, not a baron list of folders and files, just files. (To clarify, I mean you should only have folders on your C: nothing else)
  • Have a C:/Store folder and a C:/Drivers folder, C:/Store is for stuff you need but don’t want, like pesky programs that wont live in Program Files. and C:/Drivers is for all the installers for your computer from your manufacturers website.

Why go to all this trouble? Well its good practise I suppose.

The Joys of 5TB at your disposal..

I have my computer for multiple reasons, editing, video production, gameing, rendering and general use, because of that I have a very high spec computer and it’s great, but today I want to talk about the joys of excessive HDD space.

First of all, I dont have a SSD, and I dont plan on getting one, but they seem great, so I may consider it, please stop commenting on this subject, I am fully aware of the Joys of SSDs. my server has a 30GB one and it is great, but please, no more spam.

So first, whats it good for? Well currently I have 3 HDDs and they are setup with no raid, but I do have VSS running which is great, but heres a bullet pointed list.

 

  • Previous Versions, A vital backup tool.I have this on Alfie (My harddrive name), this is connected to the computer via USB so its slower, and therefore I use it for bvackups and archiveing stuff rather than storage.Its great!, when your computer dies, you cant help but feel a bit down hearted, but with this, you just hit F8 a bunch of times, select your date and your done, but it can take some time if your backup was a while ago, so do it regularly, or set it to an interval.
  • Windows Image Backup or File History,¬†¬†its like backup, but you can restore Individual files so if you deleted a folder, you can just roll it back I have used this a few times and its really saved me. ¬†I over use this to, deleted something you shouldn’t?, ‘is it in the recycle bin, no, hmm just roll back the folder, ah there it is.’ . Also on Alife.
  • Store all the things. I have Felix for this, a swifty SATA HDD, I haven’t deleted anything in a while I keep all my songs, video and Pictures on it and its great. I also keep software and Installers on there incase my software breaks.
  • RAID. I dont have this, but its worth pointing out RAID would be useful, but Id rather use all the space :).

 

Example Bukkit Plugin

This is an example plugin I wrote, feel free to use it however you wish, for a tutorial on how to install and configure the plugin to work on a minecraft server, excludeing placeing it in your minecraft server and error checking see here

Also, you can download the entire source here

 

Adding Hosts to Godaddy

GoDaddy is a great Domain Registrar,  I have GoDaddy as my Domain Registrar.

When using domains and Subdomains you may want to have multiple websites on the same server, here is how to add hosts to your GoDaddy account.

 

First Browse to Godaddy and Login, It may be slightly different for you as I live in the UK.

First Click on My Account, then Visit My Account… You should see this page, Expand Domains.

Godaddy Main

On the domain you would like to Add a Host to, Click Launch. You should See this Page….

Godaddy Main 2

Please note some of my sensitive information has been removed…

To add a subdomain Click Host Names (Manage) In there click Add Hostname. The Hostname will be the Subdomain Name, The IP address will be the IP address of the web server(Or Application Server). Then Click Add.

Please note that it can take up to 48 Hours for a DNS Host to update through the Internet.

To Set the Domain Record, Click DNS Zone File, Click Add Record, Select A (Host), Enter the Host that will be the Domain or Subdomain, such as www (By Default this is already configured, so click edit rather than add record.) Then Click Points to, The IP address will be the IP address of the web server(Or Application Server), Then set The Time To Live (TTL), If you are unsure what to do, leave it as default. Then Click Add.

Please note that it can take up to 48 Hours for a DNS Host to update through the Internet.

 

You have now configured a new host!

 

If you want to add another, repeat the process.

Adding Virtual Domains to Apache

Virtual Hosts are great for servers, it allows you to have multiple domains, Subdomains and Users all use the same Web Host (Server) and Is easy to configure.

 

First Please make sure your server is configured to use Virtual Hosts, See Here , Please note this is fundamental

 

Now you have your domain on a Virtual host you can now add others, But you need to add your Host to your DNS zone file from your domain regestrar, See Here

 

 

Now you are ready browse to your Apache installation folder and go to httpd-vhosts.conf

[box type=”shadow”]apacheconfextrahttpd-vhosts.conf[/box]

 

and add the extra hosts you setup in your Domain Registrars DNS Host Names like so,

(be sure to replace ‘dds’ with your subdomain)

Make sure this is at the end of your file, after your root of the domain, make sure you have configured the subdomain folder and the DNS Host names

Be aware that It can take up to 48 hours for Host Records to update through the internet!

How to Configure Apache to use Virtual Hosts

Using Apache is Good, but for one website is limiting its potential you can create multiple websites, domains and sub-domains with Apache, see below.

 

 

First you need to stop your server, you can do this on lunix by entering
[box type=”shadow”] $ sudo /etc/init.d/apache2 stop¬†[/box]

into your terminal, this allows you to make changes to files in your server without breaking it, for windows you need to stop Apache using Xammp, see below.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Now Enable Mod_log_config browse here

[box type=”shadow”]xamppapacheconf[/box]

and in httpd.conf remove the # from this line

[box type=”shadow”]#LoadModule log_config_module modules/mod_log_config.so[/box]

to look like this

[box type=”shadow”]LoadModule log_config_module modules/mod_log_config.so[/box]

 

next using an FTP program or other method, go to your website’s root directory such as

[box type=”shadow”]/home/*/public_html/cgi-bin/[/box]

 

Or for windows

[box type=”shadow”]C:xampphtdocs[/box]

This is the base of your web server, and probably where your Index.html is located, create two folders, Domains and Subdomains, this is where your domains will be stored. See below

Domains, Subdomains

 

 

 

 

 

 

 

In Domains, Place the dome of your website, replacing dots with hyphens like so

Domains, if

 

 

 

(Also add any other websites that you plan to host on the server)

Then copy the data that was in your root of the server into the domain folder on the server like this

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

then paste  into your domain folder like this

 

Paste

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

So your Server should now have the ‘root’ of the server in

[box type=”shadow”]WEBROOTDomainsinfinityflame-co-ukindex.html[/box]

or subsequent folders in Linux.

now you need to redirect traffic from your website to the correct folder, this is done with virtual Hosts’s, and is also how you add sub domains see below

browse to your Apache installation folder and go to httpd-vhosts.conf

[box type=”shadow”]apacheconfextrahttpd-vhosts.conf[/box]

 

and at the bottom add the following code replaceing my domain, with yours.

now test the website, start Apache and browse to your domain, you should see your site as you did before, you have now configured your website to use Virtual Hosts

now you need to add other domains and subdomains, See Here