Ejemplo n.º 1
0
 public static function getNotificationRecipients($notificationID)
 {
     global $db;
     $agents = $db->select('agentsNotifications', ['agent'], ['notification' => $notificationID]);
     $toReturn = [];
     foreach ($agents as $agent) {
         array_push($toReturn, Agents::getAgent($agent));
     }
     return $toReturn;
 }
Ejemplo n.º 2
0
 public static function getAllNotificationsToShow()
 {
     global $db;
     $notifications = $db->select('notifications', '*');
     $toReturn = [];
     foreach ($notifications as $notification) {
         $notification['recipients'] = Agents::getNotificationRecipients($notification['id']);
         array_push($toReturn, $notification);
     }
     return $toReturn;
 }
Ejemplo n.º 3
0
 public static function authenticateAgent($sourceId)
 {
     $agent = new Agent($sourceId);
     $xmlStr = REC_XML;
     $db = Zend_Registry::get('my_db');
     //if authentication type is username and password
     if (Zone::getZoneAuthenticationType() == 1) {
         if (!isset($_SERVER['PHP_AUTH_USER'])) {
             GeneralError::invalidUserError($xmlStr);
             exit;
         } else {
             $username = $_SERVER['PHP_AUTH_USER'];
             $password = $_SERVER['PHP_AUTH_PW'];
             if ($agent->username == $username && $agent->password == $password) {
                 $_SESSION['username'] = $username;
                 return;
             } else {
                 ZitLog::writeToErrorLog('[Invalid User] User does not exist', 'User in agent request does not exist in the system', 'Authenticate Agent', $_SESSION['ZONE_ID'], $agent->agentId);
                 GeneralError::invalidUserError($xmlStr);
                 exit;
             }
         }
     } else {
         if (Zone::getZoneAuthenticationType() == 2) {
             if (!isset($_SERVER['SSL_CLIENT_CERT'])) {
                 ZitLog::writeToErrorLog('[Missing Certificate] Certificate is missing for agent', 'Agent request does not contain a certificate.  Zone is set to certificate authentication', 'Verify Certificate', $_SESSION['ZONE_ID'], $agent->agentId);
                 GeneralError::missingSenderCertificate($xmlStr);
                 exit;
             } else {
                 $cert = $_SERVER['SSL_CLIENT_CERT'];
                 $dn = "C: " || $_SERVER['SSL_CLIENT_S_DN_S'] || '<br/>' || "O: " || $_SERVER['SSL_CLIENT_S_DN_O'] || '<br/>' || "OU: " || $_SERVER['SSL_CLIENT_S_DN_OU'] || '<br/>' || "CN: " || $_SERVER['SSL_CLIENT_S_DN_CN'] || '<br/>' || "End Date: " || $_SERVER['SSL_CLIENT_V_END'] || '<br/>';
             }
             if ($agent->certCommonName == null || $agent->certCommonName == '' || $agent->certCommonName == ' ') {
                 $agents = new Agents($db);
                 $row = $agents->fetchRow("agent_id = " . $agent->agentId);
                 $row->cert_common_name = $cert;
                 $row->cert_common_dn = $dn;
                 $row->save();
                 $agent->certCommonName = $cert;
             }
             if ($agent->certCommonName != $cert) {
                 ZitLog::writeToErrorLog('[CN is not valid] CN of certificate is invalid', 'CN of request certificate does not match the CN setup with the agent', 'Verify Certificate', $_SESSION['ZONE_ID'], $agent->agentId);
                 GeneralError::agentCommonNameDoesNoMatch($xmlStr);
                 exit;
             }
         }
     }
     /*			if($agent->isRegistered())
     			{
     				//$remoteAddress = SifProcessRequest::getIpAddress();
     				$cn = $_SERVER['SSL_CLIENT_S_DN_CN'];
     				$result  = $_SERVER['SSL_CLIENT_VERIFY'];
     				switch($agent->getAgentRegistrationSifAuthenticationLevel())
     				{
     					case 1:
     						if($cn == null || $cn == '' || $cn == ' '){
     							ZitLog::writeToErrorLog('[Missing Certificate] Certificate is missing for agent', 'Agent request does not contain a certificate.  Zone is set to certificate authentication', 'Verify Certificate', $_SESSION['ZONE_ID'], $agent->agentId);
     							GeneralError::missingSenderCertificate(REC_XML);
     							exit;
     						}
     					break;
     					case 3:
     						if($agent->certCommonName != $cn){
     							ZitLog::writeToErrorLog('[CN is not valid] CN of certificate is invalid', 'CN of request certificate does not match the CN setup with the agent', 'Verify Certificate', $_SESSION['ZONE_ID'], $agent->agentId);
     							GeneralError::agentCommonNameDoesNoMatch(REC_XML);
     							exit;
     						}
     					break;
     				}
     			}
     */
     //		}//end authentication type check
 }
Ejemplo n.º 4
0
 /**
  * Return agent as object.
  * @return Agent
  */
 public function GetAgentObj()
 {
     if ($this->_AgentObj == null) {
         $ags = new Agents();
         $this->_AgentObj = $ags->GetAgent($this->GetAgentId());
     }
     return $this->_AgentObj;
 }
