本文整理汇总了PHP中Toolbox::encrypt方法的典型用法代码示例。如果您正苦于以下问题:PHP Toolbox::encrypt方法的具体用法?PHP Toolbox::encrypt怎么用?PHP Toolbox::encrypt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Toolbox
的用法示例。
在下文中一共展示了Toolbox::encrypt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
static function install(Migration $mig)
{
global $DB;
$table = 'glpi_plugin_sccm_configs';
if (!TableExists($table)) {
$query = "CREATE TABLE `" . $table . "`(\n `id` int(11) NOT NULL,\n `sccmdb_host` VARCHAR(255) NULL,\n `sccmdb_dbname` VARCHAR(255) NULL,\n `sccmdb_user` VARCHAR(255) NULL,\n `sccmdb_password` VARCHAR(255) NULL,\n `fusioninventory_url` VARCHAR(255) NULL,\n `active_sync` tinyint(1) NOT NULL default '0',\n `date_mod` datetime default NULL,\n `comment` text,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$DB->queryOrDie($query, __("Error when using glpi_plugin_sccm_configs table.", "sccm") . "<br />" . $DB->error());
$sccmdb_password = Toolbox::encrypt("", GLPIKEY);
$query = "INSERT INTO `{$table}`\n (id, date_mod, sccmdb_host, sccmdb_dbname, \n sccmdb_user, sccmdb_password, fusioninventory_url)\n VALUES (1, NOW(), 'srv_sccm','bdd_sccm','user_sccm','" . $sccmdb_password . "',\n 'http://glpi/plugins/fusioninventory/front/communication.php')";
$DB->queryOrDie($query, __("Error when using glpi_plugin_sccm_configs table.", "sccm") . "<br />" . $DB->error());
}
return true;
}
示例2: prepareInputForAdd
/**
* @see CommonDBTM::prepareInputForAdd()
**/
function prepareInputForAdd($input)
{
if (isset($input["passwd"])) {
if (empty($input["passwd"])) {
unset($input["passwd"]);
} else {
$input["passwd"] = Toolbox::encrypt(stripslashes($input["passwd"]), GLPIKEY);
}
}
if (isset($input['mail_server']) && !empty($input['mail_server'])) {
$input["host"] = Toolbox::constructMailServerConfig($input);
}
if (!NotificationMail::isUserAddressValid($input['name'])) {
Session::addMessageAfterRedirect(__('Invalid email address'), false, ERROR);
}
return $input;
}
示例3: prepareInputForAdd
function prepareInputForAdd($input)
{
//If it's the first ldap directory then set it as the default directory
if (!self::getNumberOfServers()) {
$input['is_default'] = 1;
}
if (isset($input["rootdn_passwd"]) && !empty($input["rootdn_passwd"])) {
$input["rootdn_passwd"] = Toolbox::encrypt(stripslashes($input["rootdn_passwd"]), GLPIKEY);
}
return $input;
}
示例4: prepareInputForUpdate
/**
* Prepare input datas for updating the item
*
* @see CommonDBTM::prepareInputForUpdate()
*
* @param $input array of datas used to update the item
*
* @return the modified $input array
**/
function prepareInputForUpdate($input)
{
global $CFG_GLPI;
// Update only an item
if (isset($input['context'])) {
return $input;
}
// Process configuration for plugins
if (!empty($input['config_context'])) {
$config_context = $input['config_context'];
unset($input['id']);
unset($input['_glpi_csrf_token']);
unset($input['update']);
unset($input['config_context']);
if (!empty($input['config_class']) && class_exists($input['config_class']) && method_exists($input['config_class'], 'configUpdate')) {
$config_method = $input['config_class'] . '::configUpdate';
unset($input['config_class']);
$input = call_user_func($config_method, $input);
}
$this->setConfigurationValues($config_context, $input);
return false;
}
if (isset($input['allow_search_view']) && !$input['allow_search_view']) {
// Global search need "view"
$input['allow_search_global'] = 0;
}
if (isset($input["smtp_passwd"])) {
if (empty($input["smtp_passwd"])) {
unset($input["smtp_passwd"]);
} else {
$input["smtp_passwd"] = Toolbox::encrypt(stripslashes($input["smtp_passwd"]), GLPIKEY);
}
}
if (isset($input["_blank_smtp_passwd"]) && $input["_blank_smtp_passwd"]) {
$input['smtp_passwd'] = '';
}
if (isset($input["proxy_passwd"])) {
if (empty($input["proxy_passwd"])) {
unset($input["proxy_passwd"]);
} else {
$input["proxy_passwd"] = Toolbox::encrypt(stripslashes($input["proxy_passwd"]), GLPIKEY);
}
}
if (isset($input["_blank_proxy_passwd"]) && $input["_blank_proxy_passwd"]) {
$input['proxy_passwd'] = '';
}
// Manage DB Slave process
if (isset($input['_dbslave_status'])) {
$already_active = DBConnection::isDBSlaveActive();
if ($input['_dbslave_status']) {
DBConnection::changeCronTaskStatus(true);
if (!$already_active) {
// Activate Slave from the "system" tab
DBConnection::createDBSlaveConfig();
} else {
if (isset($input["_dbreplicate_dbhost"])) {
// Change parameter from the "replicate" tab
DBConnection::saveDBSlaveConf($input["_dbreplicate_dbhost"], $input["_dbreplicate_dbuser"], $input["_dbreplicate_dbpassword"], $input["_dbreplicate_dbdefault"]);
}
}
}
if (!$input['_dbslave_status'] && $already_active) {
DBConnection::deleteDBSlaveConfig();
DBConnection::changeCronTaskStatus(false);
}
}
// Matrix for Impact / Urgence / Priority
if (isset($input['_matrix'])) {
$tab = array();
for ($urgency = 1; $urgency <= 5; $urgency++) {
for ($impact = 1; $impact <= 5; $impact++) {
$priority = $input["_matrix_{$urgency}_{$impact}"];
$tab[$urgency][$impact] = $priority;
}
}
$input['priority_matrix'] = exportArrayToDB($tab);
$input['urgency_mask'] = 0;
$input['impact_mask'] = 0;
for ($i = 1; $i <= 5; $i++) {
if ($input["_urgency_{$i}"]) {
$input['urgency_mask'] += 1 << $i;
}
if ($input["_impact_{$i}"]) {
$input['impact_mask'] += 1 << $i;
}
}
}
// Beware : with new management system, we must update each value
unset($input['id']);
unset($input['_glpi_csrf_token']);
unset($input['update']);
//.........这里部分代码省略.........
示例5: update0782to080
//.........这里部分代码省略.........
$user_id = 0;
if ($data['users_id'] > 0) {
$user_id = $data['users_id'];
}
$user_email = '';
if (strcasecmp($data['user_email'], $data['EMAIL']) != 0) {
$user_email = addslashes($data['user_email']);
}
$query = "INSERT INTO `glpi_tickets_users`\n (`tickets_id`, `users_id`,`type`,\n `use_notification`, `alternative_email`)\n VALUES ('" . $data['id'] . "', '{$user_id}', '" . CommonITILActor::REQUESTER . "',\n '" . $data['use_email_notification'] . "', '{$user_email}')";
$DB->queryOrDie($query, "0.80 migrate data to glpi_tickets_users table");
}
}
}
}
$migration->dropField('glpi_tickets', 'users_id');
$migration->dropField('glpi_tickets', 'users_id_assign');
$migration->dropField('glpi_tickets', 'use_email_notification');
$migration->dropField('glpi_tickets', 'user_email');
// ADD observer when requester is set : 3>21 / 13>20 / 12 >22
$fromto = array(3 => 21, 13 => 20, 12 => 22);
// GROUP_SUPERVISOR
foreach ($fromto as $from => $to) {
$query = "SELECT *\n FROM `glpi_notificationtargets`\n INNER JOIN `glpi_notifications`\n ON (`glpi_notifications`.`id` = `glpi_notificationtargets`.`notifications_id`)\n WHERE `glpi_notifications`.`itemtype` = 'Ticket'\n AND `glpi_notificationtargets`.`type` = '1'\n AND `glpi_notificationtargets`.`items_id` = '{$from}'";
if ($result = $DB->query($query)) {
if ($DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$query = "INSERT INTO `glpi_notificationtargets`\n (`items_id` ,`type` ,`notifications_id`)\n VALUES ('{$to}', '1', '" . $data['notifications_id'] . "')";
$DB->queryOrDie($query, "0.80 insert default notif for observer");
}
}
}
}
}
$migration->displayMessage(sprintf(__('Data migration - %s'), 'passwords encryption'));
if ($migration->addField('glpi_configs', 'proxy_passwd', 'varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL')) {
$migration->migrationOneTable('glpi_configs');
$query = "SELECT `proxy_password`\n FROM `glpi_configs`\n WHERE `id` = '1'";
if ($result = $DB->query($query)) {
if ($DB->numrows($result) > 0) {
$value = $DB->result($result, 0, 0);
if (!empty($value)) {
$query = "UPDATE `glpi_configs`\n SET `proxy_passwd` = '" . addslashes(Toolbox::encrypt($value, GLPIKEY)) . "'\n WHERE `id` = '1' ";
$DB->queryOrDie($query, "0.80 update proxy_passwd in glpi_configs");
}
}
}
$migration->dropField('glpi_configs', 'proxy_password');
}
if ($migration->addField('glpi_configs', 'smtp_passwd', 'varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL')) {
$migration->migrationOneTable('glpi_configs');
$query = "SELECT `smtp_password`\n FROM `glpi_configs`\n WHERE `id` = '1'";
if ($result = $DB->query($query)) {
if ($DB->numrows($result) > 0) {
$value = $DB->result($result, 0, 0);
if (!empty($value)) {
$query = "UPDATE `glpi_configs`\n SET `smtp_passwd` = '" . addslashes(Toolbox::encrypt($value, GLPIKEY)) . "'\n WHERE `id` = '1' ";
$DB->queryOrDie($query, "0.80 update smtp_passwd in glpi_configs");
}
}
}
$migration->dropField('glpi_configs', 'smtp_password');
}
if ($migration->addField('glpi_authldaps', 'rootdn_passwd', 'varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL')) {
$migration->migrationOneTable('glpi_authldaps');
$query = "SELECT *\n FROM `glpi_authldaps`\n WHERE `rootdn_password` IS NOT NULL\n AND `rootdn_password` <> ''";
if ($result = $DB->query($query)) {
示例6: prepareInputForUpdate
/**
* Prepare input datas for updating the item
*
* @see CommonDBTM::prepareInputForUpdate()
*
* @param $input array of datas used to update the item
*
* @return the modified $input array
**/
function prepareInputForUpdate($input)
{
if (isset($input['allow_search_view']) && !$input['allow_search_view']) {
// Global search need "view"
$input['allow_search_global'] = 0;
}
if (isset($input["smtp_passwd"])) {
if (empty($input["smtp_passwd"])) {
unset($input["smtp_passwd"]);
} else {
$input["smtp_passwd"] = Toolbox::encrypt(stripslashes($input["smtp_passwd"]), GLPIKEY);
}
}
if (isset($input["_blank_smtp_passwd"]) && $input["_blank_smtp_passwd"]) {
$input['smtp_passwd'] = '';
}
if (isset($input["proxy_passwd"])) {
if (empty($input["proxy_passwd"])) {
unset($input["proxy_passwd"]);
} else {
$input["proxy_passwd"] = Toolbox::encrypt(stripslashes($input["proxy_passwd"]), GLPIKEY);
}
}
if (isset($input["_blank_proxy_passwd"]) && $input["_blank_proxy_passwd"]) {
$input['proxy_passwd'] = '';
}
// Manage DB Slave process
if (isset($input['_dbslave_status'])) {
$already_active = DBConnection::isDBSlaveActive();
if ($input['_dbslave_status']) {
DBConnection::changeCronTaskStatus(true);
if (!$already_active) {
// Activate Slave from the "system" tab
DBConnection::createDBSlaveConfig();
} else {
if (isset($input["_dbreplicate_dbhost"])) {
// Change parameter from the "replicate" tab
DBConnection::saveDBSlaveConf($input["_dbreplicate_dbhost"], $input["_dbreplicate_dbuser"], $input["_dbreplicate_dbpassword"], $input["_dbreplicate_dbdefault"]);
}
}
}
if (!$input['_dbslave_status'] && $already_active) {
DBConnection::deleteDBSlaveConfig();
DBConnection::changeCronTaskStatus(false);
}
}
// Matrix for Impact / Urgence / Priority
if (isset($input['_matrix'])) {
$tab = array();
for ($urgency = 1; $urgency <= 5; $urgency++) {
for ($impact = 1; $impact <= 5; $impact++) {
$priority = $input["_matrix_{$urgency}_{$impact}"];
$tab[$urgency][$impact] = $priority;
}
}
$input['priority_matrix'] = exportArrayToDB($tab);
$input['urgency_mask'] = 0;
$input['impact_mask'] = 0;
for ($i = 1; $i <= 5; $i++) {
if ($input["_urgency_{$i}"]) {
$input['urgency_mask'] += 1 << $i;
}
if ($input["_impact_{$i}"]) {
$input['impact_mask'] += 1 << $i;
}
}
}
return $input;
}