Sh3ll
OdayForums


Server : LiteSpeed
System : Linux premium84.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : claqxcrl ( 523)
PHP Version : 8.1.32
Disable Function : NONE
Directory :  /home/claqxcrl/anfangola.com/wp-content/plugins/matomo/app/plugins/Goals/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/claqxcrl/anfangola.com/wp-content/plugins/matomo/app/plugins/Goals/Model.php
<?php

/**
 * Matomo - free/libre analytics platform
 *
 * @link https://matomo.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 *
 */
namespace Piwik\Plugins\Goals;

use Piwik\Common;
use Piwik\Db;
class Model
{
    private static $rawPrefix = 'goal';
    private $table;
    public function __construct()
    {
        $this->table = Common::prefixTable(self::$rawPrefix);
    }
    private function getNextIdGoal($idSite)
    {
        $db = $this->getDb();
        $idGoal = $db->fetchOne("SELECT max(idgoal) + 1 FROM " . $this->table . "\n                                 WHERE idsite = ?", $idSite);
        if (empty($idGoal)) {
            $idGoal = 1;
        }
        return $idGoal;
    }
    public function createGoalForSite($idSite, $goal)
    {
        $db = $this->getDb();
        $goalId = $this->getNextIdGoal($idSite);
        $goal['idgoal'] = $goalId;
        $goal['idsite'] = $idSite;
        $db->insert($this->table, $goal);
        return $goalId;
    }
    public function updateGoal($idSite, $idGoal, $goal)
    {
        $idSite = (int) $idSite;
        $idGoal = (int) $idGoal;
        $db = $this->getDb();
        $db->update($this->table, $goal, "idsite = '{$idSite}' AND idgoal = '{$idGoal}'");
    }
    // actually this should be in a log_conversion model
    public function deleteGoalConversions($idSite, $idGoal)
    {
        $table = Common::prefixTable("log_conversion");
        Db::deleteAllRows($table, "WHERE idgoal = ? AND idsite = ?", "idvisit", 100000, array($idGoal, $idSite));
    }
    public function getActiveGoal($idSite, $idGoal)
    {
        $idSite = (int) $idSite;
        $idGoal = (int) $idGoal;
        $goals = Db::fetchRow("SELECT * FROM " . $this->table . "\n                                WHERE idsite = {$idSite} AND idgoal = {$idGoal}\n                                      AND deleted = 0 LIMIT 1");
        return $goals;
    }
    public function getActiveGoals($idSite)
    {
        $idSite = array_map('intval', $idSite);
        $goals = Db::fetchAll("SELECT * FROM " . $this->table . "\n                                WHERE idsite IN (" . implode(", ", $idSite) . ")\n                                      AND deleted = 0");
        return $goals;
    }
    public function deleteGoalsForSite($idSite)
    {
        Db::query("DELETE FROM " . $this->table . " WHERE idsite = ? ", array($idSite));
    }
    public function deleteGoal($idSite, $idGoal)
    {
        $query = "UPDATE " . $this->table . " SET deleted = 1\n                  WHERE idsite = ? AND idgoal = ?";
        $bind = array($idSite, $idGoal);
        Db::query($query, $bind);
    }
    public function getActiveGoalCount()
    {
        return (int) Db::fetchOne("SELECT count(*) FROM " . $this->table . "\n                                WHERE deleted = 0");
    }
    private function getDb()
    {
        return Db::get();
    }
    /**
     * Checks if an active idgoal exists for the site
     *
     * @param int $idGoal
     * @param int $idSite
     *
     * @return bool
     */
    public function doesGoalExist(int $idGoal, int $idSite) : bool
    {
        return (bool) Db::fetchOne("SELECT COUNT(*) FROM " . $this->table . "\n                                WHERE deleted = 0 AND idsite = ? AND idgoal = ?", [$idSite, $idGoal]);
    }
}

ZeroDay Forums Mini