3 if (!class_exists(
'ProtectorRegistry'))
exit(
'Registry not found');
11 eval(
' function xoops_module_update_'.
$mydirname.
'( $module ) { return protector_onupdate_base( $module , "'.
$mydirname.
'" ) ; } ' ) ;
14 if( ! function_exists(
'protector_onupdate_base' ) ) {
23 if( defined(
'XOOPS_CUBE_LEGACY' ) ) {
24 $root =& XCube_Root::getSingleton();
25 $root->mDelegateManager->add(
'Legacy.Admin.Event.ModuleUpdate.' . ucfirst(
$mydirname) .
'.Success',
'protector_message_append_onupdate' ) ;
28 if( ! is_array( $msgs ) ) $msgs = array() ;
37 $check_sql =
"SHOW COLUMNS FROM ".$db->prefix(
"config").
" LIKE 'conf_title'" ;
38 if( (
$result =
$db->query( $check_sql ) ) && ( $myrow =
$db->fetchArray(
$result ) ) && @$myrow[
'Type'] ==
'varchar(30)' ) {
39 $db->queryF(
"ALTER TABLE ".
$db->prefix(
"config").
" MODIFY `conf_title` varchar(255) NOT NULL default '', MODIFY `conf_desc` varchar(255) NOT NULL default ''" ) ;
41 list( , $create_string ) =
$db->fetchRow(
$db->query(
"SHOW CREATE TABLE ".$db->prefix(
"config") ) ) ;
42 foreach( explode(
'KEY' , $create_string ) as $line ) {
43 if( preg_match(
'/(\`conf\_title_\d+\`) \(\`conf\_title\`\)/' , $line , $regs ) ) {
44 $db->query(
"ALTER TABLE ".
$db->prefix(
"config").
" DROP KEY ".$regs[1] ) ;
47 $db->query(
"ALTER TABLE ".
$db->prefix(
"config").
" ADD KEY `conf_title` (`conf_title`)" ) ;
50 list( , $create_string ) =
$db->fetchRow(
$db->query(
"SHOW CREATE TABLE ".$db->prefix(
$mydirname.
"_log") ) ) ;
51 if( preg_match(
'/timestamp\(/i' , $create_string ) ) {
52 $db->query(
"ALTER TABLE ".
$db->prefix(
$mydirname.
"_log").
" MODIFY `timestamp` DATETIME" ) ;
58 $tpl_path = dirname(__FILE__).
'/templates' ;
59 if(
$handler = @opendir( $tpl_path .
'/' ) ) {
61 if( substr(
$file , 0 , 1 ) ==
'.' ) continue ;
62 $file_path = $tpl_path .
'/' .
$file ;
63 if( is_file( $file_path ) && in_array( strrchr(
$file ,
'.' ) , array(
'.html' ,
'.css' ,
'.js' ) ) ) {
64 $mtime = intval( @filemtime( $file_path ) ) ;
65 $tplfile =& $tplfile_handler->create() ;
66 $tplfile->setVar(
'tpl_source' , file_get_contents( $file_path ) ,
true ) ;
67 $tplfile->setVar(
'tpl_refid' ,
$mid ) ;
68 $tplfile->setVar(
'tpl_tplset' ,
'default' ) ;
70 $tplfile->setVar(
'tpl_desc' ,
'' ,
true ) ;
71 $tplfile->setVar(
'tpl_module' ,
$mydirname ) ;
72 $tplfile->setVar(
'tpl_lastmodified' , $mtime ) ;
73 $tplfile->setVar(
'tpl_lastimported' , 0 ) ;
74 $tplfile->setVar(
'tpl_type' ,
'module' ) ;
75 if( ! $tplfile_handler->insert( $tplfile ) ) {
76 $msgs[] =
'<span style="color:#ff0000;">ERROR: Could not insert template <b>'.htmlspecialchars(
$mydirname.
'_'.$file).
'</b> to the database.</span>';
78 $tplid = $tplfile->getVar(
'tpl_id' ) ;
79 $msgs[] =
'Template <b>'.htmlspecialchars(
$mydirname.
'_'.$file).
'</b> added to the database. (ID: <b>'.$tplid.
'</b>)';
81 include_once XOOPS_ROOT_PATH.
'/class/xoopsblock.php' ;
82 include_once XOOPS_ROOT_PATH.
'/class/template.php' ;
84 $msgs[] =
'<span style="color:#ff0000;">ERROR: Failed compiling template <b>'.htmlspecialchars(
$mydirname.
'_'.$file).
'</b>.</span>';
86 $msgs[] =
'Template <b>'.htmlspecialchars(
$mydirname.
'_'.$file).
'</b> compiled.</span>';
93 include_once XOOPS_ROOT_PATH.
'/class/xoopsblock.php' ;
94 include_once XOOPS_ROOT_PATH.
'/class/template.php' ;
100 function protector_message_append_onupdate( &$module_obj , &$log )
102 if( is_array( @
$GLOBALS[
'msgs'] ) ) {
103 foreach(
$GLOBALS[
'msgs'] as $message ) {
104 $log->add( strip_tags( $message ) ) ;