/*
Constructor
@tiposMB objeto con los tipos de datos de ModBus
@endian tipo de endian del dispositivo
488662
function(tiposMB, endian, noErrores) {
    if (!(this instanceof generadorBuffer)) return new generadorBuffer(tiposMB, endian, noErrores);
    this.bytesBuffer = 0;
    this.buff = new Array;
    this.tiposMB = tiposMB;
    this.endian = endian;
    this.noErrores = noErrores;
    
    /*
     * Creación de las funciones específicas para cada tipo de dato
     */
    
    // Obtenemos un array con los tipos de datos de ModBus
    var arrTipos = new Array;
    var tipo;
    for (tipo in this.tiposMB) {
        arrTipos.push(tipo);
    }  

    // Creamos las funciones correspondientes para cada tipo de dato, de forma que conviertan los bytes del buffer en el tipo numérico adecuado
    arrTipos.forEach((function (nombreTipo) {
        generadorBuffer.prototype[nombreTipo] = function(dato) {
            return this.agregarDato(nombreTipo, dato);
        }
    }).bind(this));
    
    return true; // Devuelve algo para evitar errores en la comprobación de código
}
423465
public function createConst() {

		$properties = get_object_vars($this);

		if(isset($properties['db'])) {
			foreach($properties['db'] as $k => $v) {
				if(is_scalar($v)) {
					$k = strtoupper($k);
					if(!defined("DB$k")) { define("DB$k", $v); }
				}
			}
		}

		if(isset($properties['site'])) {
			foreach($properties['site'] as $k => $v) {
				if(is_scalar($v)) {
					$k = strtoupper($k);
					if(!defined($k)) { define($k, $v); }
				}
			}
		}

		if(isset($properties['paths'])) {
			foreach($properties['paths'] as $k => $v) {
				$k = strtoupper($k);
				if(!defined($k)) { define($k, $v['subdir']); }
			}
		}

		$locale = localeconv();

		foreach($locale as $k => $v) {
			$k = strtoupper($k);
			if(!defined($k) && !is_array($v)) { define($k, $v); }
		}
	}
259779
function() {

			var attr = Public.attributes.slice(0),
				argv = [].slice.apply(arguments),
				buffer = {},
				x = argv.length,
				y = attr.length;

			// Convertimos la matriz de argumentos a objeto

			while (x--)

				buffer[_toString(argv[x]).toLowerCase()] = 1;

			// Si se desea eliminar el atributo `hostname` o `port`

			if (buffer.hostname || buffer.port) {

				// Eliminamos el atributo `host`, ya que contiene a ambos

				buffer.host = 1;

			// Si se desea eliminar el atributo `host`

			} else if (buffer.host) {

				// Eliminamos el atributo `hostname` y `port`, ya que contiene a ambos

				buffer.hostname = 1;
				buffer.port = 1;

			}

			// Recorremos los atributos

			while (y--)

				// Si se encuentra en la lista

				if (buffer[attr[y]])

					// Lo eliminamos

					attr.splice(y, 1);

			return _prototypeSelect.apply(this, [attr]);

		}
175310
public function init()
    {
        $this->addElement((new Element\Text('url'))
            ->addValidator(new \Mmi\Validator\Regex(['/^https?:\/\/[a-z0-9\.\/]+$/', 'link nie jest poprawnym adresem HTTPS']))
            ->setDescription('form.connectorImportContentForm.url.description')
            ->setRequired()
            ->setLabel('form.connectorImportContentForm.url.label'));

        $this->addElement((new Element\Text('identity'))
            ->setLabel('form.connectorImportContentForm.identity.label')
            ->setRequired());

        $this->addElement((new Element\Password('credential'))
            ->setLabel('form.connectorImportContentForm.credential.label')
            ->setRequired());

        $this->addElement((new Element\Checkbox('acl'))
            ->setLabel('form.connectorImportContentForm.acl.label'));

        $this->addElement((new Element\Checkbox('content'))
            ->setLabel('form.connectorImportContentForm.content.label'));

        $this->addElement((new Element\Checkbox('file'))
            ->setLabel('form.connectorImportContentForm.file.label'));

        $this->addElement((new Element\Submit('submit'))
            ->setLabel('form.connectorImportContentForm.submit.label'));
    }
112270
protected function init(){
        //Carga las dependencias en base a la lista de archivos definidos en configuracion global
        $this->dependencies= array();
        foreach ($this->context->getDependenciesFile() as $nameFile) {
            $this->dependencies= array_merge($this->dependencies, $this->context->readConfigurationFile($nameFile));
        }
        //Define las dependencias que se cargan segun Type
        $this->loadDependencies= array();
        foreach ($this->dependencies as $key => $value) {
            if(isset($value['load_in'])){
                $this->loadDependencies[$key]= $value;
            }
        }
    }
