当前位置: 首页>>代码示例>>PHP>>正文


PHP Common::hex2bin方法代码示例

本文整理汇总了PHP中Piwik\Common::hex2bin方法的典型用法代码示例。如果您正苦于以下问题:PHP Common::hex2bin方法的具体用法?PHP Common::hex2bin怎么用?PHP Common::hex2bin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik\Common的用法示例。


在下文中一共展示了Common::hex2bin方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 public static function update($idvisitor, $name = false, $email = false, $phone = false, $comments = false)
 {
     if ($name == false && $email == false && $phone == false && $comments == false) {
         return false;
     }
     $buildQuery = "";
     $argSet = array();
     $argOnUpdate = array();
     $argSet[] = @Common::hex2bin($idvisitor);
     if ($name) {
         $argSet[] = $name;
         $argOnUpdate[] = $name;
         $buildQuery .= " name = ?,";
     }
     if ($email) {
         $argSet[] = $email;
         $argOnUpdate[] = $email;
         $buildQuery .= " email = ?,";
     }
     if ($phone) {
         $argSet[] = $phone;
         $argOnUpdate[] = $phone;
         $buildQuery .= " phone = ?,";
     }
     if ($comments) {
         $argSet[] = $comments;
         $argOnUpdate[] = $comments;
         $buildQuery .= " comments = ?,";
     }
     $buildQuery = trim(substr_replace($buildQuery, "", -1));
     $arguments = array_merge($argSet, $argOnUpdate);
     Db::query("INSERT INTO " . Common::prefixTable('chat_personnal_informations') . " SET idvisitor = ?, {$buildQuery} ON DUPLICATE KEY UPDATE {$buildQuery}", $arguments);
     return true;
 }
开发者ID:WHATNEXTLIMITED,项目名称:piwik-chat,代码行数:34,代码来源:ChatPersonnalInformation.php

示例2: setLastSent

 public static function setLastSent($idsite, $idvisitor, $microtime)
 {
     foreach (ChatCommon::getUsersBySite($idsite) as $user) {
         $arguments = array($user['login'], @Common::hex2bin($idvisitor), $microtime, $microtime);
         Db::query("INSERT INTO " . Common::prefixTable('chat_history_admin') . " SET login = ?, idvisitor = ?, lastsent = ? ON DUPLICATE KEY UPDATE lastsent = ?", $arguments);
     }
     return true;
 }
开发者ID:WHATNEXTLIMITED,项目名称:piwik-chat,代码行数:8,代码来源:ChatAcknowledgment.php

示例3: test_makeLogVisitsQueryString_whenSegment

    public function test_makeLogVisitsQueryString_whenSegment()
    {
        $model = new Model();
        list($sql, $bind) = $model->makeLogVisitsQueryString($idSite = 1, $period = 'month', $date = '2010-01-01', $segment = 'customVariablePageName1==Test', $offset = 0, $limit = 100, $visitorId = 'abc', $minTimestamp = false, $filterSortOrder = false);
        $expectedSql = ' SELECT sub.* FROM
                (

                    SELECT log_inner.*
                    FROM (
                        SELECT log_visit.*
                        FROM ' . Common::prefixTable('log_visit') . ' AS log_visit
                          LEFT JOIN ' . Common::prefixTable('log_link_visit_action') . ' AS log_link_visit_action
                          ON log_link_visit_action.idvisit = log_visit.idvisit
                        WHERE ( log_visit.idsite in (?)
                          AND log_visit.idvisitor = ?
                          AND log_visit.visit_last_action_time >= ?
                          AND log_visit.visit_last_action_time <= ? )
                          AND ( log_link_visit_action.custom_var_k1 = ? )
                        ORDER BY idsite, visit_last_action_time DESC
                        LIMIT 100
                        ) AS log_inner
                    ORDER BY idsite, visit_last_action_time DESC
                    LIMIT 100
                 ) AS sub
                 GROUP BY sub.idvisit
                 ORDER BY sub.visit_last_action_time DESC
        ';
        $expectedBind = array('1', Common::hex2bin('abc'), '2010-01-01 00:00:00', '2010-02-01 00:00:00', 'Test');
        $this->assertEquals(SegmentTest::removeExtraWhiteSpaces($expectedSql), SegmentTest::removeExtraWhiteSpaces($sql));
        $this->assertEquals(SegmentTest::removeExtraWhiteSpaces($expectedBind), SegmentTest::removeExtraWhiteSpaces($bind));
    }
