function add($ip, &$errors) { global $cfg; $passphrase = $cfg->getAPIPassphrase(); if (!$passphrase) { $errors['err'] = 'API passphrase missing.'; } if (!$ip || !Validator::is_ip($ip)) { $errors['ip'] = 'Valid IP required'; } elseif (Api::getKey($ip)) { $errors['ip'] = 'API key for the IP already exists'; } $id = 0; if (!$errors) { $sql = 'INSERT INTO ' . API_KEY_TABLE . ' SET created=NOW(), updated=NOW(), isactive=1' . ',ipaddr=' . db_input($ip) . ',apikey=' . db_input(strtoupper(md5($ip . md5($passphrase)))); //Security of the apikey is not as critical at the moment if (db_query($sql)) { $id = db_insert_id(); } } return $id; }
function add($ip, &$errors) { global $cfg; $passphrase = $cfg->getAPIPassphrase(); if (!$passphrase) { $errors['err'] = 'Senha API faltando.'; } if (!$ip || !Validator::is_ip($ip)) { $errors['ip'] = 'IP válido obrigatório'; } elseif (Api::getKey($ip)) { $errors['ip'] = 'Chave API para o IP já existe'; } $id = 0; if (!$errors) { $sql = 'INSERT INTO ' . API_KEY_TABLE . ' SET created=NOW(), updated=NOW(), isactive=1' . ',ipaddr=' . db_input($ip) . ',apikey=' . db_input(strtoupper(md5($ip . md5($passphrase)))); //Security of the apikey is not as critical at the moment if (db_query($sql)) { $id = db_insert_id(); } } return $id; }
function add($ip, &$errors) { global $cfg; $passphrase = $cfg->getAPIPassphrase(); if (!$passphrase) { $errors['err'] = 'Falta la frase secreta de la API.'; } if (!$ip || !Validator::is_ip($ip)) { $errors['ip'] = 'Se requiere una IP válida'; } elseif (Api::getKey($ip)) { $errors['ip'] = 'Clave API para esta IP ya existe'; } $id = 0; if (!$errors) { $sql = 'INSERT INTO ' . API_KEY_TABLE . ' SET created=NOW(), updated=NOW(), isactive=1' . ',ipaddr=' . db_input($ip) . ',apikey=' . db_input(strtoupper(md5($ip . md5($passphrase)))); //Security of the apikey is not as critical at the moment if (db_query($sql)) { $id = db_insert_id(); } } return $id; }