Example #1
1
 public static function ConvertFromDB($arProperty, $value)
 {
     if (strlen($value["VALUE"]) > 0) {
         $value["VALUE"] = CDatabase::FormatDate($value["VALUE"], "YYYY-MM-DD", CLang::GetDateFormat("SHORT"));
     }
     return $value;
 }
Example #2
0
 public function executeStatements()
 {
     $CDatabase = new CDatabase();
     $execSql = $CDatabase->prepare(implode($this->sql));
     $execSql->execute();
     $stmt = $CDatabase->prepare(implode($this->result));
     $stmt->execute();
     $res = $stmt->fetchAll(PDO::FETCH_ASSOC);
     return $this->generateHTMLTableResult($res);
 }
Example #3
0
function addBloggsAndPagesToNavbar()
{
    //connnect to database
    global $urbax;
    $db = new CDatabase($urbax['database']);
    //defalut navigaion items
    $arr = array(new CMenuItem('CTextFilter', '?p=ctextfilter'), new CMenuItem('CContent ->', '?p=contentreset'), array(new CMenuItem('Återställ', '?p=contentreset'), new CMenuItem('Nytt innehåll', '?p=contentadd'), new CMenuItem('Editera innehåll', '?p=contentedit'), new CMenuItem('Radera', '?p=contentdelete')), new CMenuItem('CPage', '?p=contentpage'), new CMenuItem('CBlogg', '?p=contentblogg'));
    //fetch pages
    $pages = $db->ExecuteSelectQueryAndFetchAll("SELECT title, url FROM Content WHERE type='page' AND deleted IS NULL");
    //add pages to navigation
    if (count($pages) > 0) {
        $pagesNavItem = new CMenuItem('Webbsidor ->', '?p=contentpage');
        $subPages = null;
        foreach ($pages as $navItem) {
            //get text
            $text = ucfirst($navItem->title);
            //and shorten it if needed...
            if (strlen($text) > 20) {
                $text = substr($text, 0, 17) . '...';
            }
            //get url
            $url = $navItem->url;
            //add to array
            $subPages[] = new CMenuItem($text, '?p=contentpage&url=' . $url);
        }
        //add 'headline'
        $arr[] = $pagesNavItem;
        //add subpages
        $arr[] = $subPages;
    }
    //fetch blogposts
    $posts = $db->ExecuteSelectQueryAndFetchAll("SELECT title, slug FROM Content WHERE type='post' AND deleted IS NULL");
    //add pages to navigation
    if (count($posts) > 0) {
        $postsNavItem = new CMenuItem('Bloggposter ->', '?p=contentblogg');
        $subPages = null;
        foreach ($posts as $navItem) {
            //get text
            $text = ucfirst($navItem->title);
            //and shorten it if needed...
            if (strlen($text) > 20) {
                $text = substr($text, 0, 17) . '...';
            }
            //get slug
            $slug = $navItem->slug;
            //add to array
            $subPages[] = new CMenuItem($text, '?p=contentblogg&slug=' . $slug);
        }
        //add 'headline'
        $arr[] = $postsNavItem;
        //add subpages
        $arr[] = $subPages;
    }
    return $arr;
}
Example #4
0
 public function Lookup()
 {
     $DB = CDatabase::GetModuleConnection('statistic');
     if ($this->city_avail && $this->ip_number) {
         $rs = $DB->Query("\n\t\t\t\tSELECT *\n\t\t\t\tFROM b_stat_city_ip\n\t\t\t\tWHERE START_IP = (\n\t\t\t\t\tSELECT MAX(START_IP)\n\t\t\t\t\tFROM b_stat_city_ip\n\t\t\t\t\tWHERE START_IP <= " . $this->ip_number . "\n\t\t\t\t)\n\t\t\t\tAND END_IP >= " . $this->ip_number . "\n\t\t\t", true);
         if ($rs) {
             $ar = $rs->Fetch();
             if ($ar) {
                 $this->country_code = $ar["COUNTRY_ID"];
                 $this->city_id = $ar["CITY_ID"];
             }
         } else {
             //Here is mysql 4.0 version which does not supports subqueries
             //and not smart to optimeze query
             $rs = $DB->Query("\n\t\t\t\t\tSELECT START_IP\n\t\t\t\t\tFROM b_stat_city_ip\n\t\t\t\t\tWHERE START_IP <= " . $this->ip_number . "\n\t\t\t\t\tORDER BY START_IP DESC\n\t\t\t\t\tLIMIT 1\n\t\t\t\t");
             $ar = $rs->Fetch();
             if ($ar && strlen($ar["START_IP"]) > 0) {
                 $rs = $DB->Query("\n\t\t\t\t\t\tSELECT *\n\t\t\t\t\t\tFROM b_stat_city_ip\n\t\t\t\t\t\tWHERE START_IP = " . $ar["START_IP"] . "\n\t\t\t\t\t\tAND END_IP >= " . $this->ip_number . "\n\t\t\t\t\t");
                 $ar = $rs->Fetch();
                 if ($ar) {
                     $this->country_code = $ar["COUNTRY_ID"];
                     $this->city_id = $ar["CITY_ID"];
                 }
             }
         }
     }
     if (!$this->country_code && $this->country_avail) {
         $this->country_code = i2c_get_country();
     }
 }
