/**
  * Sets up navigation for current view
  *
  * @param string $sNode None name
  */
 protected function _setupNavigation($sNode)
 {
     $myAdminNavig = $this->getNavigation();
     $sNode = oxRegistry::getConfig()->getRequestParameter("menu");
     // active tab
     $iActTab = oxRegistry::getConfig()->getRequestParameter('actedit');
     $iActTab = $iActTab ? $iActTab : $this->_iDefEdit;
     $sActTab = $iActTab ? "&actedit={$iActTab}" : '';
     // list url
     $this->_aViewData['listurl'] = $myAdminNavig->getListUrl($sNode) . $sActTab;
     // edit url
     $sEditUrl = $myAdminNavig->getEditUrl($sNode, $iActTab) . $sActTab;
     if (!getStr()->preg_match("/^http(s)?:\\/\\//", $sEditUrl)) {
         //internal link, adding path
         /** @var oxUtilsUrl $oUtilsUrl */
         $oUtilsUrl = oxRegistry::get("oxUtilsUrl");
         $sSelfLinkParameter = $this->getViewConfig()->getViewConfigParam('selflink');
         $sEditUrl = $oUtilsUrl->appendParamSeparator($sSelfLinkParameter) . $sEditUrl;
     }
     $this->_aViewData['editurl'] = $sEditUrl;
     // tabs
     $this->_aViewData['editnavi'] = $myAdminNavig->getTabs($sNode, $iActTab);
     // active tab
     $this->_aViewData['actlocation'] = $myAdminNavig->getActiveTab($sNode, $iActTab);
     // default tab
     $this->_aViewData['default_edit'] = $myAdminNavig->getActiveTab($sNode, $this->_iDefEdit);
     // passign active tab number
     $this->_aViewData['actedit'] = $iActTab;
     // buttons
     $this->_aViewData['bottom_buttons'] = $myAdminNavig->getBtn($sNode);
 }
/**
 * Smarty function
 * -------------------------------------------------------------
 * Purpose: add additional parameters to SEO url
 * add |oxaddparams:"...." to link
 * -------------------------------------------------------------
 *
 * @param string $sUrl       Url
 * @param string $sDynParams Dynamic URL parameters
 *
 * @return string
 */
function smarty_modifier_oxaddparams($sUrl, $sDynParams)
{
    $oStr = getStr();
    // removing empty parameters
    $sDynParams = $sDynParams ? $oStr->preg_replace(array('/^\\?/', '/^\\&(amp;)?$/'), '', $sDynParams) : false;
    if ($sDynParams) {
        $sUrl .= (strpos($sUrl, '?') !== false ? "&" : "?") . $sDynParams;
    }
    return oxUtilsUrl::getInstance()->processSeoUrl($sUrl);
}
Exemplo n.º 3
1
 /**
  * Set attribute selected value
  *
  * @param string $sValue - attribute value
  *
  * @return null
  */
 public function setActiveValue($sValue)
 {
     $this->_sActiveValue = getStr()->htmlspecialchars($sValue);
 }
Exemplo n.º 4
0
 /**
  * @return $this
  * @throws Exception
  */
 public function parse()
 {
     $handle = self::getFileHandler(self::$parseFile, "r");
     self::flushMainFile();
     self::flushTempFile();
     /**
      * @param $handle
      * @return Generator
      */
     function getStr($handle)
     {
         while (($buffer = fgets($handle)) !== false) {
             $keywords = preg_split("/[\\s+]/", preg_replace("/[^\\d\\w]+/ui", ' ', $buffer));
             (yield $keywords);
         }
         fclose($handle);
     }
     $generator = getStr($handle);
     $a = [];
     foreach ($generator as $value) {
         foreach ($value as $item) {
             $a[strtolower($item)] = isset($a[strtolower($item)]) ? $a[strtolower($item)] + 1 : 1;
         }
         if (count($a) >= self::MAX_ARRAY_ELEMENT) {
             $this->writeData($a);
             $a = [];
         }
     }
     $this->writeData($a);
     return $this;
 }
 /**
  * Sets efire parameters to view, returns name of template to render
  *
  * @return string
  */
 public function render()
 {
     $oStr = getStr();
     $myConfig = $this->getConfig();
     $this->_aViewData['sEfiUsername'] = $oStr->htmlspecialchars($myConfig->getConfigParam('sEfiUsername'));
     $this->_aViewData['sEfiPassword'] = $oStr->htmlspecialchars($myConfig->getConfigParam('sEfiPassword'));
     return parent::render();
 }
Exemplo n.º 6
0
 /**
  * Prepares and returns string for search engines.
  *
  * @param string $sSearchStr String to prepare for search engines
  *
  * @return string
  */
 public function prepareStrForSearch($sSearchStr)
 {
     $oStr = getStr();
     if ($oStr->hasSpecialChars($sSearchStr)) {
         return $oStr->recodeEntities($sSearchStr, true, array('&'), array('&'));
     }
     return '';
 }