348950
private function init()
    {
        $this->nb_response = new CNabuHTTPResponse($this->nb_plugins_manager, $this);

        $this->nb_site = null;
        $this->nb_site_alias = null;
        $this->nb_site_target = null;
        $this->nb_language = null;

        $this->user_remote_ip = null;
        $this->user_agent = null;
        $this->accept_mimetypes = null;
        $this->accept_languages = null;
        $this->method = null;

        $this->secure = false;
        $this->zone = null;

        $this->page_uri = null;

        $this->variables = array();

        // This block is intended for XDR IE8 & IE9 compatibility
        /*
        if (count($_POST) === 0) {
            if (isset($HTTP_RAW_POST_DATA)) {
                parse_str($HTTP_RAW_POST_DATA, $this->xdr_post);
            } else {
                parse_str(file_get_contents('php://input'), $this->xdr_post);
            }
        }
        */
    }
1143404
private function prepareDataBits()
    {
        $n              = $this->structureAppendN;
        $m              = $this->structureAppendM;
        $parity         = $this->structureAppendParity;
        $originalData   = $this->structureAppendOriginalData;

        $dataCounter   = 0;

        if ( $this->checkStructureAppend($n, $m) )
        {
            $dataValue[0]  = 3;
            $dataBits[0]   = 4;

            $dataValue[1]  = $m - 1;
            $dataBits[1]   = 4;

            $dataValue[2]  = $n - 1;
            $dataBits[2]   = 4;

            $originalDataLength = strlen($originalData);

            if ( $originalDataLength > 1 )
            {
                $parity = 0;

                $i      = 0;
                while ($i < $originalDataLength)
                {
                    $parity = ($parity ^ ord(substr($originalData, $i, 1)));
                    $i++;
                }
            }

            $dataValue[3]  = $parity;
            $dataBits[3]   = 8;

            $dataCounter   = 4;
        }

        $dataBits[$dataCounter] = 4;

        return $dataBits;
    }
563028
private function createIm() {
        $w1 = imagesx($this->image1);
        $w2 = imagesx($this->image2);
        $h1 = imagesy($this->image1);
        $h2 = imagesy($this->image2);

        if ($this->position === self::POSITION_LEFT || $this->position === self::POSITION_RIGHT) {
            $w = $w1 + $w2 + $this->space;
            $h = max($h1, $h2);
        } else {
            $w = max($w1, $w2);
            $h = $h1 + $h2 + $this->space;
        }

        $this->im = imagecreatetruecolor($w, $h);
        imagefill($this->im, 0, 0, $this->background->allocate($this->im));

        // We start defining position of images
        if ($this->position === self::POSITION_TOP) {
            if ($w1 > $w2) {
                $posX1 = 0;
                $posX2 = $this->findPosition($w1, $w2, $this->alignment);
            } else {
                $a = $this->changeAlignment($this->alignment);
                $posX1 = $this->findPosition($w1, $w2, $a);
                $posX2 = 0;
            }

            $posY2 = 0;
            $posY1 = $h2 + $this->space;
        } elseif ($this->position === self::POSITION_LEFT) {
            if ($w1 > $w2) {
                $posY1 = 0;
                $posY2 = $this->findPosition($h1, $h2, $this->alignment);
            } else {
                $a = $this->changeAlignment($this->alignment);
                $posY2 = 0;
                $posY1 = $this->findPosition($h1, $h2, $a);
            }

            $posX2 = 0;
            $posX1 = $w2 + $this->space;
        } elseif ($this->position === self::POSITION_BOTTOM) {
            if ($w1 > $w2) {
                $posX2 = $this->findPosition($w1, $w2, $this->alignment);
                $posX1 = 0;
            } else {
                $a = $this->changeAlignment($this->alignment);
                $posX2 = 0;
                $posX1 = $this->findPosition($w1, $w2, $a);
            }

            $posY1 = 0;
            $posY2 = $h1 + $this->space;
        } else { // defaults to RIGHT
            if ($w1 > $w2) {
                $posY2 = $this->findPosition($h1, $h2, $this->alignment);
                $posY1 = 0;
            } else {
                $a = $this->changeAlignment($this->alignment);
                $posY2 = 0;
                $posY1 = $this->findPosition($h1, $h2, $a);
            }

            $posX1 = 0;
            $posX2 = $w1 + $this->space;
        }

        imagecopy($this->im, $this->image1, $posX1, $posY1, 0, 0, $w1, $h1);
        imagecopy($this->im, $this->image2, $posX2, $posY2, 0, 0, $w2, $h2);
    }