Ejemplo n.º 5
0
 /**
  * Creates query string from given params
  * @param string $select
  * @param string $sorting
  * @param array $filters
  * @return string
  */
 protected static function GetQuery($select = "SELECT * ", $sorting = "", $filters = null, $groupBy = '')
 {
     $query = $select . " FROM #S#offers AS o ";
     if ($filters != null && (array_key_exists("department", $filters) || array_key_exists("departments", $filters) || array_key_exists("NajpierwIdekiOddzialow", $filters) || array_key_exists("not_agents", $filters) || array_key_exists("not_mls", $filters))) {
         $query .= " LEFT JOIN #S#agents AS a ON o.agents_id=a.id ";
     }
     if (array_key_exists('properties', $filters)) {
         $i = 1;
         foreach ($filters['properties'] as $name => $values) {
             $query .= " INNER JOIN #S#offers_properties AS op{$i} ON (o.id = op{$i}.offers_id AND o.id_lng = op{$i}.offers_id_lng AND op{$i}.properties_id = " . OffersHelper::getProps($name) . ")";
             $i++;
         }
         if ($groupBy === '') {
             $groupBy = 'o.id';
         }
     }
     $query .= " WHERE 1=1 ";
     if ($filters != null) {
         foreach ($filters as $key => $value) {
             switch ($key) {
                 case "country":
                     $query .= " AND o.country = ?";
                     break;
                 case "floor_noFrom":
                     $query .= " AND o.floor_no >= ?";
                     break;
                 case "floor_noTo":
                     $query .= " AND o.floor_no <= ?";
                     break;
                 case "RokBudowyOd":
                     $query .= " AND CAST(o.year_of_construction AS SIGNED) >= ?";
                     break;
                 case "RokBudowyDo":
                     $query .= " AND CAST(o.year_of_construction AS SIGNED) <= ?";
                     break;
                 case "PierwszaStrona":
                     $query .= " AND o.first_page = ?";
                     break;
                 case "house_types":
                     $query .= " AND o.house_type IN (" . self::prepareStringToBind($value) . ")";
                     break;
                 case "object_types":
                     $query .= " AND o.object_type IN (" . self::prepareStringToBind($value) . ")";
                     break;
                 case "wylacznosc":
                     $query .= " AND o.contract_type LIKE ?";
                     break;
                 case "IloscOdslonWWWSort":
                     $query .= " AND o.visits_no ";
                     break;
                 case "StatusWlasnosci":
                     $query .= " AND o.ownership_status = ?";
                     break;
                 case "StanPrawny":
                     $query .= " AND o.legal_status = ?";
                     break;
                 case "umeblowanie":
                     $query .= " AND o.furnishings = ?";
                     break;
                 case "field_areaFrom":
                     $query .= " AND o.field_area >= ?";
                     break;
                 case "field_areaTo":
                     $query .= " AND o.field_area <= ?";
                     break;
                 case "zamiana":
                     $query .= " AND o.change_status = 1";
                     break;
                 case "pola_opisowe":
                     $query .= " AND (o.notices LIKE ? OR o.notices_property LIKE ?)";
                     break;
                 case "IdLng":
                     $query .= " AND o.id_lng=?";
                     break;
                 case "status":
                     $query .= " AND o.status = ?";
                     break;
                 case "statuses":
                     $query .= " AND o.status IN (" . self::prepareStringToBind($value) . ")";
                     break;
                 case "symbol":
                     $query .= " AND o.symbol LIKE ?";
                     break;
                 case "province":
                     $query .= " AND o.province = ?";
                     break;
                 case "district":
                     $query .= " AND o.district = ?";
                     break;
                 case "location":
                     $query .= " AND o.location = ?";
                     break;
                 case "object":
                     $query .= " AND o.object = ?";
                     break;
                 case "quarter":
                     $query .= " AND o.quarter = ?";
                     break;
                 case "region":
                     $query .= " AND o.region = ?";
                     break;
                 case "street":
                     $query .= " AND o.street LIKE ?";
                     break;
                 case "building_technology":
                     $query .= " AND o.building_technology = ?";
                     break;
                 case "construction_material":
                     $query .= " AND o.construction_material = ?";
                     break;
                 case "construction_status":
                     $query .= " AND o.construction_status = ?";
                     break;
                 case "construction_statuses":
                     $query .= " AND o.construction_status IN (" . self::prepareStringToBind($value) . ")";
                     break;
                 case "building_type":
                     $query .= " AND o.building_type = ?";
                     break;
                 case "priceFrom":
                     $query .= " AND o.price >= ?";
                     break;
                 case "priceTo":
                     $query .= " AND o.price <= ?";
                     break;
                 case "price_squareFrom":
                     $query .= " AND o.price_square >= ?";
                     break;
                 case "price_squareTo":
                     $query .= " AND o.price_square <= ?";
                     break;
                 case "rooms_no":
                     $query .= " AND o.rooms_no = ?";
                     break;
                 case "rooms_noFrom":
                     $query .= " AND o.rooms_no >= ?";
                     break;
                 case "rooms_noTo":
                     $query .= " AND o.rooms_no <= ?";
                     break;
                 case "areaFrom":
                     $query .= " AND o.area >= ?";
                     break;
                 case "areaTo":
                     $query .= " AND o.area <= ?";
                     break;
                 case "floorFrom":
                     $query .= " AND FLOOR(REPLACE(REPLACE(o.floor,'parter','0'),'p','')) >= ?";
                     break;
                 case "floorTo":
                     $query .= " AND FLOOR(REPLACE(REPLACE(o.floor,'parter','0'),'p','')) <= ?";
                     break;
                 case "districts":
                     $query .= " AND o.district IN (" . self::prepareStringToBind($value) . ")";
                     break;
                 case "locations":
                     $query .= " AND o.location IN (" . self::prepareStringToBind($value) . ")";
                     break;
                 case "objects":
                     $query .= " AND o.object IN (" . self::prepareStringToBind($value) . ")";
                     break;
                 case "quarters":
                     $query .= " AND o.quarter IN (" . self::prepareStringToBind($value) . ")";
                     break;
                 case "noquarters":
                     $query .= " AND o.quarter NOT IN (" . self::prepareStringToBind($value) . ")";
                     break;
                 case "locations_or_quarters":
                     $query .= " AND (o.location IN (" . self::prepareStringToBind($value) . ") OR o.quarter IN (" . self::prepareStringToBind($value) . "))";
                     break;
                 case "locations_or_quarters_or_region":
                     $query .= " AND (o.location IN (" . self::prepareStringToBind($value) . ") OR o.quarter IN (" . self::prepareStringToBind($value) . ") OR o.region IN (" . self::prepareStringToBind($value) . "))";
                     break;
                 case "quarters_or_region":
                     $query .= " AND ( o.quarter IN (" . self::prepareStringToBind($value) . ") OR o.region IN (" . self::prepareStringToBind($value) . "))";
                     break;
                 case "districts_or_locations_or_quarters_or_region":
                     $query .= " AND (o.district IN (" . self::prepareStringToBind($value) . ") OR o.location IN (" . self::prepareStringToBind($value) . ") OR o.quarter IN (" . self::prepareStringToBind($value) . ") OR o.region IN (" . self::prepareStringToBind($value) . "))";
                     break;
                 case "districts_or_locations_or_quarters_or_region_or_street":
                     $query .= " AND (o.district IN (" . self::prepareStringToBind($value) . ") OR o.location IN (" . self::prepareStringToBind($value) . ") OR o.quarter IN (" . self::prepareStringToBind($value) . ") OR o.region IN (" . self::prepareStringToBind($value) . ") OR o.street IN(" . self::prepareStringToBind($value) . ") )";
                     break;
                 case "location_or_location":
                     $query .= " AND " . self::prepareArrayToBind($value);
                     break;
                 case "building_types":
                     $query .= " AND o.building_type IN (" . self::prepareStringToBind($value) . ")";
                     break;
                 case "creationDateFrom":
                     $query .= " AND o.creation_date >= ?";
                     break;
                 case "creationDateTo":
                     $query .= " AND o.creation_date <= ?";
                     break;
                 case "modificationDateFrom":
                     $query .= " AND o.modification_date >= ?";
                     break;
                 case "modificationDateTo":
                     $query .= " AND o.modification_date <= ?";
                     break;
                 case "expirationDateFrom":
                     $query .= " AND o.expiration_date >= ?";
                     break;
                 case "video_swf":
                     $query .= " AND (o.has_swfs=1 OR o.video_link IS NOT NULL)";
                     break;
                 case "virtual_visit":
                     $query .= " AND o.has_swfs=1";
                     break;
                 case "without_virtual_visit":
                     $query .= " AND o.has_swfs=0";
                     break;
                 case "photos":
                     $query .= " AND o.has_photos=1";
                     break;
                 case "projs":
                     $query .= " AND o.has_proj=1";
                     break;
                 case "ids":
                     $query .= " AND o.id IN (" . self::prepareStringToBind($value) . ")";
                     break;
                 case "not_ids":
                     $query .= " AND o.id NOT IN (" . self::prepareStringToBind($value) . ")";
                     break;
                 case "original":
                     $query .= " AND o.original=?";
                     break;
                 case "on_map":
                     $query .= " AND o.latitude > 0 AND o.longitude > 0";
                     break;
                 case "map_bounds":
                     $query .= " AND o.latitude < ? AND o.latitude > ? AND o.longitude < ? AND o.longitude > ?";
                     break;
                 case "department":
                     $query .= " AND a.departments_id = ?";
                     break;
                 case "departments":
                     $query .= " AND a.departments_id IN (" . self::prepareStringToBind($value) . ")";
                     break;
                 case "not_agents":
                     $query .= " AND a.id NOT IN (" . self::prepareStringToBind($value) . ")";
                     break;
                 case "not_mls":
                     $query .= " AND a.id NOT IN (" . Agents::GetMLSAgentId() . ")";
                     break;
                 case "zeroprow":
                     $query .= " AND o.no_commission=1 ";
                     break;
                 case "hasUwagiOpis":
                     $query .= " AND o.notices != ''";
                     break;
                 case "kitchen_type":
                     $query .= " AND o.id IN (SELECT ofr.offers_id FROM #S#offers_rooms ofr WHERE ofr.type IN (" . self::prepareStringToBind($value) . ") )";
                     break;
                 case "SortNaWylacznosc":
                     break;
                 case "properties":
                     $query .= self::preparePropertiesToQuery($value);
                     break;
                 case "NajpierwIdekiOddzialow":
                     break;
                     //na potrzeby sortowania wg własnych oddziałów
                 //na potrzeby sortowania wg własnych oddziałów
                 default:
                     $query .= " AND o.{$key}=?";
                     break;
             }
         }
     }
     if ($groupBy) {
         $query .= " GROUP BY " . $groupBy;
     }
     if ($sorting != "") {
         if ($filters != null && array_key_exists("SortNaWylacznosc", $filters)) {
             $sorting = "id_lng ASC, CASE o.contract_type WHEN 'Umowa na wyłączność' THEN 0 ELSE 1 END ASC, o." . self::prepareSort($sorting);
             $query .= " ORDER BY " . $sorting;
         } elseif ($filters != null && array_key_exists("NajpierwIdekiOddzialow", $filters)) {
             $sort = "id_lng ASC, CASE a.departments_id ";
             $odids = explode(",", $filters["NajpierwIdekiOddzialow"]);
             foreach ($odids as $oid) {
                 $sort .= "WHEN " . $oid . " THEN 0 ";
             }
             $sort .= " ELSE 1 END ASC, ";
             $sorting = $sort . self::prepareSort($sorting);
             $query .= " ORDER BY " . $sorting;
         } else {
             $query .= " ORDER BY o." . self::prepareSort($sorting);
         }
     }
     return $query;
 }
