Example #1
0
}
#foreach ($newtickets as &$row) {
##foreach ($newtickets as $i => $row) {
#	#	$db->Execute("REPLACE INTO gridimage_moderation_lock SET user_id = {$USER->user_id}, gridimage_id = {$row['gridimage_id']}");
#	if (empty($row['title2']))
#		$ctitle = $row['title'];
#	elseif (empty($row['title']))
#		$ctitle = $row['title2'];
#	else
#		$ctitle = $row['title'] . ' (' . $row['title2'] . ')';
#	$row['title1'] = $row['title'];
#	$row['title'] = $ctitle;
#}
foreach ($newtickets as $i => $row) {
    #	$db->Execute("REPLACE INTO gridimage_moderation_lock SET user_id = {$USER->user_id}, gridimage_id = {$row['gridimage_id']}");
    $ctitle = combineTexts($row['title'], $row['title2']);
    $newtickets[$i]['title'] = $ctitle;
    $newtickets[$i]['title1'] = $row['title'];
}
$smarty->assign_by_ref('newtickets', $newtickets);
if (empty($_GET['locked'])) {
    #################
    # lock images
    foreach ($newtickets as $i => $row) {
        $db->Execute("REPLACE INTO gridimage_moderation_lock SET user_id = {$USER->user_id}, gridimage_id = {$row['gridimage_id']}");
    }
    #############################
    $db->Execute("UNLOCK TABLES");
}
#############################
$template = !empty($_GET['sidebar']) ? 'admin_tickets_sidebar.tpl' : 'admin_tickets.tpl';
Example #2
0
 /**
  * return a sparse 2d array for every grid on the map
  * @access private
  */
 function &getGridArray($isimgmap = false)
 {
     global $memcache;
     if ($this->type_or_user == -10) {
         //we want a blank map!
         return array();
     }
     if ($memcache->valid) {
         //we only use cache imagemap as they invalidate correctly - and checksheets get smarty cached anyways
         $mkey = $this->getImageFilename();
         $mnamespace = $isimgmap ? 'mi' : 'ms';
         $grid =& $memcache->name_get($mnamespace, $mkey);
         if ($grid) {
             return $grid;
         }
         $mperiod = $isimgmap ? $memcache->period_long * 4 : $memcache->period_short;
     }
     //figure out what we're mapping in internal coords
     $db =& $this->_getDB();
     $grid = array();
     $left = $this->map_x;
     $bottom = $this->map_y;
     $right = $left + floor($this->image_w / $this->pixels_per_km) - 1;
     $top = $bottom + floor($this->image_h / $this->pixels_per_km) - 1;
     $overscan = 0;
     $scanleft = $left - $overscan;
     $scanright = $right + $overscan;
     $scanbottom = $bottom - $overscan;
     $scantop = $top + $overscan;
     $rectangle = "'POLYGON(({$scanleft} {$scanbottom},{$scanright} {$scanbottom},{$scanright} {$scantop},{$scanleft} {$scantop},{$scanleft} {$scanbottom}))'";
     if (!empty($this->type_or_user) && $this->type_or_user > 0) {
         $where_crit = " and gi2.user_id = {$this->type_or_user}";
         $where_crit2 = " and gi.user_id = {$this->type_or_user}";
         $columns = ", sum(moderation_status='geograph') as has_geographs, sum(moderation_status IN ('accepted','geograph')) as imagecount";
     } else {
         $where_crit = '';
         $where_crit2 = '';
         $columns = '';
     }
     if ($isimgmap) {
         //yes I know the imagecount is possibly strange in the join, but does speeds it up, having it twice speeds it up even more! (by preference have the second one, speed wise!), also keeping the join on gridsquare_id really does help too for some reason!
         $sql = "select gs.*,gridimage_id,gi.realname as credit_realname,if(gi.realname!='',gi.realname,user.realname) as realname,title,title2 \n\t\t\t\tfrom gridsquare gs\n\t\t\t\tleft join gridimage gi ON \n\t\t\t\t(imagecount > 0 AND gi.gridsquare_id = gs.gridsquare_id {$where_crit2} AND imagecount > 0 AND gridimage_id = \n\t\t\t\t\t(select gridimage_id from gridimage_search gi2 where gi2.grid_reference=gs.grid_reference \n\t\t\t\t\t {$where_crit} order by moderation_status+0 desc,seq_no limit 1)\n\t\t\t\t) \n\t\t\t\tleft join user using(user_id)\n\t\t\t\twhere \n\t\t\t\tCONTAINS( GeomFromText({$rectangle}),\tpoint_xy)\n\t\t\t\tand percent_land<>0 \n\t\t\t\tgroup by gs.grid_reference order by y,x";
     } else {
         $sql = "select gs.* {$columns},\n\t\t\t\tsum(moderation_status='accepted') as accepted, sum(moderation_status='pending') as pending,\n\t\t\t\tDATE_FORMAT(MAX(if(moderation_status!='rejected',imagetaken,null)),'%d/%m/%y') as last_date\n\t\t\t\tfrom gridsquare gs\n\t\t\t\tleft join gridimage gi on(gi.gridsquare_id = gs.gridsquare_id {$where_crit2} )\n\t\t\t\twhere \n\t\t\t\tCONTAINS( GeomFromText({$rectangle}),\tpoint_xy)\n\t\t\t\tand percent_land<>0 \n\t\t\t\tgroup by gs.gridsquare_id order by y,x";
     }
     $recordSet =& $db->Execute($sql);
     while (!$recordSet->EOF) {
         $gridx = $recordSet->fields['x'];
         $gridy = $recordSet->fields['y'];
         $posx = $gridx - $this->map_x;
         $posy = $top - $bottom - ($gridy - $bottom);
         $recordSet->fields['geographs'] = $recordSet->fields['imagecount'] - $recordSet->fields['accepted'];
         $recordSet->fields['title1'] = $recordSet->fields['title'];
         $recordSet->fields['title'] = combineTexts($recordSet->fields['title1'], $recordSet->fields['title2']);
         $grid[$posx][$posy] = $recordSet->fields;
         $recordSet->MoveNext();
     }
     $recordSet->Close();
     if ($memcache->valid) {
         $memcache->name_set($mnamespace, $mkey, $grid, $memcache->compress, $mperiod);
     }
     return $grid;
 }