Example #5
0
 function InitStep()
 {
     global $DB;
     $wizard =& $this->GetWizard();
     $node_id = intval($wizard->GetVar('node_id'));
     if (!CModule::IncludeModule('cluster')) {
         $this->SetError(GetMessage('CLUWIZ_NO_MODULE_ERROR'));
     } elseif ($DB->type != "MYSQL") {
         $this->SetError(GetMessage('CLUWIZ_DATABASE_NOT_SUPPORTED'));
     } elseif ($node_id <= 1) {
         $this->SetError(GetMessage('CLUWIZ_NO_NODE_ERROR'));
     } else {
         $this->arNode = CClusterDBNode::GetByID($node_id);
         if (!is_array($this->arNode)) {
             $this->SetError(GetMessage('CLUWIZ_NO_NODE_ERROR'));
         } else {
             // $arNode["ROLE_ID"] == "SLAVE"
             // $arNode["STATUS"] == "READY"
             $this->nodeDB = CDatabase::GetDBNodeConnection($this->arNode["ID"], true, false);
             if (!is_object($this->nodeDB)) {
                 $this->SetError(GetMessage('CLUWIZ_NO_CONN_ERROR'));
             }
         }
     }
 }
Example #6
0
 function DelayedStemIndex()
 {
     $DB = CDatabase::GetModuleConnection('search');
     $etime = time() + intval(COption::GetOptionString("search", "agent_duration"));
     do {
         $stemQueue = $DB->Query($DB->TopSql("\n\t\t\t\tSELECT SEARCH_CONTENT_ID ID\n\t\t\t\tFROM b_search_content_stem\n\t\t\t\tWHERE SEARCH_CONTENT_ID < 0\n\t\t\t", 1));
         if ($stemTask = $stemQueue->Fetch()) {
             $ID = -$stemTask["ID"];
             $sites = array();
             $rsSite = $DB->Query("\n\t\t\t\t\tSELECT SITE_ID, URL\n\t\t\t\t\tFROM b_search_content_site\n\t\t\t\t\tWHERE SEARCH_CONTENT_ID = " . $ID . "\n\t\t\t\t");
             while ($arSite = $rsSite->Fetch()) {
                 $sites[$arSite["SITE_ID"]] = $arSite["URL"];
             }
             if (BX_SEARCH_VERSION > 1) {
                 $sql = "SELECT SEARCHABLE_CONTENT from b_search_content_text WHERE SEARCH_CONTENT_ID = {$ID}";
             } else {
                 $sql = "SELECT SEARCHABLE_CONTENT from b_search_content WHERE ID = {$ID}";
             }
             $rsContent = $DB->Query($sql);
             if ($arContent = $rsContent->Fetch()) {
                 $DB->Query("DELETE FROM b_search_content_stem WHERE SEARCH_CONTENT_ID = " . $ID);
                 CSearch::StemIndex($sites, $ID, $arContent["SEARCHABLE_CONTENT"]);
             }
             $DB->Query("DELETE FROM b_search_content_stem WHERE SEARCH_CONTENT_ID = " . $stemTask["ID"]);
         } else {
             //Cancel the agent
             return "";
         }
     } while ($etime >= time());
     return "CSearchStemTable::DelayedStemIndex();";
 }
Example #7
0
	public static function GetLastByID($ID)
	{
		$DB = CDatabase::GetModuleConnection('statistic');
		$ID = intval($ID);
		if($ID>0)
		{
			$strSql = "
				SELECT
					G.ID,
					G.FAVORITES,
					G.LAST_USER_ID,
					A.ID as LAST_ADV_ID,
					if(to_days(curdate())=to_days(G.LAST_DATE), 'Y', 'N') LAST
				FROM b_stat_guest G
				LEFT JOIN b_stat_adv A ON A.ID = G.LAST_ADV_ID
				WHERE G.ID='$ID'
				";
			$res = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
		}
		else
		{
			$res = new CDBResult;
			$res->InitFromArray(array());
		}
		return $res;
	}