Ejemplo n.º 6
0
 /**
  * Return agent as object.
  * @return Agent
  */
 public function GetUzytkownik()
 {
     if ($this->_IsAgentObjSet == false) {
         $this->_AgentObj = Agents::GetAgent($this->Getagents_id());
         $this->_IsAgentObjSet = true;
     }
     return $this->_AgentObj;
 }
Ejemplo n.º 7
0
<?php

require_once 'class/inc.php';
$Device = @$_POST["device"];
$task = @$_POST["task"];
$data = @$_POST["data"];
$ty = @$_GET["q"];
$xY = new Agents();
echo $xY->AgentInsert($Device, $task, base64_decode($data, true), $ty);
@header('Pragma: no-cache');
@header('Cache-Control: no-store, no-cache, max-age=0, must-revalidate');
@header("Content-type: text/xml");
Ejemplo n.º 8
0
 public static function getAllAgents()
 {
     $agents = array();
     //$db = ZitDBAdapter::getDBAdapter();
     $db = Zend_Registry::get('my_db2');
     $agt = new Agents($db);
     $adminLevel = $_SESSION['ADMIN_LEVEL'];
     $adminId = $_SESSION['ADMIN_ID'];
     if ($adminLevel == Utility::$SUPER_ADMIN) {
         $select = $agt->select()->order('source_id');
     } else {
         $select = $agt->select()->where('admin_id = ' . $adminId)->order('source_id');
     }
     $result = $agt->fetchAll($select);
     foreach ($result as $row) {
         switch (DB_TYPE) {
             case 'mysql':
                 $agent = new Agent($row->agent_id);
                 break;
             case 'oci8':
                 $agent = new Agent($row->AGENT_ID);
                 break;
         }
         array_push($agents, $agent);
     }
     return $agents;
 }
