. */ if( isset($setup) ) { ################################################################# ### Create and mail passwords for Contacts (and other bodies) ### ################################################################# if( $setup['PromoteAnonymousApplication'] ) { $out.="\n\n=== Creating and mailing passwords for all bodies ===\n"; $query = "SELECT `BodyCode`, `BodyName`, `Email`, `BodyCategory` FROM `ab_bodies` WHERE `BodyCategoryOrder`>=0 AND `Password`=''"; }else { $out.="\n\n=== Creating and mailing passwords for Contacts ===\n"; $query = "SELECT `BodyCode`, `BodyName`, `Email`, `BodyCategory` FROM `ab_bodies` WHERE `BodyCategoryOrder`>=0 AND `BodyCategory`='Contacts' AND `Password`=''"; } if( @mysql_num_rows( $res=doquery($query) )>0 ) { // Get data about all Contacts that don't have a password yet $Contacts = array(); while( $row=mysql_fetch_array($res) ) { $Contacts[ $row['BodyCode'] ]['BodyName'] = $row['BodyName']; $Contacts[ $row['BodyCode'] ]['Email'] = $row['Email']; $Contacts[ $row['BodyCode'] ]['BodyCategory'] = $row['BodyCategory']; } // Search applications for the Contacts that don't have a password $k = array_keys($Contacts); $query2 = "SELECT `BodyCode` FROM `persons` WHERE `BodyCode`='".addslashes($k[0])."'"; for( $i=1; $i0 ) { while( $row2=mysql_fetch_array($res2) ) { $newPassword = substr(md5($setup['EventCode'].mt_rand().$row2['BodyCode']), 0, 10); $query3 = "UPDATE `ab_bodies` SET `Password`='".addslashes(md5($newPassword))."' WHERE `BodyCode`='".addslashes($row2['BodyCode'])."'"; if( doquery($query3) ) { // New password set if( $setup['PromoteAnonymousApplication'] ) { $message = "Dear board of ".$Contacts[ $row2['BodyCode'] ]['BodyName'].",\n\n"; }else { $message = "Dear Contact ".$Contacts[ $row2['BodyCode'] ]['BodyName'].",\n\n"; } $message.= "Within the last 24 hours, the first application from your body for ".$setup['SetupEventType']." was made. You'll have to approve all applications made before the "; $message.= "deadline, which is ".$setup['EventDatePartTypeFix']." 23h59 ".date("T").". When you approve, you'll have to assign the applicants a status. "; if( $setup['PromoteAnonymousApplication'] ) { $message.= "Depending on the status of your body, you might be able to select Delegates, Envoys, Observers and Visitors. The applicants you select as Delegate, Envoy and Observer "; $message.= "should be the official representatives of your body. The others should be assigned Visitor status.\n\n"; }else { $message.= "The applicants you select as Observer should be the official representatives of your Contact (board members). The others (official representatives that do not fit in the "; $message.= "Observer places) and your members should be assigned Visitor status.\n\n"; } $message.= "To approve the applications, go to the following url:\n\n"; if( $Contacts[ $row2['BodyCode'] ]['BodyCategory']=="Contacts" ) $message.= "\thttps://".$FULL_URL."contacts.php?bodycode=".strtolower($row2['BodyCode'])."\n\n"; else $message.= "\thttps://".$FULL_URL."board.php?bodycode=".strtolower($row2['BodyCode'])."\n\n"; $message.= "Select your body from the list, and use the following password to log in: ".$newPassword."\n\n"; $message.= "This password will be valid for all applications from your body for the upcoming ".$setup['SetupEventType'].". Please make sure you keep this password until the "; $message.= "event is over (".$setup['EventDateEnd']."). The password will only be send once and cannot be recovered.\n\n"; $message.= "Please make sure that the people you approve will really come. If they don't show up without informing the organizers, your body will get fewer places assigned for "; $message.= "the next event.\n\n"; $message.= "With kind regards,\n\nThe webmaster"; $mail = new Mail($setup['MailReturnpath'], $Contacts[ $row2['BodyCode'] ]['Email']); $mail->setSubject("Password for approving applications"); $mail->addHeader("To", "\"".Mail::encodeHeader($Contacts[ $row2['BodyCode'] ]['BodyName'])."\" <".$Contacts[ $row2['BodyCode'] ]['Email'].">"); $mail->addHeader("From", "\"".$setup['SetupEventType']." Application Mailer\" <".$setup['EventApplFromEmail'].">"); $mail->addHeader("Auto-Submitted", "auto-generated"); $mail->addHeader("X-Content", "password to board"); $mail->addHeader("X-BodyCode", $row2['BodyCode']); $mail->addHeader("X-Signature", get_signature("password to board", $row2['BodyCode'])); $mail->setMessage($message); switch( $mail->send(true) ) { case Mail::MAIL_OK: $out.="Created new password for body ".$Contacts[ $row2['BodyCode'] ]['BodyName']." and sent it by mail.\n"; break; case Mail::MAIL_QUEUE: $out.="Created new password for body ".$Contacts[ $row2['BodyCode'] ]['BodyName']." and queued it for later mailing.\n"; break; default: $query4 = "UPDATE `ab_bodies` SET `Password`='' WHERE `BodyCode`='".addslashes($row2['BodyCode'])."'"; if( doquery($query4) ) { $out.="Failed mailing new password for body ".$Contacts[ $row2['BodyCode'] ]['BodyName'].". Password has been removed from database. Will retry tomorrow.\n"; }else { $out.="Failed mailing new password for body ".$Contacts[ $row2['BodyCode'] ]['BodyName']." and failed removing it from database. Something is terribly wrong!\n"; } } unset($Contacts[ $row2['BodyCode'] ]); }else { $out.="Failed saving new password for ".$Contacts[ $row2['BodyCode'] ]['BodyName']."\n"; } } }else { $out.="No applications found for bodies without password.\n"; } if( $setup['UploadMembersList'] && is_after("SendPasswordForMemListDate") ) { $bodyCodes = array_keys($Contacts); foreach( $bodyCodes as $bodyCode ) { if( $Contacts[$bodyCode]['BodyCategory']=="Locals" || $Contacts[$bodyCode]['BodyCategory']=="Contacts" ) { $newPassword = substr(md5($setup['EventCode'].mt_rand().$bodyCode), 0, 10); $query3 = "UPDATE `ab_bodies` SET `Password`='".addslashes(md5($newPassword))."' WHERE `BodyCode`='".addslashes($bodyCode)."'"; if( doquery($query3) ) { // New password set $message = "Dear board of ".$Contacts[ $bodyCode ]['BodyName'].",\n\n"; $message.= "According to the CIA, you have to hand in the list of members for your local. This will be done by uploading your list of members in CSV format (more explanations at the linked site) at the application system for the upcoming ".$setup['SetupEventType'].", at the same pages where you can approve applications of your members.\n\n"; $message.= "To upload the list of members, go to the following url:\n\n"; $message.= "\thttps://".$FULL_URL."board.php?bodycode=".strtolower($bodyCode)."\n\n"; $message.= "Select your body from the list, and use the following password to log in: ".$newPassword."\n\n"; $message.= "This password will be valid to upload the list of members, as well as to approve all applications from your local for the upcoming ".$setup['SetupEventType'].". Please make sure you keep this password until the event is over (".$setup['EventDateEnd']."). The password will only be send once and cannot be recovered.\n\n"; $message.= "When you approve people as participant, please make sure that the people you approve will really come. If they don't show up without informing the organizers, your local will get fewer places assigned for the next event.\n\n"; $message.= "With kind regards,\n\nThe webmaster"; $mail = new Mail($setup['MailReturnpath'], $Contacts[ $bodyCode ]['Email']); $mail->setSubject("Password for uploading members list and approving applications"); $mail->addHeader("To", "\"".Mail::encodeHeader($Contacts[ $bodyCode ]['BodyName'])."\" <".$Contacts[ $bodyCode ]['Email'].">"); $mail->addHeader("From", "\"".$setup['SetupEventType']." Application Mailer\" <".$setup['EventApplFromEmail'].">"); $mail->addHeader("Auto-Submitted", "auto-generated"); $mail->addHeader("X-Content", "password to board"); $mail->addHeader("X-BodyCode", $bodyCode); $mail->addHeader("X-Signature", get_signature("password to board", $bodyCode)); $mail->setMessage($message); switch( $mail->send(true) ) { case Mail::MAIL_OK: $out.="Created new password for body ".$Contacts[ $bodyCode ]['BodyName']." and sent it by mail.\n"; break; case Mail::MAIL_QUEUE: $out.="Created new password for body ".$Contacts[ $bodyCode ]['BodyName']." and queued it for later mailing.\n"; break; default: $query4 = "UPDATE `ab_bodies` SET `Password`='' WHERE `BodyCode`='".addslashes($bodyCode)."'"; if( doquery($query4) ) { $out.="Failed mailing new password for body ".$Contacts[ $bodyCode ]['BodyName'].". Password has been removed from database. Will retry tomorrow.\n"; }else { $out.="Failed mailing new password for body ".$Contacts[ $bodyCode ]['BodyName']." and failed removing it from database. Something is terribly wrong!\n"; } } }else { $out.="Failed saving new password for ".$Contacts[ $bodyCode ]['BodyName']."\n"; } } } } }else { $out.="No bodies found without a password.\n"; } } ?>