. */ define("MAX_UPLOAD_SIZE", 512000); // In bytes $columns = array(); $columns[''] = "-- please select --"; $columns['GivenName'] = "Given name"; $columns['Surname'] = "Surname (family name)"; #$columns['CSN'] = "CSN"; #$columns['DateBirth'] = "Date of birth"; #$columns['MemberSince'] = "Member since"; $columns['Fee'] = "Membership fee in €"; $columns['Other'] = "Other"; if( !isset($_SESSION['sess_uid']) && !isset($_SESSION['body_BodyCode']) ) { include("../include/header.php"); echo " You cannot call this file directly."; include("../include/footer.php"); exit; } if( !isset($setup['SetupEventType']) ) { exit(); } if( !is_before("EventDatePartTypeFix") && $_SESSION['sess_uid']==0 ) { // Deadline passed, no access echoln("It is after the deadline, you cannot upload the list of members for your body any more."); echoln("
As the selection of participants already started, which is based upon the number of members your local has, you cannot change this number any more. Also, keep in mind "); echoln("that this is the number of members you'll have to pay for at the Agora, and which is used to assign the amount of votes."); echoln("

Back

"); }else { echoln("

Upload the list of members for ".$Body[ $_SESSION['body_BodyCode'] ]."

"); echoln("The selection of visitors is based on the number of members a local has. The more members, the more visitor places you get. To have the accurate number of members of your local "); echoln("and to fulfil the antenna criteria, you have to upload the list of members of your local. Your name will be saved with the number of members."); echoln("
Warning: the number of members is calculated automatically. Please check if this is correct! The number of members that is calculated is the amount you'll have to pay for at "); echoln("the Agora to AEGEE-Europe and the number of stickers to validate the membership cards you'll receive. The Juridical Commission will base the number of votes you receive upon this "); echoln("number. It is not possible to change the members list after the deadline!"); echoln("
You can change it until ".$setup['EventDatePartTypeFix'].".

