ProjectConfiguration.class.php 2.59 KB
Newer Older
Яков's avatar
first  
Яков committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
require_once __DIR__ . '/../vendor/lib/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();

class ProjectConfiguration extends sfProjectConfiguration
{
    public function setup()
    {
        $this->enablePlugins('sfDoctrinePlugin');
        $this->enablePlugins('sfImageTransformPlugin');
        $this->enablePlugins('sfCaptchaGDPlugin');
        $this->enablePlugins('doAuthPlugin');
        $this->enablePlugins('sfRUtilsPlugin');
        $this->enablePlugins('sfSphinxPlugin');
        $this->enablePlugins('csSettingsPlugin');
    }
}

class ProjectUtils
{
    public static function get($url)
    {
        $ch = curl_init();
        @curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        $r = curl_exec($ch);
        curl_close($ch);
        return $r;
    }
}

class ProjectUlils
{
    public static function post($url, $data)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        $r = curl_exec($ch);
        curl_close($ch);
    }

    public static function generateUuid()
    {
        mt_srand((double)microtime() * 10000);
        $charid = strtolower(md5(uniqid(rand(), true)));
        $hyphen = chr(45);
        $uuid = substr($charid, 0, 8) . $hyphen . substr($charid, 8, 4) . $hyphen . substr($charid, 12, 4) . $hyphen . substr($charid, 16, 4) . $hyphen . substr($charid, 20, 12);
        return $uuid;
    }

    static public function rusDate($date, $time = false, $skip_year = false)
    {
        $a = array(
            '01' => 'января',
            '02' => 'февраля',
            '03' => 'марта',
            '04' => 'апреля',
            '05' => 'мая',
            '06' => 'июня',
            '07' => 'июля',
            '08' => 'августа',
            '09' => 'сентября',
            '10' => 'октября',
            '11' => 'ноября',
            '12' => 'декабря',
        );
        $ex = explode(' ', $date);
        if (count($ex) == 2) {
            $timeex = explode(':', $ex[1]);
        }
        $ex = explode('-', $ex[0]);
        return intval($ex[2]) . ' ' . $a[$ex[1]] . ($skip_year && $ex[0] == date('Y') ? '' : ' ' . $ex[0]) . ($time ? ' ' . $timeex[0] . ':' . $timeex[1] : '');
    }
}

function object2array($object)
{
    return @json_decode(@json_encode($object), 1);
}