// // ------------------------------------------------------------------------- // include_once( '../../../include/cp_header.php' ) ; include_once "../include/gtickets.php" ; include_once XOOPS_ROOT_PATH.'/class/template.php'; include_once dirname(dirname(__FILE__)).'/include/Text_Diff.php' ; include_once dirname(dirname(__FILE__)).'/include/Text_Diff_Renderer.php' ; include_once dirname(dirname(__FILE__)).'/include/Text_Diff_Renderer_unified.php' ; $xoops_system_path = XOOPS_ROOT_PATH . '/modules/system' ; // initials $db =& Database::getInstance(); $myts =& MyTextSanitizer::getInstance() ; // determine language $language = $xoopsConfig['language'] ; if( ! file_exists( "$xoops_system_path/language/$language/admin/tplsets.php") ) $language = 'english' ; // load language constants // to prevent from notice that constants already defined $error_reporting_level = error_reporting( 0 ) ; include_once( "$xoops_system_path/constants.php" ) ; include_once( "$xoops_system_path/language/$language/admin.php" ) ; include_once( "$xoops_system_path/language/$language/admin/tplsets.php" ) ; error_reporting( $error_reporting_level ) ; // check $xoopsModule if( ! is_object( $xoopsModule ) ) redirect_header( XOOPS_URL.'/user.php' , 1 , _NOPERM ) ; // check access right (needs system_admin of tplset) $sysperm_handler =& xoops_gethandler('groupperm'); if (!$sysperm_handler->checkRight('system_admin', XOOPS_SYSTEM_TPLSET, $xoopsUser->getGroups())) redirect_header( XOOPS_URL.'/user.php' , 1 , _NOPERM ) ; // tpl_file from $_GET $tpl_file = $myts->stripSlashesGPC( @$_GET['tpl_file'] ) ; $tpl_file = str_replace( 'db:' , '' , $tpl_file ) ; $tpl_file4sql = addslashes( $tpl_file ) ; // tpl_file from $_GET $tpl_tplset = $myts->stripSlashesGPC( @$_GET['tpl_tplset'] ) ; if( ! $tpl_tplset ) $tpl_tplset = $xoopsConfig['template_set'] ; $tpl_tplset4sql = addslashes( $tpl_tplset ) ; // get information from tplfile table $sql = "SELECT * FROM ".$db->prefix("tplfile")." f NATURAL LEFT JOIN ".$db->prefix("tplsource")." s WHERE f.tpl_file='$tpl_file4sql' ORDER BY f.tpl_tplset='$tpl_tplset4sql' DESC,f.tpl_tplset='default' DESC" ; $tpl = $db->fetchArray( $db->query( $sql ) ) ; // error in specifying tpl_file if( empty( $tpl ) ) { if( strncmp( $tpl_file , 'file:' , 5 ) === 0 ) { die( 'Not DB template' ) ; } else { die( 'Invalid tpl_file.' ) ; } } //************// // POST stage // //************// if( ! empty( $_POST['do_modify'] ) ) { // Ticket Check if ( ! $xoopsGTicket->check() ) { redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors()); } $result = $db->query( "SELECT tpl_id FROM ".$db->prefix("tplfile")." WHERE tpl_file='$tpl_file4sql' AND tpl_tplset='".addslashes($tpl['tpl_tplset'])."'" ) ; while( list( $tpl_id ) = $db->fetchRow( $result ) ) { $sql = "UPDATE ".$db->prefix("tplsource")." SET tpl_source='".addslashes($myts->stripSlashesGPC($_POST['tpl_source']))."' WHERE tpl_id=$tpl_id" ; if( ! $db->query( $sql ) ) die( 'SQL Error' ) ; $db->query( "UPDATE ".$db->prefix("tplfile")." SET tpl_lastmodified=UNIX_TIMESTAMP() WHERE tpl_id=$tpl_id" ) ; xoops_template_touch( $tpl_id ) ; } redirect_header( 'mytplsadmin.php?dirname='.$tpl['tpl_module'] , 1 , _MD_AM_DBUPDATED ) ; exit ; } xoops_cp_header() ; $mymenu_fake_uri = "/admin/mytplsadmin.php?dirname={$tpl['tpl_module']}" ; if( file_exists( './mymenu.php' ) ) include( './mymenu.php' ) ; echo "

"._MD_AM_TPLSETS." : ".htmlspecialchars($tpl['tpl_type'],ENT_QUOTES)." : ".htmlspecialchars($tpl['tpl_file'],ENT_QUOTES)." (".htmlspecialchars($tpl['tpl_tplset'],ENT_QUOTES).")

\n" ; // diff from file to selected DB template $basefilepath = XOOPS_ROOT_PATH.'/modules/'.$tpl['tpl_module'].'/templates/'.($tpl['tpl_type']=='block'?'blocks/':'').$tpl['tpl_file'] ; $diff_from_file4disp = '' ; if( file_exists( $basefilepath ) ) { $diff =& new Text_Diff( file( $basefilepath ) , explode("\n",$tpl['tpl_source']) ) ; $renderer =& new Text_Diff_Renderer_unified(); $diff_str = htmlspecialchars( $renderer->render( $diff ) , ENT_QUOTES ) ; foreach( explode( "\n" , $diff_str ) as $line ) { if( ord( $line ) == 0x2d ) { $diff_from_file4disp .= "".$line."\n" ; } else if( ord( $line ) == 0x2b ) { $diff_from_file4disp .= "".$line."\n" ; } else { $diff_from_file4disp .= $line."\n" ; } } } // diff from DB-default to selected DB template $diff_from_default4disp = '' ; if( $tpl['tpl_tplset'] != 'default' ) { list( $default_source ) = $db->fetchRow( $db->query( "SELECT tpl_source FROM ".$db->prefix("tplfile")." NATURAL LEFT JOIN ".$db->prefix("tplsource")." WHERE tpl_tplset='default' AND tpl_file='".addslashes($tpl['tpl_file'])."' AND tpl_module='".addslashes($tpl['tpl_module'])."'" ) ) ; $diff =& new Text_Diff( explode("\n",$default_source) , explode("\n",$tpl['tpl_source']) ) ; $renderer =& new Text_Diff_Renderer_unified(); $diff_str = htmlspecialchars( $renderer->render( $diff ) , ENT_QUOTES ) ; foreach( explode( "\n" , $diff_str ) as $line ) { if( ord( $line ) == 0x2d ) { $diff_from_default4disp .= "".$line."\n" ; } else if( ord( $line ) == 0x2b ) { $diff_from_default4disp .= "".$line."\n" ; } else { $diff_from_default4disp .= $line."\n" ; } } } echo "
 
$diff_from_file4disp
 
\n" ; echo "
".$xoopsGTicket->getTicketHtml( __LINE__ )."
\n" ; xoops_cp_footer() ; ?>