Example #8
0
 function GetList(&$by, &$order, $arFilter = array(), &$is_filtered)
 {
     $err_mess = "File: " . __FILE__ . "<br>Line: ";
     $DB = CDatabase::GetModuleConnection('statistic');
     $arSqlSearch = array();
     $strSqlSearch = "";
     if (is_array($arFilter)) {
         foreach ($arFilter as $key => $val) {
             if (is_array($val)) {
                 if (count($val) <= 0) {
                     continue;
                 }
             } else {
                 if (strlen($val) <= 0 || $val === "NOT_REF") {
                     continue;
                 }
             }
             $match_value_set = array_key_exists($key . "_EXACT_MATCH", $arFilter);
             $key = strtoupper($key);
             switch ($key) {
                 case "LAST":
                     $arSqlSearch[] = $val == "Y" ? "S.DATE_STAT = curdate()" : "S.DATE_STAT<>curdate()";
                     break;
                 case "USER_AGENT":
                     $match = $arFilter[$key . "_EXACT_MATCH"] == "Y" && $match_value_set ? "N" : "Y";
                     $arSqlSearch[] = GetFilterQuery("S.USER_AGENT", $val, $match);
                     break;
                 case "COUNTER1":
                     $arSqlSearch_h[] = "COUNTER>=" . intval($val);
                     break;
                 case "COUNTER2":
                     $arSqlSearch_h[] = "COUNTER<=" . intval($val);
                     break;
             }
         }
         for ($i = 0; $i < count($arSqlSearch_h); $i++) {
             $strSqlSearch_h .= " and (" . $arSqlSearch_h[$i] . ") ";
         }
     }
     if ($by == "s_user_agent") {
         $strSqlOrder = "ORDER BY S.USER_AGENT";
     } elseif ($by == "s_counter") {
         $strSqlOrder = "ORDER BY COUNTER";
     } else {
         $by = "s_counter";
         $strSqlOrder = "ORDER BY COUNTER";
     }
     if ($order != "asc") {
         $strSqlOrder .= " desc ";
         $order = "desc";
     }
     $strSqlSearch = GetFilterSqlSearch($arSqlSearch);
     $strSql = "SET OPTION SQL_BIG_SELECTS=1";
     $res = $DB->Query($strSql, false, $err_mess . __LINE__);
     $strSql = "\n\t\t\tSELECT\n\t\t\t\tS.USER_AGENT,\n\t\t\t\tcount(S.ID) COUNTER\n\t\t\tFROM\n\t\t\t\tb_stat_session S\n\t\t\tLEFT JOIN b_stat_browser B ON (\n\t\t\t\tlength(B.USER_AGENT)>0\n\t\t\tand B.USER_AGENT is not null\n\t\t\tand\tupper(S.USER_AGENT) like upper(B.USER_AGENT)\n\t\t\t)\n\t\t\tLEFT JOIN b_stat_searcher R ON (\n\t\t\t\tlength(R.USER_AGENT)>0\n\t\t\tand\tR.USER_AGENT is not null\n\t\t\tand\tupper(S.USER_AGENT) like upper(concat('%',R.USER_AGENT,'%'))\n\t\t\t)\n\t\t\tWHERE\n\t\t\t{$strSqlSearch}\n\t\t\tand S.USER_AGENT is not null\n\t\t\tand S.USER_AGENT<>''\n\t\t\tand S.NEW_GUEST<>'N'\n\t\t\tand B.ID is null\n\t\t\tand R.ID is null\n\t\t\tGROUP BY S.USER_AGENT\n\t\t\tHAVING '1'='1' {$strSqlSearch_h}\n\t\t\t{$strSqlOrder}\n\t\t\t";
     $res = $DB->Query($strSql, false, $err_mess . __LINE__);
     $is_filtered = IsFiltered($strSqlSearch) || strlen($strSqlSearch_h) > 0;
     return $res;
 }
	protected function mark_order_as_error($order, array $data) {
		CSaleOrder::Update($order['ID'], array(
			'PS_STATUS' => 'N',
			'PS_SUM' => $data['amount'],
			'PS_CURRENCY' => $data['currency'],
			'PS_STATUS_MESSAGE' => $data['message'],
			'PS_RESPONSE_DATE' => Date(CDatabase::DateFormatToPHP(CLang::GetDateFormat('FULL', LANG))),
		));
	}
Example #10
0
	function Search($phrase = "", $nTopCount = 5, $arParams = array(), $bNotFilter = false, $order = "")
	{
		$DB = CDatabase::GetModuleConnection('search');
		$this->_arPhrase = stemming_split($phrase, LANGUAGE_ID);
		if(!empty($this->_arPhrase))
		{
			$nTopCount = intval($nTopCount);
			if($nTopCount <= 0)
				$nTopCount = 5;

			$arId = CSearchFullText::GetInstance()->searchTitle($phrase, $this->_arPhrase, $nTopCount, $arParams, $bNotFilter, $order);
			if (!is_array($arId))
			{
				return $this->searchTitle($phrase, $nTopCount, $arParams, $bNotFilter, $order);
			}
			elseif (!empty($arId))
			{
				$strSql = "
					SELECT
						sc.ID
						,sc.MODULE_ID
						,sc.ITEM_ID
						,sc.TITLE
						,sc.PARAM1
						,sc.PARAM2
						,sc.DATE_CHANGE
						,L.DIR
						,L.SERVER_NAME
						,sc.URL as URL
						,scsite.URL as SITE_URL
						,scsite.SITE_ID
						,if(locate('".$DB->ForSQL(ToUpper($phrase))."', upper(sc.TITLE)) > 0, 1, 0) RANK1
					FROM
						b_search_content sc
						INNER JOIN b_search_content_site scsite ON sc.ID = scsite.SEARCH_CONTENT_ID
						INNER JOIN b_lang L ON scsite.SITE_ID = L.LID
					WHERE
						sc.ID in (".implode(",", $arId).")
						and scsite.SITE_ID = '".SITE_ID."'
					ORDER BY ".(
						$bOrderByRank?
							"RANK1 DESC, TITLE":
							"DATE_CHANGE DESC, RANK1 DESC, TITLE"
					)."
				";

				$r = $DB->Query($DB->TopSql($strSql, $nTopCount+1));
				parent::CDBResult($r);
				return true;
			}
		}
		else
		{
			return false;
		}
	}
