Exemplo n.º 1
0
 public function ConvertContacts()
 {
     $contact_data = $this->DbOld->GetAll('SELECT * FROM contacts');
     $ok = $fail = 0;
     foreach ($contact_data as $i => $contact_row) {
         $imported = (int) $this->DbNew->GetOne('SELECT COUNT(*) FROM contacts WHERE clid = ?', array($contact_row['clid']));
         if ($imported) {
             // Skip contact, that was imported with domain in $this->ConvertActiveDomains
             continue;
         }
         $this->Log(sprintf('Import contact %s', $contact_row['clid']));
         if ($contact_row['type'] == 'bill') {
             $contact_row['type'] = CONTACT_TYPE::BILLING;
         }
         $Registry = $this->RegistryFactory->GetRegistryByExtension($contact_row['TLD'], $db_check = false);
         $Contact = $Registry->NewContactInstance($contact_row['type']);
         $Contact->CLID = $contact_row['clid'];
         $Contact->AuthCode = $contact_row['pw'];
         $Contact->UserID = $contact_row['userid'];
         try {
             $Contact = $Registry->GetRemoteContact($Contact);
             $this->DBContact->Save($Contact);
             $ok++;
         } catch (Exception $e) {
             $this->Log($e->getMessage(), E_USER_ERROR);
             $fail++;
         }
     }
     $this->Log(sprintf("Imported: %s; Failed: %s", $ok, $fail));
 }
Exemplo n.º 2
0
 function _testBusy()
 {
     $Contact = DBContact::GetInstance()->LoadByCLID('VRSGN3');
     //$Module = $this->Registry->GetModule();
     //$Domain = $this->Registry->NewDomainInstance();
     //$Domain->Name = "webta";
     //$Module->CreateDomain($Domain, 2);
     $Domain = $this->Registry->NewDomainInstance();
     $Domain->Name = "webta-" . rand(1000, 9999);
     $Domain->UserID = 1;
     $Domain->SetContact($Contact, CONTACT_TYPE::REGISTRANT);
     $Domain->SetContact($Contact, CONTACT_TYPE::BILLING);
     $Domain->SetContact($Contact, CONTACT_TYPE::TECH);
     $this->Registry->CreateDomain($Domain, 2);
     //$ns1 = new NameserverHost('ns1.' . $Domain->GetHostName(), gethostbyname('hostdad.com'));
     //$ns2 = new NameserverHost('ns2.' . $Domain->GetHostName(), gethostbyname('hostdad.com'));
     /*
     $this->Registry->CreateNameserverHost($ns1);
     $this->Registry->CreateNameserverHost($ns2);
     
     $Changes = $Domain->GetNameserverChangelist();
     $Changes->Add($ns1);
     $Changes->Add($ns2);
     $this->Registry->UpdateDomainNameservers($Domain, $Changes);
     */
 }
Exemplo n.º 3
0
 /**
  * @return DBContact
  */
 public static function GetInstance()
 {
     if (self::$Instance === null) {
         self::$Instance = new DBContact();
     }
     return self::$Instance;
 }
Exemplo n.º 4
0
 function import()
 {
     $module = strtolower($this->module);
     if ($module == "dotnl") {
         $parser = new DotNLParser();
         $registry = $this->registryFactory->GetRegistryByName('DotNL');
     } else {
         if ($module == "rrpproxy") {
             $parser = new RRPProxyParser();
             $registry = $this->registryFactory->GetRegistryByName('RRPProxy');
         }
     }
     if ($parser == null) {
         throw new Exception("Cannot find line parser for module '{$module}'");
     }
     // Import process
     $fp = $this->fopen($this->in);
     $headers = $this->fgetcsv($fp);
     for ($lineno = 1; !feof($fp); $lineno++) {
         $line = $this->fgetcsv($fp);
         $line = array_combine($headers, array_map('trim', $line));
         try {
             $parseResult = $parser->parseLine($line);
             if (!$parseResult) {
                 continue;
             }
         } catch (Exception $e) {
             print "Cannot parse line {$lineno}\n";
             continue;
         }
         if ($this->dbContact->FindByCLID($parseResult['clid'])) {
             // Skip existing in database
             print "[{$parseResult['clid']}] Skipped. Already exists in database.\n";
             continue;
         }
         // Construct contact
         $contact = $registry->NewContactInstanceByGroup($parseResult['group']);
         $contact->CLID = $parseResult['clid'];
         $contact->UserID = $this->userid;
         try {
             $contact->SetFieldList($parseResult['fields'], 1);
         } catch (ErrorList $e) {
             print "[{$contact->CLID}] Contact data violates manifest rules. " . join("; ", $e->GetAllMessages()) . "\n";
             print "[{$contact->CLID}] Set non strict mode\n";
             $contact->SetFieldList($parseResult['fields'], 0);
         }
         // Save contact
         try {
             $this->dbContact->Save($contact);
             print "[{$contact->CLID}] Imported\n";
         } catch (Exception $e) {
             print "[{$contact->CLID}] Cannot save. {$e->getMessage()}\n";
         }
     }
     fclose($fp);
 }
Exemplo n.º 5
0
 function DispatchPollDeleteContact(PollDeleteContactResponse $resp)
 {
     if ($resp->IsFailed()) {
         Log::Log(sprintf('DispatchContactDeleted failed. Registry response: %s', $resp->ErrMsg), E_USER_ERROR);
         throw new Exception($resp->ErrMsg, $resp->Code);
     }
     $contact = $this->DBContact->LoadByCLID($resp->CLID);
     $this->DBContact->Delete($contact);
     $this->FireEvent('ContactDeleted', $contact);
 }
