Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matomo license #20570

Open
alteholz opened this issue Apr 8, 2023 · 5 comments
Open

Matomo license #20570

alteholz opened this issue Apr 8, 2023 · 5 comments
Labels
Critical Indicates the severity of an issue is very critical and the issue has a very high priority. Technical debt Issues the will help to reduce technical debt

Comments

@alteholz
Copy link

alteholz commented Apr 8, 2023

While looking at the license of Matomo, I stumbled upon the module c-pchart. According to your composer.json it is required.
When looking at https://github.com/szymach/c-pchart#license it says: "... if you wish to use it in a commercial project, you need to pay an appropriate fee." As c-pchart is a fork of pchart, looking at http://www.pchart.net/license, I am also told that I need to buy a commercial license if I want to redistribute pchart. So strictly speaking I am not allowed to use Matomo in a commercial environment when downloaded from [1], right?

Are you already aware of this license issue? Is c-pchart really needed? Another project, ampache, also used c-pchart but removed it after being aware of the non-commercial license[2].

Best regards
Thorsten

[1] https://builds.matomo.org/matomo-latest.zip
[2] ampache/ampache#1515

@mikkeschiren
Copy link
Contributor

Looking into the code I can find CpChart inside the ImageGraph plugin. c-pchart needs to be removed because of the licensing.

@sgiehl
Copy link
Member

sgiehl commented Apr 12, 2023

CpChart ist used to generate the static images, that are e.g. used in PDF reports.
Our team will be looking into this possible license issue soon.

@sgiehl sgiehl added the Critical Indicates the severity of an issue is very critical and the issue has a very high priority. label Apr 12, 2023
@sgiehl sgiehl added this to the For Prioritization milestone Apr 12, 2023
@mattab mattab modified the milestones: For Prioritization, 5.4.0 Apr 16, 2023
@williamdes
Copy link
Contributor

I made this fake library to replace the provider for anyone that wants to package matomo or use it without this vendor.
And does not care about graphs in scheduled reports sent by email.

It builds an empty square with the text: Graphs renders are disabled

Author: William Desportes <[email protected]>
Date:   Tue Jul 18 01:18:02 2023 +0200

