/**
 * Get Internal Link List to Images/Downloads.
 *
 * @param array  $h              headings array.
 * @param array  $u              URL array.
 * @param array  $l              menulevel array.
 * @param string $downloads_path downloads folder path.
 *
 * @return JSON structured images / downloads list
 */
function get_internal_links($h, $u, $l, $downloads_path)
{
    $list = array();
    for ($i = 0; $i < count($h); $i++) {
        $spacer = '';
        if ($l[$i] > 1) {
            $spacer = str_repeat('__', $l[$i] - 1);
            // just for
            // indenting lower level "pages"
        }
        $list[] = array('title' => $spacer . html_entity_decode(addcslashes($h[$i], "\n\r\t\"\\")), 'value' => '?' . $u[$i]);
    }
    if (is_dir($downloads_path)) {
        $list[] = array('title' => 'DOWNLOADS:', 'value' => " ");
        $fs = sortdir($downloads_path);
        foreach ($fs as $p) {
            if (preg_match("/.+\\..+\$/", $p)) {
                $list[] = array('title' => '__' . substr($p, 0, 25) . ' (' . round(filesize($downloads_path . '/' . $p) * 10 >> 8) / 10 . ' KB)', 'value' => './?download=' . $p);
            }
        }
    }
    return XH_encodeJSON($list);
}
예제 #2
0
파일: links.php 프로젝트: 2014c2g1/2014cadp
function get_internal_links($h, $u, $l, $sn, $downloads_path)
{
    $list = '';
    for ($i = 0; $i < count($h); $i++) {
        $spacer = '';
        if ($l[$i] > 1) {
            $spacer = str_repeat('&nbsp;&nbsp;&nbsp;', $l[$i] - 1);
            // just for indenting lower level "pages"
        }
        //$list.='["' . $spacer . substr(str_replace('"', '&quot;', $h[$i]), 0, 30) . '", "' . $sn . '?' . $u[$i] . '"],';
        $list .= '["' . $spacer . addcslashes($h[$i], "\n\r\t\"\\") . '", "?' . $u[$i] . '"],';
    }
    if (@is_dir($downloads_path)) {
        $list .= '["DOWNLOADS:",""],';
        $fs = sortdir($downloads_path);
        foreach ($fs as $p) {
            if (preg_match("/.+\\..+\$/", $p)) {
                $list .= '["&nbsp;&nbsp;' . substr($p, 0, 25) . ' (' . round(filesize($downloads_path . '/' . $p) / 102.4) / 10 . ' KB)", "./?download=' . $p . '"],';
            }
        }
    }
    $list = substr($list, 0, -1);
    return $list;
}