Esempio n. 1
0
 static function update_index($task)
 {
     try {
         $completed = $task->get("completed", 0);
         $start = microtime(true);
         foreach (ORM::factory("item")->join("iptc_records", "items.id", "iptc_records.item_id", "left")->where("type", "=", "photo")->and_open()->where("iptc_records.item_id", "IS", null)->or_where("iptc_records.dirty", "=", 1)->close()->find_all() as $item) {
             // The query above can take a long time, so start the timer after its done
             // to give ourselves a little time to actually process rows.
             if (!isset($start)) {
                 $start = microtime(true);
             }
             iptc::extract($item);
             $completed++;
             if (microtime(true) - $start > 1.5) {
                 break;
             }
         }
         list($remaining, $total, $percent) = iptc::stats();
         $task->set("completed", $completed);
         if ($remaining == 0 || !($remaining + $completed)) {
             $task->done = true;
             $task->state = "success";
             site_status::clear("iptc_index_out_of_date");
             $task->percent_complete = 100;
         } else {
             $task->percent_complete = round(100 * $completed / ($remaining + $completed));
         }
         $task->status = t2("one record updated, index is %percent% up-to-date", "%count records updated, index is %percent% up-to-date", $completed, array("percent" => $percent));
     } catch (Exception $e) {
         $task->done = true;
         $task->state = "error";
         $task->status = $e->getMessage();
         $task->log((string) $e);
     }
 }
Esempio n. 2
0
 private function _get_admin_form()
 {
     // Make a new Form.
     $form = new Forge("admin/iptc/saveprefs", "", "post", array("id" => "g-iptc-adminForm"));
     // Create group for display settings
     $iptc_display_group = $form->group("Global")->label(t("Display Settings"));
     $show = t("Show");
     foreach (iptc::keys() as $keyword => $iptcvar) {
         unset($checkbox);
         $checkbox[$keyword] = array($show . " \"" . $iptcvar[1] . "\" ?", module::get_var("iptc", "show_" . $keyword));
         $iptc_display_group->checklist($keyword)->options($checkbox);
     }
     // Add a save button to the form.
     $form->submit("SaveSettings")->value(t("Save"));
     // Return the newly generated form.
     return $form;
 }
Esempio n. 3
0
 static function get($block_id, $theme)
 {
     $block = "";
     switch ($block_id) {
         case "iptc":
             if ($theme->item()) {
                 $details = iptc::get($theme->item());
                 if (count($details) > 0) {
                     $block = new Block();
                     $block->css_id = "g-metadata";
                     $block->title = t("IPTC info");
                     $block->content = new View("iptc_block.html");
                     $block->content->details = $details;
                 }
             }
             break;
     }
     return $block;
 }
Esempio n. 4
0
 static function check_index()
 {
     list($remaining) = iptc::stats();
     if ($remaining) {
         site_status::warning(t('Your Iptc index needs to be updated.  <a href="%url" class="g-dialog-link">Fix this now</a>', array("url" => html::mark_clean(url::site("admin/maintenance/start/iptc_task::update_index?csrf=__CSRF__")))), "iptc_index_out_of_date");
     }
 }
 static function activate()
 {
     iptc::check_index();
 }
Esempio n. 6
0
/**
 * Write the IPCT date to an image
 *
 * @global type $UNC_GALLERY
 * @param type $file_path
 * @param type $date_str
 */
function unc_ipct_date_write($file_path, $date_str)
{
    global $UNC_GALLERY;
    if ($UNC_GALLERY['debug']) {
        XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    }
    // convert date_str to IPCT
    $search_pattern = '/(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d) (\\d\\d):(\\d\\d):(\\d\\d)/';
    $date_pattern = '$1$2$3';
    $ipct_date = preg_replace($search_pattern, $date_pattern, $date_str);
    $time_pattern = '$4$5$6';
    $ipct_time = preg_replace($search_pattern, $time_pattern, $date_str);
    if ($UNC_GALLERY['debug']) {
        XMPP_ERROR_trace('will write IPCT date in format', "{$ipct_date} / {$ipct_time}");
    }
    // write IPICT Date / time
    $taget_ipct_obj = new iptc($file_path);
    $taget_ipct_obj->set('created_date', $ipct_date);
    $taget_ipct_obj->set('created_time', $ipct_time);
    $taget_ipct_obj->write();
}
Esempio n. 7
0
 static function item_created($item)
 {
     if ($item->is_photo()) {
         iptc::extract($item);
     }
 }
Esempio n. 8
0
<?php

