コード例 #1
0
ファイル: ConversionTest.php プロジェクト: rmasters/units
 public function testIntegerModifier()
 {
     $conversion = new Conversion($this->from, $this->to, 1000);
     $this->assertEquals($this->from, $conversion->from());
     $this->assertEquals($this->to, $conversion->to());
     $this->assertEquals(5000, $conversion->convert(5));
 }
コード例 #2
0
 public static function GetEncoding($list)
 {
     $pattern = '0';
     $multiplier = 1;
     foreach ($list as $member) {
         $pattern = Conversion::BinaryMultiply($pattern, Conversion::Binary($multiplier));
         //echo $pattern.'<br>';
         $pattern = Conversion::BinaryAdd($pattern, Conversion::Binary($member[1]));
         $multiplier = $member[0];
     }
     return $pattern;
 }
コード例 #3
0
ファイル: base64.php プロジェクト: guille-phillips/phpmisc
 public static function Decode($base64)
 {
     $binary_digits = '';
     $alignment = strpos(self::$symbols, substr($base64, 0, 1));
     if ($alignment === false) {
         return false;
     }
     if ($alignment > 0) {
         $alignment = 6 - $alignment;
     }
     $length = strlen($base64);
     for ($symbol_pos = 1; $symbol_pos < $length; $symbol_pos++) {
         $value = strpos(self::$symbols, substr($base64, $symbol_pos, 1));
         if ($value === false) {
             return false;
         } else {
             $binary_digits .= Conversion::Binary($value, 6);
         }
     }
     return substr($binary_digits, 0, strlen($binary_digits) - $alignment);
 }
コード例 #4
0
ファイル: video_scheduler.php プロジェクト: ph3l1x/mydea
        echo "Unable to locate Drupal root, user -r option to specify path to Drupal root\n";
        exit(1);
    }
    chdir($path);
}
if (isset($args['s']) || isset($args['site'])) {
    $site = isset($args['s']) ? $args['s'] : $args['site'];
    if (file_exists('./sites/' . $site)) {
        $_SERVER['HTTP_HOST'] = $site;
    } else {
        echo "ERROR: Unable to locate site {$site}\n";
        exit(1);
    }
} else {
    if (preg_match('/' . preg_quote($path . '/sites/', '/') . '(.*?)\\//i', $cwd, $matches)) {
        if ($matches[1] != 'all' && file_exists('./sites/' . $matches[1])) {
            $_SERVER['HTTP_HOST'] = $matches[1];
        }
    }
}
define('DRUPAL_ROOT', realpath(getcwd()));
ini_set('display_errors', 0);
include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
ini_set('display_errors', 1);
// turn off the output buffering that drupal is doing by default.
ob_end_flush();
//include our conversion class (also contains our defines)
module_load_include('inc', 'video', 'includes/Conversion');
$video_conversion = new Conversion();
$video_conversion->runQueue();
コード例 #5
0
 public function testGetBitFlipCount()
 {
     $this->assertEquals(2, Conversion::getBitFlipCount(29, 15));
 }
コード例 #6
0
ファイル: commission.php プロジェクト: vNative/vnative
 /**
  * Gets the Rate based on the type of record i.e 'publisher', or 'advertiser'
  * @param  array  $commissions Array of Commissions to search for ad_id
  * @param  String $type        Advertiser | Publisher
  * @return array
  */
 public static function campaignRate($adid, &$commissions = [], $country = null, $extra = [])
 {
     $commFetched = $extra['commFetched'] ?? false;
     if ($commFetched) {
         $comm = $commissions;
     } else {
         $comm = self::find($commissions, $adid);
     }
     $info = ['campaign' => 'cpc', 'rate' => 0, 'revenue' => 0, 'type' => $extra['type']];
     if (!is_array($comm)) {
         return $info;
     }
     $commission = array_key_exists($country, $comm) ? $comm[$country] : @$comm['ALL'];
     // because commission might not exists if country is null
     if (!is_object($commission)) {
         return $info;
     }
     $query = ['adid' => $adid, 'created' => Db::dateQuery($extra['start'], $extra['end'])];
     switch ($extra['type']) {
         case 'advertiser':
             $info['revenue'] = (double) $commission->revenue;
             break;
         case 'publisher':
             $info['rate'] = self::getPubRate($commission, $extra);
             $query['pid'] = $extra['publisher']->_id ?? null;
             break;
         case 'both':
             $info['revenue'] = (double) $commission->revenue;
             $info['rate'] = self::getPubRate($commission, $extra);
             if (isset($extra['publisher'])) {
                 $query['pid'] = $extra['publisher']->_id;
             }
             break;
     }
     switch (strtolower($commission->model)) {
         case 'cpa':
         case 'cpi':
             $count = \Conversion::count($query);
             $info['conversions'] = $count;
             break;
         case 'cpm':
             $info['impressions'] = \Impression::getStats($query);
             break;
     }
     $info['campaign'] = strtolower($commission->model);
     return $info;
 }
