$act_key = trim($act_key); if (!preg_match('/^[a-z|A-Z|0-9]{32}$/', "{$act_key}")) { header("Location: no_such_key.html"); die; } #------------------------------------------------------------------------------------------------------------------------- #Open MySQL-DB $link = open_db(); #Has someone this activation key? $result = mysql_query("SELECT * FROM Yane WHERE activation_key = '{$act_key}'") or die(mysql_error()); #If no, show error if (mysql_num_rows($result) == 0) { mysql_close($link); header("Location: no_such_key.html"); die; } else { #Get mailaddress $result = mysql_query("SELECT email_address FROM Yane WHERE activation_key = '{$act_key}';") or die(mysql_error()); $row = mysql_fetch_assoc($result); #If yes, set activation-key to NULL mysql_query("UPDATE Yane SET activation_key = NULL WHERE CONVERT( activation_key USING utf8 ) = '{$act_key}'") or die(mysql_error()); mysql_close($link); # Log the correct login log_correct_login($row['email_address'], $_SERVER['REMOTE_ADDR']); # Set account modification-time log_change($row['email_address']); #------------------------------------------------------------------------------------------------------------------------- #Send mail #send_mail($row['email_address'], "activated", "http://newsletters.yacy-forum.de/activate"); header("Location: success.html"); }
header("Location: pws_dont_match.html"); die; } #------------------------------------------------------------------------------------------------------------------------- #If user doesn't exist: #Add new user #------------------------------------------------------------------------------------------------------------------------- add_user($mailaddress); #------------------------------------------------------------------------------------------------------------------------- #Set password #------------------------------------------------------------------------------------------------------------------------- update_PW($mailaddress, $plain_pw1); #------------------------------------------------------------------------------------------------------------------------- #Log time of last modification on dataset #------------------------------------------------------------------------------------------------------------------------- log_change($mailaddress); #------------------------------------------------------------------------------------------------------------------------- #Initialize the login values #------------------------------------------------------------------------------------------------------------------------- #Get the user's IP $ip = $_SERVER['REMOTE_ADDR']; log_correct_login($mailaddress, $ip); #------------------------------------------------------------------------------------------------------------------------- #Generate and save activation key #------------------------------------------------------------------------------------------------------------------------- $token = generate_activation_key($mailaddress); #------------------------------------------------------------------------------------------------------------------------- #If we didn't die() up to now, everything was successful #Send confirmation mail to user #send_mail($mailadresse, "register", "http://newsletters.yacy-forum.de/activate", $mailaddress, $ip, $token); #-------------------------------------------------------------------------------------------------------------------------
function delete_entry($entry_id) { $entry = get_entry($entry_id); $query = "DELETE FROM entries WHERE entry_id = {$entry_id}"; if ($result = mysql_query($query)) { echo $query; log_change(CURRENT_USER, 'removed', $entry['person_id'], 'from', $entry['project_id'], $entry['startdate']); } else { die("<p>could not delete item because:<br>" . mysql_error() . "<br>the query was {$query}.</p>"); } }
function schedule_request($requestId, $comments, $startTime, $endTime, $retries, $retryInterval, $changeControl, $priority, $hosts, $groups) { // We need to determine if the user add or deleted hosts // Update change_targets table $hosts = preg_replace("/<[^>]*>/", "", $hosts); $hostArray = explode ("\n", $hosts); // Let's create a temporary table to store the agentid, groupid $cmd = "DROP TABLE IF EXISTS agentlist"; run_sql_cmd($cmd); $cmd = "CREATE TEMPORARY TABLE agentList (agentid int(4) primary key, groupid int(4))"; run_sql_cmd($cmd); $whereHosts = ""; if (count($hostArray)) { foreach ($hostArray as $value) { $value = trim ($value); if ($value == "") { continue; } $valueArray = explode(" ", $value); if ($whereHosts != "") { $whereHosts = $whereHosts . " OR "; $whereHosts = $whereHosts . " (hostname = '$valueArray[0]' AND port = '$valueArray[1]') "; } else { $whereHosts = "((hostname = '$valueArray[0]' AND port = '$valueArray[1]') "; } } $whereHosts = $whereHosts . ")"; // We need to get all the if ($whereHosts != ")") { $cmd = " INSERT IGNORE INTO agentList (agentid, groupid) SELECT id agentid, null groupid FROM agents WHERE $whereHosts"; run_sql_cmd($cmd); } } $groups = trim ($groups, ","); $groupArray = explode (" ", $groups); foreach ($groupArray as $group) { $group = trim ($group); if ($group == "") { continue; } // We need to get the id of the group $query = "SELECT id FROM server_groups WHERE server_group = '$group'"; $groupId = run_query($query); $groupId = $groupId[0]; $cmd = " INSERT IGNORE INTO agentList (agentid, groupid) SELECT agents.id agentid, $groupId groupid FROM agents, agent_groups, server_groups WHERE agents.id = agent_groups.agentid AND agent_groups.groupid = server_groups.id AND server_groups.server_group LIKE '$group%' GROUP BY agents.id"; run_sql_cmd($cmd); } // The agent List table have all hosts that the user selected. // we need to compare the list with the one that hte user submitted $query = "SELECT agentid FROM change_targets WHERE requestid = '$requestId'"; $userAgent = run_query ($query); $query = "SELECT agentid FROM agentList"; $adminAgent = run_query($query); $adminAdd = array_diff ($adminAgent, $userAgent); $adminRemove = array_diff ($userAgent,$adminAgent); // We need to update 3 tables scheduled_changes - change_requests - change_target $comments = str_replace("'", " ", $comments); $changeControl = str_replace("'", " ", $changeControl); $startTime = format_date($startTime); $endTime = format_date($endTime); $schedulerId = $_SESSION['user']; // We first need to add the hosts that the admin added to the change_targets table if (count($adminAdd)) { $whereField = get_where_for_fields($adminAdd, "id"); $cmd = " INSERT INTO change_targets ( requestid, status, agentid) SELECT $requestId requestid, 0 status, a.id agentid FROM agents a WHERE $whereField"; run_sql_cmd($cmd); } // We need to add a new request to hold all the hosts that the admin removed if (count($adminRemove)) { $cmd = " INSERT INTO change_requests ( PID, UserId, Priority, Status, ApproverId, Comment, Date_Entered, Date_Modified, Change_Control) SELECT $requestId PID, UserId, Priority, Status, ApproverId, Comment, Date_Entered, now() Date_Modified, Change_Control FROM change_requests WHERE id = $requestId"; run_sql_cmd($cmd); // We need to get the new request id $query = "SELECT last_insert_id()"; $result = run_query ($query); $newRequestId = $result[0]; $cmd = " INSERT INTO request_rules ( requestId, ruleId) SELECT $newRequestId requestId, ruleId FROM request_rules WHERE requestId = $requestId"; run_sql_cmd($cmd); // Now we need to update the change target table to make the one removed point to the new request $whereField = get_where_for_fields($adminRemove, "id"); $cmd = "UPDATE change_targets SET requestid = $newRequestId WHERE requestid = '$requestId' AND agentid in ( SELECT id FROM agents WHERE $whereField )"; run_sql_cmd($cmd); } // Now let's update the scheduled_changes table $cmd = " INSERT INTO scheduled_changes ( RequestId, SchedulerId, Retries, date_entered, date_modified, start_time, end_time, comment) VALUES ( '$requestId', '$schedulerId', '$retries', now(), now(), '$startTime', '$endTime', '$comments')"; run_sql_cmd($cmd); $cmd = " UPDATE change_requests SET status = '4', date_modified = now() , change_control = '$changeControl', priority = '$priority' WHERE Id = '$requestId'"; run_sql_cmd($cmd); if ($changeControl){ log_change ("Ticket $changeControl: Request ID $requestId has been scheduled to start at $startTime and end at $endTime."); } else { log_change ("Request ID $requestId has been scheduled to start at $startTime and end at $endTime"); } }