session_start();
if ($_SESSION['hash'] != $_POST['hash']) {
    die("error::Session expired!");
}
// $_POST["caption"]="Test caption";
// $_POST["city"]="city";
// $_POST["location"]="25346526876976";
$caption = $_POST["caption"];
//$iptc["2#120"][0];// 2000 chars
$city = $_POST["city"];
//$iptc["2#090"][0];// 32 chars
$location = $_POST["location"];
//$iptc["2#092"][0];//
$path = "../../" . $_POST["path"];
//"../../../photos/Portraits/20090408-2.jpg";//20090704_003129.jpg";//
DEFINE('IPTC_CITY', '090');
DEFINE('IPTC_GLOBAL_POSITION', '092');
DEFINE('IPTC_CAPTION', '120');
include "iptc.php";
$i = new iptc($path);
$i->set(IPTC_CAPTION, $caption);
$i->set(IPTC_CITY, $city);
$i->set(IPTC_GLOBAL_POSITION, $location);
echo $i->write();
Esempio n. 9
0
<?php

// This script will return to flash an XML with some IPTC and EXIF fields
DEFINE('IPTC_CAPTION', '120');
// 2000 chars
DEFINE('IPTC_CITY', '090');
// 32 chars
DEFINE('IPTC_GLOBAL_POSITION', '092');
// improvisation for wikimapia geodata
DEFINE('EXIF_GEO_LAT', 'GPSLatitude');
DEFINE('EXIF_GEO_LAT_REF', 'GPSLatitudeRef');
DEFINE('EXIF_GEO_LON', 'GPSLongitude');
DEFINE('EXIF_GEO_LON_REF', 'GPSLongitudeRef');
DEFINE('EXIF_EXPOSURE', 'ExposureTime');
DEFINE('EXIF_APERTURE', 'FNumber');
DEFINE('EXIF_FOCAL_LENGTH', 'FocalLength');
DEFINE('EXIF_ISO', 'ISOSpeedRatings');
include "iptc.php";
include "exif.php";
$path = "../../" . $_POST['path'];
$i = new iptc($path);
$e = new exif($path);
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><info>" . "<caption><![CDATA[" . $i->get(IPTC_CAPTION) . "]]></caption>" . "<city><![CDATA[" . $i->get(IPTC_CITY) . "]]></city>" . "<location><![CDATA[" . $i->get(IPTC_GLOBAL_POSITION) . "]]></location>" . "<geodata>" . $e->getGPS(EXIF_GEO_LAT, EXIF_GEO_LAT_REF) . "+" . $e->getGPS(EXIF_GEO_LON, EXIF_GEO_LON_REF) . "</geodata>" . "<exposure>" . $e->getEXIF(EXIF_EXPOSURE) . "</exposure>" . "<aperture>" . $e->getDividedEXIF(EXIF_APERTURE) . "</aperture>" . "<focallength>" . $e->getDividedEXIF(EXIF_FOCAL_LENGTH) . "</focallength>" . "<iso>" . $e->getEXIF(EXIF_ISO) . "</iso>" . "</info>";
        preg_match_all("/[a-zA-Z0-9\\/+]{20,}/", $this->local_file_contents, $base64);
        if (!empty($base64[0])) {
            foreach ($base64[0] as $response) {
                similar_text(strtoupper($response), strtoupper($text), $percentage);
                if (number_format($percentage, 0) > 90) {
                    $iptc_tag = str_replace($this->predefined_message, "", $response);
                    echo "2#" . $iptc_tag . " - " . $this->iptc_header_array["2#" . $iptc_tag] . " - with response: {$response}<br />\n";
                    echo "Text: " . base64_decode(str_replace($iptc_tag, "", $response)) . "<br />\n";
                }
            }
        }
    }
    public function get_contents()
    {
        var_dump(strip_tags($this->local_file_contents));
    }
}
$iptc = new iptc();
$iptc->predefined_message = base64_encode("Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ut nibh lorem. Vivamus neque odio, blandit molestie euismod vitae, feugiat ut erat. In porta enim id sodales commodo.");
$total_message = strlen(base64_decode($iptc->predefined_message));
echo "<b>Hidden message in image ({$total_message} characters): </b><br />\n" . base64_decode($iptc->predefined_message) . "<br />\n";
// http://postimage.org/ - all iptc - http://s28.postimg.org/clazc1hx7/12087056_931474056947112_5870482655699367021_o.jpg
// https://facebook.com/ - 2 iptc -  https://scontent-ams2-1.xx.fbcdn.net/hphotos-xtp1/t31.0-8/12138350_931569530270898_7157633721123481689_o.jpg
// https://dumpyourphoto.com/ - all iptc - https://static.dyp.im/74tv3aXEXk/26e14cc863fb4e2ff9b2e63afb809f39.jpg
// http://imgup.net/ - all iptc - http://h50.imgup.net/testa9a7.jpg
$facebook_image = "https://scontent-ams2-1.xx.fbcdn.net/hphotos-xat1/t31.0-8/12068469_932209523540232_140332007141850262_o.jpg";
echo "<b>My base64 string: </b><br />\n" . $iptc->predefined_message . "<br />\n";
$iptc->create_iptc("original.jpg", "test.jpg", $iptc->predefined_message);
$iptc->read_iptc($facebook_image);
echo "<b>Iptc compared with results: </b><br />\n";
$iptc->compare($iptc->predefined_message, $facebook_image);