Пример #1
0
/**
 *  Extends function display_show
 *
 * modified to duplicatean entry for reordering
 */
function plugin_display_show($db, $Allfields, $id)
{
    global $PHP_SELF, $md, $USER, $tableinfo, $system_settings;
    $dbstring = $PHP_SELF;
    $dbstring .= "?";
    $dbstring .= "tablename=" . $tableinfo->name . "&";
    echo "<form name='order_form' method='post' id='protocolform' enctype='multipart/form-data' {$j2} action='{$dbstring}'>\n";
    echo "<input type='hidden' name='md' value='{$md}'>\n";
    echo "<table border=0 align='center'>\n";
    // initailize a blank array
    $Allfields2 = array();
    // Define variables to be cleared from the arrays
    $badnames = array('date_ordered', 'confirmed');
    // variables to not be messed with, rather these are explicitly defined later or system set*/
    $notouch = array('date', 'ordered_by', 'date_requested', 'ownerid', 'magic');
    foreach ($Allfields as $nowfield2) {
        $flag = 1;
        foreach ($badnames as $nolike) {
            if ($nowfield2[label] == $nolike) {
                $flag = 0;
            }
        }
        foreach ($notouch as $nolike2) {
            if ($nowfield2[label] == $nolike2) {
                $flag = 666;
            }
        }
        if ($flag == 1) {
            echo "<input type='hidden' name='{$nowfield2['name']}' value='{$nowfield2['values']}'>\n";
        } elseif ($flag == 0) {
            echo "<input type='hidden' name='{$nowfield2['name']}' value=''>\n";
        }
    }
    /* set the magic variable*/
    $magic = time();
    echo "<input type='hidden' name='magic' value='{$magic}'>\n";
    /* Put in the date requested, who requested it, etc*/
    $dateformat = get_cell($db, 'dateformats', 'dateformat', 'id', $system_settings['dateformat']);
    $date = time();
    $date = date($dateformat, $date);
    $date .= '-reorder';
    echo "<input type='hidden' name='date_requested' value='{$date}'>\n";
    $r = $db->Execute("SELECT firstname,lastname,email FROM users WHERE id={$USER}");
    $myname = $USER['firstname'] . ' ' . $USER['lastname'];
    echo "<input type='hidden' name='ordered_by' value='{$myname}'>\n";
    echo "<input type='hidden' name='subm' value=''>\n";
    echo "<td colspan=7 align='center'><input type='button' name='sub' value='Re-order' onClick='document.order_form.subm.value=\"Add Record\"; document.order_form.submit(); window.opener.document.g_form.search.value=\"Search\"; window.opener.document.g_form.submit(); window.opener.focus(); '>\n";
    //echo "<td colspan=7 align='center'><input type='button' name='sub' value='Re-order' onClick='document.order_form.subm.value=\"Add Record\"; document.order_form.submit(); window.opener.document.g_form.search.value=\"Search\"; setTimeout(\"window.opener.document.g_form.submit(); window.opener.focus(); window.close();\",300); '>\n";
    echo "&nbsp;&nbsp;<input type='button' name='sub' value='Cancel' onClick='window.opener.focus(); window.close();'></td>\n";
    //end of table
    echo "</tr>\n</table>\n</form>\n";
}
Пример #2
0
/**
 *  Change that groupname.  
 *
 * On error, returns an error string
 */
function modify_group($db, $groupid, $new_name)
{
    // Only change the name when there is a new one provided
    if (!$new_name) {
        return "Please enter a groupname!";
    }
    // check whether a group with the new name already exists
    $r = $db->Execute("SELECT id FROM groups WHERE \n                   (name='{$new_name}' AND NOT id='{$groupid}');");
    if (!$r->EOF) {
        return "Groupname <b>{$new_name}</b> already exists, please select another name";
    } else {
        // get the old name
        $old_name = get_cell($db, "groups", "name", "id", $groupid);
        $query = "UPDATE groups SET name='{$new_name}' WHERE id='{$groupid}';";
        if ($db->Execute($query)) {
            echo "New groupname is <b>{$new_name}</b><br><br>";
        }
    }
}
Пример #3
0
/**
 *  Interacts with the SQL database to create/modify users
 *
 * can be called to create (type=create) or modify (type=modify) other users or oneselves (type=me) 
 */