Exemplo n.º 6
0
 /**
  * @param $params = array(
  * 		clid		string		Contact CLID
  * 		fields		array		
  * )
  * @return eppdrs-api.xsd#updateContactResponse
  */
 function UpdateContact($params)
 {
     $this->CheckContactAccess($params['clid']);
     $contact = DBContact::GetInstance()->LoadByCLID($params['clid']);
     $registry = $contact->ModuleName ? $this->registry_factory->GetRegistryByName($contact->ModuleName) : $this->registry_factory->GetRegistryByExtension($contact->Extension);
     try {
         $contact->SetFieldList($params['fields']);
     } catch (ErrorList $e) {
         throw new Exception(join("\n", $e->GetAllMessages()));
     }
     $registry->UpdateContact($contact);
     return new stdClass();
 }
Exemplo n.º 7
0
 /**
  * 
  * @param $params = array(
  * 		query		string		Search over contact fields and clid
  * 		userId		int 		User ID (Only in admin mode)
  * 
  * 		start		int			Data slice start. Default 0
  * 		limit		int			Date slice size. Default 25. -1 Unlimited 
  * )
  * @return object
  */
 function ListContacts($params = null)
 {
     $sql = "SELECT DISTINCT c.* from contacts AS c";
     $where = array();
     $bind = array();
     // Apply filter
     if ($params["query"]) {
         $query = mysql_escape_string($params["query"]);
         $sql .= " LEFT JOIN contacts_data as cd ON c.clid = cd.contactid";
         $where[] = "(c.clid LIKE '%{$query}%' OR cd.`value` LIKE '%{$query}%')";
     }
     if ($this->access_mode == self::ACCESS_MODE_ADMIN) {
         if ($params["userId"]) {
             $where[] = "c.userid = ?";
             $bind[] = $params["userId"];
         }
     } else {
         // Users can search only in their domains
         $where[] = "c.userid = ?";
         $bind[] = $this->user_id;
     }
     // Build SQL
     $sql .= $where ? " WHERE " . join(" AND ", $where) : "";
     $sql_total = preg_replace('/DISTINCT c\\.\\*/', 'COUNT(DISTINCT c.id)', $sql, 1);
     // Sorting
     $sql .= " ORDER BY id ASC";
     // Apply limits
     if ($params["limit"] != -1) {
         $sql .= sprintf(" LIMIT %d, %d", $params["start"] ? $params["start"] : 0, $params["limit"] ? $params["limit"] : 25);
     }
     $rows = $this->db->GetAll($sql, $bind);
     $total = $this->db->GetOne($sql_total, $bind);
     $ret = new stdClass();
     $ret->contactList = new stdClass();
     $ret->total = $total;
     $db_contact = DBContact::GetInstance();
     foreach ($rows as $row) {
         $ret_contact = new stdClass();
         $ret_contact->clid = $row["clid"];
         try {
             $contact = $db_contact->Load($row["id"]);
             $ret_contact->name = $contact->GetFullName();
             $ret_contact->email = $contact->GetEmail();
         } catch (Exception $e) {
             $ret_contact->name = $ret_contact->email = "Unknown";
         }
         $ret->contactList->contact[] = $ret_contact;
     }
     return $ret;
 }
 /**
  * @param Invoice $Invoice Paid trade invoice
  * @throws LogicException
  */
 private function initFromInvoice(Invoice $Invoice)
 {
     if ($Invoice->Status != INVOICE_STATUS::PAID) {
         throw new LogicException("Invoice is unpaid");
     }
     if ($Invoice->Purpose != INVOICE_PURPOSE::DOMAIN_TRADE) {
         throw new LogicException("Invoice status must be INVOICE_PURPOSE::DOMAIN_TRADE. '{$Invoice->Purpose}' taken");
     }
     try {
         $this->Domain = DBDomain::GetInstance()->Load($Invoice->ItemID);
         $this->contact_type = CONTACT_TYPE::REGISTRANT;
         $this->NewContact = DBContact::GetInstance()->LoadByCLID($this->Domain->NewRegistrantCLID);
         $this->Invoice = $Invoice;
     } catch (Exception $e) {
         $this->Domain = null;
         $this->contact_type = null;
         $this->NewContact = null;
         $this->Invoice = null;
         throw new LogicException(sprintf(_("Cannot initialize action. Reason: %s"), $e->getMessage()));
     }
 }