Ejemplo n.º 9
0
 /**
  * Get a list of agents to be added or remove. Write the agent to database.
  * @param int $id
  * @return int
  */
 public function GetAgenci($id = 0)
 {
     if (!$this->WS()) {
         return null;
     }
     try {
         $params = array('sid' => $this->_sid, 'id' => $id);
         $result = $this->WS()->getSC()->__soapCall("GetUserzy", array($params));
         if ($result->GetUserzyResult->Status != 0) {
             Errors::LogError("WebService:GetUserzy", "Response: " . $result->GetUserzyResult->Message);
             return 0;
         }
         $xml = simplexml_load_string($result->GetUserzyResult->XMLContent);
         $cnt = 0;
         foreach ($xml->children() as $node) {
             $agent = new Agent($node["ID"], $node->Nazwa, $node->Telefon, $node->Komorka, $node->Email, $node->Oddzial, $node->JabberLogin, $node->NrLicencji, $node->OdpowiedzialnyNazwa, $node->OdpowiedzialnyNrLicencji, $node->Komunikator, $node->PlikFoto, $node->KodPracownika, $node->DzialFunkcja);
             Agents::AddEditAgent($agent);
             echo DataBase::GetDbInstance()->LastError();
             $cnt++;
         }
         return $cnt;
     } catch (Exception $ex) {
         Errors::LogError("WebService:GetUserzy", $ex->getMessage());
         return 0;
     }
 }
Ejemplo n.º 10
0
    $id = $request->param('id');
    $data = $request->param('notificationData');
    $recipients = $request->param('notificationRecipients');
    $result = Notifications::updateNotification($id, $data, $recipients);
    if ($result > 0) {
        $response->json(Result::success('Notification Updated.'));
    } elseif ($result === 0) {
        $response->json(Result::success('Notification not Updated.'));
    } else {
        $response->json(Result::error('Notification not found'));
    }
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $notificationData = Notifications::getNotification($id);
    $notificationRecipients = Agents::getNotificationRecipients($id);
    $result = array("notificationData" => $notificationData, "notificationRecipients" => $notificationRecipients);
    if ($result) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('Notification not found'));
    }
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = Notifications::deleteNotification($id);
    if ($result > 0) {
        $response->json(Result::success('Notification Deleted.'));
    } else {
        $response->json(Result::error('Notification not Deleted'));
    }
Ejemplo n.º 11
0
<?php

