コード例 #1
0
ファイル: BxDolParams.php プロジェクト: toxalot/dolphin.pro
 function get($sKey, $bFromCache = true)
 {
     if (!$sKey) {
         return false;
     }
     if ($bFromCache && $this->isInCache($sKey)) {
         return $this->_aParams[$sKey];
     } else {
         return $this->_oDb->getOne("SELECT `VALUE` FROM `sys_options` WHERE `Name`= ? LIMIT 1", [$sKey]);
     }
 }
コード例 #2
0
ファイル: categories.php プロジェクト: Arvindvi/dolphin
function getAddCategoryForm()
{
    $oForm = getCategoryForm();
    $oForm->initChecker();
    $sResult = '';
    if ($oForm->isSubmittedAndValid()) {
        $oDb = new BxDolDb();
        if ($oDb->getOne("SELECT COUNT(*) FROM `sys_categories` WHERE `Category` = '" . $oForm->getCleanValue('Category') . "' AND `ID` = 0 AND `Type` = '" . $oForm->getCleanValue('Type') . "'") == 0) {
            $aValsAdd = array('ID' => 0, 'Owner' => 0, 'Status' => 'active');
            $oForm->insert($aValsAdd);
            header('Location:' . BX_DOL_URL_ADMIN . 'categories.php?action=all&module=' . $oForm->getCleanValue('Type'));
        } else {
            $sResult = sprintf(_t('_categ_exist_err'), $oForm->getCleanValue('Category'));
        }
    }
    return (strlen($sResult) > 0 ? MsgBox($sResult) : '') . $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $oForm->getCode()));
}
コード例 #3
0
ファイル: match.inc.php プロジェクト: dalinhuang/shopexts
function getMatchProfiles($iProfileId, $bForce = false, $sSort = 'none')
{
    $aResult = array();
    if (!getParam('enable_match')) {
        return $aResult;
    }
    $oDb = new BxDolDb();
    if (!(int) $iProfileId) {
        return $aResult;
    }
    if (!$bForce) {
        $aMatch = $oDb->getRow("SELECT `profiles_match` FROM `sys_profiles_match` WHERE `profile_id` = {$iProfileId} AND `sort` = '{$sSort}'");
        if (!empty($aMatch)) {
            return unserialize($aMatch['profiles_match']);
        }
    } else {
        $oDb->query("DELETE FROM `sys_profiles_match` WHERE `profile_id` = {$iProfileId}");
    }
    $aProf = getProfileInfo($iProfileId);
    if (empty($aProf)) {
        return $aResult;
    }
    $aMathFields = getMatchFields();
    $iAge = (int) $oDb->getOne("SELECT DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(), '{$aProf['DateOfBirth']}')), '%Y') + 0 AS age");
    foreach ($aMathFields as $sKey => $aFields) {
        $aMathFields[$sKey]['profiles'] = array();
        if ($aProf[$aFields['Name']]) {
            if ($aMathFields[$aFields['MatchField']]['Name'] == 'DateOfBirth') {
                if ($iAge) {
                    $sCond = "(DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(), `DateOfBirth`)), '%Y') + 0) = {$iAge}";
                }
            } else {
                if ($aMathFields[$aFields['MatchField']]['Name']) {
                    $sCond = "`{$aMathFields[$aFields['MatchField']]['Name']}` = '" . process_db_input($aProf[$aFields['Name']], BX_TAGS_NO_ACTION, BX_SLASHES_NO_ACTION) . "'";
                    $aMathFields[$sKey]['profiles'] = $oDb->getAllWithKey("SELECT `ID` FROM `Profiles` WHERE `Status` = 'Active' AND `ID` != {$iProfileId} AND {$sCond}", 'ID');
                }
            }
        }
    }
    $sCondSort = '';
    if ($sSort == 'activity') {
        $sCondSort = 'ORDER BY `DateLastNav` DESC';
    } else {
        if ($sSort == 'date_reg') {
            $sCondSort = 'ORDER BY `DateReg` DESC';
        }
    }
    $iPercentThreshold = getParam('match_percent');
    $aProfiles = $oDb->getColumn("SELECT `ID` FROM `Profiles` WHERE `Status` = 'Active' AND `ID` != {$iProfileId} {$sCondSort}");
    foreach ($aProfiles as $iProfId) {
        $iPercent = 0;
        foreach ($aMathFields as $sKey => $aFields) {
            if (isset($aFields['profiles'][$iProfId])) {
                $iPercent += (int) $aFields['MatchPercent'];
            }
        }
        if ($iPercent >= $iPercentThreshold) {
            $aResult[] = $iProfId;
        }
    }
    $oDb->query("INSERT INTO `sys_profiles_match`(`profile_id`, `sort`, `profiles_match`) VALUES({$iProfileId}, '{$sSort}', '" . serialize($aResult) . "')");
    return $aResult;
}