function iiif_baseurl($issue, $page)
{
    $subdirs = array(Issue::LOCTYPE_PENDING => "pending", Issue::LOCTYPE_AWAITING_REVIEW => "awaiting-review");
    $fullpath = pathjoin($issue->fullpath(), sprintf("%04d.jp2", $page));
    $path = pathjoin($issue->relative_path, sprintf("%04d.jp2", $page));
    if (!is_file($fullpath)) {
        $path = $issue->relative_page_derivative_path($page) . ".jp2";
    }
    return sprintf("%s/%s%%2F%s", IIIF_SERVER_URL, $subdirs[$issue->loctype], urlencode($path));
}
Exemplo n.º 2
0
 function delete()
 {
     if ($this->is_error()) {
         return false;
     }
     $filepath = pathjoin($this->get_path(), $this->get_filename());
     if (!is_file($filepath)) {
         $this->error_set(sprintf('Image::Delete: cannot delete file "%s": file not found.', $filepath));
         return false;
     }
     if (!@unlink($filepath)) {
         $this->error_set(sprintf('Image::Delete: cannot delete file %s.', $filepath));
         return false;
     }
     return true;
 }
Exemplo n.º 3
0
        case 'all':
            $CorePage = 'all';
            break;
        default:
            $CorePage = '';
    }
    $CoreId = $start_page_id;
} else {
    $CoreId = isset($_GET['id']) ? $_GET['id'] : '';
    $CorePage = $_GET['p'];
}
$CoreModulesMap = array(1 => 'alter_view.php', 2 => 'comments_view.php', 3 => 'comments_add.php', 4 => 'category_view.php', 5 => 'pages_view.php', 6 => 'articles_view.php', 7 => 'newsletter.php', 8 => 'search.php', 9 => 'date_view.php');
require_once pathjoin(PATH_TO_MODULES_USER, array_key_exists($CorePage, $CoreModulesMap) ? $CoreModulesMap[$CorePage] : 'main_view.php');
// wyznaczamy szablon jaki ma byc parsowany, sprawdzajac
// czy faktycznie znajduje sie on w katalogu z szablonami
if (!isset($assigned_tpl) || !file_exists(pathjoin(ROOT, 'templates', $lang, $theme, 'tpl', $assigned_tpl . '_page.tpl'))) {
    $assigned_tpl = 'main_page';
}
$ft->define_dynamic('alternate_design_row', $assigned_tpl);
while ($d = $read_dir->read()) {
    if ($d[0] != '.') {
        $ft->assign(array('ALTERNATE_TEMPLATE' => $d, 'TEMPLATE_LINK' => $CoreRewrite->template_switch($d, $rewrite)));
        $ft->parse('ALTERNATE_DESIGN_ROW', '.alternate_design_row');
    }
}
// tablica includowanych modulow
$modules = array('category_list', 'pages_list', 'links_list');
while (list($m) = each($modules)) {
    require_once PATH_TO_MODULES_USER . $modules[$m] . '.php';
}
if ((bool) $show_calendar) {
Exemplo n.º 4
0
 * by the Free Software Foundation; version 2 only.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 */
header('Content-type: text/html; charset=UTF8');
header("Content-type: application/xml");
require_once "administration/inc/config.php";
require_once 'inc/common_lib.php';
require_once pathjoin(ROOT, 'inc', 'main_lib.php');
$required_classes = array('db_mysql.php', 'fast_template.php', 'db_config.php', 'view.php', 'corebase.php', 'corerss.php', 'rss.php');
while (list($c) = each($required_classes)) {
    require_once pathjoin(PATH_TO_CLASSES, 'cls_' . $required_classes[$c]);
}
// mysql_server_version
get_mysql_server_version();
$CoreRss = new CoreRss();
$ft =& new FastTemplate('./templates/pl/main/tpl/');
$ft->define('xml_feed', 'xml_feed.tpl');
$ft->define_dynamic('xml_row', 'xml_feed');
$ft->define_dynamic("cat_row", "xml_feed");
$ft->assign(array('MAINSITE_LINK' => 'http://', 'NEWS_FEED' => true));
$CoreRss->rss_list(null);
foreach ($CoreRss->rss as $rss) {
    $id = $rss->get_id();
    /*
        $ft->assign(array(
               'DATE'          =>date($date_format, $rss->get_timestamp()),
Exemplo n.º 5
0
        $privilege_level = 5;
        break;
}
// Templates
// inicjowanie klasy, wkazanie katalogu przechowujacego szablony
$ft = new FastTemplate(pathjoin('templates', $lang, 'tpl'));
// tablica definicji użytych plików *.tpl
$ft->define(array('index' => 'index.tpl', 'main_loader' => 'main_loader.tpl', 'result_note' => 'result_note.tpl', 'menu_header' => 'menu_header.tpl', 'menu' => 'menu.tpl'));
$ft->define_dynamic('menu_row', 'menu');
// przełącznica ładowanej treści
$CorePage = isset($_GET['p']) ? $_GET['p'] : 0;
$CoreModulesMap = array(1 => 'add_note.php', 2 => 'edit_note.php', 3 => 'add_page.php', 4 => 'edit_page.php', 5 => 'edit_comments.php', 6 => 'most_comments.php', 7 => 'add_user.php', 8 => 'add_category.php', 9 => 'edit_category.php', 10 => 'core_configuration.php', 11 => 'add_links.php', 12 => 'edit_links.php', 13 => 'edit_users.php', 14 => 'edit_templates.php', 15 => 'transfer_note.php', 16 => 'list_note.php');
if (array_key_exists($CorePage, $CoreModulesMap)) {
    require pathjoin(PATH_TO_MODULES_ADM, $CoreModulesMap[$CorePage]);
} else {
    require pathjoin(PATH_TO_MODULES_ADM, 'main.php');
}
//menu glowne - zaznaczenie wybranej zakladki
if (in_array($CorePage, array(1, 2, 5, 6, 16))) {
    $tag = 'NEWS_CURRENT';
} elseif (in_array($CorePage, array(3, 4))) {
    $tag = 'PAGES_CURRENT';
} elseif (in_array($CorePage, array(7, 13))) {
    $tag = 'USERS_CURRENT';
} elseif (in_array($CorePage, array(8, 9, 15))) {
    $tag = 'CAT_CURRENT';
} elseif (in_array($CorePage, array(10))) {
    $tag = 'CONFIG_CURRENT';
} elseif (in_array($CorePage, array(11, 12))) {
    $tag = 'LINKS_CURRENT';
} elseif (in_array($CorePage, array(14))) {
 /**
  * Returns an array of page numbers for this issue
  */
 public function pages()
 {
     $path = $this->fullpath();
     $dh = opendir($path);
     $pages = array();
     while ($fname = readdir($dh)) {
         $filepath = pathjoin($path, $fname);
         if (is_dir($filepath)) {
             continue;
         }
         $matches = array();
         if (is_file($filepath) && preg_match("|/(\\d\\d\\d\\d)\\.pdf\$|", $filepath, $matches)) {
             $pages[] = (int) $matches[1];
         }
     }
     asort($pages);
     return $pages;
 }
Exemplo n.º 7
0
function renderdir($rootdir, $dir)
{
    global $ignore;
    $ret = '';
    $r = $fnlist = $dirlist = array();
    $r['index'] = null;
    if (($dir = safepath($rootdir, $dir)) === false) {
        redirect('index.php');
    }
    $r['dir'] = $dir;
    $list = (array) uscandir(pathjoin($rootdir, $dir));
    if ($list === false) {
        redirect('index.php?base=' . $_GET['base']);
    }
    foreach ($list as $e) {
        if ($e == '.' || $e == '..' || in_array(strtolower($e), $ignore)) {
            continue;
        }
        if (uis_dir(pathjoin($rootdir, $dir, $e))) {
            $dirlist[] = $e;
        } else {
            $fnlist[] = $e;
        }
    }
    $index_file = tryindex($fnlist, $dir);
    if (!empty($index_file)) {
        $r['index'] = pathjoin($rootdir, $dir, $index_file);
    }
    natsort($dirlist);
    natsort($fnlist);
    foreach ($dirlist as $e) {
        $cfg = loadcfg(pathjoin($rootdir, $dir, $e));
        if (isset($cfg['index'])) {
            $idx = pathjoin($dir, $e, upath($cfg['index']));
            $ahref = urlenc(pathjoin($rootdir, $idx));
            $img = 'thumb.php?base=' . $_GET['base'] . '&file=' . urlencode($idx);
        } else {
            $ahref = 'index.php?base=' . $_GET['base'] . '&dir=' . urlencode(pathjoin($dir, $e));
            $img = 'images/dir.gif';
        }
        if (isset($cfg['icon'])) {
            $img = 'thumb.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e, upath($cfg['icon'])));
        }
        $ret .= mkitem($e, $e, $e, '<a href="' . $ahref . '"' . ($cfg['target'] == '_blank' ? ' target="_blank"' : '') . '>', $img, istoday(pathjoin($rootdir, $dir, $e)), ($dz = udirsize(pathjoin($rootdir, $dir, $e))) > 0 ? '<br /><a name="pack" style="visibility: hidden; float:right;" href="pack.php?base=' . $_GET['base'] . '&dir=' . urlencode(pathjoin($dir, $e)) . '"><img alt="Download" title="Download - ' . fsize($dz) . '" src="images/pack.gif" /></a>' : '');
    }
    foreach ($fnlist as $e) {
        if (isvideo($e) || isaudio($e)) {
            $ahref = '<a href="flowplayer.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)) . '">';
        } elseif (isimage($e)) {
            $ahref = '<a href="image.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)) . '">';
        } elseif (isweb($e)) {
            $ahref = '<a href="' . urlenc(pathjoin($rootdir, $dir, $e)) . '">';
        } elseif (isdocument($e)) {
            $ahref = '<a href="document.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)) . '">';
        } elseif (iscode($e)) {
            $ahref = '<a href="code.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)) . '">';
        } else {
            $ahref = '<a href="' . urlenc(pathjoin($rootdir, $dir, $e)) . '">';
        }
        #		echo $dir.$e."\t".urlencode($dir.$e)."\n";
        $ret .= mkitem($e, $e, $e . ' - (' . fsize(ufilesize(pathjoin($rootdir, $dir, $e))) . ')', $ahref, 'thumb.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)), istoday(pathjoin($rootdir, $dir, $e)), null);
    }
    $r['html'] = $ret;
    return $r;
}
Exemplo n.º 8
0
function tryindex($fs, $dir)
{
    global $CFG, $RTI;
    $bdir = basedir($dir);
    $index_file = '';
    $ifile = pathjoin($CFG['cachedir'], $RTI['base'], sha1($dir) . '.idx');
    if (isarchive() && ($index_file = @file_get_contents($ifile)) !== false) {
        return $index_file;
    } else {
        foreach ($fs as $f) {
            if (!isweb($f)) {
                continue;
            }
            if (empty($index_file)) {
                $index_file = $f;
            } elseif (preg_match('/^index/i', $f)) {
                if (preg_match('/^index/i', $index_file)) {
                    if (strlen(getname($f)) < strlen(getname($index_file))) {
                        $index_file = $f;
                    }
                } else {
                    $index_file = $f;
                }
            } elseif (preg_match('/^default/i', $f)) {
                if (preg_match('/^default/i', $index_file)) {
                    if (strlen(getname($f)) < strlen(getname($index_file))) {
                        $index_file = $f;
                    }
                } elseif (!preg_match('/^index/i', $index_file)) {
                    $index_file = $f;
                }
            } elseif (levenshtein($bdir, $f) < levenshtein($bdir, $index_file) && !preg_match('/^index/i', $index_file) && !preg_match('/^default/i', $index_file)) {
                $index_file = $f;
            }
        }
        if (isarchive()) {
            if (!ufile_exists($CFG['cachedir'] . $RTI['base'])) {
                umkdir($CFG['cachedir'] . $RTI['base']);
            }
            file_put_contents($ifile, $index_file);
        }
        return $index_file;
    }
}
 private function create_directory_or_delete()
 {
     // Check for the directory already existing - this is a failure in terms of
     // mkdir's return, but it isn't a reason to delete the db record
     $dir = pathjoin(SCANS_AWAITING_DERIVATIVES, $this->code);
     if (is_dir($dir)) {
         return TRUE;
     }
     // Create the directory or remove the DB entry
     if (mkdir($dir) === FALSE) {
         $db = DB::get_db();
         $sql = sprintf("DELETE FROM mocs WHERE id = %d", $this->id);
         if (!$db->query($sql)) {
             error_log("Unable to delete bad MOC record: " . $db->error . " (sql: {$sql})");
         }
         return FALSE;
     }
     return TRUE;
 }
Exemplo n.º 10
0
$todo = array();
foreach ($base as $b) {
    $todo[] = array($b[0], '');
}
while (count($todo)) {
    list($b, $p) = array_shift($todo);
    #	echo $b.$p."\n";
    $rootdir = getbase($b);
    $fp = pathjoin($rootdir, $p);
    if (uis_dir($fp)) {
        $fs = uscandir($fp);
        foreach ($fs as $f) {
            if ($f == '.' || $f == '..') {
                continue;
            }
            $todo[] = array($b, pathjoin($p, $f));
        }
        continue;
    }
    $hash = mkhash($fp);
    $hash = $b . '/' . $hash;
    $size = $CFG['thumb_size'];
    if (isimage($fp)) {
        $t1 = $CFG['cachedir'] . $hash . '_' . $size . '.jpg';
        if (!newer($fp, $t1)) {
            touch($t1, filemtime($t1), $_now);
            continue;
        }
    } elseif (isvideo($fp)) {
        $t1 = $CFG['cachedir'] . $hash . '.mp4';
        $t2 = $CFG['cachedir'] . $hash . '_L.jpg';