Exemplo n.º 1
0
/**
 * Created by JetBrains PhpStorm.
 * User: oleg
 * Date: 01.10.12
 * Time: 21:06
 * To change this template use File | Settings | File Templates.
 */
function agent_kingcoupon_pars()
{
    require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
    CModule::IncludeModule("iblock");
    CModule::IncludeModule("mytb");
    $content = file_get_contents("http://kingcoupon.ru/offer/category/Food/");
    preg_match_all("#kingcoupon\\.ru/offer/([0-9]+)/#is", $content, $arr);
    $xml = file_get_contents("http://kingcoupon.ru/offer/export/?refId=100132540459877345");
    $svg = new SimpleXMLElement($xml);
    $clubListID = array();
    foreach ($arr[1] as $var) {
        $clubListID[$var] = $var;
    }
    foreach ($svg->offers->offer as $var) {
        $R = array();
        if (in_array($var->id, $arr[1])) {
            $R['clubName'] = (string) $var->supplier->name;
            foreach ((array) $var->supplier->addresses as $address) {
                if (is_array($address)) {
                    foreach ((array) $address as $var1) {
                        $R['clubAdress'][] = (string) $var1->name;
                    }
                } else {
                    $R['clubAdress'][] = $address->name;
                }
            }
            foreach ((array) $var->supplier->tel as $tel) {
                $R['clubPhone'][] = $tel;
            }
            $id = $var->id;
            $url = preg_replace("#http://#i", "", $var->supplier->url);
            $url = preg_replace("#^([^/]+)/.*#i", "\\1", $url);
            $url = str_replace("www.", "", $url);
            $R['url'] = $url;
            $arSelect = array("ID", "NAME");
            $arFilter = array("IBLOCK_ID" => IB_CLUB_ID, "PROPERTY_SITE" => "%" . $url . "%");
            $res = CIBlockElement::GetList(array("SORT" => "DESC"), $arFilter, FALSE, FALSE, $arSelect);
            if (!$res->Fetch()) {
                $PROP = array();
                //                $PROP["PHONE"]   = $R['clubPhone'];
                //                $PROP["ADDRESS"] = $R['clubAdress'];
                $PROP["SITE"] = $R['url'];
                $PROP["LIST"] = array(54);
                $el = new CIBlockElement();
                $arLoadProductArray = array("IBLOCK_ID" => IB_CLUB_ID, "PROPERTY_VALUES" => $PROP, "NAME" => $R['clubName'], "TAGS" => "kingcoupon", "ACTIVE" => "Y", "SORT" => "0");
                if ($PRODUCT_ID = $el->Add($arLoadProductArray)) {
                    foreach ($R['clubAdress'] as $addressItem) {
                        MyTbCore::Add(array("CLUB_ID" => $PRODUCT_ID, "SITY_ID" => 1, "ADDRESS" => $addressItem, "PHONE" => serialize($R['clubPhone'])), "address");
                        printAr($addressItem);
                    }
                } else {
                    echo "Error: " . $el->LAST_ERROR;
                }
            }
        }
    }
    return "agent_kingcoupon_pars();";
}
Exemplo n.º 2
0
<?php