Exemplo n.º 7
0
 public function getGPSData()
 {
     $userVehicle = $this->userModel->getAssignedVehicle($this->userId);
     if ($userVehicle !== null) {
         $vehicleId = getStr($userVehicle->Vehicle_idvehicle);
         echo $this->vehicleModel->getLastDrivenPath($vehicleId);
     }
 }
 /**
  * Uploaded file processor (filters, etc), sets configuration parameters to  passed object and returns it.
  *
  * @param object $oObject          Object, that parameters are modified according to passed files.
  * @param array  $aFiles           Name of files to process.
  * @param bool   $blUseMasterImage Use master image as source for processing.
  * @param bool   $blUnique         TRUE - forces new file creation with unique name.
  *
  * @return object
  */
 public function processFiles($oObject = null, $aFiles = array(), $blUseMasterImage = false, $blUnique = true)
 {
     $aFiles = $aFiles ? $aFiles : $_FILES;
     if (isset($aFiles['myfile']['name'])) {
         $oDb = oxDb::getDb();
         $oConfig = $this->getConfig();
         $oStr = getStr();
         // A. protection for demoshops - strictly defining allowed file extensions.
         $blDemo = (bool) $oConfig->isDemoShop();
         // Folder where images will be processed.
         $sTmpFolder = $oConfig->getConfigParam('sCompileDir');
         $iNewFilesCounter = 0;
         $aSource = $aFiles['myfile']['tmp_name'];
         $aError = $aFiles['myfile']['error'];
         $sErrorsDescription = '';
         $oEx = oxNew('oxExceptionToDisplay');
         while (list($sKey, $sValue) = each($aFiles['myfile']['name'])) {
             $sSource = $aSource[$sKey];
             $iError = $aError[$sKey];
             $aFiletype = explode('@', $sKey);
             $sKey = $aFiletype[1];
             $sType = $aFiletype[0];
             $sValue = strtolower($sValue);
             $sImagePath = $this->_getImagePath($sType);
             // Should translate error to user if file was uploaded.
             if (UPLOAD_ERR_OK !== $iError && UPLOAD_ERR_NO_FILE !== $iError) {
                 $sErrorsDescription = $this->translateError($iError);
                 $oEx->setMessage($sErrorsDescription);
                 oxRegistry::get('oxUtilsView')->addErrorToDisplay($oEx, false);
             }
             // Checking file type and building final file name.
             if ($sSource && ($sValue = $this->_prepareImageName($sValue, $sType, $blDemo, $sImagePath, $blUnique))) {
                 // Moving to tmp folder for processing as safe mode or spec. open_basedir setup.
                 // Usually does not allow file modification in php's temp folder.
                 $sProcessPath = $sTmpFolder . basename($sSource);
                 if ($sProcessPath) {
                     if ($blUseMasterImage) {
                         // Using master image as source, so only copying it to.
                         $blMoved = $this->_copyFile($sSource, $sImagePath . $sValue);
                     } else {
                         $blMoved = $this->_moveImage($sSource, $sImagePath . $sValue);
                     }
                     if ($blMoved) {
                         // New image successfully add.
                         $iNewFilesCounter++;
                         // Assign the name.
                         if ($oObject && isset($oObject->{$sKey})) {
                             $oObject->{$sKey}->setValue($sValue);
                             $oDb->Execute("INSERT INTO `ongr_sync_jobs` SET\n                                            `TYPE` = 'U',\n                                            `WORKER_TYPE` = 'P',\n                                            `ENTITY` = 'pictures',\n                                            `TABLE` = ?,\n                                            `OXID` = ?,\n                                            `STATUS` = 0,\n                                            `PRIORITY` = 0,\n                                            `CHANGES` = ?", array($oObject->getCoreTableName(), $oObject->getId(), $sKey));
                         }
                     }
                 }
             }
         }
         $this->_setNewFilesCounter($iNewFilesCounter);
     }
     return $oObject;
 }
Exemplo n.º 9
0
/**
 * Smarty plugin
 * -------------------------------------------------------------
 * File: function.oxstyle.php
 * Type: string, html
 * Name: oxstyle
 * Purpose: Collect given css files. but include them only at the top of the page.
 *
 * Add [{oxstyle include="oxid.css"}] to include local css file.
 * Add [{oxstyle include="oxid.css?20120413"}] to include local css file with query string part.
 * Add [{oxstyle include="http://www.oxid-esales.com/oxid.css"}] to include external css file.
 *
 * IMPORTANT!
 * Do not forget to add plain [{oxstyle}] tag where you need to output all collected css includes.
 * -------------------------------------------------------------
 *
 * @param array  $params  params
 * @param Smarty &$smarty clever simulation of a method
 *
 * @return string
 */
