Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F41923909
core2.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
core2.php
View Options
<?php
function
is_mail
(
$string
)
{
return
preg_match
(
'/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+
\.
[A-Za-z0-9]{2,4}$/'
,
$string
);
}
/*
Unit testing ->
1 is_mail("dereckson@gmail.com");
1 is_mail("dereckson@trustspace.42");
1 is_mail("dereckson@gmail.a.a.a.a.a.a.a.ax.org");
1 is_mail("dereckson+wazza@gmail.com");
0 is_mail("dereckson`ls`@gmail.com");
*/
/**
* Gets an HTTP context
*/
function
get_http_context
()
{
return
stream_context_create
([
'http'
=>
[
'method'
=>
'GET'
,
'user_agent'
=>
'NasqueronTools/0.1'
]
]);
}
function
get_innerHtml
(
DOMNode
$element
)
{
$innerHtml
=
""
;
foreach
(
$element
->
childNodes
as
$childNode
)
{
$dom
=
new
DOMDocument
(
'1.0'
,
'utf-8'
);
$dom
->
appendChild
(
$dom
->
importNode
(
$childNode
,
true
)
);
$innerHtml
.=
trim
(
$dom
->
saveHTML
());
}
return
$innerHtml
;
}
function
get_array_from_html_table
(
$html
,
$stripHTML
=
true
)
{
$array
=
[];
$html
=
str_ireplace
(
'<th '
,
'<td '
,
$html
);
$html
=
str_ireplace
(
'<th>'
,
'<td>'
,
$html
);
$html
=
str_ireplace
(
'</th>'
,
'</td>'
,
$html
);
$html
=
str_ireplace
(
'<th/>'
,
'<td/>'
,
$html
);
//No reason not to be as permissive as browsers.
$dom
=
new
DOMDocument
(
'1.0'
,
'utf-8'
);
$dom
->
loadHTML
(
$html
);
$rows
=
$dom
->
getElementsByTagName
(
'tr'
);
foreach
(
$rows
as
$row
)
{
$values
=
[];
$rowCells
=
$row
->
getElementsByTagName
(
'td'
);
foreach
(
$rowCells
as
$cell
)
{
$values
[]
=
$stripHTML
?
$cell
->
nodeValue
:
get_innerHtml
(
$cell
);
}
$array
[]
=
$values
;
}
return
$array
;
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Aug 8, 03:05 (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3960595
Default Alt Text
core2.php (1 KB)
Attached To
Mode
rTOOLS Nasqueron Tools
Attached
Detach File
Event Timeline
Log In to Comment