Exemplo n.º 9
0
 function _testGenerateCLID()
 {
     return;
     $DBContact = DBContact::GetInstance();
     $clid = $DBContact->GenerateCLID('H%d8');
     $this->assertTrue(preg_match('/^H\\d{8}$/', $clid) == true, 'Generate CLID');
 }
 /**
  * Enter description here...
  */
 public function Render()
 {
     $this->rendered_data = array();
     $Manifest = $this->Registry->GetManifest();
     $section_shared_contacts = (bool) $Manifest->GetRegistryOptions()->ability->section_shared_contacts;
     $contacts_config = UI::GetContactsListForSmarty($Manifest->GetSectionConfig());
     $DbContact = DBContact::GetInstance();
     foreach ($contacts_config as $v) {
         $smarty_contact = $v;
         $smarty_contact["groupname"] = $Manifest->GetGroupNameByContactType($v["type"]);
         if (!$section_shared_contacts) {
             $section_name = $Manifest->GetSectionName();
             $target_index = $Manifest->GetContactTargetIndex($this->tld, $smarty_contact["groupname"]);
             $smarty_contact['target_title'] = $Manifest->GetContactTargetTitle($this->tld, $smarty_contact["groupname"]);
         } else {
             $section_name = "";
             $target_index = 0;
             $smarty_contact['target_title'] = $this->Registry->GetModuleName();
         }
         // Calculate contact num in group
         $num_items = (int) $this->Db->GetOne("\r\n        \t\tSELECT COUNT(clid) FROM contacts \r\n        \t\tWHERE userid=? AND \r\n        \t\t(TLD = ? OR (module_name=? AND section_name=? AND target_index=?)) AND \r\n        \t\tgroupname=?", array($this->userid, $this->tld, $this->Registry->GetModuleName(), $section_name, $target_index, $smarty_contact["groupname"]));
         if ($num_items < self::MAX_ITEMS) {
             // Render simple contact select list
             $smarty_contact["exists"] = $this->Db->GetAll("\r\n\t        \t\tSELECT clid FROM contacts \r\n\t        \t\tWHERE userid=? AND \r\n\t        \t\t(TLD = ? OR (module_name=? AND section_name=? AND target_index=?)) AND \r\n\t        \t\tgroupname=? \r\n\t        \t\tORDER BY id ASC", array($this->userid, $this->tld, $this->Registry->GetModuleName(), $section_name, $target_index, $smarty_contact["groupname"]));
             $DomainContact = null;
             if ($this->Domain) {
                 $DomainContact = $this->Domain->GetContact($v["type"]);
             }
             $smarty_contact["disabled"] = array();
             foreach ($smarty_contact["exists"] as &$c) {
                 try {
                     $Contact = $DbContact->LoadByCLID($c["clid"]);
                     $smarty_contact["disabled"][$c["clid"]] = count($Contact->GetPendingOperationList());
                     $c['title'] = $Contact->GetTitle();
                     // Check selected
                     if ($DomainContact && $DomainContact->CLID == $c["clid"]) {
                         $c["selected"] = true;
                         $smarty_contact['selected'] = $c['clid'];
                     }
                 } catch (Exception $e) {
                     Log::Log($e->getMessage(), E_USER_ERROR);
                     unset($c);
                     continue;
                 } catch (ErrorList $e) {
                     Log::Log(join('; ', $e->GetAllMessages()), E_USER_ERROR);
                     unset($c);
                     continue;
                 }
             }
             $smarty_contact['list'] = array();
             foreach ($smarty_contact['exists'] as $ex) {
                 $smarty_contact['list'][$ex['clid']] = $ex['title'];
             }
         } else {
             // External contact select
             $smarty_contact['too_many_items'] = true;
         }
         $this->rendered_data['contacts'][] = $smarty_contact;
     }
     $this->rendered_data['tld'] = $this->tld;
     $this->rendered_data['form_title'] = $this->form_title;
     $this->rendered_data['button_text'] = $this->button_text;
     $this->rendered_data['form_action'] = $this->form_action;
     $this->rendered_data['form_method'] = $this->form_method;
     $this->rendered_data['form_fields'] = $this->form_fields;
 }