function smarty_function_oxstyle($params, &$smarty)
{
    $myConfig = oxRegistry::getConfig();
    $sSuffix = !empty($smarty->_tpl_vars["__oxid_include_dynamic"]) ? '_dynamic' : '';
    $sWidget = !empty($params['widget']) ? $params['widget'] : '';
    $blInWidget = !empty($params['inWidget']) ? $params['inWidget'] : false;
    $sCStyles = 'conditional_styles' . $sSuffix;
    $sStyles = 'styles' . $sSuffix;
    $aCStyles = (array) $myConfig->getGlobalParameter($sCStyles);
    $aStyles = (array) $myConfig->getGlobalParameter($sStyles);
    if ($sWidget && !$blInWidget) {
        return;
    }
    $sOutput = '';
    if (!empty($params['include'])) {
        $sStyle = $params['include'];
        if (!preg_match('#^https?://#', $sStyle)) {
            $sOriginalStyle = $sStyle;
            // Separate query part #3305.
            $aStyle = explode('?', $sStyle);
            $sStyle = $aStyle[0] = $myConfig->getResourceUrl($aStyle[0], $myConfig->isAdmin());
            if ($sStyle && count($aStyle) > 1) {
                // Append query part if still needed #3305.
                $sStyle .= '?' . $aStyle[1];
            } elseif ($sSPath = $myConfig->getResourcePath($sOriginalStyle, $myConfig->isAdmin())) {
                // Append file modification timestamp #3725.
                $sStyle .= '?' . filemtime($sSPath);
            }
        }
        // File not found ?
        if (!$sStyle) {
            if ($myConfig->getConfigParam('iDebug') != 0) {
                $sError = "{oxstyle} resource not found: " . getStr()->htmlspecialchars($params['include']);
                trigger_error($sError, E_USER_WARNING);
            }
            return;
        }
        // Conditional comment ?
        if (!empty($params['if'])) {
            $aCStyles[$sStyle] = $params['if'];
            $myConfig->setGlobalParameter($sCStyles, $aCStyles);
        } else {
            $aStyles[] = $sStyle;
            $aStyles = array_unique($aStyles);
            $myConfig->setGlobalParameter($sStyles, $aStyles);
        }
    } else {
        foreach ($aStyles as $sSrc) {
            $sOutput .= '<link rel="stylesheet" type="text/css" href="' . $sSrc . '" />' . PHP_EOL;
        }
        foreach ($aCStyles as $sSrc => $sCondition) {
            $sOutput .= '<!--[if ' . $sCondition . ']><link rel="stylesheet" type="text/css" href="' . $sSrc . '"><![endif]-->' . PHP_EOL;
        }
    }
    return $sOutput;
}
Exemplo n.º 10
0
 function checkData($data)
 {
     if (is_array($data)) {
         foreach ($data as $key => $v) {
             $data[$key] = checkData($v);
         }
     } else {
         $data = getStr($data);
     }
     return $data;
 }
Exemplo n.º 11
0
function selectTable($sp)
{
    $ids = explode(",", getInstanceIDs("Device.X_CISCO_COM_DDNS.Service."));
    foreach ($ids as $key => $j) {
        $spArr[$j] = getStr("Device.X_CISCO_COM_DDNS.Service." . $j . ".ServiceName");
        if (strcasecmp($sp, $spArr[$j]) == 0) {
            return $j;
        }
    }
    return 0;
}
Exemplo n.º 12
0
function php_getstr($str)
{
    if ("Enabled" == $_SESSION["psmMode"]) {
        if (strstr($str, "WiFi")) {
            return "";
        }
        if (strstr($str, "MoCA")) {
            return "";
        }
    }
    return getStr($str);
}
 /**
  * Adds filter SQL to current query
  *
  * @param string $sQ query to add filter condition
  *
  * @return string
  */
 protected function _addFilter($sQ)
 {
     $sQ = parent::_addFilter($sQ);
     // display variants or not ?
     if ($this->getConfig()->getConfigParam('blVariantsSelection')) {
         $sQ .= ' group by ' . $this->_getViewName('oxarticles') . '.oxid ';
         $oStr = getStr();
         if ($oStr->strpos($sQ, "select count( * ) ") === 0) {
             $sQ = "select count( * ) from ( {$sQ} ) as _cnttable";
         }
     }
     return $sQ;
 }
