}
if (!gs_get_conf('GS_GRANDSTREAM_PROV_ENABLED')) {
    gs_log(GS_LOG_DEBUG, "Grandstream provisioning not enabled");
    _settings_err('Not enabled.');
}
$requester = gs_prov_check_trust_requester();
if (!$requester['allowed']) {
    _settings_err('No! See log for details.');
}
$mac = preg_replace('/[^0-9A-F]/', '', strToUpper(@$_REQUEST['mac']));
if (strLen($mac) !== 12) {
    gs_log(GS_LOG_NOTICE, "Grandstream provisioning: Invalid MAC address \"{$mac}\" (wrong length)");
    # don't explain this to the users
    _settings_err('No! See log for details.');
}
if (hexDec(subStr($mac, 0, 2)) % 2 == 1) {
    gs_log(GS_LOG_NOTICE, "Grandstream provisioning: Invalid MAC address \"{$mac}\" (multicast address)");
    # don't explain this to the users
    _settings_err('No! See log for details.');
}
if ($mac === '000000000000') {
    gs_log(GS_LOG_NOTICE, "Grandstream provisioning: Invalid MAC address \"{$mac}\" (huh?)");
    # don't explain this to the users
    _settings_err('No! See log for details.');
}
# make sure the phone is a Grandstream:
#
if (subStr($mac, 0, 6) !== '000B82') {
    gs_log(GS_LOG_NOTICE, "Grandstream provisioning: MAC address \"{$mac}\" is not a Grandstream phone");
    # don't explain this to the users
    _settings_err('No! See log for details.');
Example #2
0
 /**
  * Sets the colour, using one of the following formats: '#FFFFFF', '#fff',
  * 'rgb(255, 255, 255)', [$r, $g, $b] or ARGB
  * ({@link http://en.wikipedia.org/wiki/ARGB#ARGB}).
  * @param array|int|string $color
  */
 public function setColor($color)
 {
     switch (getType($color)) {
         case 'array':
             $this->r = $color[0];
             $this->g = $color[1];
             $this->b = $color[2];
             break;
         case 'integer':
             // ARGB format
             $this->r = $color >> 16 & 0xff;
             $this->g = $color >> 8 & 0xff;
             $this->b = $color & 0xff;
             break;
         case 'string':
             $length = strLen($color);
             if ($length == 7) {
                 // e.g. '#FFFFFF'.
                 $this->r = hexDec(subStr($color, 1, 2));
                 $this->g = hexDec(subStr($color, 3, 2));
                 $this->b = hexDec(subStr($color, 5, 2));
             } else {
                 if ($length == 4) {
                     // e.g. '#FFF'.
                     $this->r = hexDec(subStr($color, 1, 1)) * 17;
                     $this->g = hexDec(subStr($color, 2, 1)) * 17;
                     $this->b = hexDec(subStr($color, 3, 1)) * 17;
                 } else {
                     if (strToLower(subStr($color, 0, 4)) == 'rgb(') {
                         // e.g. 'rgb(255, 255, 255)'.
                         $listOfColors = subStr($color, 4, -1);
                         $arrayOfColors = explode(',', $listOfColors);
                         $this->r = intVal($arrayOfColors[0]);
                         $this->g = intVal($arrayOfColors[1]);
                         $this->b = intVal($arrayOfColors[2]);
                     }
                 }
             }
             break;
     }
 }
Example #3
0
function hexUnicodeToUtf8($hexcp)
{
    return @codepointToUtf8(@hexDec($hexcp));
}
 /**
  * public function tagImage
  * USED
  */
 public function tagImage($type, $position, $state, $file, $text, $font, $fontSize, $startX = null, $startY = null, $textColorRGB = 'variation')
 {
     $this->debug('function : ' . __FUNCTION__, 2, __LINE__);
     $addReflect = false;
     $site = $this->linker->site;
     $templateFolder = $site->templateFolder;
     // Gets the font and its params
     if (strpos($font, SH_FONTS_FOLDER) === false) {
         $font = str_replace(SH_FONTS_PATH, SH_FONTS_FOLDER, $font);
     }
     $fontParamsFile = substr($font, 0, -3) . 'php';
     if (!file_exists($font) || !file_exists($fontParamsFile)) {
         return false;
     }
     include $fontParamsFile;
     // Inserts a variable called $boxes
     foreach ($boxes as $textHeight => $box) {
         if ($box['fontSize'] == $fontSize) {
             break;
         }
     }
     if ($textColorRGB == 'variation') {
         $variation = $site->variation;
         if ($state == 'active') {
             $textColorRGB = str_replace('#', '', $this->linker->variation->get('buttonTextActive|buttonText', '999999'));
         } elseif ($state == 'selected') {
             $textColorRGB = str_replace('#', '', $this->linker->variation->get('buttonTextSelected|buttonText', '999999'));
         } else {
             $textColorRGB = str_replace('#', '', $this->linker->variation->get('buttonText', '999999'));
         }
     }
     // text color
     list($r, $g, $b) = str_split($textColorRGB, 2);
     $color['R'] = hexDec($r);
     $color['G'] = hexDec($g);
     $color['B'] = hexDec($b);
     // Gets the un-tagged image, and prepares it
     $srcImage = imagecreatefrompng($file);
     imagesavealpha($srcImage, true);
     $width = imagesX($srcImage);
     $height = imagesY($srcImage);
     $newImage = imageCreateTrueColor($width, $height);
     imagesavealpha($newImage, true);
     $textColor = imagecolorallocate($newImage, $color['R'], $color['G'], $color['B']);
     $transparentColor = imagecolorallocatealpha($newImage, 0, 0, 0, 127);
     imagefill($newImage, 0, 0, $transparentColor);
     imagecopy($newImage, $srcImage, 0, 0, 0, 0, $width, $height);
     // Free the space
     imagedestroy($srcImage);
     imagecolortransparent($newImage, $transparentColor);
     if ($startX == null || strtoupper($startX) == 'NULL') {
         if (file_exists($this->builderFolder . $type . '/model/' . $position . '.php')) {
             include $this->builderFolder . $type . '/model/' . $position . '.php';
             $textBox = imagettfbbox($fontSize, 0, $font, $text);
             $startX = $image['startLeft'] + $box['left'];
             $startY = $image['startTop'] + $box['top'];
         }
     }
     /*
            if($addReflect == true){
                $reflect = imagecreatetruecolor($width,$textHeight / 2);
                $textColor2 = imagecolorallocate(
                    $reflect,
                    $color['R'],
                    $color['G'],
                    $color['B']
                );
                $transparentColor2 = imagecolorallocatealpha(
                    $reflect,
                    $transparentColorRGB['R'],
                    $transparentColorRGB['G'],
                    $transparentColorRGB['B'],
                    127
                );
                imagefill($reflect,0,0,$transparentColor2);
                imagecolortransparent($reflect, $transparentColor2);
     
                // writes the text
                imagettftext(
                    $reflect,
                    $fontSize,
                    0,
                    $startX,
                    $image['startTop'],
                    $textColor2,
                    $font,
                    $text
                );
                $cpt = 0;
                $open = false;
                // Gets the pixels that are colored in the first line
                for($a = 1; $a<$width + 1;$a++){
                    for($b = 1; $b<($textHeight / 2) - 1;$b++){
                        $color = imagecolorat($reflect, $a, $b);
                        $colorrgb = imagecolorsforindex($reflect,$color);
     
                        if($colorrgb['alpha'] < 67){
                            $trans = $colorrgb['alpha'] + 127 - ($b / ($textHeight / 2)) * 67;
                            if($trans<127){
                                $tempColor = imagecolorallocatealpha($newImage,
                                    $colorrgb['red'],
                                    $colorrgb['green'],
                                    $colorrgb['blue'],
                                    $trans
                                );
                                imagesetpixel(
                                    $newImage,
                                    $a,
                                    $startY + ($textHeight / 2) - $b,
                                    $tempColor
                                );
                            }
                        }
                    }
                }
                imageDestroy($reflect);
            }
     *
     */
     // writes the text
     imagettftext($newImage, $fontSize, 0, $startX, $startY, $textColor, $font, $text);
     imagepng($newImage, $file);
     imageDestroy($newImage);
     return true;
 }