Công cụ thành viên

Công cụ trang web


programming4:moduleupdate

Khác biệt

Đây là những khác biệt giữa hai phiên bản của trang.

Liên kết đến bản xem so sánh này

Phiên bản sau
Phiên bản trước
programming4:moduleupdate [2016/06/16 15:35] – được tạo ra hoaquynhtim99programming4:moduleupdate [2017/11/07 10:56] (hiện tại) – [Gói nâng cấp mẫu] hoaquynhtim99
Dòng 1: Dòng 1:
-Kể từ phiên bản NukeViet 3.4.01, chức năng nâng cấp dành cho hệ thống và cho module hoàn toàn tự động được đưa vào sử dụng. Để làm việc với chức năng mới này các nhà phát triển module cần chú ý.+Kể từ phiên bản NukeViet 3.4.01, chức năng nâng cấp dành cho hệ thống và cho module hoàn toàn tự động được đưa vào sử dụng. Để làm việc với chức năng mới này các nhà phát triển module cần chú ý các vấn đề sau:
 ====== Cấu trúc của một gói nâng cấp module ====== ====== Cấu trúc của một gói nâng cấp module ======
 Gói nâng cấp module và gói nâng cấp nhân NukeViet là hoàn toàn tương tự nhau, được đặt trong thư mục install, gồm có: Gói nâng cấp module và gói nâng cấp nhân NukeViet là hoàn toàn tương tự nhau, được đặt trong thư mục install, gồm có:
Dòng 12: Dòng 12:
   * install/update_docs_fr.html   * install/update_docs_fr.html
   * install/update/index.php   * install/update/index.php
-  * install/update/CJzip.php 
   * install/update/modules/news/theme.php   * install/update/modules/news/theme.php
  
Dòng 23: Dòng 22:
  
 /** /**
- * @Project NUKEVIET-MUSIC + * @Project VIDEO CLIPS AJAX 4.x 
- * @Author Phan Tan Dung (phantandung92@gmail.com) + * @Author PHAN TAN DUNG (phantandung92@gmail.com) 
- * @Copyright (C) 2011 Freeware + * @Copyright (C) 2014 PHAN TAN DUNG. All rights reserved 
- * @Createdate 29-03-2012 03:29+ * @License GNU/GPL version 2 or any later version 
 + * @Createdate Dec 01, 2014, 04:33:14 AM
  */  */
  
-if( ! defined( 'NV_IS_UPDATE' ) ) die( 'Stop!!!' ); +if (!defined('NV_IS_UPDATE')) 
- +    die('Stop!!!'); 
 $nv_update_config = array(); $nv_update_config = array();
  
-$nv_update_config['type'] = 1; // Kieu nang cap 1: Update; 2: Upgrade +// Kieu nang cap 1: Update; 2: Upgrade 
-$nv_update_config['packageID'] = 'NVUDMUSIC3401'; // ID goi cap nhat +$nv_update_config['type'] = 1; 
-$nv_update_config['formodule'] = "music"; // Cap nhat cho module nao, de trong neu la cap nhat NukeViet, ten thu muc module neu la cap nhat module+ 
 +// ID goi cap nhat 
 +$nv_update_config['packageID'] = 'NVUDVIDEOCLIP4029'; 
 + 
 +// Cap nhat cho module nao, de trong neu la cap nhat NukeViet, ten thu muc module neu la cap nhat module 
 +$nv_update_config['formodule'] = 'video-clip';
  
 // Thong tin phien ban, tac gia, ho tro // Thong tin phien ban, tac gia, ho tro
