trouble with custom plugin

3 posts / 0 new
Last post
#1 Sun, 07/08/2012 - 14:14
seemeinhi

trouble with custom plugin

I am trying to make my first plugin. I have added it to plugins and features and account plan... But haven't been able to make it show up in the virtualmin menu. It shows up in webmin modules but not in menu. Ant help will be appreciated.

Mon, 07/09/2012 - 09:04
andreychek

Howdy,

Is there any chance you could post the contents of your plugin?

Thanks!

-Eric

Mon, 07/09/2012 - 09:58
seemeinhi

Seemed like it shouldn't be too hard... Just have to launch the php script to connect to the simplescript interface. But I have never tried, and it is probably over my head.

Module.info

desc=A Plugin to enable SimpleScripts category=system version=1.0

virtualmin-simplescripts-lib.pl

use WebminCore; &init_config(); &foreign_require("virtual-server", "virtual-server-lib.pl"); 1;

virtual-feature.pl

do 'virtualmin-simplescripts-lib.pl';

sub feature_name { return "A Plug-In to enable SimpleScripts with Virtualmin."; }

sub feature_label { return "Enable the Simple Scripts plugin"; }

sub feature_setup { my ($d) = @_; &$virtual_server::first_print("Setting up My plugin.."); my $ex = system("/usr/bin/php launch-simplescripts --add $d->{'dom'} >/dev/null 2>&1"); if ($ex) { &$virtual_server::second_print(".. failed!"); return 1; } else { &$virtual_server::second_print(".. done"); return 1; } }

sub feature_links { local ($d) = @_; return ( { 'mod' => $virtualmin-simplescripts, 'desc' => "Manage My plugin", 'page' => 'launch-simplescripts.php?dom='.$d->{'dom'}, 'cat' => 'services', } ); }

launch-simplescripts.php

<?php
/* Sample Code for the SimpleScripts Client Login API. */

//Gather all the necessary client information into one place.
//START EDITING HERE.
$my_request = array(
   "host_key" => "PNMvDB8TDa0M",
   "host_api_key" => "FST1qvMpbx8348sRXUz7PXlCmy45Yba9",
   "user_unique" => "****",
   "user_domain" => "1cheaphoster.com",
   "user_ip" => "209.139.209.148",
   "user_email" => "don@1cheaphoster.com",
   "user_username" => "****",
   "user_password" => "*****",
   "user_cptype" => "virtualmin",
);
//STOP EDITING HERE.

//build the query.
$my_request_str = "";
foreach ($my_request as $key => $value) { $my_request_str.= $key."=".urlencode($value)."&"; }

//cPanel (and maybe other panels) come with a gutted version of PHP that does not
//include the standard CURL libraries.  If your panel supports them, you can use those instead.
ob_start();
passthru('curl -k https://www.simplescripts.com/api/client_login.php
    --data "'.rtrim($my_request_str,"& ").'" --max-time 60');
$response = ob_get_contents();
ob_end_clean();

//Take apart the response.  First part is the success/failure bit (1/0, respectively),
//and the second is either a link to redirect to, or a failure message for debugging.
$parts = explode("|",$response);
if ($parts[0] == "0") {
    die("Something went wrong!<br />\n".$parts[1]);
}
else {
    header("Location: ".$parts[1]);
}
?>
Topic locked