function transferCategories()
 {
     $sSql = "SELECT \r\n        \t\t\t`CategoryID` AS `id`, \r\n        \t\t\t`CategoryName` AS `name`\r\n        \t\tFROM `ArticlesCategory`";
     $rResult = mysql_query($sSql, $this->rOldDb);
     $iCount = mysql_num_rows($rResult);
     while ($aCategory = mysql_fetch_assoc($rResult)) {
         if (get_mb_len($aCategory['name']) > 32) {
             $aCategory['name'] = get_mb_substr($aCategory['name'], 0, 32);
         }
         if ($this->existsCategory($aCategory['name'], 0, $this->_sType)) {
             continue;
         }
         //escape all values
         $aCategory['name'] = $this->oMigrationModule->_oDb->escape($aCategory['name']);
         $sSql = "INSERT INTO `sys_categories`(`Category`, `ID`, `Type`, `Owner`, `Status`, `Date`)\r\n            \t\t VALUES('" . $aCategory['name'] . "', '0', '" . $this->_sType . "', '0', 'active', NOW())";
         $iResult = (int) $this->oDolModule->_oDb->query($sSql);
         if ($iResult <= 0) {
             $this->setResultStatus('Database error. Cannot insert category in the database.');
             return MIGRATION_FAILED;
         }
     }
     return MIGRATION_SUCCESSFUL;
 }
Esempio n. 2
0
 /**
  * Constructor
  * $sSystem - comments system name
  * $iId - obect id to be commented
  */
 function __construct($sSystem, $iId, $iInit = 1)
 {
     parent::__construct();
     $this->_aSystems = $this->getSystems();
     if (!isset($this->_aSystems[$sSystem])) {
         return;
     }
     $this->_sSystem = $sSystem;
     $this->_aSystem = $this->_aSystems[$sSystem];
     $this->_aSystem['table_images'] = 'sys_cmts_images';
     $this->_aSystem['table_images2entries'] = 'sys_cmts_images2entries';
     $this->_aSystem['table_ids'] = 'sys_cmts_ids';
     $this->_aSystem['is_browse_filter'] = (int) $this->_bBrowseFilter;
     $this->_iDpMaxLevel = (int) $this->_aSystem['number_of_levels'];
     $this->_sDisplayType = $this->_iDpMaxLevel == 0 ? BX_CMT_DISPLAY_FLAT : BX_CMT_DISPLAY_THREADED;
     $this->_sDpSessionKey = 'bx_' . $this->_sSystem . '_dp_';
     $this->_sBrowseType = $this->_aSystem['browse_type'];
     $this->_sBrowseFilter = BX_CMT_FILTER_ALL;
     $this->_sBpSessionKeyType = 'bx_' . $this->_sSystem . '_bpt_';
     $this->_sBpSessionKeyFilter = 'bx_' . $this->_sSystem . '_bpf_';
     $this->_aOrder = array('by' => BX_CMT_ORDER_BY_DATE, 'way' => BX_CMT_ORDER_WAY_ASC);
     list($mixedUserDp, $mixedUserBpType, $mixedUserBpFilter) = $this->_getUserChoice();
     if (!empty($mixedUserDp)) {
         $this->_sDisplayType = $mixedUserDp;
     }
     if (!empty($mixedUserBpType)) {
         $this->_sBrowseType = $mixedUserBpType;
     }
     if (!empty($mixedUserBpFilter)) {
         $this->_sBrowseFilter = $mixedUserBpFilter;
     }
     $this->_sViewUrl = BX_DOL_URL_ROOT . 'cmts.php';
     $this->_sBaseUrl = BxDolPermalinks::getInstance()->permalink($this->_aSystem['base_url']);
     if (get_mb_substr($this->_sBaseUrl, 0, 4) != 'http') {
         $this->_sBaseUrl = BX_DOL_URL_ROOT . $this->_sBaseUrl;
     }
     $this->_sListAnchor = "cmts-anchor-%s-%d";
     $this->_oQuery = new BxDolCmtsQuery($this);
     $this->_sFormObject = 'sys_comment';
     $this->_sFormDisplayPost = 'sys_comment_post';
     $this->_sFormDisplayEdit = 'sys_comment_edit';
     $this->_sConnObjFriends = 'sys_profiles_friends';
     $this->_sConnObjSubscriptions = 'sys_profiles_subscriptions';
     $this->_sMenuObjManage = 'sys_cmts_item_manage';
     $this->_sMenuObjActions = 'sys_cmts_item_actions';
     $this->_sMetatagsObj = 'sys_cmts';
     if ($iInit) {
         $this->init($iId);
     }
 }