コード例 #7
0
ファイル: french.php プロジェクト: rali-udem/JSrealB
<?php

ini_set('max_execution_time', 90);
ob_start();
header('Content-Type: text/html; charset=utf-8');
/*** error reporting ***/
error_reporting(-1);
ini_set('display_errors', 'On');
/*** error reporting ***/
define('REAL_PATH_ROOT', realpath('./') . '/');
require_once REAL_PATH_ROOT . 'autoloader.php';
try {
    $oJSRealService = new JSRealFrService("fr");
    $aExportedFile = $oJSRealService->export();
    $sOutput = Conversion::getJsonFromArray(array_merge(array('bSuccess' => true), $aExportedFile));
} catch (Exception $ex) {
    $sOutput = Conversion::getJsonFromArray(array('bSuccess' => false, 'sErrorMessage' => $e->getMessage(), 'iErrorCode' => $e->getCode()));
}
//ob_end_clean();
echo $sOutput;
コード例 #8
0
ファイル: debug.php プロジェクト: BillTheBest/1.6.x
/**
 * This function is used to covert all constants of restriction into a human readable strings
 */
function simplify_restriction($restriction)
{
    if (!is_array($restriction)) {
        return $restriction;
    }
    switch ($restriction[0]) {
        case RES_AND:
            $restriction[0] = "RES_AND";
            if (isset($restriction[1][0]) && is_array($restriction[1][0])) {
                foreach (array_keys($restriction[1]) as $key) {
                    $restriction[1][$key] = simplify_restriction($restriction[1][$key]);
                }
            } else {
                if (isset($restriction[1]) && $restriction[1]) {
                    $restriction[1] = simplify_restriction($restriction[1]);
                }
            }
            break;
        case RES_OR:
            $restriction[0] = "RES_OR";
            if (isset($restriction[1][0]) && is_array($restriction[1][0])) {
                foreach (array_keys($restriction[1]) as $key) {
                    $restriction[1][$key] = simplify_restriction($restriction[1][$key]);
                }
            } else {
                if (isset($restriction[1]) && $restriction[1]) {
                    $restriction[1] = simplify_restriction($restriction[1]);
                }
            }
            break;
        case RES_NOT:
            $restriction[0] = "RES_NOT";
            $restriction[1][0] = simplify_restriction($restriction[1][0]);
            break;
        case RES_COMMENT:
            $restriction[0] = "RES_COMMENT";
            $res = simplify_restriction($restriction[1][RESTRICTION]);
            $props = $restriction[1][PROPS];
            foreach (array_keys($props) as $key) {
                $propTag = $props[$key][ULPROPTAG];
                $propValue = $props[$key][VALUE];
                unset($props[$key]);
                $props[$key]["ULPROPTAG"] = is_string($propTag) ? $propTag : Conversion::getPropertyName($propTag);
                $props[$key]["VALUE"] = is_array($propValue) ? $propValue[$propTag] : $propValue;
            }
            unset($restriction[1]);
            $restriction[1]["RESTRICTION"] = $res;
            $restriction[1]["PROPS"] = $props;
            break;
        case RES_PROPERTY:
            $restriction[0] = "RES_PROPERTY";
            $propTag = $restriction[1][ULPROPTAG];
            $propValue = $restriction[1][VALUE];
            $relOp = $restriction[1][RELOP];
            unset($restriction[1]);
            // relop flags
            $relOpFlags = "";
            if ($relOp == RELOP_LT) {
                $relOpFlags = "RELOP_LT";
            } else {
                if ($relOp == RELOP_LE) {
                    $relOpFlags = "RELOP_LE";
                } else {
                    if ($relOp == RELOP_GT) {
                        $relOpFlags = "RELOP_GT";
                    } else {
                        if ($relOp == RELOP_GE) {
                            $relOpFlags = "RELOP_GE";
                        } else {
                            if ($relOp == RELOP_EQ) {
                                $relOpFlags = "RELOP_EQ";
                            } else {
                                if ($relOp == RELOP_NE) {
                                    $relOpFlags = "RELOP_NE";
                                } else {
                                    if ($relOp == RELOP_RE) {
                                        $relOpFlags = "RELOP_RE";
                                    }
                                }
                            }
                        }
                    }
                }
            }
            $restriction[1]["RELOP"] = $relOpFlags;
            $restriction[1]["ULPROPTAG"] = is_string($propTag) ? $propTag : Conversion::getPropertyName($propTag);
            $restriction[1]["VALUE"] = is_array($propValue) ? $propValue[$propTag] : $propValue;
            break;
        case RES_CONTENT:
            $restriction[0] = "RES_CONTENT";
            $propTag = $restriction[1][ULPROPTAG];
            $propValue = $restriction[1][VALUE];
            $fuzzyLevel = $restriction[1][FUZZYLEVEL];
            unset($restriction[1]);
            // fuzzy level flags
            $fuzzyLevelFlags = Conversion::fuzzylevelToString($fuzzyLevel);
            $restriction[1]["FUZZYLEVEL"] = $fuzzyLevelFlags;
            $restriction[1]["ULPROPTAG"] = is_string($propTag) ? $propTag : Conversion::getPropertyName($propTag);
            $restriction[1]["VALUE"] = is_array($propValue) ? $propValue[$propTag] : $propValue;
            break;
        case RES_COMPAREPROPS:
            $propTag1 = $restriction[1][ULPROPTAG1];
            $propTag2 = $restriction[1][ULPROPTAG2];
            unset($restriction[1]);
            $restriction[1]["ULPROPTAG1"] = is_string($propTag1) ? $proptag1 : Conversion::getPropertyName($proptag1);
            $restriction[1]["ULPROPTAG2"] = is_string($propTag2) ? $propTag2 : Conversion::getPropertyName($propTag2);
            break;
        case RES_BITMASK:
            $restriction[0] = "RES_BITMASK";
            $propTag = $restriction[1][ULPROPTAG];
            $maskType = $restriction[1][ULTYPE];
            $maskValue = $restriction[1][ULMASK];
            unset($restriction[1]);
            // relop flags
            $maskTypeFlags = "";
            if ($maskType == BMR_EQZ) {
                $maskTypeFlags = "BMR_EQZ";
            } else {
                if ($maskType == BMR_NEZ) {
                    $maskTypeFlags = "BMR_NEZ";
                }
            }
            $restriction[1]["ULPROPTAG"] = is_string($propTag) ? $propTag : Conversion::getPropertyName($propTag);
            $restriction[1]["ULTYPE"] = $maskTypeFlags;
            $restriction[1]["ULMASK"] = $maskValue;
            break;
        case RES_SIZE:
            $restriction[0] = "RES_SIZE";
            $propTag = $restriction[1][ULPROPTAG];
            $propValue = $restriction[1][CB];
            $relOp = $restriction[1][RELOP];
            unset($restriction[1]);
            // relop flags
            $relOpFlags = "";
            if ($relOp == RELOP_LT) {
                $relOpFlags = "RELOP_LT";
            } else {
                if ($relOp == RELOP_LE) {
                    $relOpFlags = "RELOP_LE";
                } else {
                    if ($relOp == RELOP_GT) {
                        $relOpFlags = "RELOP_GT";
                    } else {
                        if ($relOp == RELOP_GE) {
                            $relOpFlags = "RELOP_GE";
                        } else {
                            if ($relOp == RELOP_EQ) {
                                $relOpFlags = "RELOP_EQ";
                            } else {
                                if ($relOp == RELOP_NE) {
                                    $relOpFlags = "RELOP_NE";
                                } else {
                                    if ($relOp == RELOP_RE) {
                                        $relOpFlags = "RELOP_RE";
                                    }
                                }
                            }
                        }
                    }
                }
            }
            $restriction[1]["ULPROPTAG"] = is_string($propTag) ? $propTag : Conversion::getPropertyName($propTag);
            $restriction[1]["RELOP"] = $relOpFlags;
            $restriction[1]["CB"] = $propValue;
            break;
        case RES_EXIST:
            $propTag = $restriction[1][ULPROPTAG];
            unset($restriction[1]);
            $restriction[1]["ULPROPTAG"] = is_string($propTag) ? $propTag : Conversion::getPropertyName($propTag);
            break;
        case RES_SUBRESTRICTION:
            $propTag = $restriction[1][ULPROPTAG];
            $res = simplify_restriction($restriction[1][RESTRICTION]);
            unset($restriction[1]);
            $restriction[1]["ULPROPTAG"] = is_string($propTag) ? $propTag : Conversion::getPropertyName($propTag);
            $restriction[1]["RESTRICTION"] = $res;
            break;
    }
    return $restriction;
}
コード例 #9
0
ファイル: JSRealFrService.php プロジェクト: rali-udem/JSrealB
 protected function applyLexiconPatchToTestVerb(array &$aTestConjugatedVerb)
 {
     $aTenseList = array('p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'ps1', 'ps2', 'ps3', 'ps4', 'ps5', 'ps6', 's1', 's2', 's3', 's4', 's5', 's6', 'ip2', 'ip4', 'ip5', 'pr', 'pp');
     $sPatchFile = Config::get('path.real.root') . Config::get('path.relative.root_to_app') . Config::get('path.relative.app_to_data') . Config::get('jsreal.lexicon.simple_nlg.patch.' . $this->sLanguage);
     $sJsonPatch = Filesystem::get($sPatchFile);
     $aPatch = Conversion::getArrayFromJson($sJsonPatch);
     foreach ($aPatch as $sUnit => $aInfo) {
         if (isset($aInfo['V'])) {
             foreach ($aInfo['V'] as $sTenseAndPerson => $sConjugatedVerb) {
                 if (Arr::in($aTenseList, $sTenseAndPerson)) {
                     $aTestConjugatedVerb[$sUnit][$sTenseAndPerson] = $sConjugatedVerb;
                 }
             }
         }
     }
 }
コード例 #10
0
ファイル: ConversionTest.php プロジェクト: seytar/psx
 public function testConversionSeconds()
 {
     $this->assertEquals('1 s', Conversion::seconds(1));
     $this->assertEquals('6 ms', Conversion::seconds(0.006));
 }
コード例 #11
0
ファイル: DmFormatter.php プロジェクト: rali-udem/JSrealB
 public function getRuleTable($sRuleOptionName = 'option')
 {
     $aFormatedRule = array();
     foreach ($this->aRawRuleList as $aRawRule) {
         $sTableId = $aRawRule[0];
         $sEnding = $aRawRule[1];
         $aDeclensionList = array();
         $sPreviousOption = '';
         $sCurrentOption = '';
         for ($i = 2, $iLength1 = count($aRawRule); $i < $iLength1; $i++) {
             $sValue = $aRawRule[$i][0];
             $aOptionList = array('val' => $sValue);
             $sCurrentOption = Conversion::getJsonFromArray($aOptionList);
             for ($j = 1, $iLength2 = count($aRawRule[$i]); $j < $iLength2; $j++) {
                 $sInformation = $aRawRule[$i][$j];
                 $sFeatureClass = $this->oDmConverter->getClassName($sInformation);
                 if (!is_null($sFeatureClass) && !empty($sFeatureClass)) {
                     $sFeatureValue = $this->oDmConverter->getProperName($sInformation);
                     $aOptionList[$sFeatureClass] = $sFeatureValue;
                     $sCurrentOption .= $sFeatureClass . $sFeatureValue;
                 } else {
                     echo 'Traduction manquante : ';
                     // DEBUG ONLY
                     var_dump($sInformation);
                     echo '<br />';
                     //                        die;
                 }
             }
             if ($sPreviousOption !== $sCurrentOption) {
                 $aDeclensionList[] = $aOptionList;
                 $sPreviousOption = $sCurrentOption;
             }
         }
         $aFormatedRule[$sTableId] = array('ending' => $sEnding, $sRuleOptionName => $aDeclensionList);
     }
     return $aFormatedRule;
 }
コード例 #12
0
ファイル: JSRealService.php プロジェクト: rali-udem/JSrealB
 private function exportToJson($sJsonFilePath, array $aData, $bCompress = false)
 {
     $sNewJsonContent = Conversion::getJsonFromArray($aData, $bCompress);
     if (Filesystem::put($sJsonFilePath, $sNewJsonContent) !== false) {
         return Filesystem::name($sJsonFilePath) . '.' . Filesystem::extension($sJsonFilePath);
     } else {
         throw new FileNotCreatedException('File : ' . $sJsonFilePath);
     }
 }