-$nv_update_config['release_date'] = 1333929600+$nv_update_config['release_date'] = 1463590800
-$nv_update_config['author'] = "Phan Tan Dung (phantandung92@gmail.com)"+$nv_update_config['author'] = 'PHAN TAN DUNG (phantandung92@gmail.com)'
-$nv_update_config['support_website'] = "http://nukeviet.vn/phpbb/viewforum.php?f=118"+$nv_update_config['support_website'] = 'https://github.com/hoaquynhtim99/video-clip-update/tree/4.0.29'
-$nv_update_config['to_version'] = "3.5.01"+$nv_update_config['to_version'] = '4.0.29'
-$nv_update_config['allow_old_version'] = array( "3.0.01""3.1.00""3.2.00""3.3.00""3.3.01""3.4.01" ); +$nv_update_config['allow_old_version'] = array( 
-$nv_update_config['update_auto_type'] = 1; // 0:Nang cap bang tay, 1:Nang cap tu dong, 2:Nang cap nua tu dong+    '4.0.01', 
 +    '4.0.22', 
 +    '4.0.23', 
 +    '4.0.24', 
 +    '4.0.27', 
 +    '4.0.28' 
 +); 
 + 
 +// 0:Nang cap bang tay, 1:Nang cap tu dong, 2:Nang cap nua tu dong 
 +$nv_update_config['update_auto_type'] = 1;
  
 $nv_update_config['lang'] = array(); $nv_update_config['lang'] = array();
 $nv_update_config['lang']['vi'] = array(); $nv_update_config['lang']['vi'] = array();
-$nv_update_config['lang']['en'] = array(); 
  
 // Tiếng Việt // Tiếng Việt
-$nv_update_config['lang']['vi']['nv_up_author'] = 'Cập nhật nhạsĩ cho bảng bài hát, video'; +$nv_update_config['lang']['vi']['nv_up_p1'] = 'Thay đổi cấu trúc bảng dữ liệu'; 
- +$nv_update_config['lang']['vi']['nv_up_finish'] = 'Đánh dấu phiên bản mới';
-$nv_update_config['lang']['vi']['nv_up_version'] = 'Cập nhật phiên bản'; +
- +
-// English +
-$nv_update_config['lang']['en']['nv_up_author'] = 'Update author for song, clip table'; +
- +
-$nv_update_config['lang']['en']['nv_up_version'] = 'Updated version'; +
- +
-// Require level: 0: Khong bat buoc hoan thanh; 1: Canh bao khi that bai; 2: Bat buoc hoan thanh neu khong se dung nang cap. +
-// r: Revision neu la nang cap site, phien ban neu la nang cap module+
  
 $nv_update_config['tasklist'] = array(); $nv_update_config['tasklist'] = array();
-$nv_update_config['tasklist'][] = array( 'r' => '3.4.01', 'rq' => 2, 'l' => 'nv_up_author', 'f' => 'nv_up_author' ); +$nv_update_config['tasklist'][] = array( 
- +    'r' => '4.0.28', 
-$nv_update_config['tasklist'][] = array( 'r' => '3.5.01', 'rq' => 2, 'l' => 'nv_up_version', 'f' => 'nv_up_version' );+    'rq' => 1, 
 +    'l' => 'nv_up_p1', 
 +    'f' => 'nv_up_p1' 
 +); 
 +$nv_update_config['tasklist'][] = array( 
 +    'r' => '4.0.29', 
 +    'rq' => 1, 
 +    'l' => 'nv_up_finish', 
 +    'f' => 'nv_up_finish' 
 +);
  
 // Danh sach cac function // Danh sach cac function
Dòng 71: Dòng 85:
 Chuan hoa tra ve: Chuan hoa tra ve:
 array( array(
- 'status' => +'status' => 
- 'complete' =>  +'complete' =>  
- 'next' => +'next' => 
- 'link' => +'link' => 
- 'lang' => +'lang' => 
- 'message' =>+'message' =>
 ); );
- 
 status: Trang thai tien trinh dang chay status: Trang thai tien trinh dang chay
 - 0: That bai - 0: That bai
 - 1: Thanh cong - 1: Thanh cong
- 
 complete: Trang thai hoan thanh tat ca tien trinh complete: Trang thai hoan thanh tat ca tien trinh
 - 0: Chua hoan thanh tien trinh nay - 0: Chua hoan thanh tien trinh nay
 - 1: Da hoan thanh tien trinh nay - 1: Da hoan thanh tien trinh nay
- 
 next: next:
 - 0: Tiep tuc ham nay voi "link" - 0: Tiep tuc ham nay voi "link"
 - 1: Chuyen sang ham tiep theo - 1: Chuyen sang ham tiep theo
- 
 link: link:
 - NO - NO
 - Url to next loading - Url to next loading
- 
 lang: lang:
 - ALL: Tat ca ngon ngu - ALL: Tat ca ngon ngu
 - NO: Khong co ngon ngu loi - NO: Khong co ngon ngu loi
 - LangKey: Ngon ngu bi loi vi,en,fr ... - LangKey: Ngon ngu bi loi vi,en,fr ...
