Sometimes when you publish a list of events at specific dates on your website,
it can be usefull to allow external people to subscribe to a calendar using outlook
or any other calendar (mozilla calendar or ical for example).
To do this you can create a php webpage creating an ical compatible file dynamically.
1- Generate informations in php:
Create the ical header:
print("BEGIN:VCALENDAR\n");
print("VERSION:2.0\n");
print("PRODID:-//hacksw/handcal//NONSGML v1.0//EN\n");
Then you need to create events, here i add an event on the first of July 2010 at
9 o'clock PM to 11 o'clock PM named "come to my party":
print("BEGIN:VEVENT\n");
print("DTSTART:20100701T210000\n");
print("DTEND:20100701T230000\n");
print("SUMMARY:come to my party\n");
print("END:VEVENT\n");
You can generate those entries from any inputs, like an sql database for example.
Lots of other flags are available in the vcalendar format if you want to create
something more complex.
At the end you must finish the calendar using:
print('END:VCALENDAR\n");
Now you just need to tell people to add a network calendar and to enter
the address of the php page you created.
When you create a website using a database, you really often use one php page
and generate contents using GET arguments (for example to know which element
of the database to display).
This method could be a problem for search engine who like to have page adresses
with name reflecting the content of the page.
Apache and mod_rewrite can be used to optimize this.
We will take an example where you have a php page displaying all elements
from a category (for example in a blog). Usual way to create links would be
to have links looking like that:
http://mywebsite/myblog/index.php?type=mytype
Something easier to understand for visitors and search engines would be to have:
http://mywebsite/myblog/mytype/index.html
To do this you need to add the following into apache configuration:
RewriteEngine on
RewriteBase /myblog/
RewriteRule ^([a-zA-Z]+)/index.html$ index.php?type=$1
First ligne activates the apache rewrite engine.
RewriteBase is setting the "directory" on which the rule will be applied, this
prevent to write "myblog/" at beginning and in destination of each rule when
you have more then one.
RewriteRule is the actual conversion rule using regular expression. in this we
assume the type is only composed of letters in small and/or big case.
My blog is in fact only one php webpage but using this rule you see directories
corresponding to the categories and page names instead of GET arguments.
If you host your own website or anything else on a Linux server,
it will become usefull to filter requests from IP addresses or classes
of IP addresses to prevent attacks on your website or deny of service attemps.
iptables allow you to filter any incoming messages using rules.
To filter all packets coming from ip 1.2.3.4, you can use the command:
iptables -A INPUT -s 1.2.3.4 -j DROP
iptables -A OUTPUT -d 1.2.3.4 -j DROP
To filter all packets coming from ip 1.2.3.0 to 1.2.3.255, you can use the command:
ptables -A INPUT -s 1.2.3.0/24 -j DROP
iptables -A OUTPUT -d 1.2.3.0/24 -j DROP
I store the list of ip addresses in a file "ignorelist" and the list of
classes to ignore in a file "classignore" and use the following script to program iptables:
#!/bin/bash
for myip in $(cat ignorelist | grep -v "#"); do
iptables -D INPUT -s $myip -j DROP > /dev/null 2>&1;
iptables -A INPUT -s $myip -j DROP;
iptables -D OUTPUT -d $myip -j DROP > /dev/null 2>&1;
iptables -A OUTPUT -d $myip -j DROP;
done
for myip in $(cat classignore | grep -v "#"); do
iptables -D INPUT -s ${myip}.0/24 -j DROP > /dev/null 2>&1;
iptables -A INPUT -s ${myip}.0/24 -j DROP;
iptables -D OUTPUT -d ${myip}.0/24 -j DROP > /dev/null 2>&1;
iptables -A OUTPUT -d ${myip}.0/24 -j DROP;
done
Some explanations on this script:
- there is a grep filter so i can add comments on the files
- i first remove the rule using the -D option before adding
it so it is possible to rerun the script when i add an entry
without duplicating the already existing rules.
Now all you have to do is find out from your servers logs
when someone is making "weird" access to your website.
The Mac OS airport is nice and very fast to use to connect to a Wifi network but
it also gives very few information on the networks available (channels, mac adresse etc...).
iStumbler is filling this gap with a nice graphic tool giving detailled information
on every Wifi networks available.
You can download it from this website:
iStumbler.net