--- /dev/null
+<?php
+global $BASE_URLS, $MENU_ITEMS, $GLOBAL_BASE_URL;
+
+$BASE_URLS["ds"]["base"] = "ds"; // ap for apt-proxy
+$BASE_URLS["ds"]["function"] = "ds_contentUrls"; // the page builder function for us
+
+// the datastore post url
+$BASE_URLS["dsp"]["base"] = "dsp"; // ap for apt-proxy
+$BASE_URLS["dsp"]["function"] = "ds_contentPostUrls"; // the page builder function for us
+
+$MENU_ITEMS["ds"]["title"] = "DataStores";
+$MENU_ITEMS["ds"]["link"] = "/ds/control";
+
+
+function ds_contentPostUrls()
+{
+ $calls["needs_base_page"] = false;
+ $calls["page_builder"] = "ds_postContent";
+
+ return $calls;
+}
+
+function ds_postContent()
+{
+ global $URL_COMPONENTS;
+ $call = $URL_COMPONENTS[1];
+
+ switch($call) {
+ case "createds":
+ $dsname = $_REQUEST["dsname"];
+ $dsloc = $_REQUEST["dsloc"];
+ ds_createDS($dsname, $dsloc);
+ msg_addMessage("#008800", "DataStore, $dsname created at $dsloc");
+ break;
+ }
+
+ $loc = urlCreate("/ds/control");
+ header("Location: $loc");
+
+ return 0;
+
+}
+
+function ds_contentPane()
+{
+ global $URL_COMPONENTS;
+ if(isset($URL_COMPONENTS[1])) {
+ switch($URL_COMPONENTS[1]) {
+ case "browse":
+ $dsbr = $URL_COMPONENTS[2];
+ echo "<h3>Browsing, $dsbr</h3><br>";
+ break;
+ case "createds":
+ ds_createDS($_REQUEST["dsname"], $_REQUEST["dsloc"]);
+ echo "DS Created, <a href=\"".urlCreate("/ds/control")."\">return</a>";
+ break;
+ case "control":
+ default:
+ ds_controlPane();
+ // go thru the db and list the components
+ }
+ }
+}
+
+function ds_controlPane()
+{
+ global $GLOBAL_BASE_URL;
+ echo "<h3>DataStores</h3>";
+ $dss = ds_listDS();
+
+ if($dss != false) {
+ echo "<table border=1>";
+ echo "<tr><td>DataStore Name</td><td>DataStore Path</td><td>Size</td><td>Usage</td><td>Control</td></tr>";
+ foreach($dss as $dsl) {
+ $dsname = $dsl["dsname"];
+ $dspath = $dsl["dslocation"];
+ echo "<tr><td>$dsname</td><td>$dspath</td></tr>";
+ }
+ echo "</table>";
+ }
+ echo "<h3>Create DataStore</h3>";
+ echo "<form method=\"post\" action=\"".urlCreate("/dsp/createds")."\">";
+ echo "DataStore Name: <input type=\"text\" name=\"dsname\"><br>";
+ echo "DataStore Location: <input type=\"text\" name=\"dsloc\"><br>";
+ echo "<input type=\"submit\" name=\"create\" value=\"create\">";
+ echo "</form>";
+
+}
+
+function ds_leftMenu()
+{
+ global $GLOBAL_BASE_URL;
+ echo "<h3>Browse</h3>";
+ $dss = ds_listDS();
+ //echo "<pre>";
+ //print_r($dss);
+ //echo "</pre>";
+ foreach ($dss as $dsl) {
+ $dsname = $dsl["dsname"];
+ echo "<a href=\"".urlCreate("/ds/browse/$dsname")."\">$dsname</a><br>";
+ }
+}
+
+function ds_contentUrls()
+{
+ $calls["needs_base_page"] = true;
+ $calls["content_pane_function"] = "ds_contentPane";
+ $calls["left_menu_function"] = "ds_leftMenu";
+
+ return $calls;
+}
+
+function ds_createDS($ds_name, $store_location)
+{
+ db_createTable("datastores", "dsname", "dslocation");
+ db_createTable("datastores_files", "dsname", "fileowner", "filename", "dsfname");
+
+ $data = db_selectData("datastores", "dsname", "$ds_name");
+ if(isset($data[0]["dsname"])) return false;
+
+ db_insertData("datastores", "$ds_name", "$store_location");
+}
+
+function ds_listDS()
+{
+ return db_selectData("datastores");
+}
+
+function ds_deleteFile($ds_name, $file_name, $file_tag)
+{
+ $dlk = db_selectData("datastores_files", "filename", $file_name);
+ $afname = "";
+ foreach($dlk as $kmm) {
+ if($kmm["fileowner"] == $file_tag) {
+ // we got ya
+ $afname = $kmm["dsfname"];
+ if(file_exists($afname)) unlink($afname);
+ //echo "name was: $afname\n";
+ }
+ }
+ //echo "now delete name was: $afname\n";
+ if($afname != "") db_deleteData("datastores_files", "dsfname", $afname);
+}
+
+// returns a file name to the location a file can be created
+function ds_fileds($ds_name, $file_name, $file_tag)
+{
+
+ $data = db_selectData("datastores", "dsname", "$ds_name");
+
+ $dtime = time();
+ $made_file_name = "$dtime-".md5($file_name)."-".basename($file_name);
+
+ $act_fname = $data[0]["dslocation"]."/".basename($made_file_name);
+
+ db_insertData("datastores_files", "$ds_name", "$file_tag", "$file_name", "$act_fname");
+
+ return $act_fname;
+}
+
+function ds_getFileList($ds_name, $file_tag)
+{
+ $list = db_selectData("datastores_files", "fileowner", "$file_tag");
+
+ return $list;
+}
+
+
+function ds_deleteDS($ds_name)
+{
+ db_deleteData("datastores", "dsname", "$ds_name");
+ db_deleteData("datastores_files", "dsname", $ds_name);
+}
+
+function ds_downloadAndStore($ds_name, $file_id, $file_name, $file_url)
+{
+
+}
+
+?>
\ No newline at end of file