Пример #1
0
    function loadSampleStatisticalData()
    {
        if (!($tem_id = $this->loadTemplate())) {
            return false;
        }
        if (!($news_private_id = $this->loadPrivateNewsletter($tem_id))) {
            return false;
        }
        if (!($news_public_id = $this->loadPublicNewsletter($tem_id))) {
            return false;
        }
        if (!$this->loadMessages($news_private_id, $news_public_id)) {
            return false;
        }
        $dbo =& $this->getDBO();
        $now = JFactory::getDate();
        for ($i = 0; $i < 60; $i++) {
            $num = (int) rand(15, 50);
            for ($j = 0; $j < $num; $j++) {
                $d = new JDate($now->toUNIX() - $i * 24 * 60 * 60 + rand(0, 24 * 60) * 60);
                $query = "INSERT INTO #__jinc_stats_event (type, date, news_id) " . "VALUES (0, '" . $d->toSQL() . "', {$news_private_id})";
                $dbo->setQuery($query);
                if (!$dbo->query()) {
                    $this->setError($dbo->getErrorMsg() . ': ' . $query);
                    return false;
                }
            }
            $num = (int) rand(5, 15);
            for ($j = 0; $j < $num; $j++) {
                $d = new JDate($now->toUNIX() - $i * 24 * 60 * 60 + rand(0, 24 * 60) * 60);
                $query = "INSERT INTO #__jinc_stats_event (type, date, news_id) " . "VALUES (1, '" . $d->toSQL() . "', {$news_private_id})";
                $dbo->setQuery($query);
                if (!$dbo->query()) {
                    $this->setError($dbo->getErrorMsg() . ': ' . $query);
                    return false;
                }
            }
            $num = (int) rand(15, 50);
            for ($j = 0; $j < $num; $j++) {
                $d = new JDate($now->toUNIX() - $i * 24 * 60 * 60 + rand(0, 24 * 60) * 60);
                $query = "INSERT INTO #__jinc_stats_event (type, date, news_id) " . "VALUES (0, '" . $d->toSQL() . "', {$news_public_id})";
                $dbo->setQuery($query);
                if (!$dbo->query()) {
                    $this->setError($dbo->getErrorMsg() . ': ' . $query);
                    return false;
                }
            }
            $num = (int) rand(5, 15);
            for ($j = 0; $j < $num; $j++) {
                $d = new JDate($now->toUNIX() - $i * 24 * 60 * 60 + rand(0, 24 * 60) * 60);
                $query = "INSERT INTO #__jinc_stats_event (type, date, news_id) " . "VALUES (1, '" . $d->toSQL() . "', {$news_public_id})";
                $dbo->setQuery($query);
                if (!$dbo->query()) {
                    $this->setError($dbo->getErrorMsg() . ': 

        

        

         

        ' . $query);
                    return false;
                }
            }
        }
        return true;
    }