function create($name, $type, $version, $port, $path)
 {
     $q0 = get_link()->prepare('insert into ' . get_ini('BDD_PREFIX') . 'cmdb_db_instances (id_os,name,db_type,db_version,db_port,db_bin_path,audited,created_date,created_id,edited_date,edited_id,deleted_date,deleted_id) VALUES (:id_os,:name,:db_type,:db_version,:db_port,:db_bin_path,:audited,:created_date,:created_id,0,0,0,0)');
     $q0->execute(array('id_os' => $this->idOs, 'name' => $name, 'db_type' => $type, 'db_version' => $version, 'db_port' => $port, 'db_bin_path' => $path, 'audited' => '-1', 'created_date' => time(), 'created_id' => $_SESSION['USER_ID']));
     // Create the object
     $obj = new objectManager();
     $obj->create(get_table_id('cmdb_db_instances'), $this->getId($name));
     return $this->getId($name);
 }
 function create($parentId, $name)
 {
     $q0 = get_link()->prepare('insert into ' . get_ini('BDD_PREFIX') . 'cmdb_environments (id_parent,name,created_date,created_id,edited_date,edited_id,deleted_date,deleted_id) VALUES (:id_parent,:name,:created_date,:created_id,0,0,0,0)');
     $q0->execute(array('id_parent' => $parentId, 'name' => $name, 'created_date' => time(), 'created_id' => $_SESSION['USER_ID']));
     // Create the object
     $obj = new objectManager();
     $obj->create(get_table_id('cmdb_environments'), $this->getId($name));
     return $this->getId($name);
 }
Пример #3
0
 function create($type, $port)
 {
     $q0 = get_link()->prepare('insert into ' . get_ini('BDD_PREFIX') . 'cmdb_dev_os (id_device,os_type,os_name,os_port,os_install_date,os_last_boot_time,os_memory_size,created_date,created_id,edited_date,edited_id,deleted_date,deleted_id) VALUES (:id_device,:type,\'\',:port,0,0,0,:created_date,:created_id,0,0,0,0)');
     $q0->execute(array('id_device' => $this->idDevice, 'type' => $type, 'port' => $port, 'created_date' => time(), 'created_id' => $_SESSION['USER_ID']));
     // Create the object
     $obj = new objectManager();
     $obj->create(get_table_id('cmdb_dev_os'), $this->getId($type, $port));
     return $this->getId($type, $port);
 }
 function create($name, $icon)
 {
     $q0 = get_link()->prepare('INSERT INTO ' . get_ini('BDD_PREFIX') . 'core_user_auth_methods (name,icon,created_id,created_date,edited_id,edited_date,deleted_id,deleted_date) VALUES (:name,:icon,:created_id,:created_date,0,0,0,0)');
     $q0->execute(array('name' => $name, 'icon' => $icon, 'created_id' => $_SESSION['USER_ID'], 'created_date' => time()));
     // Create the object
     $obj = new objectManager();
     $obj->create(get_table_id('core_user_auth_methods'), $this->getId($name));
     // Return the id of this new group
     return $this->getId($name);
 }
Пример #5
0
 function create($idPlugin, $page)
 {
     $q0 = get_link()->prepare('INSERT INTO ' . get_ini('BDD_PREFIX') . 'core_jobs (id_plugin,page,last_run_pid,last_run,created_id,created_date,edited_id,edited_date,deleted_id,deleted_date) VALUES (:id_plugin,:page,0,0,:created_id,:created_date,0,0,0,0)');
     $q0->execute(array('id_plugin' => $idPlugin, 'page' => $page, 'created_id' => $_SESSION['USER_ID'], 'created_date' => time()));
     // Create the object
     $obj = new objectManager();
     $obj->create(get_table_id('core_job'), $this->getId($idPlugin, $page));
     // Return the id of this new group
     return $this->getId($idPlugin, $page);
 }
