I've seen blocks of code like this
use Win32::OLE;
my $Notes = Win32::OLE->new('Notes.NotesSession')
or die "Cannot start Lotus Notes Session object.\n";
my $database = $Notes->GetDatabase("",'mail\VIMM.nsf');
but my script is running on a virtual webfusion apache service so how do you establish a connection to database on my domino server, I have control of its acl and its a website so can pass in a username & password. The script & 'POST' data is sent by a third party gateway with results of the transaction (Success/ Fail + name value pairs etc) which I need to capture. I can't do it directly on the domino server because although Domino supports PERL scripts, they will only work if PERL is also installed on the server which isn't an option.
Lotus Domino is also a web application server so you can communicate with the server using HTTP (GET and POST) from your perl script on the Apache server.
This might require changes to the Domino application in question in order for it to serve the content you expect.
Also, you can provide a WebService on your Domino Server.
For OLE/COM to work, Perl and the script have to be located on a server where Notes and/or Domino are installed. Otherwise, the OLE/COM classes are not installed and not available.
As Per and Klaus mentioned, if you can't put Notes/Domino on the machine with Perl on it, you have to switch to some sort of webbased communication.
If you are not limited to COM/OLE, you could use the IBM Lotus Domino Data Service, which is new in Domino Designer 8.5.3 Upgrade Pack 1:
The IBM® Lotus® Domino® Data Service is a REST API that accesses
databases on Domino servers. It is part of Domino Access Services.
The Domino Data Service receives requests and sends responses using
HTTP and HTTPS protocols with body content in JSON format.
The Domino Data Service allows you to obtain information on databases,
views, folders, and documents. You can update, add, and delete
documents.
The underlying problem is that a url such as http://www.mysite.com/thankyou?orderno=123 won't work in a Lotus Domino website because the ? is a special character (eg ?openagent, ?opendatabase) to the Domino web engine. You also can't use http://www.mysite.com/(thankyou)?openagent?orderno=456 (I tried), in both cases all you get is 404 page not found error and a domino log error "don't understand the url". The question was originally asking for help with Perl to solve the problem but I couldn't Perl scripts to run on my webfusion community server but fortunately quickly had success with this simple php script:
<?php
$params = "";
$url = "http://www.mywebsite.co.uk/";
$path = "wpx/website.nsf/httpagent?openagent";
if($_GET) {
$kv = array();
foreach ($_GET as $key => $value) {
$kv[] = "$key=$value";
}
$params = join("&", $kv);
}
print "<script>window.location.href=\"" . $url . $path . "&" . $params . "\"</script>";
?>
The script is placed on my webfusion server under a subdomain which effectively translates the url into a format that Domino can handle, the format ?openagent&orderno=456 is easily handled by either a java or Lotusscript agent, the parameter is extracted from the CGI Request_Content field.
The redirect means I don't for now need to manipulate data in the domino database directly, it also means that with the exception of the url translation script all the website code is in the domino database.
Related
$output = file_get_contents("http://www.canadapost.ca/cpc2/addrm/hh/current/indexa/caONu-e.asp");
var_dump($output);
HTTP 505 Status means the webserver does not support the HTTP version used by the client (in this case, your PHP program).
What version of PHP are you running, and what HTTP/Web package(s) are you using in your PHP program?
[edit...]
Some servers deliberately block some browsers -- your code may "look like" a browser that the server is configured to ignore. I would particularly check the user agent string that your code is passing along to the server.
Check in your PHP installation (php.ini file) if the allow_url_fopen is enabled.
If not, any calls to file_get_contents will fail.
It works fine for me.
That site could be blocking the server that you're using to access it.
When you run the URL from your browser, your own ISP is used to get the information and display in your browser. But when you run from PHP, the ISP of your web host is used to get the information, then it passes it back to you.
Maybe you can do this to check and see what kind of headers its returning for you?
$headers=get_headers("http://www.canadapost.ca/cpc2/addrm/hh/current/indexa/caONu-e.asp");
print_r($headers);
I'm trying to get around an access control origin error for a web service by building a local proxy, but I'm not sure how to do it. The web service looks like the attached file, and is accessed directly by using the following URL:
https://url.com/SparkService.asmx?op=InsertConsumer
How would I write something locally that carried out this URL's functionality?
I built a PHP file that will pull the web service URLs contents, but it doesn't seem to carry out the functionality of that web service:
<?php
$op = htmlspecialchars($_GET["op"]);
$proxyURL = 'https://url.com/SparkService.asmx?op=' . $op;
die( file_get_contents($proxyURL) );
?>
The image shows you have to use a POST, which you can't do with bare-bones file_get_contents - it defaults to using a GET query. You'll have to use CURL, or set up a stream to configure and perform a POST.
I am not sure about your intension of doing this.
you can use WSO2 ESB proxy[1] to send messages to the real service through a local end point.
Or else you can create your own service by using WSO2 AS[2] and deploying a sample POJO as a web service.
[1] http://wso2.org/project/esb/java/4.0.0/docs/samples/proxy_samples.html
[2] http://wso2.org/project/app-server/
I am trying to get my head round node.js...
I am very happy with my LAMP set up as it currently fulfils my requirements. Although I want to add some real-time features into my PHP app. Such as showing all users currently logged into my site and possible chat features.
I don't want to replace my PHP backend, but I do want scalable real-time solutions.
1. Can I throw node.js into the mix to serve my needs without rebuilding the whole application server-side script?
2. How best could node.js serve my 'chat' and 'currently logged in' features?
Great to hear your views!
W.
I suggest you use Socket.io along side node.js. Install and download the libs from http://socket.io/. You can run it along side your Apache server no problems.
First create a node server:
var http = require('http')
, url = require('url')
, fs = require('fs')
, io = require('../')//path to your socket.io lib
, sys = require(process.binding('natives').util ? 'util' : 'sys')
, server;
server = http.createServer(function(req, res){
var path = url.parse(req.url).pathname;
}),
server.listen(8084);//This could be almost any port number
Second, run your server from the command line using:
node /path/to/your/server.js
Third, connect to the socket using client side js:
var socket = new io.Socket(null, {port: 8084, rememberTransport: false});
socket.connect();
You will have to have include the socket.io lib client side aswell.
Send data from client side to the node server using:
socket.send({data:data});
Your server.js should also have functions for processing requests:
io.on('connection', function(client){
//action when client connets
client.on('message', function(message){
//action when client sends msg
});
client.on('disconnect', function(){
//action when client disconnects
});
});
There are two main ways to send data from the server to the client:
client.send({ data: data});//sends it back to the client making the request
and
client.broadcast({ data: data});//sends it too every client connected to the server
I suspect the chat as well as the logged in listing would work via Ajax.
The chat part would be pretty easy to program in Node.js, use one of the mysql modules for Node to connect to your existing database and query login information and such and then do all the actual chatting via Node.js, I recommend you to check out Socket.io since it makes Browser/Node.js communcation really trivial, this should allow you to focus on the actual chat logic.
Also, you could take a look at the "official" chat demo of Node.js, for some inspiration.
As far as the currently online part goes, this is never easy to implement since all you can do is to display something along the lines of "5 users active in the last X minutes".
Of course you could easily add some Ajax that queries the chat server and display the userlist from that on the homepage.
Or you completely crazy and establish a Socket.io connection for every visitor and monitor it this way, although it's questionable whether this is worth the effort.
What about using a socket file
just like pedro did with ngnx ?
http://nodetuts.com/tutorials/25-nginx-and-nodejs.html
You can run php from node js using node-php: https://github.com/mkschreder/siteboot_php
I'm running a wss (secure websocket) server alongside my LAMP setup.
Node.js can easily run alongside any other web server (apache) you want. In #KitCarrau example, he lets node run on port 8084 - that's where it's running and listening to, not 80 or 443 etc (those are usually taken by apache anyway). But you can still use the same port to also serve http/https (in my case just stating some conf and general info that the service is up).
Starting from the console isn't the best way (remotely, node stops when closing the console).
I recommend taking a look at Running node as service
Easy to track log in realtime (log with console.log("hello"); in your application) with:
tail -f /var/.../SocketServer.log
Sample script (node-server.conf):
author ....
description "node.js server"
# used to be: start on startup
# until we found some mounts weren't ready yet while booting:
start on started mountall
stop on shutdown
# Automatically Respawn:
respawn
respawn limit 99 5
# Max open files are # 1024 by default. Bit few.
limit nofile 32768 32768
script
# Not sure why $HOME is needed, but we found that it is:
export HOME="/root"
exec node /var/.../SocketServer.js >> /var/www/node/.../SocketServer.log 2>&1
end script
post-start script
# Optionally put a script here that will notifiy you node has (re)started
# /root/bin/hoptoad.sh "node.js has started!"
echo "\n*********\nServer started\n$(date)\n*********" >> /var/.../SocketServer.log
end script
I am running a socket server using PHP. The socket server runs fine because I can connect to it using PHP.
Now, I have a flash application that is trying to connect to it:
this.socket.addEventListener(Event.CONNECT, onSocketConnect);
this.socket.addEventListener(Event.CLOSE, onSocketClose);
this.socket.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
this.socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecError);
try {
this.socket.connect("myip", 9999);
} catch (ioError:IOError) {
this.debugLbl.text += "ioError1 "+ioError.message;
} catch (secError:SecurityError) {
this.debugLbl.text += "secError1 "+secError.message;
}
When I run the application locally, it works! However, when I upload it to my server I get a sandbox security error (#2048). The flash app is actually hosted on the same server as the socket server, and there is cross domain policy file in place.
Is it possibly you need to use a php proxy? I had to do that, doc'd it here. Although you did mention that the app's on the same server and theres a crossdomain.xml in place, so i'm probably off the mark there (btw, Flash 10 needs a different crossdomain.xml than prev versions as far as I know).
Are you actually loading the cross domain policy file? As far as I know, Flash Player only tries to load automatically the following file: http://www.example.com/crossdomain.xml. If your file is in another place, you should load it:
Security.loadPolicyFile("http://www.example.com/subfolder/crossdomain.xml");
Also, even if the app is on the same server, Flash Player believes "http://www.example.com" to be different from "http://example.com", so you should make sure you cover this possibility in the cross domain policy file:
<allow-access-from domain="*.example.com"/>
You need to pass the crossdomain.xml file by the socket, because when you work with socket dont work any policy file in the root of the app web.
Here the sample : http://www.blog.lessrain.com/as3-java-socket-connections-to-ports-below-1024/
I have scripts that use the $_SERVER["LOGON_USER"] which is obtained on my servers through IIS authentication settings. I want this same variable to contain my domain\username when running locally, or at least to have a way to set it when I fire up the PHP built-in server on localhost.
How can I configure PHP on my machine to obtain and fill this variable the same way it does when running through IIS?
PS: I have seen this question, but the answer addresses $_ENV, not $_SERVER.
This is a workaround, if anyone has a better/proper solution (i.e. enabling NTLM), please post it as an answer and I'll accept it.
I was able to fill that variable using a router script. According to the docs, this script is run at the start of each HTTP request, so I use it to set this variable when running locally.
Also in my case, my environment had these two variables set, USERDOMAIN and USERNAME, so I used them to form the LOGON_USER server variable.
routerCredentials.php
<?php
$_SERVER["LOGON_USER"] = getenv("USERDOMAIN") . "\\" . getenv("USERNAME");
return false; // serve the requested resource as-is.
To use it, you just have to point to that file when you start the PHP built-in server:
php -S localhost:8000 "c:\somepath\routerCredentials.php"