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


PHP PMA_Util::pow方法代码示例

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


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

示例1: testNegativeExpGmppow

 public function testNegativeExpGmppow()
 {
     if (function_exists('gmp_pow')) {
         $this->assertEquals(
             false,
             PMA_Util::pow(2, -2, 'gmp_pow')
         );
     } else {
         $this->markTestSkipped('function gmp_pow() does not exist');
     }
 }
开发者ID:nhodges,项目名称:phpmyadmin,代码行数:11,代码来源:PMA_pow_test.php

示例2: PMA_ipMaskTest

/**
 * Based on IP Pattern Matcher
 * Originally by J.Adams <jna@retina.net>
 * Found on <http://www.php.net/manual/en/function.ip2long.php>
 * Modified for phpMyAdmin
 *
 * Matches:
 * xxx.xxx.xxx.xxx        (exact)
 * xxx.xxx.xxx.[yyy-zzz]  (range)
 * xxx.xxx.xxx.xxx/nn     (CIDR)
 *
 * Does not match:
 * xxx.xxx.xxx.xx[yyy-zzz]  (range, partial octets not supported)
 *
 * @param string $testRange string of IP range to match
 * @param string $ipToTest  string of IP to test against range
 *
 * @return boolean    always true
 *
 * @access  public
 */
function PMA_ipMaskTest($testRange, $ipToTest)
{
    $result = true;
    $match = preg_match('|([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)/([0-9]+)|', $testRange, $regs);
    if ($match) {
        // performs a mask match
        $ipl = ip2long($ipToTest);
        $rangel = ip2long($regs[1] . '.' . $regs[2] . '.' . $regs[3] . '.' . $regs[4]);
        $maskl = 0;
        for ($i = 0; $i < 31; $i++) {
            if ($i < $regs[5] - 1) {
                $maskl = $maskl + PMA_Util::pow(2, 30 - $i);
            }
            // end if
        }
        // end for
        if (($maskl & $rangel) == ($maskl & $ipl)) {
            return true;
        } else {
            return false;
        }
    } else {
        // range based
        $maskocts = explode('.', $testRange);
        $ipocts = explode('.', $ipToTest);
        // perform a range match
        for ($i = 0; $i < 4; $i++) {
            if (preg_match('|\\[([0-9]+)\\-([0-9]+)\\]|', $maskocts[$i], $regs)) {
                if ($ipocts[$i] > $regs[2] || $ipocts[$i] < $regs[1]) {
                    $result = false;
                }
                // end if
            } else {
                if ($maskocts[$i] != $ipocts[$i]) {
                    $result = false;
                }
                // end if
            }
            // end if/else
        }
        //end for
    }
    //end if/else
    return $result;
}
开发者ID:nhodges,项目名称:phpmyadmin,代码行数:66,代码来源:ip_allow_deny.lib.php

示例3: PMA_getAjaxReturnForSetVal

/**
 * Get Ajax return when $_REQUEST['type'] === 'setval'
 *
 * @param Array $variable_doc_links documentation links
 *
 * @return null
 */
function PMA_getAjaxReturnForSetVal($variable_doc_links)
{
    $response = PMA_Response::getInstance();
    $value = $_REQUEST['varValue'];
    $matches = array();
    if (isset($variable_doc_links[$_REQUEST['varName']][3]) && $variable_doc_links[$_REQUEST['varName']][3] == 'byte' && preg_match('/^\\s*(\\d+(\\.\\d+)?)\\s*(mb|kb|mib|kib|gb|gib)\\s*$/i', $value, $matches)) {
        $exp = array('kb' => 1, 'kib' => 1, 'mb' => 2, 'mib' => 2, 'gb' => 3, 'gib' => 3);
        $value = floatval($matches[1]) * PMA_Util::pow(1024, $exp[mb_strtolower($matches[3])]);
    } else {
        $value = PMA_Util::sqlAddSlashes($value);
    }
    if (!is_numeric($value)) {
        $value = "'" . $value . "'";
    }
    if (!preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName']) && $GLOBALS['dbi']->query('SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value)) {
        // Some values are rounded down etc.
        $varValue = $GLOBALS['dbi']->fetchSingleRow('SHOW GLOBAL VARIABLES WHERE Variable_name="' . PMA_Util::sqlAddSlashes($_REQUEST['varName']) . '";', 'NUM');
        $response->addJSON('variable', PMA_formatVariable($_REQUEST['varName'], $varValue[1], $variable_doc_links));
    } else {
        $response->isSuccess(false);
        $response->addJSON('error', __('Setting variable failed'));
    }
}
开发者ID:mercysmart,项目名称:naikelas,代码行数:30,代码来源:server_variables.lib.php

