[#3017] including a php file during a plan registration ?

12 years 6 months ago - 12 years 5 months ago #180918 by activha
Hello

I would like the attached script to be run during a plan so I linked the url with the url integration.

But nothing happens and the sql and scripts are not executed.

Could you help me on this and tell me what is going wrong ? all integrations seems to work ok (except PAP of course :-) ) but I have problem with this script

Thanks in advance

File Attachment:

File Name: cb_update_....php.zip
File Size:2 KB
Attachments:

Please Log in to join the conversation.

12 years 6 months ago - 12 years 6 months ago #180925 by krileon
No idea what the script is as security won't allow me to download it (never have a files extension in an archived packages name). Please add your source to a .txt file and attach the text file.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

12 years 6 months ago #180959 by activha
quote="krileon" post=180925] (never have a files extension in an archived packages name). Please add your source to a .txt file and attach the text file.[/quote]

Mmmm... maybe switch to a real computer... MacBook for instance :-) :-)

Ok I removed the php stuff in the name, it should work now for a PC to understand it ;)

File Attachment:

File Name: cb_update_...ript.zip
File Size:2 KB
Attachments:

Please Log in to join the conversation.

12 years 6 months ago #181108 by krileon

Mmmm... maybe switch to a real computer... MacBook for instance

Has nothing to do with my computer. Our server security blocked it.

Ok I removed the php stuff in the name, it should work now for a PC to understand it

Yup, works fine now.

Have reviewed your script and don't understand why you're using "$this->". That won't give you access to the user object as the plugin is designed to do an HTTP REQUEST. For example you can pass ?user=[user_id] then use $_GET to get the users ID. None of that API will work either unless it actually includes Joomla/CBs files.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

12 years 6 months ago #181353 by activha
Instead of calling the file, could I just insert a sql request such as:
$sql = 'INSERT INTO #__enmasse_sales_person(name,user_name,address,phone,email,zip_code,city,country,published,created_at,updated_at)
                        VALUE(
                            "' . $this->_cmsUser->name . '",
                            "' . $this->_cmsUser->username . '",
                            "' . $this->_comprofilerUser->address . '",
                            "' . $this->_comprofilerUser->phone . '",  
                            "' . $this->_cmsUser->email . '",
                            "' . $this->_comprofilerUser->zipcode . '",
                            "' . $this->_comprofilerUser->city . '",
                            "' . $this->_comprofilerUser->country . '",
                            "1",
                            "' . date("Y-m-d H:i:s") . '",
                            "' . date("Y-m-d H:i:s") . '"
                        )
                       ';
        //echo $sql; die;
        $oDB->setQuery($sql);
        $oDB->query();
        $salesId = $oDB->insertid();

                        '" . date("Y-m-d H:i:s") . "',
                            '" . date("Y-m-d H:i:s") . "'
                        )
             //Setup Branch for Merchant
        $arrBranches = array();
        $arrBranches['branch1']['branchname'] = 'branch1';
        $arrBranches['branch1']['name'] = $this->_cmsUser->name;
        $arrBranches['branch1']['description'] = '';
        $arrBranches['branch1']['google_map_width'] = '200';
        $arrBranches['branch1']['google_map_height'] = '200';
        $arrBranches['branch1']['address'] = $this->_comprofilerUser->address;
        $arrBranches['branch1']['telephone'] = $this->_comprofilerUser->phone;
        $arrBranches['branch1']['fax'] = $this->_comprofilerUser->fax;
        $arrBranches['branch1']['google_map_lat'] = '';
        $arrBranches['branch1']['google_map_long'] = '';
        $arrBranches['branch1']['google_map_zoom'] = '';
        $jsonBranches = json_encode($arrBranches);
        //echo '<pre>'; print_r($jsonBranches); echo '</pre>';

        $sqlMerchant = "INSERT INTO #__enmasse_merchant_branch(name,user_name,sales_person_id,branches,zip_code,city,country,published,created_at,updated_at)
                        VALUE(
                            '" . $this->_cmsUser->name . "',
                            '" . $this->_cmsUser->username . "',
                            '" . $salesId . "',
                            '" . $jsonBranches . "',
                            '" . $this->_comprofilerUser->zipcode . "',
                            '" . $this->_comprofilerUser->city . "',
                            '" . $this->_comprofilerUser->country . "',
                            '1',
                      ";
        //echo $sqlMerchant; die;
        $oDB->setQuery($sqlMerchant);
        $oDB->query();

Please Log in to join the conversation.

12 years 6 months ago #181356 by krileon
Do, your script has zero access to Joomla/CB API and of course zero access to "$this". It is a HTML request to that file and that file has no access to anything from the calling site. The only way the above would work is if for example it included the file then return the results, which is not what the integration does.

Being just database queries however you maybe able to do this using the SQL Actions plugin to perform the queries or do as I've suggested earlier and pass variables to your script either in GET or in POST then retrieve and use those variables. You will need to manually create a connection to your database. All of which is without Joomla/CB API and done in pure PHP. You could include Joomlas API I believe though into your script file (if it's on a server with Joomla) and you should then be able to use the API.

