Thursday, February 24, 2011

run cron.php using Windows Scheduled Task.


I used Windows 7.
1. Go to Start - Control Panel -Administration tools- Scheduled Tasks
(For Windows Server 2003, Control Panel - Add Scheduled tasks, for
view old scheduled tasks, double click scheduled tasks)
2, Create basic task, Name: cron.php, Description test
3. Trigger: weekly
4. Action: Start a program
5. Program/script:
c:\php\php-win.exe -f c:\LMS\cron\cron.php
6. Click Finish

Reference:
http://docs.moodle.org/en/Cron#Managing_Cron_on_Windows_systems

How to embed stock market index in your website or blog?


Go to Google Financial Gadget:
http://www.google.com/ig/directory?synd=open&hl=en&gl=en&cat=finance
Find the financial gadgets you like and embed in your website.
Below are two gadgets I embeded:
1) Canada S&P/TSE (^GSPTSE)


2) Forex Market TV

How to add RSS Feeds to your website?


Step 1: Search the topics you are interested with rss feed. For example:
I am interested in:
http://www.theglobeandmail.com/globe-investor/markets/markets-blog/?service=rss
Step 2:Go to http://www.feeddigest.com  and paste the URL in the digest. You can create an account
for free. 
Step 3: Following step 2, you can get JavaScript, or  flash, pdf etc to embed in your website.
Step 4: A sameple of embed RSS feeds in my website as follows:
http://www.jiansenlu.zoka.cc/editable/stock_market_canada__rss.php
(One note: about free account in zoka.cc, if your webpage name contains chat, your webpage will be directed to http://ifastnet.com/notify2.html. The free account does not support chat. This bug took me long time to figure it out. I need to embed video chat. I have to change the name from chat to talk:
http://www.jiansenlu.zoka.cc/editable/talk_to_friend.php)

Monday, February 21, 2011

Create an Online public survey form using Google Docs


Step 1 - Create the Google Form

The first step is to create a Google Form from within Google Docs.  You can use form template or survey template. I created a form template as follows:

Remember this address with gform?key, in future you need this address to edit your form

Step 2 - Share

Go to Google Docs, click the document you just created. Then Action->Share->Share setting
->anyone with this link can view, you can see the address for anyone to view in popup
https://spreadsheets.google.com/ccc?key=0An205fRvYTLAdDktY09KTTE3Q1FoNG9RNTJXakxuWkE&hl=en&authkey=CNjy6Rw
This is a spreadsheet and you may need to let others input in nice web form.

Step 3 -  Find the key for view and user enter data


Go to Google Docs, click the document you just created. View page  source and search formkey and you can find something  like this
"formkey":"dDktY09KTTE3Q1FoNG9RNTJXakxuWkE6MQ"
Your form address for user enter the data will be:
 
https://spreadsheets.google.com/viewform?formkey=dDktY09KTTE3Q1FoNG9RNTJXakxuWkE6MQ
 
When user enter data, you can see all entries  in Step 2 URL (Spreadsheet)
-------------------------------------------------------------------------------- 
Advanced: Submit data to a Google Form with PHP: 
http://www.brighthub.com/hubfolio/matthew-casperson/articles/55171.aspx
Source code:
<?php
    $formURL = "http://spreadsheets.google.com/formResponse?formkey=dDVuRGlwQjgxSWxxUHV3dFN2TW9NdWc6MA&amp;ifq";
  
    function buildMultipleChoice($group, $heading, $options)
    {
        echo '<div>' . $heading . '</div>';
        echo '<ul style="list-style-type: none;">';
      
        foreach ($options as $option)
        {
            echo '<li><input type="radio" name="entry.' . $group . '.group" value="' . $option . '">';
            echo $option;
            echo '</li>';
        }
      
        echo '</ul>';
    }
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>PHP Google Forms</title>
    </head>
    <body>
        <?php
            echo '<form action="' . $formURL . '" method="POST">';
          
            buildMultipleChoice(0, 'What is your favourite colour?', array('Red', 'Green', 'Blue'));   
            buildMultipleChoice(1, 'What is your favourite fruit?', array('Apple', 'Banana', 'Pear'));
          
            echo '<input type="submit" name="submit" value="Submit">';
            echo '</form>';  
        ?>
    </body>
</html>

Saturday, February 19, 2011

create a JavaScript tutorial Website


I created a JavaScript tutorial Website
https://sites.google.com/site/jiansenjavascripttutorial/
Using JavaScript to make dynamic website is very interesting.

Friday, February 18, 2011

Create a PHP online tutorial website


I created a PHP online tutorial website:
https://sites.google.com/site/jiansenphptutorial/
In this tutorial, I summarized   my experience in PHP programming and  provided practical examples.
In future, I will develop JavaScript, CSS, Actionscript and other computer programming tutorial.

Wednesday, February 16, 2011

Difference between id and class in CSS div


Ids are to be used only once in your html layout. Ids are used for the main elements of the page, such as header, main content, sidebar, footer, etc. Ids have priority over classes. Ids start with # in css

Classes are used for elements that will appear several times on your page. Classes start with . in css

example:
<!--CSS part:-->
<style type="text/css">
#blueidstyle {color:blue}
.redclassstyle {color:red}
</style>
<!--HTML part:-->
<body>
<p id="blueidstyle">Blue for id</p>
<p class="redclassstyle">Red for class</p>
</body>

result:



Blue for id
Red for class

Thursday, February 10, 2011

Actionscript and Flash Media Server (FMS) tutorial from Adobe TV


1)An introduction to basic interactivity and ActionScript 3. Learn how to create a simple UI slider component, invisible buttons, and add basic interactivity in Flash Professional CS3.
2) Lisa Larson-Kelley reveals tips and tricks on working with video in Flash. Get up to speed with demos, how-tos, and interviews in this fast-paced, info-packed series!
Click links to display in the same window.
Reference
http://tv.adobe.com/channels/
Flash media server developer center


