--- /dev/null
+$BASE_URLS["ypc"]["base"] = "ypc"; // ap for apt-proxy
+$BASE_URLS["ypc"]["function"] = "yp_contentUrlsCtl";
+
+$MENU_ITEMS["yp"]["title"] = "YUM Proxy";
+$MENU_ITEMS["yp"]["link"] = "/ypc/proxycontrol";
+
+$GLOBAL_BASE_URL="/src/eclipse-workspace/glcas/www/";
+$DB_URL="sqlite:$BASE_DIR/var/ds_store.db";
require_once("config.php");
require_once("wsdl.php");
+
// first and foremost, load the plugins
$basedir = dirname(__FILE__);
+
+// we load this first
+if(file_exists("$basedir/plugins/www.php")) require_once("$basedir/plugins/www.php");
+
if(is_dir("$basedir/plugins")) {
$dh = opendir("$basedir/plugins");
if($dh) {
<?php
global $BASE_URLS;
-$BASE_URLS["ap"]["base"] = "ap"; // ap for apt-proxy
-$BASE_URLS["ap"]["function"] = "ap_pageBuilder"; // the page builder function for us
+$BASE_URLS["apc"]["base"] = "apc"; // ap for apt-proxy
+$BASE_URLS["apc"]["function"] = "ap_pageBuilderCtl"; // the page builder function for us
+$BASE_URLS["apr"]["base"] = "apr"; // ap for apt-proxy
+$BASE_URLS["apr"]["function"] = "ap_pageBuilderPrx"; // the page builder function for us
+
+$MENU_ITEMS["ap"]["title"] = "APT Proxy";
+$MENU_ITEMS["ap"]["link"] = "/apc/proxycontrol";
+
+function ap_pageBuilderCtl()
+{
+ $calls["needs_base_page"] = true;
+ $calls["content_pane_function"] = "ap_contentPane";
+ $calls["left_menu_function"] = "ap_leftMenu";
+
+ return $calls;
+}
+
+function ap_contentPane()
+{
+ echo "i am a ap content pane<br>";
+}
+
+function ap_leftMenu()
+{
+ echo "i am a ap leftmenu";
+}
+
+
?>
\ No newline at end of file
$BASE_URLS["ds"]["base"] = "ds"; // ap for apt-proxy
$BASE_URLS["ds"]["function"] = "ds_contentUrls"; // the page builder function for us
$MENU_ITEMS["ds"]["title"] = "DataStores";
-$MENU_ITEMS["ds"]["link"] = "$GLOBAL_BASE_URL/ds/control";
+$MENU_ITEMS["ds"]["link"] = "/ds/control";
function ds_contentPane()
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_fileds($ds_name, $file_id, $file_name)
+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)
{
$db = db_getDB();
+ if(db_tableExists($tablename)) return true;
+
$sql = "create table \"$tablename\" (\"".$tablename."_id\" INTEGER PRIMARY KEY AUTOINCREMENT";
for($i=1; $i < func_num_args(); $i++) {
$colname = func_get_arg($i);
$db->query($sql);
}
-function db_selectData($tablename, $column, $value)
+function db_selectData($tablename, $column="", $value="")
{
$db = db_getDB();
- $sql = "select * from \"$tablename\" where $column like '%$value%'";
+ if($column != "") $extra = " where $column like '%$value%'";
+ else $extra = "";
+ $sql = "select * from \"$tablename\"$extra";
$res = $db->query($sql);
$data = $res->fetchAll();
{
$db = db_getDB();
- $sql = "delete from \"$tablename\" where column_$column like '%$value%'";
+ $sql = "delete from \"$tablename\" where $column like '%$value%'";
+ //echo "Sql is $sql\n";
return $db->query($sql);
}
$BASE_URLS["wp"]["base"] = "";
$BASE_URLS["wp"]["function"] = "wp_pageBuilder";
+$MENU_ITEMS["wp"]["title"] = "Home";
+$MENU_ITEMS["wp"]["link"] = "/";
function goWebProcessor($calls)
{
if(isset($calls["needs_base_page"])) {
if($calls["needs_base_page"] == true) {
// build page
- echo "here base\n";
+ // echo "here base\n";
www_basePage($calls);
} else {
$func = $calls["page_builder"];
$func();
}
} else {
- echo "here base 2\n";
www_basePage($calls);
}
}
+function wp_pageBuilder()
+{
+ $calls["needs_base_page"] = true;
+
+ return $calls;
+}
+
function www_basePage($calls)
{
echo "<h1>Welcome to GLCAS</h1>";
echo "<table><tr>";
- global $MENU_ITEMS;
+ global $MENU_ITEMS, $GLOBAL_BASE_URL;
foreach($MENU_ITEMS as $mes) {
$mtext = $mes["title"];
- $mlink = $mes["link"];
- echo "<td><a href=\"$mlink\">$mtext</a></td>";
+ $mlink = "$GLOBAL_BASE_URL/".$mes["link"];
+ // remove the excess /'s
+ $mlink2 = preg_replace("/\/[\/]+/", "/", $mlink);
+ //echo "went from $mlink to $mlink2\n";
+ echo "<td><a href=\"$mlink2\">$mtext</a></td>";
}
echo "</tr></table>";
$BASE_URLS["ypr"]["base"] = "ypr"; // ap for apt-proxy
$BASE_URLS["ypr"]["function"] = "yp_contentUrlsPrx"; // the page builder function for us
$MENU_ITEMS["yp"]["title"] = "YUM Proxy";
-$MENU_ITEMS["yp"]["link"] = "$GLOBAL_BASE_URL/ypc/proxycontrol";
+$MENU_ITEMS["yp"]["link"] = "/ypc/proxycontrol";
function yp_contentPane()
return $calls;
}
+
+function yp_contentUrlsPrx()
+{
+ $calls["needs_base_page"] = false;
+ $calls["page_builder"] = "yp_proxyPageBuilder";
+
+ return $calls;
+}
+
+function yp_proxyPageBuilder()
+{
+ echo "<html>I write the songs that make the whole world sing</html>";
+}
?>
\ No newline at end of file
--- /dev/null
+<?php
+
+require_once("../lib/lib.php");
+
+echo "create 3 datastores\n";
+ds_createDS("name1", "/tmp");
+ds_createDS("name2", "/tmp");
+ds_createDS("name3", "/tmp");
+
+$tl = ds_listDS();
+
+print_r($tl);
+
+echo "try to create them again\n";
+ds_createDS("name1", "/tmp");
+ds_createDS("name2", "/tmp");
+ds_createDS("name3", "/tmp");
+
+$tl = ds_listDS();
+
+print_r($tl);
+
+echo "Delete 2 of them\n";
+ds_deleteDS("name1");
+ds_deleteDS("name2");
+
+$tl = ds_listDS();
+
+print_r($tl);
+
+echo "delete the last one\n";
+ds_deleteDS("name3");
+
+$tl = ds_listDS();
+
+print_r($tl);
+
+echo "now create a new ds\n";
+ds_createDS("name1", "/tmp");
+
+$myfname = "/asdf/asdf/asdf/asdf";
+$mytag = "mytag";
+
+echo "now createa a file inside our ds\n";
+//ds_fileds($ds_name, $file_name, $file_tag)
+$lk = ds_fileds("name1", $myfname, $mytag);
+echo "file created as name: $lk\n";
+
+echo "get file list:\n";
+$lk = ds_getFileList("name1", $mytag);
+print_r($lk);
+
+echo "delete the file\n";
+ds_deleteFile("name1", $myfname, $mytag);
+
+echo "get file list:\n";
+$lk = ds_getFileList("name1", $mytag);
+print_r($lk);
+
+echo "delete the last ds\n";
+ds_deleteDS("name1");
+?>
\ No newline at end of file