diff --git a/chart-lib.php b/chart-lib.php
new file mode 100644
index 0000000000..b53552f0eb
--- /dev/null
+++ b/chart-lib.php
@@ -0,0 +1,317 @@
+<?php
+
+namespace ChartLib {
+    /**
+     * 			message: "#^Constant AXIS_FORMAT_CUSTOM not found\\.$#"
+     *			message: "#^Constant LEGEND_FAMILY_LINE not found\\.$#"
+     *			message: "#^Constant LEGEND_FAMILY_BOX not found\\.$#"
+     *			message: "#^Constant LEGEND_HORIZONTAL not found\\.$#"
+     *			message: "#^Constant LEGEND_NOBORDER not found\\.$#"
+     *			message: "#^Constant LEGEND_VERTICAL not found\\.$#"
+     *			message: "#^Constant SCALE_MODE_MANUAL not found\\.$#"
+     *			message: "#^Constant SCALE_POS_LEFTRIGHT not found\\.$#"
+     *			message: "#^Constant SCALE_POS_TOPBOTTOM not found\\.$#"
+     */
+
+    // Copied from https://github.com/szymach/c-pchart/blob/v3.0.17/constants.php
+
+    define("AXIS_FORMAT_CUSTOM", 680007);
+
+    define("SCALE_POS_LEFTRIGHT", 690101);
+    define("SCALE_POS_TOPBOTTOM", 690102);
+    define("SCALE_MODE_MANUAL", 690205);
+
+    define("LEGEND_FAMILY_BOX", 691051);
+    define("LEGEND_FAMILY_LINE", 691053);
+
+    define("LEGEND_NOBORDER", 690800);
+    define("LEGEND_VERTICAL", 690901);
+    define("LEGEND_HORIZONTAL", 690902);
+
+    abstract class Draw {
+
+        /**
+         * GD picture object
+         * @var resource
+         */
+        public $Picture;
+
+        /**
+         * Turn antialias on or off
+         * @var boolean
+         */
+        public $Antialias = true;
+
+        // -----
+
+        /**
+         * Draw a bar chart
+         * @param array $Format
+         */
+        public function drawBarChart(array $Format = [])
+        {
+        }
+
+        /**
+         * @param array $Format
+         * @throws Exception
+         */
+        public function drawScale(array $Format = [])
+        {
+        }
+
+        /**
+         * Write text
+         * @param int|float $X
+         * @param int|float $Y
+         * @param string $Text
+         * @param array $Format
+         * @return array
+         */
+        public function drawText($X, $Y, $Text, array $Format = [])
+        {
+        }
+
+
+        /**
+         * Draw a line chart
+         * @param array $Format
+         */
+        public function drawLineChart(array $Format = [])
+        {
+        }
+    }
+
+    class Pie {
+        public function __construct($pImage, $pData) {
+        }
+
+        /**
+         * Set the color of the specified slice
+         * @param mixed $SliceID
+         * @param array $Format
+         */
+        public function setSliceColor($SliceID, array $Format = [])
+        {
+        }
+
+        /**
+         * Draw the legend of pie chart
+         * @param int $X
+         * @param int $Y
+         * @param array $Format
+         * @return int
+         */
+        public function drawPieLegend($X, $Y, array $Format = [])
+        {
+        }
+
+        /**
+         * Draw a 3D pie chart
+         * @param int $X
+         * @param int $Y
+         * @param array $Format
+         * @return int
+         */
+        public function draw3DPie($X, $Y, array $Format = [])
+        {
+        }
+
+        /**
+         * Draw a pie chart
+         * @param int $X
+         * @param int $Y
+         * @param array $Format
+         * @return int
+         */
+        public function draw2DPie($X, $Y, array $Format = [])
+        {
+        }
+
+    }
+    class Data {
+        public function __construct() {
+        }
+        /**
+         * Return the data & configuration of the series
+         * @return array
+         */
+        public function getData()
+        {
+            return [];
+        }
+
+        /**
+         * Return the max value of a given serie
+         * @param string $Serie
+         * @return mixed
+         */
+        public function getMax($Serie)
+        {
+            return null;
+        }
+
+        /**
+         * Define if a serie should be draw with a special weight
+         * @param mixed $Series
+         * @param int $Weight
+         */
+        public function setSerieWeight($Series, $Weight = 0)
+        {
+        }
+
+        /**
+         * Set the color of one serie
+         * @param mixed $Series
+         * @param array $Format
+         */
+        public function setPalette($Series, array $Format = [])
+        {
+        }
+
+        /**
+         * Set the description of a given serie
+         * @param string|array $Series
+         * @param string $Description
+         */
+        public function setSerieDescription($Series, $Description = "My serie")
+        {
+        }
+        /**
+         * Set the serie that will be used as abscissa
+         * @param string $Serie
+         */
+        public function setAbscissa($Serie)
+        {
+        }
+
+        /**
+         * Add a single point or an array to the given serie
+         * @param mixed $Values
+         * @param string $SerieName
+         * @return int
+         */
+        public function addPoints($Values, $SerieName = "Serie1")
+        {
+        }
+
+        /**
+         * Set the display mode of an Axis
+         * @param int $AxisID
+         * @param int $Mode
+         * @param array $Format
+         */
+        public function setAxisDisplay($AxisID, $Mode = AXIS_FORMAT_DEFAULT, $Format = null)
+        {
+        }
+
+        /**
+         * Set the icon associated to a given serie
+         * @param mixed $Series
+         * @param mixed $Picture
+         */
+        public function setSeriePicture($Series, $Picture = null)
+        {
+        }
+    }
+
+    class Image extends Draw {
+        /**
+         * @param int $XSize
+         * @param int $YSize
+         * @param Data $DataSet
+         * @param boolean $TransparentBackground
+         */
+        public function __construct(
+            $XSize,
+            $YSize,
+            Data $DataSet = null,
+            $TransparentBackground = false
+        ) {
+            $this->Picture = imagecreate($XSize, $YSize)
+                or die("Cannot Initialize new GD image stream");
+            $background = imagecolorallocate($this->Picture, 224, 224, 209);
+            $textColor = imagecolorallocate($this->Picture, 0, 51, 102);
+
+            imagestring(
+                $this->Picture,
+                2,// Font
+                5,// X
+                5,// Y
+                "Graphs renders are disabled",
+                $textColor
+            );
+        }
+
+        /**
+         * Set the graph area position
+         * @param int $X1
+         * @param int $Y1
+         * @param int $X2
+         * @param int $Y2
+         * @return int|null
+         */
+        public function setGraphArea($X1, $Y1, $X2, $Y2)
+        {
+        }
+
+        /**
+         * @param array $Format
+         * @throws \Exception
+         */
+        public function drawScale(array $Format = [])
+        {
+        }
+
+        /**
+         * Draw a filled rectangle
+         * @param int $X1
+         * @param int $Y1
+         * @param int $X2
+         * @param int $Y2
+         * @param array $Format
+         */
+        public function drawFilledRectangle($X1, $Y1, $X2, $Y2, array $Format = [])
+        {
+        }
+
+        /**
+         * Draw the legend of the active series
+         * @param int $X
+         * @param int $Y
+         * @param array $Format
+         */
+        public function drawLegend($X, $Y, array $Format = [])
+        {
+        }
+
+        /**
+         * Set current font properties
+         * @param array $Format
+         */
+        public function setFontProperties($Format = [])
+        {
+        }
+
+        /**
+         * Render the picture to a file
+         * @param string $FileName
+         */
+        public function render($FileName)
+        {
+            imagepng($this->Picture, $FileName);
+            imagedestroy($this->Picture);
+        }
+
+        /**
+         * Render the picture to a web browser stream
+         * @param boolean $BrowserExpire
+         */
+        public function stroke($BrowserExpire = false)
+        {
+            header('Content-type: image/png');
+            imagepng($this->Picture);
+            imagedestroy($this->Picture);
+        }
+    }
+}
diff --git a/composer.json b/composer.json
index 466cf70950..a2b6585a16 100644
--- a/composer.json
+++ b/composer.json
@@ -93,7 +93,8 @@
             "Archive_": "libs/"
         },
         "files": [
-            "LegacyAutoloader.php"
+            "LegacyAutoloader.php",
+            "chart-lib.php"
         ]
     },
     "autoload-dev": {
diff --git a/plugins/ImageGraph/StaticGraph.php b/plugins/ImageGraph/StaticGraph.php
index bfa3976c4c..b1cc029dde 100644
--- a/plugins/ImageGraph/StaticGraph.php
+++ b/plugins/ImageGraph/StaticGraph.php
@@ -9,8 +9,8 @@
 
 namespace Piwik\Plugins\ImageGraph;
 
-use CpChart\Data;
-use CpChart\Image;
+use ChartLib\Data;
+use ChartLib\Image;
 use Piwik\Container\StaticContainer;
 use Piwik\NumberFormatter;
 use Piwik\Piwik;
diff --git a/plugins/ImageGraph/StaticGraph/Exception.php b/plugins/ImageGraph/StaticGraph/Exception.php
index f1785a22d5..34aa7d9d27 100644
--- a/plugins/ImageGraph/StaticGraph/Exception.php
+++ b/plugins/ImageGraph/StaticGraph/Exception.php
@@ -8,7 +8,7 @@
  */
 namespace Piwik\Plugins\ImageGraph\StaticGraph;
 
-use CpChart\Data;
+use ChartLib\Data;
 use Piwik\Plugins\ImageGraph\StaticGraph;
 
 /**
diff --git a/plugins/ImageGraph/StaticGraph/PieGraph.php b/plugins/ImageGraph/StaticGraph/PieGraph.php
index 455a7e74c9..9f0e7c95dd 100644
--- a/plugins/ImageGraph/StaticGraph/PieGraph.php
+++ b/plugins/ImageGraph/StaticGraph/PieGraph.php
@@ -9,7 +9,7 @@
 
 namespace Piwik\Plugins\ImageGraph\StaticGraph;
 
-use CpChart\Chart\Pie;
+use ChartLib\Pie;
 use Piwik\Plugins\ImageGraph\StaticGraph;
 
 /**

@utkarsh2102
Copy link

Hi @mattab, @sgiehl,

Any ETA on this happening? Can we drop CpChart in favor of its alternatives?

@williamdes
Copy link
Contributor

@sgiehl What do you think about a PR to 5.x to incorporate part of my patch to move all the code discussing with C-pchart to a PHP wrapper class ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Critical Indicates the severity of an issue is very critical and the issue has a very high priority. Technical debt Issues the will help to reduce technical debt
Projects
None yet
Development

No branches or pull requests

7 participants