' ; exit ; } else { img_txt ( $txt ) ; } } function db_get_tab ( $qwe, $tab ) { global $DEBUG, $conn ; $res = array () ; $sel = db_query_params ( $qwe, $tab ) ; if ( $sel === FALSE ) { db_fail ( $qwe, $tab ) ; } $num = pg_numrows ( $sel ) ; if ( $DEBUG ) { printf ( "db_get : qwe '%s'
\n", $qwe ) ; printf ( "db_get : num '%s'
\n", $num ) ; } for ( $i = 0 ; $i < $num ; $i++ ) { $res [] = pg_fetch_object ( $sel, $i ) ; } return $res ; } function img_txt ( $txt ) { global $IMG_NP_W, $IMG_NP_H ; $im = imagecreate ( $IMG_NP_W, $IMG_NP_H ) ; $blck = imagecolorallocate ( $im, 0 , 0 , 0 ) ; $whit = imagecolorallocate ( $im, 255, 255, 255 ) ; $blue = imagecolorallocate ( $im, 0 , 0 , 255 ) ; imagefilledrectangle ( $im, 1, 1, $IMG_NP_W - 2, $IMG_NP_H - 2, $whit ) ; imagestring ( $im, 5, 5, $IMG_NP_H / 3 , $txt, $blue ) ; header ( "Content-type: image/png" ) ; imagepng ( $im ) ; exit ; } $xxx = array () ; $sizs = array () ; $revs = array () ; $rid = $_GET [ 'RID' ] ; $sty = $_GET [ 'STY' ] ; $sum = $_GET [ 'SUM' ] ; if ( ! $sty ) { $sty = 'BIG' ; } if ( ! $rid ) { if ( $DEBUG ) { echo 'no rid' ; exit ; } else { img_txt ( ' no rid' ) ; } } elseif ( ! preg_match ( '/^[0-9]+$/i', $rid ) ) { croak ( ' bad rid' ) ; } $repo = get_repo ( $rid ) ; $name = $repo -> repo_name () ; if ( $repo -> sum () != $sum ) { croak ( "not yours" ) ; } $QWE = "SELECT * FROM {$TBL(repo_stats)} WHERE rid = $1 ORDER BY date ;" ; $tab = array ( $repo -> id ) ; $tups = db_get_tab ( $QWE, $tab ) ; if ( ! $tups ) { if ( $DEBUG ) { echo 'no data' ; exit ; } else { img_txt ( ' no data' ) ; } } elseif ( count ( $tups ) == 1 ) { if ( $DEBUG ) { echo 'one point' ; exit ; } else { img_txt ( 'only 1 pnt' ) ; } } foreach ( $tups as $tup ) { $date = $tup -> date ; $temp = explode ( '-', $date ) ; $time = gmmktime ( 12, 12, 12, $temp[1], $temp[2], $temp[0] ) ; $siz = $tup -> size ; $rev = $tup -> rev ; $xxx [] = $time ; $sizs [] = $siz / 1024 ; $revs [] = $rev ; if ( $DEBUG ) { printf ( "date '%s' time '%s' size '%s' rev '%s'
\n" , $date, $time, $siz, $rev ) ; } } if ( $DEBUG ) { printf ( "frst '%s' last '%s'
\n", $xxx[0], 'last' ) ; } if ( $DEBUG ) { exit ; } function array_max ( $a ) { $res = 0 ; if ( count ( $a ) > 0 ) { foreach ( $a as $v ) { if ( $v > $res ) { $res = $v ; } } } return $res ; } if ( $sty == 'SML' ) { $graph = new Graph ( 170, 100 ) ; $graph -> SetScale ( 'datlin' ) ; $graph -> SetMargin ( 60, 10, 5, 10 ) ; $graph -> SetMarginColor ( 'lightblue@0.5' ) ; $graph -> title -> SetFont ( FF_FONT1, FS_BOLD ) ; $graph -> title -> Set ( "statistics" ) ; $graph -> xaxis -> scale -> SetDateFormat("m-y"); $graph -> xaxis -> HideLabels () ; $graph -> xaxis -> HideTicks () ; $plot1 = new LinePlot ( $sizs, $xxx ); $plot1 -> SetFillColor ( 'lightblue@0.5' ) ; $graph -> Add ( $plot1 ) ; $graph -> Stroke () ; } else { $n = count( $xxx ) ; $puls_x = array () ; $puls_y = array () ; $UTILS = new DateScaleUtils ; list ( $tickPositions, $minTickPositions ) = $UTILS -> GetTicks ( $xxx, DSUTILS_MONTH1 ) ; $min = $xxx [ 0 ] ; # - 3 * 60 * 24 * 64 ; $max = $xxx [ $n - 1 ] ; # + 3 * 60 * 24 * 64 ; $y_min = date ( 'Y', $min ) + 1 ; $y_max = date ( 'Y', $max ) ; $max_value = max ( $revs ) ; if ( $y_min <= $y_max ) { for ( $y = $y_min ; $y <= $y_max ; $y ++ ) { $puls_x [] = gmmktime ( 0, 0, 0, 1, 1, $y ) ; $puls_y [] = $max_value ; } } $larr = sprintf ( '&#%04d;', hexdec ( '2190' ) ) ; $larr = '' ; $graph = new Graph ( 800, 500 ) ; $graph -> SetScale ( 'intlin' ) ; $graph -> SetMargin ( 80, 150, 30, 90 ) ; $graph -> SetMarginColor ( 'linen' ) ; $graph -> title -> SetFont ( FF_FONT2, FS_BOLD ) ; $graph -> title -> Set ( $name ) ; $graph -> subtitle -> SetFont ( FF_FONT2, FS_BOLD ) ; $graph -> subtitle -> Set ( "$larr size and revision" ) ; $graph -> legend -> SetPos (0.92, 0.1, 'center', 'right' ) ; $graph -> SetYScale (0, 'int' ) ; $graph -> xaxis -> SetLabelFormatString ( 'd M Y', true ) ; $graph -> xaxis -> SetLabelAngle ( 90 ) ; $graph -> xgrid -> SetWeight ( 1 ) ; $graph -> xgrid -> SetColor ( 'lightgray' ) ; $graph -> xgrid -> Show ( true, true ) ; $graph -> yaxis -> title -> Set ( "Size [MB]" ) ; $graph -> yaxis -> SetTitleMargin ( 50 ) ; $graph -> yaxis -> title -> SetFont ( FF_FONT2 , FS_BOLD ); $plot1 = new LinePlot ( $sizs, $xxx ); $plot1 -> SetFillColor ( 'lightblue@0.5' ) ; $plot1 -> SetLegend ('size') ; $graph -> Add ( $plot1 ) ; $plot2 = new ScatterPlot ( $revs, $xxx ) ; $graph -> AddY ( 0, $plot2 ) ; $graph -> ynaxis [ 0 ] -> title -> Set ( "Revision" ) ; $graph -> ynaxis [ 0 ] -> SetTitleMargin ( 40 ) ; $graph -> ynaxis [ 0 ] -> title -> SetFont( FF_FONT2 , FS_BOLD ); $plot3 = new LinePlot ( $revs, $xxx ) ; $plot3 -> SetLegend ( 'revision' ) ; $graph -> AddY ( 0, $plot3 ) ; if ( count ( $puls_x ) ) { $plotP = new ScatterPlot ( $puls_y, $puls_x ) ; $plotP -> SetWeight ( 1 ) ; $plotP -> mark -> Hide () ; $plotP -> SetImpuls () ; $plotP -> SetColor ( 'red' ) ; $graph -> AddY ( 0, $plotP ) ; } $graph -> Stroke () ; } ?>