- 
 message: message:
 - Any message - Any message
- 
 Duoc ho tro boi bien $nv_update_baseurl de load lai nhieu lan mot function Duoc ho tro boi bien $nv_update_baseurl de load lai nhieu lan mot function
 Kieu cap nhat module duoc ho tro boi bien $old_module_version Kieu cap nhat module duoc ho tro boi bien $old_module_version
 */ */
  
-$array_lang_music_update = array();+$array_modlang_update = array(); 
 // Lay danh sach ngon ngu // Lay danh sach ngon ngu
-$result = $db->sql_query( "SELECT `langFROM `" . $db_config['prefix'] . "_setup_languageWHERE `setup`=1" ); +$result = $db->query("SELECT lang FROM " . $db_config['prefix'] . "_setup_language WHERE setup=1"); 
-while( list( $_tmp ) = $db->sql_fetchrow$result ) ) +while (list($_tmp) = $result->fetch(PDO::FETCH_NUM)) { 
-+    $array_modlang_update[$_tmp] = array("lang" => $_tmp, "mod" => array()); 
- $array_lang_music_update[$_tmp] = array( "lang" => $_tmp, "mod" => array() ); + 
-  +    // Get all module 
- // Get all module of music +    $result1 = $db->query("SELECT title, module_data FROM " . $db_config['prefix'] . "_" . $_tmp . "_modules WHERE module_file=" . $db->quote($nv_update_config['formodule'])); 
- $result1 = $db->sql_query( "SELECT `title``module_dataFROM `" . $db_config['prefix'] . "_" . $_tmp . "_modulesWHERE `module_file`='music'); +    while (list($_modt, $_modd) = $result1->fetch(PDO::FETCH_NUM)) { 
- while( list( $_modt, $_modd ) = $db->sql_fetchrow$result1 ) ) +        $array_modlang_update[$_tmp]['mod'][] = array("module_title" => $_modt, "module_data" => $_modd); 
- +    }
- $array_lang_music_update[$_tmp]['mod'][] = array( "module_title" => $_modt, "module_data" => $_modd ); +
- }+
 } }
  
