DirectAdmin API - issue with show user config - directadmin

<?php
include '../protocol/httpsocket.php';
$sock = new HTTPSocket;
$sock->connect('localhost',2222);
$sock->set_login('admin','admin_password');
$show_user='user5';
$sock->query('/CMD_API_SHOW_USER_CONFIG?user='.$show_user);
$result = $sock->fetch_parsed_body();
print_r($result);
?>
This above code return:
white page with only "Array ( )"
Connection with DA is correct, because I can create user API etc.

Try add $sock->set_method('POST'); or $sock->set_method('GET'); after $sock->set_login('admin','admin_password');

Related

Pass values from url to another redirected url

zero.php
<?php
$q = $_GET['id'];
echo = $q
?>
this code is not working, Help me!
I am not using .htaccess in this.
Try this.
<?php
$q = $_GET['value'];
echo $q;
Your syntax is significantly off.
Have you tried?
<?php
$q = $_GET['id'];
echo $q;
?>
and of course this is assuming that there is a GET parameter called id it is being passed so a even better solution would be to check to see if it is defined first.
<?php
if (isset($_GET['id'])) {
$q = $_GET['id'];
echo $q;
} else {
echo "ID PARAMETER NOT SET";
}
?>

disable layout for particular pages in ZF2

How to disable particular layout(example:menus.phtml) for particular pages in controller in ZF2?? In the below example menus.phtml should be disable for specific pages. Remaining pages must contain menus.phtml like header and footer.
<div>
header.phtml
</div>
<div>
menus.phtml
</div>
<div>
<?php echo $this->content; ?>
</div>
<div>
footer.phtml
</div>
There are various aproaches to this. Also modules.zendframework has quite a few modules here that may help you out.
If you are still keen on writing that yourself you could add variables to your layout within your controllers like so:
<?php
//YourController.php
public function someAction()
{
...
$this->layout()->footer = 'default';
...
}
//layout.phtml
<?php if ($this->footer === 'default') : ?>
//show the footer
<?php endif; ?>
Doing this is pretty inefficient though. Just imagine you'd need to do this to every action in all the controllers... I sure would not like to do that.
Now zf2 has a service and event layer that could help us out quite a bit here. This is a pretty nice read and introduction to it. You'd just write a service and trigger a event on your controllers/routes/whatever. Now you would also probably like to configure what is shown and what is hidden right? Thats pretty easy, too. Just write yourself a config file and merge it with the global.config like so:
<?php
//CustomModule/module.php
public function getConfig() {
$config = array();
$configFiles = array(
include __DIR__ . '/config/module.config.php',
include __DIR__ . '/config/module.customconfig.php',
);
foreach ($configFiles as $file) {
$config = \Zend\Stdlib\ArrayUtils::merge($config, $file);
}
return $config;
}
Source: Where to put custom settings in Zend Framework 2?
First, get the controller or action name:
$controllerName =$this->params('controller');
$actionName = $this->params('action');
then in your layout/view script add a simple logic.
<?php if ($actionName != 'action that you want to disable the layout/menu'): ?>
echo $this->render('menus.phtml');
<?php endif; ?>

In zf2 how to load more than one action in controller in a page

How to show both of my Signin and Signup module in a same page,both work fine seperately in their route
www.mydomain.com/Signin
www.mydomain.com/SignUp
How it is possible to include/call signup action while in Signin Action ?
Is there any website in LIVE that had been done in ZF2 ?
Can i get any sample project of Zf2 except ZendSkeltonApplication (It doesn't have two actions in a same page) ?
Try use like this, action in your controller
public function loginAction()
{
$signin = $this->forward()
->dispatch('App\Controller\Signin');
$signup = $this->forward()
->dispatch('App\Controller\Signup');
$page = new ViewModel();
$page->addChild($signin, 'signinBlock');
$page->addChild($signup, 'signupBlock');
return $page;
}
in your view
<?php echo $this->signinBlock ?>
<?php echo $this->signupBlock ?>

How to get the request parameters that are passed from Request made by view in Kohana 3.3.0

I am trying to echo a request in the view file in Kohana using Request::factory() method and i am sending a value in that request which i am unable to get in the User Controller here is my code:
The View file:
<h1> Welcome to My First View File </h1>
<?php echo Request::factory("user",array("id" => 123))->execute(); ?>
Then the User.php Controller have this code:
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_User extends Controller {
public function action_index()
{
$value = $this->request->param('id');
$content = View::factory('menu')->bind("id", $value);
$this->response->body($content);
}
} // End User
and the view menu.php have this code:
<h2> This is the view called by Request and Parameters send was:
<?php echo $id; ?>
</h2>
when i run the code it display the text This is the view called by Request and Parameters send was: but it doesn't display the $id anyone can tell me why?
P.S: sorry for my bad English as its not my native language
Here you can see, that Request::factory() requires URI value a the first param. So, you should call something like:
<h1> Welcome to My First View File </h1>
<?php echo Request::factory(Route::get("user")->uri(array("id" => 123)))->execute(); ?>
or
<h1> Welcome to My First View File </h1>
<?php echo Request::factory("user/123")->execute(); ?>
First example uses reverse routing, where "user" is a Route name. I assume that you already have Route for handling URIs like '/user/123'.

Get data from previous page

I create a popup window using onclick="window.open()" the question is how can i get the data from previous page? here is my code :
<?php
include ("conn.php");
extract($_GET);
$applicantID = $_GET['applicantID'];
$sql = "SELECT * FROM applicant WHERE applicantID ='$applicantID'";
$query = mysql_query($sql);
$data = mysql_fetch_array($query);
echo $data['applicantID'];
?>
When i echo $data['applicantID']; it doesn't show any data.
I use this <input type="button" value="Check" onclick="window.open('checkstatus.php','popup','width=800,height=800,scrollbars=yes,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false" />
Why don't you use window.open('checkstatus.php?applicantID=something')? And retrieve it by $applicantID = $_GET['applicantID'] so that I hope it will work.

Resources