function definetomap($zoom, $pid, $page) { global $tb, $lr, $vh; $image = imagecreatefromstring($page['image']); $offset = offset($image, 0, 0, $page); $width = $page['width']; $height = $page['height']; //draw lines of corner edges $vert = true; $linewidth = 5; $lc = 0; foreach ($offset as $coord) { if ($vert == true) { $top = 0; if ($lc > 3) { $top = $height / $zoom - $height / 4 / $zoom; } //drawing a vertical line so use $coord as $x print "<div style='position: absolute; top:" . $top . "px; left:" . $coord / $zoom . "px; width:" . $linewidth / $zoom . "px; height:" . $height / 4 / $zoom . "px; background-color: blue; opacity: 0.8;'></div>"; $vert = false; } else { //drawing a horizontal line so use $coord as $y $left = 0; if ($lc == 3 || $lc == 7) { $left = $width / $zoom - $width / 4 / $zoom; } print "<div style='position: absolute; top:" . $coord / $zoom . "px; left:" . $left . "px; width:" . $width / 4 / $zoom . "px; height:" . $linewidth / $zoom . "px; background-color: blue; opacity: 0.8;'></div>"; $vert = true; } $lc++; } foreach ($tb as $a) { foreach ($lr as $b) { foreach ($vh as $c) { $vname = "{$a}{$b}" . "_" . $c . "_"; $tlx = $page[strtoupper($vname . "tlx")]; $tly = $page[strtoupper($vname . "tly")]; $brx = $page[strtoupper($vname . "brx")]; $bry = $page[strtoupper($vname . "bry")]; print "<div id='{$vname}' style='position: absolute; top:" . $tly / $zoom . "px; left: " . $tlx / $zoom . "px; width:" . ($brx - $tlx) / $zoom . "px; height:" . ($bry - $tly) / $zoom . "px; background-color: green; opacity: 0.6;' class='drsElement'><div class='drsMoveHandle'>" . $vname . "</div></div>"; } } } //Don't display barcode anymore as it is detected on a system level /* $vname = "barcode_"; $tlx = constant(strtoupper($vname . "tlx")); $tly = constant(strtoupper($vname . "tly")); $brx = constant(strtoupper($vname . "brx")); $bry = constant(strtoupper($vname . "bry")); $barcodeimage = crop($image,array("tlx" => BARCODE_TLX, "tly" => BARCODE_TLY, "brx" => BARCODE_BRX, "bry" => BARCODE_BRY)); $barcode = barcode($barcodeimage); print "<div id='$vname' style='position: absolute; top:" . $tly / $zoom. "px; left: " . $tlx / $zoom. "px; width:" . ($brx-$tlx)/ $zoom. "px; height:" . ($bry-$tly)/ $zoom. "px; background-color: brown; opacity: 0.6;' class='drsElement'><div class='drsMoveHandle'>" . $vname . "</div>$barcode</div>"; */ }
function print_fdsnws_graph($d = null) { if ($d === null) { date_default_timezone_set('UTC'); $today = offset(date('Y-m-d'), -4); } else { $today = $d; } $pieces = explode('-', $today); $display_year = $pieces[0]; $imgfile = "../data/total-user-{$display_year}_fdsnws.svg"; $txtfile = "../data/total-user-{$display_year}_fdsnws.txt"; // Original is currently 960x480... print '<a href="' . $imgfile . '"><img width="480" height="240" src="' . $imgfile . '" alt="Total data download by fdsnws ' . $display_year . '" /></a>'; print '<a href="' . "../data/sources-user-{$display_year}_fdsnws.svg" . '">Year to date by DCID</a>...'; print '<br />'; print '<p>Summary table for <a href="' . $txtfile . '">' . $display_year . '</a>'; print '<br />'; }
<?php /* OpenLinkMap Copyright (C) 2010 Alexander Matheisen This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See http://wiki.openstreetmap.org/wiki/OpenLinkMap for details. */ require_once "functions.php"; // include translation file includeLocale($_GET['lang']); $format = $_GET['format']; $id = $_GET['id']; $type = $_GET['type']; // offset of user's timezone to UTC $offset = offset($_GET['offset']); $callback = $_GET['callback']; date_default_timezone_set('UTC'); // protection of sql injections if (!isValidType($type) || !isValidId($id)) { echo "NULL"; exit; } // get the most important langs of the user $langs = getLangs(); if ($_GET['lang']) { $langs[0] = $_GET['lang']; } if (!getDetails($db, $id, $type, $langs, $offset)) { echo "NULL"; }
showApiError(300, 'No such item (the guid you provided has no release in our database)'); } break; // Get individual NZB details. // Get individual NZB details. case 'd': if (!isset($_GET['id'])) { showApiError(200, 'Missing parameter (id is required for downloading an NZB)'); } $page->users->addApiRequest($uid, $_SERVER['REQUEST_URI']); $data = $releases->getByGuid($_GET['id']); $relData = []; if ($data) { $relData[] = $data; } printOutput($relData, $outputXML, $page, offset()); break; // Capabilities request. // Capabilities request. case 'c': //get categories $category = new Category(['Settings' => $page->settings]); $cats = $category->getForMenu(); //insert cats into template variable $page->smarty->assign('parentcatlist', $cats); if ($outputXML) { //use apicaps.tpl if xml is requested $response = $page->smarty->fetch('apicaps.tpl'); header('Content-type: text/xml'); header('Content-Length: ' . strlen($response)); echo $response;
function definetomap($zoom, $pid, $filename) { $tb = array('t', 'b'); $lr = array('l', 'r'); $vh = array('vert', 'hori'); $el = array('tlx', 'tly', 'brx', 'bry'); $image = imagecreatefrompng($filename . $pid . ".png"); $width = imagesx($image); $height = imagesy($image); $page = defaultpage($width - 1, $height - 1); $offset = offset($image, false, 0, $page); //draw lines of corner edges $vert = true; $linewidth = 8; $lc = 0; foreach ($offset as $coord) { if ($vert == true) { $top = 0; if ($lc > 3) { $top = $height / $zoom - $height / 4 / $zoom; } //drawing a vertical line so use $coord as $x print "<div style='position: absolute; top:" . $top . "px; left:" . $coord / $zoom . "px; width:" . $linewidth / $zoom . "px; height:" . $height / 4 / $zoom . "px; background-color: blue;'></div>"; $vert = false; } else { //drawing a horizontal line so use $coord as $y $left = 0; if ($lc == 3 || $lc == 7) { $left = $width / $zoom - $width / 4 / $zoom; } print "<div style='position: absolute; top:" . $coord / $zoom . "px; left:" . $left . "px; width:" . $width / 4 / $zoom . "px; height:" . $linewidth / $zoom . "px; background-color: blue;'></div>"; $vert = true; } $lc++; } foreach ($tb as $a) { foreach ($lr as $b) { foreach ($vh as $c) { $vname = "{$a}{$b}" . "_" . $c . "_"; $tlx = $page[strtoupper($vname . "tlx")]; $tly = $page[strtoupper($vname . "tly")]; $brx = $page[strtoupper($vname . "brx")]; $bry = $page[strtoupper($vname . "bry")]; print "<div id='{$vname}' style='position: absolute; top:" . $tly / $zoom . "px; left: " . $tlx / $zoom . "px; width:" . ($brx - $tlx) / $zoom . "px; height:" . ($bry - $tly) / $zoom . "px; background-color: green; opacity: 0.6;' class='drsElement'><div class='drsMoveHandle'>" . $vname . "</div></div>"; } } } $btlx = floor(BARCODE_TLX_PORTION * $width); if ($btlx <= 0) { $btlx = 1; } $btly = floor(BARCODE_TLY_PORTION * $height); if ($btly <= 0) { $btly = 1; } $bbrx = floor(BARCODE_BRX_PORTION * $width); if ($bbrx <= 0) { $bbrx = 1; } $bbry = floor(BARCODE_BRY_PORTION * $height); if ($bbry <= 0) { $bbry = 1; } $barcodeimage = crop($image, array("tlx" => $btlx, "tly" => $btly, "brx" => $bbrx, "bry" => $bbry)); $barcode = barcode($barcodeimage); if ($barcode === false) { $barcode = T_("NO BARCODE DETECTED"); } else { if (strlen($barcode) != BARCODE_LENGTH_PID) { $barcode = T_("Detected but not BARCODE_LENGTH_PID length") . ": " . $barcode; } else { $barcode = T_("Detected") . ": " . $barcode; } } print "<div id='barcodebox' style='position: absolute; top:" . $btly / $zoom . "px; left: " . $btlx / $zoom . "px; width:" . ($bbrx - $btlx) / $zoom . "px; height:" . ($bbry - $btly) / $zoom . "px; background-color: brown; opacity: 0.6;' class='drsElement'><div class='drsMoveHandle'>{$barcode}</div></div>"; }
function newquestionnaire($filename, $desc = "", $type = "pngmono") { global $db; if ($desc == "") { $desc = $filename; } //generate temp file $tmp = tempnam(TEMPORARY_DIRECTORY, "FORM"); //print "Creating PNG files<br/>"; //use ghostscript to convert to PNG exec(GS_BIN . " -sDEVICE={$type} -r300 -sOutputFile=\"{$tmp}\"%d.png -dNOPAUSE -dBATCH \"{$filename}\""); //print("gs -sDEVICE=pngmono -r300 -sOutputFile=$tmp%d.png -dNOPAUSE -dBATCH $filename"); //print "Creating PNG files<br/>"; //add to questionnaire table // //create form entry in DB // $db->StartTrans(); $sql = "INSERT INTO questionnaires (qid,description,sheets)\r\n\t\tVALUES (NULL,'{$desc}',0)"; $db->Execute($sql); $qid = $db->Insert_Id(); //Number of imported pages $pages = 0; //read pages from 1 to n - stop when n does not exist $n = 1; $file = $tmp . $n . ".png"; while (file_exists($file)) { //print "PAGE $n: "; //open file $data = file_get_contents($file); $image = imagecreatefromstring($data); $images = split_scanning($image); unset($image); unset($data); foreach ($images as $image) { //get the data from the image ob_start(); imagepng($image); $data = ob_get_contents(); ob_end_clean(); $width = imagesx($image); $height = imagesy($image); $btlx = floor(BARCODE_TLX_PORTION * $width); if ($btlx <= 0) { $btlx = 1; } $btly = floor(BARCODE_TLY_PORTION * $height); if ($btly <= 0) { $btly = 1; } $bbrx = floor(BARCODE_BRX_PORTION * $width); if ($bbrx <= 0) { $bbrx = 1; } $bbry = floor(BARCODE_BRY_PORTION * $height); if ($bbry <= 0) { $bbry = 1; } $barcode = crop($image, array("tlx" => $btlx, "tly" => $btly, "brx" => $bbrx, "bry" => $bbry)); //imagepng($barcode,"/mnt/iss/tmp/temp$n.png"); //check for barcode $pid = barcode($barcode, 1, BARCODE_LENGTH_PID); //if failed try second location if (!$pid) { $btlx = floor(BARCODE_TLX_PORTION2 * $width); if ($btlx <= 0) { $btlx = 1; } $btly = floor(BARCODE_TLY_PORTION2 * $height); if ($btly <= 0) { $btly = 1; } $bbrx = floor(BARCODE_BRX_PORTION2 * $width); if ($bbrx <= 0) { $bbrx = 1; } $bbry = floor(BARCODE_BRY_PORTION2 * $height); if ($bbry <= 0) { $bbry = 1; } $barcode = crop($image, array("tlx" => $btlx, "tly" => $btly, "brx" => $bbrx, "bry" => $bbry)); //check for barcode $pid = barcode($barcode, 1, BARCODE_LENGTH_PID2); } if ($pid) { $pages++; print T_("BARCODE") . ": {$pid}"; //Don't do these calculations when importing as they need to be set up after the fact //calc offset //$offset = offset($image,0,0); //check if any edges were not detected //if (!in_array("",$offset)) //{ //calc rotation //$rotation = calcrotate($offset); $width = imagesx($image); $height = imagesy($image); $record = defaultpage($width - 1, $height - 1, $qid, $pid, $data); //get page edges $offset = offset($image, 0, 0, $record); $off = array("tlx", "tly", "trx", "try", "blx", "bly", "brx", "bry"); //combine with key $offset = array_combine($off, $offset); //merge $record = array_merge($record, $offset); $db->AutoExecute('pages', $record, 'INSERT'); //save image to db including offset and rotation //$sql = "INSERT INTO pages // (pid,qid,pidentifierbgid,pidentifierval,tlx,tly,trx,try,blx,bly,brx,bry,image,rotation,width,height) // VALUES (NULL,'$qid','1','$pid','{$offset[0]}','{$offset[1]}','{$offset[2]}','{$offset[3]}','{$offset[4]}','{$offset[5]}','{$offset[6]}','{$offset[7]}','" . addslashes($data) . "','$rotation','$width','$height')"; //print $sql; //if ($db->HasFailedTrans()) die($sql); //} //else //{ // $db->FailTrans(); // print "<p>" . T_("FAILED TO IMPORT AS COULD NOT DETECT ALL PAGE EDGES FOR PAGE") . ":$n</p>"; // break 2; //} } else { print T_("INVALID - IGNORING BLANK PAGE"); } unset($data); unset($image); unset($barcode); } $n++; $file = $tmp . $n . ".png"; unset($images); } //no pages were imported - fail if ($pages <= 0) { $db->FailTrans(); print T_("Failed to import as no pages were detected"); } //check if we have created conflicting if ($db->CompleteTrans()) { $n = 1; $file = $tmp . $n . ".png"; while (file_exists($file)) { //delete temp file unlink($file); $n++; $file = $tmp . $n . ".png"; } return $qid; } else { return array(false, $tmp); } }
/** * Detect the rotation, scale and offset of the given image * Use the template page offsets for calculations of scale and offset * */ function detecttransforms($image, $page) { $width = imagesx($image); $height = imagesy($image); $page = sanitizepage($page, $width, $height); $offset = offset($image, false, 0, $page); //correct offset if possible (multiple runs to correct for possible multiple errors) $offset = validate_offset($offset, $page); $offset = validate_offset($offset, $page); $offset = validate_offset($offset, $page); if (!in_array("", $offset)) { $centroid = calccentroid($offset); $rotate = calcrotate($offset); $rotate = $rotate - $page['rotation']; //rotate offset for ($i = 0; $i <= 6; $i += 2) { list($offset[$i], $offset[$i + 1]) = rotate($rotate, array($offset[$i], $offset[$i + 1]), $centroid); } $scale = calcscale($page, $offset); //scale offset for ($i = 0; $i <= 6; $i += 2) { list($offset[$i], $offset[$i + 1]) = scale($scale, array($offset[$i], $offset[$i + 1]), $centroid); } //calc offset $offsetxy = array(); $offsetxy[0] = $page['tlx'] - $offset[0]; $offsetxy[1] = $page['tly'] - $offset[1]; //reverse all values $offsetxy[0] *= -1.0; $offsetxy[1] *= -1.0; $scale[0] = 1.0 / $scale[0]; $scale[1] = 1.0 / $scale[1]; $rotate *= -1.0; $transforms = array('offx' => $offsetxy[0], 'offy' => $offsetxy[1], 'scalex' => $scale[0], 'scaley' => $scale[1], 'centroidx' => $centroid[0], 'centroidy' => $centroid[1], 'costheta' => cos($rotate), 'sintheta' => sin($rotate), 'width' => $width, 'height' => $height); return $transforms; } return array('offx' => 0, 'offy' => 0, 'scalex' => 1, 'scaley' => 1, 'centroidx' => 0, 'centroidy' => 0, 'costheta' => 1, 'sintheta' => 0, 'width' => $width, 'height' => $height); //return no transformation if all edges not detected }
function auto_link() { $isjs = js(); $args = $isjs ? arguments : func_get_args(); if (count($args) === 0) { return ''; } $t = $args[0]; $do_embed = count($args) > 1 && $args[1] !== false; $do_link = count($args) < 3 || $args[2] !== false; $re = auto_link_re(); $ms = preg_matches($re, $t); if (!$ms) { return $t; } $mlen = count($ms); $sp = preg_split($re, $t); $t = ""; $sp[0] = string($sp[0]); for ($i = 0; $i < $mlen; $i += 1) { $mi = $ms[$i]; $spliti = $sp[$i]; $t = strcat($t, $spliti); $sp[$i + 1] = string($sp[$i + 1]); if (substr($sp[$i + 1], 0, 1) === '/') { $sp[$i + 1] = substr($sp[$i + 1], 1, strlen($sp[$i + 1]) - 1); $mi = strcat($mi, '/'); } $spe = substr($spliti, -2, 2); if ((!$spe || !preg_match('/(?:\\=[\\"\\\']?|t;)/', $spe)) && substr(trim($sp[$i + 1]), 0, 3) !== '</a' && !contains('@charset@font@font-face@import@media@namespace@page@ABCDEFGHIJKLMNOPQ@', strcat($mi, '@'))) { $afterlink = ''; $afterchar = substr($mi, -1, 1); while (contains('.!?,;"\')]}', $afterchar) && ($afterchar !== ')' || !contains($mi, '('))) { $afterlink = strcat($afterchar, $afterlink); $mi = substr($mi, 0, -1); $afterchar = substr($mi, -1, 1); } $fe = 0; if ($do_embed) { $fe = strtolower(substr($mi, -4, 1) === '.' ? substr($mi, -4, 4) : substr($mi, -5, 5)); } $wmi = web_address_to_uri($mi, true); $prot = protocol_of_uri($wmi); $hn = hostname_of_uri($wmi); $pa = path_of_uri($wmi); $ih = is_http_uri($wmi); $ahref = '<span class="figure" style="text-align:left">'; $enda = '</span>'; if ($do_link) { $ahref = strcat('<a class="auto-link figure" href="', $wmi, '">'); $enda = '</a>'; } if ($fe && ($fe === '.jpeg' || $fe === '.jpg' || $fe === '.png' || $fe === '.gif' || $fe === '.svg')) { $alt = strcat('a ', offset('photo', $mi) != 0 ? 'photo' : substr($fe, 1)); $t = strcat($t, $ahref, '<img class="auto-embed" alt="', $alt, '" src="', $wmi, '"/>', $enda, $afterlink); } else { if ($fe && ($fe === '.mp4' || $fe === '.mov' || $fe === '.ogv' || $fe === '.webm')) { $t = strcat($t, $ahref, '<video class="auto-embed" ', 'controls="controls" src="', $wmi, '"></video>', $enda, $afterlink); } else { if ($hn === 'vimeo.com' && ctype_digit(substr($pa, 1))) { if ($do_link) { $t = strcat($t, '<a class="auto-link" href="', 'https:', relative_uri_hash($wmi), '">', $mi, '</a> '); } $t = strcat($t, '<iframe class="vimeo-player auto-embed figure" width="480" height="385" style="border:0" src="', 'https://player.vimeo.com/video/', substr($pa, 1), '"></iframe>', $afterlink); } else { if ($hn === 'youtu.be' || ($hn === 'youtube.com' || $hn === 'www.youtube.com') && ($yvid = offset('watch?v=', $mi)) !== 0) { if ($hn === 'youtu.be') { $yvid = substr($pa, 1); } else { $yvid = explode('&', substr($mi, $yvid + 7)); $yvid = $yvid[0]; } if ($do_link) { $t = strcat($t, '<a class="auto-link" href="', 'https:', relative_uri_hash($wmi), '">', $mi, '</a> '); } $t = strcat($t, '<iframe class="youtube-player auto-embed figure" width="480" height="385" style="border:0" src="', 'https://www.youtube.com/embed/', $yvid, '"></iframe>', $afterlink); } else { if ($mi[0] === '@' && $do_link) { if ($sp[$i + 1][0] === '.' && $spliti != '' && ctype_email_local(substr($spliti, -1, 1))) { $t = strcat($t, $mi, $afterlink); } else { $t = strcat($t, '<a class="auto-link h-x-username" href="', $wmi, '">', $mi, '</a>', $afterlink); } } else { if ($do_link) { $t = strcat($t, '<a class="auto-link" href="', $wmi, '">', $mi, '</a>', $afterlink); } else { $t = strcat($t, $mi, $afterlink); } } } } } } } else { $t = strcat($t, $mi); } } return strcat($t, $sp[$mlen]); }