示例4: getPointOnSurface

 /**
  * Returns a point that is guaranteed to be on the surface of the ring.
  * (for simple closed rings)
  *
  * @param array $ring array of points forming the ring
  *
  * @return array|void a point on the surface of the ring
  * @access public
  * @static
  */
 public static function getPointOnSurface($ring)
 {
     // Find two consecutive distinct points.
     for ($i = 0, $nb = count($ring) - 1; $i < $nb; $i++) {
         if ($ring[$i]['y'] != $ring[$i + 1]['y']) {
             $x0 = $ring[$i]['x'];
             $x1 = $ring[$i + 1]['x'];
             $y0 = $ring[$i]['y'];
             $y1 = $ring[$i + 1]['y'];
             break;
         }
     }
     if (!isset($x0)) {
         return false;
     }
     // Find the mid point
     $x2 = ($x0 + $x1) / 2;
     $y2 = ($y0 + $y1) / 2;
     // Always keep $epsilon < 1 to go with the reduction logic down here
     $epsilon = 0.1;
     $denominator = sqrt(PMA_Util::pow($y1 - $y0, 2) + PMA_Util::pow($x0 - $x1, 2));
     $pointA = array();
     $pointB = array();
     while (true) {
         // Get the points on either sides of the line
         // with a distance of epsilon to the mid point
         $pointA['x'] = $x2 + $epsilon * ($y1 - $y0) / $denominator;
         $pointA['y'] = $y2 + ($pointA['x'] - $x2) * ($x0 - $x1) / ($y1 - $y0);
         $pointB['x'] = $x2 + $epsilon * ($y1 - $y0) / (0 - $denominator);
         $pointB['y'] = $y2 + ($pointB['x'] - $x2) * ($x0 - $x1) / ($y1 - $y0);
         // One of the points should be inside the polygon,
         // unless epsilon chosen is too large
         if (PMA_GIS_Polygon::isPointInsidePolygon($pointA, $ring)) {
             return $pointA;
         }
         if (PMA_GIS_Polygon::isPointInsidePolygon($pointB, $ring)) {
             return $pointB;
         }
         //If both are outside the polygon reduce the epsilon and
         //recalculate the points(reduce exponentially for faster convergence)
         $epsilon = PMA_Util::pow($epsilon, 2);
         if ($epsilon == 0) {
             return false;
         }
     }
 }
开发者ID:Sorekk,项目名称:cvillecouncilus,代码行数:56,代码来源:GIS_Polygon.class.php

示例5: ADVISOR_bytime

/**
 * Formats interval like 10 per hour
 *
 * @param integer $num       number to format
 * @param integer $precision required precision
 *
 * @return string formatted string
 */
function ADVISOR_bytime($num, $precision)
{
    if ($num >= 1) {
        // per second
        $per = __('per second');
    } elseif ($num * 60 >= 1) {
        // per minute
        $num = $num * 60;
        $per = __('per minute');
    } elseif ($num * 60 * 60 >= 1) {
        // per hour
        $num = $num * 60 * 60;
        $per = __('per hour');
    } else {
        $num = $num * 60 * 60 * 24;
        $per = __('per day');
    }
    $num = round($num, $precision);
    if ($num == 0) {
        $num = '<' . PMA_Util::pow(10, -$precision);
    }
    return "{$num} {$per}";
}
开发者ID:BIGGANI,项目名称:zpanelx,代码行数:31,代码来源:Advisor.class.php