"); $step = 1; if( isset($_FILES['file']) ) { switch($_FILES['file']['error']) { case UPLOAD_ERR_OK: // There is no error, the file uploaded with success. if( is_uploaded_file($_FILES['file']['tmp_name']) ) { if( $_FILES['file']['size']>MAX_UPLOAD_SIZE ) { echoln("The file you uploaded exceeded the limit of ".get_bytesize(MAX_UPLOAD_SIZE).".
"); }elseif( $_FILES['file']['type']!="text/csv" && strtolower(substr($_FILES['file']['name'], -4))!=".csv" ) { echoln("You can only upload files of the type text/csv.
"); }else { if( isset($_SESSION['sess_uid']) && $_SESSION['sess_uid']>0 ) { $dest = "../uploads/memlist-".$_SESSION['body_BodyCode']."-".date("YmdHis").".csv"; }else { $dest = "./uploads/memlist-".$_SESSION['body_BodyCode']."-".date("YmdHis").".csv"; } if( @move_uploaded_file($_FILES['file']['tmp_name'], $dest) ) { $destUtf8 = substr($dest, 0, -4) . "-utf8.csv"; if( ($fpI = fopen($dest, "r"))!==FALSE && ($fpO = fopen($destUtf8, "w"))!==FALSE ) { $data = fread($fpI, filesize($dest)); if( fwrite($fpO, mb_convert_encoding($data, "UTF-8", "UTF-8, ISO-8859-1, ASCII"))!==FALSE ) { fclose($fpI); fclose($fpO); $_SESSION['body_MemList'] = $destUtf8; $_POST['containsHeader'] = true; if( ($fp = fopen($_SESSION['body_MemList'], "r")) !== FALSE ) { $r = 0; $data = ""; while( ($line = fgets($fp, 4096)) !== FALSE ) { $data .= $line; $r++; if( $r>=10 ) break; } fclose($fp); $_SESSION['body_MemListDelimiter'] = (substr_count($data, ";")>substr_count($data, ",")?";":","); $_SESSION['body_MemListEnclosure'] = (substr_count($data, "'")>substr_count($data, "\"")?"'":"\""); } $step = 2; }else { fclose($fpI); fclose($fpO); echoln("Failed writing to file for conversion, please try again.
"); } }else { echoln("Failed opening file for conversion, please try again.
"); } }else { echoln("Failed moving uploaded file, please try again.
"); } } }else { echoln("Uploaded file not found on the system, please try again.
"); } break; case UPLOAD_ERR_INI_SIZE: // The uploaded file exceeds the upload_max_filesize directive in php.ini. case UPLOAD_ERR_FORM_SIZE: // The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form. echoln("The file you uploaded exceeded the limit of ".get_bytesize(MAX_UPLOAD_SIZE).".
"); break; case UPLOAD_ERR_PARTIAL: // The uploaded file was only partially uploaded. echoln("The file was only partially uploaded. Please try again.
"); case UPLOAD_ERR_NO_FILE: // No file was uploaded. echoln("You did not upload a file.
"); break; case UPLOAD_ERR_NO_TMP_DIR: // Missing a temporary folder. case UPLOAD_ERR_CANT_WRITE: // Failed to write file to disk. default: echoln("An unknown error occurred. Please try again. If this fails, contact the webmaster and report error code ".$_FILES['file']['error']. " while uploading a file.
"); break; } }elseif( isset($_SESSION['body_MemList']) && $_SERVER['REQUEST_METHOD']=="POST" ) { $step = 2; $error = false; $usedCols = array(); for( $c=0; $c<$_SESSION['body_MemListCols']; $c++ ) { if( $_POST['header'][$c]=="" || !array_key_exists($_POST['header'][$c], $columns) || array_key_exists($_POST['header'][$c], $usedCols) ) { $error = true; } if( $_POST['header'][$c]!="" && $_POST['header'][$c]!="Other" ) { $usedCols[ $_POST['header'][$c] ] = $c; } } if( $error ) { echoln("You didn't select a value for a column, or you selected an invalid value. For all columns you'll have to tell what data is stored. In case it is "); echoln("something not mentioned, choose the last option (Other). Please note: you can select every option only once (except for 'Other')!
"); }elseif( !array_key_exists("Surname", $usedCols) || !array_key_exists("GivenName", $usedCols) ) { echoln("Your members list should at least contain a given name and surname. Either select a column as surname, or upload a correct file."); }else { if( ($fp = fopen($_SESSION['body_MemList'], "r")) !== FALSE ) { $line = 0; if( isset($_POST['containsHeader']) ) { $data = fgets($fp, 4096); $line++; } $query = "INSERT INTO `memberlist` (`BodyCode`"; $usedColsKeys = array_keys($usedCols); for( $i=0; $iFailed processing line ".$line.". \"".$data[ $usedCols[ $usedColsKeys[$i] ] ]."\" is not a valid number, falling back to 0.
"); } $query .= ", ".mysql_real_escape_string($value); }else { // This is text $query .= ", '".mysql_real_escape_string($data[ $usedCols[ $usedColsKeys[$i] ] ])."'"; } } $query .= "), "; }else { echoln("Failed processing line ".$line.". At least one column is empty for this row.
"); } }else { echoln("Failed processing line ".$line.". Is it possible this line contains no data?
"); } } fclose($fp); $query = substr($query, 0, -2).";"; doquery("DELETE FROM `memberlist` WHERE `BodyCode`='".$_SESSION['body_BodyCode']."'"); if( doquery($query) && doquery("UPDATE `ab_bodies` SET `MemberClaimed`=".$memberCount.", `MemberClaimedBy`='".mysql_real_escape_string(isset($_SESSION['sess_name'])?$_SESSION['sess_name']:"Memberlist upload")."' WHERE `BodyCode`='".$_SESSION['body_BodyCode']."'") ) { $step = 3; }else { echoln("Failed to process file. Please contact the webmaster for help."); } }else { echoln("Failed opening uploaded file for processing. Please try again. If that does not help, contact the webmaster.
"); } } } switch($step) { case 1: // Step 1: upload members list unset($_SESSION['body_MemList']); echoln("

Step 1: upload members list

"); echoln("

Instructions

"); echoln("

Specifications for the members' list

"); echoln(""); echoln("

Instructions on how to export a members' list

"); echoln("In case you have your data stored in a database, please extract a file according to the specifications above. "); echoln("In case you have them stored in an excel, open office or any other file type, you case easily export them by using the 'save as' function. "); echoln("

Before saving a file as .csv (comma separated values), please making sure that you have:

"); echoln("
    "); echoln("
  1. Removed all columns apart from two: given name and surname. Keep in mind that given name and surname have to be in a separate column, otherwise you will not be able to upload the file.;
  2. "); echoln("
  3. Removed all empty rows on top of the file, leaving the first cell of the first row named as given name, under which all given names are placed, and the second cell as surname, under which all surnames (family name) are placed. (NB: you can put first the surname and second the given name if it's more convenient for you;
  4. "); echoln("
  5. Removed all empty rows between rows with data (the first empty row should be after the data of the last member).
  6. "); echoln("
"); echoln("

You can now proceed to save the file as .csv (comma separated values). "); echoln("
Now, let's cross-check that everything is fine! Open the file with a text editor (in windows, right click, open with, notepad)

"); echoln("
    "); echoln("
  1. Is there anything vertically before the given names? If yes, you did something wrong! Remove it!
  2. "); echoln("
  3. Are given names and surnames separated by , or ; ? If no, you did something wrong! Use the replace function to change it to either of the two!
  4. "); echoln("
  5. What is there in the file after surnames? Nothing or ; is fine! If not, you did something wrong! Use the replace function to change it to either of the two!
  6. "); echoln("
"); echoln("You can now proceed to upload the file!"); echoln("

Upload members list

"); echoln("

"); echoln(" "); echoln(" "); echoln("

"); echoln("
"); break; case 2: // Step 2: assign columns of uploaded file to the default columns echoln("

Step 2: choose the columns your file contained

"); echoln("

Instructions

"); echoln("Above you can see a preview of your file (first 5 lines). "); echoln("If you followed the previous instructions, you should only have two columns."); echoln("

You need to assign to them the correct type (given name or surname). "); echoln("For any other column that appears there (if any) select 'other'."); echoln("
Then, if your first row is 'given name' & 'surname', then click continue. "); echoln("In case your first row includes data of members, meaning that there is no header row (titles of columns) you have to uncheck the checkbox. After unchecking, click on continue.

"); echoln("

In case there is an error, follow the instructions given from the website to correct the problem. "); echoln("You either selected something wrong in the previous step, or your file is not properly prepared!

"); echoln("

When you succeed, you will see the following message: \"Successfully uploaded members list.\"

"); echoln("

Choose the columns your file contained

"); if( ($fp = fopen($_SESSION['body_MemList'], "r")) !== FALSE ) { $r = 0; $cols = 0; $data = array(); while( ($data[$r] = fgetcsv($fp, 4096, $_SESSION['body_MemListDelimiter'], $_SESSION['body_MemListEnclosure'])) !== FALSE ) { $cols = max($cols, count($data[$r])); $r++; if( $r>=5 ) break; } fclose($fp); $_SESSION['body_MemListCols'] = $cols; echoln("

"); echoln(" Please select in the column headers which data is stored in the column below. The data of the first 5 rows of the uploaded file is shown."); echoln("

"); echoln(" "); for( $c=0; $c<$cols; $c++ ) { echoln(" "); } echoln(" "); for( $r=0; $r"); for( $c=0; $c<$cols; $c++ ) { echoln(" "); } echoln(" "); } echoln("
"); echoln(" "); echoln("
".$data[$r][$c]."
"); echoln("

.

"); echoln(" In case you have more than one row without a header, your file is not in the correct format. "); echoln(" Please make sure you have maximum one header row (that means, maximum one row shows non-member data). "); echoln(" You should see at least 4 members in the preview."); echoln("

"); echoln("
"); }else { echoln("Failed opening uploaded file for processing. Please try again. If that does not help, contact the webmaster.
"); } break; case 3: // Step 3: confirmation echoln("

Step 3: confirmation

"); echoln("Successfully uploaded members list."); echoln("

The members list was successfully uploaded and processed. According to this members list, you have ".$memberCount." members. In case this is not correct, correct "); echoln("your members list and upload it again. If this does not have the intended result, please contact the webmaster and clearly describe what is the problem.

"); echoln("

Please check that the number of members mentioned is the correct. "); echoln("The Financial Director will use this number to calculate your membership fees. "); echoln("The Juridical Commission will use this number in order to allocate votes to your local. "); echoln("The Network Director will use this number in your antenna criteria status.

"); if( !isset($_SESSION['sess_uid']) || $_SESSION['sess_uid']<1 ) { echoln("

If the number was not the correct one, you did something wrong with the creation of the file. "); echoln("Have a look at it and click on edit to upload the corrected version.

"); echoln("

When the number is the correct one, check the members list. "); echoln("Here, please check that names are appearing properly (use a couple of rows as sample and check that all non-latin characters appear properly).

"); echoln("

We would like to remind you that according to Article 6 of the Agora Working Format:"); echoln("
2The delegates must be members of the Antenna or Working Group since at least before the preceding Agora. "); echoln("3This does not apply to the Antennae or Working Groups that were created after the preceding Agora.

"); echoln("

This means that if a person's name is not present in the members' list that you are currently submitting, or if a person's name is not present in the members' list that you have submitted at the previous Agora, then, this person cannot be a delegate at the current Agora!

"); echoln("

Back to main screen

"); } break; } } ?>