Exemplo n.º 11
0
            	$err = $e->getAllMessages();
            }
            
            if (!$err)
            {
				$Contact->UserID = $_SESSION['userid'];

				try
				{
	   				// Get contact change policy
					$ContactConfig = $Contact->GetConfig();
					$need_approval = $ContactConfig->policy->approveChangesPolicy 
							&& $ContactConfig->policy->approveChangesPolicy->getName(); 
					if ($need_approval)
					{
						DBContact::GetInstance()->Save($Contact);						
						$Registry->AddPendingOperation($Contact, Registry::OP_CREATE_APPROVE);
						EmailToRegistrantObserver::OnNewChangeContactRequest($Contact, Registry::OP_CREATE_APPROVE);
						
						$okmsg = _("Contact will be created after administrator approval");
						CoreUtils::Redirect("change_contact_policy.php?contactid=".$Contact->ID."&next_url=".urlencode("contacts_view.php"));
					}
					else
					{
						$Registry->CreateContact($Contact);
		            	$okmsg = _("Contact successfully created.");
						CoreUtils::Redirect("contacts_view.php");
					}
				}
				catch (Exception $e)
				{
Exemplo n.º 12
0
        function _testContactObject()
        {
        	// CreateContact
        	/*
        	try
        	{
	        	$c = $this->registry->NewContactInstance("registrant");
	        	$c->SetFieldList(array(
	        		'name' 		=> 'marat komarov',
	        		'org' 		=> 'MK1O',
	        		'cc' 		=> 'NO',
	        		'sp' 		=> 'crimea',
	        		'city' 		=> 'TRONDHEIM',
	        		'pc' 		=> '7491',
	        		'sp' 		=> 'Crimea',
	        		'street1' 	=> 'bbfdgfd fds',
					'street2' 	=> 'dsf fd d',
	        		'voice' 	=> '+33.12345678',
	        		'fax' 		=> '+33.12345678',
	        		'email' 	=> '*****@*****.**'	
	        	));
        	}
        	catch(ErrorList $e)
        	{
        		var_dump($e);
        	}
        	
        	try 
        	{
        		//$this->registry->CreateContact($c);
        		//$this->assertTrue(true, 'Contact created');
        	}
        	catch (Exception $e)
        	{
        		$this->assertTrue(false, 'Contact created');
        		var_dump($e);
        	}
        	
        	try
        	{
	        	$c = $this->registry->NewContactInstance("tech");
	        	$c->SetFieldList(array(
	        		'name' 		=> 'marat komarov',
	        		'org' 		=> 'MK1O',
	        		'cc' 		=> 'NO',
	        		'sp' 		=> 'crimea',
	        		'city' 		=> 'TRONDHEIM',
	        		'pc' 		=> '7491',
	        		'sp' 		=> 'Crimea',
	        		'street1' 	=> 'bbfdgfd fds',
					'street2' 	=> 'dsf fd d',
	        		'voice' 	=> '+33.12345678',
	        		'fax' 		=> '+33.12345678',
	        		'email' 	=> '*****@*****.**'	
	        	));
        	}
        	catch(ErrorList $e)
        	{
        		var_dump($e);
        	}
        	
        	try 
        	{
        		//$this->registry->CreateContact($c);
        		//$this->assertTrue(true, 'Contact created');
        	}
        	catch (Exception $e)
        	{
        		$this->assertTrue(false, 'Contact created');
        		var_dump($e);
        	}
        	
        	exit();
        	sleep(1);
        	
        	try
        	{
	        	$c->SetFieldList(array(
	        		'name' 		=> 'marat komarov2',
	        		'org' 		=> 'MK1O2',
	        		'cc' 		=> 'UA',
	        		'sp' 		=> 'crimea2',
	        		'city' 		=> 'TRONDHEIM2',
	        		'pc' 		=> '74912',
	        		'sp' 		=> 'Crimea2',
	        		'street1' 	=> 'bbfdgfd fds2',
					'street2' 	=> 'dsf fd d2',
	        		'voice' 	=> '+33.123456782',
	        		'fax' 		=> '+33.123456782',
	        		'email' 	=> '*****@*****.**'	
	        	));
        	}
        	catch(ErrorList $e)
        	{
        		var_dump($e);
        		exit();
        	}
        	
        	try
        	{
        		//$this->registry->UpdateContact($c);        		
        	}
        	catch (Exception $e)
        	{
        		$this->assertTrue(false, 'Contact updated');
        		var_dump($e->getMessage());
        	}
        	
        	sleep(1);
        	*/
        	$c = DBContact::GetInstance()->LoadByCLID("11390275");
        	
        	try 
        	{
        		$c2 = $this->registry->GetRemoteContact($c);
        		var_dump($c2);
        		$this->assertTrue($c2, 'Remote contact received');
        	} 
        	catch (Exception $e) 
        	{
        		var_dump($e);
        		$this->assertTrue(false, 'remote contact received');
        	}
        		
        	try 
        	{
        		//$this->registry->DeleteContact($c2);
        	}
        	catch (Exception $e)
        	{
        		$this->assertTrue(false, 'Contact deleted');
        		var_dump($e->getMessage());        		
        	}
        }
Exemplo n.º 13
0
 /**
  * Retourne la liste des contacts au format JSON
  */
 private function jsonList()
 {
     if (parent::select(array('type' => 'list', 'getlang' => $this->getlang)) != null) {
         foreach (parent::select(array('type' => 'list', 'getlang' => $this->getlang)) as $key) {
             $json[] = '{"idcontact":' . json_encode($key['idcontact']) . ',"mail_contact":' . json_encode($key['mail_contact']) . '}';
         }
         print '[' . implode(',', $json) . ']';
     } else {
         print '{}';
     }
 }
Exemplo n.º 14
0
				$Registry->RemovePendingOperation($PendingOperation->ID);
				if ($PendingOperation->Type == Registry::OP_UPDATE_APPROVE)
				{
					$fields = array();
					foreach ($Contact->GetEditableNames() as $n)
					{
						$fields[$n] = $PendingOperation->ObjectBefore->GetField($n);
					}
					$Contact->SetFieldList($fields);	
					$Contact->SetDiscloseList($PendingOperation->ObjectBefore->GetDiscloseList());
					DBContact::GetInstance()->Save($Contact);	
					$okmsg = _("Contact update rejected");
				}
				else
				{
					DBContact::GetInstance()->Delete($Contact);
					$okmsg = _("Contact create rejected");					
				}
				
				CoreUtils::Redirect("contacts_view.php");
				break;
			}
		}
	}
	
   
    $display["help"] = _("This page contains all your contacts for all domain extensions that you have registered. Contacts are unique per domain extension. There are different types of contacts. Most common are Registrant, Billing and Technical. Some domain extension require other contact types to register domain.");
    $display["load_extjs"] = true;
    
	require_once ("src/append.inc.php")
