function menu(CommonGLPI $serial, $withtemplate = '')
 {
     global $LANG, $DB, $PLUGIN_HOOKS, $CFG_GLPI;
     $config = new PluginWinadminpasswordConfig();
     $config->getFromDB(1);
     $key = $config->fields['key'];
     $length = $config->fields['length'];
     $size = $config->fields['size'];
     $color = $config->fields['color'];
     $algo = $config->fields['algo'];
     switch ($algo) {
         case 1:
             $hash = "{$key}.{$serial}";
             break;
         case 2:
             $hash = "{$serial}{$key}";
             break;
         case 3:
             $hash = "{$serial}{$key}{$serial}";
             break;
         case 4:
             $hash = "{$key}{$serial}{$key}";
             break;
         case 5:
             $hash = "{$key}{$serial}";
             break;
         default:
             $hash = "{$key}.{$serial}";
     }
     # Encoding in sha1 base 64
     $digest = base64_encode(sha1($hash, true));
     $password = substr($digest, 0, $length);
     # Delete "/" and "&" characters
     $password = str_replace("/", "-", $password);
     $password = str_replace("\\", "!", $password);
     $password = str_replace("&", "+", $password);
     if ($this->canView()) {
         if ($serial || $serial == '0') {
             echo "<div align='center'><table class='tab_cadre'><tr><th>" . $LANG['plugin_winadminpassword'][2] . "</th></tr>";
             echo "<tr><td class='tab_bg_2' align='center'><font color='{$color}' size='{$size}' face='Century'>{$password}</font></td></tr>";
             echo "</table>";
             echo "</div>";
         } else {
             echo "<div align='center'><table class='tab_cadre'><tr><th>" . $LANG['plugin_winadminpassword'][3] . "</th></tr>";
             echo "<tr><td class='tab_bg_2' align='center'>" . $LANG['plugin_winadminpassword'][4] . "</td></tr>";
             echo "</table>";
             echo "</div>";
         }
     }
 }
Example #2
0
You should have received a copy of the GNU General Public License
along with GLPI; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
--------------------------------------------------------------------------
// ----------------------------------------------------------------------
// Original Author of file: Nicolas BOURGES
// Purpose of file: plugin winadminpassword v1.1.1 - GLPI 0.84
// ----------------------------------------------------------------------
*/
include '../../../inc/includes.php';
include_once "../inc/config.class.php";
Session::checkRight("config", "w");
// Mainly usefull if not actived
Plugin::load('winadminpassword', true);
$config = new PluginWinadminpasswordConfig();
Html::Header($LANG['plugin_winadminpassword']['config'][1], '', "plugins", "winadminpassword");
if (isset($_POST["add"])) {
    if ($config->canCreate()) {
        $config->add($_POST);
    }
    Html::redirect($_SERVER['HTTP_REFERER']);
} else {
    if (isset($_POST["update"])) {
        if ($config->canCreate()) {
            $config->update($_POST);
        }
        Html::redirect($_SERVER['HTTP_REFERER']);
    } else {
        echo "<div align='center'>" . $LANG['plugin_winadminpassword']['config'][1] . "</div>";
        $config->showForm(1);