coliut-svncommit Mailing List for Command Line Utility
Status: Planning
Brought to you by:
ronaldmaas
You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(7) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|---|
|
From: <ron...@us...> - 2008-06-24 09:34:37
|
Revision: 8
http://coliut.svn.sourceforge.net/coliut/?rev=8&view=rev
Author: ronaldmaas
Date: 2008-06-24 02:27:14 -0700 (Tue, 24 Jun 2008)
Log Message:
-----------
Added include file to contain all functions.
Changed main script to include the include files and remove the functions.
Modified Paths:
--------------
web/coliut.php
Added Paths:
-----------
web/coliut.inc.php
Added: web/coliut.inc.php
===================================================================
--- web/coliut.inc.php (rev 0)
+++ web/coliut.inc.php 2008-06-24 09:27:14 UTC (rev 8)
@@ -0,0 +1,62 @@
+<?php
+// Webserver include PHP script to process the requests from the coliut client
+//
+// Copyright (C) 2008 Ronald Maas <ron...@us...>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+function coliut_login() {
+ global $session_id;
+
+ $username = $_POST['username'];
+ $password = $_POST['password'];
+
+ if (($username == 'ronald') && ($password == 'secret')) {
+ $resp = 'result=OK&session_id=' . $session_id;
+ } else {
+ $resp = 'result=Error&message=' . urlencode('Invalid login details');
+ }
+
+ return $resp;
+}
+
+function coliut_logout() {
+ global $session_id;
+
+ $username = $_POST['username'];
+ $sess_id = $_POST['session_id'];
+
+ if (($user_name == 'ronald') && ($sess_id == $session_id)) {
+ $resp = 'result=OK';
+ } else {
+ $resp = 'result=Error&message=' . urlencode('Invalid logout');
+ }
+
+ return $resp;
+}
+
+function coliut_list() {
+ $resp = 'result=Error&message=' . urlencode('List not implemented......yet');
+
+ return $resp;
+}
+
+function coliut_default() {
+ $resp = 'result=Error&message=' . urlencode('Method not implemented');
+
+ return $resp;
+}
+
+?>
Modified: web/coliut.php
===================================================================
--- web/coliut.php 2008-05-26 11:42:56 UTC (rev 7)
+++ web/coliut.php 2008-06-24 09:27:14 UTC (rev 8)
@@ -19,6 +19,8 @@
header('Content-type: text/plain');
+require_once('coliut.inc.php');
+
$session_id = '495834905acbdef';
$action = $_POST['action'];
@@ -40,46 +42,4 @@
print($response);
-function coliut_login() {
- global $session_id;
-
- $username = $_POST['username'];
- $password = $_POST['password'];
-
- if (($username == 'ronald') && ($password == 'secret')) {
- $resp = 'result=OK&session_id=' . $session_id;
- } else {
- $resp = 'result=Error&message=' . urlencode('Invalid login details');
- }
-
- return $resp;
-}
-
-function coliut_logout() {
- global $session_id;
-
- $username = $_POST['username'];
- $sess_id = $_POST['session_id'];
-
- if (($user_name == 'ronald') && ($sess_id == $session_id)) {
- $resp = 'result=OK';
- } else {
- $resp = 'result=Error&message=' . urlencode('Invalid logout');
- }
-
- return $resp;
-}
-
-function coliut_list() {
- $resp = 'result=Error&message=' . urlencode('List not implemented......yet');
-
- return $resp;
-}
-
-function coliut_default() {
- $resp = 'result=Error&message=' . urlencode('Method not implemented');
-
- return $resp;
-}
-
?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ron...@us...> - 2008-05-26 11:43:01
|
Revision: 7
http://coliut.svn.sourceforge.net/coliut/?rev=7&view=rev
Author: ronaldmaas
Date: 2008-05-26 04:42:56 -0700 (Mon, 26 May 2008)
Log Message:
-----------
Intermediate parser commit
Modified Paths:
--------------
client/Coliut.java
client/ColiutParser.java
Modified: client/Coliut.java
===================================================================
--- client/Coliut.java 2008-05-26 10:26:54 UTC (rev 6)
+++ client/Coliut.java 2008-05-26 11:42:56 UTC (rev 7)
@@ -19,6 +19,14 @@
public class Coliut
{
+ public static void displayStringArray(String[] string)
+ {
+ for (int i=0; i < string.length; i++)
+ {
+ System.out.println(string[i]);
+ }
+ }
+
public static void main(String[] args)
{
// Get webserver properties
@@ -32,21 +40,65 @@
System.out.println(port);
ColiutSocket cs = new ColiutSocket(servername, documentname, port);
+/*
String response = cs.getData("action=login&username=ronald&password=secrets");
System.out.println(response);
String response2 = cs.getData("action=logout");
System.out.println(response2);
+*/
- String[] rxm1 = ColiutParser.getParsedString(response, "&");
- for (int i=0; i < rxm1.length; i++)
+ String test = "result=OK&"
+ + "message="
+ + "menu:login@exit;"
+ + "desc:Log+On@Exit;"
+ + "param:username#password@;"
+ + "menu_id:1@x";
+
+// String test = "result=Error&"
+// + "message=Invalid+address";
+
+ System.out.println(test);
+ ColiutParser parser = new ColiutParser();
+ parser.parseString(test);
+ if (parser.isError())
{
- String[] rxm2 = ColiutParser.getParsedString(rxm1[i], "=");
- System.out.println(rxm1[i]);
- for (int j=0; j < rxm2.length; j++)
+ System.out.println(parser.getErrorMessage());
+ }
+ else
+ {
+ int choice = -1;
+ while (choice == -1)
{
- System.out.println(rxm2[j]);
+ parser.displayMenu();
+// parser.resetDescItems();
+// while (parser.hasMoreDescItems())
+// {
+// System.out.println(parser.nextDescItem());
+// }
+// System.out.println("");
+ String rxm1 = parser.getMenuChoice();
+ choice = parser.getChoiceIndex(rxm1);
}
+
+ String menuChoice = parser.getMenu(choice);
+ String paramChoice = parser.getParam(choice);
+ System.out.println(menuChoice);
+ System.out.println(paramChoice);
+
+ String[] param = paramChoice.split("#", 20);
+ displayStringArray(param);
+ String rxm = "action=" + menuChoice;
+ for (int i = 0; i < param.length; i++)
+ {
+ String response = ColiutInput.getInput("Enter " + param[i]);
+ rxm = rxm + "&" + param[i] + "=" + response;
+ }
+ System.out.println(rxm);
+
+ String response = cs.getData(rxm);
+ System.out.println(response);
}
+
}
}
Modified: client/ColiutParser.java
===================================================================
--- client/ColiutParser.java 2008-05-26 10:26:54 UTC (rev 6)
+++ client/ColiutParser.java 2008-05-26 11:42:56 UTC (rev 7)
@@ -16,12 +16,182 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
+import java.net.*;
+import java.io.*;
+
public class ColiutParser
{
+ private String result;
+ private String message;
+
+ private String[] menu;
+
+ private String[] desc;
+ private int currentDescItem;
+ private int maxDescItem;
+
+ private String[] param;
+
+ private String[] menuId;
+
+ public ColiutParser()
+ {
+ currentDescItem = 0;
+ maxDescItem = 0;
+ }
+
public static String[] getParsedString(String string, String delimiter)
{
return string.split(delimiter);
}
+
+//String test = "result=OK&"
+//+ "message="
+//+ "menu:login@exit;"
+//+ "desc:Log+On@Exit;"
+//+ "param:username#password@;"
+//+ "menu_id:1@x";
+
+ public void parseString(String input)
+ {
+ String[] tempParsed;
+ String[] tempResult;
+ String[] tempMessage;
+ String[] tempCommands;
+ String[] tempMenu;
+ String[] tempDesc;
+ String[] tempParam;
+ String[] tempMenuId;
+
+ try
+ {
+ tempParsed = input.split("&");
+ tempResult = tempParsed[0].split("=");
+ tempMessage = tempParsed[1].split("=");
+ this.result = tempResult[1];
+ this.message = URLDecoder.decode(tempMessage[1], "UTF-8");
+
+ if (!isError())
+ {
+ tempCommands = tempMessage[1].split(";");
+ tempMenu = tempCommands[0].split(":");
+ this.menu = tempMenu[1].split("@", 20);
+
+ tempDesc = tempCommands[1].split(":");
+ this.desc = tempDesc[1].split("@", 20);
+ maxDescItem = this.desc.length;
+ for (int i = 0; i < maxDescItem; i++)
+ {
+ this.desc[i] = URLDecoder.decode(this.desc[i], "UTF-8");
+ }
+
+ tempParam = tempCommands[2].split(":");
+ this.param = tempParam[1].split("@", 20);
+
+ tempMenuId = tempCommands[3].split(":");
+ this.menuId = tempMenuId[1].split("@", 20);
+ }
+ }
+ catch (UnsupportedEncodingException ex)
+ {
+ System.out.println("Unsupported Encoding of UTF-8");
+ System.exit(1);
+ }
+ }
+
+ public boolean isError()
+ {
+ if (this.result.equals("OK"))
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ public String getErrorMessage()
+ {
+ if (this.isError())
+ {
+ return this.message;
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+ public void displayMenu()
+ {
+ for (int i = 0; i < this.desc.length; i++)
+ {
+ System.out.println(this.menuId[i] + ". " + this.desc[i]);
+ }
+ System.out.println("");
+ }
+
+ public String getMenuChoice()
+ {
+ String choice;
+ choice = ColiutInput.getInput("Enter choice");
+ return choice;
+ }
+
+ public String nextDescItem()
+ {
+ String descItem;
+ if (hasMoreDescItems())
+ {
+ descItem = this.menuId[this.currentDescItem] + ". " + this.desc[this.currentDescItem];
+ this.currentDescItem = this.currentDescItem + 1;
+ }
+ else
+ {
+ descItem = "";
+ }
+ return descItem;
+ }
+
+ public void resetDescItems()
+ {
+ this.currentDescItem = 0;
+ }
+
+ public boolean hasMoreDescItems()
+ {
+ if (this.currentDescItem >= this.maxDescItem)
+ return false;
+ else
+ return true;
+ }
+
+ public int getChoiceIndex(String choice)
+ {
+ int menuItem = -1;
+
+ for (int i = 0; i < this.menuId.length; i++)
+ {
+ if (this.menuId[i].equals(choice))
+ {
+ menuItem = i;
+ }
+ }
+
+ return menuItem;
+ }
+
+ public String getMenu(int menuItem)
+ {
+ return this.menu[menuItem];
+ }
+
+ public String getParam(int menuItem)
+ {
+ return this.param[menuItem];
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ron...@us...> - 2008-05-26 10:26:55
|
Revision: 6
http://coliut.svn.sourceforge.net/coliut/?rev=6&view=rev
Author: ronaldmaas
Date: 2008-05-26 03:26:54 -0700 (Mon, 26 May 2008)
Log Message:
-----------
Refine exception handling
Modified Paths:
--------------
client/ColiutInput.java
Modified: client/ColiutInput.java
===================================================================
--- client/ColiutInput.java 2008-05-24 12:34:43 UTC (rev 5)
+++ client/ColiutInput.java 2008-05-26 10:26:54 UTC (rev 6)
@@ -30,7 +30,7 @@
try
{
input = in.readLine();
- } catch (Exception ex)
+ } catch (IOException ex)
{
input = "";
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ron...@us...> - 2008-05-24 12:34:47
|
Revision: 5
http://coliut.svn.sourceforge.net/coliut/?rev=5&view=rev
Author: ronaldmaas
Date: 2008-05-24 05:34:43 -0700 (Sat, 24 May 2008)
Log Message:
-----------
Add coliut input class
Added Paths:
-----------
client/ColiutInput.java
Added: client/ColiutInput.java
===================================================================
--- client/ColiutInput.java (rev 0)
+++ client/ColiutInput.java 2008-05-24 12:34:43 UTC (rev 5)
@@ -0,0 +1,40 @@
+// Class to read a string from the input
+//
+// Copyright (C) 2008 Ronald Maas <ron...@us...>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+import java.io.*;
+
+public class ColiutInput
+{
+
+ public static String getInput(String prompt)
+ {
+ BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+ String input;
+
+ System.out.print(prompt + ": ");
+ try
+ {
+ input = in.readLine();
+ } catch (Exception ex)
+ {
+ input = "";
+ }
+ return input;
+ }
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ron...@us...> - 2008-05-19 21:09:23
|
Revision: 4
http://coliut.svn.sourceforge.net/coliut/?rev=4&view=rev
Author: ronaldmaas
Date: 2008-05-19 14:09:11 -0700 (Mon, 19 May 2008)
Log Message:
-----------
Add initial parser
Modified Paths:
--------------
client/Coliut.java
Added Paths:
-----------
client/ColiutParser.java
Modified: client/Coliut.java
===================================================================
--- client/Coliut.java 2008-05-17 20:39:36 UTC (rev 3)
+++ client/Coliut.java 2008-05-19 21:09:11 UTC (rev 4)
@@ -32,10 +32,21 @@
System.out.println(port);
ColiutSocket cs = new ColiutSocket(servername, documentname, port);
- String response = cs.getData("action=login&username=ronald&password=secret");
+ String response = cs.getData("action=login&username=ronald&password=secrets");
System.out.println(response);
String response2 = cs.getData("action=logout");
System.out.println(response2);
+
+ String[] rxm1 = ColiutParser.getParsedString(response, "&");
+ for (int i=0; i < rxm1.length; i++)
+ {
+ String[] rxm2 = ColiutParser.getParsedString(rxm1[i], "=");
+ System.out.println(rxm1[i]);
+ for (int j=0; j < rxm2.length; j++)
+ {
+ System.out.println(rxm2[j]);
+ }
+ }
}
}
Added: client/ColiutParser.java
===================================================================
--- client/ColiutParser.java (rev 0)
+++ client/ColiutParser.java 2008-05-19 21:09:11 UTC (rev 4)
@@ -0,0 +1,27 @@
+// Class to perform string parsing
+//
+// Copyright (C) 2008 Ronald Maas <ron...@us...>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+public class ColiutParser
+{
+
+ public static String[] getParsedString(String string, String delimiter)
+ {
+ return string.split(delimiter);
+ }
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ron...@us...> - 2008-05-17 20:39:55
|
Revision: 3
http://coliut.svn.sourceforge.net/coliut/?rev=3&view=rev
Author: ronaldmaas
Date: 2008-05-17 13:39:36 -0700 (Sat, 17 May 2008)
Log Message:
-----------
Add properties file and processing
Modified Paths:
--------------
client/Coliut.java
Added Paths:
-----------
client/ColiutProperties.java
client/coliut.properties
Modified: client/Coliut.java
===================================================================
--- client/Coliut.java 2008-05-17 12:22:05 UTC (rev 2)
+++ client/Coliut.java 2008-05-17 20:39:36 UTC (rev 3)
@@ -21,7 +21,17 @@
public static void main(String[] args)
{
- ColiutSocket cs = new ColiutSocket("coliut.sourceforge.net", "/coliut/coliut.php", 80);
+ // Get webserver properties
+ ColiutProperties cp = new ColiutProperties();
+ String servername = cp.getProperty("servername");
+ String documentname = cp.getProperty("documentname");
+ int port = Integer.parseInt(cp.getProperty("port"));
+
+ System.out.println(servername);
+ System.out.println(documentname);
+ System.out.println(port);
+
+ ColiutSocket cs = new ColiutSocket(servername, documentname, port);
String response = cs.getData("action=login&username=ronald&password=secret");
System.out.println(response);
String response2 = cs.getData("action=logout");
Added: client/ColiutProperties.java
===================================================================
--- client/ColiutProperties.java (rev 0)
+++ client/ColiutProperties.java 2008-05-17 20:39:36 UTC (rev 3)
@@ -0,0 +1,64 @@
+// Class to read the coliut properties
+//
+// Copyright (C) 2008 Ronald Maas <ron...@us...>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+/**
+ * The ColiutProperties class.
+ *
+ * @author Ronald Maas <ron...@us...>
+ * @version 0.1
+ *
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class ColiutProperties
+{
+
+ private Properties properties;
+
+ /**
+ * Class constructor.
+ *
+ */
+
+ public ColiutProperties()
+ {
+ this.properties = new Properties();
+ try {
+ this.properties.load(new FileInputStream("coliut.properties"));
+ } catch (IOException e) {
+ System.out.println("Error on properties load " + e);
+ System.exit(1);
+ }
+ }
+
+ /**
+ * Gets a coliut property.
+ *
+ * @param propertyName The name of the property you're looking for
+ * @return The value of the property you're looking for
+ */
+
+ public String getProperty(String propertyName)
+ {
+ String propertyValue = this.properties.getProperty(propertyName);
+ return propertyValue;
+ }
+
+}
Added: client/coliut.properties
===================================================================
--- client/coliut.properties (rev 0)
+++ client/coliut.properties 2008-05-17 20:39:36 UTC (rev 3)
@@ -0,0 +1,3 @@
+servername=coliut.sourceforge.net
+documentname=/coliut/coliut.php
+port=80
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ron...@us...> - 2008-05-17 12:22:17
|
Revision: 2
http://coliut.svn.sourceforge.net/coliut/?rev=2&view=rev
Author: ronaldmaas
Date: 2008-05-17 05:22:05 -0700 (Sat, 17 May 2008)
Log Message:
-----------
Initial import
Added Paths:
-----------
client/
client/Coliut.java
client/ColiutSocket.java
Added: client/Coliut.java
===================================================================
--- client/Coliut.java (rev 0)
+++ client/Coliut.java 2008-05-17 12:22:05 UTC (rev 2)
@@ -0,0 +1,31 @@
+// Main entry point for the coliut client program
+//
+// Copyright (C) 2008 Ronald Maas <ron...@us...>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+public class Coliut
+{
+
+ public static void main(String[] args)
+ {
+ ColiutSocket cs = new ColiutSocket("coliut.sourceforge.net", "/coliut/coliut.php", 80);
+ String response = cs.getData("action=login&username=ronald&password=secret");
+ System.out.println(response);
+ String response2 = cs.getData("action=logout");
+ System.out.println(response2);
+ }
+
+}
Added: client/ColiutSocket.java
===================================================================
--- client/ColiutSocket.java (rev 0)
+++ client/ColiutSocket.java 2008-05-17 12:22:05 UTC (rev 2)
@@ -0,0 +1,101 @@
+// Class to perform the webserver interaction
+//
+// Copyright (C) 2008 Ronald Maas <ron...@us...>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+/**
+ * The ColiutSocket class.
+ *
+ * @author Ronald Maas <ron...@us...>
+ * @version 0.1
+ *
+ */
+
+import java.net.*;
+import java.io.*;
+
+public class ColiutSocket
+{
+
+ private String server;
+ private String document;
+ private int port;
+
+ /**
+ * Class constructor.
+ *
+ * @param server Name of the server to connect to.
+ * @param document The URL that is to be executed.
+ * @param port The port of server that is used for the connection.
+ */
+
+ public ColiutSocket(String server, String document, int port)
+ {
+ this.server = server;
+ this.document = document;
+ this.port = port;
+ }
+
+ /**
+ * Gets the data from the webserver.
+ *
+ * @param postDocument The document that is to be posted to the webserver.
+ * @return Returns the response string from the webserver.
+ */
+
+ public String getData(String postDocument)
+ {
+ try {
+ Socket s = new Socket(server, port);
+
+ InputStream sin = s.getInputStream();
+ OutputStream sout = s.getOutputStream();
+
+ s.setSoTimeout(10000);
+
+ BufferedReader fromServer = new BufferedReader(new InputStreamReader(sin));
+ PrintWriter toServer = new PrintWriter(new OutputStreamWriter(sout));
+
+ toServer.print("POST " + document + " HTTP/1.1\n");
+ toServer.print("Host: " + server + "\n");
+ toServer.print("Content-Type: application/x-www-form-urlencoded\n");
+ toServer.print("Content-Length: " + postDocument.length() + "\n\n");
+ toServer.print(postDocument + "\n");
+ toServer.flush();
+
+ String resp = "";
+ String string = "";
+ while ((string = fromServer.readLine()) != null)
+ {
+ if (string.startsWith("result="))
+ {
+ resp = resp + string;
+ }
+ }
+
+ toServer.close();
+ fromServer.close();
+ s.close();
+
+ return resp;
+ } catch (Exception e) {
+ return "result=Error&message=" + e;
+ }
+ }
+
+
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ron...@us...> - 2008-05-17 12:21:12
|
Revision: 1
http://coliut.svn.sourceforge.net/coliut/?rev=1&view=rev
Author: ronaldmaas
Date: 2008-05-17 05:21:04 -0700 (Sat, 17 May 2008)
Log Message:
-----------
Initial import
Added Paths:
-----------
web/
web/coliut.php
Added: web/coliut.php
===================================================================
--- web/coliut.php (rev 0)
+++ web/coliut.php 2008-05-17 12:21:04 UTC (rev 1)
@@ -0,0 +1,85 @@
+<?php
+// Webserver main PHP script to process the requests from the coliut client
+//
+// Copyright (C) 2008 Ronald Maas <ron...@us...>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+header('Content-type: text/plain');
+
+$session_id = '495834905acbdef';
+
+$action = $_POST['action'];
+
+switch ($action) {
+ case 'login':
+ $response = coliut_login();
+ break;
+ case 'logout':
+ $response = coliut_logout();
+ break;
+ case 'list':
+ $response = coliut_list();
+ break;
+ default:
+ $response = coliut_default();
+ break;
+}
+
+print($response);
+
+function coliut_login() {
+ global $session_id;
+
+ $username = $_POST['username'];
+ $password = $_POST['password'];
+
+ if (($username == 'ronald') && ($password == 'secret')) {
+ $resp = 'result=OK&session_id=' . $session_id;
+ } else {
+ $resp = 'result=Error&message=' . urlencode('Invalid login details');
+ }
+
+ return $resp;
+}
+
+function coliut_logout() {
+ global $session_id;
+
+ $username = $_POST['username'];
+ $sess_id = $_POST['session_id'];
+
+ if (($user_name == 'ronald') && ($sess_id == $session_id)) {
+ $resp = 'result=OK';
+ } else {
+ $resp = 'result=Error&message=' . urlencode('Invalid logout');
+ }
+
+ return $resp;
+}
+
+function coliut_list() {
+ $resp = 'result=Error&message=' . urlencode('List not implemented......yet');
+
+ return $resp;
+}
+
+function coliut_default() {
+ $resp = 'result=Error&message=' . urlencode('Method not implemented');
+
+ return $resp;
+}
+
+?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|