Forum Moderators: coopster

Message Too Old, No Replies

when I issue system command for htpasswd it just returns the help

         

jackvull

8:55 pm on Aug 14, 2009 (gmt 0)

10+ Year Member



when I issue system command for htpasswd it just returns the help code on the command line even though it runs through the sql correctly.
?

Also, do I need safe_mode off for this even though I am running it from the command line? The script won't ever be used on a webpage.


[root@localhost myscripts]# ./test.php
Usage:
htpasswd [-cmdpsD] passwordfile username
htpasswd -b[cmdpsD] passwordfile username password

htpasswd -n[mdps] username
htpasswd -nb[mdps] username password
-c Create a new file.
-n Don't update file; display results on stdout.
-m Force MD5 encryption of the password.
-d Force CRYPT encryption of the password (default).
-p Do not encrypt the password (plaintext).
-s Force SHA encryption of the password.
-b Use the password from the command line rather than prompting for it.
-D Delete the specified user.
On Windows, NetWare and TPF systems the '-m' flag is used by default.
On all other systems, the '-p' flag will probably not work.


#! /usr/bin/php
<?php
# CONFIG VARIABLES
$host = "remote-server";
$database = "db";
$tablename = "tbl";
$user = "usern";
$pw = "pwd";

# PHP MYSQL CONNECT
$link = mysql_connect($host, $user, $pw);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('squid', $link);
if (!$db_selected) {
die ('Can\'t select squid : ' . mysql_error());
}

# DEFINE A MySQL QUERY
$query = "SELECT user, password, enabled, customers_id FROM passwd WHERE UpdateOnNextCycle=1";

# EXECUTE THE QUERY FUNCTION
$result = mysql_query($query);

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {

#if enabled =1 then add the user
if ($row == 1 )
{
#htpasswd command add
system("htpasswd -b /etc/squid/squid_passwd ".$row[0]." ".$row[1]);

}

#if enabled =0 then delete the user
if ($row[2] == 0 )
{
#htpasswd command del
system("htpasswd -D ".$row[0]);
}

#after which we update the UpdateOnNextCycle flag to 0 and set UsedDemo to 1
$result_update = mysql_query("
UPDATE passwd
SET UpdateOnNextCycle = 0,
UsedDemo = 1
WHERE customers_id = ".$row[3]."
");
}
?>

eelixduppy

4:22 am on Aug 20, 2009 (gmt 0)



Given your other thread you started, I'm assuming you have resolved this issue?