-function nv_up_author()+/** 
 + * nv_up_p1() 
 + * 
 + * @return 
 + * 
 + */ 
 +function nv_up_p1()
 { {
- global $nv_update_baseurl, $db, $db_config, $old_module_version, $array_lang_music_update; +    global $nv_update_baseurl, $db, $db_config, $nv_Cache, $array_modlang_update;
- $return = array( 'status' => 1, 'complete' => 1, 'next' => 1, 'link' => 'NO', 'lang' => 'NO', 'message' => '', ); +
-  +
- $array_author = array(); +
-  +
- // Lấy tất cả các nhạc sĩ +
- foreach( $array_lang_music_update as $lang => $array_mod ) +
-+
- foreach( $array_mod['mod'] as $module_info ) +
-+
- $table = $db_config['prefix'] . "_" . $lang . "_" . $module_info['module_data'] . "_author"; +
- $sql = "SELECT * FROM `" . $table . "`"; +
- $check = $db->sql_query($sql); +
-  +
- while( $row = $db->sql_fetchrow( $check ) ) +
-+
- $array_author[$lang][$module_info['module_data']][$row['ten']] = ( int ) $row['id']; +
-+
-+
-+
- $db->sql_freeresult();+
  
- // Cập nhật nhạc sĩ cho bảng bài hátvideo +    $return = array( 
- foreach( $array_lang_music_update as $lang => $array_mod ) +        'status' => 1
- { +        'complete' => 1, 
- foreach( $array_mod['mod'] as $module_info ) +        'next=> 1, 
- +        'link' ='NO', 
- $table $db_config['prefix'] . "_" . $lang . "_" . $module_info['module_data'] . "";+        'lang' => 'NO', 
 +        'message' => '' 
 +    );
  
- $array_author[$lang][$module_info['module_data']]['na'= 0; +    foreach ($array_modlang_update as $lang => $array_mod) { 
-  +        foreach ($array_mod['mod'as $module_info) { 
- foreach( $array_author[$lang][$module_info['module_data']] as $alias => $id +            $table_prefix = $db_config['prefix'. "_"$lang . "_"$module_info['module_data']
- +             
- $db->sql_query( "UPDATE `" . $table . "SET `nhacsi`='" . $id . "' WHERE `nhacsi`='" . $alias . "'" ); +            // Cập nhật default chasert của các bảng 
- $db->sql_query( "UPDATE `" . $table . "_video` SET `nhacsi`='" . $id . "' WHERE `nhacsi`='" . $alias . "'" ); +            try { 
- +                $db->query("ALTER TABLE " . $table_prefix . "_clip DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); 
-+            } catch (PDOException $e) 
- +                trigger_error($e->getMessage()); 
- $db->sql_freeresult(); +            } 
-  +            try { 
- return $return;+                $db->query("ALTER TABLE " . $table_prefix . "_hit DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); 
 +            } catch (PDOException $e) { 
 +                trigger_error($e->getMessage()); 
 +            } 
 +            try { 
 +                $db->query("ALTER TABLE " . $table_prefix . "_topic DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); 
 +            } catch (PDOException $e) { 
 +                trigger_error($e->getMessage()); 
 +            } 
 +            try { 
 +                $db->query("ALTER TABLE " . $table_prefix . "_comm DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); 
 +            } catch (PDOException $e) { 
 +                trigger_error($e->getMessage()); 
 +            } 
 +             
 +            // Sửa lại các bảng 
 +            try { 
 +                $db->query("ALTER TABLE " . $table_prefix . "_clip CHANGE title title VARCHAR(250) NOT NULL DEFAULT ''"); 
 +                $db->query("ALTER TABLE " . $table_prefix . "_clip CHANGE alias alias VARCHAR(250) NOT NULL DEFAULT ''"); 
 +            } catch (PDOException $e) { 
 +                trigger_error($e->getMessage()); 
 +            } 
 +            try { 
 +                $db->query("ALTER TABLE " . $table_prefix . "_topic CHANGE title title VARCHAR(250) NOT NULL DEFAULT ''"); 
 +                $db->query("ALTER TABLE " . $table_prefix . "_topic CHANGE alias alias VARCHAR(250) NOT NULL DEFAULT ''"); 
 +            } catch (PDOException $e) { 
 +                trigger_error($e->getMessage()); 
 +            } 
 +             
 +            // Cập nhật chasert từng cột của các bảng 
 +            $array_table array('_clip', '_hit', '_topic', '_comm'); 
 +             
 +            foreach ($array_table as $table) { 
 +                $sql = "SHOW FULL COLUMNS FROM " . $table_prefix $table; 
 +                $result = $db->query($sql); 
 +                 
 +                while($row = $result->fetch()) { 
 +                    if($row['collation'] == 'utf8_general_ci') { 
 +                        try { 
 +                            $db->query("ALTER TABLE " . $table_prefix . $table . " CHANGE  
 +                 " . $row['field'] . " " . $row['field'] . " " . $row['type'] . " CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci " .  
 +                 ($row['null'] == 'NO' ? "NOT NULL" : ""(strpos($row['type'], 'varchar') === false ? '' : " DEFAULT '" . $row['default'. "'")); 
 +                        catch (PDOException $e) { 
 +                            trigger_error($e->getMessage()); 
 +                        } 
 +                    } 
 +                } 
 +            } 
 +        } 
 +    } 
 + 
 +    return $return;
 } }
  
-function nv_up_version()+/** 
 + * nv_up_finish() 
 + * 
 + * @return 
 + * 
 + */ 
 +function nv_up_finish()
 { {
- global $nv_update_baseurl, $db, $db_config, $old_module_version, $array_lang_music_update; +    global $nv_update_baseurl, $db, $db_config, $nv_Cache, $nv_update_config;
- $return = array( 'status' => 1, 'complete' => 1, 'next' => 1, 'link' => 'NO', 'lang' => 'NO', 'message' => '', );+
  
- // Cap nhat lai revision va version cua module +    $return array( 
- foreach( $array_lang_music_update as $lang => $array_mod ) +        'status=> 1, 
- +        'complete=> 1, 
- foreach( $array_mod['mod'] as $module_info ) +        'next=1, 
- +        'link' ='NO', 
- $table = $db_config['prefix'] . "_" . $lang . "_" . $module_info['module_data'] . "_setting"; +        'lang' ='NO', 
- $db->sql_query( "UPDATE `" . $table . "` SET `value`=331 WHERE `key`='revision'" );  +        'message' ='' 
- $db->sql_query( "UPDATE `" . $table . "` SET `char`='3.5.01WHERE `key`='version'" );  +    );
- +
-+
-  +
- $mod_version = "3.5.01 1333929600"; +
- $db->sql_query( "UPDATE `" . $db_config['prefix'] . "_setup_modules` SET `mod_version`='" . $mod_version . "', `author`='PHAN TAN DUNG (phantandung92@gmail.com)WHERE `module_file`='music'" ); +
-  +
- nv_delete_all_cache(); +
-  +
- return $return; +
-}+
  
-?>+    try { 
 +        $num = $db->query("SELECT COUNT(*) FROM " . $db_config['prefix'] . "_setup_extensions WHERE basename='" . $nv_update_config['formodule'] . "' AND type='module'")->fetchColumn(); 
 +        $version = "4.0.29 1463590800"; 
 +         
 +        if (!$num) { 
 +            $db->query("INSERT INTO " . $db_config['prefix'] . "_setup_extensions ( 
 +                id, type, title, is_sys, is_virtual, basename, table_prefix, version, addtime, author, note 
 +            ) VALUES ( 
 +                79, 'module', 'video-clip', 0, 1, 'video-clip', 'video_clip', '4.0.29 1463590800', " . NV_CURRENTTIME . ", 'PHAN TAN DUNG (phantandung92@gmail.com)',  
 +                'Module playback of video-clips' 
 +            )"); 
 +        } else { 
 +            $db->query("UPDATE " . $db_config['prefix'] . "_setup_extensions SET  
 +                id=79,  
 +                version='" . $version . "',  
 +                author='PHAN TAN DUNG (phantandung92@gmail.com)'  
 +            WHERE basename='" . $nv_update_config['formodule'] . "' AND type='module'"); 
 +        } 
 +    } catch (PDOException $e) { 
 +        trigger_error($e->getMessage()); 
 +    } 
 + 
 +    $nv_Cache->delAll(); 
 +    return $return; 
 +}
 </file> </file>
 +
 +**Kể từ NukeViet 4.2.01 về sau đoạn:**
 +
 +<code php>
 +// Lay danh sach ngon ngu
 +$result = $db->query("SELECT lang FROM " . $db_config['prefix'] . "_setup_language WHERE setup=1");
 +while (list($_tmp) = $result->fetch(PDO::FETCH_NUM)) {
 +</code>
 +
 +Chỉ cần thay bằng 
 +
 +<code php>
 +foreach ($global_config['allow_sitelangs'] as $_tmp) {
 +</code>
 +
 +> Chú ý: Nếu trong function cần kiểm tra gọi $global_config
 ===== Cấu hình gói nâng cấp ===== ===== Cấu hình gói nâng cấp =====
 Trong ví dụ trên thì việc cấu hình gói nâng cấp được khai báo trong đoạn Trong ví dụ trên thì việc cấu hình gói nâng cấp được khai báo trong đoạn
 <code php> <code php>
-$nv_update_config['type'] = 1; // Kieu nang cap 1: Update; 2: Upgrade +// Kieu nang cap 1: Update; 2: Upgrade 
-$nv_update_config['packageID'] = 'NVUDMUSIC3401'; // ID goi cap nhat +$nv_update_config['type'] = 1; 
-$nv_update_config['formodule'] = "music"; // Cap nhat cho module nao, de trong neu la cap nhat NukeViet, ten thu muc module neu la cap nhat module+ 
 +// ID goi cap nhat 
 +$nv_update_config['packageID'] = 'NVUDVIDEOCLIP4029'; 
 + 
 +// Cap nhat cho module nao, de trong neu la cap nhat NukeViet, ten thu muc module neu la cap nhat module 
 +$nv_update_config['formodule'] = 'video-clip';
  
 // Thong tin phien ban, tac gia, ho tro // Thong tin phien ban, tac gia, ho tro
-$nv_update_config['release_date'] = 1333929600+$nv_update_config['release_date'] = 1463590800
-$nv_update_config['author'] = "Phan Tan Dung (phantandung92@gmail.com)"+$nv_update_config['author'] = 'PHAN TAN DUNG (phantandung92@gmail.com)'
-$nv_update_config['support_website'] = "http://nukeviet.vn/phpbb/viewforum.php?f=118"+$nv_update_config['support_website'] = 'https://github.com/hoaquynhtim99/video-clip-update/tree/4.0.29'
-$nv_update_config['to_version'] = "3.5.01"+$nv_update_config['to_version'] = '4.0.29'
-$nv_update_config['allow_old_version'] = array( "3.0.01""3.1.00""3.2.00""3.3.00""3.3.01""3.4.01" ); +$nv_update_config['allow_old_version'] = array( 
-$nv_update_config['update_auto_type'] = 1; // 0:Nang cap bang tay, 1:Nang cap tu dong, 2:Nang cap nua tu dong+    '4.0.01', 
 +    '4.0.22', 
 +    '4.0.23', 
 +    '4.0.24', 
 +    '4.0.27', 
 +    '4.0.28' 
 +);
  
-$nv_update_config['lang'] = array(); +// 0:Nang cap bang tay, 1:Nang cap tu dong, 2:Nang cap nua tu dong 
-$nv_update_config['lang']['vi'] = array(); +$nv_update_config['update_auto_type'] = 1;
-$nv_update_config['lang']['en'] = array();+
 </code> </code>
 Trong đó Trong đó
-<code php>$nv_update_config['type'] = 1;</code>+<code php>$nv_update_config['update_auto_type'] = 1;</code>
 Là kiểu nâng cấp, 1 là Update 2 là Upgrade, việc khai báo thông số này không có mục đích gì ngoài việc thay đổi ngôn ngữ thông báo. Là kiểu nâng cấp, 1 là Update 2 là Upgrade, việc khai báo thông số này không có mục đích gì ngoài việc thay đổi ngôn ngữ thông báo.
 <code php>$nv_update_config['packageID']</code> <code php>$nv_update_config['packageID']</code>
 Là ID gói nâng cấp, được viết hoa tất cả, được đặt theo chuẩn NVU[A-Z][0-9]{4} ví dụ NVUMUSIC3400, NVU3501, .... Là ID gói nâng cấp, được viết hoa tất cả, được đặt theo chuẩn NVU[A-Z][0-9]{4} ví dụ NVUMUSIC3400, NVU3501, ....
-<code php>$nv_update_config['formodule'] = "music";</code>+<code php>$nv_update_config['formodule'] = 'video-clip';</code>
 Giá trị bằng tên module (không ảo) sẽ nâng cấp (hay tên thư mục chứa module đó). Giá trị bằng tên module (không ảo) sẽ nâng cấp (hay tên thư mục chứa module đó).
 <code php>$nv_update_config['release_date'] = 1333929600;</code> <code php>$nv_update_config['release_date'] = 1333929600;</code>
Dòng 253: Dòng 343:
 Đầu tiên ta khai báo danh sách các hàm sẽ thự hiện: Đầu tiên ta khai báo danh sách các hàm sẽ thự hiện:
 <code php>$nv_update_config['tasklist'] = array(); <code php>$nv_update_config['tasklist'] = array();
-$nv_update_config['tasklist'][] = array( 'r' => '3.4.01', 'rq' => 2, 'l' => 'nv_up_author', 'f' => 'nv_up_author' ); +$nv_update_config['tasklist'][] = array( 
-$nv_update_config['tasklist'][] = array( 'r' => '3.5.01', 'rq' => 2, 'l' => 'nv_up_version', 'f' => 'nv_up_version' );+    'r' => '4.0.28', 
 +    'rq' => 1, 
 +    'l' => 'nv_up_p1', 
 +    'f' => 'nv_up_p1' 
 +); 
 +$nv_update_config['tasklist'][] = array( 
 +    'r' => '4.0.29', 
 +    'rq' => 1, 
 +    'l' => 'nv_up_finish', 
 +    'f' => 'nv_up_finish' 
 +);
 </code> </code>
 Trong đó: Trong đó:
Dòng 267: Dòng 367:
 Tiếp theo ta viết các hàm thực hiện công việc đó. Ví dụ Tiếp theo ta viết các hàm thực hiện công việc đó. Ví dụ
 <code php> <code php>
-$array_lang_music_update = array();+$array_modlang_update = array(); 
 // Lay danh sach ngon ngu // Lay danh sach ngon ngu
-$result = $db->sql_query( "SELECT `langFROM `" . $db_config['prefix'] . "_setup_languageWHERE `setup`=1" ); +$result = $db->query("SELECT lang FROM " . $db_config['prefix'] . "_setup_language WHERE setup=1"); 
-while( list( $_tmp ) = $db->sql_fetchrow$result ) ) +while (list($_tmp) = $result->fetch(PDO::FETCH_NUM)) { 
-+    $array_modlang_update[$_tmp] = array("lang" => $_tmp, "mod" => array()); 
- $array_lang_music_update[$_tmp] = array( "lang" => $_tmp, "mod" => array() ); + 
-  +    // Get all module 
- // Get all module of music +    $result1 = $db->query("SELECT title, module_data FROM " . $db_config['prefix'] . "_" . $_tmp . "_modules WHERE module_file=" . $db->quote($nv_update_config['formodule'])); 
- $result1 = $db->sql_query( "SELECT `title``module_dataFROM `" . $db_config['prefix'] . "_" . $_tmp . "_modulesWHERE `module_file`='music'); +    while (list($_modt, $_modd) = $result1->fetch(PDO::FETCH_NUM)) { 
- while( list( $_modt, $_modd ) = $db->sql_fetchrow$result1 ) ) +        $array_modlang_update[$_tmp]['mod'][] = array("module_title" => $_modt, "module_data" => $_modd); 
- +    }
- $array_lang_music_update[$_tmp]['mod'][] = array( "module_title" => $_modt, "module_data" => $_modd ); +
- }+
 } }
  
-function nv_up_author()+/** 
 + * nv_up_p1() 
 + * 
 + * @return 
 + * 
 + */ 
 +function nv_up_p1()
 { {
- global $nv_update_baseurl, $db, $db_config, $old_module_version, $array_lang_music_update+    global $nv_update_baseurl, $db, $db_config, $nv_Cache, $array_modlang_update
- $return = array( 'status' => 1, 'complete' => 1, 'next' => 1, 'link' => 'NO', 'lang' => 'NO', 'message' => '', ); + 
-  +    $return = array( 
- $array_author = array(); +        'status' => 1, 
-  +        'complete' => 1, 
- // Lấy tất cả các nhạc sĩ +        'next' => 1, 
- foreach( $array_lang_music_update as $lang => $array_mod ) +        'link' => 'NO', 
-+        'lang' => 'NO', 
- foreach( $array_mod['mod'] as $module_info ) +        'message' => '' 
-+    );
- $table = $db_config['prefix'] . "_" . $lang . "_" . $module_info['module_data'] . "_author"; +
- $sql = "SELECT * FROM `" . $table . "`"; +
- $check = $db->sql_query($sql); +
-  +
- while( $row = $db->sql_fetchrow( $check ) ) +
-+
- $array_author[$lang][$module_info['module_data']][$row['ten']] = ( int ) $row['id']; +
-+
-+
-+
- $db->sql_freeresult();+
  
- // Cập nhật nhạc sĩ cho bảng bài hátvideo +    foreach ($array_modlang_update as $lang => $array_mod) { 
- foreach( $array_lang_music_update as $lang => $array_mod +        foreach ($array_mod['mod'] as $module_info) { 
-+            $table_prefix = $db_config['prefix'] . "_" . $lang . "_" . $module_info['module_data']; 
- foreach( $array_mod['mod'as $module_info +             
- +            // Cập nhật default chasert của các bảng 
- $table $db_config['prefix'] . "_" . $lang . "_" . $module_info['module_data'] . "";+            try { 
 +                $db->query("ALTER TABLE " . $table_prefix . "_clip DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); 
 +            } catch (PDOException $e) { 
 +                trigger_error($e->getMessage()); 
 +            } 
 +            try { 
 +                $db->query("ALTER TABLE " . $table_prefix . "_hit DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); 
 +            } catch (PDOException $e) { 
 +                trigger_error($e->getMessage()); 
 +            } 
 +            try { 
 +                $db->query("ALTER TABLE " . $table_prefix . "_topic DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); 
 +            } catch (PDOException $e) { 
 +                trigger_error($e->getMessage()); 
 +            } 
 +            try { 
 +                $db->query("ALTER TABLE " . $table_prefix . "_comm DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); 
 +            } catch (PDOException $e) { 
 +                trigger_error($e->getMessage()); 
 +            } 
 +             
 +            // Sửa li các bảng 
 +            try { 
 +                $db->query("ALTER TABLE " . $table_prefix . "_clip CHANGE title title VARCHAR(250) NOT NULL DEFAULT ''"); 
 +                $db->query("ALTER TABLE " . $table_prefix . "_clip CHANGE alias alias VARCHAR(250) NOT NULL DEFAULT ''"); 
 +            } catch (PDOException $e) { 
 +                trigger_error($e->getMessage()); 
 +            } 
 +            try { 
 +                $db->query("ALTER TABLE " . $table_prefix . "_topic CHANGE title title VARCHAR(250) NOT NULL DEFAULT ''"); 
 +                $db->query("ALTER TABLE " . $table_prefix . "_topic CHANGE alias alias VARCHAR(250) NOT NULL DEFAULT ''"); 
 +            } catch (PDOException $e) { 
 +                trigger_error($e->getMessage()); 
 +            } 
 +             
 +            // Cập nhật chasert từng cột của các bảng 
 +            $array_table = array('_clip''_hit', '_topic', '_comm'); 
 +             
 +            foreach ($array_table as $table) { 
 +                $sql "SHOW FULL COLUMNS FROM " . $table_prefix . $table; 
 +                $result = $db->query($sql); 
 +                 
 +                while($row = $result->fetch()) 
 +                    if($row['collation'== 'utf8_general_ci'{ 
 +                        try 
 +                            $db->query("ALTER TABLE " . $table_prefix . $table . " CHANGE  
 +                 "$row['field'] . " " . $row['field'. " " . $row['type'] . " CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci .  
 +                 ($row['null'] == 'NO' ? "NOT NULL" : "") . (strpos($row['type'], 'varchar') === false ? '' : " DEFAULT '" . $row['default'] . "'")); 
 +                        } catch (PDOException $e) { 
 +                            trigger_error($e->getMessage()); 
 +                        } 
 +                    } 
 +                } 
 +            } 
 +        } 
 +    }
  
- $array_author[$lang][$module_info['module_data']]['na'] = 0; +    return $return;
-  +
- foreach( $array_author[$lang][$module_info['module_data']] as $alias => $id ) +
-+
- $db->sql_query( "UPDATE `" . $table . "` SET `nhacsi`='" . $id . "' WHERE `nhacsi`='" . $alias . "'" ); +
- $db->sql_query( "UPDATE `" . $table . "_video` SET `nhacsi`='" . $id . "' WHERE `nhacsi`='" . $alias . "'" ); +
-+
-+
-+
- $db->sql_freeresult(); +
-  +
- return $return;+
 } }
 </code> </code>
Dòng 350: Dòng 488:
 ====== Gói nâng cấp mẫu ====== ====== Gói nâng cấp mẫu ======
  
-Tham khảo gói nâng cấp module music lên phiên bản 3.4.01 của tác giả Phan Tấn Dũng (phantandung92@gmail.com) tại: http://code.google.com/p/nukeviet-music/downloads/detail?name=Update_Module_Music_3.3.01_To_3.4.01.zip+Tham khảo gói nâng cấp module video-clip lên phiên bản 4.0.09 của tác giả Phan Tấn Dũng (phantandung92@gmail.com) tại: https://github.com/hoaquynhtim99/video-clip-update/releases/download/4.0.29/update_video-clip_to4.0.29.zip 
 + 
 +====== Một số ghi chú ====== 
 + 
 +Kể từ phiên bản 4.2.01, thay vì viết 
 + 
 +<code php> 
 +// Duyệt tất cả các ngôn ngữ 
 +$language_query = $db->query('SELECT lang FROM ' $db_config['prefix'] . '_setup_language WHERE setup = 1'); 
 +while (list ($lang) = $language_query->fetch(3)) { 
 +</code> 
 + 
 +Ta chỉ cần dùng 
 + 
 +<code php> 
 +foreach ($global_config['allow_sitelangs'] as $lang) { 
 +</code>
  
 +> Chú ý: Nếu trong function cần kiểm tra gọi $global_config
programming4/moduleupdate.1466066107.txt.gz · Sửa đổi lần cuối: 2016/06/16 15:35 bởi hoaquynhtim99