Как сделать чтоб ссылка <?php linklokurl('text.txt',10,1);?> была после echo и работала?Как такое можно реализовать?Помогите пожалуйста. Код (Text): <?php include"linklokurl.php"; ?> <img src="1.jpg"><br> <? if (isset($_SERVER["PHP_AUTH_USER"])) { echo "Показывает текст зарегистрированному пользователю"; } else { echo "<a href=<?php linklokurl('text.txt',10,1);?>>скачать</a>"; } ?>
PHP: <?php include 'linklokurl.php'; ?> <img src="1.jpg"><br> <?php if (isset($_SERVER["PHP_AUTH_USER"])) { echo 'Показывает текст зарегистрированному пользователю'; } else { echo '<a href="' . linklokurl('text.txt', 10, 1) . '">скачать</a>'; } ?>
Сейчас он не считает за ссылку <a href="' . linklokurl('text.txt', 10, 1) . '"> получается так: /index.php/text.txt?linklokauth=text.txt%2C1152706329%2C1%2C82cd986c57deb4c2710c7150b15bbeeb и только потом ссылка скачать ??
Код (Text): <?php $LinklokKey="secretkeyword"; $LinklokLocation="http://www.test1.ru/down/"; $ManualPassword="letmein"; $ErrorTemplate=""; $LinklokLog=""; // The following variables must be set if you wish to use the email links feature of Linklok $YourCompany="CC"; $YourEmail="me@somehost.ru"; $EmailTemplate=""; $HTMLEmail="Y"; // List of email addresses / services to block if required. You can add delete from this list $FreeEmail[]="yahoo."; $FreeEmail[]="hotmail."; $FreeEmail[]="altavista."; $FreeEmail[]="prontomail."; $FreeEmail[]="talk21."; $FreeEmail[]="address."; $FreeEmail[]="mail."; $FreeEmail[]="@australia."; $FreeEmail[]="boardermail."; $FreeEmail[]="@canada."; $FreeEmail[]="bolt."; $FreeEmail[]="dbzmail."; $FreeEmail[]="etoast."; $FreeEmail[]="fastmail."; $FreeEmail[]="freemail."; $FreeEmail[]="icqmail."; $FreeEmail[]="jaydemail."; $FreeEmail[]="keromail."; $FreeEmail[]="linuxmail."; $FreeEmail[]="lycos."; $FreeEmail[]="myrealbox."; $FreeEmail[]="netscape."; $FreeEmail[]="popmail."; $FreeEmail[]="themail."; $FreeEmail[]="toast."; $FreeEmail[]="webcity."; /////////////////////////////////////////////////////////////////////////////////////////////////////// if (!empty($HTTP_GET_VARS)) while(list($name, $value) = each($HTTP_GET_VARS)) $$name = $value; if (!empty($HTTP_POST_VARS)) while(list($name, $value) = each($HTTP_POST_VARS)) $$name = $value; if ((isset($HTTP_GET_VARS['LinklokKey'])) || (isset($HTTP_POST_VARS['LinklokKey']))) { ShowMessage($ErrorTemplate,"Access denied"); exit; } if ((isset($HTTP_GET_VARS['ManualPassword'])) || (isset($HTTP_POST_VARS['ManualPassword']))) { ShowMessage($ErrorTemplate,"Access denied"); exit; } if (isset($HTTP_GET_VARS['linklokauth'])) $linklokauth=$HTTP_GET_VARS['linklokauth']; if (isset($HTTP_POST_VARS['linklokauth'])) $linklokauth=$HTTP_POST_VARS['linklokauth']; if (isset($HTTP_GET_VARS['linklokform'])) $linklokform=$HTTP_GET_VARS['linklokform']; if (isset($HTTP_POST_VARS['linklokform'])) $linklokform=$HTTP_POST_VARS['linklokform']; $ipaddr=$HTTP_SERVER_VARS['REMOTE_ADDR']; $thispage=$HTTP_SERVER_VARS['PHP_SELF']; $thisurl="http://".$HTTP_SERVER_VARS['HTTP_HOST'].$thispage; // If ?orderform them request password if ((isset($manualentry)) || (isset($MANUALENTRY))) { print "<html><head><title>Linklok URL Manual Entry Form</title></head><body>\n"; print "<script language=\"JavaScript\">\n"; print "<!-- JavaScript\n"; print "function validateform(form)\n"; print "{\n"; print " if (form.password.value==\"\")\n"; print " {\n"; print " alert(\"Please enter the password\")\n"; print " form.password.focus()\n"; print " return\n"; print " }\n"; print " form.submit();\n"; print "}\n"; print "// - JavaScript - -->\n"; print "</script>\n"; print "<form name=\"form1\" method=\"post\" action=\"$thisurl\">\n"; print "<p align=\"left\"><font face=\"Arial\" color=\"#333399\"><span style=\"font-size:16pt;\"><b>Linklok Manual Entry Form</b></span></font></p>\n"; print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"10\" bgcolor=\"#FFFFCC\">\n"; print "<tr><td><p><font face=\"Arial\" size=\"2\">Password</font></p></td>\n"; print "<td><p><input type=\"password\" name=\"password\" maxlength=\"50\" size=\"30\"></p></td></tr><tr><td><p> </p></td>\n"; print "<td align=\"right\"><p><input type=\"button\" name=\"button1\" value=\"Login\" onclick=\"validateform(this.form);\"></p></td>"; print "</tr></table></form></body></html>\n"; exit; } if (($ManualPassword!="") && (isset($password)) && ($ManualPassword!=$password)) { ShowMessage($ErrorTemplate,"Incorrect password."); exit; } if ($linklokauth!="") { // Request to access file linklokgetfile($linklokauth); } if ($linklokform!="") { // Request to send email with links linklokemaillinks($HTTP_GET_VARS,$HTTP_POST_VARS,$FreeEmail); } // If password entered and correct then display manual order form if (($ManualPassword!="") && ($ManualPassword==$password)) { print "<html><head><title>Linklok URL Manual Entry Form</title></head><body>\n"; print "<script language=\"JavaScript\">\n"; print "<!-- JavaScript\n"; print "function validateform(form)\n"; print "{\n"; print " if (form.f0.value==\"\")\n"; print " {\n"; print " alert(\"Please select at least one item\")\n"; print " form.f0.focus()\n"; print " return\n"; print " }\n"; print " if (ValidateEmail(form.email.value)==false)\n"; print " {\n"; print " alert(\"Please enter a valid email address\")\n"; print " form.email.focus()\n"; print " return\n"; print " }\n"; print " form.submit();\n"; print "}\n"; print "\n"; print "function ValidateEmail(str)\n"; print "{\n"; print " // are regular expressions supported?\n"; print " var supported = 0;\n"; print " if (window.RegExp) {\n"; print " var tempStr = \"a\";\n"; print " var tempReg = new RegExp(tempStr);\n"; print " if (tempReg.test(tempStr)) supported = 1;\n"; print " }\n"; print " if (!supported)\n"; print " return (str.indexOf(\".\") > 2) && (str.indexOf(\"@\") > 0);\n"; print " var r1 = new RegExp(\"(@.*@)|(\\\.\\\.)|(@\\\.)|(^\\\.)\");\n"; print " var r2 = new RegExp(\"^.+\\\@(\\\[?)[a-zA-Z0-9\\\-\\\.]+\\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\\]?)$\");\n"; print " return (!r1.test(str) && r2.test(str));\n"; print "}\n"; print "// - JavaScript - -->\n"; print "</script>\n"; print "<form name=\"form1\" method=\"post\" action=\"$thisurl\">\n"; print "<input type=\"hidden\" name=\"password\" value=\"$password\">\n"; print "<input name=\"m\" type=\"hidden\" value=\"0\">\n"; print "<input name=\"a\" type=\"hidden\" value=\"$password\">\n"; print "<input name=\"g\" type=\"hidden\" value=\"\">\n"; print "<input name=\"linklokform\" type=\"hidden\" value=\"1\">\n"; print "<p align=\"left\"><font face=\"Arial\" color=\"#333399\"><span style=\"font-size:16pt;\"><b>Linklok Manual Entry Form</b></span></font></p>\n"; print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"10\" bgcolor=\"#FFFFCC\">\n"; for ($i=0;$i<=9;$i++) { print "<tr>\n"; print "<td><p><font face=\"Arial\" size=\"2\">Item $i</font></p></td>\n"; $fnum="f".$i; if ($$fnum!="") print "<td><p><input name=\"f$i\" type=\"text\" value=\"".$$fnum."\"></p></td>\n"; else print "<td><p><input name=\"f$i\" type=\"text\" value=\"\"></p></td>\n"; print "</tr>\n"; } print "<tr><td><p><font face=\"Arial\" size=\"2\">Expiry Time</font></p></td>\n"; print "<td><p><select name=\"x\" size=\"1\">\n"; if ($x=="10") print "<option selected value=\"10\">10 minutes</option>\n"; else print "<option value=\"10\">10 minutes</option>\n"; if ($x=="60") print "<option selected value=\"60\">1 Hour</option>\n"; else print "<option value=\"60\">1 Hour</option>\n"; if ($x=="180") print "<option selected value=\"180\">3 Hours</option>\n"; else print "<option value=\"180\">3 Hours</option>\n"; if (($x=="1440") || (!isset($x))) print "<option selected value=\"1440\">24 Hours</option>\n"; else print "<option value=\"1440\">24 Hours</option>\n"; if ($x=="43200") print "<option selected value=\"43200\">30 Days</option>\n"; else print "<option value=\"43200\">30 Days</option>\n"; if ($x=="525600") print "<option selected value=\"525600\">1 Year</option>\n"; else print "<option value=\"525600\">1 Year</option>\n"; if ($x=="0") print "<option selected value=\"0\">No Expiry</option>\n"; else print "<option value=\"0\">No Expiry</option>\n"; print "</select></p></td></tr><tr><td><p><font face=\"Arial\" size=\"2\">Email address</font></p></td><td><p>\n"; print "<font face=\"Arial\"><span style=\"font-size:10pt;\"><input type=\"text\" name=\"email\" size=\"30\"></span></font></p></td></tr>\n"; print "<tr><td><p><font face=\"Arial\"><span style=\"font-size:10pt;\"> </span></font></p></td>\n"; print "<td><p align=\"right\"><font face=\"Arial\"><span style=\"font-size:10pt;\"><input type=\"button\" name=\"Submit\" value=\"Send Links\" onclick=\"validateform(this.form);\">\n"; print "</span></font></p></td></tr></table></form></body></html>\n"; exit; } function linklokurl($fname,$expiry,$dialog) { global $LinklokKey,$thispage,$NoExtraPath; if ($expiry>0) $expirytime=time()+($expiry*60); else $expirytime=0; $auth=md5($LinklokKey.$fname.$expirytime); $link=$fname.",".$expirytime.",".$dialog.",".$auth; $link=rawurlencode($link); // Get filename only $i=strrpos($fname,"/"); if (is_integer($i)) $fnameonly=substr($fname,$i+1,strlen($fname)-i-1); else $fnameonly=$fname; if ($NoExtraPath==1) $link=$thispage."?linklokauth=".$link; else $link=$thispage."/".$fnameonly."?linklokauth=".$link; print($link); } function linklokemail($files,$expiry,$filter,$goto) { global $LinklokKey; $fnames=explode(",",$files); $tohash=$LinklokKey; for ($k=0;$k<count($fnames);$k++) { print("<input name=\"f$k\" type=\"hidden\" value=\"$fnames[$k]\">\n"); $tohash.=$fnames[$k]; } print("<input name=\"x\" type=\"hidden\" value=\"$expiry\">\n"); $tohash.=$expiry; print("<input name=\"m\" type=\"hidden\" value=\"$filter\">\n"); $tohash.=$filter; $hash=md5($tohash); print("<input name=\"g\" type=\"hidden\" value=\"$goto\">\n"); print("<input name=\"a\" type=\"hidden\" value=\"$hash\">\n"); print("<input name=\"linklokform\" type=\"hidden\" value=\"1\">\n"); } function linklokgetfile($linklokauth) { global $LinklokKey, $LinklokLocation,$ErrorTemplate; // Split linklokauth into its parts $linklokauth=rawurldecode($linklokauth); $fname=strtok($linklokauth,","); $expirytime=strtok(","); $dialog=strtok(","); $auth=strtok(","); $auth=trim($auth); // Verify hash value to ensure nothing tampered wth if (md5($LinklokKey.$fname.$expirytime)!=$auth) { ShowMessage($ErrorTemplate,"Linklok URL authentication failed"); exit; } // Check link hasn't expired if ($expirytime!=0) { $curtime=time(); if ($curtime>$expirytime) { ShowMessage($ErrorTemplate,"Sorry but this Linklok link has expired.\n"); exit; } } // Make full path or url to file $link=$LinklokLocation.$fname; // See if link is local path or URL $pos=strpos(strtolower($link),"http://"); if (!is_integer($pos)) { // If link is a local path then get local path and handle resume & download managers $i=strrpos($link,"/"); $fname=substr($link,$i+1,strlen($link)-i); $fsize=@filesize($link); /* is resume requested? */ $headers = xgetallheaders(); if(isset($headers["Range"])) { header("HTTP/1.1 206 Partial content"); $val=split("=",$headers["Range"]); if(ereg("^-",$val[1])) { $slen = ereg_replace("-","",$val[1]); $sfrom = $fsize - $slen; header("Content-Length: ".$slen); } else if(ereg("-$",$val[1])) { $sfrom = ereg_replace("-","",$val[1]); $slen = $fsize - $sfrom; header("Content-Length: ".(string)((int)$fsize-(int)$sfrom)); } $br = $sfrom."-".(string)($fsize-1)."/".$fsize; header("Content-Range: bytes $br"); $mimetype=getmimetype($link); if (($dialog==1) || ($mimetype=="")) { header("Content-type: application/octet-stream\n"); header("Connection: close"); } else { header("Content-type: $mimetype\n"); header("Connection: close"); } if (!($fh=@fopen($link,"rb"))) { ShowMessage($ErrorTemplate,"Linklok could not open the file."); exit; } fseek($fh, $sfrom); @fpassthru($fh); } else { $i=strrpos($link,"/"); $fname=substr($link,$i+1,strlen($link)-i); $size=@filesize($link); if (!($fh=@fopen($link,"rb"))) { ShowMessage($ErrorTemplate,"Linklok could not open the file."); exit; } $mimetype=getmimetype($link); if (($dialog==1) || ($mimetype=="")) { header("Content-type: application/octet-stream\n"); header("Content-disposition: attachment; filename=".$fname."\n"); } else { header("Content-type: $mimetype\n"); } header("Content-transfer-encoding: binary\n"); header("Content-Length: ".$size."\n"); @fpassthru($fh); } } else { // link is a URL rather than local path so do simple download $i=strrpos($link,"/"); $fname=substr($link,$i+1,strlen($link)-i); if (!($fh=@fopen($link,"rb"))) { ShowMessage($ErrorTemplate,"Linklok could not open the file."); exit; } $mimetype=getmimetype($link); if (($dialog==1) || ($mimetype=="")) { header("Content-type: application/octet-stream\n"); header("Content-disposition: attachment; filename=".$fname."\n"); } else { header("Content-type: $mimetype\n"); } header("Content-transfer-encoding: binary\n"); if ((int)$size>0) header("Content-Length: ".$size."\n"); @fpassthru($fh); } exit; } function linklokemaillinks($getvars, $postvars,$freem) { global $LinklokKey,$EmailTemplate,$YourCompany,$YourEmail,$thisurl,$LinklokLog,$NoExtraPath,$ManualPassword,$LinklokLocation,$HTMLEmail,$ErrorTemplate,$ipaddr; $tohash=$LinklokKey; for ($k=0;$k<10;$k++) { $var="f".$k; if ((isset($getvars[$var])) && ($getvars[$var]!="")) { $fname[]=$getvars[$var]; $tohash.=$fname[$k]; } if ((isset($postvars[$var])) && ($postvars[$var]!="")) { $fname[]=$postvars[$var]; $tohash.=$fname[$k]; } } if (isset($getvars['x'])) { $expiry=$getvars['x']; $tohash.=$expiry; } if (isset($postvars['x'])) { $expiry=$postvars['x']; $tohash.=$expiry; } if (isset($getvars['m'])) { $filter=$getvars['m']; $tohash.=$filter; } if (isset($postvars['m'])) { $filter=$postvars['m']; $tohash.=$filter; } if (isset($getvars['email'])) $clientemail=$getvars['email']; if (isset($postvars['email'])) $clientemail=$postvars['email']; $goto=""; if (isset($getvars['g'])) $goto=$getvars['g']; if (isset($postvars['g'])) $goto=$postvars['g']; // if filter set to 1 then block free email services listed above if ($filter=="1") { for ($k=0; $k<count($freem);$k++) { $pos=strpos(strtolower($clientemail),strtolower($freem[$k])); if (is_integer($pos)) { ShowMessage($ErrorTemplate,"Linklok does not accept free email addresses.<BR><BR>Click your browsers BACK button and try again."); exit; } } } $clientname=""; if (isset($getvars['name'])) $clientname=$getvars['name']; if (isset($postvars['name'])) $clientname=$postvars['name']; if (isset($getvars['a'])) $auth=$getvars['a']; if (isset($postvars['a'])) $auth=$postvars['a']; $hash=md5($tohash); // If manual order password then override $manualentry=False; if (($auth==$ManualPassword) && ($ManualPassword!="")) { $manualentry=True; $hash=$auth; } if ($hash!=$auth) { ShowMessage($ErrorTemplate,"Linklok form authentication failed"); exit; } if ($expiry>0) $expirytime=time()+($expiry*60); else $expirytime=0; // Now send email with download links to client if ($EmailTemplate=="") { $subject = "Download Links from ".$YourCompany; $mailBody="Please use the link(s) below to begin downloading.\n\n"; for ($k=0;$k<count($fname);$k++) { $auth=md5($LinklokKey.$fname[$k].$expirytime); $link=$fname[$k].",".$expirytime.","."1".",".$auth; $link=rawurlencode($link); $reallocation=$LinklokLocation.$fname[$k]; // See if link is local path or URL $fsize=0; $pos=strpos(strtolower($reallocation),"http://"); if (!is_integer($pos)) $fsize=@filesize($reallocation); // Get filename only $i=strrpos($fname[$k],"/"); if (is_integer($i)) $fnameonly=substr($fname[$k],$i+1,strlen($fname[$k])-i-1); else $fnameonly=$fname[$k]; if ($NoExtraPath==1) $link=$thisurl."?linklokauth=".$link; else $link=$thisurl."/".$fnameonly."?linklokauth=".$link; if($HTMLEmail == "Y") { $mailBody.="To download ".$fnameonly." click the link below:\n"; $mailBody.="<a href=\"".$link."\">".$fnameonly."</a>"; if ($fsize!=0) $mailBody.=" (".FriendlyFileSize($fsize).")"; if ($expiry!="0") $mailBody.=" ~ Download link will expire in ".FriendlyExpiryTime($expiry).".\n"; else $mailBody.=" \n"; $mailBody.=" \n"; } else { $mailBody.="To download ".$fnameonly." click the link below:\n".$link."\n"; $mailBody.=$fnameonly; if ($fsize!=0) $mailBody.=" (".FriendlyFileSize($fsize).")"; if ($expiry!="0") $mailBody.=" ~ Download link will expire in ".FriendlyExpiryTime($expiry).".\n"; else $mailBody.=" \n"; $mailBody.=" \n"; } } $mailBody.="\n"; $mailBody.=$YourCompany."\n"; $mailBody.=$YourEmail."\n"; if($HTMLEmail == "Y") $mailBody = eregi_replace("\n","<br>",$mailBody); $headers.= "MIME-Version: 1.0\r\n"; if($HTMLEmail == "Y") $headers.= "Content-type: text/html; charset=iso-8859-1\r\n"; else $headers.= "Content-type: text/plain\r\n"; $headers.= "From: ".$YourCompany."<".$YourEmail.">\r\n"; $headers.= "Reply-To: ".$YourCompany."<$YourEmail>\r\n"; mail($clientname." <".$clientemail.">", $subject, $mailBody, $headers); } else { if (!($fh=@fopen($EmailTemplate,"r"))) { ShowMessage($ErrorTemplate,"Can't open email template"); exit; } $mailBody = fread ($fh,100000); fclose($fh); $i=strrpos($EmailTemplate,"."); $ext=substr($EmailTemplate,$i,strlen($EmailTemplate)-$i); $ext=strtolower($ext); // Get subject for email if ($ext==".txt") { $pos=strpos($mailBody,"\n"); $subject=substr($mailBody,0,$pos); $mailBody=substr($mailBody,$pos+1,strlen($mailBody)-$pos-1); } else { $subject="Download Links"; $pos=strpos($mailBody,"<TITLE>"); if (!is_integer($pos)) $pos=strpos($mailBody,"<title>"); $pos2=strpos($mailBody,"</TITLE>"); if (!is_integer($pos2)) $pos2=strpos($mailBody,"</title>"); if ((is_integer($pos)) && (is_integer($pos2))) { $subject=substr($mailBody,$pos+7,$pos2-$pos-7); } } // Create secure links and get size and filename for each file for ($k=0;$k<count($fname);$k++) { // Get filename only $i=strrpos($fname[$k],"/"); if (is_integer($i)) $fnameonly=substr($fname[$k],$i+1,strlen($fname[$k])-i-1); else $fnameonly=$fname[$k]; $ProdFile[$k]=$fnameonly; $auth=md5($LinklokKey.$fname[$k].$expirytime); $link=$fname[$k].",".$expirytime.","."1".",".$auth; $link=rawurlencode($link); if ($NoExtraPath==1) $ProdLink[$k]=$thisurl."?linklokauth=".$link; else $ProdLink[$k]=$thisurl."/".$fnameonly."?linklokauth=".$link; $reallocation=$LinklokLocation.$fname[$k]; // See if link is local path or URL $fsize=0; $pos=strpos(strtolower($reallocation),"http://"); if (!is_integer($pos)) $fsize=@filesize($reallocation); $ProdSize[$k]=$fsize; } $max=30; if (count($fname)>$max) $max=count($fname); // First deal with any !!!link_n!!! that is part of hyperlink $start=0; do { $pos=strpos($mailBody,"<a",$start); if (!is_integer($pos)) $pos=strpos($mailBody,"<A",$start); $pos2=strpos($mailBody,"</a>",$pos); if (!is_integer($pos2)) $pos2=strpos($mailBody,"</A>",$pos); $found=0; if ((is_integer($pos)) && (is_integer($pos2))) { $found=1; for ($k=1; $k<=$max; $k++) { if ($ProdLink[$k-1]=="") { // See if !!!link_k!!! is within the hyperlink $hl=substr($mailBody,$pos,$pos2-$pos); $pos3=strpos($hl,"!!!link_".$k."!!!"); if (!is_integer($pos3)) $pos3=strpos($hl,"!!!link_".$k."!!!"); if (is_integer($pos3)) { $start=$pos; $mailBody=substr_replace($mailBody,"",$pos,$pos2-$pos); break; } else $start=$pos2; } else $start=$pos2; } } } while($found==1); // Now replace all other variables for ($k=1; $k<=$max; $k++) { if ($ProdLink[$k-1]!="") { $mailBody=eregi_replace("!!!filename_".$k."!!!",$ProdFile[$k-1],$mailBody); $mailBody=eregi_replace("!!!link_".$k."!!!",$ProdLink[$k-1],$mailBody); $mailBody=eregi_replace("!!!size_".$k."!!!",FriendlyFileSize($ProdSize[$k-1]),$mailBody); $mailBody=eregi_replace("!!!expires_".$k."!!!",FriendlyExpiryTime($expiry),$mailBody); if(($HTMLEmail == "Y") || ($ext!=".txt")) { $tot="To download ".$ProdFile[$k-1]." click the link below:<BR>"; $tot.="<a href=\"".$ProdLink[$k-1]."\">".$ProdFile[$k-1]."</a>"; if ($ProdSize[$k-1]!="0") $tot.=" (".FriendlyFileSize($ProdSize[$k-1]).")"; if ($expiry!="0") $tot.=" ~ Download link will expire in ".FriendlyExpiryTime($expiry); } else { $tot="To download ".$ProdFile[$k-1]." click the link below:\n".$ProdLink[$k-1]."\n"; $tot.=$ProdFile[$k-1]; if ($ProdSize[$k-1]!="0") $tot.=" (".FriendlyFileSize($ProdSize[$k-1]).")"; if ($expiry!="0") $tot.=" ~ Download link will expire in ".FriendlyExpiryTime($expiry); } $mailBody=eregi_replace("!!!download_".$k."!!!",$tot,$mailBody); } else { $mailBody=eregi_replace("!!!filename_".$k."!!!","",$mailBody); $mailBody=eregi_replace("!!!size_".$k."!!!","",$mailBody); $mailBody=eregi_replace("!!!expires_".$k."!!!","",$mailBody); $mailBody=eregi_replace("!!!download_".$k."!!!","",$mailBody); $mailBody=eregi_replace("!!!link_".$k."!!!","",$mailBody); } } // Now we should see if !!!eachfilestart!!! sections exists $start=0; do { $found=0; $pos=strpos($mailBody,"<!--eachfilestart-->"); $pos2=strpos($mailBody,"<!--eachfileend-->"); if ((is_integer($pos)) && (is_integer($pos2))) { $found=1; $buf=substr($mailBody,$pos+20,$pos2-$pos-20); // Now remove this section $mailBody1=substr($mailBody,0,$pos); $mailBody2=substr($mailBody,$pos2+18,strlen($mailBody)-$pos2-18); $mailBody=$mailBody1; for ($k=1; $k<=count($ProdLink); $k++) { $repeatbuf=$buf; $repeatbuf=eregi_replace("!!!filename!!!",$ProdFile[$k-1],$repeatbuf); $repeatbuf=eregi_replace("!!!link!!!",$ProdLink[$k-1],$repeatbuf); $repeatbuf=eregi_replace("!!!size!!!",FriendlyFileSize($ProdSize[$k-1]),$repeatbuf); $repeatbuf=eregi_replace("!!!expires!!!",FriendlyExpiryTime($expiry),$repeatbuf); if(($HTMLEmail == "Y") || ($ext!=".txt")) { $tot="To download ".$ProdFile[$k-1]." click the link below:<BR>"; $tot.="<a href=\"".$ProdLink[$k-1]."\">".$ProdFile[$k-1]."</a>"; if ($ProdSize[$k-1]!="0") $tot.=" (".FriendlyFileSize($ProdSize[$k-1]).")"; if ($expiry!="0") $tot.=" ~ Download link will expire in ".FriendlyExpiryTime($expiry); } else { $tot="To download ".$ProdFile[$k-1]." click the link below:\n".$ProdLink[$k-1]."\n"; $tot.=$ProdFile[$k-1]; if ($ProdSize[$k-1]!="0") $tot.=" (".FriendlyFileSize($ProdSize[$k-1]).")"; if ($expiry!="0") $tot.=" ~ Download link will expire in ".FriendlyExpiryTime($expiry); } $repeatbuf=eregi_replace("!!!download!!!",$tot,$repeatbuf); $mailBody.=$repeatbuf; } $mailBody.=$mailBody2; } } while($found==1); if(($HTMLEmail == "Y") && ($ext==".txt")) $mailBody = eregi_replace("\n","<br>",$mailBody); $headers.= "MIME-Version: 1.0\r\n"; if($HTMLEmail == "Y") $headers.= "Content-type: text/html; charset=iso-8859-1\r\n"; else $headers.= "Content-type: text/plain\r\n"; $headers.= "From: ".$YourCompany."<".$YourEmail.">\r\n"; $headers.= "Reply-To: ".$YourCompany."<".$YourEmail.">\r\n"; mail($clientname." <".$clientemail.">", $subject, $mailBody, $headers); } // If manual form entry then don't send email to site or log entry. if ($manualentry==True) return; // Send email to website owner with all fields from the form $subject = "Website download request"; $mailBody="The following files were requested.\n\n"; for($k=0;$k<count($fname);$k++) $mailBody.=$fname[$k]."\n"; $mailBody.="\nData from other form fields:-\n\n"; if (!empty($getvars)) { while(list($namepair, $valuepair) = each($getvars)) { $$namepair = $valuepair; if ((strlen($namepair)>2) && ($namepair!="linklokform")) $mailBody.=$namepair." : ".$valuepair."\n"; } } if (!empty($postvars)) { while(list($namepair, $valuepair) = each($postvars)) { $$namepair = $valuepair; if ((strlen($namepair)>2) && ($namepair!="linklokform")) $mailBody.=$namepair." : ".$valuepair."\n"; } } $mailBody.="IP : ".$ipaddr."\n"; $mailBody.="\n"; $headers= "MIME-Version: 1.0\r\n"; $headers.= "Content-type: text/plain\r\n"; $headers.= "From: ".$YourCompany."<".$YourEmail.">\r\n"; $headers.= "Reply-To: ".$YourCompany."<$YourEmail>\r\n"; mail($YourCompany." <".$YourEmail.">", $subject, $mailBody, $headers); // if Logfile required add a line to it containing details of this request if ($LinklokLog!="") { if (is_writeable($LinklokLog)) { $fh=@fopen($LinklokLog,"a"); if ($fh) { $logstr="Date,".date("d/m/y").",Time,".date("H:i:s").",IP,".$ipaddr; // Date,time,IP // Add filenames File0,test.zip,File1,demo.pdf etc for($k=0;$k<count($fname);$k++) $logstr.=",File".$k.",".$fname[$k]; // Add other form fields Name,Adrian,Email,test@mysite.com etc if (!empty($getvars)) { reset($getvars); while(list($namepair, $valuepair) = each($getvars)) { $$namepair = $valuepair; if ((strlen($namepair)>2) && ($namepair!="linklokform")) $logstr.=",".$namepair.",".$valuepair; } } if (!empty($postvars)) { reset($getvars); while(list($namepair, $valuepair) = each($postvars)) { $$namepair = $valuepair; if ((strlen($namepair)>2) && ($namepair!="linklokform")) $logstr.=",".$namepair.",".$valuepair; } } $logstr.="\n"; fputs($fh,$logstr); fclose($fh); } } } if ($goto!="") { header("Location: ".$goto); } } function getmimetype($fn) { $mt['jpg']="image/jpeg"; $mt['gif']="image/gif"; $mt['cgm']="image/cgm"; $mt['gif']="image/gif"; $mt['htm']="text/html"; $mt['html']="text/html"; $mt['txt']="text/plain"; $mt['pdf']="application/pdf"; $mt['mpg']="video/mpeg"; $mt['mpeg']="video/mpeg"; $mt['rm']="audio/x-pn-realaudio"; $mt['wmv']="application/x-ms-wmv"; $i=strrpos($fn,"."); $ext=substr($fn,$i+1,strlen($fn)-$i); $ext=strtolower($ext); if (isset($mt[$ext])) $mimetype=$mt[$ext]; else $mimetype=""; return("$mimetype"); } function FriendlyExpiryTime($exp) { if ($exp==0) return(""); if (($exp>=1) && ($exp<=59)) { if ($exp==1) return("$exp minute"); else return("$exp minutes"); } if (($exp>=60) && ($exp<=1440)) { $hours=intval($exp/60); $mins=$exp % 60; if ($hours==1) $ret=$hours." hour"; else $ret=$hours." hours"; if ($mins>0) { if ($mins==1) $ret.=" & ".$mins." minute"; else $ret.=" & ".$mins." minutes"; } return($ret); } if ($exp>=1441) { $days=intval($exp/1440); $exp=$exp-($days*1440); $hours=intval($exp/60); $mins=$exp % 60; if ($days==1) $ret=$days." day"; else $ret=$days." days"; if ($hours>0) { if ($mins==0) $ret.=" &"; if ($hours==1) $ret.=" ".$hours." hour"; else $ret.=" ".$hours." hours"; } if ($mins>0) { if ($mins==1) $ret.=" & ".$mins." minute"; else $ret.=" & ".$mins." minutes"; } return($ret); } } function FriendlyFileSize($sz) { if ($sz<=1023) return("$sz Bytes"); if (($sz>=1024) && ($sz<=1048575)) { $sz=intval($sz/1024); return("$sz KB"); } if ($sz>=1048576) { $sz=$sz/1048576; $sz=intval($sz*100)/100; return("$sz MB"); } } function CustomMessage($Template,$msg) { if ($Template=="") return(0); if (!($fh=@fopen($Template,"r"))) return(0); // Read each line of template page and insert Linklok variables while(!feof($fh)) { $lne=fgets($fh,1024); $lne=eregi_replace("!!!message!!!",$msg,$lne); print($lne); } fclose($fh); return(1); } function ShowMessage($Template,$msg) { if (0==CustomMessage($Template,$msg)) { print ("<HTML>\n"); print ("<HEAD>\n"); print ("<TITLE>Linklok URL</TITLE>\n"); print ("</HEAD>\n"); print ("<BODY>\n"); print("$msg<BR>"); print ("</BODY>\n"); print ("</HTML>\n"); } } function xgetallheaders() { global $HTTP_SERVER_VARS; $headers = array(); while (list($key, $value) = each ($HTTP_SERVER_VARS)) { if (strncmp($key, "HTTP_", 5) == 0) { $key = strtr(ucwords(strtolower(strtr(substr($key, 5), "_", " "))), " ", "-"); $headers[$key] = $value; } } return $headers; } ?>