Laravel 5.3 cannot access PrimeryKey object - laravel-5.3

Laravel 5.3. I get a wrong value for primaryKey of a table (users table) although i get it properly. It is very strange. Here is my code
protected $table = 'users_tbl';
protected $primaryKey = "email";
The Controller:
$user = User::find('alaile#hotmail.com');
dd($user);
#table: "users_tbl"
#primaryKey: "email"
#fillable: array:8 [▶]
#hidden: array:2 [▶]
#connection: null
#keyType: "int"
#perPage: 15
+incrementing: true
+timestamps: true
#attributes: array:15 [▼
"email" => "alaile#hotmail.com"
"register" => "1892"
"section" => "GO"
"turn" => 92
...
output the email properly but when I access through the object get 0. However the rest of attributes are ok:
echo $user->email;
echo "<br>";
echo $user->register;
echo "<br>";
echo $user->section;
echo "<br>";
echo $user->turn;
echo "<br>";
exit;
output
0
1892
GO
92
Any ideas whats going on?

I believe you forgot to set the increments to false for laravel to not look for an auto incremented id.
This is something that happen to me before and drove me crazy!!
On your User.php model add this line:
public $incrementing = false;

Related

PHP Warning: Use of undefined constant exportMeta - assumed 'exportMeta' log error

I have a product listing system using ORM framework and it's not working because I changed servers. The reason it doesn't work is that it doesn't list new products when I enter them. I'm posting the LOG output below.
I was using Mysql 5.7 and Centos on the previous server. The new server was almalinux and Mysql 8. I think it's caused by this.
PHP Warning: Use of undefined constant exportMeta - assumed 'exportMeta' (this will throw an Error in a future version of PHP) in /home/siteadi/public_html/orm/addJsonTable.php on line 24
PHP Warning: Use of undefined constant exportTerms - assumed 'exportTerms' (this will throw an Error in a future version of PHP) in /home/siteadi/public_html/orm/addJsonTable.php on line 25
PHP Warning: Use of undefined constant exportMedia - assumed 'exportMedia' (this will throw an Error in a future version of PHP) in /home/siteadi/public_html/orm/addJsonTable.php on line 26
PHP Warning: PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'set primary_image = concat('/wp-content/uploads/', primary_image) where (primary' at line 1 in /home/siteadi/public_html/orm/idiorm.php on line 505
"addJsonTable.php" file below;
<?php
//ini_set('error_reporting', E_ALL);
ini_set('display_errors', false);
set_time_limit(0);
header("Access-Control-Allow-Origin: http://127.0.0.1:8887");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
header("Access-Control-Allow-Credentials: true");
header('Content-Type: application/json');
require_once "idiorm.php";
require_once "methods.php";
initDB();
$ID = isset($_GET['id']) ? $_GET['id'] : 0;
if ($ID) {
$hasItem = ORM::for_table('json_table')->where('ID', $ID)->find_one();
if ($hasItem) {
ORM::raw_execute("delete from json_table where ID = $ID");
}
$phone = ORM::for_table('exportview')->where('ID', $ID)->find_array();
$phone = array_map(exportMeta, $phone);
$phone = array_map(exportTerms, $phone);
$phone = array_map(exportMedia, $phone);
foreach ($phone as $ikey => $item) {
$phone[$ikey]['media'] = $item['media_ids'] ? array_map(exportMeta, $item['media']) : [];
$phone[$ikey]['media'] = $item['media_ids'] ? array_combine(array_column($phone[$ikey]['media'], 'ID'), array_column($phone[$ikey]['media'], 'guid')) : [];
$phone[$ikey]['insert_time'] = strtotime($item['post_date_gmt']);
$phone[$ikey]['image'] = $item['meta']['resim_url'] ?: $phone[$ikey]['media'][$item['meta']['_thumbnail_id']] ?: null;
$phone[$ikey]['primary_image'] = $phone[$ikey]['media'][$item['meta']['_thumbnail_id']] ?: null;
}
foreach ($phone as $key => $item) {
if ($key < 1000000) {
$item['meta']['term_ids'] = $item['term_ids'];
$item['meta']['media_ids'] = $item['media_ids'];
ORM::raw_execute("INSERT INTO json_table (ID, title, name, type, image, primary_image, meta, media, insert_time) VALUES(:ID, :title, :name, :type, :image, :primary_image, :meta, :media, :insert_time)",
[
'ID' => $item['ID'],
'title' => $item['post_title'],
'name' => $item['post_name'],
'type' => $item['post_type'],
'image' => $item['image'],
'primary_image' => $item['primary_image'],
'meta' => json_encode($item['meta']),
'media' => json_encode($item['media']),
'insert_time' => $item['insert_time'],
]
);
}
}
ORM::raw_execute("update json_table set primary_image = concat('/wp-content/uploads/', primary_image) where (primary_image not like '%http%' and primary_image not like '%wp-content%');");
echo 1;
} else {
echo 0;
}
When I update a product that is live, the product page gives an error. I want to solve this.
A working product page:https://www.cepkolik.com/cep-telefonu/honor-80-pro/
A product page that doesn't work (after saying update product): https://www.cepkolik.com/cep-telefonu/oppo-find-n2/