27002
protected function createMsgId()
    {
        $msg = hex2bin($this->messageId);
        $chars = str_split($msg);
        $chars_val = array_map('ord', $chars);
        $pos = count($chars_val) - 1;
        while (true) {
            if ($chars_val[$pos] < 255) {
                $chars_val[$pos]++;
                break;
            } else {
                $chars_val[$pos] = 0;
                $pos--;
            }
        }
        $chars = array_map('chr', $chars_val);
        $msg = bin2hex(implode($chars));
        $this->messageId = $msg;

        return $this->messageId;
    }
1132331
function init() {
    // When code is sent to Espruino, search it for bits of assembler and then assemble them
    Espruino.addProcessor("transformForEspruino", function(code, callback) {
      findASMBlocks(code, "", callback);
    });
    // When a module is sent to Espruino...
    Espruino.addProcessor("transformModuleForEspruino", function(module, callback) {
      findASMBlocks(module.code, " in "+module.name, function(code) {
        module.code = code;
        callback(module);
      });
    });
  }
1179683
private function _initialize()
    {
        $params = $this->getParameters();
        $n = count($params);

        if ($params !== null) {
            for ($i = 0; $i < $n; $i++) {
                if ($params[$i] !== null) {
                    $name = $params[$i]->getName();
                    switch ($name) {
                        case 'begintoken':
                            $this->_beginToken = $params[$i]->getValue();
                            break;
                        case 'endtoken':
                            $this->_endToken = $params[$i]->getValue();
                            break;
                        case 'dir':
                            $this->_dir = $params[$i]->getValue();
                            break;
                        case 'prefix':
                            $this->_prefix = $params[$i]->getValue();
                            break;
                        case 'postfix':
                            $this->_postfix = $params[$i]->getValue();
                            break;
                        case 'translatehtml':
                            $this->_translatehtml = $params[$i]->getValue();
                            break;
                    }
                }
            }
        }
    }
1150704
function _make_odd()
    {
        switch (MATH_BIGINTEGER_MODE) {
            case self::MODE_GMP:
                gmp_setbit($this->value, 0);
                break;
            case self::MODE_BCMATH:
                if ($this->value[strlen($this->value) - 1] % 2 == 0) {
                    $this->value = bcadd($this->value, '1');
                }
                break;
            default:
                $this->value[0] |= 1;
        }
    }
388459
private static function _initCommon()
    {
        global $PPHP;

        self::$_req['warnings'] = array();
        self::$_req['status'] = 200;
        self::$_req['redirect'] = false;
        self::$_req['protocol'] = (self::$_req['ssl'] ? 'https' : 'http');
    }
60713
function tmp()
    {
        //$xlog = new Model\Xlog;

        //$xlog->decodeAgent();

        //Fazendo login
        //Lib\User::this()->login('admin', 'admin#123');
        //Lib\User::this()->setCriptoCookie();

        //Lib\User::this()->unsetCriptoCookie();
        $user = new Lib\User();

        $user->login('jessica', 'jessica#123');

        //$user->unsetCriptoCookie();
        //
        //
        Lib\App::p($user->get(), true);
        Lib\App::p(Lib\User::this()->get(), true);
        Lib\App::p($_SERVER['REMOTE_ADDR'], true);
        Lib\App::p($_SERVER['HTTP_USER_AGENT'], true);
        Lib\App::p($_SERVER['HTTP_ACCEPT_LANGUAGE'], true);

        echo "<br>OS: </b>".$this->operating_system_detection();

        echo '<hr/>';

        $jsonBrowser = json_encode(get_browser());

        echo '<br><b>Tamanho do arquivo: </b>'.strlen($jsonBrowser).'<br>';
        Lib\App::p(json_decode($jsonBrowser), true);


        //Fazendo login
        //Lib\User::this()->login('jessica', 'jessica#123');
        //Lib\User::this()->setCriptoCookie();

        //Lib\App::p(Lib\User::this()->get(), true);

        echo "<hr/><b>Finished!</b>";
    }
617454
function createGeo() {
    $cnt = count( $this->geo );
    if( 0 >= $cnt )
      return;
    $attributes = $this->_createParams( $this->geo['params'] );
    $content    = null;
    $content   .= number_format( (float) $this->geo['value']['latitude'], 6, '.', '');
    $content   .= ';';
    $content   .= number_format( (float) $this->geo['value']['longitude'], 6, '.', '');
    return $this->_createElement( 'GEO', $attributes, $content );
  }
