コード例 #1
0
/**
  @package    admin::graphs
  @author     Loaded Commerce
  @copyright  Copyright 2003-2014 Loaded Commerce, LLC
  @copyright  Portions Copyright 2003 osCommerce
  @license    https://github.com/loadedcommerce/loaded7/blob/master/LICENSE.txt
  @version    $Id: banner_yearly.php v1.0 2013-08-08 datazen $
*/
function lc_banner_yearly($_id)
{
    global $lC_Database, $lC_Language, $lC_Vqmod;
    require $lC_Vqmod->modCheck('external/panachart/panachart.php');
    $lC_ObjectInfo = new lC_ObjectInfo(lC_Banner_manager_Admin::getData($_id));
    $image_extension = lc_dynamic_image_extension();
    $views = array();
    $clicks = array();
    $vLabels = array();
    $stats = array();
    $Qstats = $lC_Database->query('select year(banners_history_date) as year, sum(banners_shown) as value, sum(banners_clicked) as dvalue from :table_banners_history where banners_id = :banners_id group by year');
    $Qstats->bindTable(':table_banners_history', TABLE_BANNERS_HISTORY);
    $Qstats->bindInt(':banners_id', $_id);
    $Qstats->execute();
    while ($Qstats->next()) {
        $stats[] = array($Qstats->valueInt('year'), $Qstats->valueInt('value') > 0 ? $Qstats->valueInt('value') : '0', $Qstats->valueInt('dvalue') > 0 ? $Qstats->valueInt('dvalue') : '0');
        $views[] = $Qstats->valueInt('value');
        $clicks[] = $Qstats->valueInt('dvalue');
        $vLabels[] = $Qstats->valueInt('year');
    }
    $ochart = new chart(600, 350, 5, '#eeeeee');
    $ochart->setTitle(sprintf($lC_Language->get('subsection_heading_statistics_yearly'), $lC_ObjectInfo->get('banners_title')), '#000000', 2);
    $ochart->setPlotArea(SOLID, '#444444', '#dddddd');
    $ochart->setFormat(0, ',', '.');
    $ochart->setXAxis('#000000', SOLID, 1, '');
    $ochart->setYAxis('#000000', SOLID, 2, '');
    $ochart->setLabels($vLabels, '#000000', 1, VERTICAL);
    $ochart->setGrid('#bbbbbb', DASHED, '#bbbbbb', DOTTED);
    $ochart->addSeries($views, 'area', 'Series1', SOLID, '#000000', '#0000ff');
    $ochart->addSeries($clicks, 'area', 'Series1', SOLID, '#000000', '#ff0000');
    $ochart->plot('images/graphs/banner_yearly-' . $_id . '.' . $image_extension);
    return $stats;
}
コード例 #2
0
 function __construct()
 {
     global $lC_Language, $lC_MessageStack;
     $this->_page_title = $lC_Language->get('heading_title');
     if (!isset($_GET['action'])) {
         $_GET['action'] = '';
     }
     $this->image_extension = lc_dynamic_image_extension();
     // check if the graphs directory exists
     $_SESSION['errArr'] = array();
     if (!empty($this->image_extension)) {
         if (is_dir('images/graphs')) {
             if (!is_writeable('images/graphs')) {
                 $_SESSION['errArr']['error'] = true;
                 $_SESSION['errArr']['errmsg'] = sprintf($lC_Language->get('ms_error_graphs_directory_not_writable'), realpath('images'));
             }
         } else {
             $_SESSION['errArr']['error'] = true;
             $_SESSION['errArr']['errmsg'] = sprintf($lC_Language->get('ms_error_graphs_directory_non_existant'), realpath('images'));
         }
     }
     if (!empty($_GET['action']) && !$_SESSION['error']) {
         switch ($_GET['action']) {
             case 'save':
                 $data = array('title' => $_POST['title'], 'url' => $_POST['url'], 'target' => isset($_POST['target']) && $_POST['target'] == 'on' ? true : false, 'group' => isset($_POST['group']) ? $_POST['group'] : null, 'group_new' => $_POST['group_new'], 'image' => isset($_FILES['image']) ? $_FILES['image'] : null, 'image_local' => $_POST['image_local'], 'image_target' => $_POST['image_target'], 'html_text' => $_POST['html_text'], 'date_scheduled' => $_POST['date_scheduled'], 'date_expires' => $_POST['date_expires'], 'expires_impressions' => $_POST['expires_impressions'], 'status' => isset($_POST['status']) && $_POST['status'] == 'on' ? true : false);
                 /*
                  * Save the banner information
                  *
                  * @param integer $_GET['bid'] The banner id
                  * @param array $data The banner information
                  * @access public
                  * @return boolean
                  */
                 if (lC_Banner_manager_Admin::save(isset($_GET['bid']) && is_numeric($_GET['bid']) ? $_GET['bid'] : null, $data)) {
                     lc_redirect_admin(lc_href_link_admin(FILENAME_DEFAULT, $this->_module));
                 } else {
                     $_SESSION['error'] = true;
                     $_SESSION['errmsg'] = $lC_Language->get('ms_error_action_not_performed');
                 }
                 break;
         }
     }
 }
