新澤西華人網 | 中文

HomeWebsite SetupOrder Online ServiceChineseNJ AdvertisingE-Marketing Service Contact Us

Home
E-Business Service
E-Marketing Service
E-Selling Service
ChineseNJ Ads
Contact
About Us

Start from $100, You can own your personal web page on chinesenj.com.
Detail...

只需$100, 您就可以在新澤西華人網上擁有自己的個人網頁。
詳情...

You are here: Home >> Source Code Example

Source Code Example
To help IT professionals to understand the architecture, technology, logical and design about our website, this page list some source code segments.

index.php
require('MYSQL.php');
require('PAGE.php');

//MYSQL Instance, used in the page session
//All class/object will keep and use this mysql object
$mysql =  new MYSQL;

$page = new PAGE($_GET['page'], $mysql);
$page->initialize();
$page->show();
PAGE.php
class PAGE extends Smarty{
        public $name;
        public $id;
        public $template;
        public $keywords;
        public $description;
        public $navigation_bar;
        public $contents;
        public $parent_id;

        public $parent;
        public $siblings;
        public $children;

        public $mysql;
        public $debug;
        ....
simple_template.tpl
{include file = `header.tpl`}
{include file = `left_menu.tpl`}
{include file = `navigation_bar.tpl`}
{include file = `content.tpl`}
{include file = `footer.tpl`}
signup.php
...
if(isset($_POST[`signup`])){
        $account = new ACCOUNT($mysql);
        $account->init_from_input();
        $error = array_merge($account->check_input_error(), $account->check_passwd_error());

        if(count($error)>0){
                $account_data = get_class_vars(`ACCOUNT`);
                foreach ($account_data as $name => $value) {
                        if($account->$name){
                                $page->assign(`$name`, $account->$name);
                        }
                }
                while($key = key($error)){
                        $page->assign(`$key`, $error[$key]);
                        next($error);
                }
                $page->assign(`error_message`, 
                `There are problems with the information you provided. 
                Please fix the highlighted errors.`);
        }else{
                $account->create();
                $account->welcome_notice();
                $account->signin();
                ...
mysql-myisam-daily-backup.pl
...

open (LOG, `>$logfile`);

$buffer = qq{show databases};
@db = MYSQL->query($buffer);

for(my $i=0; $i<@db; $i++){
        next if($db[$i][0] =~ /information_schema|test/i);
      
        print LOG `Database $i: $db[$i][0]`;

        $buffer = qq{show tables from $db[$i][0]};
        @tables = MYSQL->query($buffer);
        for(my $t=0; $t<@tables; $t++){
                my $updated = 0;               
                ...
                $file = `$datadir/$db[$i][0]/$tables[$t][0].MYD`;
                #ignore if file not exist;
                next if(!(-e $file));

                $stat = stat($file);
                ($mode,$uid,$gid,$mtime) = 
(($stat->mode & 07777) >> 6, $stat->uid, $stat->gid, $stat->mtime);
              
                next if($uid != $mysqluid);
                next if($mode != 6); #rw
                $updated++ if($mtime > $lastbackup);

                if(!$updated){
                        print LOG `Not updated since last update.`;
                        next;
                }

                trace(__FILE__, __LINE__, `$file: $mtime $lastbackup`);

                if(!(-e `$backupdir/$db[$i][0]`)){
                        mkdir(`$backupdir/$db[$i][0]`);
                }


                $buffer = qq{lock table $db[$i][0].$tables[$t][0] read};
                MYSQL->execute($buffer);


                $buffer = qq{flush table $db[$i][0].$tables[$t][0]};
                MYSQL->execute($buffer);

                $buffer = qq{flush logs};
                MYSQL->execute($buffer);


                #backup
                $command = 
`rsync -utrlpgoD $datadir/$db[$i][0]/$tables[$t][0]*  $backupdir/$db[$i][0]/`;

                `$command 2>>$backup_log` ;

                $buffer = qq{unlock table};
                MYSQL->execute($buffer);
                ....

Site Map . Copyright 2010 www.mwebiz.com All Rights Reserved