Ejemplo n.º 1
0
 /**
  * Start http stream.
  * @return unknown_type
  */
 public static function streamHeader()
 {
     $boundary = self::BOUNDARY;
     GWF_HTTP::noCache();
     header("Content-type: multipart/x-mixed-replace;boundary={$boundary}");
     echo "\n--{$boundary}\n";
 }
Ejemplo n.º 2
0
 public function execute()
 {
     # Don't store this url.
     GWF3::setConfig('store_last_url', false);
     # Load the Captcha class
     require GWF_CORE_PATH . 'inc/3p/Class_Captcha.php';
     # disable Logging
     GWF3::setConfig('log_request', false);
     # disable HTTP Caching
     GWF_HTTP::noCache();
     # Setup Font, Color, Size
     $aFonts = $this->module->cfgCaptchaFont();
     $rgbcolor = $this->module->cfgCaptchaBG();
     $width = $this->module->cfgCaptchaWidth();
     $height = $this->module->cfgCaptchaHeight();
     $oVisualCaptcha = new PhpCaptcha($aFonts, $width, $height, $rgbcolor);
     # Output the captcha
     die($oVisualCaptcha->Create('', Common::getGetString('chars', true)));
 }
Ejemplo n.º 3
0
 private function graphB(WC_Site $site, $field)
 {
     $graphtitle = $this->module->lang('gt_site_' . $field, array($site->getVar('site_name')));
     $siteid = $site->getID();
     $history = GDO::table('WC_HistorySite');
     if (false === ($result = $history->select("sitehist_date, {$field}", 'sitehist_sid=' . $siteid, 'sitehist_date ASC'))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     //		$db = gdo_db();
     //		$table = $history->getTableName();
     //		if (false === ($result = $db->query("SELECT sitehist_date, $field FROM $table WHERE sitehist_sid=$siteid ORDER BY sitehist_date ASC"))) {
     //			return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     //		}
     //load in the data
     $xdataarray = array();
     $ydataarray = array();
     $highestvalue = 0;
     //		while (false !== ($row = $db->fetchRow($result)))
     while (false !== ($row = $history->fetch($result, GDO::ARRAY_N))) {
         $value = (int) $row[1];
         $xdataarray[] = $row[0];
         $ydataarray[] = $value;
         if ($value > $highestvalue) {
             $highestvalue = $value;
         }
     }
     $history->free($result);
     // add current value
     $xdataarray[] = time();
     $ydataarray[] = $value = $site->getVar(str_replace('hist_', '_', $field));
     if ($value > $highestvalue) {
         $highestvalue = $value;
     }
     //		var_dump($xdataarray);
     //		var_dump($ydataarray);
     //		var_dump($xticks);
     if ($highestvalue === 0) {
         $graph = new Graph($this->module->cfgGraphWidth(), $this->module->cfgGraphHeight());
         $graph->SetScale('intlin', 1, 2, 1, 2);
         $caption = new Text($this->module->lang('err_graph_empty'), 0.1, 0.8);
         //			$caption->SetFont(FS_BOLD);
         $graph->AddText($caption);
         $graph->stroke();
         die(0);
     }
     #		$dateformat = GWF_HTML::lang('df_8');
     //		$dateformat = "d.M.y-H:i";
     $dateformat = "M.y";
     $datemargin = strlen(date($dateformat)) * 11;
     //define the graph
     $graph = new Graph($this->module->cfgGraphWidth(), $this->module->cfgGraphHeight());
     $graph->SetScale('datlin', 0, 1.05 * $highestvalue);
     $graph->title->Set($graphtitle);
     //		$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 12);
     $graph->SetColor(array(238, 238, 238));
     $graph->SetMarginColor(array(208, 211, 237));
     $graph->SetShadow();
     $graph->xaxis->SetLabelAngle(90);
     //		$graph->xaxis->SetTickPositions($xticks, NULL, $xdataarray);
     $graph->xaxis->scale->SetDateFormat($dateformat);
     $graph->img->SetMargin(50, 40, 40, $datemargin);
     $lineplot = new LinePlot($ydataarray, $xdataarray);
     $lineplot->SetColor("blue");
     $lineplot->SetWeight(2);
     $graph->Add($lineplot);
     //		$graph->img->SetAntiAliasing();
     // Display the graph
     GWF_HTTP::noCache();
     $graph->Stroke();
     die(0);
 }
Ejemplo n.º 4
0
 private function graphUserLevel($type)
 {
     $dir = dirname(GWF_JPGRAPH_PATH) . '/';
     require_once $dir . 'jpgraph.php';
     require_once $dir . 'jpgraph_date.php';
     require_once $dir . 'jpgraph_line.php';
     require_once $dir . 'jpgraph_plotline.php';
     if (false === ($user = GWF_User::getByName(Common::getGet('username', '')))) {
         return $this->graphError(GWF_HTML::lang('ERR_UNKNOWN_USER'));
     }
     if (false !== ($vs = Common::getGet('vs'))) {
         $vs = GWF_User::getByName($vs);
     }
     $uh = GWF_TABLE_PREFIX . 'wc_user_history2';
     switch ($type) {
         case 'userhist_rank':
             $type2 = 'rank';
             break;
         case 'userhist_totalscore':
             $type2 = 'totalscore';
             break;
         default:
             die('Unknown Type');
     }
     if ($vs === false) {
         $graphtitle = $this->module->lang('alt_graph_' . $type2, array($user->displayUsername()));
     } else {
         $graphtitle = $this->module->lang('alt_graph_' . $type2 . '_vs', array($user->displayUsername(), $vs->displayUsername()));
     }
     $db = gdo_db();
     $uid = $user->getID();
     $query = "SELECT userhist_date,{$type} FROM {$uh} WHERE userhist_uid={$uid} ORDER BY userhist_date ASC";
     if (false === ($result = $db->queryRead($query))) {
         die(GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__)));
     }
     $invert = $type2 === 'rank';
     $highestValue = 0;
     //		$lowestValue = 2111222333;
     $xdata = array();
     $ydata = array();
     if ($type2 === 'totalscore') {
         $xdata[] = GWF_Time::getTimestamp($user->getVar('user_regdate'));
         $ydata[] = 0;
         //			$highestValue = 20;
     } elseif ($type2 === 'rank') {
         $xdata[] = GWF_Time::getTimestamp($user->getVar('user_regdate'));
         $ydata[] = 0;
         //			$del = GWF_User::DELETED;
         //			$ydata[] = -GDO::table('GWF_User')->countRows("user_options&$del=0");
         //			$highestValue = -$ydata[0];
     }
     while (false !== ($row = $db->fetchRow($result))) {
         $time = intval($row[0]);
         $xdata[] = $time;
         $value = intval($row[1]);
         $ydata[] = $invert ? -$value : $value;
         $highestValue = $value > $highestValue ? $value : $highestValue;
         //			$lowestValue = $value < $lowestValue ? $value : $lowestValue;
     }
     $db->free($result);
     // Now the Opponent
     if ($vs !== false) {
         $uid2 = $vs->getID();
         $query = "SELECT userhist_date,{$type} FROM {$uh} WHERE userhist_uid={$uid2} ORDER BY userhist_date ASC";
         if (false === ($result = $db->queryRead($query))) {
             die(GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__)));
         }
         $xdata2 = array();
         $ydata2 = array();
         if ($type2 === 'totalscore') {
             $xdata2[] = GWF_Time::getTimestamp($vs->getVar('user_regdate'));
             $ydata2[] = 0;
         } elseif ($type2 === 'rank') {
             $xdata2[] = GWF_Time::getTimestamp($vs->getVar('user_regdate'));
             $ydata2[] = 0;
             //				$del = GWF_User::DELETED;
             //				$ydata2[] = GDO::table('GWF_User')->countRows("user_options&$del=0");
             //				$highestValue = -$ydata2[0];
         }
         while (false !== ($row = $db->fetchRow($result))) {
             $time = intval($row[0]);
             $xdata2[] = $time;
             $value = intval($row[1]);
             $highestValue = $value > $highestValue ? $value : $highestValue;
             //				$lowestValue = $value < $lowestValue ? $value : $lowestValue;
             $ydata2[] = $invert ? -$value : $value;
         }
         $db->free($result);
     }
     if ($type2 === 'rank') {
         $ydata[0] = -$highestValue;
         $ydata2[0] = -$highestValue;
     }
     //		$this->max_rank = $highestValue;
     $dateformat = "M.y";
     $datemargin = strlen(date($dateformat)) * 11;
     //define the graph
     $graph = new Graph($this->module->cfgGraphWidth(), $this->module->cfgGraphHeight());
     if ($invert) {
         $graph->SetScale('datlin', -$highestValue, -1);
     } else {
         $graph->SetScale('datlin', 0, 1.05 * $highestValue);
     }
     $graph->title->Set($graphtitle);
     //		$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 12);
     $graph->SetColor(array(238, 238, 238));
     $graph->SetMarginColor(array(208, 211, 237));
     $graph->SetShadow();
     $graph->xaxis->SetLabelAngle(90);
     //		$graph->xaxis->SetTickPositions($xticks, NULL, $xdataarray);
     $graph->xaxis->scale->SetDateFormat($dateformat);
     $graph->img->SetMargin(50, 40, 40, $datemargin);
     $graph->legend->Pos(0.011, 0.005, "right", "top");
     # Add plots
     $lineplot = new LinePlot($ydata, $xdata);
     $lineplot->SetColor("blue");
     $lineplot->SetWeight(2);
     $lineplot->SetLegend($user->getVar('user_name'));
     $graph->Add($lineplot);
     if ($vs !== false) {
         $lineplot = new LinePlot($ydata2, $xdata2);
         $lineplot->SetColor("red");
         $lineplot->SetWeight(2);
         $lineplot->SetLegend($vs->getVar('user_name'));
         $graph->Add($lineplot);
     }
     if ($invert) {
         $graph->yaxis->SetLabelFormatCallback(array($this, 'negation_callback'));
         $graph->xaxis->SetLabelSide(SIDE_DOWN);
         $graph->xaxis->setPos('min');
         //			$graph->yaxis->SetValueFormatCallback(array($this, 'negation_callback'));
     }
     GWF_HTTP::noCache();
     // Display the graph
     //		$graph->img->SetAntiAliasing();
     $graph->Stroke();
     die;
 }