:::

7-9 /include/onUpdate.php

<?php

function xoops_module_update_tad_ebook(&$module, $old_version) {
    GLOBAL $xoopsDB;

    mk_dir(XOOPS_ROOT_PATH.'/uploads/tad_ebook');
    mk_dir(XOOPS_ROOT_PATH.'/uploads/tad_ebook/file');
    mk_dir(XOOPS_ROOT_PATH.'/uploads/tad_ebook/image');
    mk_dir(XOOPS_ROOT_PATH.'/uploads/tad_ebook/flash');

		if(chk_chk1()) go_update1();

    return true;
}

//檢查某欄位是否存在
function chk_chk1(){
	global $xoopsDB;
	$sql="select count(`ebook_content`) from ".$xoopsDB->prefix("tad_ebook");
	$result=$xoopsDB->query($sql);
	if(empty($result)) return true;
	return fasle;
}

//執行更新
function go_update1(){
	global $xoopsDB;
	$sql="ALTER TABLE ".$xoopsDB->prefix("tad_ebook")." ADD `ebook_content` text NOT NULL COMMENT '內容介紹'";
	$xoopsDB->queryF($sql) or redirect_header(XOOPS_URL,3,  mysql_error());

	return true;
}


//建立目錄
function mk_dir($dir=""){
    //若無目錄名稱秀出警告訊息
    if(empty($dir))return;
    //若目錄不存在的話建立目錄
    if (!is_dir($dir)) {
        umask(000);
        //若建立失敗秀出警告訊息
        mkdir($dir, 0777);
    }
}

//拷貝目錄
function full_copy( $source="", $target=""){
	if ( is_dir( $source ) ){
		@mkdir( $target );
		$d = dir( $source );
		while ( FALSE !== ( $entry = $d->read() ) ){
			if ( $entry == '.' || $entry == '..' ){
				continue;
			}

			$Entry = $source . '/' . $entry;
			if ( is_dir( $Entry ) )	{
				full_copy( $Entry, $target . '/' . $entry );
				continue;
			}
			copy( $Entry, $target . '/' . $entry );
		}
		$d->close();
	}else{
		copy( $source, $target );
	}
}


function rename_win($oldfile,$newfile) {
   if (!rename($oldfile,$newfile)) {
      if (copy ($oldfile,$newfile)) {
         unlink($oldfile);
         return TRUE;
      }
      return FALSE;
   }
   return TRUE;
}


function delete_directory($dirname) {
    if (is_dir($dirname))
        $dir_handle = opendir($dirname);
    if (!$dir_handle)
        return false;
    while($file = readdir($dir_handle)) {
        if ($file != "." && $file != "..") {
            if (!is_dir($dirname."/".$file))
                unlink($dirname."/".$file);
            else
                delete_directory($dirname.'/'.$file);
        }
    }
    closedir($dir_handle);
    rmdir($dirname);
    return true;
}

?>

 


:::

搜尋

QR Code 區塊

https%3A%2F%2Ftad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D1165%26tbsn%3D37

書籍目錄

展開 | 闔起

線上使用者

76人線上 (26人在瀏覽線上書籍)

會員: 0

訪客: 76

更多…