Пример #1
0
if ($noattach == "") {
    daily_stat("Resource download", $ref);
    resource_log($ref, 'd', 0, $usagecomment, "", "", $usage, $size);
    hook('moredlactions');
    # update hit count if tracking downloads only
    if ($resource_hit_count_on_downloads) {
        # greatest() is used so the value is taken from the hit_count column in the event that new_hit_count is zero to support installations that did not previously have a new_hit_count column (i.e. upgrade compatability).
        sql_query("update resource set new_hit_count=greatest(hit_count,new_hit_count)+1 where ref='{$ref}'");
    }
    # We compute a file name for the download.
    $filename = $ref . $size . ($alternative > 0 ? "_" . $alternative : "") . "." . $ext;
    if ($original_filenames_when_downloading) {
        # Use the original filename.
        if ($alternative > 0) {
            # Fetch from the resource_alt_files alternatives table (this is an alternative file)
            $origfile = get_alternative_file($ref, $alternative);
            $origfile = get_data_by_field($ref, $filename_field) . "-" . $origfile["file_name"];
        } else {
            # Fetch from field data or standard table
            $origfile = get_data_by_field($ref, $filename_field);
        }
        if (strlen($origfile) > 0) {
            # do an extra check to see if the original filename might have uppercase extension that can be preserved.
            $pathparts = pathinfo($origfile);
            if (isset($pathparts['extension'])) {
                if (strtolower($pathparts['extension']) == $ext) {
                    $ext = $pathparts['extension'];
                }
            }
            # Use the original filename if one has been set.
            # Strip any path information (e.g. if the staticsync.php is used).
Пример #2
0
    $hashkey = md5($api_scramble_key . getval("key", ""));
    // generate the signature required to match against given skey to continue
    $keytotest = md5($hashkey . $test_query);
    if ($keytotest != getval('skey', '')) {
        header("HTTP/1.0 403 Forbidden.");
        echo "HTTP/1.0 403 Forbidden. Invalid Signature";
        exit;
    }
}
// if only a resource is specified, return all alt files
if ($alt_file == "" && $resource != "") {
    $results = get_alternative_files($resource);
}
// if a specific alt file and resource are specified, return a single result
if ($alt_file != "" && $resource != "") {
    $results[0] = get_alternative_file($resource, $alt_file);
}
for ($n = 0; $n < count($results); $n++) {
    $thepath = get_resource_path($resource, true, '', false, $results[$n]['file_extension'], -1, 1, false, "", $results[$n]["ref"]);
    if (file_exists($thepath)) {
        $results[$n]['file_path'] = $thepath;
    }
    if (getval("previewsize", "") != "") {
        $thepath = get_resource_path($resource, true, getval("previewsize", ""), false, 'jpg', -1, 1, false, "", $results[$n]["ref"]);
        if (file_exists($thepath) && count($results[$n]) != 1) {
            $results[$n]['preview'] = $thepath;
        }
    }
}
if (!is_array($results) || isset($results[0]) && count($results[0]) == 1) {
    $results = array();
Пример #3
0
$default_sort="DESC";
if (substr($order_by,0,5)=="field"){$default_sort="ASC";}
$sort=getval("sort",$default_sort);

$resource=getvalescaped("resource","",true);

# Fetch resource data.
$resourcedata=get_resource_data($resource);

# Not allowed to edit this resource?
if ((!checkperm("e" . $resourcedata["archive"])) && ($resource>0)) {exit ("Permission denied.");}

hook("pageevaluation");

# Fetch alternative file data
$file=get_alternative_file($resource,$ref);if ($file===false) {exit("Alternative file not found.");}

if (getval("name","")!="")
	{
	hook("markmanualupload");
	# Save file data
	save_alternative_file($resource,$ref);
	hook ("savealternatefiledata");
	redirect ($baseurl_short."pages/alternative_files.php?ref=$resource&search=".urlencode($search)."&offset=$offset&order_by=$order_by&sort=$sort&archive=$archive");
	}

	
include "../include/header.php";
?>
<div class="BasicsBox">
<p>
Пример #4
0
function get_page_count($resource,$alternative=-1)
    {
    # gets page count for multipage previews from resource_dimensions table.
    # also handle alternative file multipage previews by switching $resource array if necessary
    # $alternative specifies an actual alternative file
    $ref=$resource['ref'];
    if ($alternative!=-1)
        {
        $pagecount=sql_value("select page_count value from resource_alt_files where ref=$alternative","");
        $resource=get_alternative_file($ref,$alternative);
        }
    else
        {
        $pagecount=sql_value("select page_count value from resource_dimensions where resource=$ref","");
        }
    if ($pagecount!=""){return $pagecount;}
    # or, populate this column with exiftool (for installations with many pdfs already previewed and indexed, this allows pagecount updates on the fly when needed):
    # use exiftool. 
    # locate exiftool
    $exiftool_fullpath = get_utility_path("exiftool");
    if ($exiftool_fullpath==false){}
    else
        {
        $command = $exiftool_fullpath;
        if ($resource['file_extension']=="pdf" && $alternative==-1)
            {
            $file=get_resource_path($ref,true,"",false,"pdf");
            }
        else if ($alternative==-1)
            {
            # some unoconv files are not pdfs but this needs to use the auto-alt file
            $alt_ref=sql_value("select ref value from resource_alt_files where resource=$ref and unoconv=1","");
            $file=get_resource_path($ref,true,"",false,"pdf",-1,1,false,"",$alt_ref);
            }
        else
            {
            $file=get_resource_path($ref,true,"",false,"pdf",-1,1,false,"",$alternative);
            }
    
        $command=$command." -sss -pagecount $file";
        $output=run_command($command);
        $pages=str_replace("Page Count","",$output);
        $pages=str_replace(":","",$pages);
        $pages=trim($pages);

    if (!is_numeric($pages)){ $pages = 1; } // default to 1 page if we didn't get anything back

        if ($alternative!=-1)
            {
            sql_query("update resource_alt_files set page_count='$pages' where ref=$alternative");
            }
        else
            {
            sql_query("update resource_dimensions set page_count='$pages' where resource=$ref");
            }
        return $pages;
    }
}
if (substr($order_by, 0, 5) == "field") {
    $default_sort = "ASC";
}
$sort = getval("sort", $default_sort);
$resource = getvalescaped("resource", "", true);
# Fetch resource data.
$resourcedata = get_resource_data($resource);
# Load the configuration for the selected resource type. Allows for alternative notification addresses, etc.
resource_type_config_override($resourcedata["resource_type"]);
# Not allowed to edit this resource?
if ((!get_edit_access($resource, $resourcedata["archive"], false, $resourcedata) || checkperm('A')) && $resource > 0) {
    exit("Permission denied.");
}
hook("pageevaluation");
# Fetch alternative file data
$file = get_alternative_file($resource, $ref);
if ($file === false) {
    exit("Alternative file not found.");
}
if (getval("name", "") != "") {
    hook("markmanualupload");
    # Save file data
    save_alternative_file($resource, $ref);
    // Check to see if we need to notify users of this change
    if ($notify_on_resource_change_days != 0) {
        notify_resource_change($resource);
    }
    hook("savealternatefiledata");
    redirect($baseurl_short . "pages/alternative_files.php?ref={$resource}&search=" . urlencode($search) . "&offset={$offset}&order_by={$order_by}&sort={$sort}&archive={$archive}");
}
include "../include/header.php";