function modify($db, $type)
{
    global $_POST, $USER, $perms, $perms2, $perms3, $post_vars;
    // quote all bad characters:
    foreach ($_POST as $key => $value) {
        if (!is_array($_POST[$key])) {
            $_POST[$key] = addslashes($value);
        }
    }
    $id = $_POST['id'];
    $login = $_POST['login'];
    $pwd = $_POST['pwd'];
    $user_group = $_POST['user_group'];
    $user_add_groups = $_POST['user_add_groups'];
    $firstname = $_POST['firstname'];
    $lastname = $_POST['lastname'];
    $email = $_POST['email'];
    $USER['settings']['style'] = $_POST['user_style'];
    if ($perms) {
        for ($i = 0; $i < sizeof($perms); $i++) {
            $permissions = $permissions | $perms[$i];
        }
    }
    if (!$permissions) {
        $permissions = 0;
    }
    if ($perms2) {
        for ($i = 0; $i < sizeof($perms2); $i++) {
            $permissions2 = $permissions2 | $perms2[$i];
        }
    }
    if (!$permissions2) {
        $permissions2 = 0;
    }
    if ($perms3) {
        for ($i = 0; $i < sizeof($perms3); $i++) {
            $permissions3 = $permissions3 | $perms3[$i];
        }
    }
    if (!$permissions3) {
        $permissions3 = 0;
    }
    // include here, to avoid being overwritten by post_vars
    include './includes/defines_inc.php';
    // check whether status of the victim is smaller than
    //  the current users status
    if ($type == 'modify') {
        $original_permissions = get_cell($db, 'users', 'permissions', 'id', $id);
    }
    // check whether this is not illegitimate
    if (!($USER['permissions'] & $SUPER || $USER['permissions'] & $ADMIN && $USER['groupid'] == $user_group && $USER['permissions'] > $original_permissions || $USER['id'] == $id)) {
        echo 'You are not allowed to do this. <br>';
        return false;
    }
    // log some info
    $theid = $USER['id'];
    $theip = getenv('REMOTE_ADDR');
    $thedate = time();
    if ($type == 'modify' && $id) {
        $query = "UPDATE users SET login='******', firstname='{$firstname}', \n                     lastname='{$lastname}',  \n                     groupid='{$user_group}', email='{$email}',  \n                     permissions='{$permissions}', permissions2='{$permissions2}',\n                     modbyid='{$theid}',\n\t\t     modbyip='{$theip}', moddate='{$thedate}'";
        if ($pwd) {
            $pwd = md5($pwd);
            $query .= ", pwd='{$pwd}'";
        }
        $query .= " WHERE id='{$id}';";
        if ($db->Execute($query)) {
            echo "Modified settings of user <i>" . stripslashes($firstname) . ' ' . stripslashes($lastname) . "</i>.<br>\n";
            $db->Execute("DELETE FROM usersxgroups WHERE usersid={$id}");
            if ($user_add_groups) {
                foreach ($user_add_groups as $add_groupid) {
                    $db->Execute("INSERT INTO usersxgroups VALUES ('{$id}','{$add_groupid}')");
                }
            }
        } else {
            echo "Could not modify settings of user: <i>" . stripslashes($firstname) . ' ' . stripslashes($lastname) . "</i>.<br>\n";
        }
    } elseif ($type == 'create') {
        $id = $db->GenID('users_id_seq');
        $pwd = md5($pwd);
        $new_user_settings['menustyle'] = 1;
        $new_user_settings = serialize($new_user_settings);
        $query = "INSERT INTO users (id, login, pwd, groupid, firstname, lastname, permissions, permissions2, email, createdbyid, createdbyip, createddate, settings) ";
        $query .= "VALUES('{$id}','{$login}','{$pwd}','{$user_group}','{$firstname}','{$lastname}', '{$permissions}', '{$permissions2}','{$email}', '{$theid}', '{$theip}', '{$thedate}', '{$new_user_settings}')";
        if ($db->Execute($query)) {
            echo "User <i>{$firstname} {$lastname}</i> added.<br>\n";
            if ($user_add_groups) {
                foreach ($user_add_groups as $add_groupid) {
                    $db->Execute("INSERT INTO usersxgroups VALUES ('{$id}','{$add_groupid}')");
                }
            }
        } else {
            echo "Failed to add user: <i>{$firstname} {$lastname}</i>.<br>\n";
        }
    } elseif ($type == 'me' && $id) {
        $query = "UPDATE users SET firstname='{$firstname}', \n                     lastname='{$lastname}',  \n                     email='{$email}',\n\t\t     modbyid='{$theid}',\n\t\t     moddate='{$thedate}',\n\t\t     modbyip='{$theip}'";
        if ($pwd) {
            $pwd = md5($pwd);
            // require at least write permissions to change the password
            if ($USER["permissions"] >= $WRITE) {
                $query .= ", pwd='{$pwd}'";
            }
        }
        $query .= " WHERE id='{$id}';";
        $result .= "\n<table border=0 align='center'>\n  <tr>\n    <td align='center'>\n      ";
        if ($db->Execute($query)) {
            // modify menu view in settings
            if ($_POST['menustyle'] == 1) {
                $USER['settings']['menustyle'] = 1;
            } else {
                $USER['settings']['menustyle'] = 0;
            }
            $result .= "Your settings have been modified.<br>\n";
            // superuser can do whatever he please also with herself
            if ($USER['permissions'] & $SUPER) {
                $db->Execute("DELETE FROM usersxgroups WHERE usersid={$id}");
                if ($user_add_groups) {
                    foreach ($user_add_groups as $add_groupid) {
                        $db->Execute("INSERT INTO usersxgroups VALUES ('{$id}','{$add_groupid}')");
                    }
                }
            }
        } else {
            $result .= "Failed to modify you settings.<br>\n";
        }
        $result .= "    </td>\n  </tr>\n</table>\n\n";
    } else {
        $result .= "Strange error!< Please report to your system administrator<br>\n";
    }
    return $result;
}
   	<th>Batch UDT</th>
  
    

  </tr>
