function plugin_addressing_install() { global $DB; include_once GLPI_ROOT . "/plugins/addressing/inc/profile.class.php"; $update = false; if (!TableExists("glpi_plugin_addressing_display") && !TableExists("glpi_plugin_addressing") && !TableExists("glpi_plugin_addressing_configs")) { $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/empty-1.9.0.sql"); } else { $update = true; if (!TableExists("glpi_plugin_addressing_profiles") && !FieldExists("glpi_plugin_addressing_display", "ipconf1")) { //1.4 $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.4.sql"); } if (!TableExists("glpi_plugin_addressing") && TableExists("glpi_plugin_addressing_display") && FieldExists("glpi_plugin_addressing_display", "ipconf1")) { $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.5.sql"); } if (TableExists("glpi_plugin_addressing_display") && !FieldExists("glpi_plugin_addressing", "ipdeb")) { $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.6.sql"); } if (TableExists("glpi_plugin_addressing_profiles") && FieldExists("glpi_plugin_addressing_profiles", "interface")) { $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.7.0.sql"); } if (!TableExists("glpi_plugin_addressing_configs")) { $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.8.0.sql"); } if (!fieldExists("glpi_plugin_addressing_profiles", "use_ping_in_equipment")) { $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.9.0.sql"); } } if ($update) { $query_ = "SELECT *\n FROM `glpi_plugin_addressing_profiles` "; $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { while ($data = $DB->fetch_array($result_)) { $query = "UPDATE `glpi_plugin_addressing_profiles`\n SET `profiles_id` = '" . $data["id"] . "'\n WHERE `id` = '" . $data["id"] . "'"; $result = $DB->query($query); } } if (FieldExists("glpi_plugin_addressing_profiles", "name")) { $query = "ALTER TABLE `glpi_plugin_addressing_profiles`\n DROP `name` "; $result = $DB->query($query); } Plugin::migrateItemType(array(5000 => 'PluginAddressingAddressing', 5001 => 'PluginAddressingReport'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets")); } PluginAddressingProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); return true; }
public function validateUser($data) { if ($data['password'] == $data['password2']) { if (!fieldExists("users", "email", $data['email'])) { if (substr($data['email'], -25) == "@pilani.bits-pilani.ac.in") { if (!fieldExists("users", "username", $data['username'])) { return true; } else { echo 'Username already taken. Please choose a different one.'; } } else { echo 'Use your BITS mail only'; } } else { echo 'Email already registered. Please choose a different one.'; } } else { echo 'Password mismatch.'; } }
/** * Verify database */ function verifyDatabase() { /* required tables */ $reqTables = array("instructions", "ipaddresses", "logs", "requests", "sections", "settings", "settingsDomain", "subnets", "devices", "deviceTypes", "users", "vrf", "vlans", "widgets", "changelog", "userGroups", "lang", "api", "settingsMail"); /* required fields for each table */ $fields['instructions'] = array("instructions"); $fields['ipaddresses'] = array("subnetId", "ip_addr", "description", "dns_name", "mac", "owner", "switch", "port", "owner", "state", "note", "lastSeen", "excludePing"); $fields['logs'] = array("severity", "date", "username", "ipaddr", "command", "details"); $fields['requests'] = array("subnetId", "ip_addr", "description", "dns_name", "owner", "requester", "comment", "processed", "accepted", "adminComment"); $fields['sections'] = array("name", "description", "permissions", "strictMode", "subnetOrdering", "order", "showVLAN", "showVRF", "masterSection"); $fields['settings'] = array("siteTitle", "siteAdminName", "siteAdminMail", "siteDomain", "siteURL", "domainAuth", "enableIPrequests", "enableVRF", "enableDNSresolving", "version", "dbverified", "donate", "IPfilter", "printLimit", "visualLimit", "vlanDuplicate", "vlanMax", "subnetOrdering", "pingStatus", "defaultLang", "api", "editDate", "vcheckDate", "dhcpCompress", "enableChangelog", "scanPingPath", "scanMaxThreads", "prettyLinks", "hideFreeRange", "hiddenCustomFields", "inactivityTimeout"); $fields['settingsDomain'] = array("account_suffix", "base_dn", "domain_controllers", "use_ssl", "use_tls", "ad_port", "adminUsername", "adminPassword"); $fields['subnets'] = array("subnet", "mask", "sectionId", "description", "masterSubnetId", "vrfId", "allowRequests", "vlanId", "showName", "permissions", "pingSubnet", "discoverSubnet", "isFolder"); $fields['devices'] = array("hostname", "ip_addr", "type", "vendor", "model", "version", "description", "sections"); $fields['deviceTypes'] = array("tid", "tname", "tdescription"); $fields['users'] = array("username", "password", "groups", "role", "real_name", "email", "domainUser", "lang", "widgets", "favourite_subnets", "mailNotify", "mailChangelog", "passChange"); $fields['vrf'] = array("vrfId", "name", "rd", "description"); $fields['vlans'] = array("vlanId", "name", "number", "description"); $fields['userGroups'] = array("g_id", "g_name", "g_desc"); $fields['lang'] = array("l_id", "l_code", "l_name"); $fields['api'] = array("app_id", "app_code", "app_permissions", "app_comment"); $fields['changelog'] = array("cid", "ctype", "coid", "cuser", "caction", "cresult", "cdate", "cdiff"); $fields['widgets'] = array("wid", "wtitle", "wdescription", "wfile", "wparams", "whref", "wsize", "wadminonly", "wactive"); $fields['settingsMail'] = array("id", "mtype", "mauth", "mserver", "mport", "muser", "mpass", "mAdminName", "mAdminMail", "msecure"); /** * check that each database exist - if it does check also fields * 2 errors -> $tableError, $fieldError[table] = field ****************************************************************/ foreach ($reqTables as $table) { //check if table exists if (!tableExists($table)) { $error['tableError'][] = $table; } else { foreach ($fields[$table] as $field) { //if it doesnt exist store error if (!fieldExists($table, $field)) { $error['fieldError'][$table] = $field; } } } } /* result */ if (isset($error)) { return $error; } else { return array(); } }
$fields['vlans'] = array("vlanId", "name", "number", "description"); $fields['userGroups'] = array("g_id", "g_name", "g_descr"); $fields['lang'] = array("l_id", "l_code", "l_name"); $fields['api'] = array("app_id", "app_code", "app_permissions"); /** * check that each database exist - if it does check also fields * 2 errors -> $tableError, $fieldError[table] = field ****************************************************************/ foreach ($reqTables as $table) { //check if table exists if (!tableExists($table)) { $tableError[] = $table; } else { foreach ($fields[$table] as $field) { //if it doesnt exist store error if (!fieldExists($table, $field)) { $fieldError[$table] = $field; } } } } /* print result */ if (!isset($tableError) && !isset($fieldError)) { print '<div class="alert alert-success alert-absolute">' . _('All tables and fields are installed properly') . '!</div>' . "\n"; } else { if (isset($tableError)) { print '<div class="alert alert-error alert-absolute" style="text-align:left;">' . "\n"; print '<b>' . _('Missing table') . 's:</b>' . "\n"; print '<ul>' . "\n"; foreach ($tableError as $table) { print '<li>' . $table . '</li>' . "\n";