Creation: 24/07/2009 19:35
Last Modification: 24/07/2009 19:35
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.
Creation: 21/07/2009 22:10
Last Modification: 21/07/2009 22:10
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.
Creation: 14/07/2009 18:18
Last Modification: 18/07/2009 17:56
In a website, it is sometimes usefull to set the opacity of an element.
Problem is, Internet explorer and firefox don't handle this the same way.
Here is a solution to have both firefox and Internet explorer setting the opacity of an element.
Firefox has a standard option name opacity.
You can use this one to set and element opacity
(from 0 to 1, 1 meaning full opacity).
Internet explorer does not handle the opacity option.
To set the opacity you will have to use the alpha filter.
This will give alpha(opacity=20) where the value is an
integer between 0 and 100.
You can add the following to an html page:
<style>
a.opac {
filter: "alpha(opacity=100)";
opacity: 1;
}
a.opac:hover {
filter: "alpha(opacity=20)";
opacity: 0.2;
}
</style>
<a href="http://www.netbertrand.com" class=opac>Opacity link</a>
And you will have the following result:
This will create a link and change the opacity when mouse is over.
Creation: 14/07/2009 17:59
Last Modification: 18/07/2009 17:58
VLC is a very powerfull Video on Demand server.
i will show you how to set up a VLC server and give
the right playlist to the local network computers so
they can view your videos.
This procedure could be used to share videos over internet
but you would have to use live streaming to unless you have
a very large capacity on your connection.
1- Create the vlc vod configuration:
Create a vlc.conf file with one entry for each of your videos:
(works with windows but you have to put windows style paths)
new myvid1 vod
setup myvid1 input "/path/to/myideo1.mpg"
setup myvid1 enabled
new myvid2 vod
setup myvid2 input "/path/to/myvideo2.avi"
setup myvid2 enabled
Then vlc must be started with the command:
vlc --rtsp-host 0.0.0.0:5554 --vlm-conf vlc.conf -I dummy
2: Create the vlc.m3u playlist
(here myserver must be replaced by the ip adress of the computer
on which vlc has been started earlier):
#EXTM3U
#EXTINF:0,0 - myvideo1
rtsp://myserver:5554/myvid1
#EXTINF:0,0 - myvideo2
rtsp://myserver:5554/myvid2
Just start this playlist in vlc on any computer of your network and
you will be able to watch the videos, with pause and fast forward
support.
Enjoy !!!
Creation: 14/07/2009 15:53
Last Modification: 18/07/2009 18:00
Here is a sum up of how i created my blog.
It is based on 2 sql tables:
- one for the categories with an integer indentifier and a name
CREATE TABLE blog_cat (
id int(11) NOT NULL auto_increment,
name char(255) default NULL,
PRIMARY KEY (id)
)
- one for the entries with an integer identifier, a title, contents,
date of last mofication and date of creation, identifier of the
category corresponding.
CREATE TABLE blog_entry (
id int(11) NOT NULL auto_increment,
title text,
category int(11) default NULL,
creation datetime default NULL,
lastmod datetime default NULL,
content longtext,
PRIMARY KEY (id)
)
An article is then created and attached to one category. Once an article
exists only the last mofication time will be shown.
This blog is still missing some features:
- add a list of links to an article
- add some files possible to download
- perhaps make it possible to have a better presentation
Each article is only displayed using a "pre" html category so i don't have
to care about new lines and others.
Don't forget to use addslashes/stripslashes when modifying/reading entries
from the database otherwise you will get problems with special characters.