Exemplo n.º 14
0
function getPort4XHSEnabled()
{
    $rootObjName = "Device.X_CISCO_COM_MultiLAN.";
    $paramNameArray = array("Device.X_CISCO_COM_MultiLAN.");
    $mapping_array = array("PrimaryLANBridge", "PrimaryLANBridgeHSPorts", "HomeSecurityBridge", "HomeSecurityBridgePorts");
    $multiLan = getParaValues($rootObjName, $paramNameArray, $mapping_array);
    if (!empty($multiLan)) {
        $pLanBridgeHSPortEnable = getStr($multiLan[0]["PrimaryLANBridge"] . ".Port." . $multiLan[0]["PrimaryLANBridgeHSPorts"] . ".Enable");
        $HSBridgePortEnable = getStr($multiLan[0]["HomeSecurityBridge"] . ".Port." . $multiLan[0]["HomeSecurityBridgePorts"] . ".Enable");
        return $pLanBridgeHSPortEnable === 'false' && $HSBridgePortEnable === 'true';
    }
    return false;
}
 /**
  * Formats and returns statiistics configuration related data array for ajax response
  *
  * @param string $sCountQ this param currently is not used as thsi mathod overrides default function behaviour
  * @param string $sQ      this param currently is not used as thsi mathod overrides default function behaviour
  *
  * @return array
  */
 protected function _getData($sCountQ, $sQ)
 {
     $aResponse['startIndex'] = $this->_getStartIndex();
     $aResponse['sort'] = '_' . $this->_getSortCol();
     $aResponse['dir'] = $this->_getSortDir();
     // all possible reports
     $aReports = oxSession::getVar("allstat_reports");
     $sSynchId = oxConfig::getParameter("synchoxid");
     $sOxId = oxConfig::getParameter("oxid");
     $sStatId = $sSynchId ? $sSynchId : $sOxId;
     $oStat = oxNew('oxstatistic');
     $oStat->load($sStatId);
     $aStatData = unserialize($oStat->oxstatistics__oxvalue->value);
     $aData = array();
     $iCnt = 0;
     $oStr = getStr();
     // filter data
     $aFilter = oxConfig::getParameter("aFilter");
     $sFilter = is_array($aFilter) && isset($aFilter['_0']) ? $oStr->preg_replace('/^\\*/', '%', $aFilter['_0']) : null;
     foreach ($aReports as $oReport) {
         if ($sSynchId) {
             if (is_array($aStatData) && in_array($oReport->filename, $aStatData)) {
                 continue;
             }
         } else {
             if (!is_array($aStatData) || !in_array($oReport->filename, $aStatData)) {
                 continue;
             }
         }
         // checking filter
         if ($sFilter && !$oStr->preg_match("/^" . preg_quote($sFilter) . "/i", $oReport->name)) {
             continue;
         }
         $aData[$iCnt]['_0'] = $oReport->name;
         $aData[$iCnt]['_1'] = $oReport->filename;
         $iCnt++;
     }
     // ordering ...
     if (oxConfig::getParameter("dir")) {
         if ('asc' == oxConfig::getParameter("dir")) {
             usort($aData, array($this, "sortAsc"));
         } else {
             usort($aData, array($this, "sortDesc"));
         }
     } else {
         usort($aData, array($this, "sortAsc"));
     }
     $aResponse['records'] = $aData;
     $aResponse['totalRecords'] = count($aReports);
     return $aResponse;
 }
Exemplo n.º 16
0
 /**
  * Goal: If passed url is not found,
  * try to find any other that consist of it,
  * by removing each time the string after the last slash.
  *
  * Ex.
  * if "http://[yourwebsite.com]/magazin/tag/[tagname]" was not found
  * then render "http://[yourwebsite.com]/magazin/"
  *
  * @param $sSeoUrl
  * @return mixed
  */
 public function decodeUrl($sSeoUrl)
 {
     $aRet = parent::decodeUrl($sSeoUrl);
     $sStylaBase = StylaSEO_Setup::STYLA_BASEDIR;
     if ($this->getConfig()->getConfigParam('styla_seo_basedir')) {
         $sStylaBase = $this->getConfig()->getConfigParam('styla_seo_basedir');
     }
     $oStr = getStr();
     if ($aRet === false && $oStr->strpos($sSeoUrl, $sStylaBase) !== false) {
         # Fallback to magazine route
         $aRet = parent::decodeUrl(rtrim($sStylaBase, '/') . '/');
     }
     return $aRet;
 }
Exemplo n.º 17
0
 public function testGetTreePath()
 {
     $sTag = "testTag";
     $oStr = getStr();
     $aPath[0] = oxNew("oxCategory");
     $aPath[0]->setLink(false);
     $aPath[0]->oxcategories__oxtitle = new oxField(oxRegistry::getLang()->translateString('TAGS'));
     $aPath[1] = oxNew("oxCategory");
     $aPath[1]->setLink(false);
     $aPath[1]->oxcategories__oxtitle = new oxField($oStr->htmlspecialchars($oStr->ucfirst($sTag)));
     $oView = $this->getMock("tag", array("getTag"));
     $oView->expects($this->once())->method('getTag')->will($this->returnValue($sTag));
     $this->assertEquals($aPath, $oView->getTreePath());
 }
Exemplo n.º 18
0
/**
 * This method replaces existing Smarty function for truncating strings
 * (check Smarty documentation for details). When truncating strings
 * additionally we need to convert &#039;/&quot; entities to '/"
 * and after truncating convert them back.
 *
 * -------------------------------------------------------------
 * Name:     truncate<br>
 * Purpose:  Truncate a string to a certain length if necessary,
 *           optionally splitting in the middle of a word, and
 *           appending the $etc string or inserting $etc into the middle.
 *  -------------------------------------------------------------
 *
 * @param string  $sString      String to truncate
 * @param integer $iLength      To length
 * @param string  $sSufix       Truncation mark
 * @param bool    $blBreakWords break words
 * @param bool    $middle       middle ?
 *
 * @return string
 */