?>
Exemplo n.º 15
0
			$RegistryContacts = UI::GetContactsListForSmarty($registry_config);		
			
	        $display["TLD"] = $_SESSION["domaininfo"]["extension"];
	
	        foreach ($RegistryContacts as $k=>$v)
	        {
	        	if (!$_POST[$v["type"]] && $v["isrequired"] == 1)
	        	{
	        		$message = sprintf(_("%s contact not specified"), $v["name"]);
	        		$exception->AddMessage(sprintf(_("%s contact not specified"), $v["name"]));
	        	}
	        	else if ($_POST[$v["type"]])
	        	{
	        		try
	        		{
	        			$Contact = DBContact::GetInstance()->LoadByCLID($_POST[$v["type"]]);
	        			if ($Contact->HasPendingOperation(Registry::OP_CREATE_APPROVE)
	        				|| $Contact->HasPendingOperation(Registry::OP_UPDATE_APPROVE))
	        			{
	        				$exception->AddMessage(
	        					sprintf(_("Contact <%s> is not yet approved by administrator"), $Contact->GetTitle()));
	        			}
	        			else
	        			{
	        				// Accept contact
		        			$_SESSION["domaininfo"][$v["type"]] = $_POST[$v["type"]];	        				
	        			}
	        		}
	        		catch (Exception $e)
	        		{
	        			$exception->AddMessage($e->getMessage());
Exemplo n.º 16
0
 function Report(Task $Task)
 {
     $Job = $Task->JobObject;
     $DbContact = DBContact::GetInstance();
     if ($Job->clids[CONTACT_TYPE::REGISTRANT]) {
         $emlvars['Registrant'] = $DbContact->LoadByCLID($Job->clids[CONTACT_TYPE::REGISTRANT]);
     }
     if ($Job->clids[CONTACT_TYPE::ADMIN]) {
         $emlvars['Admin'] = $DbContact->LoadByCLID($Job->clids[CONTACT_TYPE::ADMIN]);
     }
     if ($Job->clids[CONTACT_TYPE::TECH]) {
         $emlvars['Tech'] = $DbContact->LoadByCLID($Job->clids[CONTACT_TYPE::TECH]);
     }
     if ($Job->clids[CONTACT_TYPE::BILLING]) {
         $emlvars['Billing'] = $DbContact->LoadByCLID($Job->clids[CONTACT_TYPE::BILLING]);
     }
     $emlvars['report'] = array();
     foreach ($Task->GetAllTargets() as $Target) {
         $emlvars['report'][] = array('domain' => "{$Target->target}.{$Job->TLD}", 'status' => $Target->status == TargetStatus::OK ? "ok" : "failed", 'fail_reason' => $Target->fail_reason);
     }
     $Client = Client::Load($Task->userid);
     $emlvars['Client'] = $Client;
     mailer_send("bulk_update_contact.eml", $emlvars, $Client->Email, $Client->Name);
 }
Exemplo n.º 17
0
				foreach ($errors as $_errmsg) $err[] = $_errmsg;
		}
		
		//var_dump($err);
		//var_dump($post_add_data);
		//die();
		
		if (!$err)
		{
			if ($transfer_contacts)
			{
				foreach($transfer_contacts as $v)
				{
					if ($_POST[$v])
					{
						$c = DBContact::GetInstance()->LoadByCLID($_POST[$v]);
						if ($c->HasPendingOperation(Registry::OP_CREATE_APPROVE)
	        				|| $c->HasPendingOperation(Registry::OP_UPDATE_APPROVE))
	        			{
	        				$err[] = sprintf(_("Contact <%s> is not yet approved by administrator"), $c->GetTitle()); 
	        			}
	        			else
	        			{
							$Domain->SetContact($c, $v);
	        			}						
					}			
				}
			}
	
			if (!$err)
			{
Exemplo n.º 18
0
 function _testMemento()
 {
     // Skip
     return;
     // Domain
     $DBDomain = DBDomain::GetInstance();
     $domain = $DBDomain->Load(88);
     $domain->Status = DOMAIN_STATUS::DELEGATED;
     $oldDomain = $DBDomain->GetInitialState($domain);
     $this->assertTrue($oldDomain->Status == DOMAIN_STATUS::REGISTRATION_PENDING, 'Domain memento');
     // Contact
     $DBContact = DBContact::GetInstance();
     $contact = $DBContact->LoadByCLID('H26523637');
     $contact->SetDiscloseValue('addr', 1);
     $oldContact = $DBContact->GetInitialState($contact);
     $oldDisclose = $oldContact->GetDiscloseList();
     $this->assertTrue($oldDisclose['addr'] == 0, 'Contact memento');
 }
Exemplo n.º 19
0
		function updateRoleObject () {
			$title = 'Update the contact role with an additional contact person.';
			try {
				// Need to save contact to prevent 
				// [Exception] Contact was not loaded through DBContact, or was deleted at class.DBContact.php line 55
				// DotNO module during UpdateContact checks DBContact initial state
				$dbContact = DBContact::GetInstance();
				$dbContact->Save($this->role1);				
				
				$data = $this->role1->GetFieldList();
				$data['id'] = $this->role1->CLID;
				$data['no-ext-add'] = "<no-ext-contact:add>"
						. "<no-ext-contact:roleContact>{$this->contact2->CLID}</no-ext-contact:roleContact>"
						. "</no-ext-contact:add>";
				$data['no-ext-rem'] = '';
				
				$trResp = $this->module->Request('contact-update', $data);
				$this->assertTrue($trResp->Succeed, $title);
				
			} catch (RegistryException $e) {
				$this->fail($title);
			}
			
			$dbContact->Delete($this->role1);
		}
 protected function PostContacts()
 {
     $k = "contact_list";
     $DbContact = DBContact::GetInstance();
     $ErrList = new ErrorList();
     foreach ($this->attr[$k] as $tld => $contacts) {
         foreach ($contacts as $clid) {
             if ($clid) {
                 try {
                     $Contact = $DbContact->LoadByCLID($clid);
                     if ($Contact->HasPendingOperation(Registry::OP_CREATE_APPROVE) || $Contact->HasPendingOperation(Registry::OP_UPDATE_APPROVE)) {
                         throw new Exception(sprintf(_("Contact <%s> is not yet approved by administrator"), $Contact->GetTitle()));
                     }
                 } catch (Exception $e) {
                     $ErrList->AddMessage($e->getMessage());
                 }
             }
         }
     }
     if ($ErrList->HasMessages()) {
         throw $ErrList;
     }
     $this->{$k} = $this->attr[$k];
 }
Exemplo n.º 21
0
 /**
  * Save domain in database
  *
  * @param Domain $domain
  * @return Domain
  */
 public function Save(Domain $domain)
 {
     if (!$domain->ID) {
         // check for duplicate domain
         $duplicate = $this->DB->GetOne('SELECT COUNT(*) FROM domains WHERE name = ? AND TLD = ?', array($domain->Name, $domain->Extension));
         if ($duplicate) {
             throw new Exception(sprintf(_('Domain %s already exists in DB and could\'t be added twice'), $domain->GetHostName()));
         }
     }
     // Properties data
     $row = array();
     foreach ($this->FieldPropertyMap as $field => $property) {
         $row[$field] = $domain->{$property} !== null ? $domain->{$property} : "";
     }
     if ($domain->IncompleteOrderOperation === null) {
         $row['incomplete_operation'] = null;
     }
     // Nameservers data
     $nslist = $domain->GetNameserverList();
     // If nameservers list smaller then size of db slots
     for ($i = 2; $i > count($ns_list); $i--) {
         $row['ns' . $i] = '';
     }
     $ns_n = array();
     foreach (array_values($nslist) as $i => $ns) {
         if ($i < 2) {
             $row['ns' . ($i + 1)] = $ns->HostName;
         } else {
             $ns_n[] = $ns->HostName;
         }
     }
     $row['ns_n'] = join(';', $ns_n);
     // Contacts data
     $contact_list = $domain->GetContactList();
     foreach ($this->ContactFieldTypeMap as $field => $contact_type) {
         $contact = $contact_list[$contact_type];
         // Add/Remove references to contact
         $row[$field] = $contact ? $contact->CLID : '';
     }
     // Domain extra fields
     $extra_fields = array();
     foreach ($domain->GetConfig()->xpath('registration/extra_fields/field') as $field) {
         settype($field, "array");
         $field = $field["@attributes"];
         if (isset($domain->{$field['name']})) {
             $extra_fields[$field['name']] = $domain->{$field['name']};
         }
     }
     foreach ((array) $domain->ExtraFields as $k => $v) {
         $extra_fields[$k] = $v;
     }
     // Prepare data for DB
     $row["start_date"] = $row["start_date"] ? date("Y-m-d H:i:s", $row["start_date"]) : '0000-00-00 00:00:00';
     $row["end_date"] = $row["end_date"] ? date("Y-m-d H:i:s", $row["end_date"]) : '0000-00-00 00:00:00';
     $row['dtTransfer'] = $row['dtTransfer'] ? date("Y-m-d H:i:s", $row["dtTransfer"]) : '0000-00-00 00:00:00';
     $row["islocked"] = (int) (bool) $row["islocked"];
     $row['managed_dns'] = (int) (bool) $row['managed_dns'];
     $row['period'] = (int) $row['period'];
     $row['delete_status'] = (int) $row['delete_status'];
     $row['renew_disabled'] = (int) (bool) $row['renew_disabled'];
     // Save it!
     //if ($domain->ID)
     unset($row['id']);
     // Prepare SQL statement
     $set = array();
     $bind = array();
     foreach ($row as $field => $value) {
         $set[] = "`{$field}` = ?";
         $bind[] = $value;
     }
     $set = join(', ', $set);
     $this->DB->BeginTrans();
     try {
         if ($domain->ID) {
             // Perform Update
             $bind[] = $domain->ID;
             $this->DB->Execute("UPDATE domains SET {$set} WHERE id = ?", $bind);
         } else {
             // Perform Insert
             $this->DB->Execute("INSERT INTO domains SET {$set}", $bind);
             $domain->ID = $this->DB->Insert_ID();
         }
         // Save extra data
         $this->DB->Execute('DELETE FROM domains_data WHERE domainid = ?', array($domain->ID));
         foreach ($extra_fields as $name => $value) {
             $this->DB->Execute('INSERT INTO domains_data SET `domainid` = ?, `key` = ?, `value` = ?', array($domain->ID, $name, $value));
         }
         // Save flags
         $this->DB->Execute('DELETE FROM domains_flags WHERE domainid = ?', array($domain->ID));
         $flag_list = $domain->GetFlagList();
         foreach ($flag_list as $flag) {
             $this->DB->Execute('INSERT INTO domains_flags SET domainid = ?, flag = ?', array($domain->ID, $flag));
         }
         // Save contacts
         foreach ($contact_list as $contact) {
             if (!$contact->UserID) {
                 $contact->UserID = $domain->UserID;
             }
             $this->DBContact->Save($contact);
         }
         // Save nameserver hosts
         $ns_list = $domain->GetNameserverHostList();
         foreach ($ns_list as $ns) {
             $ns_id = $this->DB->GetOne('SELECT id FROM nhosts WHERE domainid=? AND hostname=?', array($domain->ID, $ns->GetBaseName()));
             if ($ns_id) {
                 $this->DB->Execute('UPDATE nhosts SET ipaddr=? WHERE hostname=? AND domainid=?', array($ns->IPAddr, $ns->GetBaseName(), $domain->ID));
             } else {
                 $this->DB->Execute('INSERT INTO nhosts SET domainid=?, hostname=?, ipaddr=?', array($domain->ID, $ns->GetBaseName(), $ns->IPAddr));
                 $ns_id = $this->DB->Insert_ID();
             }
             $ns->ID = $ns_id;
         }
         //$this->DBNameserverHost->SaveList($ns_list, $domain->ID);
     } catch (Exception $e) {
         $this->DB->RollbackTrans();
         throw new ApplicationException($e->getMessage(), $e->getCode());
     }
     $this->DB->CompleteTrans();
     // Update domain in loaded objects storage
     $this->LoadedObjects[$domain->ID] = clone $domain;
     return $domain;
 }
Exemplo n.º 22
0
<?php

require_once 'src/prepend.inc.php';
// Load contact from DB
$DbContact = DBContact::GetInstance();
try {
    $Contact = $DbContact->Load($req_contactid);
} catch (Exception $e) {
    $errmsg = $e->getMessage();
}
if ($Contact) {
    // Get contact registry module
    try {
        $Registry = $Contact->ModuleName ? $RegistryModuleFactory->GetRegistryByName($Contact->ModuleName) : $RegistryModuleFactory->GetRegistryByExtension($Contact->Extension);
    } catch (Exception $e) {
        $errmsg = $e->getMessage();
    }
    $ContactConfig = $Contact->GetConfig();
    $policy = $ContactConfig->policy->children();
    $policy = $policy[0];
    $policy_id = $policy->attributes()->id;
    $RegistryOptions = $Registry->GetManifest()->GetRegistryOptions();
    $Policy = $RegistryOptions->xpath("policy[@id='{$policy_id}']");
    $display["policy_text"] = count($Policy) ? (string) $Policy[0] : null;
}
$display["button_js_action"] = "location.href='{$req_next_url}'";
require "src/append.inc.php";
Exemplo n.º 23
0
}
if ($req_query) {
    $filter = mysql_escape_string($req_query);
    $sql .= " AND (clid IN (SELECT DISTINCT contactid FROM contacts_data WHERE value LIKE '%{$filter}%') or clid LIKE '%{$filter}%')";
}
//	$sort = $req_sort ? mysql_escape_string($req_sort) : "module_name";
//	$dir = $req_dir ? mysql_escape_string($req_dir) : "ASC";
$sql .= " ORDER BY tld ASC, module_name ASC";
$response["total"] = $db->GetOne(preg_replace('/clid/', 'COUNT(*)', $sql, 1));
$start = $req_start ? (int) $req_start : 0;
$limit = $req_limit ? (int) $req_limit : 20;
$sql .= " LIMIT {$start}, {$limit}";
$response["data"] = array();
foreach ($db->GetAll($sql) as $row) {
    try {
        $Contact = DBContact::GetInstance()->LoadByCLID($row["clid"]);
    } catch (ErrorList $e) {
        Log::Log(join('; ', $e->GetAllMessages()), E_USER_ERROR);
        continue;
    } catch (Exception $e) {
        Log::Log($e->getMessage(), E_USER_ERROR);
        continue;
    }
    $status = null;
    if ($Contact->HasPendingOperation(Registry::OP_UPDATE_APPROVE)) {
        $status = "Await update approve";
    }
    if ($Contact->HasPendingOperation(Registry::OP_CREATE_APPROVE)) {
        $status = "Await create approve";
    }
    $allows = array();
 private function Init()
 {
     if (!$this->prepared) {
         $ErrList = new ErrorList();
         if (!$this->Registry) {
             $Factory = RegistryModuleFactory::GetInstance();
             try {
                 $this->Registry = $Factory->GetRegistryByExtension($this->tld);
             } catch (Exception $e) {
                 throw new RegisterDomainAction_Exception(sprintf(_("Cannot init registry module. Reason: %s"), $e->getMessage()));
             }
         }
         $registry_config = $this->Registry->GetManifest()->GetSectionConfig();
         $Validator = new Validator();
         /**
          * Validate period
          */
         if ($this->period) {
             self::ValidatePeriod($this->period, $this->Registry);
         }
         /*
          * Validate additional domain information
          */
         $extra_fields = null;
         if (count($registry_config->domain->registration->extra_fields->field) > 0) {
             $extra_fields = UI::GetRegExtraFieldsForSmarty($registry_config);
             foreach ($extra_fields as $field) {
                 if ($field["isrequired"] == 1 && $field["type"] != "checkbox") {
                     if (!strlen($this->extra_data[$field['name']])) {
                         $ErrList->AddMessage(sprintf(_("%s required"), ucfirst($field["name"])));
                     }
                 }
             }
         }
         // Break on errors
         $this->ExceptionOnErrors($ErrList);
         /**
          * Validate DNS
          */
         if (!$this->managed_dns_enabled) {
             if (!$this->nameserver_list) {
                 foreach ($this->ns_list as $ns) {
                     $this->nameserver_list[] = new Nameserver($ns);
                 }
             }
             $nameserver_list = $this->nameserver_list;
             if (count(array_unique($nameserver_list)) < count($nameserver_list)) {
                 $ErrList->AddMessage(_("Cannot use the same nameserver twice."));
             } else {
                 foreach ($nameserver_list as $Nameserver) {
                     if (!$Validator->IsDomain($Nameserver->HostName)) {
                         $ErrList->AddMessage(sprintf(_("'%s' is not a valid host"), $Nameserver->HostName));
                     }
                 }
             }
         } else {
             $this->nameserver_list = array(new Nameserver(CONFIG::$NS1), new Nameserver(CONFIG::$NS2));
         }
         $this->ExceptionOnErrors($ErrList);
         /*
          * Validate contacts 
          */
         if (!$this->contact_list) {
             $DbContact = DBContact::GetInstance();
             $this->contact_list = array();
             foreach ($this->clid_list as $ctype => $clid) {
                 if (!$clid) {
                     continue;
                 }
                 try {
                     $Contact = $DbContact->LoadByCLID($clid);
                     $this->contact_list[$ctype] = $Contact;
                 } catch (Exception $e) {
                     $ErrList->AddMessage(sprintf(_("Cannot load %s contact. %s"), $ctype, $clid, $e->getMessage()));
                 }
             }
             // Break on errors
             $this->ExceptionOnErrors($ErrList);
         }
         $this->ExceptionOnErrors(self::ValidateContactList($this->contact_list, $this->Registry));
         $this->prepared = true;
     }
 }
Exemplo n.º 25
0
 } else {
     if ($stepno == 2) {
         // Accept selected domains
         if (!empty($post_domains)) {
             $_SESSION['BU_DOMAINS'] = $post_domains;
             $stepno = 3;
         } else {
             $errmsg = sprintf(_("No domains were selected"));
         }
     } else {
         if ($stepno == 3) {
             // Accept selected contacts and create pending update operation
             foreach (array($post_registrant, $post_admin, $post_billing, $post_tech) as $clid) {
                 if ($clid) {
                     try {
                         $Contact = DBContact::GetInstance()->LoadByCLID($clid);
                         if ($Contact->HasPendingOperation(Registry::OP_CREATE_APPROVE) || $Contact->HasPendingOperation(Registry::OP_UPDATE_APPROVE)) {
                             $err[] = sprintf(_("Contact <%s> is not yet approved by administrator"), $Contact->GetTitle());
                         }
                     } catch (Exception $e) {
                         $err[] = $e->getMessage();
                     }
                 }
             }
             if (!$err) {
                 if (!($post_registrant || $post_admin || $post_billing || $post_tech)) {
                     $errmsg = sprintf(_("No contacts were selected"));
                 } else {
                     if (!$_SESSION['BU_TLD']) {
                         $errmsg = sprintf(_("No domain extension was selected"));
                     } else {
Exemplo n.º 26
0
			$req_filter_q,
			array(),
			"(clid IN (SELECT DISTINCT contactid FROM contacts_data WHERE value LIKE '%[FILTER]%')) or clid LIKE '%[FILTER]%'"
		);
		$paging->SetURLFormat("javascript:ContactList_ShowPage('{$req_type}', %d)");
		$paging->TrainLength = 5;
		$sql = $paging->ApplySQLPaging();
		$paging->ParseHTML();
			
		$clids = $db->GetAll($sql);
		$rows = array();
		foreach ($clids as $clid)
		{
			try
			{
				$c = DBContact::GetInstance()->LoadByCLID($clid['clid']);
				$contact_fields = $c->GetFieldList();
				$rows[] = array
				(
					'clid' => $c->CLID,
					'title' => $c->GetTitle()
				);
			}
			catch (Exception $e)
			{}
		}

		$display['rows'] = $rows;
		$display['paging'] = $paging->GetPagerHTML("client/inc/paging.tpl");
		$display['filter'] = $paging->GetFilterHTML('client/inc/contact_table_filter.tpl');
		$display['type'] = $req_type;
Exemplo n.º 27
0
				(userid=? OR (clid='{$c[0]}' OR clid='{$c[1]}' OR clid='{$c[2]}' OR clid='{$c[3]}')) AND 
				groupname=? AND 
				(TLD = ? OR (module_name=? AND section_name=? AND target_index=?)) 
			ORDER BY IF(clid = ?, 1, 0) DESC",
			array(
				$_SESSION['userid'], $group_name, 
				$Domain->Extension, $Registry->GetModuleName(), $section_name, $target_index, 
				$curr_clid
			)
		);
		
		foreach ($contacts as &$c)
		{
			try
			{
				$Cont = DBContact::GetInstance()->LoadByCLID($c["clid"], $Manifest);
				$c['title'] = $Cont->GetTitle();
				
				unset($Cont);
				$display['contacts'][] = $c;
			}
			catch (Exception $e) 
			{
			}
		}
	}
	else
	{
		$display['too_many_items'] = true;
	}
	
Exemplo n.º 28
0
		CoreUtils::Redirect("domains_view.php");
	}
			
	$oDomain = @unserialize($info["object_before"]);
	$nDomain = @unserialize($info["object_after"]);
			
	if ($oDomain->UserID != $_SESSION['userid'] || $nDomain->UserID != $_SESSION['userid'])
		CoreUtils::Redirect("domains_view.php");
		
	switch($info["operation"])
	{			
		case "TRADE":
			
			$attrs = array(
							"NewContact" => DBContact::GetInstance()->LoadByCLID($nDomain->GetContact("registrant")->CLID),
							"OldContact" => DBContact::GetInstance()->LoadByCLID($oDomain->GetContact("registrant")->CLID),
						  );
			
			$smarty->assign($attrs);
			$display["details"] = $smarty->fetch("inc/pending_operations_details/trade.tpl"); 
						  
			break;
						
		case "UPDATE":
			
			$contacts = $oDomain->GetContactList();
			foreach ($contacts as $type=>$contact)
			{
				if ($contact->CLID != $nDomain->GetContact($type)->CLID)
					$changes[] = sprintf("Change %s contact from %s to %s", ucfirst($type), $contact->GetFullName(), $nDomain->GetContact($type)->GetFullName());
			}