Example #11
0
 public static function GetURLs($site_id, $ID, $limit = 0)
 {
     $DB = CDatabase::GetModuleConnection('search');
     $strSql = "\n\t\tSELECT\n\t\t\tsc.ID\n\t\t\t,sc.MODULE_ID\n\t\t\t,sc.ITEM_ID\n\t\t\t,sc.TITLE\n\t\t\t,sc.PARAM1\n\t\t\t,sc.PARAM2\n\t\t\t,sc.UPD\n\t\t\t,sc.DATE_FROM\n\t\t\t,sc.DATE_TO\n\t\t\t,L.DIR\n\t\t\t,L.SERVER_NAME\n\t\t\t,sc.URL as URL\n\t\t\t,scsite.URL as SITE_URL\n\t\t\t,scsite.SITE_ID\n\t\t\t," . $DB->DateToCharFunction("sc.DATE_CHANGE") . " as FULL_DATE_CHANGE\n\t\t\t," . $DB->DateToCharFunction("sc.DATE_CHANGE", "SHORT") . " as DATE_CHANGE\n\t\tFROM\tb_search_content sc\n\t\t\tINNER JOIN b_search_content_site scsite ON sc.ID=scsite.SEARCH_CONTENT_ID\n\t\t\tINNER JOIN b_lang L ON scsite.SITE_ID=L.LID\n\t\t\tINNER JOIN b_search_content_right scg ON sc.ID=scg.SEARCH_CONTENT_ID\n\t\tWHERE\n\t\t\tscg.GROUP_CODE='G2'\n\t\t\tAND scsite.SITE_ID='" . $DB->ForSQL($site_id, 2) . "'\n\t\t\tAND (sc.DATE_FROM is null OR sc.DATE_FROM <= " . $DB->CurrentTimeFunction() . ")\n\t\t\tAND (sc.DATE_TO is null OR sc.DATE_TO >= " . $DB->CurrentTimeFunction() . ")\n\t\t\tAND sc.ID > " . intval($ID) . "\n\t\tORDER BY\n\t\t\tsc.ID\n\t\t";
     if (intval($limit) > 0) {
         $strSql .= "LIMIT " . intval($limit);
     }
     $r = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     parent::CDBResult($r->result);
 }
Example #12
0
 public function setPayed($value)
 {
     $value = (bool) $value ? 'Y' : 'N';
     if ($value == 'Y') {
         \CSaleOrder::PayOrder($this['ID'], 'Y');
     } else {
         $data = array('PAYED' => (bool) $value ? 'Y' : 'N', 'DATE_PAYED' => Date(\CDatabase::DateFormatToPHP(\CLang::GetDateFormat('FULL', LANG))), 'USER_ID' => $this['USER_ID']);
         return \CSaleOrder::Update($this['ID'], $data);
     }
 }
