function pingFeedManager($newfeed_url = null)
 {
     global $FEEDMANAGER_HOST, $FEEDMANAGER_PATH;
     displayDebug("pinging FeedManager: " . "http://" . $FEEDMANAGER_HOST . $FEEDMANAGER_PATH . "?url=" . "http://" . $newfeed_url, 3);
     $response = file("http://" . $FEEDMANAGER_HOST . $FEEDMANAGER_PATH . "?url=" . "http://" . $newfeed_url);
     return $response;
 }
示例#2
0
 function query($query)
 {
     displayDebug("function query", 4);
     displayDebug("query: " . $query, 4);
     displayDebugParam($r, 4);
     $r = new resultset_abstract($query, $this->db);
     return $r;
 }
    function saveFNAnnotationFeed($fn_image, $fn_annotation)
    {
        global $FN_FEED_STYLESHEET_PATH;
        // BUILD *feed xml*
        // SET *style sheet path*
        $feed_stylesheet = $FN_FEED_STYLESHEET_PATH;
        displayDebug("feed_stylesheet: {$feed_stylesheet}", 3);
        // SET *feed file path* from annotation param
        $feed_file_path = $fn_annotation->param["feed_file_path"];
        // SET Other params
        $feed_uuid = $fn_annotation->param["feed_uuid"];
        $created = $fn_image->param["timestamp"];
        // SET *xml head*
        $xml_prefix = <<<EOD
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href='{$feed_stylesheet}' type='text/css'?>
<feed version="0.3"
     xmlns="http://purl.org/atom/ns#"
     xmlns:ps="http://pubsub.com/xmlns"
     xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en"
     xmlns:fn="http://fotonotes.net/protocol/fotonotes_0.2"
>

EOD;
        displayDebug("feed_file_path(2): " . $feed_file_path, 3);
        // SET additional prefix information
        // NEED to improve link href that specifes $feed_file_path
        $xml_prefix_additional = <<<EOD
<title mode='escaped' type='text/html'>FotoNotes(tm) Feed</title>
<link href='{$_SERVER[path]}/{$feed_file_path}' rel='service.post' 
title='FotoNotes(tm) Feed' type='application/atom+xml'/>
<id>{$feed_uuid}</id>
<issued>{$created}</issued>
<created>{$created}</created> 
<modified>{$created}</modified>
<generator url='fotonotes.php' version='0.70'>FotoNotes(tm) Annotation Script</generator>
<author><name>FotoNotes(tm) Annotatator</name></author>
<info mode='xml' type='text/html'>This is a FotoNotes Image Annotation Feed</info>
EOD;
        // SET *xml* suffix
        $xml_suffix = "\n</feed>";
        // assemble full feed
        $newfeed_xml = $xml_prefix . $xml_prefix_additional . $fn_annotation->param["xml_entryinfo"] . $xml_suffix;
        // WRITE *feed xml* to filesystem
        $handle = fopen($feed_file_path, 'w');
        fwrite($handle, $newfeed_xml);
        fclose($handle);
    }
 function fn_makeImage($photographName, $selectionToPhotographRectangle = null, $zoom = 1, $width = null, $height = null, $filepath = null)
 {
     $imageSpecs = getimagesize($photographName);
     $extension = substr($photographName, -4);
     switch (strtolower($extension)) {
         case '.jpg':
             $image = imageCreateFromJpeg($photographName);
             break;
         case '.png':
             $image = imageCreateFrompng($photographName);
             break;
         case '.gif':
             $image = imageCreateFromGif($photographName);
             break;
         default:
             $image = imageCreateFromJpeg($photographName);
             break;
     }
     // try to split bounding box on comma ','
     $coordiantesArray = split(",", $selectionToPhotographRectangle);
     if (!$coordiantesArray[1]) {
         // try to split on space ' '
         $coordiantesArray = split(" ", $selectionToPhotographRectangle);
     }
     if (!$coordiantesArray[1]) {
         // still no split? use whole image
         $coordiantesArray = array(0, 0, $imageSpecs[0], $imageSpecs[1]);
     }
     // translate boundingbox's x1,y1,x2,y2 to x1,y1,w,h
     $fn_x1 = $coordiantesArray[0];
     $fn_y1 = $coordiantesArray[1];
     $fn_w = $coordiantesArray[2] - $coordiantesArray[0];
     $fn_h = $coordiantesArray[3] - $coordiantesArray[1];
     if (!$zoom) {
         // no zoom? give full size
         $zoom = 1;
     }
     displayDebug("selection: {$selectionToPhotographRectangle}", 3);
     displayDebug("\n{$fn_x1} | {$fn_y1} | {$fn_w} | {$fn_h} ", 3);
     // adjust for width and height params if passed
     if ($width && !$height) {
         $height = $width * $imageSpecs[1] / $imageSpecs[0];
     } else {
         if (!$width) {
             $width = $fn_w * $zoom;
         }
         if (!$height) {
             $height = $fn_h * $zoom;
         }
     }
     // let's grabbed the region
     #$croppedImage=ImageCreate($width, $height);
     $croppedImage = imagecreatetruecolor($width, $height);
     imagecopyresized($croppedImage, $image, 0, 0, $coordiantesArray[0], $coordiantesArray[1], $width, $height, $fn_w, $fn_h);
     $image = $croppedImage;
     if ($filepath) {
         // output to file
         switch (strtolower($extension)) {
             // send to browser with proper header
             case '.jpg':
                 imagejpeg($image, $filepath);
                 break;
             case '.png':
                 imagepng($image, $filepath);
                 break;
             case '.gif':
                 imageGif($image, $filepath);
                 break;
             default:
                 imagejpeg($image, $filepath);
                 break;
         }
     } else {
         // output to browser
         switch (strtolower($extension)) {
             // send to browser with proper header
             case '.jpg':
                 header('Content-Type: image/jpeg');
                 imagejpeg($image);
                 break;
             case '.png':
                 header('Content-Type: image/png');
                 imagepng($image);
                 break;
             case '.gif':
                 header('Content-Type: image/gif');
                 imageGif($image);
                 break;
             default:
                 header('Content-Type: image/jpeg');
                 imagejpeg($image);
                 break;
         }
     }
     // delete image from memory
     imagedestroy($image);
     return true;
 }
 public static function staticSetTagAttribute($string, $tag, $attribute, $attvalue, $onematch = true, $retstring = true, $debug = false)
 {
     // For a given tag, set an attribute value.
     $matched = false;
     $retmatch = false;
     $tag = str_replace("<", "", $tag);
     $tag = str_replace(">", "", $tag);
     $tag = "<" . $tag;
     $pos = strpos($string, $tag);
     if ($pos !== false) {
         // Found at least one tag
         $all_tags = explode($tag, $string);
         if ($debug) {
             echo "<!-- perseverate! ";
             print_r($all_tags);
             echo "-->";
         }
         foreach ($all_tags as $sstring) {
             $pos2 = strpos($sstring, ">");
             // if index starts with < , it could be a surious set of tag matches .. .should be skipped
             if (substr($sstring, 0, 1) != "<" && !empty($sstring)) {
                 $ss_old = $sstring;
                 $sstring = substr($sstring, 0, $pos2);
                 // text string of tag
                 $attributes = preg_split("/[\"'] +/", $sstring);
                 // match against truncated string
             } else {
                 $attributes = array();
             }
             // it'll skip the foreach loop
             // Loop over all attributes
             foreach ($attributes as $test) {
                 $test = trim($test);
                 if (strpos($test, $attribute) !== false && $matched === false) {
                     // Potential attribute match
                     $pos3 = strpos($test, "=");
                     $matchstring = $attribute . "=";
                     if (substr($test, 0, $pos3 + 1) == $matchstring) {
                         // Matching attribute found
                         $value = substr($test, $pos3 + 2);
                         // old attribute value
                         if ($value == $attvalue) {
                             if ($onematch) {
                                 $matched = true;
                             }
                             // so it won't find subsequent instances
                             $retmatch = true;
                             // for the purposes of returning, a match was found
                         } else {
                             // stitch together a new tag
                             if ($onematch) {
                                 $matched = true;
                             }
                             // so it won't find subsequent instances
                             $retmatch = true;
                             // for the purposes of returning, a match was found
                             $newtag = trim($tag);
                             foreach ($attributes as $el) {
                                 if (strpos($el, $matchstring) === false) {
                                     if (substr($el, -1) == "'") {
                                         $el = substr($el, 0, -1);
                                     }
                                     $newtag .= " " . $el . "'";
                                     //#echo "Stiched on \"$el\" \n";
                                 } else {
                                     // sanitize out the attribute value
                                     $elout = $matchstring . "'" . $attvalue . "'";
                                     $newtag .= " " . $elout;
                                 }
                             }
                             // put the rest of the tag info on
                             $newtag = $newtag . substr($ss_old, $pos2);
                             break;
                             // break out of the foreach loop
                         }
                     }
                     // keep looping if not found
                 } else {
                     if ($matched === true) {
                         $sstring = trim($tag) . $ss_old;
                     }
                 }
                 // to properly fill in
             }
             // Attribute not found in list of attributes for this tag.
             if (!empty($newtag)) {
                 $sstring = $newtag;
             }
             // break the tag seach
             $newtag = "";
             // empty out new tag
             $new_buffer .= $sstring;
         }
         // This tag instance fails. Repeat next tag
         if (!$retmatch) {
             // no match, but there is a tag. Add the attribute.
             // start with $string, since no changes have been made.
             if ($debug) {
                 echo "<!-- This is what we're checking -->";
             }
             $i = 0;
             // Re-find the tag, append to instances as specified.
             foreach ($all_tags as $sstring) {
                 $pos2 = strpos($sstring, ">");
                 if (substr($sstring, 0, 1) != "<" && !empty($sstring)) {
                     // fix appending to first tag
                     //if($i=0) $i=1; // since the implode will throw the tag between [0] and [1]
                     $all_tags[$i] = " " . $attribute . "='" . $attvalue . "'" . $sstring;
                     if ($debug) {
                         echo "<!-- Just set alltags element {$i}: ." . $all_tags[$i] . " -->";
                     }
                     if ($onematch) {
                         break;
                     }
                 }
                 $i++;
             }
             if ($debug) {
                 echo displayDebug(print_r($all_tags, true));
             }
             $new_buffer = implode($tag, $all_tags);
         }
         if ($retstring) {
             return $new_buffer;
         } else {
             return true;
         }
     }
     // If no tag matches at all, return a failure or the same string. Don't create a new tag.
     if ($retstring) {
         return $string;
     } else {
         return false;
     }
     // found no matching tags at all
 }
 function getAnnotations(&$fn_image)
 {
     // The $fn_image must be passed by reference because this functions sets parameters.
     $DHTML_MAXWIDTH = $fn_image->param['width'];
     $DHTML_MAXHEIGHT = $fn_image->param['height'];
     //$this->image = $fn_image->param['image'];
     $this->image = $fn_image->param['image_path'];
     displayDebug('FNRetrieveJPEGHeader called & image is ' . $this->image, 4);
     //$imageinfo = $this->getImageInfo($imagefile);
     //$size = getimagesize($imageinfo['image_src']);
     $size = getimagesize($this->image);
     displayDebugParam($size, 4);
     $ratioWidth = $DHTML_MAXWIDTH / $size[0];
     $ratioHeight = $DHTML_MAXHEIGHT / $size[1];
     if ($ratioHeight > $ratioWidth) {
         $ratio = $ratioWidth;
     } else {
         $ratio = $ratioHeight;
     }
     if ($ratio > 1) {
         $ratio = 1;
     }
     $fn_image->setFnImageParam('scalefactor', $ratio);
     $this->annotationXMLBlock = $this->getAnnotationsXMLBlockFromJPEGHeader();
     $fn_image->setFnImageParam("annotationXMLBlock", $this->annotationXMLBlock);
     //return $this->annotationXMLBlock;
     //$xml = $this->readFotonotesXML($imagefile); // from older code
     $xml = $this->annotationXMLBlock;
     preg_match_all("#<entry>(.*)</entry>#Umsi", $xml, $entries);
     foreach ($entries[1] as $entry) {
         preg_match("#<fn:boundingBox>(.*)</fn:boundingBox>#Umsi", $entry, $coordstring);
         $coords = explode(",", $coordstring[1]);
         list($annotation['upperleftx'], $annotation['upperlefty'], $annotation['lowerrightx'], $annotation['lowerrighty']) = $coords;
         //$annotation['width'] = ($coords[2] - $coords[0])*$ratio;
         $annotation['width'] = ($coords[2] - $coords[0]) * $ratio;
         $annotation['height'] = ($coords[3] - $coords[1]) * $ratio;
         $annotation['upperlefty'] *= $ratio;
         $annotation['upperleftx'] *= $ratio;
         $annotation['lowerrightx'] *= $ratio;
         $annotation['lowerrighty'] *= $ratio;
         preg_match("#<title>(.*)</title>#Umsi", $entry, $title);
         $annotation['title'] = $title[1];
         preg_match("#<content.*>(.*)</content>#Umsi", $entry, $content);
         $annotation['content'] = $content[1];
         preg_match("#<name>(.*)</name>#Umsi", $entry, $author);
         $annotation['author'] = $author[1];
         preg_match("#<created>(.*)</created>#Umsi", $entry, $created);
         $annotation['created'] = $created[1];
         preg_match("#<issued>(.*)</issued>#Umsi", $entry, $issued);
         $annotation['issued'] = $issued[1];
         preg_match("#<modified>(.*)</modified>#Umsi", $entry, $modified);
         $annotation['modified'] = $modified[1];
         preg_match("#<id>(.*)</id>#Umsi", $entry, $id);
         //$annotation['id'] = basename($id[1]);  Do not get basename, use full url
         $annotation['id'] = $id[1];
         $annotations[] = $annotation;
     }
     return $annotations;
 }