开发者ID:dorelljames,项目名称:piwik,代码行数:31,代码来源:ModelTest.php

示例4: getAutomaticMessageReceivedById

 public function getAutomaticMessageReceivedById($idAutoMsg)
 {
     $arguments = array($this->idsite, @Common::hex2bin($this->idvisitor), $idAutoMsg);
     $rows = Db::fetchAll("SELECT * FROM " . Common::prefixTable('chat') . " WHERE idsite = ? AND idvisitor = ? AND idautomsg = ? ORDER BY microtime DESC", $arguments);
     $rows = ChatCommon::formatRows($rows);
     return $rows;
 }
开发者ID:WHATNEXTLIMITED,项目名称:piwik-chat,代码行数:7,代码来源:ChatConversation.php

示例5: getVisitorId

 /**
  * Is the request for a known VisitorId, based on 1st party, 3rd party (optional) cookies or Tracking API forced Visitor ID
  * @throws Exception
  */
 public function getVisitorId()
 {
     $found = false;
     // Was a Visitor ID "forced" (@see Tracking API setVisitorId()) for this request?
     $idVisitor = $this->getForcedVisitorId();
     if (!empty($idVisitor)) {
         if (strlen($idVisitor) != Tracker::LENGTH_HEX_ID_STRING) {
             throw new Exception("Visitor ID (cid) {$idVisitor} must be " . Tracker::LENGTH_HEX_ID_STRING . " characters long");
         }
         Common::printDebug("Request will be recorded for this idvisitor = " . $idVisitor);
         $found = true;
     }
     // - If set to use 3rd party cookies for Visit ID, read the cookie
     if (!$found) {
         // - By default, reads the first party cookie ID
         $useThirdPartyCookie = $this->shouldUseThirdPartyCookie();
         if ($useThirdPartyCookie) {
             $cookie = $this->makeThirdPartyCookie();
             $idVisitor = $cookie->get(0);
             if ($idVisitor !== false && strlen($idVisitor) == Tracker::LENGTH_HEX_ID_STRING) {
                 $found = true;
             }
         }
     }
     // If a third party cookie was not found, we default to the first party cookie
     if (!$found) {
         $idVisitor = Common::getRequestVar('_id', '', 'string', $this->params);
         $found = strlen($idVisitor) >= Tracker::LENGTH_HEX_ID_STRING;
     }
     if ($found) {
         $truncated = substr($idVisitor, 0, Tracker::LENGTH_HEX_ID_STRING);
         $binVisitorId = @Common::hex2bin($truncated);
         if (!empty($binVisitorId)) {
             return $binVisitorId;
         }
     }
     return false;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:42,代码来源:Request.php

示例6: setIdVisitorForExistingVisit

 /**
  * @param $visitor
  * @param $valuesToUpdate
  * @return mixed
  */
 private function setIdVisitorForExistingVisit($valuesToUpdate)
 {
     // Might update the idvisitor when it was forced or overwritten for this visit
     if (strlen($this->visitProperties->getProperty('idvisitor')) == Tracker::LENGTH_BINARY_ID) {
         $binIdVisitor = $this->visitProperties->getProperty('idvisitor');
         $valuesToUpdate['idvisitor'] = $binIdVisitor;
     }
     // User ID takes precedence and overwrites idvisitor value
     $userId = $this->request->getForcedUserId();
     if ($userId) {
         $userIdHash = $this->request->getUserIdHashed($userId);
         $binIdVisitor = Common::hex2bin($userIdHash);
         $this->visitProperties->setProperty('idvisitor', $binIdVisitor);
         $valuesToUpdate['idvisitor'] = $binIdVisitor;
     }
     return $valuesToUpdate;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:22,代码来源:Visit.php

示例7: getAdjacentVisitorId

 public function getAdjacentVisitorId($idSite, $visitorId, $visitLastActionTime, $segment, $getNext)
 {
     $visitorId = $this->adjacentVisitorId($idSite, @Common::hex2bin($visitorId), $visitLastActionTime, $segment, $getNext);
     if (!empty($visitorId)) {
         $visitorId = bin2hex($visitorId);
     }
     return $visitorId;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:8,代码来源:LogVisit.php

示例8: loadLastVisitorDetailsFromDatabase

 private function loadLastVisitorDetailsFromDatabase($idSite, $period, $date, $segment = false, $countVisitorsToFetch = 100, $visitorId = false, $minTimestamp = false, $filterSortOrder = false)
 {
     $where = $whereBind = array();
     list($whereClause, $idSites) = $this->getIdSitesWhereClause($idSite);
     $where[] = $whereClause;
     $whereBind = $idSites;
     if (strtolower($filterSortOrder) !== 'asc') {
         $filterSortOrder = 'DESC';
     }
     $orderBy = "idsite, visit_last_action_time " . $filterSortOrder;
     $orderByParent = "sub.visit_last_action_time " . $filterSortOrder;
     if (!empty($visitorId)) {
         $where[] = "log_visit.idvisitor = ? ";
         $whereBind[] = @Common::hex2bin($visitorId);
     }
     if (!empty($minTimestamp)) {
         $where[] = "log_visit.visit_last_action_time > ? ";
         $whereBind[] = date("Y-m-d H:i:s", $minTimestamp);
     }
     // If no other filter, only look at the last 24 hours of stats
     if (empty($visitorId) && empty($countVisitorsToFetch) && empty($period) && empty($date)) {
         $period = 'day';
         $date = 'yesterdaySameTime';
     }
     // SQL Filter with provided period
     if (!empty($period) && !empty($date)) {
         $currentSite = new Site($idSite);
         $currentTimezone = $currentSite->getTimezone();
         $dateString = $date;
         if ($period == 'range') {
             $processedPeriod = new Range('range', $date);
             if ($parsedDate = Range::parseDateRange($date)) {
                 $dateString = $parsedDate[2];
             }
         } else {
             $processedDate = Date::factory($date);
             if ($date == 'today' || $date == 'now' || $processedDate->toString() == Date::factory('now', $currentTimezone)->toString()) {
                 $processedDate = $processedDate->subDay(1);
             }
             $processedPeriod = Period\Factory::build($period, $processedDate);
         }
         $dateStart = $processedPeriod->getDateStart()->setTimezone($currentTimezone);
         $where[] = "log_visit.visit_last_action_time >= ?";
         $whereBind[] = $dateStart->toString('Y-m-d H:i:s');
         if (!in_array($date, array('now', 'today', 'yesterdaySameTime')) && strpos($date, 'last') === false && strpos($date, 'previous') === false && Date::factory($dateString)->toString('Y-m-d') != Date::factory('now', $currentTimezone)->toString()) {
             $dateEnd = $processedPeriod->getDateEnd()->setTimezone($currentTimezone);
             $where[] = " log_visit.visit_last_action_time <= ?";
             $dateEndString = $dateEnd->addDay(1)->toString('Y-m-d H:i:s');
             $whereBind[] = $dateEndString;
         }
     }
     if (count($where) > 0) {
         $where = join("\n\t\t\t\tAND ", $where);
     } else {
         $where = false;
     }
     $segment = new Segment($segment, $idSite);
     // Subquery to use the indexes for ORDER BY
     $select = "log_visit.*";
     $from = "log_visit";
     $subQuery = $segment->getSelectQuery($select, $from, $where, $whereBind, $orderBy);
     $sqlLimit = $countVisitorsToFetch >= 1 ? " LIMIT 0, " . (int) $countVisitorsToFetch : "";
     // Group by idvisit so that a visitor converting 2 goals only appears once
     $sql = "\n\t\t\tSELECT sub.* FROM (\n\t\t\t\t" . $subQuery['sql'] . "\n\t\t\t\t{$sqlLimit}\n\t\t\t) AS sub\n\t\t\tGROUP BY sub.idvisit\n\t\t\tORDER BY {$orderByParent}\n\t\t";
     try {
         $data = Db::fetchAll($sql, $subQuery['bind']);
     } catch (Exception $e) {
         echo $e->getMessage();
         exit;
     }
     $dataTable = new DataTable();
     $dataTable->addRowsFromSimpleArray($data);
     // $dataTable->disableFilter('Truncate');
     if (!empty($data[0])) {
         $columnsToNotAggregate = array_map(function () {
             return 'skip';
         }, $data[0]);
         $dataTable->setMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME, $columnsToNotAggregate);
     }
     return $dataTable;
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:81,代码来源:API.php

示例9: getVisitorIdcookie

 /**
  *  Returns visitor cookie
  *
  * @return string  binary
  */
 protected function getVisitorIdcookie()
 {
     if ($this->isVisitorKnown()) {
         return $this->visitorInfo['idvisitor'];
     }
     // If the visitor had a first party ID cookie, then we use this value
     if (!empty($this->visitorInfo['idvisitor']) && strlen($this->visitorInfo['idvisitor']) == Tracker::LENGTH_BINARY_ID) {
         return $this->visitorInfo['idvisitor'];
     }
     return Common::hex2bin($this->generateUniqueVisitorId());
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:16,代码来源:Visit.php

示例10: getWhereClauseAndBind

 /**
  * @param string $whereClause
  * @param array $bindIdSites
  * @param $idSite
  * @param $period
  * @param $date
  * @param $visitorId
  * @param $minTimestamp
  * @return array
  * @throws Exception
  */
 private function getWhereClauseAndBind($whereClause, $bindIdSites, $idSite, $period, $date, $visitorId, $minTimestamp)
 {
     $where = array();
     $where[] = $whereClause;
     $whereBind = $bindIdSites;
     if (!empty($visitorId)) {
         $where[] = "log_visit.idvisitor = ? ";
         $whereBind[] = @Common::hex2bin($visitorId);
     }
     if (!empty($minTimestamp)) {
         $where[] = "log_visit.visit_last_action_time > ? ";
         $whereBind[] = date("Y-m-d H:i:s", $minTimestamp);
     }
     // SQL Filter with provided period
     if (!empty($period) && !empty($date)) {
         $currentSite = $this->makeSite($idSite);
         $currentTimezone = $currentSite->getTimezone();
         $dateString = $date;
         if ($period == 'range') {
             $processedPeriod = new Range('range', $date);
             if ($parsedDate = Range::parseDateRange($date)) {
                 $dateString = $parsedDate[2];
             }
         } else {
             $processedDate = Date::factory($date);
             $processedPeriod = Period\Factory::build($period, $processedDate);
         }
         $dateStart = $processedPeriod->getDateStart()->setTimezone($currentTimezone);
         $where[] = "log_visit.visit_last_action_time >= ?";
         $whereBind[] = $dateStart->toString('Y-m-d H:i:s');
         if (!in_array($date, array('now', 'today', 'yesterdaySameTime')) && strpos($date, 'last') === false && strpos($date, 'previous') === false && Date::factory($dateString)->toString('Y-m-d') != Date::factory('now', $currentTimezone)->toString()) {
             $dateEnd = $processedPeriod->getDateEnd()->setTimezone($currentTimezone);
             $where[] = " log_visit.visit_last_action_time <= ?";
             $dateEndString = $dateEnd->addDay(1)->toString('Y-m-d H:i:s');
             $whereBind[] = $dateEndString;
         }
     }
     if (count($where) > 0) {
         $where = join("\n\t\t\t\tAND ", $where);
     } else {
         $where = false;
     }
     return array($whereBind, $where);
 }
开发者ID:piwik,项目名称:piwik,代码行数:55,代码来源:Model.php

示例11: getDummyVisitorId

 private function getDummyVisitorId()
 {
     return Common::hex2bin('ea95f303f2165aa0');
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:4,代码来源:LogHelper.php


注:本文中的Piwik\Common::hex2bin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。