示例6: PMA_getColumnNumberFromName

/**
 * Returns the column number based on the Excel name.
 * So "A" = 1, "Z" = 26, "AA" = 27, etc.
 *
 * Basically this is a base26 (A-Z) to base10 (0-9) conversion.
 * It iterates through all characters in the column name and
 * calculates the corresponding value, based on character value
 * (A = 1, ..., Z = 26) and position in the string.
 *
 * @param string $name column name(i.e. "A", or "BC", etc.)
 *
 * @return int The column number
 * @access  public
 */
function PMA_getColumnNumberFromName($name)
{
    if (empty($name)) {
        return 0;
    }
    $name = mb_strtoupper($name);
    $num_chars = mb_strlen($name);
    $column_number = 0;
    for ($i = 0; $i < $num_chars; ++$i) {
        // read string from back to front
        $char_pos = $num_chars - 1 - $i;
        // convert capital character to ASCII value
        // and subtract 64 to get corresponding decimal value
        // ASCII value of "A" is 65, "B" is 66, etc.
        // Decimal equivalent of "A" is 1, "B" is 2, etc.
        $number = (int) (mb_ord($name[$char_pos]) - 64);
        // base26 to base10 conversion : multiply each number
        // with corresponding value of the position, in this case
        // $i=0 : 1; $i=1 : 26; $i=2 : 676; ...
        $column_number += $number * PMA_Util::pow(26, $i);
    }
    return $column_number;
}
开发者ID:sruthikudaravalli,项目名称:QuickCabs,代码行数:37,代码来源:import.lib.php

示例7: header

 if (isset($_REQUEST['type'])) {
     if ($_REQUEST['type'] === 'getval') {
         // Send with correct charset
         header('Content-Type: text/html; charset=UTF-8');
         $varValue = PMA_DBI_fetch_single_row('SHOW GLOBAL VARIABLES WHERE Variable_name="' . PMA_Util::sqlAddSlashes($_REQUEST['varName']) . '";', 'NUM');
         if (isset($VARIABLE_DOC_LINKS[$_REQUEST['varName']][3]) && $VARIABLE_DOC_LINKS[$_REQUEST['varName']][3] == 'byte') {
             $response->addJSON('message', implode(' ', PMA_Util::formatByteDown($varValue[1], 3, 3)));
         } else {
             $response->addJSON('message', $varValue[1]);
         }
     } else {
         if ($_REQUEST['type'] === 'setval') {
             $value = $_REQUEST['varValue'];
             if (isset($VARIABLE_DOC_LINKS[$_REQUEST['varName']][3]) && $VARIABLE_DOC_LINKS[$_REQUEST['varName']][3] == 'byte' && preg_match('/^\\s*(\\d+(\\.\\d+)?)\\s*(mb|kb|mib|kib|gb|gib)\\s*$/i', $value, $matches)) {
                 $exp = array('kb' => 1, 'kib' => 1, 'mb' => 2, 'mib' => 2, 'gb' => 3, 'gib' => 3);
                 $value = floatval($matches[1]) * PMA_Util::pow(1024, $exp[strtolower($matches[3])]);
             } else {
                 $value = PMA_Util::sqlAddSlashes($value);
             }
             if (!is_numeric($value)) {
                 $value = "'" . $value . "'";
             }
             if (!preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName']) && PMA_DBI_query('SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value)) {
                 // Some values are rounded down etc.
                 $varValue = PMA_DBI_fetch_single_row('SHOW GLOBAL VARIABLES WHERE Variable_name="' . PMA_Util::sqlAddSlashes($_REQUEST['varName']) . '";', 'NUM');
                 $response->addJSON('variable', formatVariable($_REQUEST['varName'], $varValue[1]));
             } else {
                 $response->isSuccess(false);
                 $response->addJSON('error', __('Setting variable failed'));
             }
         }
开发者ID:yxwzaxns,项目名称:sakura,代码行数:31,代码来源:server_variables.php


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