Example #3
0
$stylefile = "http://{$CONF['KML_HOST']}/kml/style.kmz";
$folder = $kml->addChild('Document');
$folder->setItem('name', "{$gr} :: Geograph SuperLayer");
$links = new kmlPrimative('Folder');
$links->setItem('name', 'Next Level...');
$prefix = $db->GetRow('select * from gridprefix where prefix=' . $db->Quote($square->gridsquare) . ' limit 1');
$left = $prefix['origin_x'] + intval($square->eastings / 20) * 20;
$right = $left + 20 - 1;
$bottom = $prefix['origin_y'] + intval($square->northings / 20) * 20;
$top = $bottom + 20 - 1;
$rectangle = "'POLYGON(({$left} {$bottom},{$right} {$bottom},{$right} {$top},{$left} {$top},{$left} {$bottom}))'";
$sql_where = "CONTAINS(GeomFromText({$rectangle}),point_xy)";
$photos = $db->GetAll("select \r\ngridimage_id,grid_reference,title,title2,imagecount,view_direction,natgrlen,realname,\r\nwgs84_lat,wgs84_long\r\nfrom gridimage_kml \r\nwhere {$sql_where} and tile = 1\r\norder by null");
foreach ($photos as $id => $entry) {
    $point = new kmlPoint($entry['wgs84_lat'], $entry['wgs84_long']);
    $title = combineTexts($entry['title'], $entry['title2']);
    if ($entry['imagecount'] == 1) {
        $placemark = new kmlPlacemark($entry['gridimage_id'], $entry['grid_reference'] . ' :: ' . $title, $point);
        $placemark->useCredit($entry['realname'], "http://{$_SERVER['HTTP_HOST']}/photo/{$entry['gridimage_id']}");
        $html .= getHtmlLinkP($placemark->link, $entry['grid_reference'] . ' :: ' . $entry['title'] . ' by ' . $entry['realname']);
        $placemark->setItem('description', $placemark->link);
        $r = $entry['natgrlen'] > 4 ? '' : 'r';
        if ($entry['view_direction'] != -1) {
            $placemark->useHoverStyle('p1d' . $r);
            $Style = $placemark->addChild('Style');
            $IconStyle = $Style->addChild('IconStyle');
            $IconStyle->setItem('heading', $entry['view_direction']);
        } else {
            $placemark->useHoverStyle('p1' . $r);
        }
    } else {
//this takes a long time, so we output a header first of all
$smarty->display('_std_begin.tpl');
echo "<h3> ReBuilding Wordnet...</h3>";
flush();
set_time_limit(3600 * 24);
$tim = time();
$recordSet =& $db->Execute("select gridimage_id,title,title2 from gridimage where moderation_status != 'rejected'");
$db->Execute("truncate wordnet1");
$db->Execute("truncate wordnet2");
$db->Execute("truncate wordnet3");
$db->Execute("LOCK TABLES wordnet1 WRITE,wordnet2 WRITE,wordnet3 WRITE");
$db->Execute("ALTER TABLE wordnet1 DISABLE KEYS");
$db->Execute("ALTER TABLE wordnet2 DISABLE KEYS");
$db->Execute("ALTER TABLE wordnet3 DISABLE KEYS");
while (!$recordSet->EOF) {
    $title = combineTexts($recordSet->fields['title'], $recordSet->fields['title2']);
    updateWordnet($db, $title, 'title', $recordSet->fields['gridimage_id']);
    //the comments arent searched yet anyway...
    //if ($_GET['comments'])
    //	updateWordnet($db,$recordSet->fields['comment'],'comment',$recordSet->fields['gridimage_id']);
    if ($recordSet->fields['gridimage_id'] % 5000 == 0) {
        printf("done %d at <b>%d</b> seconds<BR>", $recordSet->fields['gridimage_id'], time() - $tim);
        flush();
    }
    $recordSet->MoveNext();
}
$recordSet->Close();
$db->Execute("ALTER TABLE wordnet1 ENABLE KEYS ");
$db->Execute("ALTER TABLE wordnet2 ENABLE KEYS ");
$db->Execute("ALTER TABLE wordnet3 ENABLE KEYS ");
$db->Execute("UNLOCK TABLES");
   <NumberFormat ss:Format="Short Date"/>
  </Style>
 </Styles>
 <Worksheet ss:Name="geograph">
  <Table>
   <Row>
<?php 
foreach (explode(',', $csvhead) as $col) {
    print "<Cell><Data ss:Type=\"String\">{$col}</Data></Cell>";
}
print "</Row>\n";
$counter = -1;
while (!$recordSet->EOF) {
    print "<Row>\n";
    $image = $recordSet->fields;
    $image['title'] = combineTexts($image['title'], $image['title2']);
    print "<Cell ss:StyleID=\"sHy\" ss:HRef=\"http://{$_SERVER['HTTP_HOST']}/photo/{$image['gridimage_id']}\"><Data ss:Type=\"Number\">{$image['gridimage_id']}</Data></Cell>\n";
    print "<Cell><Data ss:Type=\"String\">{$image['title']}</Data></Cell>";
    print "<Cell><Data ss:Type=\"String\">{$image['grid_reference']}</Data></Cell>";
    print "<Cell><Data ss:Type=\"String\">{$image['realname']}</Data></Cell>";
    print "<Cell><Data ss:Type=\"String\">{$image['imageclass']}</Data></Cell>";
    if (!empty($_GET['thumb'])) {
        $gridimage->fastInit($image);
        print "<Cell><Data ss:Type=\"String\">" . $gridimage->getThumbnail(120, 120, true) . "</Data></Cell>";
    }
    if (!empty($_GET['en'])) {
        print "<Cell><Data ss:Type=\"Number\">{$image['nateastings']}</Data></Cell>\n";
        print "<Cell><Data ss:Type=\"Number\">{$image['natnorthings']}</Data></Cell>\n";
        print "<Cell><Data ss:Type=\"Number\">{$image['natgrlen']}</Data></Cell>\n";
        if (!empty($_GET['ppos'])) {
            print "<Cell><Data ss:Type=\"Number\">{$image['viewpoint_eastings']}</Data></Cell>\n";
 /**
  * Updates a given field of the image, holding it for moderation if necessary
  * A series of calls to this function should be followed up with a call
  * to commit(), which persist the ticket and any unmoderated changes
  * @access public
  */
 function updateField($fieldname, $oldvalue, $newvalue, $moderated)
 {
     $ok = true;
     //no change?
     if ($oldvalue == $newvalue) {
         return $ok;
     }
     if (!$moderated) {
         //make the changes right away...
         $img =& $this->_getImage();
         if ($fieldname == "grid_reference") {
             $err = "";
             $ok = $img->reassignGridsquare($newvalue, $err);
             if ($ok) {
                 $this->commit_count++;
             } else {
                 die("Sorry, wasn't expecting reassignGridsquare to fail ({$err}) please contact us for assistance");
             }
         } elseif ($fieldname == "photographer_gridref") {
             //need to parse value for nat coords
             $sq = new GridSquare();
             if ($sq->setByFullGridRef($newvalue, true, true, true)) {
                 $img->viewpoint_eastings = $sq->nateastings;
                 $img->viewpoint_northings = $sq->natnorthings;
                 $img->viewpoint_grlen = $sq->natgrlen;
                 $img->viewpoint_refindex = $sq->reference_index;
                 $this->commit_count++;
             } elseif (empty($newvalue)) {
                 // we are setting to 'blank'
                 $img->viewpoint_eastings = 0;
                 $img->viewpoint_northings = 0;
                 $img->viewpoint_grlen = 0;
                 $img->viewpoint_refindex = 0;
                 $this->commit_count++;
             }
         } else {
             $img->{$fieldname} = $newvalue;
             //we'll do this commit later
             $this->commit_count++;
         }
         $status = "immediate";
         $approver_id = $this->user_id;
         $img->title = combineTexts($img->title1, $img->title2);
         $img->comment = combineTexts($img->comment1, $img->comment2);
     } else {
         $status = "pending";
         $approver_id = 0;
     }
     //have we already got a change record?
     $found = false;
     foreach ($this->changes as $c) {
         if ($c['field'] == $fieldname) {
             $found = true;
         }
     }
     if (!$found) {
         //create a change record
         $change = array("field" => $fieldname, "oldvalue" => $oldvalue, "newvalue" => $newvalue, "status" => $status, "approver_id" => $approver_id);
         $this->changes[] = $change;
     }
 }
Example #7
0
$smarty->caching = 0;
//do we have a valid image?
if (!empty($_POST)) {
    $image = new GridImage();
    $image->gridimage_id = 0;
    $image->moderation_status = 'pending';
    $image->submitted = time();
    $image->user_id = $USER->user_id;
    $image->realname = $USER->realname;
    $image->profile_link = "/profile/{$image->user_id}";
    $image->title1 = strip_tags(trim(stripslashes($_POST['title'])));
    $image->comment1 = strip_tags(trim(stripslashes($_POST['comment'])));
    $image->title2 = strip_tags(trim(stripslashes($_POST['title2'])));
    $image->comment2 = strip_tags(trim(stripslashes($_POST['comment2'])));
    $image->title = combineTexts($image->title1, $image->title2);
    $image->comment = combineTexts($image->comment1, $image->comment2);
    $image->imageclass = strip_tags(trim(stripslashes($_POST['imageclass'])));
    if ($image->imageclass == "Other") {
        $image->imageclass = strip_tags(trim(stripslashes($_POST['imageclassother'])));
    }
    if (isset($_POST['imagetakenYear'])) {
        $image->imagetaken = sprintf("%04d-%02d-%02d", $_POST['imagetakenYear'], $_POST['imagetakenMonth'], $_POST['imagetakenDay']);
    }
    $image->use6fig = !empty($_POST['use6fig']);
    if (!empty($_POST['grid_reference'])) {
        $image->grid_square = new GridSquare();
        $image->grid_square->setByFullGridRef($_POST['grid_reference']);
        $image->grid_reference = $image->grid_square->grid_reference;
        $image->natgrlen = $image->grid_square->natgrlen;
        $image->nateastings = $image->grid_square->nateastings;
        $image->natnorthings = $image->grid_square->natnorthings;
Example #8
0
            if (count($openTickets)) {
                $smarty->assign_by_ref('opentickets', $openTickets);
            }
            $image->lookupModerator();
        }
        if (isset($_POST['title']) && isset($_POST['create'])) {
            $title = trim(stripslashes($_POST['title']));
            $title = strip_tags($title);
            $title2 = trim(stripslashes($_POST['title2']));
            $title2 = strip_tags($title2);
            $comment = trim(stripslashes($_POST['comment']));
            $comment = strip_tags($comment);
            $comment2 = trim(stripslashes($_POST['comment2']));
            $comment2 = strip_tags($comment2);
            $image->title1 = $title;
            $image->comment1 = $comment;
            $image->title2 = $title2;
            $image->comment2 = $comment2;
            $image->title = combineTexts($title, $title2);
            $image->comment = combineTexts($comment, $comment2);
        }
        //strip out zeros from date
        #$image->imagetaken=str_replace('0000-', '-', $image->imagetaken);
        #$image->imagetaken=str_replace('-00', '-', $image->imagetaken);
    } else {
        $smarty->assign('error', 'Invalid image id specified');
    }
} else {
    $smarty->assign('error', 'No image id specified');
}
$smarty->display($template, $cacheid);
 /**
  * advanced method which sets up a gridimage without a gridsquare instance
  * only use this method if you know what you are doing
  * if need a grid_reference it should be supplied in the array
  */
 function fastInit(&$arr)
 {
     require_once 'geograph/functions.inc.php';
     $this->grid_square = null;
     $this->grid_reference = '';
     foreach ($arr as $name => $value) {
         if (!is_numeric($name)) {
             $this->{$name} = $value;
         }
     }
     $this->profile_link = "/profile/{$this->user_id}";
     if (!empty($this->credit_realname)) {
         $this->profile_link .= "?a=" . urlencode($this->realname);
     }
     $this->title1 = $this->title;
     $this->comment1 = $this->comment;
     $this->title = combineTexts($this->title1, $this->title2);
     $this->comment = combineTexts($this->comment1, $this->comment2);
 }