Sunday, December 28, 2008
Running talk on freebsd
I came up with a problem using talk under freebsd I thought this might be usefull to newcommers. The solution is simple but few docs is laying arround so one might need a little digging.
In order to run talk on freebsd you need to uncomment this line on inetd.conf :
"ntalk dgram udp wait tty:tty /usr/libexec/ntalkd ntalkd"
Once this is done you'll be able to run it easely...
Labels:
freebsd,
inetd,
talk,
talk on freebsd
Wednesday, December 3, 2008
Failed to enable the ‘httpready’ Accept Filter - Apache 2.2
I installed an apache on a FreeBSD 7 today and had this problem "Failed to enable the ‘httpready’ Accept Filter".
The solution is straigh ahead : "kldload accf_http".
Don't forget to load the module in /boot/loader.conf:
accf_http_load=”YES”
That's it !
Wednesday, November 26, 2008
Simple interface administration for SimpleDB on Zend framework
Hey,
I'm trying to have a little fun with SimpleDB.
In order to play with data (delete, mostly) I needed to write a simple function to get my informations. Now be warned, it's very poor code, but it'll allow you to see and delete your data easely. Anyone willing to write phpSimpleDBAdmin ?
Here it is :
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout(true);
echo " Current domains
";
// Build a link to show all domains
$Admin = new Admin();
$domains = $Admin->ListDomains();
foreach ($domains as $key=>$value)
{
echo " $value ";
}
if(isset($_GET['d']))
{
echo " ".$_GET['d']." data
";
echo "#ADD a pre HERE";
$data = $Admin->getDomainData($_GET['d']);
print_r($data);
foreach ($data as $k=>$v)
{
foreach ($v as $items=>$array)
{
echo "
Item id : $items actions : delete";
}
}
}
Now, this function uses 2 other functions :
public function ListDomains()
{
$request = new Amazon_SimpleDB_Model_ListDomainsRequest();
$response = $this->service->listDomains($request);
if ($response->isSetListDomainsResult()) {
$listDomainsResult = $response->getListDomainsResult();
$domainNameList = $listDomainsResult->getDomainName();
foreach ($domainNameList as $domainName) {
$data[] = $domainName;
}
}
return $data;
}
public function getDomainData($d)
{
$request = new Amazon_SimpleDB_Model_QueryWithAttributesRequest();
$request->setDomainName($d);
$response = $this->service->queryWithAttributes($request);
$data = array();
if ($response->isSetQueryWithAttributesResult()) {
$queryWithAttributesResult = $response->getQueryWithAttributesResult();
$itemList = $queryWithAttributesResult->getItem();
foreach ($itemList as $item) {
$attributeList = $item->getAttribute();
foreach ($attributeList as $attribute) {
$attribs[$attribute->getName()] = $attribute->getValue();
}
$data[] = array($item->getName() => $attribs);
$attribs = "";
}
return $data;
}
}
Note : replace #Add a pre here# by the pre tag in html.
Labels:
Amazon,
simpleDB,
zend framework
Monday, November 17, 2008
View helpers don't help when bugs
If there's somewhere a mystery bug contest I'm probably winning the race. Here's a new one : try to get a view helper to work with javascript.
Anyone has a solution ?
Here's my unworking code :
class Zend_View_Helper_Loginbox extends Zend_View_Helper_Partial
{
public function loginbox()
{
$this->view->headScript()->appendFile('/scripts/js/myfile.js');
// this doesn't work, the file never gets included
$this->view->dojo()->javascriptCaptureStart();
// neigher the content of my javascript function after this
?>
dojo.addOnLoad(function(){
alert("it s working");
});
$this->view->dojo()->javascriptCaptureEnd(); ?>
test
Javascript never get to be on the client server. Any idea why ?
Labels:
died from bugs,
javascript,
view helper
Friday, November 7, 2008
Writing your authentication provider with Zend framework
One fun thing with Zend framework is to build your own authentication provider. It's needed for exemple if you do not plan to use a database or if you want to use a highly secure authentication provider like a smartcard, or a one time pad.
In that scenario you might want to use authentication via a webservice to make sure your servers a in different compartiments.
Here's the base of a simple authentication provider :
class MyAuthenticationAdapter implements Zend_Auth_Adapter_Interface
{
private $email ;
private $password;
public function __construct($email,$password)
{
$this->email = $email;
$this->password = $password;
}
public function authenticate()
{
$Users = new Users();
if($Users->Authenticate($this->email, $this->password))
$authResult['code'] = Zend_Auth_Result::SUCCESS;
else
$authResult['code'] = Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND;
return new Zend_Auth_Result($authResult['code'],$this->email);
}
}
Not so hard after all !
More bugs - about a dojo form in a placeholder
Zend framework is a big thing and takes time to learn. Today I found another problem I don't know how to solve, it's about sending a dojo form in a placeholder located in my layout.
The form is a simple login form that works fine. However when I try to put it in the placeholder the form shows but without dojo applying to it.
Here's an extract :
This doesn't work, on index.phtml :
$login = new Login();
$this->placeholder('loginbox')->set($login);
Here's the target in my layout file :
placeholder('loginbox'); ?>
However this works fine in the index.phtml :
$login = new Login(); echo $login ;Damn !
Monday, October 6, 2008
Zend Json Server and dojo JsonRestService big, big hadache...
It's very unclear, both in the Zend documentation and the Dojo one, how it is possible to order a JsonRest server (the Zend one while we're at it!) to reply to JsonRest client (dojo...). I've tryied to make this happen for 2 days now...
Here's the client side :
dojo.addOnLoad(function(){
store = new dojox.data.JsonRestStore({target:"/test/m"});
var newItem = store.newItem(
{
post_id: 123
});
store.save();
(...)
Then, on the server side :
x First modify the router :
$route = new Zend_Controller_Router_Route('test/m/:id/*', array('controller'=>'test', 'action'=>'m'));
$front->getRouter()->addRoute('test', $route);
x Then add a a function in a custom class :
/*
* returns hello world
* @return string
*
*/
public static function addmyitem($item){
// custom code
return "Item added";
}
=> But, how am I supposed to map this function to the action controller in order to reply to the Rest POST request dojo is executing ???
That's not getting me anywhere...
// Disable auto-rendering and layouts
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout(true);
$id = $this->getRequest()->getParam('id');
$server = new Zend_Json_Server();
$server->setClass('RpcTest');
if('GET' == $_SERVER['REQUEST_METHOD']){
$server->setTarget('/test/m')
->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
$smd->setDojoCompatible(true);
header('Content-Type: application/json');
echo $smd;
return;
}
$server->handle();
Finally I'm questionning the use of the Zend Json server : would'nt it be simpler to get rid of the server and directly reply using :
if('GET' == $_SERVER['REQUEST_METHOD']){
$data = get_item_data_by_id($this->getRequest()->getParam('id'));
sendToJson($data);
}
Now : how are we supposed to make this work ?
Labels:
dojo,
json,
json server,
jsonRestserver
Subscribe to:
Posts (Atom)