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
7 // the datastore post url
8 $BASE_URLS["dsp"]["base"] = "dsp"; // ap for apt-proxy
9 $BASE_URLS["dsp"]["function"] = "ds_contentPostUrls"; // the page builder function for us
11 $MENU_ITEMS["ds"]["title"] = "DataStores";
12 $MENU_ITEMS["ds"]["link"] = "/ds/control";
15 function ds_contentPostUrls()
17 $calls["needs_base_page"] = false;
18 $calls["page_builder"] = "ds_postContent";
23 function ds_postContent()
25 global $URL_COMPONENTS;
26 $call = $URL_COMPONENTS[1];
30 $dsname = $_REQUEST["dsname"];
31 $dsloc = $_REQUEST["dsloc"];
32 ds_createDS($dsname, $dsloc);
33 msg_addMessage("#008800", "DataStore, $dsname created at $dsloc");
37 $loc = urlCreate("/ds/control");
38 header("Location: $loc");
44 function ds_contentPane()
46 global $URL_COMPONENTS;
47 if(isset($URL_COMPONENTS[1])) {
48 switch($URL_COMPONENTS[1]) {
50 $dsbr = $URL_COMPONENTS[2];
51 echo "<h3>Browsing, $dsbr</h3><br>";
54 ds_createDS($_REQUEST["dsname"], $_REQUEST["dsloc"]);
55 echo "DS Created, <a href=\"".urlCreate("/ds/control")."\">return</a>";
60 // go thru the db and list the components
65 function ds_controlPane()
67 global $GLOBAL_BASE_URL;
68 echo "<h3>DataStores</h3>";
72 echo "<table border=1>";
73 echo "<tr><td>DataStore Name</td><td>DataStore Path</td><td>Size</td><td>Usage</td><td>Control</td></tr>";
74 foreach($dss as $dsl) {
75 $dsname = $dsl["dsname"];
76 $dspath = $dsl["dslocation"];
77 echo "<tr><td>$dsname</td><td>$dspath</td></tr>";
81 echo "<h3>Create DataStore</h3>";
82 echo "<form method=\"post\" action=\"".urlCreate("/dsp/createds")."\">";
83 echo "DataStore Name: <input type=\"text\" name=\"dsname\"><br>";
84 echo "DataStore Location: <input type=\"text\" name=\"dsloc\"><br>";
85 echo "<input type=\"submit\" name=\"create\" value=\"create\">";
90 function ds_leftMenu()
92 global $GLOBAL_BASE_URL;
93 echo "<h3>Browse</h3>";
98 foreach ($dss as $dsl) {
99 $dsname = $dsl["dsname"];
100 echo "<a href=\"".urlCreate("/ds/browse/$dsname")."\">$dsname</a><br>";
104 function ds_contentUrls()
106 $calls["needs_base_page"] = true;
107 $calls["content_pane_function"] = "ds_contentPane";
108 $calls["left_menu_function"] = "ds_leftMenu";
113 function ds_createDS($ds_name, $store_location)
115 db_createTable("datastores", "dsname", "dslocation");
116 db_createTable("datastores_files", "dsname", "fileowner", "filename", "dsfname");
118 $data = db_selectData("datastores", "dsname", "$ds_name");
119 if(isset($data[0]["dsname"])) return false;
121 db_insertData("datastores", "$ds_name", "$store_location");
126 return db_selectData("datastores");
129 function ds_deleteFile($ds_name, $file_name, $file_tag)
131 $dlk = db_selectData("datastores_files", "filename", $file_name);
133 foreach($dlk as $kmm) {
134 if($kmm["fileowner"] == $file_tag) {
136 $afname = $kmm["dsfname"];
137 if(file_exists($afname)) unlink($afname);
138 //echo "name was: $afname\n";
141 //echo "now delete name was: $afname\n";
142 if($afname != "") db_deleteData("datastores_files", "dsfname", $afname);
145 // returns a file name to the location a file can be created
146 function ds_fileds($ds_name, $file_name, $file_tag)
149 $data = db_selectData("datastores", "dsname", "$ds_name");
152 $made_file_name = "$dtime-".md5($file_name)."-".basename($file_name);
154 $act_fname = $data[0]["dslocation"]."/".basename($made_file_name);
156 db_insertData("datastores_files", "$ds_name", "$file_tag", "$file_name", "$act_fname");
161 function ds_getFileList($ds_name, $file_tag)
163 $list = db_selectData("datastores_files", "fileowner", "$file_tag");
169 function ds_deleteDS($ds_name)
171 db_deleteData("datastores", "dsname", "$ds_name");
172 db_deleteData("datastores_files", "dsname", $ds_name);
175 function ds_downloadAndStore($ds_name, $file_id, $file_name, $file_url)