164826
private function _buildMbinfo()
    {
        $mbinfo = $this->_xml->addChild('MBInfo');
        $temp = $fan = $volt = $power = $current = $other = null;

        if (sizeof(unserialize(PSI_MBINFO))>0) {
            foreach (unserialize(PSI_MBINFO) as $mbinfoclass) {
                $mbinfo_data = new $mbinfoclass();
                $mbinfo_detail = $mbinfo_data->getMBInfo();

                if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='temperature') foreach ($mbinfo_detail->getMbTemp() as $dev) {
                    if ($temp == null) {
                        $temp = $mbinfo->addChild('Temperature');
                    }
                    $item = $temp->addChild('Item');
                    $item->addAttribute('Label', $dev->getName());
                    $item->addAttribute('Value', $dev->getValue());
                    if ($dev->getMax() !== null) {
                        $item->addAttribute('Max', $dev->getMax());
                    }
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
                        $item->addAttribute('Event', $dev->getEvent());
                    }
                }

                if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='fans') foreach ($mbinfo_detail->getMbFan() as $dev) {
                    if ($fan == null) {
                        $fan = $mbinfo->addChild('Fans');
                    }
                    $item = $fan->addChild('Item');
                    $item->addAttribute('Label', $dev->getName());
                    $item->addAttribute('Value', $dev->getValue());
                    if ($dev->getMin() !== null) {
                        $item->addAttribute('Min', $dev->getMin());
                    }
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
                        $item->addAttribute('Event', $dev->getEvent());
                    }
                }

                if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='voltage') foreach ($mbinfo_detail->getMbVolt() as $dev) {
                    if ($volt == null) {
                        $volt = $mbinfo->addChild('Voltage');
                    }
                    $item = $volt->addChild('Item');
                    $item->addAttribute('Label', $dev->getName());
                    $item->addAttribute('Value', $dev->getValue());
                    if ($dev->getMin() !== null) {
                        $item->addAttribute('Min', $dev->getMin());
                    }
                    if ($dev->getMax() !== null) {
                        $item->addAttribute('Max', $dev->getMax());
                    }
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
                        $item->addAttribute('Event', $dev->getEvent());
                    }
                }

                if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='power') foreach ($mbinfo_detail->getMbPower() as $dev) {
                    if ($power == null) {
                        $power = $mbinfo->addChild('Power');
                    }
                    $item = $power->addChild('Item');
                    $item->addAttribute('Label', $dev->getName());
                    $item->addAttribute('Value', $dev->getValue());
                    if ($dev->getMax() !== null) {
                        $item->addAttribute('Max', $dev->getMax());
                    }
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
                        $item->addAttribute('Event', $dev->getEvent());
                    }
                }

                if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='current') foreach ($mbinfo_detail->getMbCurrent() as $dev) {
                    if ($current == null) {
                        $current = $mbinfo->addChild('Current');
                    }
                    $item = $current->addChild('Item');
                    $item->addAttribute('Label', $dev->getName());
                    $item->addAttribute('Value', $dev->getValue());
                    if ($dev->getMin() !== null) {
                        $item->addAttribute('Min', $dev->getMin());
                    }
                    if ($dev->getMax() !== null) {
                        $item->addAttribute('Max', $dev->getMax());
                    }
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
                        $item->addAttribute('Event', $dev->getEvent());
                    }
                }

                if (!$this->_sysinfo->getBlockName() || $this->_sysinfo->getBlockName()==='other') foreach ($mbinfo_detail->getMbOther() as $dev) {
                    if ($other == null) {
                        $other = $mbinfo->addChild('Other');
                    }
                    $item = $other->addChild('Item');
                    $item->addAttribute('Label', $dev->getName());
                    $item->addAttribute('Value', $dev->getValue());
                    if (defined('PSI_SENSOR_EVENTS') && PSI_SENSOR_EVENTS && $dev->getEvent() !== "") {
                        $item->addAttribute('Event', $dev->getEvent());
                    }
                }
            }
        }
    }
310724
function initSymbols() {
  var i;
  var symlen = AMsymbols.length;
  for (i=0; i<symlen; i++) {
    if (AMsymbols[i].tex) {
      AMsymbols.push({input:AMsymbols[i].tex, 
        tag:AMsymbols[i].tag, output:AMsymbols[i].output, ttype:AMsymbols[i].ttype,
        acc:(AMsymbols[i].acc||false)});
    }
  }
  refreshSymbols();
}