Plugin Directory

Changeset 513401


Ignore:
Timestamp:
03/02/2012 09:52:39 AM (14 years ago)
Author:
TIgor4eg
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ti-stat/tags/0.4/ti_stat.php

    r512953 r513401  
    215215           
    216216            <?php
     217           
     218           
    217219            if ($auth->counter_id!= '')
    218220                    {
    219221                   
    220                    
     222                echo 'debug'.$auth->counter_id;
    221223                   
    222224                } else {
    223                
     225                    echo 'debug_false';
    224226                    $counters = ti_counters($auth->token);
    225227                                   
     
    921923        $newoptions['exp_time']= 0;
    922924        $newoptions['promote'] = $_POST['promote'];
     925        $newoptions['data'] = $options['data'];
    923926    }
    924927   
     
    15081511}
    15091512
     1513function ti_counters($token)
     1514{
     1515$xml = new SimpleXMLElement(ti_Y_API('http://api-metrika.yandex.ru/counters?oauth_token='.$token,'GET'));
     1516
     1517$counters = $xml->counters;
     1518$count = (int)$counters->attributes()->count;
     1519
     1520for ($i=0;$i<$count;$i++)
     1521    {
     1522   
     1523    $data[$i]['url']=(string) $counters->counter[$i]->site;
     1524    $data[$i]['permission']=(string) $counters->counter[$i]->permission;
     1525    $data[$i]['name']=(string) $counters->counter[$i]->name;
     1526    $data[$i]['id']=(string) $counters->counter[$i]->id;
     1527    }
     1528
     1529return $data;
     1530}
     1531
     1532
     1533function ti_Y_API($url,$method)
     1534{
     1535
     1536$ch = curl_init();
     1537curl_setopt($ch, CURLOPT_URL, $url);
     1538curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     1539curl_setopt($ch, CURLOPT_HTTPHEADER, array($url, $method));
     1540curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     1541$return = curl_exec($ch);
     1542
     1543
     1544    if(curl_errno($ch))
     1545    {
     1546      return false;
     1547      echo 'Curl errno';
     1548    }
     1549
     1550    $http_code = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
     1551   
     1552    if ($http_code != 200)
     1553    {
     1554    echo $http_code;
     1555    return false;
     1556    }
     1557    else
     1558    {
     1559    return $return;
     1560   
     1561    }
     1562}
     1563
     1564
     1565
     1566
    15101567?>
Note: See TracChangeset for help on using the changeset viewer.