<?php 
$i = 1;
$query = "select * from `base` where `pincode_change_flag`=1";
$query = mysql_query($query);
if (mysql_num_rows($query) > 0) {
    while ($row = mysql_fetch_array($query)) {
        $id = $row['id'];
        $fes = $row['fe'];
        $pre_fes = $row['previous_fes'];
        $fes_contact_no = get_cell('fes', get_fes_id($fes), 'fes_mobile_no');
        $pre_fes_contact_no = get_cell('fes', get_fes_id($pre_fes), 'fes_mobile_no');
        ?>
		<tr>
		<td ><?php 
        echo $i++;
        ?>
</td>
        <td ><?php 
        echo $row['code'];
        ?>
</td>
		<td ><?php 
        echo $row['external_id'];
        ?>
</td>
        <td ><?php 
Пример #5
0
 $pwd = md5($PHP_AUTH_PW);
 $db_query = "SELECT login FROM users WHERE login=? AND pwd=?";
 $db_result = $db->Execute($db_query, array($PHP_AUTH_USER, $pwd));
 if ($db_result) {
     $auth = $db_result->fields['login'];
 }
 // check that there is no one else like this
 $db_result->Movenext();
 if (!$db_result->EOF) {
     $auth = false;
 }
 // if pam_prg is present, check whether the user is known on the system
 $pam_prg = $system_settings['checkpwd'];
 if ($system_settings['authmethod'] == 2 && $pam_prg && !$auth) {
     // this only makes sense if the user has an account on this instance of phplabware
     if (get_cell($db, 'users', 'login', 'login', $PHP_AUTH_USER)) {
         $esc_user = escapeshellarg($PHP_AUTH_USER);
         $esc_pass = escapeshellarg($PHP_AUTH_PW);
         $test = exec("echo {$esc_pass} | {$pam_prg} {$esc_user}", $dummy, $result);
         if ($result) {
             // we are authenticated
             $auth = true;
             $authmethod = 'pam';
         }
     }
 }
 // if authenticated, this session is OK:
 if ($auth) {
     if ($_SESSION['javascript_enabled'] || ($_POST['javascript_enabled'] || $_GET['javascript_enabled'])) {
         $_SESSION['javascript_enabled'] = true;
     } else {
Пример #6
0
/**
 *   show page with choice of tables, dynamically generate list with columns
 *
 */
function show_table_column_page($db, $table_name, $addcol_name, $addcol_label)
{
    global $_GET;
    echo "<form method='post' id='table_type'>\n";
    echo "<input type='hidden' name='table_name' value='{$table_name}'></input>\n";
    echo "<input type='hidden' name='addcol_name' value='{$addcol_name}'></input>\n";
    echo "<input type='hidden' name='addcol_label' value='{$addcol_label}'></input>\n";
    // box 1 with tablenames
    $r = $db->Execute("SELECT tablename,id,table_desc_name FROM tableoftables WHERE permission='Users' AND tablename <> 'settings' AND tablename <> '{$table_name}'  AND table_desc_name IS NOT NULL ORDER BY sortkey");
    // box 2, dynamically filled with column names
    $the_array = "modelinfo = new Array (\n";
    $the_array .= make_column_js_array($db, $r);
    $r->MoveNext();
    while (!$r->EOF) {
        $the_array .= ",\n " . make_column_js_array($db, $r);
        $r->MoveNext();
    }
    $the_array .= "\n)\n";
    echo add_js($the_array);
    $jscript = "onChange=\"fillSelectFromArray(this.form.table_column_select,((this.selectedIndex == -1) ? null : modelinfo[this.selectedIndex-1]));\"";
    echo "<h3 align='center'>Choose Table and column to be associated with column <i>{$addcol_label}</i> in table <i>{$table_name}</i>.</h3>\n";
    echo "<table align='center' cellpadding='2' cellspacing='0'>\n";
    echo "<tr><th>Table</th>\n<th>Column</th><th>&nbsp;</th></tr>\n";
    $rm = $db->Execute("SELECT tablename,id FROM tableoftables WHERE permission='Users' AND tablename <> 'settings' AND tablename <> '{$table_name}'  AND table_desc_name IS NOT NULL ORDER BY sortkey");
    echo "<tr><td>" . $rm->GetMenu2("table_select", "", true, false, 0, $jscript) . "</td>\n";
    echo "<td><select name='table_column_select'></select></td>\n";
    echo "</tr>\n";
    $_GET['tablename'] = $table_name;
    $tableinfo = new tableinfo($db);
    $rs = $db->Execute("SELECT id,associated_table,associated_column,associated_local_key,label FROM {$tableinfo->desname} WHERE datatype='table'");
    if ($rs && !$rs->EOF) {
        echo "<tr><td colspan=3>Grouping:</td></tr>\n";
        echo "<tr><td colspan=3><input type='radio' name='ass_to'> Make this a primary key</input></td></tr>\n";
        while (!$rs->EOF) {
            if ($rs->fields['associated_table'] && !$rs->fields['associated_local_key']) {
                $ass_tableinfo = new tableinfo($db, false, $rs->fields['associated_table']);
                $ass_column = get_cell($db, $ass_tableinfo->desname, 'label', 'id', $rs->fields['associated_column']);
                echo "<tr><td colspan=3><input type='radio' name='ass_to' value='{$rs->fields[0]}'> Associate with: Local column: <i>{$rs->fields['label']}</i> (Foreign table: <i>{$ass_tableinfo->name}</i>, column: <i>{$ass_column}</i>),</input></td></tr>\n";
            }
            $rs->MoveNext();
        }
    }
    echo "<tr><td colspan=3 align='center'><input type='submit' name='submit' value='Submit'></input></td></tr>\n";
    echo "</table>\n</form>\n";
}
	<th>Actions</th>
  </tr>
<?php 
$i = 1;
$query = mysql_query("select * from `userinfo` where 1");
if (mysql_num_rows($query) > 0) {
    while ($row = mysql_fetch_array($query)) {
        $id = $row['id'];
        ?>
		<tr>
		<td ><?php 
        echo $i++;
        ?>
</td>
        <td ><?php 
        echo get_cell('groups', $row['user_type'], 'name');
        ?>
</td>
		<td ><?php 
        echo $row['name'];
        ?>
</td>
        <td ><?php 
        echo $row['email'];
        ?>
</td>
		
		
        <td ><a href="javascript:;" onClick="edit_user('<?php 
        echo $row['id'];
        ?>
Пример #8
0
/**
 *  checks if this user may write/modify/delete these data
 *
 */
function may_write($db, $tableid, $id, $USER)
{
    include './includes/defines_inc.php';
    $table = get_cell($db, 'tableoftables', 'real_tablename', 'id', $tableid);
    if ($USER['permissions'] & $SUPER || $USER['permissions'] & $TABLECREATOR) {
        return true;
    }
    if ($USER['permissions'] & $WRITE && !$id) {
        return true;
    }
    $ownerid = get_cell($db, $table, 'ownerid', 'id', $id);
    $ownergroup = get_cell($db, 'users', 'groupid', 'id', $ownerid);
    if ($USER['permissions'] & $ADMIN) {
        if ($USER['groupid'] == $ownergroup) {
            return true;
        }
    }
    if ($USER['permissions'] & $WRITE && $id) {
        $userid = $USER['id'];
        // 'user' write access
        if ($r = $db->Execute("SELECT * FROM {$table} WHERE id={$id} AND\n            ownerid={$userid}")) {
            if (!$r->EOF) {
                return true;
            }
        }
        // 'group' write access
        if ($r = $db->Execute("SELECT * FROM {$table} WHERE id={$id} AND gw='1'")) {
            if (!$r->EOF && in_array($ownergroup, $USER['group_array'])) {
                return true;
            }
        }
        // 'world' write access
        if ($r = $db->Execute("SELECT * FROM {$table} WHERE id={$id} AND ew='1'")) {
            if (!$r->EOF) {
                return true;
            }
        }
        // 'and also' write access
        if ($r = $db->Execute("SELECT * FROM trust WHERE trusteduserid='{$userid}'\n              AND tableid='{$tableid}' AND recordid='{$id}' AND rw='w'")) {
            if (!$r->EOF) {
                return true;
            }
        }
    }
}
Пример #9
0
 if ($version < 0.2003) {
     // Adds column key_table to description tables
     include "./dd/0_2003_inc.php";
 }
 if ($version < 0.2004) {
     // adds Ethan's ordering table
     include "./dd/ordertable.php";
 }
 if ($version < 0.3001) {
     // add tables viewnames and tableviews
     include "./dd/0_3001_inc.php";
 }
 if ($version < 0.3002) {
     // add table construct
     // if the table exists already, we do not want to create it again
     if (!get_cell($db, 'tableoftables', 'id', 'tablename', 'constructs')) {
         include "./dd/0_3002_inc.php";
     }
 }
 if ($version < 0.41) {
     // Add column permissions2 to table users
     $db->Execute('ALTER TABLE users ADD COLUMN permissions2 int;');
 }
 if ($version < 0.62) {
     // Add table usersettings, to enable tying user settings to the IP address they are coming from (useful for 'open' guest accounts)
     include "./dd/0_6200_inc.php";
 }
 $query = "UPDATE settings SET version='{$version_code}' WHERE id=1";
 if (!$db->Execute($query)) {
     $test = false;
 }
 function findCompletedTime($id)
 {
     //$status 0->Pending 1-> Accepted -> 2 Rejected ->3 Hold->4
     $status = get_cell('base', $id, 'ivr_flag');
     if ($status != 1 && $status != 2 && $status != 3) {
         return "Process..";
     } else {
         $udt = get_cell('base', $id, 'upload_date_time');
         if ($status == 1) {
             $ivr_time = get_cell('base', $id, 'ivr_accepted_timestamp');
         } else {
             if ($status == 2) {
                 $ivr_time = get_cell('base', $id, 'ivr_rejected_timestamp');
             } else {
                 if ($status == 3) {
                     $ivr_time = get_cell('base', $id, 'ivr_hold_timestamp');
                 }
             }
         }
         $time_diff = get_time_diff($udt, $ivr_time);
         return $time_diff;
     }
 }
Пример #11
0
<?php

// Adds the table constructs
$newtablename = "constructs";
$newtablelabel = "constructs";
$newtableid = $db->GenID("tableoftables_gen_id_seq");
for ($i = 0; $i < $hownew; $i++) {
    $newtablelabel .= "new";
}
while (get_cell($db, "tableoftables", "id", "tablename", $newtablename)) {
    $newtablename .= "n";
    $hownew++;
}
for ($i = 0; $i < $hownew; $i++) {
    $newtablelabel .= "new";
}
$newtableshortname = substr($newtablename, 0, 3) . $newtableid;
$newtable_realname = $newtablename . "_" . $newtableid;
$newtable_desc_name = $newtable_realname . "_desc";
$r = $db->Execute("INSERT INTO tableoftables (id,sortkey,tablename,shortname,display,permission,custom,real_tablename,table_desc_name,label,plugin_code) VALUES ('{$newtableid}','0','{$newtablename}','{$newtableshortname}','Y','Users',NULL,'{$newtable_realname}','{$newtable_desc_name}','{$newtablelabel}','')");
$rg = $db->Execute("SELECT id FROM groups");
while (!$rg->EOF) {
    $groupid = $rg->fields[0];
    $db->Execute("INSERT INTO groupxtable_display VALUES ({$groupid},{$newtableid})");
    $rg->MoveNext();
}
if ($r) {
    $rb = $db->Execute("CREATE TABLE {$newtable_desc_name} (\n      id int NOT NULL,\n      sortkey int,\n      label text,\n      columnname text,\n      display_table char(1),\n      display_record char(1),\n      required char(1),\n      type text,\n      datatype text,\n      associated_table text,\n      associated_column text,\n      associated_local_key text,\n      key_table text,\n      thumb_x_size int,\n      thumb_y_size int,\n      link_first text,\n      link_last text,\n      modifiable char(1) )");
    if ($rb) {
        $newid = $db->GenID("{$newtable_desc_name}" . "_id");
        $db->Execute("INSERT INTO {$newtable_desc_name} VALUES({$newid},'100','id','id','N','N','N','int','text',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)");
Пример #12
0
}
if (!$pdffilecounter) {
    $pdffilecounter = 0;
}
$endtime = microtime();
list($startmu, $starts) = explode(" ", $starttime);
list($endmu, $ends) = explode(" ", $endtime);
$process = $ends - $starts;
$procesmu = $endmu - $startmu;
$pt = $process + $procesmu;
$ptime = sprintf("%0f", $pt);
echo "Indexed {$textfilecounter} text files and {$pdffilecounter} pdf files in {$ptime} seconds<br>";
// load plugin php code if it has been defined
if ($HTTP_GET_VARS['tablename']) {
    $tableinfo = new tableinfo($db);
    $plugin_code = get_cell($db, 'tableoftables', 'plugin_code', 'id', $tableinfo->id);
    if ($plugin_code) {
        @(include $plugin_code);
        // and execute the cron plugin
        if (function_exists('plugin_cron')) {
            plugin_cron($db, $tableinfo);
        }
    }
}
// we'll do the postgres maintenance
if (substr($db_type, 0, 8) == 'postgres') {
    $db->debug = true;
    $db->Execute('VACUUM');
    $db->Execute('ANALYZE');
    $db->Execute('VACUUM ANALYZE');
    $db->debug = false;
Пример #13
0
      $db->Execute("UPDATE $newtable_desc_name SET associated_table=\'$ass_table\' WHERE id=$newid");
      ');
        if ($s->fields[7] == 'mpulldown') {
            fwrite($fp, '$ask_table=$newtable_realname."ask_".$id_ass;
            $db->Execute("CREATE TABLE $ask_table (
               recordid int,
               typeid int)");
         $db->Execute("UPDATE $newtable_desc_name SET key_table=\'$ask_table\' WHERE id=$newid");
         ');
        }
    } elseif ($s->fields[7] == 'table') {
        $asstable_name = get_cell($db, 'tableoftables', 'tablename', 'id', $s->fields[8]);
        $asstable_descname = get_cell($db, 'tableoftables', 'table_desc_name', 'id', $s->fields[8]);
        $asscolumnname = get_cell($db, $asstable_descname, 'columnname', 'id', $s->fields[9]);
        // also do associated local column
        $asslocalcolumnname = get_cell($db, $table_desc, 'columnname', 'id', $s->fields[10]);
        // we need to write the whole description table and only then make the association to local columns:
        if ($asslocalcolumnname) {
            fwrite($fp, '$lid[]=$newid;
');
            fwrite($fp, '$lasscolumnname[]="' . $asslocalcolumnname . "\";\n");
        }
        fwrite($fp, '$asstable_id=get_cell($db,"tableoftables","id","tablename","' . $asstable_name . "\");\n");
        fwrite($fp, '$asstable_desc=get_cell($db,"tableoftables","table_desc_name","tablename","' . $asstable_name . "\");\n");
        fwrite($fp, '$asscolumn_id=get_cell($db,"$asstable_desc","id","columnname","' . $asscolumnname . "\");\n");
        fwrite($fp, '$db->Execute("UPDATE $newtable_desc_name SET associated_table=$asstable_id,associated_column=$asscolumn_id,key_table=NULL WHERE id=$newid");
      ');
    }
    $s->MoveNext();
}
// if there were associated local columns in the description table, create those link now
Пример #14
0
/**
 *  Searches (nested) for a match with $value 
 *
 * returns the id of the record in the associated value by searching recursively
 * that can be used in a SQL search
 */
function find_nested_match($db, $tableinfo, $field, $value, $first = true)
{
    $info = getvalues($db, $tableinfo, $field);
    if ($info[0]['datatype'] == 'table') {
        $ass_tableinfo = new tableinfo($db, $info[0]['ass_table_name']);
        $value = find_nested_match($db, $ass_tableinfo, $info[0]['ass_column_name'], $value, false);
    } elseif ($info[0]['datatype'] == 'int') {
        $value = trim($value);
        // I am getting desperate, but the browser inserts junk in the first postions, test if it is a number, if not, delete it.
        if (!is_numeric($value[0])) {
            $value = substr($value, 1);
        }
        return get_cell($db, $tableinfo->realname, 'id', $field, (int) $value);
    } elseif ($info[0]['datatype'] == 'float') {
        $value = trim($value);
        if (!is_numeric($value[0])) {
            $value = substr($value, 1);
        }
        return get_cell($db, $tableinfo->realname, 'id', $field, (double) $value);
    } elseif ($info[0]['datatype'] == 'pulldown') {
        $value = get_cell($db, $info[0]['ass_t'], 'id', 'typeshort', $value);
        return get_cell($db, $tableinfo->realname, 'id', $field, $value);
    } elseif (!$first) {
        return get_cell($db, $tableinfo->realname, 'id', $field, $value);
    }
    return $value;
}
Пример #15
0
function plugin_show($db, $tableinfo, $id, $USER, $system_settings, $backbutton = true)
{
    global $PHP_SELF;
    $journaltable = get_cell($db, $tableinfo->desname, "associated_table", "columnname", "journal");
    $categorytable = get_cell($db, $tableinfo->desname, "associated_table", "columnname", "category");
    if (!may_read($db, $tableinfo, $id, $USER)) {
        return false;
    }
    // get values
    $r = $db->Execute("SELECT {$tableinfo->fields} FROM {$tableinfo->realname} WHERE id={$id}");
    if ($r->EOF) {
        echo "<h3>Could not find this record in the database</h3>";
        return false;
    }
    $column = strtok($tableinfo->fields, ",");
    while ($column) {
        ${$column} = $r->fields[$column];
        $column = strtok(",");
    }
    echo "&nbsp;<br>\n";
    echo "<table border=0 align='center'>\n";
    echo "<tr>\n";
    echo "<th>Article: </th>\n";
    echo "<td>{$title}<br>\n{$author}<br>\n";
    $text = get_cell($db, $journaltable, "type", "id", $journal);
    echo "{$text} ({$pubyear}), <b>{$volume}</b>:{$fpage}-{$lpage}\n";
    echo "</td></tr>\n";
    if ($abstract) {
        echo "<tr>\n<th>Abstract</th>\n";
        echo "<td>{$abstract}</td>\n</tr>\n";
    }
    // Category
    if ($category) {
        $type2 = get_cell($db, $categorytable, "type", "id", $category);
        echo "<tr>\n<th>Category</th>\n";
        echo "<td>{$type2}</td>\n</tr>\n";
    }
    echo "<tr>";
    $query = "SELECT firstname,lastname,email FROM users WHERE id={$ownerid}";
    $r = $db->Execute($query);
    if ($r->fields["email"]) {
        echo "<th>Submitted by: </th><td><a href='mailto:" . $r->fields["email"] . "'>";
        echo $r->fields["firstname"] . " " . $r->fields["lastname"] . "</a> ";
    } else {
        echo "<th>Submitted by: </th><td>" . $r->fields["firstname"] . " ";
        echo $r->fields["lastname"] . " ";
    }
    $dateformat = get_cell($db, "dateformats", "dateformat", "id", $system_settings["dateformat"]);
    $date = date($dateformat, $date);
    echo "({$date})</td>\n";
    echo "</tr>\n";
    if ($lastmodby && $lastmoddate) {
        echo "<tr>";
        $query = "SELECT firstname,lastname,email FROM users WHERE id={$lastmodby}";
        $r = $db->Execute($query);
        if ($r->fields["email"]) {
            echo "<th>Last modified by: </th><td><a href='mailto:" . $r->fields["email"] . "'>";
            echo $r->fields["firstname"] . " " . $r->fields["lastname"] . "</a>";
        } else {
            echo "<th>Last modified by: </th><td>" . $r->fields["firstname"] . " ";
            echo $r->fields["lastname"];
        }
        $dateformat = get_cell($db, "dateformats", "dateformat", "id", $system_settings["dateformat"]);
        $lastmoddate = date($dateformat, $lastmoddate);
        echo " ({$lastmoddate})</td>\n";
        echo "</tr>\n";
    }
    echo "<tr>";
    $notes = nl2br(htmlentities($notes));
    echo "<th>Notes: </th><td>{$notes}</td>\n";
    echo "</tr>\n";
    $columnid = get_cell($db, $tableinfo->desname, "id", "columnname", "file");
    $files = get_files($db, $tableinfo->name, $id, $columnid, 1);
    if ($files) {
        echo "<tr><th>Files:</th>\n<td>";
        for ($i = 0; $i < sizeof($files); $i++) {
            echo $files[$i]["link"] . " (" . $files[$i]["type"] . " file, " . $files[$i]["size"] . ")<br>\n";
        }
        echo "</tr>\n";
    }
    echo "<tr><th>Links:</th><td colspan=7><a href='{$PHP_SELF}?tablename=" . $tableinfo->name . "&showid={$id}&";
    echo SID;
    echo "'>" . $system_settings["baseURL"] . getenv("SCRIPT_NAME") . "?tablename=" . $tableinfo->name . "&showid={$id}</a> (This page)<br>\n";
    echo "<a href='http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?";
    if ($system_settings["pdfget"]) {
        $addget = "&" . $system_settings["pdfget"];
    }
    echo "cmd=Retrieve&db=PubMed&list_uids={$pmid}&dopt=Abstract{$addget}'>This article at Pubmed</a><br>\n";
    echo "<a href='http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?";
    echo "cmd=Link&db=PubMed&dbFrom=PubMed&from_uid={$pmid}{$addget}'>Related articles at Pubmed</a><br>\n";
    if ($supmat) {
        echo "<a href='{$supmat}'>Supplemental material</a><br>\n";
    }
    echo "</td></tr>\n";
    show_reports($db, $tableinfo, $id);
    ?>
   
<form method='post' id='pdfview' action='<?php 
    echo "{$PHP_SELF}?tablename=" . $tableinfo->name;
    ?>
&<?php 
    echo SID;
    ?>
'> 
<?php 
    if ($backbutton) {
        echo "<tr>";
        echo "<td colspan=7 align='center'><input type='submit' name='submit' value='Back'></td>\n";
        echo "</tr>\n";
    } else {
        echo "<tr><td colspan=8 align='center'>&nbsp;<br><button onclick='self.close();window.opener.focus();' name='Close' value='close'>Close</button></td></tr>\n";
    }
    echo "</table></form>\n";
}
    
    	<?php 
        $area_code_table = mysql_query('SELECT * FROM `area_code` WHERE 1 order by area_name');
        while ($fetch_area_code = mysql_fetch_array($area_code_table)) {
            ?>
      		<option <?php 
            if ($fetch_area_code['id'] == $row['area_code_id']) {
                ?>
 selected="selected"  <?php 
            }
            ?>
  value="<?php 
            echo $fetch_area_code['id'];
            ?>
"><?php 
            echo get_cell('area_code', $fetch_area_code['id'], 'area_name');
            ?>
   </option>
     		 <?php 
        }
        ?>
         
    	</select></td>
        	
		
       
	  </tr>
	<?php 
    }
} else {
    ?>
Пример #17
0
require './include.php';
require './includes/db_inc.php';
require './includes/general_inc.php';
printheader($httptitle, false);
navbar($USER['permissions']);
if (!$USER['permissions'] & $SUPER) {
    echo "<h3 align='center'>Sorry, this page is not for you.</h3>\n";
    printfooter($db, $USER);
    exit;
}
// Three GET variables are useful:
// tablename
// fields - let's you export only a subset of columns
// valuesOnly - switch wether or not values should be 'expanded'
$tablename = $_GET['tablename'];
$tableid = get_cell($db, 'tableoftables', 'id', 'tablename', $tablename);
if (!$tableid) {
    echo "<h3>This script will dump the contents of a table in a tab-delimited file. The contents of that file can be imported into phplabware or any other database program.</h3>";
    $r = $db->execute("SELECT id,tablename FROM tableoftables");
    if ($r) {
        echo "<table align='center'>\n";
        echo "<tr><td><h3>Select one of the following tables:</h3></td></tr>\n";
        while ($r && !$r->EOF) {
            echo "<tr><td><a href='dumpcontent.php?tablename=" . $r->fields[1] . "'>" . $r->fields[1] . "</a></td></tr>\n";
            $r->MoveNext();
        }
    }
    printfooter($d, $USER);
    exit;
}
$tableinfo = new tableinfo($db);
Пример #18
0
<?php 
    include "header_menu.php";
    ?>

<div id="wrapper">

<?php 
    include 'left_info_bar.php';
    ?>



<div id="wrapper_content" >
<?php 
    $userid = $_SESSION['user_id'];
    $user_type = get_cell('userinfo', $userid, 'user_type');
    if ($user_type == 1) {
        ?>
<a href="javascript:;" onClick="view_users()" class="small red button"><span>Users</span></a>
 <?php 
    } else {
        ?>
 <h1>No Settings Available Right now For you</h1>
 <?php 
    }
    ?>

<form id="settings_form" name="settings_form" method="post" enctype="multipart/form-data" target="settings_iframe"> 
<div id="setting_content">

</div>
Пример #19
0
/**
 *  Upload files and enters then into table files
 *
 * files should be called file[] in _POST
 * filetitle in _POST will be inserted in the title field of table files
 * returns id of last uploaded file upon succes, false otherwise
 */
function import_file($db, $tableid, $id, $columnid, $columnname, $tmpfileid, $system_settings)
{
    if (!$tmpfileid) {
        return false;
    }
    $table = get_cell($db, 'tableoftables', 'tablename', 'id', $tableid);
    $real_tablename = get_cell($db, 'tableoftables', 'real_tablename', 'id', $tableid);
    if (!($db && $table && $id)) {
        echo "Error in code: {$db}, {$table}, or {$id} is not defined.<br>";
        return false;
    }
    if (isset($tmpfileid) && !($filedir = $system_settings['filedir'])) {
        echo "<h3><i>Filedir</i> was not set.  The file was not uploaded. Please contact your system administrator</h3>";
        return false;
    }
    $r = $db->Execute("SELECT name,mime,type FROM tmpfiles WHERE id={$tmpfileid}");
    if (!$r->fields[0]) {
        return false;
    }
    if (!($fileid = $db->GenID("files_id_seq"))) {
        return false;
    }
    $originalname = $r->fields['name'];
    $mime = $r->fields['type'];
    $filestype = $r->fields['type'];
    $filesdir = $system_settings['tmpdir'] . '/phplabwaredump/files/';
    $tmplocation = $filesdir . $tmpfileid . '_' . $originalname;
    $size = filesize($tmplocation);
    $title = ${$originalname};
    if (!$title) {
        $title = 'NULL';
    } else {
        $title = "'{$title}'";
    }
    $type = $filestype;
    if (rename($tmplocation, "{$filedir}/{$fileid}" . '_' . "{$originalname}")) {
        $query = "INSERT INTO files (id,filename,mime,size,title,tablesfk,ftableid,ftablecolumnid,type) VALUES ({$fileid},'{$originalname}','{$mime}','{$size}',{$title},'{$tableid}',{$id},'{$columnid}','{$filestype}')";
        $db->Execute($query);
    } else {
        $fileid = false;
    }
    return $fileid;
}
Пример #20
0
function plugin_getvalues($db, &$allfields, $id, $tableid)
{
    if (!$id) {
        return true;
    }
    $table_desc = get_cell($db, "tableoftables", "table_desc_name", "id", $tableid);
    $authortable = get_cell($db, $table_desc, "associated_table", "columnname", "type2");
    while (list($key, $value) = each($allfields)) {
        if ($value[name] == "type2") {
            $index = $key;
        }
    }
    if ($index) {
        $firstname = get_cell($db, $authortable, "type", "id", $allfields[$index][values]);
        $lastname = get_cell($db, $authortable, "typeshort", "id", $allfields[$index][values]);
        if ($firstname || $lastname) {
            $allfields[$index][text] = "{$firstname} {$lastname}";
        }
    }
}
Пример #21
0
     $db->Execute("UPDATE {$newtable_desc_name} SET associated_table='{$ass_table2}' WHERE id={$newid}");
     $newid = $db->GenID("{$newtable_desc_name}" . "_id");
     $db->Execute("INSERT INTO {$newtable_desc_name} VALUES({$newid},'140','Title','title','Y','Y','Y','text','text',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Y')");
     $newid = $db->GenID("{$newtable_desc_name}" . "_id");
     $db->Execute("INSERT INTO {$newtable_desc_name} VALUES({$newid},'400','Notes','notes','Y','Y','N','text','textlong',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Y')");
     $newid = $db->GenID("{$newtable_desc_name}" . "_id");
     $filecolumnid = $newid;
     $db->Execute("INSERT INTO {$newtable_desc_name} VALUES({$newid},'600','File','file','Y','Y','N','text','file',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Y')");
     $filecolumnid = $newid;
     // and finally create the table
     $rc = $db->Execute(" CREATE TABLE {$newtable_realname} (\n         id int  NOT NULL,\n         access varchar(9) ,\n         ownerid int ,\n         magic int ,\n         lastmoddate int ,\n         lastmodby int ,\n         date int ,\n         type1 int ,\n         type2 int ,\n         title text ,\n         notes text ,\n         file text  ) ");
 }
 // copy data from 'old' protocol table to the new one
 unset($counter);
 set_magic_quotes_runtime(1);
 $tablesfk = get_cell($db, "tableoftables", "id", "real_tablename", "protocols");
 $rcb = $db->Execute("SELECT * FROM protocols");
 while (!$rcb->EOF && $rcb) {
     $newid = $db->Genid($newtable_realname . "_id_seq");
     $row = $rcb->fields;
     $rcopy = $db->Execute("INSERT INTO {$newtable_realname} VALUES ('{$newid}','{$row['access']}','{$row['ownerid']}','{$row['magic']}','{$row['lastmoddate']}','{$row['lastmodby']}','{$row['date']}','{$row['type1']}','{$row['type2']}','{$row['title']}','{$row['notes']}','{$row['file']}')");
     if (!$rcopy) {
         $failed = true;
     } else {
         $counter++;
         //change ownership of file to new table:
         $rfile = $db->Execute("UPDATE files SET tablesfk='{$newtableid}',ftableid='{$newid}',ftablecolumnid='{$filecolumnid}' WHERE tablesfk='{$tablesfk}' AND ftableid='{$row['id']}'");
         //adjust trusted users:
         $db->Execute("UPDATE trust SET tableid='{$newtableid}',recordid='{$newid}' WHERE tableid={$tablesfk} AND recordid='{$row['id']}'");
     }
     $rcb->MoveNext();
Пример #22
0
 } elseif ($modifiable == 'Y') {
     echo "<td><input type='radio' name='column_modifiable_{$id}' value='Y' onclick='tellServer(\"{$dbstring}\",{$id}, this.name, this.value)' CHECKED>yes";
     echo " <input type='radio' name='column_modifiable_{$id}' value='N' onclick='tellServer(\"{$dbstring}\",{$id}, this.name, this.value)'> no </td>\n";
 } else {
     echo "<td><input type='radio' name='column_modifiable_{$id}' value='Y' onclick='tellServer(\"{$dbstring}\",{$id}, this.name, this.value)'>yes";
     echo " <input type='radio' name='column_modifiable_{$id}' checked value='N' onclick='tellServer(\"{$dbstring}\",{$id}, this.name, this.value)'> no </td>\n";
 }
 echo "<input type='hidden' name='column_datatype_{$id}' value='{$label}'>\n";
 echo "<td>{$datatype}</td>\n";
 if ($ass_table || $ass_column) {
     echo "<td>";
     if (!$r->fields['associated_local_key']) {
         echo "<b>primary key</b><br>";
         echo "{$ass_table}<br>{$ass_column}</td>\n";
     } else {
         $ass_local_column = get_cell($db, $currdesc, 'label', 'id', $r->fields['associated_local_key']);
         echo "primary key: {$ass_local_column}<br>\n";
         echo "{$ass_column}</td>\n";
     }
 } else {
     echo "<td>&nbsp;</td>\n";
 }
 if ($link_first) {
     echo "<td>{$link_first} &nbsp;<i>content</i>&nbsp; {$link_last}</td>\n";
 } else {
     echo "<td>&nbsp;</td>\n";
 }
 $modstring = "<input type='submit' name='modcolumn" . "_{$id}' value='Modify'>\n";
 if ($datatype == "image") {
     $alinkstring = "<input type='hidden' name='thumbsize" . "_{$id}' value='{$thumbsize}'>\n";
     $alinkstring .= "<input type='submit' name='modcolumn" . "_{$id}' value='Thumbnail size' Onclick='var temp=window.prompt(\"Please enter the maximum thumbnail size (in pixels):\",\"{$thumbsize}\");if (temp) {document.tableform.thumbsize" . "_{$id}.value=temp} else {return false}; return true;' >\n";
<?php

session_start();
include 'config.php';
include 'db_functions.php';
$userid = $_SESSION['user_id'];
extract($_GET);
if ($id != "") {
    $fes_name = get_cell('fes', $id, 'fes_name');
    mysql_query("DELETE FROM `fes` WHERE  `id` = '{$id}'");
    //Event 6 = Deleted
    $affected_id = $id;
    $description = "Fes " . $fes_name . " Deleted";
    insert_log($userid, 6, 'fes', $affected_id, $description);
}
?>
<script>
window.top.window.manage_fes();
</script>
Пример #24
0
function plugin_getvalues($db, &$allfields, $id, $tableid)
{
    if (!$id) {
        return true;
    }
    $table_desc = get_cell($db, "tableoftables", "table_desc_name", "id", $tableid);
    $webmollink = get_cell($db, $table_desc, "link_first", "columnname", "webmol");
    while (list($key, $value) = each($allfields)) {
        if ($value[name] == "webmol") {
            $index = $key;
        }
        if ($value[name] == "pdbid") {
            $pdindex = $key;
        }
    }
    if ($index) {
        $pdbid = $allfields[$pdindex]["values"];
        if ($pdbid) {
            $link = $webmollink . $pdbid;
            $allfields[$index]["text"] = "<a href={$link}>{$pdbid}</a>";
        }
    }
}
Пример #25
0
/**
 *  Deletes an entry in the type table
 *
 * Currently, there can be only 1 related table ($table2)
 * When more are needed,make $table2 into an array 
 */
function del_type($db, $table, $id, $tableinfo)
{
    global $_POST, $_GET;
    if (!$id == $_POST["type_id_{$id}"]) {
        echo "ERROR";
    }
    if ($tableinfo->realname) {
        $recordref = get_cell($db, $tableinfo->desname, 'columnname', 'associated_table', $table);
        if ($id) {
            $r = $db->Execute("UPDATE {$tableinfo->realname} SET {$recordref}=NULL WHERE {$recordref}='{$id}'");
            if ($r) {
                $r = $db->Execute("DELETE FROM {$table} WHERE id={$id}");
            }
            if ($r) {
                $string = "<h3 align='center'>Record removed</h3>\n";
                echo update_opener_js($db, $table);
            }
        } else {
            $string = "<h3 align='center'>Please enter all fields</h3>\n";
        }
    } else {
        if ($id) {
            $table_array = explode('_', $table);
            $r = $db->Execute("UPDATE {$tableinfo->realname} SET " . $table_array[1] . "='' WHERE " . $table_array[1] . "={$id}");
            if ($r) {
                // keep database structure intact
                $r = $db->Execute("DELETE FROM {$table} WHERE id={$id}");
            }
            if ($r) {
                $string = "<h3 align='center'>Record removed</h3>\n";
                echo update_opener_js($db, $table);
            }
        } else {
            $string = "<h3 align='center'>Please enter all fields</h3>\n";
        }
    }
    echo "{$string}";
    return false;
}
Пример #26
0
     $db->Execute("INSERT INTO {$newtable_desc_name} VALUES({$newid},'300','Files','files','Y','Y','N','text','file',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Y')");
     $newid = $db->GenID("{$newtable_desc_name}" . "_id");
     $db->Execute("INSERT INTO {$newtable_desc_name} VALUES({$newid},'340','Buffer','buffer','N','Y','N','text','text',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Y')");
     $newid = $db->GenID("{$newtable_desc_name}" . "_id");
     $db->Execute("INSERT INTO {$newtable_desc_name} VALUES({$newid},'360','Concentration (mg/ml)','concentration','Y','Y','N','float','float',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Y')");
     $newid = $db->GenID("{$newtable_desc_name}" . "_id");
     $db->Execute("INSERT INTO {$newtable_desc_name} VALUES({$newid},'380','Source','source','N','Y','N','text','text',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Y')");
     $newid = $db->GenID("{$newtable_desc_name}" . "_id");
     $db->Execute("INSERT INTO {$newtable_desc_name} VALUES({$newid},'170','Epitope','epitope','N','Y','N','text','text',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Y')");
     // and finally create the table
     $rc = $db->Execute(" CREATE TABLE {$newtable_realname} (\n         id int  NOT NULL,\n         access varchar(9) ,\n         ownerid int ,\n         magic int ,\n         lastmoddate int ,\n         lastmodby int ,\n         date int ,\n         title text ,\n         antigen text ,\n         notes text ,\n         type1 int ,\n         type5 int ,\n         type2 int ,\n         type3 int ,\n         type4 int ,\n         location text ,\n         files text ,\n         buffer text ,\n         concentration float ,\n         source text ,\n         epitope text  ) ");
 }
 // copy data from 'old' protocol table to the new one
 unset($counter);
 set_magic_quotes_runtime(1);
 $tablesfk = get_cell($db, "tableoftables", "id", "real_tablename", "antibodies");
 $rcb = $db->Execute("SELECT * FROM antibodies");
 while (!$rcb->EOF && $rcb) {
     $newid = $db->Genid($newtable_realname . "_id_seq");
     $row = $rcb->fields;
     $rcopy = $db->Execute("INSERT INTO {$newtable_realname} VALUES ('{$newid}','{$row['access']}','{$row['ownerid']}','{$row['magic']}','{$row['lastmoddate']}','{$row['lastmodby']}','{$row['date']}','{$row['name']}','{$row['antigen']}','{$row['notes']}','{$row['type1']}','{$row['type5']}','{$row['type2']}','{$row['type3']}','{$row['type4']}','{$row['location']}','{$row['files']}','{$row['buffer']}','{$row['concentration']}','{$row['source']}','{$row['epitope']}')");
     if (!$rcopy) {
         $failed = true;
     } else {
         $counter++;
         //change ownership of file to new table:
         $rfile = $db->Execute("UPDATE files SET tablesfk='{$newtableid}',ftableid='{$newid}',ftablecolumnid='{$filecolumnid}' WHERE tablesfk='{$tablesfk}' AND ftableid='{$row['id']}'");
         //adjust trusted users:
         $db->Execute("UPDATE trust SET tableid='{$newtableid}',recordid='{$newid}' WHERE tableid={$tablesfk} AND recordid='{$row['id']}'");
     }
     $rcb->MoveNext();
Пример #27
0
     $newid = $db->GenID("{$newtable_desc_name}" . "_id");
     $db->Execute("INSERT INTO {$newtable_desc_name} VALUES({$newid},'180','Notes','notes','Y','Y','N','text','textlong',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Y')");
     $newid = $db->GenID("{$newtable_desc_name}" . "_id");
     $db->Execute("INSERT INTO {$newtable_desc_name} VALUES({$newid},'100','PDBID','pdbid','Y','Y','N','text','text',NULL,NULL,NULL,NULL,NULL,'http://www.rcsb.org/cgi/explre.cgi?pdbId=',NULL,'Y')");
     $newid = $db->GenID("{$newtable_desc_name}" . "_id");
     $filecolumnid = $newid;
     $db->Execute("INSERT INTO {$newtable_desc_name} VALUES({$newid},'220','File','file','Y','Y','N','text','file',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'Y')");
     $newid = $db->GenID("{$newtable_desc_name}" . "_id");
     $db->Execute("INSERT INTO {$newtable_desc_name} VALUES({$newid},'200','Webmol','webmol','Y','Y','N','text','text',NULL,NULL,NULL,NULL,NULL,'webmol.php?pdbid=',NULL,'N')");
     // and finally create the table
     $rc = $db->Execute(" CREATE TABLE {$newtable_realname} (\n         id int  NOT NULL,\n         access varchar(9) ,\n         ownerid int ,\n         magic int ,\n         lastmoddate int ,\n         lastmodby int ,\n         date int ,\n         title text ,\n         author text ,\n         notes text ,\n         pdbid text ,\n         file text ,\n         webmol text  ) ");
 }
 // copy data from 'old' pdbs table to the new one
 unset($counter);
 set_magic_quotes_runtime(1);
 $tablesfk = get_cell($db, "tableoftables", "id", "real_tablename", "pdbs");
 $rcb = $db->Execute("SELECT * FROM pdbs");
 while (!$rcb->EOF && $rcb) {
     $newid = $db->Genid($newtable_realname . "_id_seq");
     $row = $rcb->fields;
     $rcopy = $db->Execute("INSERT INTO {$newtable_realname} VALUES ('{$newid}','{$row['access']}','{$row['ownerid']}','{$row['magic']}','{$row['lastmoddate']}','{$row['lastmodby']}','{$row['date']}','{$row['title']}','{$row['author']}','{$row['notes']}','{$row['pdbid']}','{$row['file']}','{$row['pdbid']}')");
     if (!$rcopy) {
         $failed = true;
     } else {
         $counter++;
         //change ownership of file to new table:
         $rfile = $db->Execute("UPDATE files SET tablesfk='{$newtableid}',ftableid='{$newid}',ftablecolumnid='{$filecolumnid}' WHERE tablesfk='{$tablesfk}' AND ftableid='{$row['id']}'");
         //adjust trusted users:
         $db->Execute("UPDATE trust SET tableid='{$newtableid}',recordid='{$newid}' WHERE tableid={$tablesfk} AND recordid='{$row['id']}'");
     }
     $rcb->MoveNext();
Пример #28
0
    }
}
/*
// register global really kills some stuff, so let's kill them first
if (ini_get('register_globals')) {
   reset($_POST);
   while (list($key,$val)=each($_POST)) {
      unset (${$key});
   }
}
reset($_POST);
*/
// essential includes
include './includes/config_inc.php';
include './adodb/adodb.inc.php';
// be compatible with adodb version 1.80
$ADODB_FETCH_MODE = ADODB_FETCH_DEFAULT;
// Open connection to the database
$db = NewADOConnection($db_type);
if (!$db->Connect($db_host, $db_user, $db_pwd, $db_name)) {
    echo "<h3 color='red'>Fatal Error</h3>";
    echo "Could not connect to the database server.<br>";
    echo "Please report this problem to your system administrator.";
    exit;
}
// read in the database settings
$version = get_cell($db, 'settings', 'version', 'id', 1);
$system_settings = unserialize(get_cell($db, 'settings', 'settings', 'id', 1));
// set up temp dir for adodb
$ADODB_CACHE_DIR = $system_settings['tmpdir'];
$httptitle = 'PhpLabware: ';
<?php

session_start();
include 'config.php';
include 'db_functions.php';
$userid = $_SESSION['user_id'];
extract($_GET);
if ($id != "") {
    $device_imei = get_cell('device', $id, 'device_imei');
    mysql_query("DELETE FROM `device` WHERE  `id` = '{$id}'");
    //Event 6 = Deleted
    $affected_id = $id;
    $description = "Device IMEI " . $device_imei . " Deleted";
    insert_log($userid, 6, 'device', $affected_id, $description);
}
?>
<script>
window.top.window.manage_device();
</script>
<?php

include 'config.php';
include 'db_functions.php';
extract($_GET);
$dbpassword = get_cell('fes', $id, 'password');
if ($dbpassword == $old_password) {
    $flag = 1;
} else {
    $flag = 0;
}
?>
<input type="text" id="flag" name="flag" value="<?php 
echo $flag;
?>
">