Below is an example of your script modified.
  $oDB = mysql_connect( 'mysql_server', 'mysql_user', 'mysql_password' );

  mysql_select_db( 'mysql_database', $oDB );

  $sql = 'INSERT INTO #__enmasse_sales_person(name,user_name,address,phone,email,zip_code,city,country,published,created_at,updated_at)
                        VALUE(
                            "' . $_POST['name'] . '",
                            "' . $_POST['username'] . '",
                            "' . $_POST['cb_address'] . '",
                            "' . $_POST['cb_phone'] . '",  
                            "' . $_POST['email'] . '",
                            "' . $_POST['cb_zipcode'] . '",
                            "' . $_POST['cb_city'] . '",
                            "' . $_POST['cb_country'] . '",
                            "1",
                            "' . date("Y-m-d H:i:s") . '",
                            "' . date("Y-m-d H:i:s") . '"
                        )
                       ';
        //echo $sql; die;
        mysql_query($sql,$oDB);
        $salesId = mysql_insert_id();
 
                        '" . date("Y-m-d H:i:s") . "',
                            '" . date("Y-m-d H:i:s") . "'
                        )
             //Setup Branch for Merchant
        $arrBranches = array();
        $arrBranches['branch1']['branchname'] = 'branch1';
        $arrBranches['branch1']['name'] = $_POST['name'];
        $arrBranches['branch1']['description'] = '';
        $arrBranches['branch1']['google_map_width'] = '200';
        $arrBranches['branch1']['google_map_height'] = '200';
        $arrBranches['branch1']['address'] = $_POST['cb_address'];
        $arrBranches['branch1']['telephone'] = $_POST['cb_phone'];
        $arrBranches['branch1']['fax'] = $_POST['cb_fax'];
        $arrBranches['branch1']['google_map_lat'] = '';
        $arrBranches['branch1']['google_map_long'] = '';
        $arrBranches['branch1']['google_map_zoom'] = '';
        $jsonBranches = json_encode($arrBranches);
        //echo '<pre>'; print_r($jsonBranches); echo '</pre>';
 
        $sqlMerchant = "INSERT INTO #__enmasse_merchant_branch(name,user_name,sales_person_id,branches,zip_code,city,country,published,created_at,updated_at)
                        VALUE(
                            '" . $_POST['name'] . "',
                            '" . $_POST['username'] . "',
                            '" . $salesId . "',
                            '" . $jsonBranches . "',
                            '" . $_POST['cb_zipcode'] . "',
                            '" . $_POST['cb_city'] . "',
                            '" . $_POST['cb_country'] . "',
                            '1',
                      ";
        //echo $sqlMerchant; die;
        mysql_query($sqlMerchant,$oDB);

  mysql_close($oDB);

Please keep in mind the above is just an example and of course would need changes. You also would need to ensure the method used is POST and you send those post variables.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.219 seconds

Facebook Twitter LinkedIn