function smarty_modifier_oxtruncate($sString, $iLength = 80, $sSufix = '...', $blBreakWords = false, $middle = false)
{
    if ($iLength == 0) {
        return '';
    } elseif ($iLength > 0 && getStr()->strlen($sString) > $iLength) {
        $iLength -= getStr()->strlen($sSufix);
        $sString = str_replace(array('&#039;', '&quot;'), array("'", '"'), $sString);
        if (!$blBreakWords) {
            $sString = getStr()->preg_replace('/\\s+?(\\S+)?$/', '', getStr()->substr($sString, 0, $iLength + 1));
        }
        $sString = getStr()->substr($sString, 0, $iLength) . $sSufix;
        return str_replace(array("'", '"'), array('&#039;', '&quot;'), $sString);
    }
    return $sString;
}
Exemplo n.º 19
0
/**
 * Smarty plugin
 * -------------------------------------------------------------
 * File: block.oxid_content.php
 * Type: string, html
 * Name: block_oxifcontent
 * Purpose: Output content snippet if content exists
 * add [{oxifcontent ident="..." }][{/oxifcontent}] where you want to display content
 * -------------------------------------------------------------
 *
 * @param array  $params  params
 * @param string $content rendered content
 * @param Smarty &$smarty clever simulation of a method
 * @param bool   &$repeat repeat
 *
 * @return string
 */
function smarty_block_oxifcontent($params, $content, &$smarty, &$repeat)
{
    $myConfig = oxRegistry::getConfig();
    $sIdent = isset($params['ident']) ? $params['ident'] : null;
    $sOxid = isset($params['oxid']) ? $params['oxid'] : null;
    $sAssign = isset($params['assign']) ? $params['assign'] : null;
    $sObject = isset($params['object']) ? $params['object'] : 'oCont';
    if ($repeat) {
        if ($sIdent || $sOxid) {
            static $aContentCache = array();
            if ($sIdent && isset($aContentCache[$sIdent]) || $sOxid && isset($aContentCache[$sOxid])) {
                $oContent = $sOxid ? $aContentCache[$sOxid] : $aContentCache[$sIdent];
            } else {
                $oContent = oxNew("oxContent");
                $blLoaded = $sOxid ? $oContent->load($sOxid) : $oContent->loadbyIdent($sIdent);
                if ($blLoaded && $oContent->isActive()) {
                    $aContentCache[$oContent->getId()] = $aContentCache[$oContent->getLoadId()] = $oContent;
                } else {
                    $oContent = false;
                    if ($sOxid) {
                        $aContentCache[$sOxid] = $oContent;
                    } else {
                        $aContentCache[$sIdent] = $oContent;
                    }
                }
            }
            $blLoaded = false;
            if ($oContent) {
                $smarty->assign($sObject, $oContent);
                $blLoaded = true;
            }
        } else {
            $blLoaded = false;
        }
        $repeat = $blLoaded;
    } else {
        $oStr = getStr();
        $blHasSmarty = $oStr->strstr($content, '[{');
        if ($blHasSmarty) {
            $content = oxRegistry::get("oxUtilsView")->parseThroughSmarty($content, $sIdent . md5($content), $myConfig->getActiveView());
        }
        if ($sAssign) {
            $smarty->assign($sAssign, $content);
        } else {
            return $content;
        }
    }
}
Exemplo n.º 20
0
 /**
  * Returns active category (manufacturer/vendor/tag) id
  *
  * @return string
  */
 public function getActCatId()
 {
     $sId = false;
     $aData = oxRegistry::getConfig()->getRequestParameter("aSeoData");
     if ($aData && isset($aData["oxparams"])) {
         $oStr = getStr();
         $iStartPos = $oStr->strpos($aData["oxparams"], "#");
         $iEndPos = $oStr->strpos($aData["oxparams"], "#", $iStartPos + 1);
         $iLen = $oStr->strlen($aData["oxparams"]);
         $sId = $oStr->substr($aData["oxparams"], $iStartPos + 1, $iEndPos - $iLen);
     } elseif ($aList = $this->getSelectionList()) {
         $oItem = reset($aList[$this->getActCatType()][$this->getActCatLang()]);
         $sId = $oItem->getId();
     }
     return $sId;
 }
Exemplo n.º 21
0
 /**
  * Separate query part, appends query part if needed, append file modification timestamp.
  *
  * @param string $file
  *
  * @return string
  */
 protected function formLocalFileUrl($file)
 {
     $config = oxRegistry::getConfig();
     $parts = explode('?', $file);
     $url = $config->getResourceUrl($parts[0], $config->isAdmin());
     $parameters = $parts[1];
     if (empty($parameters)) {
         $path = $config->getResourcePath($file, $config->isAdmin());
         $parameters = filemtime($path);
     }
     if (empty($url) && $config->getConfigParam('iDebug') != 0) {
         $error = "{oxstyle} resource not found: " . getStr()->htmlspecialchars($file);
         trigger_error($error, E_USER_WARNING);
     }
     return $url ? "{$url}?{$parameters}" : '';
 }