Am I generating the OAuth signature incorrectly or is there another issue with this Perl / OAuth client code?

OK, I'm going nuts here. I've spent the better part of a week working on this with Fiddler, Rest API Log, Apache logs, Postman, etc. and am no closer to a solution. Hopefully this will provide someone with a good laugh (as it's easy) and me with a solution (for my sanity).
I have a Wordpress 4.9.8 install hosted on hostgator. I have the WP REST API - OAuth 1.0a Server plugin installed and am attempting to authenticate with OAuth from a Perl script. I've been successful connecting with Postman using the credential generated by registering an application in the UI (Wordpress > Users > Applications) but cannot seem to crack the code using curl or a perl script (or php or anything else I've tried). As Postman works (whenever it does not generate a space in the OAuth signature) I believe the plugin does, in fact, work. Below is my code where I've attempted to follow the spec regarding parameters, sorting, URI encoding, utf8 encoding, etc. Everything 'looks' ok when examining headers/query params in either Fiddle or the REST API Log plugin (pretty great little tool, that) and yet, no love.
Thanks for any advice or direction.
Client code:
#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use URI::Escape;
use Digest::HMAC_SHA1 qw( hmac_sha1 );
use MIME::Base64 qw( encode_base64 );
use Encode;
use Data::Dumper;
my $timestamp = time();
my $method = 'GET';
my $url = "https://hoppingmadmonkey.com/wp-json/myapiplugin/v2/greeting";
my $client_secret = "GelrnAAr1nCe5fzmTqzrU82PsfKCmKlDOZrLPakQRkH4sizJ";
my $token_secret = "mdeVuJnrs8VSDJNJfMNPQRqBkG8xadfK0jAYjDGhmKOeaY7O";
#my $nonce = $ARGV[0]; # test with Postman generated parameters
#$timestamp = $ARGV[1]; # test with Postman generated parameters
#my $signature = $ARGV[2]; # test with Postman generated parameters
my %params = (
oauth_consumer_key => "NCo8bflKU9LI",
oauth_signature_method => "HMAC-SHA1",
oauth_realm => "https://hoppingmadmonkey.com",
oauth_timestamp => $timestamp,
oauth_token => "2GeFG7MkXliq2OBOSSCSRBPX",
oauth_version => "1.0",
);
$params{oauth_nonce} = create_nonce();
#$params{oauth_nonce} = $nonce; # test with Postman generated parameters
$params{oauth_timestamp} = $timestamp;
my $key = create_key($client_secret,$token_secret);
my ($params,$base) = build_base_string($method, $url, \%params);
my $signature = create_signature($base, $key);
#for (sort keys %params) { print "$_=$params{$_}", "\n"; }
print "params: $params\n\n";
print "basestring: $base\n\n";
print "key: $key\n\n";
print "signature [$signature]\n\n";
$params{oauth_signature} = $signature; # -- set signature for GET query string
my $request_string = build_request_string($url,\%params);
print "\nrequest_string [$request_string]\n\n";
my $ua = LWP::UserAgent->new();
$ua->default_header("Authorization", "Basic user:pass");
my $response = $ua->get($request_string);
print Dumper $response, "\n";
exit;
my $curlcmd = qq{/usr/bin/curl -i -X GET "$request_string"};
#`$curlcmd 2>&1`;
sub create_signature {
my ($t,$k) = #_;
my $str = encode_base64(hmac_sha1($t,$k));
chomp $str;
return $str;
}
# Create unique nonce
#
sub create_nonce {
my $str = `/bin/cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 11 | head -n 1`;
chomp $str;
return $str;
}
# Create oauth key for generating hmac-sha1 signature
#
sub create_key {
my ($cs,$ts) = #_;
$cs = encode('utf8',uri_escape($cs));
$ts = encode('utf8',uri_escape($ts));
return "$cs&$ts";
}
# Build basestring for generating hmac-sha1 signature
#
sub build_request_string {
my ($u,$p) = #_;
my %params = %$p;
my $str = $u . '?';
my #tmp;
for (sort keys %params) {
$p = uri_escape($_) . '=' . uri_escape($params{$_});
push #tmp, $p;
}
$str .= join '&', #tmp;
return $str;
}
# build the base string parameter for creating the signature
#
sub build_base_string {
my ($m,$u,$phash) = #_;
my %params = %$phash;
my $str = $method;
$str .= '&' . uri_escape($u) . '&';
my #tmp;
for (sort keys %params) {
push #tmp, uri_escape("$_=$params{$_}");
}
$params = join '&', #tmp;
$str .= join '&', #tmp;
return $params,$str;
}
1;
The result of running this from the command line is:
dnu [test] ::>./oauth-perl.pl
params: oauth_consumer_key%3DNCo8bflKU9LI&oauth_nonce%3DJrGdlVLXpB4&oauth_realm%3Dhttps%3A%2F%2Fhoppingmadmonkey.com&oauth_signature_method%3DHMAC-SHA1&oauth_timestamp%3D1542134239&oauth_token%3D2GeFG7MkXliq2OBOSSCSRBPX&oauth_version%3D1.0
basestring: GET&https%3A%2F%2Fhoppingmadmonkey.com%2Fwp-json%2Fmyapiplugin%2Fv2%2Fgreeting&oauth_consumer_key%3DNCo8bflKU9LI&oauth_nonce%3DJrGdlVLXpB4&oauth_realm%3Dhttps%3A%2F%2Fhoppingmadmonkey.com&oauth_signature_method%3DHMAC-SHA1&oauth_timestamp%3D1542134239&oauth_token%3D2GeFG7MkXliq2OBOSSCSRBPX&oauth_version%3D1.0
key: GelrnAAr1nCe5fzmTqzrU82PsfKCmKlDOZrLPakQRkH4sizJ&mdeVuJnrs8VSDJNJfMNPQRqBkG8xadfK0jAYjDGhmKOeaY7O
signature [2pJRR1fz0uUdUWHlUjHFWlXFbL4=]
request_string [https://hoppingmadmonkey.com/wp-json/myapiplugin/v2/greeting?oauth_consumer_key=NCo8bflKU9LI&oauth_nonce=JrGdlVLXpB4&oauth_realm=https%3A%2F%2Fhoppingmadmonkey.com&oauth_signature=2pJRR1fz0uUdUWHlUjHFWlXFbL4%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1542134239&oauth_token=2GeFG7MkXliq2OBOSSCSRBPX&oauth_version=1.0]
$VAR1 = bless( {
'_protocol' => 'HTTP/1.1',
'_content' => '
{"code":"json_oauth1_signature_mismatch","message":"OAuth signature does not match","data":{"status":401}}',
'_rc' => '401',
'_headers' => bless( {
'connection' => 'close',
'cache-control' => 'no-cache, must-revalidate, max-age=0',
'date' => 'Tue, 13 Nov 2018 18:37:19 GMT',
'client-ssl-cert-issuer' => '/C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Domain Validation Secure Server CA',
'client-ssl-cipher' => 'ECDHE-RSA-AES256-GCM-SHA384',
'client-peer' => '192.185.236.193:443',
'access-control-expose-headers' => 'X-WP-Total, X-WP-TotalPages',
'x-robots-tag' => 'noindex',
'client-warning' => 'Missing Authenticate header',
'client-date' => 'Tue, 13 Nov 2018 18:37:22 GMT',
'client-ssl-warning' => 'Peer certificate not verified',
'content-type' => 'application/json; charset=UTF-8',
'client-transfer-encoding' => [
'chunked'
],
'server' => 'Apache',
'x-endurance-cache-level' => '2',
'client-ssl-socket-class' => 'IO::Socket::SSL',
'link' => '<https://hoppingmadmonkey.com/index.php/wp-json/>; rel="https://api.w.org/"',
'access-control-allow-headers' => 'Authorization, Content-Type',
'client-response-num' => 1,
'x-content-type-options' => 'nosniff',
'client-ssl-cert-subject' => '/OU=Domain Control Validated/OU=Hosted by HostGator.com, LLC./OU=PositiveSSL Wildcard/CN=*.hostgator.com',
'expires' => 'Wed, 11 Jan 1984 05:00:00 GMT'
}, 'HTTP::Headers' ),
'_msg' => 'Unauthorized',
'_request' => bless( {
'_content' => '',
'_uri' => bless( do{\(my $o = 'https://hoppingmadmonkey.com/wp-json/myapiplugin/v2/greeting?oauth_consumer_key=NCo8bflKU9LI&oauth_nonce=JrGdlVLXpB4&oauth_realm=https%3A%2F%2Fhoppingmadmonkey.com&oauth_signature=2pJRR1fz0uUdUWHlUjHFWlXFbL4%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1542134239&oauth_token=2GeFG7MkXliq2OBOSSCSRBPX&oauth_version=1.0')}, 'URI::https' ),
'_headers' => bless( {
'user-agent' => 'libwww-perl/5.833',
'authorization' => 'Basic user:pass'
}, 'HTTP::Headers' ),
'_method' => 'GET',
'_uri_canonical' => bless( do{\(my $o = 'https://hoppingmadmonkey.com/wp-json/myapiplugin/v2/greeting?oauth_consumer_key=NCo8bflKU9LI&oauth_nonce=JrGdlVLXpB4&oauth_realm=https%3A%2F%2Fhoppingmadmonkey.com&oauth_signature=2pJRR1fz0uUdUWHlUjHFWlXFbL4%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1542134239&oauth_token=2GeFG7MkXliq2OBOSSCSRBPX&oauth_version=1.0')}, 'URI::https' )
}, 'HTTP::Request' )
}, 'HTTP::Response' );
$VAR2 = '
';
In the interests of expedience, I've included my real secrets and website. It's all test at the moment. Feel free to try a solution if you have that kind of time on your hands. I can always invalidate the tokens if/when they get abused and will obviously change once/if I can understand the problem.
The obvious thought is that I am not generating the signature correctly (Big Hint:
{"code":"json_oauth1_signature_mismatch","message":"OAuth signature does not match","data":{"status":401}}',
)
I think I've ready everything on the entire Internet to no avail. Thanks in advance for any thoughts. And if you are near Atlanta, GA and help me out, the beer's on me.
Cheers.
Try using Net::OAuth
If you really need to fix your implementation then try removing all uri_escape and testing with data that doesn't require any escaping.
It looks like you have some unnecessary or double escaping. Start with build_base_string function.
I thinks that = sign should be unescaped.
I could not get things working with Net::OAuth so I tried writing my code again from scratch and explicitly following the guidelines at http://lti.tools/oauth/ until my code output matched theirs. Hallelujah! It's now working.
One thing I had to add, and Postman fails to do this as well, is to url encode the signature. Makes sense, of course, but odd that Postman misses it and sends an occasional unescaped '+'.

woocommerce subscription API

I am using Woocomemrce REST API to connect with my site. Everything works fine when it comes to orders but it is not working with subscriptions. I have tried following code to get subscriptions but it is giving "Error: No route was found matching the URL and request method [rest_no_route]"
$woocommerce = new Client(
'https://www.example.com',
'ck_OUR_CONSUMER_KEY',
'cs_OUR_CONSUMER_SECRET',
[
'wp_api' => true,
'version' => 'wc/v2',
]
);
try {
print_r($woocommerce->get('orders')); //this works and fetch orders
print_r($woocommerce->get('subscriptions')); //but this does not work
} catch (HttpClientException $e) {
echo $e->getMessage(); // Error message.
echo $e->getRequest(); // Last request data.
echo $e->getResponse(); // Last response data.
}
Can anyone help me sort out this issue. Thank You.
I changed it to the following it worked for me.
$woocommerce = new Client(
'https://www.example.com',
'ck_OUR_CONSUMER_KEY',
'cs_OUR_CONSUMER_SECRET',
[
'wp_api' => true,
'version' => 'wc/v1',
]
);

Accessing nested parameters in Symfony ParameterBag

Have a request that looks like this
ParameterBag {#362 ▼
#parameters: array:1 [▼
"form" => array:5 [▼
"titre" => "new b"
"prix" => "4444"
"slug" => "with-different-slug"
"publier" => "unpub"
"Modifier" => ""
]
]
}
How can I use the
$post = Request::createFromGlobals();
$post->request->has() on those nested properties?
ParameterBag's has function does not support deep check. It is just an array_key_exists call.
You could use get with $deep parameter set to true.
E.g.:
$post = Request::createFromGlobals();
$post->request->get('form[titre]', null, true);
It will return null (the second parameter), if the value does not exist.
EDIT:
This function however deprecated in 2.8.
Using paths to find deeper items in get is deprecated since version 2.8 and will be removed in 3.0. Filter the returned value in your own code instead.

