Guest User

Untitled

a guest
Aug 9th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. function aol_get_dateplot( $node_id, $date, &$node = null ) {
  2. if ( ! is_numeric($node_id) || intval($node_id) != $node_id || $node_id < 0) {
  3. drupal_set_message( t('Could not generate plot because node id is invalid.', 'warning') );
  4. return;
  5. }
  6.  
  7. if( $node === null ) {
  8. $node = node_load( $node_id );
  9. }
  10.  
  11. if( ! $node || $node->type != 'lake' ) {
  12. drupal_set_message( t('Could not generate plot because node is invalid or incorrect type.', 'warning') );
  13. return;
  14. }
  15.  
  16. $lake_id = $node->field_lake_id[0]['value'];
  17.  
  18. $conn = pg_connect ( "host=xxx port=5432 dbname=xxx user=xxx password=xxx" );
  19. import_request_variables ( 'gp', 'var_' );
  20.  
  21. //$result = pg_query ( $conn, "select plr_get_raw(r_secchi_boxplot(44,'Lake Billy Chinook','Secchi Transparency')) as graph" );
  22. $result = pg_query( $conn, "select plr_get_raw(r_profile_plot(" . $lake_id . ",'" . $node->title . "','" . $date . "')) as graph" );
  23. if( $result === false) return null;
  24.  
  25. $row = pg_fetch_object ( $result );
  26.  
  27. header("Content-Type: image/png");
  28. echo pg_unescape_bytea ( $row->graph );
  29. }
Add Comment
Please, Sign In to add comment