1) ActionSCript -episode 5 2) Hooking up with FMS 3) Video Encoding Basic




My son's flash work


Saturday, February 5, 2011

Come and Post in My new Forum


I just setup a new forum:
http://jiansen.yuku.com/
Come and Post. You need to register first by clicking the 6th icon at the top (register). I am quite satisfied the theme.

"Fast Edit" - edit your content Online


You can edit your webpage online using Fast Edit. Fast Edit can also manage your html file online. Fast Edit is free software based on PHP. Unlike other editable software, Fast Edit does not use MySQL.

Please go to the official Fast Edit website at http://fast-edit.co.uk/ for a full breakdown of features, live demo and downloads.

My Webpage using Fast edit (ou need password to login for editing):
http://www.jiansenlu.zoka.cc/editable/index.php

Friday, February 4, 2011

SSL Checker


1 This SSL Checker will help you diagnose problems with your SSL certificate installation.
You can go to
http://www.sslshopper.com/ssl-checker.html
input your server name, you can get information when your SSL will expire
 and which company (such as StartCom) issued the certificate.
2) Another method:

wget http://prefetch.net/code/ssl-cert-check
./ssl-cert-check -s gmail.com -p 443
(replace gmail.com to your sever)

3) Method 3: Click at the beginning of web address in the navigation bar
to get SSL information.
 
Reference: 
1. What is SSL and what are Certificates? 
2.https://www.startssl.com/  

Thursday, February 3, 2011

Install Apache2 SSL on Windows for https


Test in my Windows 7  for localhost, you may need to change localhost to real servers.
 The steps are as follows:
1) Download Apache OpenSSL binary for indows using the links below:
 httpd-2.2.17-win32-x86-openssl-0.9.8o.msi
2) Download Win32OpenSLL from
http://www.slproweb.com/products/Win32OpenSSL.html
I download two binaries
3) Install Openssl in C:\OpenSSL-Win32
4) Download openssl.cnf from
http://www.thompsonbd.com/files/apache/openssl.cnf
and save in C:\OpenSSL-Win32\bin, in command prompt
set  OPENSSL_CONF= C:\OpenSSL-Win32\bin\openssl.cnf
5)  cd  C:\OpenSSL-Win32\bin
openssl genrsa -des3 1024 > servername.key
openssl req –new –key server.key –out server.csr
(type password, such as wife*7*9*)
5. openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 365
This creates a self-signed certificate that you can use until you get a "real" one from a certificate authority. (Which is optional; if you know your users, you can tell them to install the certificate into their browsers.) Note that this certificate expires after one year, you can increase -days 365 if you don't want this.6.  Save those key files in: C:/Servers/ssl/certs/
6.  Open the httpd.conf file and add (un-comment)
 LoadModule ssl_module modules/mod_ssl.so
 ( I use the log, I install another module log_rotate_module
LoadModule log_rotate_module modules/mod_log_rotate.so)

Add:
<VirtualHost *:443>
     ServerName egps.localhost:443
     DocumentRoot C:/Users/jiansen/Desktop/CAS/jiansen_dir/www/
     <Directory />
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
       
       <IfModule rewrite_module>
          #RewriteEngine On
          #RewriteRule !maintenance_msg\.php$ /maintenance_msg.php [R,L]
         
          RewriteEngine On
          RewriteCond %{HTTP_REFERER} !^$
          RewriteCond %{HTTP_REFERER} !^https://192.168.1.52/.*$ [NC]
          RewriteRule .*\.(jpe?g|png|gif|bmp|swf|flv) - [NC,F,L]
       </IfModule>   

     </Directory>

    SSLEngine on

     SSLCertificateFile "C:/Servers/ssl/certs/server.crt"
     SSLCertificateKeyFile "C:/Servers/ssl/keys/server.key"
     SSLCertificateChainFile "C:/Servers/ssl/certs/server.crt"

     BrowserMatch ".*MSIE.*" \
     nokeepalive ssl-unclean-shutdown
</VirtualHost>

7. To redirect http to https, add following in httpd.conf
<VirtualHost *:80>

    ServerName egps.localhost:80
   # ServerAlias http://www.mywebsite.com:80
    #ServerAlias 122.123.124.1:80
    Redirect permanent / https://localhost
</VirtualHost>

 

Tuesday, February 1, 2011

Add facebook like and unlike button in each post in your blog


Result: see my blog. The step is as follow:
1) Log into your blogger account, then go to Layout and click Edit Html.
2) Check Expand Widget Templates box.
3) Find the Code
<div class='post-header-line-1'/>
4) Copy the following code just right under <div class='post-header-line-1'/>


<iframe allowTransparency='true' expr:src='&quot;http://www.facebook.com/plugins/like.php?href=&quot; + data:post.url + &quot;&amp;layout=standard&amp;show_faces=false&amp;width=100&amp;action=like&amp;font=arial&amp;colorscheme=light&quot;' frameborder='0' scrolling='no' style='border:none; overflow:hidden; width:450px; height:40px;'/>
5) Click save template
6) Done!