Пример #1
0
function update_lastmod()
{
    safe_upsert("txp_prefs", "val = now()", "name = 'lastmod'");
    flushcachedir(true);
}
Пример #2
0
 function import($dir)
 {
     if (!$this->checkdir($dir, TEMPLATES_IMPORT)) {
         return;
     }
     /*
         Auto export into `preimport-data`
     */
     print "\n            <h1>Backing up current template data</h1>\n            <p>Your current template data will be available for re-import as `preimport-data`.</p>\n        ";
     $this->export('preimport-data');
     $basedir = sprintf("%s/%s", $this->_config['full_base_path'], $dir);
     foreach ($this->exportTypes as $type => $config) {
         print "\n                <h1>Importing " . $config['nice_name'] . "</h1>\n                <ul class='results'>\n            ";
         $exportdir = sprintf("%s/%s", $basedir, $config['subdir']);
         $dir = opendir($exportdir);
         while (false !== ($filename = readdir($dir))) {
             if (preg_match($config['regex'], $filename, $filedata)) {
                 $templateName = addslashes($filedata[1]);
                 $templateType = isset($filedata[2]) ? $filedata[2] : '';
                 $f = sprintf("%s/%s", $exportdir, $filename);
                 if ($data = file($f)) {
                     if ($type == 'css') {
                         $data = base64_encode(implode('', $data));
                     } else {
                         $data = addslashes(implode('', $data));
                     }
                     if (safe_field('name', $config['table'], "name='" . $templateName . "'")) {
                         $result = safe_update($config['table'], sprintf($config['sql'], $data, $templateType), "`name` = '" . $templateName . "'");
                         $success = $result ? 1 : 0;
                     } else {
                         $result = safe_insert($config['table'], sprintf($config['sql'], $data, $templateType) . ", `name` = '" . $templateName . "'");
                         $success = $result ? 1 : 0;
                     }
                 }
                 $success = true;
                 if ($success) {
                     print "<li><span class='success'>Successfully imported</span> file '" . $filename . "'</li>";
                     flushcachedir(true);
                 } else {
                     print "<li><span class='failure'>Failed importing</span> file '" . $filename . "'</li>";
                 }
             }
         }
         print "\n                </ul>\n            ";
     }
 }