foreach ($tplsadmin_autoupdate_mydirnames as $tplsadmin_mydirname) {
    $tplsadmin_mydirname = preg_replace('/[^a-zA-Z0-9_-]/', '', $tplsadmin_mydirname);
    require XOOPS_ROOT_PATH . '/modules/' . $tplsadmin_mydirname . '/mytrustdirname.php';
    $altsys_mid_path = $mytrustdirname == 'altsys' ? '/libs/' : '/modules/';
    $tplsadmin_autoupdate_path = XOOPS_TRUST_PATH . $altsys_mid_path . $mytrustdirname . '/templates';
    // modules
    if ($handler = @opendir($tplsadmin_autoupdate_path . '/')) {
        while (($file = readdir($handler)) !== false) {
            $file_path = $tplsadmin_autoupdate_path . '/' . $file;
            if (is_file($file_path)) {
                $mtime = intval(@filemtime($file_path));
                $tpl_file = $tplsadmin_mydirname . '_' . $file;
                list($count) = $xoopsDB->fetchRow($xoopsDB->query("SELECT COUNT(*) FROM " . $xoopsDB->prefix("tplfile") . " WHERE tpl_tplset='" . addslashes($xoopsConfig['template_set']) . "' AND tpl_file='" . addslashes($tpl_file) . "' AND tpl_lastmodified >= {$mtime}"));
                if ($count <= 0) {
                    include_once XOOPS_TRUST_PATH . '/libs/altsys/include/tpls_functions.php';
                    tplsadmin_import_data($xoopsConfig['template_set'], $tpl_file, implode('', file($file_path)), $mtime);
                }
            }
        }
    }
    /*	// blocks
    	if( $handler = @opendir( $tplsadmin_autoupdate_path . '/blocks/' ) ) {
    		while( ( $file = readdir( $handler ) ) !== false ) {
    			$file_path = $tplsadmin_autoupdate_path . '/blocks/' . $file ;
    			if( is_file( $file_path ) && substr( $file , -5 ) == '.html' ) {
    				$mtime = intval( @filemtime( $file_path ) ) ;
    				list( $count ) = $xoopsDB->fetchRow( $xoopsDB->query( "SELECT COUNT(*) FROM ".$xoopsDB->prefix("tplfile")." WHERE tpl_tplset='".addslashes($xoopsConfig['template_set'])."' AND tpl_file='".addslashes($file)."' AND tpl_lastmodified >= $mtime" ) ) ;
    				if( $count <= 0 ) {
    					include_once XOOPS_TRUST_PATH.'/libs/altsys/include/tpls_functions.php' ;
    					tplsadmin_import_data( $xoopsConfig['template_set'] , $file , implode( '' , file( $file_path ) ) , $mtime ) ;
    				}
Exemplo n.º 2
0
            $files[] = array('filename' => $info['name'], 'mtime' => $info['time'], 'content' => $info['file']);
        }
        if (empty($files)) {
            die(_TPLSADMIN_ERR_INVALIDARCHIVE);
        }
        $do_upload = true;
    }
}
if (empty($do_upload)) {
    die(_TPLSADMIN_ERR_EXTENSION);
}
//
// IMPORT STAGE
//
$tplset = @$_POST['tplset'];
if (!preg_match('/^[0-9A-Za-z_-]{1,16}$/', $tplset)) {
    die(_TPLSADMIN_ERR_INVALIDTPLSET);
}
$imported = 0;
foreach ($files as $file) {
    if (!empty($file['folder'])) {
        continue;
    }
    $pos = strrpos($file['filename'], '/');
    $tpl_file = $pos === false ? $file['filename'] : substr($file['filename'], $pos + 1);
    if (tplsadmin_import_data($tplset, $tpl_file, rtrim($file['content']), $file['mtime'])) {
        $imported++;
    }
}
redirect_header('?mode=admin&lib=altsys&page=compilehookadmin', 3, sprintf(_TPLSADMIN_FMT_MSG_PUTTEMPLATES, $imported));
exit;