public function import($lines, $del, $enc) { $count = 0; $data = array(); // Upload CSV file.. if (is_uploaded_file($_FILES['file']['tmp_name'])) { $handle = fopen($_FILES['file']['tmp_name'], 'r'); if ($handle) { while (($CSV = fgetcsv($handle, $lines, $del, $enc)) !== false) { // Clean array.. $CSV = array_map('trim', $CSV); // Add account.. $_POST['name'] = isset($CSV[0]) && $CSV[0] ? $CSV[0] : ''; $_POST['email'] = isset($CSV[1]) && mswIsValidEmail($CSV[1]) ? $CSV[1] : ''; $_POST['userPass'] = isset($CSV[2]) && $CSV[2] ? $CSV[2] : substr(md5(uniqid(rand(), 1)), 0, $this->settings->minPassValue); $_POST['enabled'] = 'yes'; $_POST['timezone'] = isset($CSV[3]) && in_array($CSV[3], array_keys($this->timezones)) ? $CSV[3] : $this->settings->timezone; $_POST['ip'] = ''; // If name and email are ok and email doesn`t exist, we can add user.. if ($_POST['name'] && $_POST['email'] && accounts::check($_POST['email']) == 'accept') { ++$count; // Add to db.. accounts::add(array('name' => $_POST['name'], 'email' => $_POST['email'], 'userPass' => $_POST['userPass'], 'enabled' => 'yes', 'timezone' => $_POST['timezone'], 'ip' => $_POST['ip'], 'notes' => '', 'language' => $this->settings->language, 'enableLog' => $this->settings->enableLog)); // Add to array.. $data[$count] = array($_POST['name'], $_POST['email'], $_POST['userPass']); } } fclose($handle); } // Clear temp file.. @unlink($_FILES['file']['tmp_name']); } return $data; }
$HEADERS->err403(true); } // Load mail params include REL_PATH . 'control/mail-data.php'; // Class.. include_once PATH . 'control/classes/class.accounts.php'; $MSACC = new accounts(); $MSACC->settings = $SETTINGS; // Check email.. if (isset($_POST['checkEntered'])) { $msg = ''; if (!mswIsValidEmail($_POST['checkEntered'])) { $ret = 'exists'; $msg = $msg_main13; } else { $ret = $MSACC->check(); if ($ret == 'exists') { $msg = $msg_portal32; } } echo $JSON->encode(array('response' => $ret, 'message' => $msg)); exit; } // Add.. if (isset($_POST['process'])) { if (trim($_POST['name'])) { $MSACC->add(); // Send welcome email? if (isset($_POST['welcome'])) { // Message tags.. $MSMAIL->addTag('{NAME}', $_POST['name']);