To access Wordfast Anywhere, please sign in at https://www.wordfast.net
"; //echo "We apologize for the inconvenience.
"; // echo "
Other services are down for the moment. We will restore operation as soon as possible.
"; $wfSelf="?go=relicense_WF6"; $buyPage="?go=buy&renProd="; if (stristr($_SERVER['HTTP_HOST'],".com") OR strlen($buyPage)>0) { // THIS STUFF REMOVES THE BIG LEFT NAVIGATION BAR PUT BY DRUPAL echo ""; // END REMOVE THE BIG LEFT NAVIGATION BAR PUT BY DRUPAL $wfSelf="https://www.wordfast.com/myaccount"; // $buyPage="https://www.wordfast.com/Wordfast_Store"; $buyPage="https://www.wordfast.com/buy/?renProd="; echo ""; } $nbr="&nb"."sp;"; // GET THE CLIENT into a single-dimension array $cl[] $cl=myUnserialize(@$_POST["this_Client"]); // GET ALL INVOICES into a 2-dimension array $in[][] $in=myUnserialize(@$_POST["all_Invoices"]); $relicPRO5 = @$_POST["relicPRO5"]; // Request for a PRO 5,6,7 activation key $relicPRO3 = @$_POST["relicPRO3"]; // Request for a PRO3 license $relicWFC = @$_POST["relicWFC"]; // Request for a classic preregistered DOT $relicWFC5 = @$_POST["relicWFC5"]; // Request for an older WFC license number $relicWFS = @$_POST["relicWFS"]; // Request for a WFS license $updateprofile = @$_POST["updateprofile"]; // Request to update personal info $myAccLogin = @$_POST["myAccLogin"]; // Request to log in $lic_readonly = @$_POST["lic_readonly"]; // is 'Show Personal Info' ON ? $showPersonalInfo= @$_POST["showPersonalInfo"]; if (strlen(@$_POST["hidePersonalInfo"])>1) $showPersonalInfo=""; $theBrass=" STYLE='background-color: #EFECED; border: 1px solid #CCCCCC; padding: 0px; border-radius: 4px; width:100%; align:left;"; $hotLink=""; // VERIFY IF LOGIN IS DONE (LOGIN is OK if $cl[] has valid 'id', 'email' if (strlen($myAccLogin)>1 OR strlen($cl['email'])<1) { if (strlen($lic_install)<1) $lic_install = @$_POST["lic_install"]; if (strlen($lic_email)<1) $lic_email = @$_POST["lic_email"]; if (strlen($lic_email)>3 AND strlen($lic_install)>1) { $sql = "SELECT * FROM clients WHERE upper(lic_email)='".strtoupper($lic_email)."'"; $theArray=remDO("remSQL=", $sql); $cl=myUnserialize($theArray); //echo $cl['id']." - ".$cl['email']." - ".$cl['name']." - ".$cl['password']; if (strlen($cl['id'])<1 OR strlen($cl['email'])<1) { // LOGIN FAILED $loginFailMsg= "\r\n
We're sorry, the email address [".$lic_email."] is not found in our database."; $loginFailMsg.="\r\n
If the sign-in procedure fails, clear the cache in your browser or try using another browser or computer.
"; $loginFailMsg.="If none of the above works, ".$hotLink."contact us.\r\n
"; $cl['id']=""; } else { if (trim($cl['password'])!=trim($lic_install)) { // WRONG PASSWORD $loginFailMsg="\r\n
We're sorry, the password you used is invalid. "; $loginFailMsg.="
Please use our password recovery procedure.\r\n
"; $loginFailMsg.="
If nothing helps, please " . $hotLink."contact us.\r\n
"; $cl['id']=""; } } if (strlen($loginFailMsg)>1) echo $loginFailMsg; } } if (strlen($cl['email'])<1) { $cl['email']=@$_POST["lic_email"]; $cl['id']=@$_POST["lic_id"]; } // LOGIN FAILED: ask to log in (NORMALLY, HAPPENS ONLY FOR WORDFAST.COM) if (strlen($cl['id'])<2) { echo "
"; } // END LOGGING IN // START MY ACCOUNT // GET INVOICES FROM THE DATABASE IF THEY ARE NOT POSTed if ($in[0]['id']<1 AND $cl['id']>0) { $sql = "SELECT * FROM invoices WHERE in_id=" . $cl['id']." ORDER BY in_date"; $theReturn = remDO("remSQL=", $sql); $in=myUnserialize($theReturn); } echo $in['product']."
"; $inNbr=-1; // FIND THE CURRENTLY SELECTED INVOICE, TWO STEPS for ($i=0; $i<256; $i++) { $theInv = @$_POST["sel_InvoiceNb".$i]; if (strlen($theInv)>1) $inNbr=$i; } if ($inNbr<0) { $theReturn = @$_POST["sel_InvoiceNb"]; if ($theReturn>0) $inNbr=$theReturn-1; } // CALCULATE THE NUMBER OF INVOICES IN THE ARRAY $inTotal=0; $isProduct=false; $canUseWFA=false; $oneValidProduct=false; foreach ($in as $key => $row) { if (validateDate($in[$inTotal]['date'], 'Y-m-d')===false) $in[$inTotal]['date']= "invalid date!
contact hotline"; $in=processSelectedInvoice($in, $cl, $inTotal); if (strlen($lic_readonly)>1) $in[$inTotal]['amount']="---"; if (stristr("ANY", $in[$inTotal]['product']) AND $in[$inTotal]['DaysLeft']>0) $isProductANY=true; if (stristr(",CLA,STU,PRO,SER,ANY,", $in[$inTotal]['product'])) { if ($inTotal==$inNbr) $isProduct=true; $canUseWFA=true; if ($in[$inTotal]['DaysLeft']>0) $oneValidProduct=true; } $inTotal=$inTotal+1; } if (strlen($WfsVer)>0) { // treat parenthesis, remove spaces (specific to WFS version number) $WfsVer=str_replace("("," . ",$WfsVer); $WfsVer=str_replace(")","",$WfsVer); $WfsVer=str_replace(" ","",$WfsVer); // only keep numbers and full stops $WfsVer= preg_replace("/[^0-9,.]/", "", trim($WfsVer)); } if (strlen($relicWFC)>2 AND $cl['id']>0) { $sql=$cl['id']."zwza".$cl['name']."zwza".$cl['email']; remDO("remWFC=", $sql); sleep(1); } // UPDATE CLIENT DETAILS, IF USER CLICKED updateprofile $theAlert=""; $ch2MD5=md5("WFA-AA@2022$".$cl['email']); $theStatus="10"; if ($oneValidProduct===false) $theStatus="free"; if (strlen($updateprofile)>1 AND $cl['id']>0) { $newMail=trim(@$_POST["email_new"]); $mOk=validateEmail($newMail); if ($mOk===false) $theAlert="
Sorry, ".$newMail." is not a valid email address. Please try again."; if ($mOk===true AND strstr($cl['email'],"@") AND strtoupper($cl['email'])!=strtoupper($newMail)) { $sql = "SELECT * FROM clients WHERE UPPER(lic_email)='".strtoupper($newMail)."'"; $theArray=remDO("remSQL=", $sql); $theTest=myUnserialize($theArray); if (stristr($theTest['email'], $newMail) or stristr($theResult, "failed")) { $theAlert="
Error: An account under ".$newMail." already exists!
"; } else { $theLink="https://anywhere.wordfast.com/jsp/loginFromWF.jsp?email=".$cl['email']."&ch=".$ch2MD5."&newmail=".$newMail."&status=".$theStatus; // ANGULAR VERSION $theLink="https://anywhere.wordfast.com/wfafront/wfa/".$cl['email']."/".$ch2MD5."/".$newMail."/".$theStatus; // EXCEPTION HERE if (stristr($cl['email'],"anywhere") OR stristr($cl['email'],"dlopez") OR stristr($cl['email'],"transperfect") OR stristr($cl['email'],"champollion")) simpleMail($cl['email'],"Wordfast Account changed", "The link for email update was:
".$theLink); //} else { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $theLink); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,60); curl_setopt($ch, CURLOPT_TIMEOUT, 60); $theResult= curl_exec($ch); curl_close($ch); echo "
Please sign out (log out) then sign in again with your new email address (".$newMail.") to complete this change.
"; $priva="Note: Wordfast LLC enforces a scrupulous, non-intrusive privacy policy. We do not check whether ".$newMail." actually exists.
"; $priva.="It is your right to use a non-existent email address. If that is the case, news and/or notifications would not reach you. "; $priva.="If you want to receive those, please subscribe here: wordfast.com/subscribe."; echo $priva; // FORCE A HEADER WITH CC TO simpleMail() $body= "From: Wordfast LLC \n"; $body.= "Reply-to: Wordfast LLC \n"; $body.= "Cc: ".$cl['email']."\n"; $body.= "Bcc: sales@wordfast.com,david@wordfast.com\n"; $body.= "X-Mailer: PHP 7.3\nX-Priority: 1\n//HEADER// "; $body ="
Dear ".$cl['name']." (".$newMail."),
We confirm an email change at your Wordfast account from ".$cl['email']. " to ".$newMail.".
"; $body.="If you did not perform this change, please contact us by replying to this email.
"; $body.="Kind regards,
The Wordfast Team.
"; //$body.= "
".$priva."".$theLink."
"; $body.= "
".$priva."
"; simpleMail($newMail,"Wordfast Account changed", $body); $body="updated"; } } if (strlen($theAlert)<2 AND strpos($cl['email'],"@")>2) { $cl['email']=@$_POST["email_new"]; $cl['password']=@$_POST["password_new"]; $cl['testquestion']= @$_POST["testquestion_new"]; $cl['testanswer']= @$_POST["testanswer_new"]; $cl['testquestion']=str_replace("'",chr(96),$cl['testquestion']); $cl['testanswer']=str_replace("'",chr(96),$cl['testanswer']); if (strpos($cl['email'],"@")>2 AND strlen($cl['password'])>1) { $sql = "UPDATE clients SET lic_email='".$cl['email']."', lic_install='".$cl['password']; $sql.="', lic_testquestion='".$cl['testquestion']."', lic_testanswer='".$cl['testanswer']."' WHERE lic_id=".$cl['id']; remDO("remSQL=", $sql); sleep(1); $sql = "SELECT * FROM clients WHERE upper(lic_email)='".strtoupper($cl['email'])."'"; $theArray=remDO("remSQL=", $sql); $cl=myUnserialize($theArray); } else { echo "Invalid values: Email=".$theEmail. " and/or password=".$thePwd."!"; } if (strlen($theLink)>2) { $lic_email=""; $cl['email']=""; $lic_id=0; } } // END EXCEPTION // } } if (strlen($hiddenLicId)<1 and strlen($cl['email'])>0) $hiddenLicId=""; $hiddenLicId.=""; $hiddenLicId.=""; $hiddenLicId.=""; $hiddenLicId.=""; $i=$inNbr+1; $hiddenSelected=""; if (strlen($cl['name'])<2 AND strlen($cl['email'])>3) $cl['name']="[".$cl['email']."]"; if ($cl['id']>0) { // DISPLAY THE "REVIEW YOUR PERSONAL DATA" SECTION AND HOTLINE LINK echo "
"; } // END DISPLAY THE REVIEW YOUR PERSONAL DATA SECTION AND HOTLINE LINK // HAVE WE WARNED AND GIVEN A BONA FIDE FREE RELICENSE ALREADY? // $IsLastLicense=(date("Y-m-d") > $in[$inNbr]['Expiry']); // if ($IsLastLicense===true AND $relicense=="" AND stristr($cl['notes'],"{LicExpired}")) $IsLastLicense=false; // if ($IsLastLicense===true) { // $sql = "UPDATE clients SET lic_notes='".$cl['notes']."{LicExpired}' WHERE lic_id=" . $cl['id']; // remDO("remSQL=", $sql); // } // // EXECUTE A PRO3 LICENSE REQUEST // if (strlen($relicPRO3)>0) { $pro3Install = @$_POST["pro3Install"]; $pro3License = @$_POST["pro3License"]; $pro3Install= preg_replace("/[^0-9,.]/", "", trim($pro3Install)); if (strlen($pro3Install)!=8) $Problem=$oneProb; if (strlen($Problem)<1) { $dateIssued = date("m/d/Y",mktime(0, 0, 0, date("m"), date("d")-1, date("Y"))); $bang=explode("-",$in[$inNbr]['Expiry']); //$TimeStmpThis=mktime(0,0,0,ltrim($bang[1],"0"),ltrim($bang[2],"0"),$bang[0]); $invalidAfter=date("m/d/Y",mktime(0,0,0,ltrim($bang[1],"0"),ltrim($bang[2],"0"),$bang[0])); $lc_name=removeDangerousChars($cl['name']); $lc_country=removeDangerousChars($cl['country']); $lc_city=removeDangerousChars($cl['city']); if (strlen($lc_city)<1) $lc_city="unknown"; if (strlen($lc_country)<1) $lc_country="unknown"; if (strlen($lc_name)<1) $lc_name="unknown"; $commandLine.= chr(34)."CN=" . $lc_name.", OU=N/A, O=N/A, L=" . $lc_city.", ST=N/A, C=" . $lc_country.chr(34)." "; $commandLine.= chr(34)."CN=Wordfast LLC, OU=Sales Dept, O=Marketing, L=Wilmington, ST=Delaware, C=USA".chr(34)." "; $commandLine.= chr(34).$dateIssued.chr(34)." ".chr(34); $commandLine.= $dateIssued .chr(34)." ".chr(34).$invalidAfter.chr(34)." ".chr(34)."Wordfast".chr(34)." ".chr(34); $newinst=MakeLicense($pro3Install); $newcount = $in[$inNbr]['counter']+1; $commandLine.= chr(34)." ".chr(34).$newinst."064".chr(34); $commandLine.="zwza" . $pro3Install."zwza".$cl['email']."zwza".$lc_name; $pro3Return = remDO("remPRO3=", $commandLine); $pro3Install=""; $pro3License=""; } } // // EXECUTE AN OLD CLASSIC LICENSE REQUEST // if ($relicWFC5) { $WfcInstall=@$_POST["WfcInstall"]; $WfcInstall= preg_replace("/[^0-9,.]/", "", trim($WfcInstall)); if (strlen($WfcInstall)!=8) $Problem=$oneProb; if (strlen($Problem)<1) { $newcount = $in[$inNbr]['counter']+1; $Somme=MakeLicense($WfcInstall); $classReturn="The new license number is $Somme "; $WfcInstall=""; if ($newcount>0) $sql = "UPDATE invoices SET in_counter=" . $newcount." WHERE in_invoiceid=" . $in[$inNbr]['invoiceid']; if (strlen($sql)>2) remDO("remSQL", $sql); } } // // EXECUTE A WF SERVER LICENSE REQUEST // if ($relicWFS) { $WfsIns=@$_POST["WfsIns"]; $WfsVer=@$_POST["WfsVer"]; if (strlen($WfsIns)>8 AND strlen($WfsVer)>6) { if ($IsLastLicense===true) $in[$inNbr]['DaysLeft']=45; $theParam=$in[$inNbr]['qty']."zwza" . $in[$inNbr]['DaysLeft']."zwza".$WfsVer."zwza" . $WfsIns."zwza" . $cl['email']."zwza" . $cl['name']."zwza".$in[$inNbr]['code']."zwza" ; $WfsLicense = remDO("remWFS=", $theParam); } } // = = = = = = DISPLAY ALL INVOICES = = = = = = = If ($inTotal>0) { echo "\r\n\r\n "; echo "\r\n \r\n \r\n "; //echo "\r\n \r\n \r\n "; echo "\r\n \r\n \r\n "; echo "\r\n \r\n "; echo "\r\n "; echo "\r\n \r\n "; $isProduct=false; for ($i=0; $i<$inTotal; $i++) { $thisBuyPage=$buyPage.$in[$i]['product']."&WFAemail=".$cl['email']; ShowOneInvoice($i, $in, $inNbr, $hiddenLicId, $wfSelf, $thisBuyPage); if (strlen($lic_readonly)>1) $in[$i]['amount']="---"; if (stristr("ANY", $in[$i]['product']) AND $in[$i]['DaysLeft']>0) $isProductANY=true; if (stristr(",CLA,STU,PRO,SER,ANY,", $in[$i]['product'])) { if ($i==$inNbr) $isProduct=true; } if ($i>256) break; } echo "\r\n
\r\n | "; echo "Date\r\n | Qty\r\n | Type\r\n | Product\r\n | Product\r\n | ".chr(36).$nbr.$nbr."\r\n | Status\r\n | Days\r\n |
"; } // NO LICENSE IF SOME CONDITIONS ARE NOT MET if ($in[$inNbr]['invoiceid']<1) $isProduct=false; if ($in[$inNbr]['DaysLeft']<1) $isProduct=false; if ($in[$inNbr]['counter']>$in[$inNbr]['Max']+1) $isProduct=false; if ($in[$inNbr]['counter']==$in[$inNbr]['Max']+1 AND $IsLastLicense===false) $isProduct=false; // SHOW THE VARIOUS RELICENSING FACILITIES IF AMOUNT<>0, DAYSLEFT>0, EXPIRED=false if ($isProduct===true) { echo "
"; } // = = = = END OF WFP4 DEMO OR FULL = = = = if ($cl['id']>0 OR strlen($Problem)>10) { echo "\r\n\r\n \r\n \r\n \r\n
Wordfast licenses are subject to the "; echo "Wordfast End User License Agreement (EULA). "; echo "\r\n |
"; } function MakeLicense($ninst) { $P=9; $K=7; For ($I=0; $I < 8 ; $I++){ $L = Ord(Substr($ninst,$I,1)) + $K - $I -1; $J =($L % 10) + 1; if ($J==0) $J = 1; $K = $J + 5; $A = $L * $J; $B = $J * 2; $L = intval($A / $B); $A = $P * $L; $P = intval($A / $J); if($L < 1) $L = 4; if(900000 <$P) $P = intval($P / $L); } $Somme=substr($P."12345678",0,8); $Somme=substr($Somme,4).substr($Somme,0,4); $I = 8 - intval(substr($ninst,0,1)); if ($I<0) $I=$I+9; $Somme = substr_replace($Somme,$I,0,1); $I = 5 - intval(substr($ninst,5,1)); if ($I<0) $I=$I+9; $Somme = substr_replace($Somme,$I,5,1); $I = 9 - intval(substr($Somme,1,1)); if ($I<0) $I=$I+9; $Somme = substr_replace($Somme,$I,3,1); $I = 7 - intval(substr($Somme,2,1)); if ($I<0) $I=$I+9; $Somme = substr_replace($Somme,$I,7,1); $I = 5 - intval(substr($Somme,4,1)); if ($I<0) $I=$I+9; $Somme = substr_replace($Somme,$I,6,1); return $Somme; } function simpleMail($toWhom, $subject, $body) { $tC=chr(89).chr(67)."-CE".chr(48); $i=stripos($body,"//HEADER//"); if ($i>0) { $header=substr($body,0,$i)."\n"; $body=substr($body,$i+11); } else { $header = "From: Wordfast LLC \n"; $header.= "Reply-to: Wordfast LLC \n"; $header.= "Bcc: sales@wordfast.com,david@wordfast.com\n"; $header.= "X-Mailer: PHP 7.3\nX-Priority: 1\n"; } // spam detectors penalize an HTML email that does not have tags. So, make sure! // also penalize an HTML email declared as text/plain, and vice-versa if (stristr($body, $tC)) $header=str_replace("sales@", "yves@", $header); if (stristr($body,""; if (stristr($body,""; $header.= "Content-Type: text/html; charset=UTF-8\n"; } else { // Create proper line feeds if not HTML //$body=str_replace("\r","",$body); //$body=str_replace("\n",chr(13).chr(10)."
",$body); $header.= "Content-Type: text/plain; charset=UTF-8\n"; } return mail($toWhom, $subject, $body, $header); } function ShowOneInvoice($iLine, $in, $inNbr, $hiddenLicId, $wfSelf, $buyPage) { $toolStartCaption="
"; $nbr="&nb"."sp;"; $alreadyRenewed=false; $isLic=true; if (strlen($in[$iLine]['type'])<2 AND strlen($in[$iLine]['product'])<2) $isLic=false; if (strlen($in[$iLine]['date'])<8 OR $isLic===false) return ""; if (strstr("-" . $in[$iLine]['code'],"R€N")) $alreadyRenewed=true; $iconInfo="".chr(38).chr(35)."128712;"; if ($iLine==$inNbr) { echo "\r\n "; $theColorTD=""; } else { if (($iLine % 2)==0) { echo "\r\n "; } else { echo "\r\n "; } $theColorTD=""; } $captions="--,LICense,RENewal,UPGrade,TRAining,HOTline,STUdio,CLAssic,PRO,ANYwhere,SERver,OTHer,VARious,CNFerence,TRAining,"; echo $theColorTD."
\r\n "; for ($j=0; $j<5; $j++) { if ($j==2) $j=3; $theKey=trim(substr(" date qty typeproductamount ",$j*7,7)); if (strlen($in[$iLine][$theKey])<1) $in[$iLine][$theKey]=" "; $cellValue=strtolower($in[$iLine][$theKey]); if ($j==3) { $k=0; $i=stripos($captions, $cellValue); if ($i>0) $k=strpos($captions, ",",$i+3); if ($i>0 AND $k>$i) { $theProduct=substr($captions, $i,1).strtolower(substr($captions, $i+1,$k-$i-1)); $theType=""; if ($in[$iLine]['type']=="LIC") $theType= "Wordfast ".$theProduct." (new license)"; if ($in[$iLine]['type']=="REN") $theType="Wordfast ". $theProduct." (license renewal)"; if (strlen($theType)>0) $cellValue=$toolStartCaption.$cellValue.$toolBefore.$theType.$toolAfter; } } else { $i=stripos($captions,",".$cellValue); if ($i>0) $k=strpos($captions, ",",$i+3); if ($i>0 AND $k>$i) $cellValue=strtolower(substr($captions, $i+1,$k-$i-1)); } if ($j<>4) { echo "".$theColorTD.$cellValue; } else { $isFuture=false; if ($in[$iLine]['date']>date("Y-m-d")) $isFuture=true; echo str_replace("$theExpiryMinusOne AND $isFuture===false) { if (stristr($in[$iLine]['product'],"ANY")) { $thePopup.= "). If you buy credit, it will start running after that date. "; } else { $thePopup.= "). If you renew, we apply the most favorable date for you: "; $thePopup.= "expiration date if you renew early; or payment date if you renew after expiry."; } $renew="
"; if (stristr($in[$iLine]['product'],"SER")) { $renew="
"; } } if ($in[$iLine]['DaysLeft']==0) { // EXPIRED if ($alreadyRenewed===false){ $doPop=$toolStartCaption." expired".$toolBefore; $doPop.="This ".$theProd." is after expiration date".$toolAfter; echo "".$theColorTD.$doPop." ".$theColorTD; } else { $doPop=$toolStartCaption." expired".$toolBefore; $doPop.="You have previously renewed this ".$theProd." and cannot renew it again.".$toolAfter;; echo "".$theColorTD.$doPop."".$theColorTD; } } else { if ($in[$iLine]['counter'] > $in[$iLine]['Max']) { $doPop=$toolStartCaption." overdrawn".$toolBefore; $doPop.="This product was activated ".$in[$iLine]['counter']." times. "; $doPop.="Use the hotline to let us know why so many re-installations were made, "; $doPop.="we will allow more installations if the EULA is respected. ".$toolAfter; $colLink="darkblue"; if ($inNbr==$iLine) $colLink="yellow"; echo "".$theColorTD.$doPop. " EULA"; echo "".$theColorTD; } else { $doPop=$toolStartCaption." valid".$toolBefore; $statusP=" has not expired"; if ($isFuture===true) $statusP=" has not started yet"; $doPop.="This ".$theProd.$statusP.$toolAfter; echo "".$theColorTD.$doPop."".$theColorTD; if ($in[$iLine]['DaysLeft']<7) { echo ""; $doPop=$toolStartCaption."".$nbr.$in[$iLine]['DaysLeft'].$nbr."".$toolBefore; $doPop.="Your ".$theProd." ends soon."; $doPop.=" Remember to click 'renew' to buy more credit!"; echo $doPop.$toolAfter; } else { if ($isFuture) { echo "yet to start"; } else { echo $in[$iLine]['DaysLeft']; } } } } echo $renew."\r\n "; } } echo "\r\n "; } function processSelectedInvoice($in, $cl, $inNbr) { if (strlen($in[$inNbr]['amount'])<1 OR strval($in[$inNbr]['amount'])<1) $in[$inNbr]['amount']="0"; if (strlen($in[$inNbr]['code'])<1) $in[$inNbr]['code']=" "; $in[$inNbr]['noOECD']=""; $OECDs =",us,ca,ad,at,be,dk,fi,fr,de,gr,is,it,li,lu,mc,pt,es,nl,no,se,ch,uk,"; $OECDs .="au,bn,hk,jp,ko,nz,sg," . "bh,il,kw,qa,sa,ae,"; if (stristr($OECDs,",".$cl['country'].",")===false) $in[$inNbr]['noOECD']="noOECD"; $theExpiry=trim($in[$inNbr]['date']); // date $TimeStmpToday=strtotime("today"); $isHardExpiry=false; $theCode="xx".$in[$inNbr]['code']; $i=strpos($theCode,"ENDS:"); if ($i>0) $check=substr($theCode,$i+9,1); if ($check!="-") $i=0; if ($i>0) $check=substr($theCode,$i+12,1); if ($check!="-") $i=0; if ($i>0) { $theExpiry=substr($theCode,$i+5,10); $i=strpos($theExpiry,"_"); if ($i>0) $theExpiry=substr($theExpiry,0,$i+1); $theExpiry=trim($theExpiry); // Get the UE date for the hard-coded date $bang=explode("-", $theExpiry); $TimeStmpThis=mktime(0,0,0,ltrim($bang[1],"0"),ltrim($bang[2],"0"),$bang[0]); $theExpiry=date('Y-m-d', $TimeStmpThis); $isHardExpiry=true; } if ($isHardExpiry===false) { $bang=explode("-", $theExpiry); if (stristr($in[$inNbr]['product'],"ANY")) { $theExpiry = addMonths($in[$inNbr]['date'], $in[$inNbr]['qty']); $bang=explode("-", $theExpiry); $TimeStmpThis=mktime(0,0,0,ltrim($bang[1],"0"),ltrim($bang[2],"0"),$bang[0]); } else { // GET THE UE date for 3 years ahead $TimeStmpThis=mktime(0,0,0,ltrim($bang[1],"0"),ltrim($bang[2],"0"),$bang[0]+3); $TheYear=substr($theExpiry,0,4); $TheYear=$TheYear+3; $theExpiry=$TheYear.substr($theExpiry,4,12); $in[$inNbr]['ExpMinus']=false; } } $in[$inNbr]['Max']=$in[$inNbr]['qty']*4; if ($in[$inNbr]['Max']<4) $in[$inNbr]['Max']=4; if (stripos(",ANY,SER,", $in[$inNbr]['product']) > 0) $in[$inNbr]['Max']=99999; if ($in[$inNbr]['counter'] >= $in[$inNbr]['Max']) $in[$inNbr]['ExpMinus']=true; if ($TimeStmpToday > $TimeStmpThis+1) { $in[$inNbr]['DaysLeft']=0; } else { $in[$inNbr]['DaysLeft']=ceil(($TimeStmpThis-time())/86400)+1; } $in[$inNbr]['Expiry']=$theExpiry; return $in; } function addMonths($date, $monthsToAdd) { $date = new DateTime($date); $tmpDate = clone $date; $tmpDate->modify('first day of +'.(int) $monthsToAdd.' month'); if($date->format('j') > $tmpDate->format('t')) { $daysToAdd = $tmpDate->format('t') - 1; } else { $daysToAdd = $date->format('j') - 1; } $tmpDate->modify('+ '. $daysToAdd .' days'); return $tmpDate->format('Y-m-d'); } function validateDate($date, $format = 'Y-m-d'){ $d = DateTime::createFromFormat($format, $date); return $d && $d->format($format) === $date; } function removeDangerousChars($string) { $string=str_replace(",","",$string); $string=str_replace("'","",$string); $string=str_replace('"','',$string); $string=str_replace("?","",$string); $string=str_replace("&","and",$string); $string=str_replace("+","plus",$string); return $string; } function remDO($whatJob, $theSqlQuer) { $dbServer="127.0.0.1/remdo2.php?"; if (stristr($_SERVER['HTTP_HOST'],".com")) $dbServer="https://www.wordfast.net/remdo2.php?"; $dbServer="https://www.wordfast.net/remdo2.php?"; $ch = curl_init(); $sqlQuer=$dbServer.$whatJob.urlencode($theSqlQuer)."&rnd=".Rand(1000,9999); curl_setopt($ch, CURLOPT_URL, $sqlQuer); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); curl_setopt($ch, CURLOPT_TIMEOUT, 15); $theResult= curl_exec($ch); if (stristr($theResult,"lic_email") OR stristr($theResult,"in_date")) { $srch=":".chr(34)."lic_"; if (stristr($theSqlQuer," invoices ")) $srch=":".chr(34)."in_"; $theResult=str_replace("11:".chr(34)."lic_install","8:".chr(34)."password",$theResult); for ($i=5; $i<19; $i++) { $k=$i-strlen($srch)+2; if (strpos($theResult,$i.$srch)>0) $theResult=str_replace($i.$srch,$k.":".chr(34),$theResult); } } return $theResult; } function myUnserialize($theArray) { if (strpos($theArray,"!!")>0) $theArray= str_replace("!!'","'",$theArray); if (strpos($theArray,chr(34)."amount".chr(34))>0) { $in=array( 'id'=>0,'date'=>'','qty'=>'','product'=>'', 'type'=>'','amount'=>'','code'=>'','invoiceid'=>0, 'note'=>'','counter'=>'','mailto'=>'','pricing'=>'', 'Max' => '','DaysLeft' => '','Expiry' => '','ExpiryMinus' => '' ); $j=0; while ($j<99) { $in[$j]['id']=unserializeItem($theArray,"id"); $in[$j]['date']=unserializeItem($theArray,"date"); $in[$j]['qty']=unserializeItem($theArray,"qty"); $in[$j]['product']=unserializeItem($theArray,"product"); $in[$j]['amount']=unserializeItem($theArray,"amount"); $in[$j]['type']=unserializeItem($theArray,"type"); $in[$j]['counter']=unserializeItem($theArray,"counter"); $in[$j]['code']=unserializeItem($theArray,"code"); $in[$j]['note']=unserializeItem($theArray,"note"); $in[$j]['invoiceid']=unserializeItem($theArray,"invoiceid"); $theArray=substr($theArray, strpos($theArray,chr(34)."code".chr(34))+4); $j=$j+1; } return $in; } if (strpos($theArray,chr(34)."password".chr(34))>0) { $cl=array( 'id'=>0,'email'=>'','name'=>'','address'=>'','password'=>'','country'=>'','city'=>'','notes'=>'','trainer'=>'', 'picture'=>'','code'=>'','history'=>'','howlearn'=>'','testquestion'=>'','testanswer'=>'','trainerDetails'=>'' ); $cl['id']=unserializeItem($theArray,"id"); $cl['email']=unserializeItem($theArray,"email"); $cl['password']=unserializeItem($theArray,"password"); $cl['name']=unserializeItem($theArray,"name"); $cl['country']=unserializeItem($theArray,"country"); $cl['testquestion']=unserializeItem($theArray,"testquestion"); $cl['testanswer']=unserializeItem($theArray,"testanswer"); $cl['notes']=unserializeItem($theArray,"notes"); return $cl; } } function unserializeItem($theArray,$oneKey) { $i=strpos($theArray,chr(34).$oneKey.chr(34)); if ($i>0) { $j=strpos($theArray,chr(34),$i+4+strlen($oneKey)); if ($j>0) { $k=strpos($theArray,chr(34),$j+2); if ($k>$j) return substr($theArray, $j+1,$k-$j-1); } } } function validateEmail($email) { // relaxed email syntax checker if (strpbrk($email, "!#$%^&*(),?:{}|<>[]".chr(34))!=false OR strpos($email, "@")<1 OR strstr($email, "@")===false) return false; return true; } ?>