Example #13
0
function addAsSearcher($mask)
{
    $statDB = CDatabase::GetModuleConnection('statistic');
    if (!checkIfBrowser($mask) && !checkIfSearcher($mask)) {
        $arFields = array("ACTIVE" => "'Y'", "SAVE_STATISTIC" => "'Y'", "NAME" => "'" . $statDB->ForSql($mask, 255) . "'", "USER_AGENT" => "'" . $statDB->ForSql($mask, 255) . "'");
        $statDB->Insert("b_stat_searcher", $arFields);
        return 1;
    } else {
        return 0;
    }
}
Example #14
0
 function SetGroups($arGroups)
 {
     $DB = CDatabase::GetModuleConnection('search');
     $dbCodes = $DB->Query("\n\t\t\tSELECT GROUP_CODE\n\t\t\tFROM b_search_user_right\n\t\t\tWHERE USER_ID = " . $this->_user_id . "\n\t\t", false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     while ($dbCode = $dbCodes->Fetch()) {
         if (!in_array($dbCode["GROUP_CODE"], $arGroups)) {
             $DB->Query("\n\t\t\t\t\tDELETE FROM b_search_user_right\n\t\t\t\t\tWHERE USER_ID = " . $this->_user_id . "\n\t\t\t\t\tAND GROUP_CODE = '" . $DB->ForSQL($dbCode["GROUP_CODE"]) . "'\n\t\t\t\t", false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         }
     }
     $this->AddGroups($arGroups);
 }
Example #15
0
 function AddGroups($arGroups)
 {
     $DB = CDatabase::GetModuleConnection('search');
     $arToInsert = array();
     foreach ($arGroups as $group_code) {
         if (strlen($group_code)) {
             $arToInsert[$group_code] = $group_code;
         }
     }
     foreach ($arToInsert as $group_code) {
         $DB->Query("\n\t\t\t\tINSERT INTO b_search_user_right\n\t\t\t\t(USER_ID, GROUP_CODE)\n\t\t\t\tVALUES\n\t\t\t\t(" . $this->_user_id . ", '" . $DB->ForSQL($group_code, 100) . "')\n\t\t\t", true, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
 }
Example #16
0
 protected function learning_log_exception($message, $code, $line, $file, $backtrace)
 {
     if (!method_exists('CDatabase', 'Query')) {
         return;
     }
     global $DB;
     if (!(is_object($DB) && method_exists($DB, 'Query'))) {
         return;
     }
     if (!$DB->TableExists('b_learn_exceptions_log')) {
         return;
     }
     $DB->Query("INSERT INTO b_learn_exceptions_log\n\t\t\t\t\t(DATE_REGISTERED, CODE, MESSAGE, FFILE, LINE, BACKTRACE)\n\t\t\t\t\tVALUES (" . CDatabase::GetNowFunction() . ", " . (int) $code . ", '" . CDatabase::ForSQL($message) . "', '" . CDatabase::ForSQL($file) . "', " . (int) $line . ",'" . CDatabase::ForSQL(base64_encode(serialize($backtrace))) . "')\n\t\t\t\t\t", true);
 }
Example #17
0
    public function __construct($options, $url, $urlSql)
    {
        $dbh = new CDatabase($options);
        $textfilter = new CTextFilter();
        // Get content
        $sql = "SELECT * FROM Content WHERE type = 'page' AND {$urlSql} AND published <= NOW() AND deleted IS NULL;";
        $res = $dbh->ExecuteSelectQueryAndFetchAll($sql, array($url));
        if ($urlSql == 1) {
            $data = '';
            foreach ($res as $row) {
                $title = "Alla sidor:";
                // Sanitize content before using it.
                $data .= "<a href='?p=contentpage&amp;url={$row->url}'>" . htmlentities($row->title, null, 'UTF-8') . "</a><br/>";
            }
            $html = <<<PAGECONT
          <article>
          <h2>{$title}</h2> 
          <p>{$data}</p>
          </article>
PAGECONT;
            $this->html = $html;
        } else {
            $data = $res[0];
            // Sanitize content before using it.
            $title = htmlentities($data->title, null, 'UTF-8');
            $data = $textfilter->doFilter(htmlentities($data->data, null, 'UTF-8'), $data->filter);
            $data .= "<p>&nbsp;</p><hr style='margin-bottom:10px;'><p><a href='?p=contentpage' class='aButton'>Visa alla</a></p>";
            $html = <<<PAGECONT
          <article>
          <h2>{$title}</h2> 
          {$data}
          </article>
PAGECONT;
            $this->html = $html;
        }
    }
Example #18
0
 function GetUpTime($node_id)
 {
     if ($node_id > 1) {
         ob_start();
         $DB = CDatabase::GetDBNodeConnection($node_id, true, false);
         ob_end_clean();
     } else {
         $DB = $GLOBALS["DB"];
     }
     if (is_object($DB)) {
         $rs = $DB->Query("show status like 'Uptime'", false, '', array('fixed_connection' => true));
         if ($ar = $rs->Fetch()) {
             return $ar["Value"];
         }
     }
     return false;
 }
Example #19
0
 function GetEditFormHTML($arUserField, $arHtmlControl)
 {
     $arHtmlControl["VALIGN"] = "middle";
     if ($arUserField["EDIT_IN_LIST"] == "Y") {
         if ($arUserField["ENTITY_VALUE_ID"] < 1 && $arUserField["SETTINGS"]["DEFAULT_VALUE"]["TYPE"] != "NONE") {
             if ($arUserField["SETTINGS"]["DEFAULT_VALUE"]["TYPE"] == "NOW") {
                 $arHtmlControl["VALUE"] = ConvertTimeStamp(time(), "SHORT");
             } else {
                 $arHtmlControl["VALUE"] = CDatabase::FormatDate($arUserField["SETTINGS"]["DEFAULT_VALUE"]["VALUE"], "YYYY-MM-DD", CLang::GetDateFormat("SHORT"));
             }
         }
         return CAdminCalendar::CalendarDate($arHtmlControl["NAME"], $arHtmlControl["VALUE"]);
     } elseif (strlen($arHtmlControl["VALUE"]) > 0) {
         return $arHtmlControl["VALUE"];
     } else {
         return '&nbsp;';
     }
 }
Example #20
0
 function GetEditFormHTML($arUserField, $arHtmlControl)
 {
     $arHtmlControl["VALIGN"] = "middle";
     if ($arUserField["EDIT_IN_LIST"] == "Y") {
         if ($arUserField["ENTITY_VALUE_ID"] < 1 && $arUserField["SETTINGS"]["DEFAULT_VALUE"]["TYPE"] != "NONE") {
             if ($arUserField["SETTINGS"]["DEFAULT_VALUE"]["TYPE"] == "NOW") {
                 $arHtmlControl["VALUE"] = ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL");
             } else {
                 $arHtmlControl["VALUE"] = str_replace(" 00:00:00", "", CDatabase::FormatDate($arUserField["SETTINGS"]["DEFAULT_VALUE"]["VALUE"], "YYYY-MM-DD HH:MI:SS", CLang::GetDateFormat("FULL")));
             }
         }
         return CAdminCalendar::CalendarDate($arHtmlControl["NAME"], $arHtmlControl["VALUE"], 20, true);
     } elseif (strlen($arHtmlControl["VALUE"]) > 0) {
         return $arHtmlControl["VALUE"];
     } else {
         return '&nbsp;';
     }
 }
 /**
  * @param $query
  * @param null $var1
  * @param null $var2
  * @return bool|\CDBResult
  */
 protected function query($query, $var1 = null, $var2 = null)
 {
     if (func_num_args() > 1) {
         $params = func_get_args();
         $query = call_user_func_array('sprintf', $params);
     }
     $search = array('#TABLE1#' => $this->tableName, '#DBNAME#' => $this->dbName);
     if (Locale::isWin1251()) {
         $search['#CHARSET#'] = 'cp1251';
         $search['#COLLATE#'] = 'cp1251_general_ci';
     } else {
         $search['#CHARSET#'] = 'utf8';
         $search['#COLLATE#'] = 'utf8_general_ci';
     }
     $querySearch = array_keys($search);
     $queryReplace = array_values($search);
     $query = str_replace($querySearch, $queryReplace, $query);
     return $this->bitrixDb->Query($query);
 }
Example #22
0
 /**
  * Constructor creating a PDO object connecting to a choosen database.
  *
  * @param array $options containing details for connecting to the database.
  *
  */
 public function __construct($options)
 {
     $default = array('dsn' => null, 'username' => null, 'password' => null, 'driver_options' => null, 'fetch_style' => PDO::FETCH_OBJ);
     $this->options = array_merge($default, $options);
     try {
         $this->db = new PDO($this->options['dsn'], $this->options['username'], $this->options['password'], $this->options['driver_options']);
     } catch (Exception $e) {
         //throw $e; // For debug purpose, shows all connection details
         throw new PDOException('Could not connect to database, hiding connection details.');
         // Hide connection details.
     }
     $this->db->SetAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, $this->options['fetch_style']);
     // Get debug information from session if any.
     if (isset($_SESSION['CDatabase'])) {
         self::$numQueries = $_SESSION['CDatabase']['numQueries'];
         self::$queries = $_SESSION['CDatabase']['queries'];
         self::$params = $_SESSION['CDatabase']['params'];
         unset($_SESSION['CDatabase']);
     }
 }
 public function change($parameter_a)
 {
     $product_list = $parameter_a['product_list'] ? $parameter_a['product_list'] : "a:0:{}";
     /*
      * $db = CDatabase::getInstance();
      * $db->query("update sk_admin_group set gname='{$parameter_a['roleName']}',rightList='{$parameter_a['rights']}',product_list='{$product_list}',parent_id='{$parameter_a['parent_id']}' where gid='{$parameter_a['id']}'");
      */
     try {
         $pdo = CDatabase::getDatabase();
         $pdo_runObject = $pdo->prepare("update sk_admin_group set gname=?,rightList=?,product_list=?,parent_id=? where gid=?");
         $pdo_runObject->bindParam(1, $parameter_a['roleName'], PDO::PARAM_STR);
         $pdo_runObject->bindParam(2, $parameter_a['rights'], PDO::PARAM_STR);
         $pdo_runObject->bindParam(3, $product_list, PDO::PARAM_STR);
         $pdo_runObject->bindParam(4, $parameter_a['parent_id'], PDO::PARAM_STR);
         $pdo_runObject->bindParam(5, $parameter_a['id'], PDO::PARAM_INT);
         $result_status = $pdo_runObject->execute();
     } catch (PDOException $e) {
         echo $e->getMessage();
     }
     return $result_status;
 }
Example #24
0
 function Search($phrase = "", $nTopCount = 5, $arParams = array(), $bNotFilter = false, $order = "")
 {
     $DB = CDatabase::GetModuleConnection('search');
     $this->_arPhrase = stemming_split($phrase, LANGUAGE_ID);
     if (!empty($this->_arPhrase)) {
         $nTopCount = intval($nTopCount);
         if ($nTopCount <= 0) {
             $nTopCount = 5;
         }
         $arId = CSearchFullText::GetInstance()->searchTitle($phrase, $this->_arPhrase, $nTopCount, $arParams, $bNotFilter, $order);
         if (!is_array($arId)) {
             return $this->searchTitle($phrase, $nTopCount, $arParams, $bNotFilter, $order);
         } elseif (!empty($arId)) {
             $strSql = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tsc.ID\n\t\t\t\t\t\t,sc.MODULE_ID\n\t\t\t\t\t\t,sc.ITEM_ID\n\t\t\t\t\t\t,sc.TITLE\n\t\t\t\t\t\t,sc.PARAM1\n\t\t\t\t\t\t,sc.PARAM2\n\t\t\t\t\t\t,sc.DATE_CHANGE\n\t\t\t\t\t\t,L.DIR\n\t\t\t\t\t\t,L.SERVER_NAME\n\t\t\t\t\t\t,sc.URL as URL\n\t\t\t\t\t\t,scsite.URL as SITE_URL\n\t\t\t\t\t\t,scsite.SITE_ID\n\t\t\t\t\t\t," . $this->getRankFunction($phrase) . " RANK1\n\t\t\t\t\tFROM\n\t\t\t\t\t\tb_search_content sc\n\t\t\t\t\t\tINNER JOIN b_search_content_site scsite ON sc.ID = scsite.SEARCH_CONTENT_ID\n\t\t\t\t\t\tINNER JOIN b_lang L ON scsite.SITE_ID = L.LID\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tsc.ID in (" . implode(",", $arId) . ")\n\t\t\t\t\t\tand scsite.SITE_ID = '" . SITE_ID . "'\n\t\t\t\t\tORDER BY " . $this->getSqlOrder($bOrderByRank) . "\n\t\t\t\t";
             $r = $DB->Query($DB->TopSql($strSql, $nTopCount + 1));
             parent::CDBResult($r);
             return true;
         }
     } else {
         return false;
     }
 }
Example #25
0
 function Search($phrase = "", $nTopCount = 5, $arParams = array(), $bNotFilter = false, $order = "")
 {
     $DB = CDatabase::GetModuleConnection('search');
     $this->_arPhrase = stemming_split($phrase, LANGUAGE_ID);
     $bOrderByRank = $order == "rank";
     if (!empty($this->_arPhrase)) {
         $nTopCount = intval($nTopCount);
         if ($nTopCount <= 0) {
             $nTopCount = 5;
         }
         $sqlHaving = array();
         $sqlWords = array();
         foreach (array_reverse($this->_arPhrase, true) as $word => $pos) {
             if (empty($sqlWords) && !preg_match("/[\\n\\r \\t]\$/", $phrase)) {
                 $s = $sqlWords[] = "ct.WORD like '" . $DB->ForSQL($word) . "%'";
             } else {
                 $s = $sqlWords[] = "ct.WORD = '" . $DB->ForSQL($word) . "'";
             }
             $sqlHaving[] = "(sum(" . $s . ") > 0)";
         }
         $bIncSites = false;
         $strSqlWhere = CSearch::__PrepareFilter($arParams, $bIncSites);
         if ($bNotFilter) {
             if (!empty($strSqlWhere)) {
                 $strSqlWhere = "NOT (" . $strSqlWhere . ")";
             } else {
                 $strSqlWhere = "1=0";
             }
         }
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tsc.ID\n\t\t\t\t\t,sc.MODULE_ID\n\t\t\t\t\t,sc.ITEM_ID\n\t\t\t\t\t,sc.TITLE\n\t\t\t\t\t,sc.PARAM1\n\t\t\t\t\t,sc.PARAM2\n\t\t\t\t\t,sc.DATE_CHANGE\n\t\t\t\t\t,L.DIR\n\t\t\t\t\t,L.SERVER_NAME\n\t\t\t\t\t,sc.URL as URL\n\t\t\t\t\t,scsite.URL as SITE_URL\n\t\t\t\t\t,scsite.SITE_ID\n\t\t\t\t\t,if(locate('" . $DB->ForSQL(ToUpper($phrase)) . "', upper(sc.TITLE)) > 0, 1, 0) RANK1\n\t\t\t\t\t,count(1) RANK2\n\t\t\t\t\t,min(ct.POS) RANK3\n\t\t\t\tFROM\n\t\t\t\t\tb_search_content_title ct\n\t\t\t\t\tINNER JOIN b_lang L ON ct.SITE_ID = L.LID\n\t\t\t\t\tinner join b_search_content sc on sc.ID = ct.SEARCH_CONTENT_ID\n\t\t\t\t\tINNER JOIN b_search_content_site scsite ON sc.ID = scsite.SEARCH_CONTENT_ID and ct.SITE_ID = scsite.SITE_ID\n\t\t\t\tWHERE\n\t\t\t\t\t" . CSearch::CheckPermissions("sc.ID") . "\n\t\t\t\t\tAND ct.SITE_ID = '" . SITE_ID . "'\n\t\t\t\t\tAND (" . implode(" OR ", $sqlWords) . ")\n\t\t\t\t\t" . (!empty($strSqlWhere) ? "AND " . $strSqlWhere : "") . "\n\t\t\t\tGROUP BY\n\t\t\t\t\tID, MODULE_ID, ITEM_ID, TITLE, PARAM1, PARAM2, DATE_CHANGE, DIR, SERVER_NAME, URL, SITE_URL, SITE_ID\n\t\t\t\t" . (count($sqlHaving) > 1 ? "HAVING " . implode(" AND ", $sqlHaving) : "") . "\n\t\t\t\tORDER BY " . ($bOrderByRank ? "RANK1 DESC, RANK2 DESC, RANK3 ASC, TITLE" : "DATE_CHANGE DESC, RANK1 DESC, RANK2 DESC, RANK3 ASC, TITLE") . "\n\t\t\t\tLIMIT 0, " . ($nTopCount + 1) . "\n\t\t\t";
         $r = $DB->Query($strSql);
         parent::CDBResult($r);
         return true;
     } else {
         return false;
     }
 }
Example #26
0
 function InitStep()
 {
     global $DB;
     $wizard =& $this->GetWizard();
     $node_id = intval($wizard->GetVar('node_id'));
     if (!CModule::IncludeModule('cluster')) {
         $this->SetError(GetMessage('CLUWIZ_NO_MODULE_ERROR'));
     } elseif ($DB->type != "MYSQL") {
         $this->SetError(GetMessage('CLUWIZ_DATABASE_NOT_SUPPORTED'));
     } elseif ($node_id <= 1) {
         $this->SetError(GetMessage('CLUWIZ_NO_NODE_ERROR'));
     } else {
         $this->arNode = CClusterDBNode::GetByID($node_id);
         if (!is_array($this->arNode)) {
             $this->SetError(GetMessage('CLUWIZ_NO_NODE_ERROR'));
         } else {
             // $arNode["ROLE_ID"] == "SLAVE"
             // $arNode["STATUS"] == "READY"
             $this->nodeDB = CDatabase::GetDBNodeConnection($this->arNode["ID"], true, false);
             if (!is_object($this->nodeDB)) {
                 $this->SetError(GetMessage('CLUWIZ_NO_CONN_ERROR'));
             } else {
                 $arGroup = CClusterGroup::GetArrayByID(intval($wizard->GetVar("group_id")));
                 if (!$arGroup) {
                     $this->SetError(GetMessage('CLUWIZ_NO_GROUP_ERROR'));
                 } else {
                     $cData = new CClusterDBNode();
                     $rsData = $cData->GetList(array(), array("=ROLE_ID" => array("MAIN", "MASTER"), "=GROUP_ID" => $arGroup["ID"], "=STATUS" => "ONLINE"));
                     $this->arMaster = $rsData->Fetch();
                     if (!$this->arMaster) {
                         $this->SetError(GetMessage('CLUWIZ_NO_MASTER_ERROR'));
                     }
                 }
             }
         }
     }
 }
 /**
  * 可添加的角色组
  */
 public function filterCanAddRole($list)
 {
     $userData = CSession::get('user');
     $groupId = $userData['groupData']['gid'];
     // 超级管理员给全部资源
     if (1 == $groupId) {
         return $list;
     }
     $category = CDatabase::getInstance()->from('admin_group')->select()->execute()->asArray();
     foreach ($category as $key => $val) {
         $category[$key]['name'] = $val['gname'];
         $category[$key]['id'] = $val['gid'];
     }
     $category = TreeClass::getTree($category);
     // 获取其子类
     $childData = $childDataVal = array();
     TreeClass::getCatTree($groupId, $category, $childData, $childDataVal);
     foreach ($list as $key => $val) {
         if (!in_array($val['gid'], $childData)) {
             unset($list[$key]);
         }
     }
     return $list;
 }
Example #28
0
 $parms .= "&VENDOR=" . urlencode($PF_USER);
 // Vendor ID
 $parms .= "&ZIP=" . urlencode($zipcode);
 // Zip
 $parms .= "&STREET=" . urlencode($address1);
 // Address
 $parms .= "&COMMENT1=" . urlencode($ORDER_ID);
 $parms .= "&COMMENT2=" . urlencode($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["DATE_INSERT"]);
 $ret_com = "{$strExePath} {$PF_HOST} {$PF_PORT} \"{$parms}\" 30";
 putenv("PFPRO_CERT_PATH=" . $PFPRO_CERT_PATH);
 putenv("LD_LIBRARY_PATH=" . $strExeDir);
 exec($ret_com, $arOutput, $ret_var);
 $strOutput = $arOutput[0];
 parse_str($strOutput, $arResult);
 if (is_array($arResult) && strlen($arResult["RESULT"]) > 0) {
     $arFields = array("PS_STATUS" => $arResult["RESULT"] == 0 ? "Y" : "N", "PS_STATUS_CODE" => $arResult["RESULT"], "PS_STATUS_DESCRIPTION" => $arResult["RESPMSG"] . " - " . $arResult["PREFPSMSG"], "PS_STATUS_MESSAGE" => $arResult["PNREF"], "PS_RESPONSE_DATE" => Date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL", LANG))));
     $arResult["RESULT"] = IntVal($arResult["RESULT"]);
     if ($arResult["RESULT"] == 0) {
         CSaleOrder::PayOrder($ORDER_ID, "Y");
     }
     CSaleOrder::Update($ORDER_ID, $arFields);
     $arResult["RESULT"] = IntVal($arResult["RESULT"]);
     if ($arResult["RESULT"] == 0) {
         $bNonePay = False;
     } else {
         if ($arResult["RESULT"] < 0) {
             $strErrorTmp .= "Communication Error: [" . $arResult["RESULT"] . "] " . $arResult["RESPMSG"] . " - " . $arResult["PREFPSMSG"] . ". ";
         } elseif ($arPaySysRes_tmp["RESULT"] == 125) {
             $strErrorTmp .= "Your payment is declined by Fraud Service. Please contact us to make payment. ";
         } elseif ($arResult["RESULT"] == 126) {
             $strErrorTmp .= "Your payment is under review by Fraud Service. We contact you in 48 hours to get more specific information. ";
Example #29
0
	function XMLDate2Dec($date_XML, $dateFormat = "DD.MM.YYYY")
	{
		static $MonthChar2Num = Array("","jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");

		if(preg_match("/(\\d+)\\s+(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\s+(\\d+)/i", $date_XML, $match))
			$timestamp = mktime(0, 0, 0, array_search(strtolower($match[2]), $MonthChar2Num), $match[1], $match[3]);
		else
			$timestamp = time();

		return  date(CDatabase::DateFormatToPHP($dateFormat), $timestamp);
	}
    if ($lmi_payee_purse != $IdM) {
        $err = 3;
        $err_text = 'ERR: НЕВЕРЕН ID МАГАЗИНА : ' . $lmi_payee_purse;
    }
    if ($lmi_prerequest == 1) {
        if ($err != 0) {
            echo $err_text;
        } else {
            echo 'YES';
        }
    } else {
        $common_string = $lmi_payee_purse . $lmi_payment_amount . $lmi_payment_no . $lmi_mode . $lmi_sys_invs_no . $lmi_sys_trans_no . $lmi_sys_trans_date . $sk . $lmi_payer_purse . $lmi_payer_wm;
        $hash = ToUpper(md5($common_string));
        if ($err == 0) {
            if ($hash == $lmi_hash) {
                $strPS_STATUS_DESCRIPTION = "";
                $strPS_STATUS_DESCRIPTION .= "Идентификатор магазина - " . $lmi_payee_purse . "; ";
                $strPS_STATUS_DESCRIPTION .= "Внутренний номер платежа  в системе Z-PAYMENT - " . $lmi_sys_invs_no . "; ";
                $strPS_STATUS_DESCRIPTION .= "Внутренний номер счета в системе Z-PAYMENT - " . $lmi_sys_trans_no . "; ";
                $strPS_STATUS_DESCRIPTION .= "дата платежа - " . $lmi_sys_trans_date . "";
                $strPS_STATUS_MESSAGE = "";
                $strPS_STATUS_MESSAGE .= "кошелек покупателя или его e-mail  - " . $lmi_payer_purse . "; ";
                $arFields = array("PS_STATUS" => "Y", "PS_STATUS_CODE" => "-", "PS_STATUS_DESCRIPTION" => $strPS_STATUS_DESCRIPTION, "PS_STATUS_MESSAGE" => $strPS_STATUS_MESSAGE, "PS_SUM" => $lmi_payment_amount, "PS_CURRENCY" => $arOrder["CURRENCY"], "PS_RESPONSE_DATE" => Date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL", LANG))), "USER_ID" => $arOrder["USER_ID"]);
                // You can comment this code if you want PAYED flag not to be set automatically
                CSaleOrder::PayOrder($arOrder["ID"], "Y");
                CSaleOrder::Update($arOrder["ID"], $arFields);
            }
        }
    }
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";