Exemplo n.º 22
0
 /**
  * Reformats date to user defined format.
  *
  * @param string $sDBDateIn         Date to reformat
  * @param bool   $blForceEnglishRet Force to return primary value(default false)
  *
  * @return string
  */
 public function formatDBDate($sDBDateIn, $blForceEnglishRet = false)
 {
     // convert english format to output format
     if (!$sDBDateIn) {
         return null;
     }
     $oStr = getStr();
     if ($blForceEnglishRet && $oStr->strstr($sDBDateIn, '-')) {
         return $sDBDateIn;
     }
     if ($this->isEmptyDate($sDBDateIn) && $sDBDateIn != '-') {
         return '-';
     } elseif ($sDBDateIn == '-') {
         return '0000-00-00 00:00:00';
     }
     // is it a timestamp ?
     if (is_numeric($sDBDateIn)) {
         // db timestamp : 20030322100409
         $sNew = substr($sDBDateIn, 0, 4) . '-' . substr($sDBDateIn, 4, 2) . '-' . substr($sDBDateIn, 6, 2) . ' ';
         // check if it is a timestamp or wrong data: 20030322
         if (strlen($sDBDateIn) > 8) {
             $sNew .= substr($sDBDateIn, 8, 2) . ':' . substr($sDBDateIn, 10, 2) . ':' . substr($sDBDateIn, 12, 2);
         }
         // convert it to english format
         $sDBDateIn = $sNew;
     }
     // remove time as it is same in english as in german
     $aData = explode(' ', trim($sDBDateIn));
     // preparing time array
     $sTime = isset($aData[1]) && $oStr->strstr($aData[1], ':') ? $aData[1] : '';
     $aTime = $sTime ? explode(':', $sTime) : array(0, 0, 0);
     // preparind date array
     $sDate = isset($aData[0]) ? $aData[0] : '';
     $aDate = preg_split('/[\\/.-]/', $sDate);
     // choosing format..
     if ($sTime) {
         $sFormat = $blForceEnglishRet ? 'Y-m-d H:i:s' : oxLang::getInstance()->translateString('fullDateFormat');
     } else {
         $sFormat = $blForceEnglishRet ? 'Y-m-d' : oxLang::getInstance()->translateString('simpleDateFormat');
     }
     if (count($aDate) != 3) {
         return date($sFormat);
     } else {
         return $this->_processDate($aTime, $aDate, $oStr->strstr($sDate, '.'), $sFormat);
     }
 }
Exemplo n.º 23
0
function get_tips($target, $status)
{
    $tip = "No Tips!";
    switch ($target) {
        case "sta_inet":
            if ("true" == $status) {
                $tip = 'Status: Connected<br/>' . getStr("Device.Hosts.X_CISCO_COM_ConnectedDeviceNumber") . ' computers connected';
            } else {
                $tip = 'Status: Unconnected<br/>no computers';
            }
            break;
        case "sta_wifi":
            if ("true" == $status) {
                $sum = 0;
                $ids = explode(",", getInstanceIds("Device.WiFi.AccessPoint."));
                foreach ($ids as $i) {
                    $sum += getStr("Device.WiFi.AccessPoint.{$i}.AssociatedDeviceNumberOfEntries");
                }
                $tip = 'Status: Connected<br/>' . $sum . ' computers connected';
            } else {
                $tip = 'Status: Unconnected<br/>no computers';
            }
            break;
        case "sta_moca":
            if ("true" == $status && "Up" == getStr("Device.MoCA.Interface.1.Status")) {
                $tip = 'Status: Connected<br/>' . (1 + intval(getStr("Device.MoCA.Interface.1.AssociatedDeviceNumberOfEntries"))) . ' nodes connected';
            } else {
                $tip = 'Status: Unconnected<br/>no nodes';
            }
            break;
        case "sta_dect":
            if ("true" == $status) {
                $tip = getStr("Device.X_CISCO_COM_MTA.Dect.HandsetsNumberOfEntries") . ' Handsets connected';
            } else {
                $tip = 'no Handsets';
            }
            break;
        case "sta_fire":
            $tip = 'Firewall is set to ' . $status;
            break;
        default:
            $tip = "No Tips!";
            break;
    }
    return $tip;
}
Exemplo n.º 24
0
 /**
  * If passed article ID (by URL or posted form) - loads article,
  * otherwise - loads list of action articles oxarticlelist::loadActionArticles().
  * In this case, the last list object will be used. Loaded article info
  * is serialized and outputted to client system.
  *
  * @deprecated since v5.1 (2013-09-25); not used anywhere
  *
  * @return null
  */
 public function getArticle()
 {
     $myConfig = $this->getConfig();
     $myUtils = oxRegistry::getUtils();
     if (!$myConfig->getConfigParam("blAllowRemoteArticleInfo")) {
         return false;
     }
     $sOutput = 'OXID__Problem : no valid oxid !';
     $oProduct = null;
     if ($sId = oxRegistry::getConfig()->getRequestParameter('oxid')) {
         $oProduct = oxNew('oxArticle');
         $oProduct->load($sId);
     } elseif ($myConfig->getConfigParam('bl_perfLoadAktion')) {
         $oArtList = oxNew('oxarticlelist');
         $oArtList->loadActionArticles('OXAFFILIATE');
         $oProduct = $oArtList->current();
     }
     if ($oProduct) {
         $aExport = array();
         $aClassVars = get_object_vars($oProduct);
         $oStr = getStr();
         // add all database fields
         while (list($sFieldName, ) = each($aClassVars)) {
             if ($oStr->strstr($sFieldName, 'oxarticles')) {
                 $sName = str_replace('oxarticles__', '', $sFieldName);
                 $aExport[$sName] = $oProduct->{$sFieldName}->value;
             }
         }
         $oPrice = $oProduct->getPrice();
         $aExport['vatPercent'] = $oPrice->getVat();
         $aExport['netPrice'] = $myUtils->fRound($oPrice->getNettoPrice());
         $aExport['brutPrice'] = $myUtils->fRound($oPrice->getBruttoPrice());
         $aExport['vat'] = $oPrice->getVatValue();
         $aExport['fprice'] = $oProduct->getFPrice();
         $aExport['ftprice'] = $oProduct->getFTPrice();
         $aExport['oxdetaillink'] = $oProduct->getLink();
         $aExport['oxmoredetaillink'] = $oProduct->getMoreDetailLink();
         $aExport['tobasketlink'] = $oProduct->getToBasketLink();
         $sPictureUrl = $myConfig->getPictureUrl(null, false, $myConfig->isSsl());
         $aExport['thumbnaillink'] = $sPictureUrl . "/" . $aExport['oxthumb'];
         $sOutput = serialize($aExport);
     }
     // stop shop here
     $myUtils->showMessageAndExit($sOutput);
 }
