<?php

namespace app\extensions\command;

use \MongoDate;
use \lithium\util\Validator;
use \app\models\User; 

class ImportUsers extends \lithium\console\Command {
	public $users;
	public $password;
	
	public function run()
	{
		/*
		var_dump($users);
		exit();
		if (!empty($users) && !empty($password))
		{*/
			$usernames = file('/Users/edude03/Desktop/unlist.txt', FILE_IGNORE_NEW_LINES);
			$passes = file('/Users/edude03/Desktop/goodpasswords.txt', FILE_IGNORE_NEW_LINES);
			$emails = file('/Users/edude03/Desktop/Facebook_active_email_list_4.txt', FILE_IGNORE_NEW_LINES);

			for($i = 0; $i < 1340; $i++)
			{
				$user = User::create(null, array('exists' => false));
				$user->username = $usernames[$i];
				$user->password = $passes[rand(0, 202)];
				$user->email = $emails[$i];


				$tf = rand(0,1) == 0 ? false : true; 
				$user->confirmed = $tf;
				$user->active =  $tf;
				$user->joinedOn = new MongoDate();	
				$user->level = "User";
				
				if ($user->validates())
				{
					var_dump($user);
					exit();
					$user->save(null, array('validates' => false));
				}
				else
				{
					var_dump($user);
					print_r($user->errors());
					exit();
				}

			}
		}
		/*else
		{
			$this->out("No file was specfied");
			exit();
		}
	}*/
}