Esempio n. 1
0
function txPageTemplateSave()
{
    global $DB, $C;
    VerifyAdministrator();
    CheckAccessList();
    // Remove extra whitespace from the template code
    $_REQUEST['code'] = trim($_REQUEST['code']);
    $_REQUEST['page_id'] = explode(',', $_REQUEST['page_id']);
    if (preg_match('~<\\?[^x]~', $_REQUEST['code'])) {
        $GLOBALS['errstr'] = "Template not saved: Your template currently contains raw PHP code using &lt;? and ?&gt; tags; " . "you should instead use the special {php} or {phpcode} template functions for raw PHP code (see the software manual for details on these template functions)";
    }
    // Attempt to compile the code
    if (!isset($GLOBALS['errstr'])) {
        foreach ($_REQUEST['page_id'] as $page_id) {
            if (!empty($page_id)) {
                $page = $DB->Row('SELECT * FROM `tx_pages` WHERE `page_id`=?', array($page_id));
                $compiled = '';
                $c = new Compiler();
                $c->flags['category_id'] = $page['category_id'];
                if ($c->compile($_REQUEST['code'], $compiled)) {
                    $DB->Update('UPDATE `tx_pages` SET `template`=?,`compiled`=? WHERE `page_id`=?', array($_REQUEST['code'], $compiled, $page_id));
                } else {
                    $GLOBALS['errstr'] = "Template for {$page['page_url']} could not be saved:<br />" . nl2br($c->get_error_string());
                }
            }
        }
        // Build pages if the option was selected
        if ($_REQUEST['build']) {
            BuildSelected($_REQUEST['page_id']);
        }
    }
    $_REQUEST['page_id'] = $_REQUEST['page_id'][0];
    $_REQUEST['page'] = $DB->Row('SELECT `page_id`,`page_url` FROM `tx_pages` WHERE `page_id`=?', array($_REQUEST['page_id']));
    if (!isset($GLOBALS['errstr'])) {
        $GLOBALS['message'] = 'Template has been successully saved';
        $GLOBALS['warnstr'] = CheckTemplateCode($_REQUEST['code']);
    }
    txShPageTemplates();
}
Esempio n. 2
0
function txPageBuild()
{
    global $json, $DB;
    VerifyAdministrator(TRUE);
    $GLOBALS['override_page_lock'] = TRUE;
    if ($_REQUEST['new']) {
        BuildNewSelected(array($_REQUEST['page_id']));
    } else {
        BuildSelected(array($_REQUEST['page_id']));
    }
    echo $json->encode(array('status' => JSON_SUCCESS, 'message' => 'The selected TGP page has been built'));
}
Esempio n. 3
0
             BuildNewTagged($args['tags']);
         } else {
             BuildNewAll();
         }
     }
     break;
 case '--build':
     $args = ParseCommandLine();
     if ($args['override-lock']) {
         $GLOBALS['override_page_lock'] = TRUE;
     }
     if (!IsEmptyString($args['pages'])) {
         if (preg_match('~(\\d+)-(\\d+)~', $args['pages'], $matches)) {
             $args['pages'] = join(',', range($matches[1], $matches[2]));
         }
         BuildSelected(explode(',', $args['pages']));
     } else {
         if (!IsEmptyString($args['tags'])) {
             BuildTagged($args['tags']);
         } else {
             BuildAll();
         }
     }
     break;
 case '--process-clicklog':
     ProcessClickLog();
     break;
 case '--backup':
     $args = ParseCommandLine();
     if (IsEmptyString($args['sql-file'])) {
         echo "ERROR: You must specify at least a SQL data backup filename when using the --backup function\n" . "Example:\n" . "{$_SERVER['_']} {$path}/{$GLOBALS['argv'][0]} --backup --sql-file=sql-backup.txt --thumbs-file=thumbs-backup.txt --archive-file=backup.tar.gz\n";