Esempio n. 3
0
function uriGenerate($s, $sTable, $sField, $iMaxLen = 255)
{
    $s = uriFilter($s);
    if (uriCheckUniq($s, $sTable, $sField)) {
        return $s;
    }
    // try to add date
    if (get_mb_len($s) > 240) {
        $s = get_mb_substr($s, 0, 240);
    }
    $s .= '-' . date('Y-m-d');
    if (uriCheckUniq($s, $sTable, $sField)) {
        return $s;
    }
    // try to add number
    for ($i = 0; $i < 999; ++$i) {
        if (uriCheckUniq($s . '-' . $i, $sTable, $sField)) {
            return $s . '-' . $i;
        }
    }
    return rand(0, 999999999);
}
function uriGenerate($s, $sTable, $sField, $iMaxLen = 255)
{
    //$s = get_mb_replace ('/[^\pL^\pN]+/u', '-', $s); // unicode characters
    $s = get_mb_replace('/([^\\d^\\w]+)/', '-', $s);
    // latin characters
    $s = get_mb_replace('/([-^]+)/', '-', $s);
    if (uriCheckUniq($s, $sTable, $sField)) {
        return $s;
    }
    // try to add date
    if (get_mb_len($s) > 240) {
        $s = get_mb_substr($s, 0, 240);
    }
    $s .= '-' . date('Y-m-d');
    if (uriCheckUniq($s, $sTable, $sField)) {
        return $s;
    }
    // try to add number
    for ($i = 0; $i < 999; ++$i) {
        if (uriCheckUniq($s . '-' . $i, $sTable, $sField)) {
            return $s . '-' . $i;
        }
    }
    return rand(0, 999999999);
}
Esempio n. 5
0
function uriGenerate($s, $sTable, $sField, $sEmpty = '-')
{
    $s = uriFilter($s, $sEmpty);
    if (uriCheckUniq($s, $sTable, $sField)) {
        return $s;
    }
    // cut off redundant part
    if (get_mb_len($s) > 240) {
        $s = get_mb_substr($s, 0, 240);
    }
    // try to add date
    $s .= '-' . date('Y-m-d');
    if (uriCheckUniq($s, $sTable, $sField)) {
        return $s;
    }
    // try to add number
    for ($i = 0; $i < 999; ++$i) {
        if (uriCheckUniq($s . '-' . $i, $sTable, $sField)) {
            return $s . '-' . $i;
        }
    }
    return rand(0, 999999999);
}
Esempio n. 6
0
 function getCorrectUri($sCaption, $iOwnerId = 0, $bCheck = true)
 {
     $sUri = uriFilter($sCaption);
     if (!$sUri) {
         $sUri = '-';
     }
     if (!$bCheck) {
         return $sUri;
     }
     if ($this->checkUriUniq($sUri, $iOwnerId)) {
         return $sUri;
     }
     if (get_mb_len($sUri) > 240) {
         $sUri = get_mb_substr($sUri, 0, 240);
     }
     $sUri .= '-' . date('Y-m-d');
     if ($this->checkUriUniq($sUri, $iOwnerId)) {
         return $sUri;
     }
     for ($i = 0; $i < 999; ++$i) {
         if ($this->checkUriUniq($sUri . '-' . $i, $iOwnerId)) {
             return $sUri . '-' . $i;
         }
     }
     return time();
 }