示例#7
0
$fni->setFnImageParam("image_path", $_SERVER['DOCUMENT_ROOT'] . $fni->param['url_parts']['path']);
displayDebug("image_path: " . $fni->param['image_path'], 4);
displayDebug("action: " . $fni->param['action'], 2);
// CLEANUP incoming XML from client, if exists
if ($fni->fnImageParamExists("xml")) {
    $fni->param["xml"] = preg_replace("#<\\?xml.*>#Umsi", "", $fni->param["xml"]);
    $fni->param["xml"] = preg_replace("#<feed.*>#Umsi", "", $fni->param["xml"]);
    $fni->param["xml"] = preg_replace("#</feed>#Umsi", "", $fni->param["xml"]);
    $fni->param["xml"] = stripslashes($fni->param["xml"]);
    // Determine username by userid
    preg_match("#<userid>(.*)</userid>#", $fni->param["xml"], $matches);
    $userid = $matches[1];
    $username = $FN_USER->getDisplayNameByUserID($userid);
    $fni->setFnImageParam("username", $username);
    $userpropername = $FN_USER->getProperNameByUserID($userid);
    $fni->setFnImageParam("userpropername", $userpropername);
    $fni->param["xml"] = preg_replace("#<name>.*</name>#Umsi", "<name>{$userpropername}</name>", $fni->param["xml"]);
}
// DO the requested action
if ($fni->fnImageParamExists("action")) {
    $fni->doFnAction();
}
displayDebug("Done.", 1);
// DONE with proceedure. Rest of file are functions and classes.
/* ABSTRACT CLASSES */
/*
To create a new UUID, instatiate the class, and call the method using:
		$CreateUUID = new UUID;
		$UUID = $CreateUUID->GenUUID();
*/
/* ADDITIONAL DOCUMENTATION */
     $token = $_REQUEST['token'];
     $userToActivate = $_REQUEST['user'];
     $encoded_key = $_REQUEST['key'];
     $result = $user->verifyUserAuth($encoded_key, $token, $userToActivate);
     if ($result['status'] === false) {
         $login_output .= "<div class='alert alert-warning'><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>&times;</span></button><h1>Could not verify user</h1><p>" . $result['message'] . "</p></div>";
     } else {
         if ($result["admin_confirm_sent"] && $result["user_confirm_sent"]) {
             $messageFollowUp = "Check your inbox for a confirmation.";
         } else {
             $messageFollowUp = "<strong>However, not all confirmations could not be sent</strong> (" . $result["error"] . ").";
         }
         $login_output .= "<div class='alert alert-info'><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>&times;</span></button><p>The user was successfully activated. {$messageFollowUp}</p></div>";
     }
     if ($debug) {
         echo displayDebug($result);
     }
 } else {
     if (isset($_REQUEST['2fa'])) {
         if ($logged_in && !$user->has2FA()) {
             # Give user 2FA
             $totp_add_form = "<section id='totp_add' class='row'>\n  <div id='totp_message' class='alert alert-info col-xs-12 col-md-6 force-center'>Two factor authentication is very secure, but when you enable it, you'll be unable to log in without your mobile device.</div>\n  <form id='totp_start' onsubmit='event.preventDefault();' class='col-xs-12 clearfix'>\n    <fieldset>\n      <legend>Login to continue</legend>\n      <div class='form-group'>\n        <label for='username' class='sr-only'>Username:</label>\n        <input type='email' value='" . $user->getUsername() . "' readonly='readonly' id='username' name='username' class='form-control'/>\n      </div>\n      <div class='form-group'>\n        <label for='password' class='sr-only'>Password:</label>\n        <input type='password' id='password' name='password' placeholder='Verify Password' class='form-control'/>\n      </div>\n      <input type='hidden' id='secret' name='secret' value='" . $_COOKIE[$cookiekey] . "'/>\n      <input type='hidden' id='hash' name='hash' value='" . $_COOKIE[$cookieauth] . "'/>\n      <br/>\n      <button id='add_totp_button' class='totpbutton btn btn-primary'>Add Two-Factor Authentication</button>\n    </fieldset>\n  </form>\n  <div class='alert force-center col-xs-12 col-md-6'>\n    <button id='totp_help' class='alert-link btn btn-link'>Help with Two-Factor Authentication</button>\n  </div>\n</section>";
             if ($require_two_factor) {
                 $totp_add_form = "<h1>This site requires two-factor authentication</h1><h2>Please set up two-factor authentication to continue.</h2>" . $totp_add_form;
             }
             $login_output .= $totp_add_form;
         } else {
             if ($logged_in && $user->has2FA()) {
                 # Remove 2FA from the user
                 $totp_remove_form = "<section id='totp_remove_section' class='row'>\n    <div id='totp_message' class='alert alert-warning col-xs-12 col-md-6 force-center'>Are you sure you want to disable two-factor authentication?</div>\n  <form id='totp_remove' onsubmit='event.preventDefault();' class='form-horizontal col-xs-12 clearfix'>\n    <fieldset>\n      <legend>Remove Two-Factor Authentication</legend>\n      <input type='email' value='" . $user->getUsername() . "' readonly='readonly' id='username' name='username'/><br/>\n      <input type='password' id='password' name='password' placeholder='Password'/><br/>\n      <input type='text' id='code' name='code' placeholder='Authenticator Code or Backup Code' size='32' maxlength='32' autocomplete='off'/><br/>\n      <button id='remove_totp_button' class='totpbutton btn btn-danger'>Remove Two-Factor Authentication</button>\n    </fieldset>\n  </form>\n</section>";
                 $login_output .= $totp_remove_form;
 function generateFnImageAnnotationXmlV03()
 {
     // make sure <entry>...<entry> is clearly generated
     global $FN_FEED_PATH, $FN_FEED_STYLESHEET_PATH, $FN_FOTONOTES_DATA_PATH_PREFIX, $FILETYPES;
     global $ANNOTATIONS_ORIGINALS_FOLDER, $ANNOTATIONS_THUMBNAILS_FOLDER;
     $xml = null;
     // get unique uuid for feed
     $feed_uuid = getNewUUID();
     $this->param["feed_uuid"] = $feed_uuid;
     // get feed file destination based on today's date
     $createdtime = time();
     $year = gmdate("Y", $createdtime);
     $month = gmdate("m", $createdtime);
     $day = gmdate("d", $createdtime);
     $created = gmdate("Y-m-d\\TH:i:s\\Z", $createdtime);
     $storagepath = $FN_FEED_PATH . $year . "/" . $month . "/" . $day;
     $feed_file_path = $storagepath . "/" . $feed_uuid . ".xml";
     $this->param["feed_file_path"] = $feed_file_path;
     displayDebug("feed_file_path: {$feed_file_path}", 3);
     displayDebug("param[feed_file_path]: " . $this->param["feed_file_path"], 3);
     //make sure path exists
     createPath($storagepath);
     // parse incoming xml
     displayDebug("this->param[src_xml]", 2);
     displayDebugParam($this->param["src_xml"], 2);
     $entry_array = $this->parseEntryXML($this->param["src_xml"]);
     // ASSIGN *entry_array* values to *annotations* params
     foreach ($entry_array as $key => $value) {
         $this->setFnImageAnnotationParam($key, $value);
     }
     // fix uuid
     // first transform existing <id> in xml to <fn:id>
     //$xml = preg_replace("#<id>(.*)</id>#","<fn2:id>$1</fn2:id>",$xml);
     $this->param["src_xml"] = preg_replace("#<id>(.*)</id>#", "<fn:id>\$1</fn:id>", $this->param["src_xml"]);
     $entry_uuid = "<id>{$entry_array['id']}</id>\n";
     $parent_entry_id = $entry_array['parent_id'];
     $parent_entry_uuid = "<parent_uuid>" . $entry_array['parent_id'] . "</parent_uuid>";
     $parent_entry_array = null;
     //getEntriesXML2Array($parent_entry_id);
     //echo "\ngeom: ".$parent_entry_array['geometry']. "\n";
     $entry_geometry = "<geometry>" . $parent_entry_array['geometry'] . "</geometry>";
     // SET parent_image_link in fn_anntoation
     $this->param["parent_link_jpg"] = $parent_entry_array["link_jpg"];
     // PREPARE *make image* parameters
     displayDebug("<p>parent_entry_array: {$parent_entry_array}", 2);
     displayDebugParam($parent_entry_array, 2);
     $annotation_storagepath = $ANNOTATIONS_ORIGINALS_FOLDER . "/" . $year . "/" . $month . "/" . $day;
     displayDebug("annotation_storagepath: {$annotation_storagepath}", 1);
     // CHECK AND CREATE  *file path*
     createPath($annotation_storagepath);
     // PREPARE xml links for section of photo
     $entry_link_jpg = "http://" . $_SERVER['HTTP_HOST'] . preg_replace("#/fns/fotonotes.php#", "", $_SERVER['REQUEST_URI']) . $annotation_storagepath . '/' . $entry_array[id] . '.jpg';
     $entry_link_jpg = "http://" . $_SERVER['HTTP_HOST'] . preg_replace("#/fns/fotonotes2.php#", "", $_SERVER['REQUEST_URI']) . $annotation_storagepath . '/' . $entry_array[id] . '.jpg';
     displayDebug("\$entry_link_jpg: {$entry_link_jpg}", 3);
     // this won't always be jpg
     $entry_mimetype = "image/jpg";
     $entry_annotation_link = "<link href=\"{$entry_link_jpg}\" rel=\"annotated_region\" type=\"{$entry_mimetype}\" />";
     $entry_jpg_link = "<link href=\"{$entry_link_jpg}\" rel=\"jpg\" type=\"{$entry_mimetype}\" />";
     // WRITE annotated section of photo to file system
     displayDebug("\n fn_makeImage ({$parent_entry_array['link_jpg']}, " . str_replace(",", " ", $entry_array[boundingbox]) . ", 1,\n\t\t\tnull, null, {$annotation_storagepath}.'/'.{$entry_array['id']}.'.jpg')");
     fn_makeImage($parent_entry_array['link_jpg'], str_replace(",", " ", $entry_array[boundingbox]), 1, null, null, $annotation_storagepath . '/' . $entry_array[id] . '.jpg', 1);
     // PREPARE *make image* parameters for *thumbnail* of annotated region
     $annotation_thumbnail_storagepath = $ANNOTATIONS_THUMBNAILS_FOLDER . "/" . $year . "/" . $month . "/" . $day;
     displayDebug("annotation_storagepath: {$annotation_thumbnail_storagepath}", 3);
     // calculate thumbscale factor	- This needs to be better, to actually calculate scale!
     $thumbscale = 1;
     // CHECK AND CREATE  *file path* for *thumbnail* of annotated region
     createPath($annotation_thumbnail_storagepath);
     // PREPARE xml links for *thumbnail* of annotated region
     $entry_thumbnail_link_jpg = "http://" . $_SERVER['HTTP_HOST'] . preg_replace("#/fns/fotonotes.php#", "", $_SERVER['REQUEST_URI']) . $annotation_thumbnail_storagepath . '/' . $entry_array[id] . '.jpg';
     $entry_thumbnail_link_jpg = "http://" . $_SERVER['HTTP_HOST'] . preg_replace("#/fns/fotonotes2.php#", "", $_SERVER['REQUEST_URI']) . $annotation_thumbnail_storagepath . '/' . $entry_array[id] . '.jpg';
     // this won't always be jpg
     $entry_mimetype = "image/jpg";
     $entry_mimetype_thn = "image/thn-jpg";
     $entry_thumbnail_link = "<link href=\"{$entry_link_jpg}\" rel=\"annotated region image\" type=\"{$entry_mimetype}\" />";
     $entry_annotation_thumbnail_link = "<link href=\"{$entry_thumbnail_link_jpg}\" rel=\"thn\" type=\"{$entry_mimetype_thn}\" />";
     // this won't always be jpg
     $parent_entry_mimetype = "image/jpg";
     $parent_entry_url = "";
     $parent_entry_link = "<link href=\"\" rel=\"annotated image\" type=\"{$parent_entry_mimetype}\" />";
     // WRITE *thumbnail of annotated section of photo to file system
     fn_makeImage($parent_entry_array['link_jpg'], str_replace(",", " ", $entry_array[boundingbox]), $thumbscale, null, null, $annotation_thumbnail_storagepath . '/' . $entry_array[id] . '.jpg');
     // Almost done - just need to create annotation entry xml, store it properly, and put feed on file system.
     // BUILD *annotation entry xml*
     // this needs fixing - what should $xml be that is getting replaced?
     $xml_entryinfo = preg_replace("#<entry>#", "<entry title=\"FotoNotes Annotation\" type=\"fn\" " . " xmlns:fn=\"http://fotonotes.net/protocol/fotonotes_0.2\">" . $entry_uuid . $entry_geometry . $entry_jpg_link . $entry_annotation_link . $entry_annotation_thumbnail_link . $parent_entry_uuid, $this->param["src_xml"]);
     $xml_entryinfo = preg_replace("#<([a-zA-Z])#", "\n<\$1", $xml_entryinfo);
     $xml_entryinfo = preg_replace("#</fn:selection>#", "\n</fn:selection>", $xml_entryinfo);
     $xml_entryinfo = preg_replace("#</author>#", "\n</author>", $xml_entryinfo);
     $xml_entryinfo = preg_replace("#</entry>#", "\n</entry>", $xml_entryinfo);
     displayDebug("xml_entryinfo: ", 2);
     displayDebugParam($xml_entryinfo, 2);
     $this->param["xml_entryinfo"] = $xml_entryinfo;
     displayDebug("generateFnImageAnnotationXml xml_entryinfo:", 2);
     displayDebugParam($this->param["xml_entryinfo"]);
     return $this->param["xml_entryinfo"];
 }
      </div>
      <div>
        <h3>Show User Data</h3>
<?php 
try {
    if ($u->validateUser()) {
        ?>
        <form action='?t=show' method='post'>
          <p>User: <?php 
        echo $_COOKIE[$cookieuser];
        ?>
</p>
          <input type='password' name='pw' placeholder='password'/><br/>
          <input type='submit'/>
        </form>
        <?php 
    } else {
        echo "Please log in above to test this.";
    }
} catch (Exception $e) {
    echo "You've not logged in. Please log in above to test this.";
}
if ($_REQUEST['t'] == 'show') {
    echo displayDebug($u->lookupUser($_COOKIE[$cookieuser], $_POST['pw']));
}
?>
      </div>
    </article>
  </body>
</html>
    <title>
      PHP Core tests
    </title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"/>
    <style type="text/css">
    .panel, .alert{ max-width: 80%; }
    code { white-space: pre-wrap; }
    </style>
  </head>
  <body>
      <div class='page-header'><h1>PHP Core tests</h1></div>
    <?php 
require_once "../core.php";
echo "All is well in load-land.<br/>";
?>
<p>Beginning tests</p>
<?php 
# Markdown
echo "<section class='panel panel-primary center-block'><div class='panel-heading'>Markdown Tests</div>";
echo "Raw input:<br/><br/>";
$text = "Here is some **Markdown** text that I *really* want to parse. What about [b]Classic options[/b]? How about greek? [grk]npLl[/grk]";
echo "<code class='center-block text-center'>{$text}</code><br/>";
$html = Wysiwyg::toHtml($text);
echo "<div class='alert alert-success center-block'>{$html}<br/><code>" . displayDebug($html, false) . "</code></div>";
echo "<br/>This de-parses as: <div class='alert alert-success center-block'><code>" . Wysiwyg::fromHtml($html) . "</code></div>";
echo "Full detail: <code>" . displayDebug(Wysiwyg::toHtml($text, true), false) . displayDebug(Wysiwyg::fromHtml($html, true), false) . "</code>";
echo "</section>";
?>
  </body>
</html>
示例#12
0
 function writeJPEGHeaders($fn_image, $fn_annotation)
 {
     global $LOCALPATH, $ADD, $MODIFY, $DELETE;
     // ADD or REPLACE existing annotation block in JPEG with new annotation block
     // The annototation block that is written must contain all annotations, new and pre-existing
     // GET *image file path* on the server
     $this->image = $fn_image->param['image_path'];
     displayDebug("image_path is: " . $this->image, 4);
     // Is image writable?
     if (!is_writable($this->image)) {
         echo "success=501";
         die;
     }
     // SET the FotoNotes image header number for a jpeg
     $this->ISTHeaderNumber = 8;
     displayDebug("WriteJPEGHeaders for image: " . $this->image, 4);
     displayDebug("New annotation received from fnclient (fn_annotation->param['src_xml']): " . $fn_annotation->param['src_xml'], 4);
     if ($fn_image->param['annotationXMLBlock'] == null) {
         // xml block does not exists, so create it an add new annotation as first entry
         if ($newtitle == '') {
             $newtitle = basename($filename);
         }
         $header = '<?xml version="1.0" encoding="UTF-8"?>';
         $header .= '<feed version="0.2" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en" xmlns:fn="http://fotonotes.net/protocol/fotonotes_0.2">';
         //$header .= '<copyright>Copyright (c) 2004, Greg Elin</copyright>';
         $header .= "<id>" . $fn_image->param['image'] . "</id>";
         $header .= "<created>" . $fn_image->param['timestamp'] . "</created>";
         $header .= "<modified>" . $fn_image->param['timestamp'] . "</modified>";
         $header .= "<title>" . $fn_image->param['title'] . "</title>";
         //$header .= '<link rel="alternate" type="text/html" href="' . $LOCALPATH . '?p=' . $filename . '" />';
         // SET annotationXMLBlock and include new annotation
         $fn_image->param['annotationXMLBlock'] = $header . $fn_annotation->param['src_xml'] . "</feed>";
     } else {
         // xml block already exists, I need to append new entry
         $fn_image->param['annotationXMLBlock'] = preg_replace("#</feed>#Umsi", $fn_annotation->param['src_xml'] . "</feed>", $fn_image->param['annotationXMLBlock']);
     }
     displayDebug("New Annotation Block to be put into jpeg header is: " . $fn_image->param['annotationXMLBlock'], 4);
     $text = $fn_image->param['annotationXMLBlock'];
     $imageIn = fopen($this->image, "rb");
     while (($char = fgetc($imageIn)) > -1) {
         $charValue = hexdec(bin2hex($char));
         if ($charValue == 0xff) {
             $char2 = fgetc($imageIn);
             if ($char2 < 0) {
                 break;
             }
             $charValue2 = hexdec(bin2hex($char2));
             if ($charValue2 == 0xe0 + $this->ISTHeaderNumber) {
                 $length = hexdec(bin2hex(fgetc($imageIn) . fgetc($imageIn)));
                 if ($length < 2) {
                     $length = 2;
                 }
                 fread($imageIn, $length - 2);
             } elseif ($charValue2 > 0xe0 && $charValue2 < 0xe0 + $this->ISTHeaderNumber) {
                 $lenA = fgetc($imageIn);
                 $lenB = fgetc($imageIn);
                 $newImage .= $char . $char2 . $lenA . $lenB;
                 $length = hexdec(bin2hex($lenA . $lenB));
                 if ($length < 2) {
                     $length = 2;
                 }
                 $newImage .= fread($imageIn, $length - 2);
             } else {
                 if ($charValue2 < 0xe0 && $charValue2 != 0xd8 || $charValue2 > 0xe0 + $this->ISTHeaderNumber) {
                     if (strlen($text) > 0) {
                         $length = str_pad(dechex(strlen($text) + 2), 4, "0", STR_PAD_LEFT);
                         $newImage .= pack("H*", "FFe" . $this->ISTHeaderNumber . $length) . $text;
                     }
                     $newImage .= $char;
                     $newImage .= $char2;
                     break;
                 }
                 $newImage .= $char;
                 $newImage .= $char2;
             }
         } else {
             $newImage .= $char;
         }
     }
     $newImage .= @fread($imageIn, @filesize($this->image));
     fclose($imageIn);
     if (!($this->imageOut = @fopen($this->image, 'wb'))) {
         die("success=Error!\n\nCouldn't add annotation because \"" . $this->image . "\" isn't writable!");
     }
     fwrite($this->imageOut, $newImage);
     fclose($this->imageOut);
     return true;
 }
示例#13
0
/**
 * Ends execution.
 *
 * What it does:
 * - Takes care of template loading and remembering the previous URL.
 * - Calls ob_start() with ob_sessrewrite to fix URLs if necessary.
 *
 * @param bool|null $header = null
 * @param bool|null $do_footer = null
 * @param bool $from_index = false
 * @param bool $from_fatal_error = false
 */
function obExit($header = null, $do_footer = null, $from_index = false, $from_fatal_error = false)
{
    global $context, $txt;
    static $header_done = false, $footer_done = false, $level = 0, $has_fatal_error = false;
    // Attempt to prevent a recursive loop.
    ++$level;
    if ($level > 1 && !$from_fatal_error && !$has_fatal_error) {
        exit;
    }
    if ($from_fatal_error) {
        $has_fatal_error = true;
    }
    // Clear out the stat cache.
    trackStats();
    // If we have mail to send, send it.
    if (!empty($context['flush_mail'])) {
        // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
        AddMailQueue(true);
    }
    $do_header = $header === null ? !$header_done : $header;
    if ($do_footer === null) {
        $do_footer = $do_header;
    }
    // Has the template/header been done yet?
    if ($do_header) {
        // Was the page title set last minute? Also update the HTML safe one.
        if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) {
            $context['page_title_html_safe'] = Util::htmlspecialchars(un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
        }
        // Start up the session URL fixer.
        ob_start('ob_sessrewrite');
        call_integration_buffer();
        // Display the screen in the logical order.
        template_header();
        $header_done = true;
    }
    if ($do_footer) {
        // Show the footer.
        loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main');
        // Just so we don't get caught in an endless loop of errors from the footer...
        if (!$footer_done) {
            $footer_done = true;
            template_footer();
            // (since this is just debugging... it's okay that it's after </html>.)
            if (!isset($_REQUEST['xml'])) {
                displayDebug();
            }
        }
    }
    // Need user agent
    $req = request();
    // Remember this URL in case someone doesn't like sending HTTP_REFERER.
    $invalid_old_url = array('action=dlattach', 'action=jsoption', 'action=viewadminfile', ';xml', ';api');
    $make_old = true;
    foreach ($invalid_old_url as $url) {
        if (strpos($_SERVER['REQUEST_URL'], $url) !== false) {
            $make_old = false;
            break;
        }
    }
    if ($make_old === true) {
        $_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
    }
    // For session check verification.... don't switch browsers...
    $_SESSION['USER_AGENT'] = $req->user_agent();
    // Hand off the output to the portal, etc. we're integrated with.
    call_integration_hook('integrate_exit', array($do_footer));
    // Don't exit if we're coming from index.php; that will pass through normally.
    if (!$from_index) {
        exit;
    }
}
 function getAnnotationScaling()
 {
     // The $fn_image must be passed by reference because this functions sets parameters.
     $DHTML_MAXWIDTH = $this->param['width'];
     $DHTML_MAXHEIGHT = $this->param['height'];
     $size = getimagesize($this->param['image_path']);
     displayDebug('getAnnotationScaling size', 4);
     displayDebugParam($size, 4);
     $ratioWidth = $DHTML_MAXWIDTH / $size[0];
     $ratioHeight = $DHTML_MAXHEIGHT / $size[1];
     if ($ratioHeight > $ratioWidth) {
         $ratio = $ratioWidth;
     } else {
         $ratio = $ratioHeight;
     }
     if ($ratio > 1) {
         $ratio = 1;
     }
     $this->setFnImageParam('scalefactor', $ratio);
 }