/**
 * User:        Олег
 * Data:        11.06.12 22:56
 * Site: http://sForge.ru
 **/
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
CModule::IncludeModule("iblock");
CModule::IncludeModule("mytb");
die;
$res = Club::getList(array(), array(), false, false, array("ID", "PROPERTY_ADDRESS", "PROPERTY_PHONE"));
$i = 0;
while ($row = $res->Fetch()) {
    foreach ($row["PROPERTY_ADDRESS_VALUE"] as $var) {
        $obj = json_decode(file_get_contents("http://geocode-maps.yandex.ru/1.x/?geocode=" . urlencode(trim($var)) . "&format=json"));
        list($LAT, $LON) = explode(" ", $obj->response->GeoObjectCollection->featureMember[0]->GeoObject->Point->pos);
        MyTbCore::Add(array("CLUB_ID" => $row["ID"], "SITY_ID" => 1, "LON" => $LON, "LAT" => $LAT, "ADDRESS" => $var, "PHONE" => serialize((array) $row["PROPERTY_PHONE_VALUE"])), "address");
    }
    $i++;
}
echo $i;
Exemplo n.º 3
0
 /**
  * Парсим новые заведения
  */
 function parse()
 {
     $i = 0;
     $count = 0;
     $content = file_get_contents($this->parsePage);
     preg_match_all($this->parseReg, $content, $arr);
     $clubListID = array();
     foreach ($arr[1] as $var) {
         $clubListID[$var] = $var;
     }
     $xml = file_get_contents($this->xml);
     $svg = new SimpleXMLElement($xml);
     foreach ($svg->offers->offer as $var) {
         $R = array();
         if (isset($clubListID[intval($var->id)])) {
             $R['clubName'] = (string) $var->supplier->name;
             foreach ((array) $var->supplier->addresses as $address) {
                 if (is_array($address)) {
                     foreach ((array) $address as $var1) {
                         $R['clubAdress'][] = (string) $var1->name;
                     }
                 } else {
                     $R['clubAdress'][] = $address->name;
                 }
             }
             foreach ((array) $var->supplier->tel as $tel) {
                 $R['clubPhone'][] = $tel;
             }
             $id = $var->id;
             $url = "";
             $url = preg_replace("#http://#i", "", trim($var->supplier->url));
             $url = preg_replace("#^([^/]+)/.*#i", "\\1", $url);
             $url = str_replace("www.", "", $url);
             $R['url'] = trim($url);
             $arSelect = array("ID", "NAME");
             $arFilter = array("IBLOCK_ID" => IB_CLUB_ID, "PROPERTY_SITE" => "%" . $url . "%");
             $res = CIBlockElement::GetList(array("SORT" => "DESC"), $arFilter, FALSE, FALSE, $arSelect);
             if (!$res->Fetch()) {
                 $PROP = array();
                 $PROP["SITE"] = trim($R['url']);
                 $PROP["LIST"] = array(PROP_CLUB_MODERATOR);
                 $el = new CIBlockElement();
                 $arLoadProductArray = array("IBLOCK_ID" => IB_CLUB_ID, "PROPERTY_VALUES" => $PROP, "NAME" => trim($R['clubName']), "TAGS" => $this->tags, "ACTIVE" => "N", "SORT" => "0");
                 if ($PRODUCT_ID = $el->Add($arLoadProductArray)) {
                     foreach ($R['clubAdress'] as $addressItem) {
                         MyTbCore::Add(array("CLUB_ID" => $PRODUCT_ID, "SITY_ID" => 1, "ADDRESS" => trim($addressItem), "PHONE" => serialize($R['clubPhone'])), "address");
                     }
                     $i++;
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
 * File name: getinfo.php
 */
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
CModule::IncludeModule("iblock");
CModule::IncludeModule("mytb");
$club_id = intval($_POST["club_id"]);
$clubInfo['NAME'] = trim($_POST["NAME"]);
$clubInfo['DETAIL_TEXT'] = trim($_POST["DESCR"]);
$clubInfo['SITE'] = trim(str_replace("http://", "", $_POST["SITE"]));
$clubInfo['EMAIL_MANAGER'] = trim($_POST["EMAIL_MANAGER"]);
$clubInfo['TIME_WORKING'] = trim($_POST["TIME_WORKING"]);
$clubInfo['AVERAGE_CHECK'] = trim($_POST["AVERAGE_CHECK"]);
$clubInfo['TYPE_FACILITY'] = (array) $_POST["KIND_CLUB"];
$clubInfo['MUSIC'] = (array) $_POST["MUSIC"];
$clubInfo['ADDRES'] = (array) $_POST["ADDRES"];
$clubInfo['ADDRES_NEW'] = (array) $_POST["ADDRES_NEW"];
foreach ($clubInfo['ADDRES'] as $address) {
    $obj = json_decode(file_get_contents("http://geocode-maps.yandex.ru/1.x/?geocode=" . urlencode(trim($address["addres"])) . "&format=json"));
    list($LAT, $LON) = explode(" ", $obj->response->GeoObjectCollection->featureMember[0]->GeoObject->Point->pos);
    $res = new MyTbCore();
    $res->update(intval($address["id"]), array("SITY_ID" => intval($address["sity"]), "ADDRESS" => trim($address["addres"]), "LON" => $LON, "LAT" => $LAT, "PHONE" => serialize(explode("\n", $address["phone"]))), "address");
}
foreach ($clubInfo['ADDRES_NEW'] as $address) {
    $obj = json_decode(file_get_contents("http://geocode-maps.yandex.ru/1.x/?geocode=" . urlencode(trim($address["addres"])) . "&format=json"));
    list($LAT, $LON) = explode(" ", $obj->response->GeoObjectCollection->featureMember[0]->GeoObject->Point->pos);
    $res = new MyTbCore();
    $res->Add(array("CLUB_ID" => $club_id, "SITY_ID" => intval($address["sity"]), "ADDRESS" => trim($address["addres"]), "LON" => $LON, "LAT" => $LAT, "PHONE" => serialize(explode("\n", $address["phone"]))), "address");
}
$clubRes = new Club($club_id);
$clubRes->update(array("NAME" => $clubInfo['NAME'], "SITE" => $clubInfo['SITE'], "EMAIL_MANAGER" => $clubInfo['EMAIL_MANAGER'], "AVERAGE_CHECK" => $clubInfo['AVERAGE_CHECK'], "TIME_WORKING" => $clubInfo['TIME_WORKING'], "TYPE_FACILITY" => $clubInfo['TYPE_FACILITY'], "MUSIC" => $clubInfo['MUSIC'], "DETAIL_TEXT" => $clubInfo['DETAIL_TEXT']));
die(json_encode(array("status" => "ok", "result" => array("ID" => $club_id, "NAME" => $clubInfo['NAME'], "PREVIEW_PICTURE" => $clubInfo['PREVIEW_PICTURE'], "SITE" => $clubInfo['PROPERTY_SITE_VALUE'], "EMAIL_MANAGER" => $clubInfo['PROPERTY_EMAIL_MANAGER_VALUE'], "AVERAGE_CHECK" => $clubInfo['PROPERTY_AVERAGE_CHECK_VALUE'], "TIME_WORKING" => $clubInfo['PROPERTY_TIME_WORKING_VALUE'], "KIND_CLUB" => (array) $clubInfo['PROPERTY_KIND_CLUB_VALUE'], "MUSIC" => (array) $clubInfo['PROPERTY_MUSIC_VALUE'], "DETAIL_TEXT" => $clubInfo['DETAIL_TEXT'], "ADDRESS" => $clubRes->getAddress()))));
Exemplo n.º 5
0
 /**
  * Обновляем список популярных клубов
  *
  * Популярность - количество подписчиков(большой приоритет) и колличество лайков в Vkontakt
  */
 function UpdatePopular()
 {
     MyTbCore::DeleteWhere("popular");
     $ob = CIBlockElement::GetList(array(), array("IBLOCK_ID" => IB_USER_PROPS, array("LOGIC" => "OR", "!PROPERTY_LINK_NEWS" => false, "!PROPERTY_LINK_EVENT" => false, "!PROPERTY_LINK_STOK" => false)), FALSE, FALSE, array("ID", "PROPERTY_USER", "PROPERTY_LINK_NEWS", "PROPERTY_LINK_EVENT", "PROPERTY_LINK_STOK"));
     $ClubList = array();
     while ($row = $ob->Fetch()) {
         foreach ($row['PROPERTY_LINK_NEWS_VALUE'] as $var) {
             $ClubList[$var]["SORT"] += 10;
             $ClubList[$var]["SUBS"]++;
         }
         foreach ($row['PROPERTY_LINK_EVENT_VALUE'] as $var) {
             $ClubList[$var]["SORT"] += 10;
             $ClubList[$var]["SUBS"]++;
         }
         foreach ($row['PROPERTY_LINK_STOK_VALUE'] as $var) {
             $ClubList[$var]["SORT"] += 10;
             $ClubList[$var]["SUBS"]++;
         }
     }
     $ob = CIBlockElement::GetList(array("ACTIVE_FROM" => "DESC"), array("IBLOCK_ID" => IB_CLUB_ID, "ACTIVE" => "Y", ">PROPERTY_RATING" => 0), FALSE, FALSE, array("ID", "PROPERTY_RATING"));
     while ($row = $ob->Fetch()) {
         $ClubList[$row["ID"]]["SORT"] += intval($row['PROPERTY_RATING_VALUE']);
     }
     if (count($ClubList)) {
         foreach ($ClubList as $clubID => $popular) {
             MyTbCore::Add(array("CLUB_ID" => $clubID, "SORT" => $popular['SORT'], "SUBS" => $popular['SUBS']), "popular");
         }
     }
     return false;
 }
Exemplo n.º 6
0
 * Created by JetBrains PhpStorm.
 * User: oleg
 * Date: 12.09.12
 * Time: 21:15
 * To change this template use File | Settings | File Templates.
 */
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
CModule::IncludeModule("iblock");
CModule::IncludeModule("mytb");
global $USER;
$userID = intval($USER::GetID());
$clubID = Club::getClubID($userID);
if ($userID <= 0) {
    die;
}
$filename = translate(basename($_FILES['qqfile']['name']));
if (!preg_match("#^.*\\.(jpg|png|gif|jpeg)\$#i", $filename)) {
    die;
}
$uploaddir = $_SERVER['DOCUMENT_ROOT'] . "/upload/tmp/" . $userID . "/";
if (!file_exists($uploaddir)) {
    @mkdir($uploaddir);
}
$uploadfile = $uploaddir . $filename;
move_uploaded_file($_FILES['qqfile']['tmp_name'], $uploadfile);
$BX_image = CFile::MakeFileArray($uploadfile);
$fid = CFile::SaveFile($BX_image, "club_photo");
$arFile = CFile::GetFileArray($fid);
$el = new MyTbCore();
$res = $el->Add(array("CLUB_ID" => $clubID, "PATH" => $arFile['SRC'], "FILE_ID" => $fid), "club_photo");
echo json_encode(array("success" => true, "src" => imgurl($arFile['SRC'], array("w" => 100, "h" => 100)), "src2" => imgurl($arFile['SRC'], array("w" => 800, "h" => 600))));