Exemplo n.º 25
0
 public function showVideoRecommendations($userId, $resultsPageToken = null)
 {
     $userVehicle = $this->getAssignedVehicle($userId);
     if ($userVehicle !== null) {
         $modelId = $userVehicle->Vehicle_Vehicle_model_idvehicle_model;
         $vehicleModel = getStr($this->api->get('vehicle_model', $modelId)->data('idVehicle_model')->name);
         $googleAPI = new Google_Client();
         $googleAPI->setDeveloperKey(YOUTUBE_API_KEY);
         $youtube = new Google_Service_YouTube($googleAPI);
         $searchOptions = ['q' => $vehicleModel, 'maxResults' => 10, 'type' => 'video'];
         if ($resultsPageToken !== null) {
             $searchOptions['pageToken'] = $resultsPageToken;
         }
         $searchResults = $youtube->search->listSearch('id, snippet', $searchOptions);
         $searchResults->searchQuery = $vehicleModel;
         // Add query string to output
         return $searchResults;
     }
     return null;
 }
Exemplo n.º 26
0
/**
 *  Description: Judge whether the user input ip valid or not (based on current gw ip and subnetmask)
 *  parameter  : input IP address
 *  return     : bool(TRUE/FALSE)
 */
function isIPValid($IP)
{
    $ret = TRUE;
    $LanSubMask = getStr("Device.X_CISCO_COM_DeviceControl.LanManagementEntry.1.LanSubnetMask");
    $LanGwIP = getStr("Device.X_CISCO_COM_DeviceControl.LanManagementEntry.1.LanIPAddress");
    $gwIP = explode('.', $LanGwIP);
    $hostIP = explode('.', $IP);
    if ($LanGwIP == $IP) {
        $ret = FALSE;
    } elseif (strstr($IP, '172.16.12')) {
        //$msg = "This ip is reserved for home security";
        $ret = FALSE;
    } elseif (strstr($LanSubMask, '255.255.255')) {
        //the first three field should be equal to gw ip field
        if ($gwIP[0] != $hostIP[0] || $gwIP[1] != $hostIP[1] || $gwIP[2] != $hostIP[2]) {
            //$msg = "Input IP is not in valid range:\n" . "$gwIP[0].$gwIP[1].$gwIP[2].[2~254]";
            $ret = FALSE;
        }
    } elseif ($LanSubMask == '255.255.0.0') {
        if ($gwIP[0] != $hostIP[0] || $gwIP[1] != $hostIP[1]) {
            //$msg = "Input IP is not in valid range:\n" . "$gwIP[0].$gwIP[1].[2~254].[2~254]";
            $ret = FALSE;
        }
    } else {
        if ($gwIP[0] != $hostIP[0]) {
            //$msg = "Input IP is not in valid range:\n [10.0.0.2 ~ 10.255.255.254]";
            $ret = FALSE;
        }
    }
    if ($ret) {
        //if above check pass, then check whether the IP have been used or not
        $idArr = explode(",", getInstanceIds("Device.DHCPv4.Server.Pool.1.StaticAddress."));
        foreach ($idArr as $key => $value) {
            if (!strcasecmp(getStr("Device.DHCPv4.Server.Pool.1.StaticAddress.{$value}.Yiaddr"), $IP)) {
                $ret = FALSE;
                break;
            }
        }
    }
    return $ret;
}
Exemplo n.º 27
0
 public function run($args)
 {
     $file = $args[0];
     /**
      * @param $handle
      * @return \Generator
      */
     function getStr($handle)
     {
         while (($buffer = fgets($handle)) !== false) {
             (yield $buffer);
         }
         fclose($handle);
     }
     $handle = self::getFileHandler($file, "r");
     $generator = getStr($handle);
     foreach ($generator as $url) {
         $newQueueElement = new QueueElement();
         $newQueueElement->setFileUrl(trim($url));
         (new DownloadQueue())->putElement($newQueueElement);
     }
 }
