2 global $BASE_URLS, $MENU_ITEMS, $GLOBAL_BASE_URL;
4 $BASE_URLS["ds"]["base"] = "ds"; // ap for apt-proxy
5 $BASE_URLS["ds"]["function"] = "ds_contentUrls"; // the page builder function for us
6 $MENU_ITEMS["ds"]["title"] = "DataStores";
7 $MENU_ITEMS["ds"]["link"] = "/ds/control";
10 function ds_contentPane()
12 global $URL_COMPONENTS;
13 if(isset($URL_COMPONENTS[1])) {
14 switch($URL_COMPONENTS[1]) {
16 $dsbr = $URL_COMPONENTS[2];
17 echo "<h3>Browsing, $dsbr</h3><br>";
20 ds_createDS($_REQUEST["dsname"], $_REQUEST["dsloc"]);
21 echo "DS Created, <a href=\"".urlCreate("/ds/control")."\">return</a>";
26 // go thru the db and list the components
31 function ds_controlPane()
34 echo "<tr><td>DataStore Name</td><td>DataStore Path</td><td>Size</td><td>Usage</td><td>Control</td></tr>";
37 echo "<form method=\"post\" action=\"".urlCreate("/ds/createds")."\">";
38 echo "DataStore Name: <input type=\"text\" name=\"dsname\">";
39 echo "DataStore Location: <input type=\"text\" name=\"dsloc\">";
40 echo "<input type=\"submit\" name=\"create\" value=\"create\">";
45 function ds_leftMenu()
47 global $GLOBAL_BASE_URL;
48 echo "<b>Browse</b><br>";
53 foreach ($dss as $dsl) {
54 $dsname = $dsl["dsname"];
55 echo "<a href=\"".urlCreate("/ds/browse/$dsname")."\">$dsname</a><br>";
59 function ds_contentUrls()
61 $calls["needs_base_page"] = true;
62 $calls["content_pane_function"] = "ds_contentPane";
63 $calls["left_menu_function"] = "ds_leftMenu";
68 function ds_createDS($ds_name, $store_location)
70 db_createTable("datastores", "dsname", "dslocation");
71 db_createTable("datastores_files", "dsname", "fileowner", "filename", "dsfname");
73 $data = db_selectData("datastores", "dsname", "$ds_name");
74 if(isset($data[0]["dsname"])) return false;
76 db_insertData("datastores", "$ds_name", "$store_location");
81 return db_selectData("datastores");
84 function ds_deleteFile($ds_name, $file_name, $file_tag)
86 $dlk = db_selectData("datastores_files", "filename", $file_name);
88 foreach($dlk as $kmm) {
89 if($kmm["fileowner"] == $file_tag) {
91 $afname = $kmm["dsfname"];
92 if(file_exists($afname)) unlink($afname);
93 //echo "name was: $afname\n";
96 //echo "now delete name was: $afname\n";
97 if($afname != "") db_deleteData("datastores_files", "dsfname", $afname);
100 // returns a file name to the location a file can be created
101 function ds_fileds($ds_name, $file_name, $file_tag)
104 $data = db_selectData("datastores", "dsname", "$ds_name");
107 $made_file_name = "$dtime-".md5($file_name)."-".basename($file_name);
109 $act_fname = $data[0]["dslocation"]."/".basename($made_file_name);
111 db_insertData("datastores_files", "$ds_name", "$file_tag", "$file_name", "$act_fname");
116 function ds_getFileList($ds_name, $file_tag)
118 $list = db_selectData("datastores_files", "fileowner", "$file_tag");
124 function ds_deleteDS($ds_name)
126 db_deleteData("datastores", "dsname", "$ds_name");
127 db_deleteData("datastores_files", "dsname", $ds_name);
130 function ds_downloadAndStore($ds_name, $file_id, $file_name, $file_url)