load("nx_addusers"); // Loading CSV if($mybb->input['action'] == "") { cpheader(); starttable(); tableheader("".$lang->main."", "", 2); tablesubheader($lang->file_setm,"",2); echo "\n"; echo "\n"; echo "
\n"; echo "{$lang->file_name}  \n"; echo "  \n"; echo "
\n"; echo "\n"; echo "\n"; endtable(); cpfooter(); } // Comfirm create/update if( $mybb->input['action'] == "getcsv") { cpheader(); $csvname=$mybb->input['file_name']; if( is_readable($csvname) ){ $csvfile = fopen("$csvname","r"); starttable(); tableheader("".$lang->main."", "", csvfield_num); tablesubheader($lang->file_set,"",csvfield_num); echo "\n"; foreach ( $csvfield_format as $fieldvalue ){ print "

{$fieldvalue}

\n"; } echo "\n"; while(! feof($csvfile)) { echo "\n"; $nx_user_data = fgetcsv($csvfile); if ($nx_user_data == NULL){ continue; }else{ foreach( $nx_user_data as $value ) { print "{$value}\n"; } } echo "\n"; } endtable(); echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; fclose($csvfile); }else{ starttable(); tableheader("".$lang->main."", "", csvfield_num); tablesubheader($lang->file_error,"",1); echo "Error : Unreadable file or file doesn't exist."; endtable(); } cpfooter(); } if( $mybb->input['action'] == "comfirm_add") { cpheader(); if (isset($mybb->input['comfirm'])){ require_once MYBB_ROOT."inc/datahandlers/user.php"; require_once( 'nx_pswgenerate.php' ); $generator = new generatepswd(); $csvname = $mybb->input['file_name']; function generate_pf_array($pf_data){ $user_pf_array = array(); for ($i=0; $i<=(csvfield_num-1); $i++) { $value = $csvfield_format[$i]; $rel_fid = $db->query("SELECT 'fid' FROM ".TABLE_PREFIX."profilefields' WHERE name={$value}"); $user_pf_array[$rel_fid]= $pf_data[$i]; } return $user_pf_array; } $csvfile = fopen("$csvname","r"); $nx_user_data = fgetcsv($csvfile); $user_pf_data = generate_pf_array($nx_user_data); print_r($user_pf_data); /* if( is_readable($csvname) ){ $csvfile = fopen("$csvname","r"); while(! feof($csvfile)) { $nx_user_data = fgetcsv($csvfile); $user_pf_data = generate_pf_array($nx_user_data); $user = array ( "profile_fields" => $user_pf_data, "profile_fields_editable" => true, ); print_r($user); } } */ cpfooter(); }else{ cpredirect("nx_addusers.php?".SID); } } ?>