Exemplo n.º 28
0
function ago($timeSpan, $precise = false)
{
    if ($timeSpan < 60) {
        $second = $timeSpan;
        return $second == 0 ? "Just now" : getStr($second, 'second') . ' ago';
    } else {
        $second = $timeSpan % 60;
        $minute = floor(($timeSpan - $second) / 60);
        if ($minute < 60) {
            return getStr($minute, 'minute') . ' ' . getStr($second, 'second') . ' ago';
        } else {
            $min = $minute % 60;
            $hour = floor(($minute - $min) / 60);
            if ($hour < 24) {
                return $precise ? getStr($hour, 'hour') . ' ' . getStr($min, 'minute') . ' ' . getStr($second, 'second') . ' ago' : getStr($hour, 'hour') . ' ' . getStr($min, 'minute') . ' ago';
            } else {
                $hr = $hour % 24;
                $days = floor(($hour - $hr) / 24);
                return $precise ? getStr($days, 'day') . ' ' . getStr($hr, 'hour') . ' ' . getStr($min, 'minute') . ' ' . getStr($second, 'second') . ' ago' : ($days == 1 ? 'yesterday' : $days . ' days' . ' ago');
            }
        }
    }
}
Exemplo n.º 29
0
 /**
  * Returns request url, which was executed to render current page view
  *
  * @param string $sParams     Parameters to object
  * @param bool   $blReturnUrl If return url
  *
  * @return string
  */
 public function getRequestUrl($sParams = '', $blReturnUrl = false)
 {
     $requestUrl = '';
     if ($_SERVER["REQUEST_METHOD"] != "POST") {
         if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI']) {
             $rawRequestUrl = $_SERVER['REQUEST_URI'];
         } else {
             $rawRequestUrl = $_SERVER['SCRIPT_URI'];
         }
         // trying to resolve controller file name
         if ($rawRequestUrl && ($iPos = stripos($rawRequestUrl, '?')) !== false) {
             $string = getStr();
             // formatting request url
             $requestUrl = 'index.php' . $string->substr($rawRequestUrl, $iPos);
             // removing possible session id
             $requestUrl = $string->preg_replace('/(&|\\?)(force_)?(admin_)?sid=[^&]*&?/', '$1', $requestUrl);
             $requestUrl = $string->preg_replace('/(&|\\?)stoken=[^&]*&?/', '$1', $requestUrl);
             $requestUrl = $string->preg_replace('/&$/', '', $requestUrl);
             $requestUrl = str_replace('&', '&amp;', $requestUrl);
         }
     }
     return $requestUrl;
 }
Exemplo n.º 30
0
function auto_post($url, $post_id, $type = '')
{
    $url = curl($url);
    $url = explode('<ul class="episodelist">', $url);
    $url = explode('</ul>', $url[1]);
    $url = str_replace('<blink>', '<b>', $url);
    $url = str_replace('</a></blink>', '</b>', $url);
    $url = explode('href="', $url[0]);
    $dem = count($url) - 1;
    ?>
<fieldset>

<?php 
    for ($i = 1; $i <= $dem; $i++) {
        $vip = getStr('"', $url[$i]);
        $vip = $vip[0];
        $name = getStr('<b>', $url[$i]);
        $name = getStr('</b>', $name[1]);
        $name = $name[0];
        $link = curl($vip);
        $link = str_replace('proxy.list', 'proxy.link', $link);
        $url1 = getStr('proxy.link=', $link);
        $url1 = getStr('&', $url1[1]);
        $url1 = $url1[0];
        $url2 = curl($url1);
        $url2 = getStr('<location><![CDATA[', $url2);
        $url2 = getStr(']]></location>', $url2[1]);
        $url2 = $url2[0];
        if (FilmEpisodeNewEpisode($name, $post_id, $_POST['episode_server'], $url2, $i, time(), $sub)) {
            $tb .= $ten_tap[$j] . ' - ';
        }
        echo $tb;
    }
    ?>
</fieldset>
<?php 
}