Esempio n. 1
0
 /**
  * Initialize all default tpl tags.
  */
 private function initialize()
 {
     $this->tpl = new RainTPL();
     try {
         $version = ApplicationUtils::checkUpdate(shaarli_version, $GLOBALS['config']['UPDATECHECK_FILENAME'], $GLOBALS['config']['UPDATECHECK_INTERVAL'], $GLOBALS['config']['ENABLE_UPDATECHECK'], isLoggedIn(), $GLOBALS['config']['UPDATECHECK_BRANCH']);
         $this->tpl->assign('newVersion', escape($version));
         $this->tpl->assign('versionError', '');
     } catch (Exception $exc) {
         logm($GLOBALS['config']['LOG_FILE'], $_SERVER['REMOTE_ADDR'], $exc->getMessage());
         $this->tpl->assign('newVersion', '');
         $this->tpl->assign('versionError', escape($exc->getMessage()));
     }
     $this->tpl->assign('feedurl', escape(index_url($_SERVER)));
     $searchcrits = '';
     // Search criteria
     if (!empty($_GET['searchtags'])) {
         $searchcrits .= '&searchtags=' . urlencode($_GET['searchtags']);
     }
     if (!empty($_GET['searchterm'])) {
         $searchcrits .= '&searchterm=' . urlencode($_GET['searchterm']);
     }
     $this->tpl->assign('searchcrits', $searchcrits);
     $this->tpl->assign('source', index_url($_SERVER));
     $this->tpl->assign('version', shaarli_version);
     $this->tpl->assign('scripturl', index_url($_SERVER));
     $this->tpl->assign('pagetitle', 'Shaarli');
     $this->tpl->assign('privateonly', !empty($_SESSION['privateonly']));
     // Show only private links?
     if (!empty($GLOBALS['title'])) {
         $this->tpl->assign('pagetitle', $GLOBALS['title']);
     }
     if (!empty($GLOBALS['titleLink'])) {
         $this->tpl->assign('titleLink', $GLOBALS['titleLink']);
     }
     if (!empty($GLOBALS['pagetitle'])) {
         $this->tpl->assign('pagetitle', $GLOBALS['pagetitle']);
     }
     $this->tpl->assign('shaarlititle', empty($GLOBALS['title']) ? 'Shaarli' : $GLOBALS['title']);
     if (!empty($GLOBALS['plugin_errors'])) {
         $this->tpl->assign('plugin_errors', $GLOBALS['plugin_errors']);
     }
 }
Esempio n. 2
0
if (empty($GLOBALS['redirector'])) {
    $GLOBALS['redirector'] = '';
}
if (empty($GLOBALS['disablesessionprotection'])) {
    $GLOBALS['disablesessionprotection'] = false;
}
if (empty($GLOBALS['privateLinkByDefault'])) {
    $GLOBALS['privateLinkByDefault'] = false;
}
if (empty($GLOBALS['titleLink'])) {
    $GLOBALS['titleLink'] = '?';
}
// I really need to rewrite Shaarli with a proper configuation manager.
if (!is_file($GLOBALS['config']['CONFIG_FILE'])) {
    // Ensure Shaarli has proper access to its resources
    $errors = ApplicationUtils::checkResourcePermissions($GLOBALS['config']);
    if ($errors != array()) {
        $message = '<p>Insufficient permissions:</p><ul>';
        foreach ($errors as $error) {
            $message .= '<li>' . $error . '</li>';
        }
        $message .= '</ul>';
        header('Content-Type: text/html; charset=utf-8');
        echo $message;
        exit;
    }
    // Display the installation form if no existing config is found
    install();
}
$GLOBALS['title'] = !empty($GLOBALS['title']) ? escape($GLOBALS['title']) : '';
$GLOBALS['titleLink'] = !empty($GLOBALS['titleLink']) ? escape($GLOBALS['titleLink']) : '';
Esempio n. 3
0
&download"><?php 
echo $this->l('action_download');
?>
</a>
	<a class="btn" href="<?php 
echo htmlspecialchars($url);
?>
&raw"><?php 
echo $this->l('action_open_raw');
?>
</a>
	<?php 
if ($isDarkColorScheme) {
    echo '<a class="btn" href="' . htmlspecialchars($url) . '&light">' . $this->l('action_switch_to_light') . '</a>';
} else {
    echo '<a class="btn" href="' . htmlspecialchars(ApplicationUtils::urlStripParameter($url, 'light')) . '">' . $this->l('action_switch_to_dark') . '</a>';
}
?>
	<?php 
if ($owner !== null && isset($_SESSION['authorized_user_id']) && $owner->getId() === $_SESSION['authorized_user_id']) {
    ?>
		<a class="btn btn-info" href="/app/index.php?action=file_edit&file=<?php 
    echo $file->getId();
    ?>
"><?php 
    echo $this->l('action_edit');
    ?>
</a>
		<a class="btn btn-danger" href="/app/index.php?action=file_delete&file=<?php 
    echo $file->getId();
    ?>
Esempio n. 4
0
 /**
  * Checks resource permissions for a non-existent Shaarli installation
  */
 public function testCheckCurrentResourcePermissionsErrors()
 {
     $config = array('CACHEDIR' => 'null/cache', 'CONFIG_FILE' => 'null/data/config.php', 'DATADIR' => 'null/data', 'DATASTORE' => 'null/data/store.php', 'IPBANS_FILENAME' => 'null/data/ipbans.php', 'LOG_FILE' => 'null/data/log.txt', 'PAGECACHE' => 'null/pagecache', 'RAINTPL_TMP' => 'null/tmp', 'RAINTPL_TPL' => 'null/tpl', 'UPDATECHECK_FILENAME' => 'null/data/lastupdatecheck.txt');
     $this->assertEquals(array('"null/tpl" directory is not readable', '"null/cache" directory is not readable', '"null/cache" directory is not writable', '"null/data" directory is not readable', '"null/data" directory is not writable', '"null/pagecache" directory is not readable', '"null/pagecache" directory is not writable', '"null/tmp" directory is not readable', '"null/tmp" directory is not writable'), ApplicationUtils::checkResourcePermissions($config));
 }