require_once 'class/inc.php';
$Device = @$_POST["device"];
$GEO = @$_POST["geo"];
$xY = new Agents();
if ($xY->KontrolEt($Device) != "true") {
    $xY->AgentAdd($Device);
}
$xY->AgentStat($Device);
echo $xY->GetAgentTastList($Device);
$xY->AgentStatUp();
@header('Pragma: no-cache');
@header('Cache-Control: no-store, no-cache, max-age=0, must-revalidate');
@header("Content-type: text/xml");
Ejemplo n.º 12
0
    $demandsResult = Demands::deleteAgentDemands($id);
    $trackedAssetsResult = TrackedAssets::deleteAgentTrackedAssets($id);
    $lidsResult = Lids::deleteAgentLids($id);

    if ($agentResult['status'] == -1)
        $response->json($agentResult);

    if ($logsResult['status'] == -1)
        $response->json($logsResult);

    if ($notificationsResult['status'] == -1)
        $response->json($notificationsResult);

    if ($conversationsResult['status'] == -1)
        $response->json($conversationsResult);

    if ($demandsResult['status'] == -1)
        $response->json($demandsResult);

    if ($trackedAssetsResult['status'] == -1)
        $response->json($trackedAssetsResult);

    if ($lidsResult['status'] == -1)
        $response->json($lidsResult);

    $response->json(Result::success('Agent removed successfully.'));
});*/
$this->respond(['GET', 'POST'], '/get/all', function ($request, $response, $service, $app) {
    $result = Agents::getAllAgents();
    $response->json(Result::success('', $result));
});
Ejemplo n.º 13
0
 /**
  * Starts site synchronization process.
  * @return string
  */
 public function SynchronizeSite()
 {
     if (!$this->checkwebext()) {
         return "Function unavailable in this version.";
     }
     try {
         if (WebServiceWeb::WS()) {
             WebServiceWeb::WS()->LoginEx();
             $ret1 = WebServiceWeb::WS()->GetService();
             $ret2 = $ret3 = $ret4 = $ret5 = $ret6 = $ret7 = $ret8 = $ret9 = $ret10 = $ret11 = $ret12 = $ile = 0;
             if ($ret1 != 0) {
                 Miejsca::DeleteMiejsce(0, 0);
                 $ret2 = WebServiceWeb::WS()->GetMiejsca();
                 Menus::DeleteMenu(0);
                 $ret3 = WebServiceWeb::WS()->GetMenu();
                 Artykuly::DeleteArtykul(0);
                 $ret4 = WebServiceWeb::WS()->GetArtykuly();
                 ArkuszeSkrypty::DeleteArkuszSkrypt(0, 0);
                 $ret5 = WebServiceWeb::WS()->GetArkuszeSkrypty();
                 Banery::DeleteBaner(0);
                 $ret6 = WebServiceWeb::WS()->GetBanery();
                 Opcje::DeleteOpcja(null);
                 $ret7 = WebServiceWeb::WS()->GetOpcje();
                 JezykiTeksty::DeleteJezyk(null);
                 $ret8 = WebServiceWeb::WS()->GetJezyki();
                 $ret9 = WebServiceWeb::WS()->GetGalerie();
                 Agents::DeleteAgent(0);
                 $ret10 = WebServiceWeb::WS()->GetAgenci();
                 Departments::DeleteDepartment(0);
                 $ret11 = WebServiceWeb::WS()->GetOddzialy();
                 Osoby::DeleteOsoba(null);
                 $ret12 = WebServiceWeb::WS()->GetOsoby();
                 $ile = WebServiceWeb::WS()->HasNewsLetter();
                 $this->SaveParam(WebAPI::PARAM_HAS_NEWSLETTER, $ile > 0 ? 1 : 0);
                 GaleriePozycje::IndeksujGaleriePozycjeDlaArtykulow();
                 if (Config::$UseOptionsDiskCache) {
                     $this->ClearOptionsCache();
                 }
                 if (Config::$UseLanguageDiskCache) {
                     $this->ClearLanguageCache();
                 }
             }
             WebServiceWeb::WS()->Logout();
             return "Serwisy: {$ret1}, Miejsca: {$ret2}, Menu: {$ret3}, Artykuly: {$ret4}, Arkusze/JS: {$ret5}, Banery: {$ret6}, Opcje: {$ret7}, Jezyki: {$ret8}, Galerie: {$ret9}, NewsL: {$ile}, Agenci: {$ret10}, Oddzialy: {$ret11}, Osoby: {$ret12}";
         } else {
             return 'Error: WebServiceWeb not available';
         }
     } catch (Exception $ex) {
         Errors::LogError("WebAPI:SynchronizeSite", $ex->getMessage());
         return "ERROR";
     }
 }
Ejemplo n.º 14
0
\t\t}

</script>