コード例 #3
0
/**
  @package    admin::graphs
  @author     Loaded Commerce
  @copyright  Copyright 2003-2014 Loaded Commerce, LLC
  @copyright  Portions Copyright 2003 osCommerce
  @license    https://github.com/loadedcommerce/loaded7/blob/master/LICENSE.txt
  @version    $Id: banner_daily.php v1.0 2013-08-08 datazen $
*/
function lc_banner_daily($_id, $_month, $_year)
{
    global $lC_Database, $lC_Language, $lC_Vqmod;
    require $lC_Vqmod->modCheck('external/panachart/panachart.php');
    $lC_ObjectInfo = new lC_ObjectInfo(lC_Banner_manager_Admin::getData($_id));
    $image_extension = lc_dynamic_image_extension();
    $views = array();
    $clicks = array();
    $vLabels = array();
    $days = @date('t', @mktime(0, 0, 0, $_month)) + 1;
    $stats = array();
    for ($i = 1; $i < $days; $i++) {
        $stats[] = array($i, '0', '0');
        $views[$i - 1] = 0;
        $clicks[$i - 1] = 0;
        $vLabels[] = $i;
    }
    $Qstats = $lC_Database->query('select dayofmonth(banners_history_date) as banner_day, banners_shown as value, banners_clicked as dvalue from :table_banners_history where banners_id = :banners_id and month(banners_history_date) = :month and year(banners_history_date) = :year');
    $Qstats->bindTable(':table_banners_history', TABLE_BANNERS_HISTORY);
    $Qstats->bindInt(':banners_id', $_id);
    $Qstats->bindInt(':month', $_month);
    $Qstats->bindInt(':year', $_year);
    $Qstats->execute();
    while ($Qstats->next()) {
        $stats[$Qstats->valueInt('banner_day') - 1] = array($Qstats->valueInt('banner_day'), $Qstats->valueInt('value') > 0 ? $Qstats->valueInt('value') : '0', $Qstats->valueInt('dvalue') > 0 ? $Qstats->valueInt('dvalue') : '0');
        $views[$Qstats->valueInt('banner_day') - 1] = $Qstats->valueInt('value');
        $clicks[$Qstats->valueInt('banner_day') - 1] = $Qstats->valueInt('dvalue');
    }
    $ochart = new chart(600, 350, 5, '#eeeeee');
    $ochart->setTitle(sprintf($lC_Language->get('subsection_heading_statistics_daily'), $lC_ObjectInfo->get('banners_title'), @strftime('%B', @mktime(0, 0, 0, $_month)), $_year), '#000000', 2);
    $ochart->setPlotArea(SOLID, '#444444', '#dddddd');
    $ochart->setFormat(0, ',', '.');
    $ochart->setXAxis('#000000', SOLID, 1, '');
    $ochart->setYAxis('#000000', SOLID, 2, '');
    $ochart->setLabels($vLabels, '#000000', 1, VERTICAL);
    $ochart->setGrid('#bbbbbb', DASHED, '#bbbbbb', DOTTED);
    $ochart->addSeries($views, 'area', 'Series1', SOLID, '#000000', '#0000ff');
    $ochart->addSeries($clicks, 'area', 'Series1', SOLID, '#000000', '#ff0000');
    $ochart->plot('images/graphs/banner_daily-' . $_id . '_' . $_month . '.' . $image_extension);
    return $stats;
}
コード例 #4
0
 public static function delete($id, $delete_image = false)
 {
     global $lC_Database;
     $error = false;
     $lC_Database->startTransaction();
     if ($delete_image === true) {
         $Qimage = $lC_Database->query('select banners_image from :table_banners where banners_id = :banners_id');
         $Qimage->bindTable(':table_banners', TABLE_BANNERS);
         $Qimage->bindInt(':banners_id', $id);
         $Qimage->execute();
     }
     $Qdelete = $lC_Database->query('delete from :table_banners where banners_id = :banners_id');
     $Qdelete->bindTable(':table_banners', TABLE_BANNERS);
     $Qdelete->bindInt(':banners_id', $id);
     $Qdelete->setLogging($_SESSION['module'], $id);
     $Qdelete->execute();
     if ($lC_Database->isError()) {
         $error = true;
     }
     if ($error === false) {
         $Qdelete = $lC_Database->query('delete from :table_banners_history where banners_id = :banners_id');
         $Qdelete->bindTable(':table_banners_history', TABLE_BANNERS_HISTORY);
         $Qdelete->bindInt(':banners_id', $id);
         $Qdelete->execute();
         if ($lC_Database->isError()) {
             $error = true;
         }
     }
     if ($error === false) {
         if ($delete_image === true) {
             if (!lc_empty($Qimage->value('banners_image'))) {
                 if (is_file('../images/' . $Qimage->value('banners_image')) && is_writeable('../images/' . $Qimage->value('banners_image'))) {
                     @unlink('../images/' . $Qimage->value('banners_image'));
                 }
             }
         }
         $image_extension = lc_dynamic_image_extension();
         if (!empty($image_extension)) {
             if (is_file('images/graphs/banner_yearly-' . $id . '.' . $image_extension) && is_writeable('images/graphs/banner_yearly-' . $id . '.' . $image_extension)) {
                 @unlink('images/graphs/banner_yearly-' . $id . '.' . $image_extension);
             }
             if (is_file('images/graphs/banner_monthly-' . $id . '.' . $image_extension) && is_writeable('images/graphs/banner_monthly-' . $id . '.' . $image_extension)) {
                 @unlink('images/graphs/banner_monthly-' . $id . '.' . $image_extension);
             }
             if (is_file('images/graphs/banner_daily-' . $id . '.' . $image_extension) && is_writeable('images/graphs/banner_daily-' . $id . '.' . $image_extension)) {
                 unlink('images/graphs/banner_daily-' . $id . '.' . $image_extension);
             }
         }
         $lC_Database->commitTransaction();
         return true;
     }
     $lC_Database->rollbackTransaction();
     return false;
 }
