Row_Inserting: call a php file with two arguments

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
mpol_ch
User
Posts: 881
Location: Switzerland

Row_Inserting: call a php file with two arguments

Post by mpol_ch »

Hello

I have a file longben.php which can be run with two arguments in command line such;

longben.php 89876776 "Nein"

I would like to execute this during "Row_inserting". When I just enter the row like above it happens nothing. The file is uploaded into same phpmaker application folder.

Can use in this in this kind? Or should include some extra code?

thanks
mpol_ch


mobhar
User
Posts: 11789

Post by mobhar »

Post the code in "longben.php" file how to catch those two arguments.


mpol_ch
User
Posts: 881
Location: Switzerland

Post by mpol_ch »

Hallo Mobhar

thanks for the response. Ich just find the following file which is similar and should be send sms if you enter the destination phone nr and message test as follow:

sms.php +41798006767 "This is test SMS".

The code is from phpclass...

Could you pleaese have a look, how to integrate this into phpmaker?

thanks anyway for your time.
mpol_ch

#!/usr/bin/php
<?php
/*

BETAMAX SMS CLASS

...

Your commandline would look like sms.php <destination> <text>
f.i.
sms.php +00000000000 "text encapsulated by hyphens and all should work fine".

REMOVE FOR EXAMPLE CODE TO WORK
//create new instance
$sms=new betamaxsms();

//setusername
$sms->username="<your username>";
//setpassword
$sms->userpassword="<your password>";
//setnumber
$sms->userphone="<your registered number>";

//These come from our commandline
$sms->destination=$argv[1];
$sms->text=$argv[2];

//mni phonebook example - this shows how you can easily
//translate names on the commandline to numbers
if($sms->destination == "John"){
$sms->destination="0000000000";
}elseif($sms->destination == "Jane"){
$sms->destination="000000001";
};

$sms->sendsms();

exit;
//REMOVE FOR EXAMPLE CODE TO WORK
class betamaxsms{

public $provurl="myaccount.VoipCheap.com";
public $okresult="/<resultstring>success/";
public $username;
public $userphone;
public $userpassword;
public $destination;
public $text;
public $result;

function sendsms(){
$text=urlencode($this->text);

$build="hxxs://".$this->provurl."/clx/sendsms.php?username=".$this->username."&password=".$this->userpassword."&from=".$this->userphone."&to=".$this->destination."&text=".$text;
$result=$this->engine($build);
if($result == 1){
	$this->resultok();
}else{
	$this->resultfail();
}

}
function engine($build){
$ch = curl_init($build);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
$this->result = curl_exec($ch);
curl_close($ch);
return(preg_match ( $this->okresult , $this->result));
}

function resultok(){
echo "SMS met text:\n\n";
echo urldecode($this->text);
echo "\n\nverzonden aan:\n\n";
echo $this->destination;
echo "\n\n";
}

function resultfail(){
echo "SMS MISLUKT !!!\n\n";
echo "technische data:\n";
echo $this->result;
}
}

?>

In the documentation is says that you can call the script like
sms.php destination "text"

Can I just enter this code in row_inserting? Or do I need shell_exec()...
my server has cURL enabled...

mpol_ch


Webmaster
User
Posts: 9432

Post by Webmaster »

You can copy the class betamaxsms to server side Global Code, and then copy the code to use the class in server event, e.g.

$sms=new betamaxsms();
....
$sms->destination = "xxx"; // set the properties directly by code
$sms->text = "yyy";
...
$sms->sendsms();


mpol_ch
User
Posts: 881
Location: Switzerland

Post by mpol_ch »


Post Reply