Пример #6
0
 function create($name, $version)
 {
     $q0 = get_link()->prepare('INSERT INTO ' . get_ini('BDD_PREFIX') . 'core_plugins (name,version,activated,created_id,created_date,edited_id,edited_date,deleted_id,deleted_date) VALUES (:name,:version,0,:created_id,:created_date,0,0,0,0)');
     $q0->execute(array('name' => $name, 'version' => $version, 'created_id' => $_SESSION['USER_ID'], 'created_date' => time()));
     // Create the object
     $obj = new objectManager();
     $obj->create(get_table_id('core_plugins'), $this->getId($name));
     // Return the id of this new page
     return $this->getId($name);
 }
Пример #7
0
function print_table_id($length = 8)
{
    echo get_table_id($length);
}
Пример #8
0
 function charger_args($args)
 {
     $args = explode('/', $args);
     // cas ~id_auteur/
     if ($args[0][0] == '~') {
         $table = 'spip_auteurs';
         $colid = array('id_auteur');
         list($auteur, $colonne) = explode('@', array_shift($args));
         if (count($auteur) > 1) {
             $id = substr($auteur, 1);
         } else {
             $id = $GLOBALS['auteur_session'] ? $GLOBALS['auteur_session']['id_auteur'] : '';
         }
         // cas table:id/
         // peut etre table:id:id/ si la table a 2 cles
     } else {
         list($table, $id) = explode(':', array_shift($args), 2);
         list($table, $colonne) = explode('@', $table);
         list($table, $colid) = get_table_id($table);
     }
     $this->param->cfg_id = $id;
     $this->param->colonne = $colonne ? $colonne : 'cfg';
     $this->param->table = $table ? $table : 'spip_auteurs';
     $this->param->nom = array_shift($args);
     if ($champ = array_pop($args)) {
         $this->champs = array($champ => true);
     }
     $this->param->casier = implode('/', $args);
     // renseigner les liens id=valeur
     $id = explode(':', $id);
     foreach ($colid as $n => $c) {
         if (isset($id[$n])) {
             $this->_id[$c] = $id[$n];
         }
     }
     return true;
 }
     break;
 case 'get_menu':
     $keyword = $_GET['keyword'];
     $data['menu_id'] = select_menu($keyword);
     return $data;
     break;
 case 'delete_history':
     $id = get_isset($_GET['id']);
     $table_id = get_isset($_GET['table_id']);
     delete_history($id);
     header("Location: transaction_new.php?table_id={$table_id}&did=3");
     break;
 case 'delete_item':
     $id = get_isset($_GET['id']);
     $member_id = get_member_id($id);
     $table_id = get_table_id($id);
     delete_item($id);
     header("Location: transaction_new.php?table_id={$table_id}&member_id={$member_id}&did=3");
     break;
 case 'delete_item_edit':
     $id = get_isset($_GET['id']);
     $table_id = get_isset($_GET['table_id']);
     delete_item_edit($id);
     header("Location: transaction_new.php?page=list_edit&table_id={$table_id}");
     break;
 case 'list_history':
     //get_header($title);
     $table_id = get_isset($_GET['table_id']);
     $check_table = check_table($table_id);
     if ($check_table > 0) {
         $query_history = select_history($table_id);
Пример #10
0
			</form>
		';
        $hint = array('Here you can change your personal information. Remember to press the \'Update\' button to store the changes.', 'Leave all password fields blank to keep your old password.');
        if ($CFG_USEEMAIL) {
            $hint[] = 'Enter a valid email address if you would like to be notified when your opponent makes a move. Leave blank otherwise.';
        }
        $html = get_item($contents, $hint);
        break;
        // ====================================================
    // ====================================================
    case 'admin':
        if (true != $_SESSION['is_admin']) {
            header('Location: index.php');
            exit;
        }
        $table_id = get_table_id();
        $contents .= '
			<form name="Admin" action="index.php?page=admin" method="post">
				<h2>Administration</h2>
				Click the relevant box next to each user, then click on \'Admin\' below to affect those changes.
				<table class="sort-table" id="' . $table_id . '">
					<thead>
						<tr>
							<th>ID</th>
							<th>Username</th>
							<th>First</th>
							<th>Last</th>
							<th>Email</th>
							<th>Create Date</th>
							<th>Reset Pass ?</th>
							<th>Admin ?</th>
Пример #11
0
 function charger_args($args)
 {
     list($table, $id) = explode(':', $args, 2);
     list($table, $colonne) = explode('@', $table);
     list($table, $colid) = get_table_id($table);
     $this->param->cfg_id = $id;
     $this->param->champs = $colonne ? array($colonne => true) : '';
     $this->param->table = $table ? $table : 'spip_cfg';
     // renseigner les liens id=valeur
     $id = explode(':', $id);
     foreach ($colid as $n => $c) {
         if (isset($id[$n])) {
             $this->_id[$c] = $id[$n];
         }
     }
     return true;
 }
Пример #12
0
 function user($id)
 {
     $this->id = $id;
     // Get the user informations
     $q0 = get_link()->prepare("SELECT \n\t\t\t\t\t\t\t\t\tusr.id AS ID,\n\t\t\t\t\t\t\t\t\tusr.name AS NAME,\n\t\t\t\t\t\t\t\t\tusr.avatar AS AVATAR,\n\t\t\t\t\t\t\t\t\tusr.mail AS MAIL,\n\t\t\t\t\t\t\t\t\tobj.id AS OBJECTID,\n\t\t\t\t\t\t\t\t\tusr.created_date AS CREATED_DATE,\n\t\t\t\t\t\t\t\t\tusr.created_id AS CREATED_ID,\n\t\t\t\t\t\t\t\t\tusr.edited_date AS EDITED_DATE,\n\t\t\t\t\t\t\t\t\tusr.edited_id AS EDITED_ID,\n\t\t\t\t\t\t\t\t\tusr.deleted_date AS DELETED_DATE,\n\t\t\t\t\t\t\t\t\tusr.deleted_id AS DELETED_ID\n\t\t\t\t\t\t\t\tFROM \n\t\t\t\t\t\t\t\t" . get_ini('BDD_PREFIX') . "core_users usr,\n\t\t\t\t\t\t\t\t" . get_ini('BDD_PREFIX') . "core_objects obj\n\t\t\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t\t\tusr.id=obj.id_ext AND\n\t\t\t\t\t\t\t\t\tobj.id_table=:id_table AND\n\t\t\t\t\t\t\t\t\tobj.deleted_date=0 AND\n\t\t\t\t\t\t\t\t\tusr.id=:id");
     $q0->execute(array('id' => $id, 'id_table' => get_table_id('core_users')));
     $r0 = $q0->fetch(PDO::FETCH_OBJ);
     if (isset($r0->ID)) {
         $this->name = _($r0->NAME);
         $this->avatar = $r0->AVATAR;
         $this->mail = $r0->MAIL;
         $this->objectId = $r0->OBJECTID;
         $this->createdDate = $r0->CREATED_DATE;
         $this->createdID = $r0->CREATED_ID;
         $this->editedDate = $r0->EDITED_DATE;
         $this->editedId = $r0->EDITED_ID;
         $this->deletedDate = $r0->DELETED_DATE;
         $this->deltedId = $r0->DELETED_ID;
         // Map user groups and get the object id
         $this->groupIdArray = array();
         $this->groupObjectIdArray = array();
         $q1 = get_link()->prepare("SELECT \n\t\t\t\t\t\t\t\t\t\tobj.id AS OBJECTID,\n\t\t\t\t\t\t\t\t\t\tmap.group_id AS GROUPID\n\t\t\t\t\t\t\t\t\tFROM \n\t\t\t\t\t\t\t\t\t\t" . get_ini('BDD_PREFIX') . "core_groups_users_map map,\n\t\t\t\t\t\t\t\t\t\t" . get_ini('BDD_PREFIX') . "core_objects obj\n\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\tobj.deleted_date=0 AND\n\t\t\t\t\t\t\t\t\t\tmap.deleted_date=0 AND\n\t\t\t\t\t\t\t\t\t\tmap.user_id = :id AND\n\t\t\t\t\t\t\t\t\t\tmap.group_id = obj.id_ext AND\n\t\t\t\t\t\t\t\t\t\tobj.id_table = :id_table\n\t\t\t\t\t\t\t\t\t");
         $q1->execute(array('id' => $this->id, 'id_table' => get_table_id('core_groups')));
         while ($r1 = $q1->fetch(PDO::FETCH_OBJ)) {
             array_push($this->groupIdArray, $r1->GROUPID);
             array_push($this->groupObjectIdArray, $r1->OBJECTID);
         }
         $q1->closeCursor();
     } else {
         if ($_SESSION['USER_ID'] == $id) {
             unset($_SESSION);
             session_destroy();
             // TODO add log management
             echo 'There is something wrong with your account. Try to refresh the page then contact your administator.';
             exit(100);
         } else {
             // TODO add log management
             echo 'The user does not exist.';
             exit(100);
         }
     }
     $q0->closeCursor();
 }
Пример #13
0
function get_game_table($label, $no_data_label, $data, $type = 'full')
{
    global $mysql;
    global $CFG_CHESS960, $CFG_LONGDATE;
    if (!is_array($data) || 0 == count($data)) {
        $html = '<div class="notable">' . $no_data_label . '</div>';
    } else {
        $sort_c960 = $CFG_CHESS960 ? ' , StringCI' : '';
        $sort_finished = 'finished' == $type ? ' , StringCI' : '';
        $sort_invite = 'invite' == $type ? ' , None' : ' , LongDate';
        $sort_moves = 'invite' == $type ? ' , StringCI' : ' , Number';
        $sort_gameid = 'invite' == $type ? '' : 'Number , ';
        $sort = $sort_gameid . 'StringCI , StringCI , StringCI ' . $sort_moves . $sort_c960 . $sort_finished . ' , LongDate ' . $sort_invite;
        call($sort);
        $table_id = get_table_id();
        $link_table = 'invite' != $type ? ' link-table' : '';
        $html = '<table class="sort-table' . $link_table . '" id="' . $table_id . '">
					<caption>' . $label . '</caption>
					<thead>
						<tr>
							';
        if ('invite' != $type) {
            $html .= '<th title="Game ID Number">Game</th>';
        }
        $html .= '
							<th title="White\'s username">White</th>
							<th title="Black\'s username">Black</th>
							<th title="Who\'s turn it is">Turn</th>
							';
        if ('invite' != $type) {
            $html .= '<th title="Moves">Moves</th>';
        } else {
            $html .= '<th title="Status">Status</th>';
        }
        if ($CFG_CHESS960) {
            $html .= '<th title="Game Type">Type</th>';
        }
        if ('finished' == $type) {
            $html .= '<th title="Game Result">Result</th>';
        }
        $html .= '
							<th title="Start Date of the Game">Start Date</th>
							';
        if ('invite' != $type) {
            $html .= '<th title="Date / Time of Last Move">Last Move</th>';
        } else {
            $html .= '<th title="Action">Action</th>';
        }
        $html .= '
						</tr>
					</thead>
					<tbody>
						';
        $i = 0;
        foreach ($data as $game) {
            // we need some default values for some variables
            $myturn = false;
            $white = '';
            $black = '';
            $curMove = 0 == $game['num_moves'] % 2 ? 'white' : 'black';
            switch ($type) {
                case 'mine':
                    $link = ' onclick="loadGame(' . $game['g_id'] . ');"';
                    // based on number of moves, figure out who's turn it is
                    $color = $game['g_white_player_id'] == $_SESSION['player_id'] ? 'white' : 'black';
                    if ($curMove == $color) {
                        $myturn = true;
                    }
                    break;
                case 'others':
                    $link = ' onclick="watchGame(' . $game['g_id'] . ');"';
                    break;
                case 'finished':
                    $link = ' onclick="watchGame(' . $game['g_id'] . ');"';
                    if ($game['g_white_player_id'] == $_SESSION['player_id']) {
                        $link = ' onclick="loadGame(' . $game['g_id'] . ');"';
                        $white = ' class="notice"';
                    } elseif ($game['g_black_player_id'] == $_SESSION['player_id']) {
                        $link = ' onclick="loadGame(' . $game['g_id'] . ');"';
                        $black = ' class="notice"';
                    }
                    if (is_null($game['g_game_message'])) {
                        $result = '';
                    } else {
                        if ('Draw' == $game['g_game_message']) {
                            $result = '½-½';
                        } elseif ('Player Resigned' == $game['g_game_message']) {
                            $result = 'white' == $game['g_message_from'] ? '0-1' : '1-0';
                            $result .= ' <abbr title="Resignation">R</abbr>';
                        } elseif ('Checkmate' == $game['g_game_message']) {
                            $result = 'white' == $game['g_message_from'] ? '1-0' : '0-1';
                            $result .= ' <abbr title="Checkmate">CM</abbr>';
                        } else {
                            $result = '';
                        }
                    }
                    break;
                case 'invite':
                    $link = '';
                    $from = $game['white_username'] == $_SESSION['username'] ? 'white' : 'black';
                    $status = substr($game['g_game_message'], strrpos(trim($game['g_game_message']), ' ') + 1);
                    $status = 'Declined' == $status ? '<span class="notice">' . $status . '</span>' : $status;
                    // based on which it is, outvite or invite, make the buttons
                    if (isset($game['invite'])) {
                        $buttons = '
										<input class="tblbutton" type="button" value="Accept" onclick="sendresponse(\'accepted\',\'' . $from . '\',' . $game['g_id'] . ')" />
										<input class="tblbutton" type="button" value="Decline" onclick="sendresponse(\'declined\',\'' . $from . '\',' . $game['g_id'] . ')" />
									';
                    } else {
                        $buttons = '
										<input class="tblbutton" type="button" value="Withdraw" onclick="withdrawrequest(' . $game['g_id'] . ')" />
									';
                    }
                    break;
            }
            // end type switch
            $alt = 0 == $i % 2 ? true : false;
            call($myturn);
            $class = '';
            if ($myturn || $alt) {
                $class = ' class="';
                if ($myturn && $alt) {
                    $class .= 'myturn alt';
                } elseif ($alt) {
                    $class .= 'alt';
                } else {
                    $class .= 'myturn';
                }
                $class .= '"';
            }
            $html .= "<tr{$link}{$class}>\n";
            if ('invite' != $type) {
                $html .= "\t<td class=\"numeric\">{$game['g_id']}</td>\n";
            }
            $html .= "\t<td{$white}>{$game['white_username']}</td>\n";
            $html .= "\t<td{$black}>{$game['black_username']}</td>\n";
            $html .= "\t<td>" . ucfirst($curMove) . "</td>\n";
            if ('invite' != $type) {
                $html .= "\t<td class=\"numeric\">" . floor($game['num_moves'] / 2) . "</td>\n";
            } else {
                $html .= "\t<td>" . $status . "</td>\n";
            }
            if ($CFG_CHESS960) {
                $gametype = 518 != $game['g_id960'] ? 'C960' : 'Normal';
                $html .= "\t<td>{$gametype}</td>\n";
            }
            if ('finished' == $type) {
                $html .= "\t<td>{$result}</td>\n";
            }
            $html .= "\t<td class=\"date\">" . date($CFG_LONGDATE, $game['u_date_created']) . "</td>\n";
            if ('invite' != $type) {
                $html .= "\t<td class=\"date\">" . date($CFG_LONGDATE, $game['u_last_move']) . "</td>\n";
            } else {
                $html .= "\t<td class=\"buttons\">" . $buttons . "</td>\n";
            }
            $html .= '</tr>';
            ++$i;
        }
        $html .= '
					</tbody>
				</table>
				';
        $html .= get_sorttable_script($table_id, $sort);
    }
    return $html;
}