コード例 #5
0
ファイル: panachart.php プロジェクト: rajeshb001/itpl_loaded7
 function plot($file)
 {
     $min = $this->m_minValue;
     $max = $this->m_maxValue + ($this->m_maxValue - $this->m_minValue) * 0.1 / 5 * 5;
     // margins
     $margin = $this->m_margin;
     $marginy = $margin;
     if ($this->m_title) {
         $marginy += $this->m_fontHeight * 1.5;
     }
     $marginbottom = $margin + 5;
     if ($this->m_labelsDirection == HORIZONTAL) {
         $marginbottom += $this->m_labelsFontWidth;
     } else {
         $marginbottom += $this->m_labelsMaxLength * $this->m_labelsFontWidth;
     }
     if (@$this->m_axisXTitle) {
         $marginbottom += $this->m_axisXFontHeight * 1.5;
     }
     $height = $this->m_height - $marginy - $marginbottom;
     if ($this->m_withLegend) {
         //
     }
     $maxvalues = floor($height / $this->m_labelsFontHeight / 1.5);
     // max displayable values
     $marginx = $margin + 5;
     $marginx += strlen(number_format($this->m_maxValue, $this->m_numberOfDecimals, ',', '.')) * $this->m_labelsFontWidth;
     if (@$this->m_axisYTitle) {
         $marginx += $this->m_axisYFontHeight * 1.5;
     }
     $width = $this->m_width - $marginx - $margin;
     $w = $width / ($this->m_maxCount + 0.2);
     $dx = $w * 0.8;
     $sx = $w - $dx;
     $width = $w * $this->m_maxCount + $sx;
     $h = $maxvalues > 0 ? $height / $maxvalues : 0;
     $dy = $max - $min > 0 ? $height / ($max - $min) : 0;
     $vdy = $maxvalues > 0 ? ($max - $min) / $maxvalues : 0;
     //plot border & background
     imagefilledrectangle($this->m_image, $marginx, $marginy, $marginx + $width, $marginy + $height, $this->m_fillColor);
     // plot title
     if ($this->m_title) {
         imagestring($this->m_image, $this->m_font, ($this->m_width - strlen($this->m_title) * $this->m_fontWidth) / 2, $margin, $this->m_title, $this->m_textColor);
     }
     // plot values (Y)
     _set_style($this->m_image, $this->m_axisYStyle, $this->m_axisYColor, $this->m_fillColor);
     for ($i = 0; $i <= $maxvalues; $i++) {
         $yvalue = number_format($min + $vdy * $i, $this->m_numberOfDecimals, $this->m_decimalSeparator, $this->m_thousandsSeparator);
         imageline($this->m_image, $marginx - 3, $marginy + $height - $i * $h, $marginx, $marginy + $height - $i * $h, IMG_COLOR_STYLED);
         imagestring($this->m_image, $this->m_labelsFont, $marginx - strlen($yvalue) * $this->m_labelsFontWidth - 4, $marginy + $height - $i * $h - $this->m_labelsFontHeight / 2, $yvalue, $this->m_labelsTextColor);
     }
     // plot grid
     if ($this->m_showHGrid) {
         for ($i = 0; $i <= $maxvalues; $i++) {
             _set_style($this->m_image, $this->m_gridHStyle, $this->m_gridHColor, $this->m_fillColor);
             imageline($this->m_image, $marginx, $marginy + $height - $i * $h, $marginx + $width, $marginy + $height - $i * $h, IMG_COLOR_STYLED);
         }
     }
     if ($this->m_showVGrid) {
         for ($i = 0; $i < count($this->m_labels); $i++) {
             $len = strlen($this->m_labels[$i]);
             if ($len > 0) {
                 _set_style($this->m_image, $this->m_gridVStyle, $this->m_gridVColor, $this->m_fillColor);
                 imageline($this->m_image, $marginx + $i * $w + $dx / 2 + $sx, $height + $marginy, $i * $w + $marginx + $dx / 2 + $sx, $marginy, IMG_COLOR_STYLED);
             }
         }
     }
     _set_style($this->m_image, $this->m_style, $this->m_strokeColor, $this->m_fillColor);
     imagerectangle($this->m_image, $marginx, $marginy, $marginx + $width, $marginy + $height, IMG_COLOR_STYLED);
     // plot graph
     foreach ($this->m_series as $series) {
         $cnt = count($series->m_values);
         // LINE PLOT
         if ($series->m_type == 'line') {
             _set_style($this->m_image, $series->m_style, $series->m_strokeColor, $this->m_fillColor);
             $startx = $marginx + $dx / 2 + $sx;
             $starty = $marginy + $height - $dy * ($series->m_values[0] - $min);
             for ($i = 1; $i < $cnt; $i++) {
                 $x = $marginx + $i * $w + $dx / 2 + $sx;
                 $y = $marginy + $height - $dy * ($series->m_values[$i] - $min);
                 imageline($this->m_image, $startx, $starty, $x, $y, IMG_COLOR_STYLED);
                 $startx = $x;
                 $starty = $y;
             }
             // AREA PLOT
         } else {
             if ($series->m_type == 'area') {
                 _set_style($this->m_image, $series->m_style, $series->m_strokeColor, $this->m_fillColor);
                 $vpoints = '';
                 $startx = $marginx + $dx / 2 + $sx;
                 $starty = $marginy + $height - $dy * ($series->m_values[0] - $min);
                 $vpoints[] = $startx;
                 $vpoints[] = $marginy + $height;
                 for ($i = 0; $i < $cnt; $i++) {
                     $x = $marginx + $i * $w + $dx / 2 + $sx;
                     $y = $marginy + $height - $dy * ($series->m_values[$i] - $min);
                     $vpoints[] = $x;
                     $vpoints[] = $y;
                     $startx = $x;
                     $starty = $y;
                 }
                 $vpoints[] = $x;
                 $vpoints[] = $marginy + $height;
                 @imagefilledpolygon($this->m_image, $vpoints, $cnt + 2, $series->m_fillColor);
                 @imagepolygon($this->m_image, $vpoints, $cnt + 2, IMG_COLOR_STYLED);
                 // BAR PLOT
             } else {
                 if ($series->m_type == 'bar') {
                     _set_style($this->m_image, $series->m_style, $series->m_strokeColor, $this->m_fillColor);
                     $vpoints = '';
                     for ($i = 0; $i < $cnt; $i++) {
                         imagefilledrectangle($this->m_image, $sx + $marginx + $i * $w, $marginy + $height - $dy * ($series->m_values[$i] - $min), $sx + $marginx + $i * $w + $dx, $marginy + $height, $series->m_fillColor);
                         imagerectangle($this->m_image, $sx + $marginx + $i * $w, $marginy + $height - $dy * ($series->m_values[$i] - $min), $sx + $marginx + $i * $w + $dx, $marginy + $height, IMG_COLOR_STYLED);
                     }
                     // IMPULS PLOT
                 } else {
                     if ($series->m_type == 'impuls') {
                         _set_style($this->m_image, $series->m_style, $series->m_fillColor, $this->m_fillColor);
                         for ($i = 0; $i < $cnt; $i++) {
                             $x = $marginx + $i * $w + $dx / 2 + $sx;
                             $y = $marginy + $height - $dy * ($series->m_values[$i] - $min);
                             imageline($this->m_image, $x, $y, $x, $marginy + $height, IMG_COLOR_STYLED);
                         }
                         // STEP PLOT
                     } else {
                         if ($series->m_type == 'step') {
                             _set_style($this->m_image, $series->m_style, $series->m_strokeColor, $this->m_fillColor);
                             $cnt = $cnt;
                             $vpoints = '';
                             $startx = $marginx + $sx / 2;
                             $starty = $marginy + $height - $dy * ($series->m_values[0] - $min);
                             $vpoints[] = $startx;
                             $vpoints[] = $marginy + $height;
                             $vpoints[] = $startx;
                             $vpoints[] = $starty;
                             for ($i = 1; $i < $cnt; $i++) {
                                 $x = $marginx + $i * $w + $sx / 2;
                                 $y = $marginy + $height - $dy * ($series->m_values[$i] - $min);
                                 $vpoints[] = $x;
                                 $vpoints[] = $starty;
                                 $vpoints[] = $x;
                                 $vpoints[] = $y;
                                 $startx = $x;
                                 $starty = $y;
                             }
                             $vpoints[] = $x + $w;
                             $vpoints[] = $y;
                             $vpoints[] = $x + $w;
                             $vpoints[] = $marginy + $height;
                             imagefilledpolygon($this->m_image, $vpoints, $cnt * 2 + 2, $series->m_fillColor);
                             imagepolygon($this->m_image, $vpoints, $cnt * 2 + 2, IMG_COLOR_STYLED);
                             // DOT PLOT
                         } else {
                             if ($series->m_type == 'dot') {
                                 _set_style($this->m_image, $series->m_style, $series->m_strokeColor, $this->m_fillColor);
                                 for ($i = 0; $i < $cnt; $i++) {
                                     $x = $marginx + $i * $w + $dx / 2 + $sx;
                                     $y = $marginy + $height - $dy * ($series->m_values[$i] - $min);
                                     imagerectangle($this->m_image, $x - 2, $y - 2, $x + 2, $y + 2, IMG_COLOR_STYLED);
                                     imagefilledrectangle($this->m_image, $x - 1, $y - 1, $x + 1, $y + 1, $series->m_fillColor);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // plot X labels
     for ($i = 0; $i < count($this->m_labels); $i++) {
         $len = strlen($this->m_labels[$i]);
         if ($len > 0) {
             _set_style($this->m_image, $this->m_axisXStyle, $this->m_axisXColor, $this->m_fillColor);
             imageline($this->m_image, $dx / 2 + $sx + $marginx + $i * $w, $height + $marginy, $dx / 2 + $sx + $i * $w + $marginx, $height + $marginy + 3, IMG_COLOR_STYLED);
             if ($this->m_labelsDirection == HORIZONTAL) {
                 imagestring($this->m_image, $this->m_labelsFont, $dx / 2 + $sx + $marginx + $i * $w - $len * $this->m_labelsFontWidth / 2, $marginy + 4 + $height, $this->m_labels[$i], $this->m_labelsTextColor);
             } else {
                 imagestringup($this->m_image, $this->m_labelsFont, $dx / 2 + $sx + $marginx + $i * $w - $this->m_labelsFontHeight / 2, $marginy + $height + $len * $this->m_labelsFontWidth + 4, $this->m_labels[$i], $this->m_labelsTextColor);
             }
         }
     }
     // plot X axis
     if ($this->m_showXAxis) {
         _set_style($this->m_image, $this->m_axisXStyle, $this->m_axisXColor, $this->m_fillColor);
         imageline($this->m_image, $marginx, $marginy + $height, $marginx + $width, $marginy + $height, IMG_COLOR_STYLED);
         if ($this->m_axisXTitle) {
             imagestring($this->m_image, $this->m_axisXFont, $marginx + ($width - strlen($this->m_axisXTitle) * $this->m_axisXFontWidth) / 2, $this->m_height - $margin - $this->m_axisXFontHeight, $this->m_axisXTitle, $this->m_axisXColor);
         }
     }
     // plot Y axis
     if ($this->m_showYAxis) {
         _set_style($this->m_image, $this->m_axisYStyle, $this->m_axisYColor, $this->m_fillColor);
         imageline($this->m_image, $marginx, $marginy, $marginx, $marginy + $height, IMG_COLOR_STYLED);
         if ($this->m_axisYTitle) {
             $titlewidth = strlen($this->m_axisYTitle) * $this->m_axisYFontWidth;
             imagestringup($this->m_image, $this->m_axisYFont, $margin, $marginy + $titlewidth + ($height - $titlewidth) / 2, $this->m_axisYTitle, $this->m_axisYColor);
         }
     }
     $image_function = 'image' . lc_dynamic_image_extension();
     if (strlen($file) > 0) {
         $image_function($this->m_image, $file);
     } else {
         $image_function($this->m_image);
     }
 }