0 ) { if (checkdate ( $startmon, $startday, $startyear )) { $ivmvac_startdate = mktime(0,0,0, $startmon, $startday, $startyear); } else { $msg[] = _("Start date error! Use year = 0 for disable startdate."); return $msg; } } if ( $endyear > 0 ) { if (checkdate ( $endmon, $endday, $endyear )) { $ivmvac_enddate = mktime(23,59,0, $endmon, $endday, $endyear); } else { $msg[] = _("End date error! Use year = 0 for disable enddate."); return $msg; } } // build the update query $update_string = 'UPDATE ' . $mysql_database . '.maildropfilter SET ' . 'datefrom = "' . $ivmvac_startdate . '", ' . 'dateend = "' . $ivmvac_enddate . '", ' . 'tofolder = "' . $ivmvac_tofolder . '", ' . 'body = "' . $vmvac_body . '", ' . 'active = "' . $vmvac_active . '" ' . 'WHERE id = "' . $vmvac_rec_id . '"'; // check for previous forward entry... $select_result = get_mysql_maildrop_vacation_for_user(); // make sure the query was OK if (!$select_result) { $msg[] = _("Error - Could not retrieve settings!"); return $msg; } // if there were no rows for this user, we need to insert instead of update... if (mysql_num_rows($select_result) == 0) { $update_string = 'INSERT INTO ' . $mysql_database . '.maildropfilter (' . 'ownerid, datefrom, dateend, filtertype, flags, fieldname, fieldvalue, tofolder, body, active ' . ') VALUES ("' . get_mysql_user_nid() . '", ' . '"' . $ivmvac_startdate . '", ' . '"' . $ivmvac_enddate . '", ' . '"anymessage","0","","", ' . '"' . $ivmvac_tofolder . '", ' . '"' . $vmvac_body . '", ' . '"' . $vmvac_active . '")'; } $msg = mysql_update_data( $update_string ); if(count($msg) > 0) { return $msg; } session_write_close(); header('Location: '.SM_PATH. 'src/options.php?optmode=submit&optpage=vmail_vacation'); exit; } function get_mysql_maildrop_vacation_for_user() { global $username; global $mysql_server, $mysql_database, $mysql_manager_id, $mysql_manager_pwd, $mysql_userid_field; // get mysql connection $databaseConnection = mysql_connect($mysql_server, $mysql_manager_id, $mysql_manager_pwd); // make sure connection is OK if ( ! $databaseConnection ) { // 'Database connection failed.' return; } // connect to desired database if ( !mysql_select_db( $mysql_database, $databaseConnection) ) { //'Database not found.' return; } // build query statement to see if user already has an entry or not // use col 0 ... 5 only for vacation $query_string = 'SELECT b.id, b.datefrom, b.dateend, b.tofolder, b.body, b.active, b.filtertype, b.fieldname, b.fieldvalue, b.flags' . ' FROM view_users AS a JOIN maildropfilter AS b ON a.id = b.ownerid ' . ' WHERE ' . $mysql_userid_field . '="' . $username . '"' . ' AND b.tofolder LIKE \'+%\' '; // execute query $select_result = mysql_query($query_string, $databaseConnection); return $select_result; } function get_mysql_maildrop_filter_for_user() { global $username; global $mysql_server, $mysql_database, $mysql_manager_id, $mysql_manager_pwd, $mysql_userid_field; // get mysql connection $databaseConnection = mysql_connect($mysql_server, $mysql_manager_id, $mysql_manager_pwd); // make sure connection is OK if ( ! $databaseConnection ) { // 'Database connection failed.' return; } // connect to desired database if ( !mysql_select_db($mysql_database, $databaseConnection) ) { //'Database not found.' return; } // build query statement to see if user already has an entry or not $query_string = 'SELECT b.id, b.active, b.datefrom, b.dateend, b.position, b.filtertype, b.fieldname, b.fieldvalue, b.tofolder, b.flags, b.body' . ' FROM view_users AS a JOIN maildropfilter AS b ON a.id = b.ownerid ' . ' WHERE ' . $mysql_userid_field . '="' . $username . '" ORDER BY `ownerid`, `position`'; // execute query $select_result = mysql_query($query_string, $databaseConnection); return $select_result; } function get_mysql_fetchmail_for_user() { global $username; global $mysql_server, $mysql_database, $mysql_manager_id, $mysql_manager_pwd, $mysql_userid_field; // get mysql connection $databaseConnection = mysql_connect($mysql_server, $mysql_manager_id, $mysql_manager_pwd); // make sure connection is OK if ( ! $databaseConnection ) { // 'Database connection failed.' return; } // connect to desired database if ( !mysql_select_db($mysql_database, $databaseConnection) ) { //'Database not found.' return; } // build query statement to see if user already has an entry or not $query_string = 'SELECT b.id, b.active, b.servername, b.prot, b.loginname, b.password, b.recipient, b.options, b.sslproto, b.sslfingerprint' . ' FROM view_users AS a JOIN fetchmail AS b ON a.id = b.ownerid ' . ' WHERE ' . $mysql_userid_field . '="' . $username . '" ORDER BY `ownerid`'; // execute query $select_result = mysql_query($query_string, $databaseConnection); return $select_result; } function get_mysql_user_nid() { global $username; global $mysql_server, $mysql_database, $mysql_manager_id, $mysql_manager_pwd, $mysql_usernd_field; // get mysql connection $databaseConnection = mysql_connect($mysql_server, $mysql_manager_id, $mysql_manager_pwd); // make sure connection is OK if ( ! $databaseConnection ) { //'Database connection failed.' return; } // connect to desired database if ( !mysql_select_db($mysql_database ,$databaseConnection) ) { //'Error - Database not found.' return; } // build query statement to see if user already has an entry or not $query_string = 'SELECT id FROM view_users WHERE ' . $mysql_usernd_field . '="' . $username . '"'; // execute query $select_result = mysql_query($query_string, $databaseConnection); // make sure the query was OK if (!$select_result) { // 'Could not get user id!' return; } // if there was more than one row returned, there // are issues best resolved by sysadmin... if (mysql_num_rows($select_result) > 1) { // 'More than one forwarding entry found for ' . $username . '.' return; } $row = mysql_fetch_row($select_result); return $row[0]; } /** * Change password * check the new password */ function cpw_check_input() { global $cpw_pass_min_length, $cpw_pass_max_length; // formdata sqgetGlobalVar('cpw_newpass', $newpw, SQ_POST); sqgetGlobalVar('cpw_verify', $verifypw, SQ_POST); $msg = array(); if(!$newpw) { $msg[] = _("You must type in a new password."); } if(!$verifypw) { $msg[] = _("You must also type in your new password in the verify box."); } elseif ($verifypw != $newpw) { $msg[] = _("Your new password does not match the verify password."); } if($newpw && (strlen($newpw) < $cpw_pass_min_length || strlen($newpw) > $cpw_pass_max_length ) ) { $msg[] = sprintf(_("Your new password should be %s to %s characters long."), $cpw_pass_min_length, $cpw_pass_max_length); } return $msg; } /** * Change password * write the new password to database */ function cpw_do_change() { global $mysql_usernd_field, $cpw_clearpass_entry; sqgetGlobalVar('cpw_newpass', $newpw, SQ_POST); sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION); sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); sqgetGlobalVar('key', $key, SQ_COOKIE); sqgetGlobalVar('username', $username, SQ_SESSION); if ( $cpw_clearpass_entry ) { $update_string = 'UPDATE virtual_users SET ' . 'password = MD5(\'' . $newpw . '\'), ' . 'datacomment = "' . $newpw . '" ' . 'WHERE ' . $mysql_usernd_field . '="' . $username . '"'; } else { $update_string = 'UPDATE virtual_users SET ' . 'password = MD5(\'' . $newpw . '\') ' . 'WHERE ' . $mysql_usernd_field . '="' . $username . '"'; } $msgs = mysql_update_data( $update_string ); if(count($msgs) > 0) { return $msgs; } /* update our password stored in the session */ $onetimepad = OneTimePadCreate(strlen($newpw)); sqsession_register($onetimepad,'onetimepad'); $key = OneTimePadEncrypt($newpw, $onetimepad); setcookie('key', $key, 0, $base_uri); /* make sure we write the session data before we redirect */ session_write_close(); header('Location: '.SM_PATH. 'src/options.php?optmode=submit&optpage=vmail_changepass'); exit; } /****************************************************************************** * Write mysql data to table *******************************************************************************/ function mysql_update_data( $update_string ) { global $mysql_server, $mysql_database, $mysql_manager_id, $mysql_manager_pwd, $mysql_usernd_field; $msgs = array(); // get mysql connection $databaseConnection = mysql_connect($mysql_server, $mysql_manager_id, $mysql_manager_pwd); // make sure connection is OK if ( ! $databaseConnection ) { array_push($msgs, _("Cannot connect to Database Server, please try later!")); return $msgs; } // connect to desired database if ( !mysql_select_db($mysql_database, $databaseConnection) ) { array_push($msgs, _("Database not found on server")); return $msgs; } // execute the update (or insert) if (!mysql_query($update_string, $databaseConnection)) { array_push($msgs, _("MySQL data update operation was not successful!")); } return $msgs; } ?>