[zoneedit_cname]

Description

Link: [zoneedit_cname]
Author: Jason Huck
Category: Utility
Version: 8.5.x
License: Public Domain
Posted: Aug. 02, 2007
Updated: Jan. 01, 0001
More by this author...
Add, remove, and list cnames for the given zone at ZoneEdit.

Methods (see sample usage for exact implementation):

->add - Adds the specified cname/subdomain to the specified target domain. Returns true if successful, false otherwise.

->list - Returns a list of all cnames associated with the given zone as an array of pairs, where the key for each pair is the cname and the value is the ZoneEdit ID for that cname. Required in order to delete a cname.

->remove - Removes the given cname from the given zone. Returns true if successful, false otherwise.

->send - Sends requests to ZoneEdit. Used internally by the other methods.

Parameters

none


Sample Usage

var('ze') = zoneedit_cname(
	-zone='mydomain.tld',
	-username='xxxxxxxxx',
	-password='xxxxxxxxx'
);

$ze->list->size;
'<hr>\n';

$ze->add( -cname='auto3', -target='www.mydomain.tld');
$ze->list->size;
'<hr>\n';

$ze->remove('auto3');
$ze->list->size;
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
define_type(
	'cname',
	-namespace='zoneedit_',
	-prototype,
	-description='Add, remove, and list cnames for the given zone at ZoneEdit.'
);
	local(
		'username' = string,
		'password' = string,
		'zone' = string,
		'cname' = string,
		'cnames' = array,
		'target' = string
	);
	
	define_tag(
		'oncreate',
		-req='zone',
		-req='username',
		-req='password'
	);
		self->zone = #zone;
		self->username = #username;
		self->password = #password;
	/define_tag;
	
	define_tag(
		'send',
		-req='post',
		-encodenone
	);
		local('response') = string;
	
		protect;
			#response = include_url(
				'https://www.zoneedit.com/auth/edit.html?zone=' + self->zone + '&type=CNAME',
				-username = self->username,
				-password = self->password,
				-postparams = #post,
				-timeout = 15
			);
		/protect;
		
		return(#response);
	/define_tag;
	
	define_tag(
		'add',
		-req='cname',
		-req='target'
	);
		local(
			'out' = false,
			'response' = string,
			'postparams' = array(
				'AddNew' = 'Add New Alias',
				'dnsfrom' = #cname,
				'dnsto' = #target,
				'confirm' = 'Yes'
			)
		);
	
		#response = self->send(#postparams);
		#response >> '<span class="subzone">' + #cname + '.</span>' ? #out = true;		
		return(#out);			
	/define_tag;
	
	define_tag('list');
		local(
			'response' = string,
			'names' = null,
			'ids' = null,
			'out' = array
		);
		
		#response = self->send(array);
		
		#names = string_findregexp(
			#response,
			-find='<span class="subzone">([a-z0-9\\-\\.]+?)\\.</span>',
			-ignorecase
		)->removeall(
			match_regexp('<span class="subzone">[a-z0-9\\-\\.]+?\\.</span>')
		)&;

		#ids = string_findregexp(
			#response,
			-find='<input type="checkbox" name="del" value="([0-9]+)">',
			-ignorecase
		)->removeall(
			match_regexp('<input type="checkbox" name="del" value="[0-9]+">')
		)&;
		
		iterate(#names, local('i'));
			protect;
				#out->insert(#i = #ids->get(loop_count));
			/protect;
		/iterate;
		
		return(#out);		
	/define_tag;
	
	define_tag(
		'remove',
		-req='cname'
	);
		local('cnames') = self->list;
		
		protect;
			local('id') = #cnames->find(#cname)->first->second;
			
			handle_error;
				return(false);
			/handle_error;
		/protect;
	
		local(
			'out' = false,
			'response' = string,
			'postparams' = array(
				'Delete' = 'Delete Selected',
				'del' = #id,
				'confirm' = 'Yes'
			)
		);
	
		#response = self->send(#postparams);			
		#out = (#response !>> ('<span class="subzone">' + #cname + '.</span>'));		
		return(#out);	
	/define_tag;
/define_type;

 

Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net