EOF;
$GO_SECURITY->authenticate();
require $GO_LANGUAGE->get_language_file('opentts');
//see if the user has access to this module
//for this to work there must be a module named 'example'
$GO_MODULES->authenticate('opentts');
//set the page title for the header file
$page_title = "Opentts";
require $GO_THEME->theme_path . "header.inc";
$tts = new db();
require_once "classes.php";
$myagents = new Agents();
$myagents->sql_fetch_array();
$textmenu = menu("entry.php", '');
eval($textmenu);
$tabtable = new tabtable('newticket_tabtable', $helpdesk_title_entry, '100%', '400');
$tabtable->print_head();
if (Security::is_action_allowed("enter_new_ticket")) {
    $t_from = Security::get_uname();
    $time = time();
    $post_date = date("{$_SESSION['GO_SESSION']['date_format']} H:i", $time);
    $end_date_d_m_y = $due_date_d_m_y = date("{$_SESSION['GO_SESSION']['date_format']} H:i", $time);
    $end_date_h = $due_date_h = date("H", $time);
    $end_date_i = $due_date_i = round(date("i", $time) / 100, 1) * 100;
    $complete = "<select name='complete'  class=textbox>" . "<option value='0'>0%</option>" . "<option value='10'>10%</option>" . "<option value='20'>20%</option>" . "<option value='30'>30%</option>" . "<option value='40'>40%</option>" . "<option value='50'>50%</option>" . "<option value='60'>60%</option>" . "<option value='70'>70%</option>" . "<option value='80'>80%</option>" . "<option value='90'>90%</option>" . "<option value='100'>100%</option>" . "</select>";
    $t_categories = fill_select("t_category", "{$prefix}{$hlpdsk_prefix}_categories", "category_id", "category_name", " order by category_name");
    $t_priorities = fill_select("t_priority", "{$prefix}{$hlpdsk_prefix}_priorities", "priority_id", "priority_name", " ");
 public function post_create_client($POST)
 {
     $ignoreCaps = array("password");
     foreach ($POST as $POST_KEY => $POST_VALUE) {
         if (!in_array($POST_KEY, $ignoreCaps)) {
             $POST[$POST_KEY] = strtoupper($POST_VALUE);
         }
     }
     $POST['billingPhone'] = preg_replace("/[^0-9]/", "", $POST['billingPhone']);
     if (strlen($POST['billingPhone']) === 10) {
         $POST['billingPhone'] = "(" . substr($POST['billingPhone'], 0, 3) . ")" . substr($POST['billingPhone'], 3, 3) . "-" . substr($POST['billingPhone'], -4);
     }
     $error = "";
     $Database = new Database($this->environment, $this->connection, $this->security);
     $Agent = new Agents($this->environment, $this->connection, $this->security);
     $User = new Users($this->environment, $this->connection, $this->security);
     $Company = new Company($this->environment, $this->connection, $this->security);
     $Provider = new Provider($this->environment, $this->connection, $this->security);
     if (!isset($POST['clientid'])) {
         $return_trans = $this->post_recurring_profile_details($POST);
         if ($return_trans['result']) {
             $type = "create";
             $return_client = $Company->post_automated_register_new_client($POST);
         } else {
             $error = "Failed to insert the transaction record. Reason: " . $return_trans['response'];
         }
     } else {
         $type = "update";
         $return_client = $Company->get_automated_register_client_info($POST);
         $nameSplit = explode(" ", $return_client['response']['contact']);
         $POST['name'] = $nameSplit[0];
         $POST['lname'] = $nameSplit[1];
         $POST['title'] = "ADMINISTRATOR";
         $POST['email'] = $return_client['response']['email'];
         $POST['billingPhone'] = $return_client['response']['phone1'];
         $POST['addonBox'] = $return_client['response']['clienttype'];
         $POST['agency'] = $return_client['response']['cotype'];
         $POST['licenseNum'] = $return_client['response']['userlicensenum'];
     }
     if (empty($error)) {
         if ($return_client['result']) {
             $POST['clientid'] = isset($return_client['clientid']) ? $return_client['clientid'] : $return_client['response']['id'];
             $return_database = $Database->post_automated_register_new_database($POST);
             if ($return_database['result']) {
                 $POST['qdatabase'] = $return_database['qdatabase'];
                 $return_provider = $Provider->post_automated_register_new_provider($POST);
                 if ($return_provider['result']) {
                     $return_agent = $Agent->post_automated_register_new_agent($POST);
                     if ($return_agent['result']) {
                         $POST['agentid'] = $return_agent['agentid'];
                         $return_user = $User->post_automated_register_new_user($POST);
                         if ($return_user['result']) {
                             $POST['userid'] = $return_user['userid'];
                             $return_company = $Company->post_automated_register_new_company($POST);
                             if ($return_company['result']) {
                                 $return_client = $Company->post_automated_register_activate_client($POST);
                                 $this->post_send_confirmation_email($POST);
                                 //send confirmation email
                                 if (!$return_user['result']) {
                                     $error = "Failed to activate the client. Reason: " . $return_client['response'];
                                 }
                             } else {
                                 $error = "Failed to update company information. Reason: " . $return_company['response'];
                             }
                         } else {
                             $error = "Failed to create the user record. Reason: " . $return_user['userid'];
                         }
                     } else {
                         $error = "Failed to create the agent record. Reason: " . $return_agent['agentid'];
                     }
                 } else {
                     $error = "Failed to create the provider record. Reason: " . $return_provider['provid'];
                 }
             } else {
                 $error = $return_database['error'];
             }
         } else {
             $error = "Failed to {$type} the client record. Reason: " . $return_client['clientid'];
         }
     }
     if (!empty($error)) {
         $Database->post_automated_register_remove_database($POST);
         $User->post_automated_register_remove_user($POST);
         // we don't want to remove the client database reference because that one will hold the transaction express client id...since they have already paid at this point, we don't want to lose that.
     }
     return array("result" => empty($error), "error" => $error);
 }
Ejemplo n.º 16
0
 public static function checkSourceId($sourceId)
 {
     $db = Zend_Registry::get('my_db');
     $agent = new Agents($db);
     $quote_sourceId = $db->quote($sourceId);
     $result = $agent->fetchAll("source_id = '" . $sourceId . "'");
     $count = $result->count();
     if ($count != 0) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 17
0
    $data = json_decode($request->body(), true);
    // Access only for Current Agent
    if (!Agents::isAdmin() && !Agents::isCurrentAgent($id)) {
        $response->json(Result::error('Access is denied'));
    } else {
        $result = Agents::updateAgent($id, $data);
        if ($result > 0) {
            $response->json(Result::success('Agent Updated.'));
        } elseif ($result === 0) {
            $response->json(Result::success('Agent not Updated.'));
        } else {
            $response->json(Result::error('Agent not found'));
        }
    }
});
$this->respond(['GET', 'POST'], '/edit/password/[:id]', function ($request, $response, $service) {
    $id = $request->param('id');
    $oldPassword = $request->param('oldPassword', '');
    $newPassword = $request->param('newPassword', '');
    // Access only for Current Agent
    if (!Agents::isAdmin() && !Agents::isCurrentAgent($id)) {
        $response->json(Result::error('Access is denied'));
    } else {
        $result = User::editPassword($oldPassword, $newPassword, $newPassword);
        if ($result === true) {
            $response->json(Result::success('edited password successfully'));
        } else {
            $response->json(Result::error($result));
        }
    }
});
Ejemplo n.º 18
0
    $id = $request->param('id');
    $logData = $request->param('logData');
    $agents = $request->param('logAgents');
    $result = Logs::updateLog($id, $logData, $agents);
    if ($result > 0) {
        $response->json(Result::success('Log Updated.'));
    } elseif ($result === 0) {
        $response->json(Result::success('Log not Updated.'));
    } else {
        $response->json(Result::error('Log not found'));
    }
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $logData = Logs::getLog($id);
    $agents = Agents::getLogAgents($id);
    $notes = Notes::getLogNotes($id);
    $result = array("logData" => $logData, "logAgents" => $agents, "logNotes" => $notes);
    if ($logData) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('Log not found'));
    }
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = Logs::deleteLog($id);
    if ($result > 0) {
        $response->json(Result::success('Log Deleted.'));
    } else {
        $response->json(Result::error('Log not Deleted'));
Ejemplo n.º 19
0
 /**
  * Returns a list of agents for given investment.
  * @param Investment $inv
  * @return Agent[]
  */
 public static function GetInvestmentsAgents(Investment $inv)
 {
     $result = DataBase::GetDbInstance()->ExecuteQueryWithParams("SELECT a.id FROM #S#agents a INNER JOIN #S#investments_agents ia ON ia.agents_id=a.id WHERE ia.investments_id=?", array($inv->GetId()));
     if ($result) {
         $list = array();
         while ($row = DataBase::GetDbInstance()->FetchArray($result)) {
             $list[count($list)] = Agents::GetAgent($row[0]);
         }
     }
     return $list;
 }
Ejemplo n.º 20
0
 /**
  * Get a list of investments to be added or remove. Write the investments to the database.
  */
 public function GetInvestments()
 {
     //echo "start<br>";
     if (!$this->WS()) {
         return null;
     }
     try {
         if ($this->_sid == "") {
             return;
         }
         $params = array('sid' => $this->_sid);
         $result = $this->WS()->getSC()->__soapCall("GetInvestments", array($params));
         if ($result->GetInvestmentsResult->Status != 0) {
             return $result->GetInvestmentsResult->Message;
         }
         $buf = $result->GetInvestmentsResult->OffersZip;
         $f = fopen(self::TMP_ZIP_FILE, "w");
         fwrite($f, $buf);
         fclose($f);
         //unzip XML file with offers
         $zip = new ZipArchive();
         if ($zip->open(self::TMP_ZIP_FILE)) {
             $fp = $zip->getStream('xml.xml');
             if (!$fp) {
                 exit("failed reading xml file (" . getcwd() . ")\n");
             }
             $contents = '';
             while (!feof($fp)) {
                 $contents .= fread($fp, 2);
             }
             fclose($fp);
             $zip->close();
             file_put_contents(self::TMP_XML_INV_FILE, $contents);
             if (file_exists(self::TMP_ZIP_FILE)) {
                 unlink(self::TMP_ZIP_FILE);
             }
         }
         //open and read XML file
         $xml = simplexml_load_file(self::TMP_XML_INV_FILE);
         $investmentsNode = null;
         //read main nodes
         foreach ($xml->children() as $child) {
             //echo "<br />" . $child->getName() . ": " . $child;
             if ($child->getName() == "Inwestycje") {
                 $investmentsNode = $child;
             }
         }
         //read investments
         $importedInv = "";
         $count = 0;
         foreach ($investmentsNode->children() as $node) {
             $count++;
             $importedInv .= $node["ID"] . ",";
             //read major properties
             $garage = $node->Garaz == "True" ? 1 : 0;
             $pool = $node->Basen == "True" ? 1 : 0;
             $ter = $node->Taras == "True" ? 1 : 0;
             $ac = $node->Klimatyzacja == "True" ? 1 : 0;
             $spec = $node->Specjalna == "True" ? 1 : 0;
             $proj = $node->Projekt == "True" ? 1 : 0;
             $investment = new Investment($node["Jezyk"], $node["ID"], CheckNumeric($node["Lp"]), $node->Numer, $node->Nazwa, $node->Opis, $node->OpisSkrot, $node->DaneKontaktowe, $node->MapMar, $garage, $pool, $ter, $ac, $proj, $spec, $node->DataUtworzenia, $node->TerminOddania, CheckNumeric($node->PowierzchniaCalkowita), CheckNumeric($node->KubaturaBrutto), CheckNumeric($node->MetrazOd), CheckNumeric($node->MetrazDo), CheckNumeric($node->CenaOd), CheckNumeric($node->CenaDo), CheckNumeric($node->CenaM2Od), CheckNumeric($node->CenaM2Do), CheckNumeric($node->PietroOd), CheckNumeric($node->PietroDo), CheckNumeric($node->PokojeOd), CheckNumeric($node->PokojeDo), $node->Kraj == "" ? null : $node->Kraj, $node->Wojewodztwo == "" ? null : $node->Wojewodztwo, $node->Powiat == "" ? null : $node->Powiat, $node->Lokalizacja == "" ? null : $node->Lokalizacja, $node->Dzielnica == "" ? null : $node->Dzielnica, $node->Rejon == "" ? null : $node->Rejon, $node->Ulica, $node->Kategoria, $node["Oddzial"]);
             $photosNode = null;
             $lngsNode = null;
             $buildingsNode = null;
             $agentsNode = null;
             //read properties
             foreach ($node->children() as $propNode) {
                 if ($propNode->getName() == "Zdjecia") {
                     $photosNode = $propNode;
                 } else {
                     if ($propNode->getName() == "Jezyki") {
                         $lngsNode = $propNode;
                     } else {
                         if ($propNode->getName() == "Budynki") {
                             $buildingsNode = $propNode;
                         } else {
                             if ($propNode->getName() == "Agenci") {
                                 $agentsNode = $propNode;
                             } else {
                                 if ($propNode->getName() == "PolaDynamiczne") {
                                     //delete unuse properties from offer
                                     $addedProperties = array();
                                     foreach ($propNode->children() as $listNode) {
                                         $pname = (string) $listNode["Nazwa"];
                                         $investment->__set($pname, $listNode);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             //save investment object to database
             Investments::AddEditInvestment($investment);
             echo DataBase::GetDbInstance()->LastError();
             //delete unuse properties from offer
             $addedProperties = array();
             foreach ($node->children() as $propNode) {
                 $pname = $propNode->getName();
                 if ($pname == "PolaDynamiczne") {
                     foreach ($propNode->children() as $listNode) {
                         $pname = (string) $listNode["Nazwa"];
                         $prop = Properties::GetPropertyName($pname);
                         if ($prop != null) {
                             $addedProperties[count($addedProperties)] = $prop->GetID();
                         }
                     }
                 }
             }
             Investments::DeleteUnUseProperties($investment->GetId(), $investment->GetIdLng(), $addedProperties);
             //photos
             if ($photosNode != null) {
                 $addedPhotos = array();
                 foreach ($photosNode->children() as $photoNode) {
                     $intro = $photoNode->intro == "True" ? 1 : 0;
                     $photo = new OfferPhoto($photoNode['ID'], null, $investment->GetId(), $photoNode->plik, $photoNode->opis, $photoNode['lp'], $photoNode['typ'], $intro, null, (string) $photoNode->LinkFilmYouTube, (string) $photoNode->LinkMiniaturkaYouTube);
                     OfferPhotos::AddEditPhoto($photo);
                     echo DataBase::GetDbInstance()->LastError();
                     $addedPhotos[count($addedPhotos)] = $photo->GetId();
                 }
                 OfferPhotos::DeleteUnUsePhotos(0, $addedPhotos, $investment->GetId());
             }
             //buildings
             if ($buildingsNode != null) {
                 $importedBlds = "";
                 foreach ($buildingsNode->children() as $buildingNode) {
                     $importedBlds .= $buildingNode["ID"] . ",";
                     $building = new InvestmentBuilding(null, $buildingNode['ID'], $buildingNode->Nazwa, $buildingNode['Symbol'], $buildingNode->Opis, $investment->GetId(), CheckNumeric($buildingNode['Metraz']), $buildingNode->TerminOddania, CheckNumeric($buildingNode['LiczbaPieter']));
                     Investmentbuildings::AddEditInvestmentBuilding($building);
                     echo DataBase::GetDbInstance()->LastError();
                     //add offers to building
                     $offersNode = $buildingNode->Oferty;
                     Investmentbuildings::AddOffersToBuilding($offersNode, $building);
                 }
                 //delete buildings
                 $importedBlds = substr($importedBlds, 0, strlen($importedBlds) - 1);
                 if ($importedBlds != "") {
                     $result = DataBase::GetDbInstance()->ExecuteQuery("SELECT id FROM #S#investments_buildings WHERE investments_id=" . $investment->GetId() . " AND id NOT IN({$importedBlds})");
                     while ($row = DataBase::GetDbInstance()->FetchArray($result)) {
                         Investmentbuildings::DeleteInvestmentBuilding($row[0]);
                         echo DataBase::GetDbInstance()->LastError();
                     }
                 }
             }
             //agenci
             if ($agentsNode != null) {
                 foreach ($agentsNode->children() as $aNode) {
                     $a = Agents::GetAgent($aNode['wartosc']);
                     if ($a != null) {
                         Investments::AddInvestmentsAgent($investment, $a);
                     }
                 }
             }
         }
         //delete investments
         $importedInv = substr($importedInv, 0, strlen($importedInv) - 1);
         if ($importedInv == "") {
             $importedInv = "-1";
         }
         $result = DataBase::GetDbInstance()->ExecuteQuery("SELECT id FROM #S#investments WHERE id NOT IN({$importedInv})");
         while ($row = DataBase::GetDbInstance()->FetchArray($result)) {
             Investments::DeleteInvestment($row[0]);
             //delete agents_investments relation
             Investments::DelInvestmentsAgents($row[0]);
             echo DataBase::GetDbInstance()->LastError();
         }
         return $count;
     } catch (Exception $ex) {
         Errors::LogError("WebServiceVirgo:GetInvestments", $ex->getMessage() . "; " . $ex->getTraceAsString());
         return 0;
     }
 }
Ejemplo n.º 21
0
    $response->header('Content-Type', 'application/json');
    if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) {
        $response->header('Access-Control-Allow-Headers', $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']);
    }
});
// Lock not logged in users from accessing the private api.
$klein->respond(['POST', 'GET', 'OPTIONS'], "{$privateControllersBase}/[*]", function ($request, $response, $service) use($klein) {
    if (User::isLoggedIn() !== true) {
        $response->json('You are not allowed to access this page.');
        $klein->skipRemaining();
        // Skip remaining routing matches.
    }
});
// Lock not admins users from accessing the admin api.
$klein->respond(['POST', 'GET', 'OPTIONS'], "{$adminControllersBase}/[*]", function ($request, $response, $service) use($klein) {
    if (Agents::isAdmin() !== true) {
        $response->json('You are not allowed to access this page.');
        $klein->skipRemaining();
        // Skip remaining routing matches.
    }
});
$klein->respond(['POST', 'GET', 'OPTIONS'], "{$publicControllersBase}/[*]", function ($request, $response, $service) use($klein) {
});
$publicControllers = ['users'];
$privateControllers = ['agents', 'assets-invest', 'assets-rent', 'contacts', 'control-panel', 'demands', 'investors', 'lids-for-review', 'logs', 'matching', 'notifications', 'rent-demands', 'rent-areas', 'rent-processes', 'tracked-assets', 'notes', 'conversations', 'investment-profiles', 'regions', 'files'];
$adminControllers = ['agents', 'control-panel'];
foreach ($publicControllers as $controller) {
    $klein->with("{$publicControllersBase}/{$controller}", "controllers/public/{$controller}.php");
}
foreach ($privateControllers as $controller) {
    $klein->with("{$privateControllersBase}/{$controller}", "controllers/private/{$controller}.php");