http://www.wetwork.org.uk/sgriptiau_wetwork/mailto.txt
Dyma'r cod:
- Cod: Dewis popeth
<?php
// CYMERWYD Y JAVASCRIPT ODDI WRTH SOLMETRA:
// http://www.solmetra.com/scripts/mailto/index.html
// Addaswyd i pHp gan xxxx xxxxxx, Wetwork, 2008
//=============== Defnydd =================================
// Rhowch y cod isod yn lle dolen e-bost normal, e.e.
//<p>Cysylltwch gan e-bost: <?php cuddiwr_e_bost("algernonquint@wetwork.org.uk","e: Algernon Quint");?> neu gan ...</p>
// Nawr bydd angen gosod y ffwythiant isod naill ai (i) mewn i ffeil "include" neu (ii) ei osod i ben y dudalen cyn y datganiad DTD (gweler y testun ar y gwaelod am fanylion ar sut i wneud hyn).
function cuddiwr_e_bost($ebost,$testun){
//(cod Wetwork)
$eb ="";
$i=0;
while($i < strlen($ebost)){
$c = substr($ebost,$i,1);
if($eb ==""){
$eb = (ord($c) + $i);
}else{
$eb = $eb . "," . (ord($c) + $i);
}
$i = $i+1;
}
$tst ="";
$i=0;
while($i < strlen($testun)){
$c = substr($testun,$i,1);
if($tst ==""){
$tst = (ord($c) + $i);
}else{
$tst= $tst . "," . (ord($c) + $i);
}
$i = $i+1;
}
//(cod Solmetra)
$stwb = "<script type=\"text/javascript\">
var spaf_eml = [{$eb}];
var spaf_txt = [{$tst}];
document.write('<a href=\"mailto:');
cnt = spaf_eml.length; for (i=0; i<cnt; i++) { document.write(String.fromCharCode(spaf_eml[i]-i)); }
document.write('\">');
cnt = spaf_txt.length; for (i=0; i<cnt; i++) { document.write(String.fromCharCode(spaf_txt[i]-i)); }
document.write('</a>');
</script>
<noscript>Galluogwch JavaScript er mwyn gweld y cyfeiriad e-bost!</noscript>";
echo $stwb;
}
//(i) I'w osod mewn ffeil "include", gallwch wneud y canlynol:
// 1. Creu ffolder a'i enwi'n "includes" neu beth bynnag arall.
// 2. Creu ffeil newydd a'i alw'n ebost.inc.php.
// 3. Copio'r ffwythiant i'r ffeil gan gofio ei gwmpasu gan dagiau agor a chau php.
// 4. Tu fewn i'ch tudalen gwe, reit ar y top (cyn y DTD), rhowch y datganiad:
// <?php
// include_once("/includes/ebost.inc.php");
// ?>
//
//
//(ii) Fel arall, gallwch gopio a gludo'r ffwythiant i'r top (gan gofio gosod tagiau agor a chau php o'i gwmpas)
?>