How to generate sip address on browser using asterisk

I need to generate a dynamic sip address on browsers so that my asterisk server can place a call on the same sip address.
This way my web browser will become a sip client which can receive call.
I can see that webrtc is the way but I don't know how can I generate sip address on my browser?
Thanks
You need to create sip user in asterisk like in any other case and register to it via WebRTC, but first you have to enable it in configuration. Hear you have tutorial that I use to start.
In case you want to create dynamic sip users you have to use realtime in asterisk, then your configuration will be read from database. Useful links how to start with realtime: https://wiki.asterisk.org/wiki/display/AST/Realtime+Database+Configuration
https://wiki.asterisk.org/wiki/display/AST/SIP+Realtime,+MySQL+table+structure
You can check my post on Asterisk 12 + Realtime + WebRTC : Websocket connection fails with asterisk 11
On top of that, add a WebService to insert a peer into the table sippeers. This Webservice would be called by your system to create the peer instantly available for a registration using SIP or whatever (SIP over WS/WSS, WebRTC...)
If you're working on Unix and need a .Net WebService, you can use NUSOAP and something like this : (sudo nano /var/html/www/mywebservice.php`. This is a basic implementation I used for testing.
<?php
require_once("nusoap.php");
$namespace = "http://yourdomain.com";
// create a new soap server
$server = new soap_server();
// configure your WSDL
$server->configureWSDL("AsteriskRealtime");
// set your namespace
$server->wsdl->schemaTargetNamespace = $namespace;
// register your WebMethod
$server->register(
// method name:
'HelloWorld',
// parameter list:
array('name'=>'xsd:string'),
// return value(s):
array('return'=>'xsd:string'),
// namespace:
$namespace,
// soapaction: (use default)
false,
// style: rpc or document
'rpc',
// use: encoded or literal
'encoded',
// description: documentation for the method
'A simple hello world');
$server->wsdl->addComplexType(
'AsteriskExtensions',
'complexType',
'struct',
'all','',
array(
'name' => array('name' => 'name', 'type' => 'xsd:string'),
'custom_id' => array('name' => 'custom_id', 'type' => 'xsd:string')
)
);
$server->wsdl->addComplexType(
'AsteriskExtensionsArray',
'complexType',
'array','',
'SOAP-ENC:Array',array(),
array(
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:AsteriskExtensions[]')
),
'tns:AsteriskExtensions'
);
$server->register(
// method name:
'GetRegisteredExtensions',
// parameter list:
array(),
// return value(s):
array('AsteriskExtensions' => 'tns:AsteriskExtensionsArray'),
// namespace:
$namespace,
// soapaction: (use default)
false,
// style: rpc or document
'rpc',
// use: encoded or literal
'encoded',
// description: documentation for the method
'List the extensions registered in AsteriskRealtime database.');
$server->register(
// method name:
'AddUpdateExtension',
// parameter list:
array('name' => 'xsd:string', 'password' => 'xsd:string', 'custom_id' => 'xsd:string'),
// return value(s):
array('return' => 'xsd:string'),
// namespace:
$namespace,
// soapaction: (use default)
false,
// style: rpc or document
'rpc',
// use: encoded or literal
'encoded',
// description: documentation for the method
'Add or Update an extension in AsteriskRealtime database. NAME is the PRIMARY KEY. Returns OK for success or ERR for failure.');
$server->register(
// method name:
'DeleteExtension',
// parameter list:
array('name' => 'xsd:string'),
// return value(s):
array('return' => 'xsd:string'),
// namespace:
$namespace,
// soapaction: (use default)
false,
// style: rpc or document
'rpc',
// use: encoded or literal
'encoded',
// description: documentation for the method
'Delete an extension registered in AsteriskRealtime database. Returns OK for success or ERR for failure. ');
$server->register(
// method name:
'GetByCustomId',
// parameter list:
array('name' => 'xsd:string'),
// return value(s):
array('AsteriskExtensions' => 'tns:AsteriskExtensionsArray'),
// namespace:
$namespace,
// soapaction: (use default)
false,
// style: rpc or document
'rpc',
// use: encoded or literal
'encoded',
// description: documentation for the method
'Gets an extension or a list of extensions for a CustomID. ');
function HelloWorld($sName)
{
return 'Hello ' . $sName . '! Hello world!';
}
function GetRegisteredExtensions()
{
$conn=odbc_connect('your-asterisk-connector-as-in-odbcinst.ini','your-mysql-user','your-mysql-password');
$result = array();
$req="SELECT * FROM `sippeers`";
$res=odbc_exec($conn,$req);
while($obj=odbc_fetch_object($res)) {
$result[] = array( 'name' => $obj->name, 'custom_id' => $obj->custom_id);
}
return $result;
}
function AddUpdateExtension($name,$password,$custom_id)
{
$conn=odbc_connect('your-asterisk-connector-as-in-odbcinst.ini','your-mysql-user','your-mysql-password');
$req="DELETE FROM `sippeers` WHERE `name` = '" . $name . "'";
$res=odbc_exec($conn,$req);
$req="insert into `sippeers` (`name`, `ipaddr`, `port`, `regseconds`, `defaultuser`, `fullcontact`, `regserver`, `useragent`, `lastms`, `host`, `type`, `context`, `permit`, `deny`, `secret`, `md5secret`, `remotesecret`, `transport`, `dtmfmode`, `directmedia`, `nat`, `callgroup`, `pickupgroup`, `language`, `disallow`, `allow`, `insecure`, `trustrpid`, `progressinband`, `promiscredir`, `useclientcode`, `accountcode`, `setvar`, `callerid`, `amaflags`, `callcounter`, `busylevel`, `allowoverlap`, `allowsubscribe`, `videosupport`, `maxcallbitrate`, `rfc2833compensate`, `mailbox`, `session-timers`, `session-expires`, `session-minse`, `session-refresher`, `t38pt_usertpsource`, `regexten`, `fromdomain`, `fromuser`, `qualify`, `defaultip`, `rtptimeout`, `rtpholdtimeout`, `sendrpid`, `outboundproxy`, `callbackextension`, `timert1`, `timerb`, `qualifyfreq`, `constantssrc`, `contactpermit`, `contactdeny`, `usereqphone`, `textsupport`, `faxdetect`, `buggymwi`, `auth`, `fullname`, `trunkname`, `cid_number`, `callingpres`, `mohinterpret`, `mohsuggest`, `parkinglot`, `hasvoicemail`, `subscribemwi`, `vmexten`, `autoframing`, `rtpkeepalive`, `call-limit`, `g726nonstandard`, `ignoresdpversion`, `allowtransfer`, `dynamic`, `path`, `supportpath`, `avpf`, `encryption`, `dtlsenable`, `dtlsverify`, `dtlscertfile`, `dtlsprivatekey`, `dtlssetup`, `force_avp`, `custom_id`) values('" . $name . "',NULL,NULL,NULL,'" . $name . "','','',NULL,'0','dynamic','friend','default',NULL,NULL,'" . $password . "',NULL,NULL,'udp,ws,wss','auto','no',NULL,NULL,NULL,NULL,NULL,'ulaw,alaw,g729,h264,g719,opus,vp8,gsm',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'no',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'yes','',NULL,'yes','yes','yes','no','/etc/asterisk/keys/asterisk.pem','/etc/asterisk/keys/asterisk.pem','actpass','yes','" . $custom_id . "')";
$res=odbc_exec($conn,$req);
return 'OK';
}
function DeleteExtension($name)
{
$conn=odbc_connect('your-asterisk-connector-as-in-odbcinst.ini','your-mysql-user','your-mysql-password');
$req="DELETE FROM `sippeers` WHERE `name` = '" . $name . "'";
$res=odbc_exec($conn,$req);
return 'OK';
}
function GetByCustomId($name)
{
$conn=odbc_connect('your-asterisk-connector-as-in-odbcinst.ini','your-mysql-user','your-mysql-password');
$result = array();
$req="SELECT * FROM `sippeers` WHERE `custom_id` = '" . $name . "'";
$res=odbc_exec($conn,$req);
while($obj=odbc_fetch_object($res)) {
$result[] = array( 'name' => $obj->name, 'custom_id' => $obj->custom_id);
}
return $result;
}
// Get our posted data if the service is being consumed
// otherwise leave this data blank.
$POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
// pass our posted data (or nothing) to the soap service
$server->service($POST_DATA);
exit();
?>

Resources