 <?php
if(isset($_POST['submit'])){
	function mail_attachment($from , $to, $subject, $message, $attachment,$f_type,$f_name, $seperator=";"){
    $fileatt_type = "application/octet-stream"; // File Type 
    $email_from = $from; // Who the email is from 
    $email_subject =  $subject; // The Subject of the email 
    $email_txt = $message; // Message that the email has in it 
    $email_to = $to; // Who the email is to

    $semi_rand = md5(time()); 
    $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 
    $headers .= "From: <".$from.">".
            "\nMIME-Version: 1.0\n" . 
            "Content-Type: multipart/mixed; " . 
            "boundary=\"{$mime_boundary}\";\n".
            "Content-Transfer-Encoding: 7bit\n\n";              
    $email_message .= "This is a multi-part message in MIME format.\n\n" . 
                "--{$mime_boundary}\n" . 
                "Content-Type: text/html\n";
    $email_message .= $email_txt . "\n\n"; 
    $fileatt = $attachment; // Path to the file                  
    $token=strtok($attachment, $seperator);
    $j=0;
    while($token!==false) {
        $start = strrpos($token, '/') > -1 ? strrpos($token, '/')+1 : 0;
        $fileatt_name = substr($token, $start, strlen($token)); // Filename that will be used for the file as the     attachment 
        $file = fopen($token,'rb'); 
        $data = fread($file,filesize($token)); 
        fclose($file); 
        $data = chunk_split(base64_encode($data));                     
        $email_message .= "--{$mime_boundary}\n" . 
                  "Content-Type: {$f_type[$j]};" . 
                  " name=\"{$f_name[$j]}\";\n" . 
                  "Content-Transfer-Encoding: base64\n" . 
                  "Content-Disposition: attachment;\n\n" . 
                 $data;
          $token=strtok($seperator);
          $j++;
    }
    $email_message .= "--{$mime_boundary}--\n";
   // echo $email_message;die("*****************");
   $ok = @mail($email_to, $email_subject, $email_message, $headers); 
    if($ok) { 
    	echo '
      		<br><br>
		<div style="border: 3px solid #336600; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px">
		<p class="MsoNormal" align="center" ><font size="4" color="#333333">We acknowledge with thanks the receipt of your paper. The suitability of your paper for external review will be determined by one of our editors within 2 weeks. If you do not receive any email from one of editors-in-chief within 2 weeks, kindly contact them via bmashayekhyf@yahoo.com and hvishki@yahoo.com. </font> </p>
                <p class="MsoNormal" align="center"><font size="4" color="#333333"> Best wishes,</font></p>
		<p class="MsoNormal" align="center"><font size="4" color="#333333"> Editorial office</font> </p>
		</div>
      	';
      	die();
    } else { 
        die("Sorry but the email could not be sent. Please go back and try again!"); 
    } 
} 
	$atu_name=$_POST['atu_name'];
	$title=$_POST['title'];
	$fname=$_POST['fname'];
	$lname=$_POST['lname'];
	$country=$_POST['country'];
	$degree=$_POST['degree'];
	$email=$_POST['email'];
	$tel=$_POST['tel'];
	$sug_editor=$_POST['sug_editor'];
	$scope=$_POST['scope'];
	$ref_name1=$_POST['ref_name1'];
	$ref_con1=$_POST['ref_con1'];
	$ref_mail1=$_POST['ref_mail1'];
	$ref_name2=$_POST['ref_name2'];
	$ref_con2=$_POST['ref_con2'];
	$ref_mail2=$_POST['ref_mail2'];
	$ref_name3=$_POST['ref_name3'];
	$ref_con3=$_POST['ref_con3'];
	$ref_mail3=$_POST['ref_mail3'];
	$ref_name4=$_POST['ref_name4'];
	$ref_con4=$_POST['ref_con4'];
	$ref_mail4=$_POST['ref_mail4'];
	$Confirmation=$_POST['Confirmation'];
	$Ethics=$_POST['Ethics'];

	
	$body = '*Corresponding author:<b>'.$atu_name.'</b><br>*(Country Code)(City Code)(Tel):<b>'.$tel.'</b><br>*Title:<b>'.$title.'</b><br><br>--------------------------------------------<br>Author(s)<br>';
	for($i=0,$j=1;$i<10;$i++,$j++){
		if($fname[$i]){
				$body.=$j.'- Full First name:<b>'.$fname[$i].'</b>&nbsp;&nbsp;Full Last name:<b>'.$lname[$i].'</b>&nbsp;&nbsp;Country:<b>'.$country[$i].'</b>&nbsp;&nbsp;Last academic degree:<b>'.$degree[$i].'</b>&nbsp;&nbsp;Email:<b>'.$email[$i].'</b><br>';
		}
	}
	$body.='--------------------------------------------<br>Suggested editor:<b>'.$sug_editor."<br>";
	if ($scope){
		$body.='</b><br><br>--------------------------------------------<br>Paper Scope:<b><br>';
	 	foreach ($scope as $t)
	 	{$body.='* '.$t.'<br />';}
	}

	$body.= '<br>--------------------------------------------<br>Suggested Referees:<br>';
		if ($ref_name1){
			$body.='1. Name: <b>'.$ref_name1.'</b>&nbsp;&nbsp;Country: <b>'.$ref_con1.'</b>&nbsp;&nbsp;Email: <b>'.$ref_mail1.'</b><br>';
			
		}
		if ($ref_name2){
			$body.='2. Name: <b>'.$ref_name2.'</b>&nbsp;&nbsp;Country: <b>'.$ref_con2.'</b>&nbsp;&nbsp;Email: <b>'.$ref_mail2.'</b><br>';
			
		}
		if ($ref_name3){
			$body.='3. Name: <b>'.$ref_name3.'</b>&nbsp;&nbsp;Country: <b>'.$ref_con3.'</b>&nbsp;&nbsp;Email: <b>'. $ref_mail3.'</b><br>';
			
		}
		if ($ref_name4){
			$body.='4. Name: <b>'.$ref_name4.'</b>&nbsp;&nbsp;Country: <b>'.$ref_con4.'</b>&nbsp;&nbsp;Email: <b>'.$ref_mail4.'</b><br>';
			
		}
							
		$body.='--------------------------------------------<br>Confirmation:<b>'.$Confirmation.'</b><br>'; 
		$body.='--------------------------------------------<br>Ethics:<b>'.$Ethics.'</b><br>'; 
		
      $fp=fopen("tmp/CoverLetter.html",'w');
      fwrite($fp,$body);
      fclose($fp);      
      $file= $_FILES['art_file1']['tmp_name'].";".$_FILES['art_file2']['tmp_name'].";./tmp/CoverLetter.html";
      $f_type=array($_FILES['art_file1']['type'],$_FILES['art_file2']['type'],filetype('./tmp/CoverLetter.html'));
      $f_name=array($_FILES['art_file1']['name'],$_FILES['art_file2']['name'],'CoverLetter.html');
      mail_attachment ($atu_name, "bmashayekhyf@yahoo.com, bmashf@um.ac.ir, hvishki@yahoo.com, vishki@um.ac.ir, moslehian@yahoo.com, moslehian@um.ac.ir", "Article Submission to KJM", $body, $file,$f_type,$f_name);     
      //mail_attachment ($atu_name, "bmashayekhyf@yahoo.com, bmashf@um.ac.ir, hvishki@yahoo.com, vishki@um.ac.ir, moslehian@yahoo.com, moslehian@um.ac.ir", "Article Submission to KJM", $body, $file,$f_type,$f_name);     
}
?>
<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
var i=1;
	function checkInfo()
	{	if(document.form.atu_name.value == ''){
			alert("Please enter Corresponding author.");
			document.form.atu_name.focus();
		}else{
			if(document.form.title.value == ''){
				alert("Please enter title of the article.");
				document.form.title.focus();
			}else{
				var Ffname = document.getElementById('fname');
				if(Ffname.value == ''){
					alert("Please Enter  Full first name.");
					Ffname.focus();
				}else{
					var Flname = document.getElementById('lname');
					if(Flname.value == ''){
						alert("Please Enter  Full last name.");
						Flname.focus();
					}else{
						var Country = document.getElementById('country');
						if(Country.value == ''){
							alert("Please Enter country name.");
							Country.focus();
						}else{
							if(document.form.tel.value == ''){
							alert("Please enter a telephone number.");
							document.form.tel.focus();
							}else{
								var Femail = document.getElementById('email');
								if(Femail.value == ''){
									alert("Please enter an email.");
									Femail.focus();
								}else{
									if(document.form.ref_name1.value == ''||document.form.ref_con1.value == '' || document.form.ref_mail1.value == ''){
										alert("Please specify 4 referees.");
										document.form.ref_name1.focus();
									}else{
										if(document.form.ref_name2.value == ''||document.form.ref_con2.value == '' || document.form.ref_mail2.value == ''){
										alert("Please specify 4 referees.");
										document.form.ref_name2.focus();
										}else{
											if(document.form.ref_name3.value == ''||document.form.ref_con3.value == '' || document.form.ref_mail3.value == ''){
											alert("Please specify 4 referees.");
											document.form.ref_name3.focus();
											}else{
												if(document.form.ref_name4.value == ''||document.form.ref_con4.value == '' || document.form.ref_mail4.value == ''){
												alert("Please specify 4 referees.");
												document.form.ref_name4.focus();
												}else{
													if(document.form.sug_editor.value == ''){
														alert("Please specify your suggested editor.");
														document.form.sug_editor.focus();
													}else{  
														if(document.form.scope.value == ''){
														alert("Please specify your paper scope.");
														document.form.scope.focus();
														}else{
																if(document.form.Confirmation.value == ''){
																	alert("Please Answer this question.");
																	document.form.Confirmation.focus();
																}else{
																	if(document.form.Ethics.value == ''){
																		alert("Please Answer this question.");
																		document.form.Ethics.focus();
																	}else{
																		var file_name=document.form.art_file1.value;
																		var len=file_name.length;
																		sub=file_name.substr(len-3,len);
																		if(sub=="pdf")
																			return true;
																		else{
																			alert("Please send pdf format of the article.");
																			document.form.art_file1.focus();
																		}
																	}
																}
															}
														}
													}		
												}
											}
									}
								}
							}
						}
					}
				}
			}
		}		
	return false;
	}
	function addRow(id){
		if( i< 10){
			i= i+1;
			var tbody = document.getElementById(id).getElementsByTagName("tbody")[1];
			var row = document.createElement("tr");
			var td0 = document.createElement("td");
			td0.innerHTML ="<p align='center'>"+i +"</p>";
			var td1 = document.createElement("td");
			td1.innerHTML ="<p align='center'><input type='text' size='20' name='fname[]'>";
			var td2 = document.createElement("td");
			td2.innerHTML ="<p align='center'><input type='text' size='30' name='lname[]'>";
			var td22 = document.createElement("td");
			td22.innerHTML ="<p align='center'><input type='text' size='30' name='country[]'>";
			var td3 = document.createElement("td");
			td3.innerHTML ="<p align='center'><select size='1' name='degree[]'><option selected >Ph.D</option><option>Ph.D. Candidate</option><option>M.Phil</option><option>M.Sc.</option><option>M.Sc. Student</option><option>B.Sc.</option><option>B.Sc. Student</option></select>";
			var td4 = document.createElement("td");
			td4.innerHTML ="<p align='center'><input type='text' size='40' name='email[]'>";
			row.appendChild(td0);
			row.appendChild(td1);
			row.appendChild(td2);
			row.appendChild(td22);
			row.appendChild(td3);
			row.appendChild(td4);
			tbody.appendChild(row);
		}
	}
</script> 
</head>

<body>
<form method="POST" action="KJM.php" onsubmit="return checkInfo();"  name="form" id="form" enctype="multipart/form-data">
	<div style="border-style: solid; border-width: 1px; padding: 20px;">
			<p align="center"><b><span style="color: red; font-size: 18pt;">
			Submission to the Khayyam Journal of Mathematics (KJM)</span></b></p> <p align="center"><b><span style="color: red; font-size: 12pt;">
(Incomplete submissions have not been considered)</span></b></p>
		<p align="center">
			<b><span style="color: blue; font-size: 18pt;">Title</span></b>
		</p>
		<p>
			<span style="color:green"> I </span>  <input type=text SIZE="23" name="atu_name" value=""> <span style="color:green"> (for example: John Stwart)</span> as the corresponding author with <span style="color:green">Tel (preferably mobile): <input type="text" size="18" name="tel" value="">&nbsp;(for example: +98-9153410495)</span>,</span>
			attached a manuscript in the PDF format entitled
		</p>
		<p>
			<b><span style="color:green">Title:</span></b>
			<input type="text" size="120" name="title" value="">&nbsp;</span>
		</p>
		<p>
			<span style="font-size:11.0pt">for possible publication in KJM.</span>
				<div style="mso-element:para-border-div;border:none;border-bottom:solid windowtext 1.0pt; mso-border-bottom-alt:solid windowtext .75pt;padding:0cm 0cm 1.0pt 0cm">
				<span style="font-size:11.0pt">&nbsp;</span>
			</div>
		</p>
		<p align="center">
			<b><span style="color: blue; font-size: 18pt;">Author(s)<span style="font-size:10.0pt">(both you and your coauthors)</span></span></b>
		</p>
			<div align="center">
		<table border="1" bordercolor="#000000" style="border-collapse: collapse" id="table">
			<tr>
				<td></td>
				<td>
				<p align="center"><b><span style="color:green">Full First name</span></b></td>
				<td>
				<p align="center"><b><span style="color:green">Full Last name</span></b></td>
				<td>
				<p align="center">
				<b><span style="color:green">Country</span></b></td>

				<td>
				<p align="center"><b><span style="color:green">Last academic 
				degree</span></b></td>
				<td>
				<p align="center"><b><span style="color:green">Email</span></b></td>
			</tr>
			<tbody>
			<tr>
				<td><p align='center'>1</p></td>
				<td>
				<p align="center"><input type="text" size="20" name="fname[]" id="fname" value=""></td>
				<td>
				<p align="center"><input type="text" size="30" name="lname[]" id="lname" value=""></td>
				<td>
				<input type="text" size="30" name="country[]" id="country" value=""></td>

				<td>
				<p align="center"><select size="1" name="degree[]" id="degree" value="">
				<option selected >Ph.D</option>
                                <option>Ph.D. Candidate</option>
				<option>M.Phil</option>
				<option>M.Sc.</option>
                                <option>M.Sc. Student</option>
				<option>B.Sc.</option>
                                <option>B.Sc. Student</option>
				</select></td>
				<td>
				<p align="center"><input type="text" size="40" name="email[]" id="email" value=""></td>
			</tr>
			</tbody>
			<tr>
				<td colspan=6>
				<p align="center"><input type="button" value="Add"  onclick="javascript:addRow('table')"></td>
			</tr>
		</table>
			</div>
		
		<p><b><i>(By clicking on "Add", please continue in the same format as above for the other 
		authors, if any.)</i></b></p>
					<div style="mso-element:para-border-div;border:none;border-bottom:solid windowtext 1.0pt; mso-border-bottom-alt:solid windowtext .75pt;padding:0cm 0cm 1.0pt 0cm">
				<span style="font-size:11.0pt">&nbsp;</span>
		</div>

		</p>
		<p align="center">
			<b><span style="color: blue; font-size: 18pt;">Suggested Editor</span></b>
		</p>
		<p>
			Please suggest an appropriate member of the editorial board (NOT of the 
			advisory board or the editor-in-chief):
		</p>
		<p>
				<b><span style="color:green">Suggested editor:<select name="sug_editor" size="1">
													<option  value="" >You should choose an editor
													</option>
<option value="H. R. Ebrahimi Vishki" >H. R. Ebrahimi Vishki (Editor-in-chief)</option>
<option value="B. Mashayekhy" >B. Mashayekhy (Editor-in-chief)</option>
<option value="Ahmad Erfanian" >Ahmad Erfanian (Coordinating Editor)</option>
<option value="Fatemeh Helen Ghane" >Fatemeh Helen Ghane (Coordinating Editor)</option>
<option value="Shirin Hejazian" >Shirin Hejazian (Coordinating Editor)</option>
<option value="Rajab Ali Kamyabi-Gol" >Rajab Ali Kamyabi-Gol (Coordinating Editor)</option>
<option value="Saeed Kayvanfar" >Saeed Kayvanfar (Coordinating Editor)</option>
<option value="Kazem Khashyarmanesh" >Kazem Khashyarmanesh (Coordinating Editor)</option>
<option value="Alireza Kamel Mirmostafaee" >Alireza Kamel Mirmostafaee (Coordinating Editor)</option>
<option value="Madjid Mirzavaziri" >Madjid Mirzavaziri(Coordinating Editor)</option>
</select>&nbsp;</span></b>
		<div style="mso-element:para-border-div;border:none;border-bottom:solid windowtext 1.0pt; mso-border-bottom-alt:solid windowtext .75pt;padding:0cm 0cm 1.0pt 0cm"></div>		
			<p align="center">
				&nbsp; <b><span style="color: blue; font-size: 18pt">&nbsp; 
				Paper Scope</span></b>
<p>
			If you cannot find an appropriate Mathematics Subject Classification (MSC2010) in the list below, it means that your paper is not in the scope of the KJM, so please submit your paper elsewhere.
		</p><p>
				&nbsp;<b><span style="color: green">Paper scope (MSC2010) <span style="font-size:10.0pt">- You can select more than one item by keeping the 'Ctrl' key pressed while you select the items with the mouse.</span></span></b><br>
			
				&nbsp;<select id="scope" name="scope[]" multiple  size="5" style="position: relative">
		<optgroup label="Mathematics Subject Classifications(MSC2010)" >
			<option value="5 - combinatorics">
			5 - combinatorics </option>
			<option value="13 - Commutative algebra">
			13 - Commutative algebra </option>
                        <option value="15 - Linear and multilinear algebra, matrix theory">
			15 - Linear and multilinear algebra </option>
			<option value="18 - Category theory, homological algebra">
			18 - Category theory, homological algebra </option>
			<option value="20 - Group Theory and generalizations">
			20 - Group Theory and generalizations</option>
			<option value="22 - Topological groups and Lie groups">
			22 - Topological groups and Lie groups  </option>
			<option value="37 - Dynamical systems and ergodic theory ">
			37 - Dynamical systems and ergodic theory  </option>
			<option value="43 - Abstract Harmonic Analysis">
			43 - Abstract Harmonic Analysis </option>
                        <option value="46 - Functional Analysis">
			46 - Functional Analysis </option>
			<option value="47 - Operator Theory ">
			47 - Operator Theory </option>
			<option value="54 - General Topology">
			54 - General Topology</option>
			<option value="55 - Algebraic Topology">
			55 - AlgebraicTopology </option>
			<option value="? - Others">
			? - Others </option>

		</optgroup>
	</select>							
		<div style="mso-element:para-border-div;border:none;border-bottom:solid windowtext 1.0pt; mso-border-bottom-alt:solid windowtext .75pt;padding:0cm 0cm 1.0pt 0cm">
				<span style="font-size:11.0pt">&nbsp;</span>
		</div>

		</p>
		<p align="center">
			<b><span style="color: blue; font-size: 18pt;">Suggested Referees</span></b>
		</p>
		<p>
			<span style="font-size:11.0pt">Following is a list (names, countries 
			and e-mails) of 4 potential referees, who are good</span> experts in 
			the area of research. I <b>
		<span style="color:red">certify</span></b> that these potential referees</p>
			<ul>
					<li>are <b>
					NOT</b> editors or editors-in-chief of KJM,</li>
					<li>are <b>
					NOT</b>&nbsp;family members of one of authors;</li>
					<li>and <b>
					3 of 4 </b> suggested referees are from American countries, 
					Japan or Europe.</li>
			</ul>
			<p>
				<b><span style="color:green">Full Names, Countries, emails of 
				referees:</span> <span style="color:red">(The paper may be rejected if suggested reviewers would not be qualified as requested.)</span></b>
				
		</p>


			<div align="center">


			<table border="1" width="76%" id="table1" style="border-collapse: collapse; text-align:center;" bordercolor="#000000">
				<tr>
					<td width="29">&nbsp;</td>
					<td style="color:green"><b>Full Name</b></td>
					<td style="color:green"><b>Country</b></td>
					<td style="color:green"><b>Email</b></td>
				</tr>
				<tr>
					<td width="29">1</td>
					<td>
					<input type="text" name="ref_name1" size="36" value=""></td>
					<td>
					<input type="text" name="ref_con1" size="28" value=""></td>
					<td>
					<input type="text" name="ref_mail1" size="28" value=""></td>
				</tr>
				<tr>
					<td width="29">2</td>
					<td>
					<input type="text" name="ref_name2" size="36" value=""></td>
					<td>
					<input type="text" name="ref_con2" size="28" value=""></td>
					<td>
					<input type="text" name="ref_mail2" size="28" value=""></td>
				</tr>
				<tr>
					<td width="29">3</td>
					<td>
					<input type="text" name="ref_name3" size="36" value=""></td>
					<td>
					<input type="text" name="ref_con3" size="28" value=""></td>
					<td>
					<input type="text" name="ref_mail3" size="28" value=""></td>
				</tr>
				<tr>
					<td width="29">4</td>
					<td>
					<input type="text" name="ref_name4" size="36" value=""></td>
					<td>
					<input type="text" name="ref_con4" size="28" value=""></td>
					<td>
					<input type="text" name="ref_mail4" size="28" value=""></td>
				</tr>
				
			</table>
			</div>
			<div style="mso-element:para-border-div;border:none;border-bottom:solid windowtext 1.0pt; mso-border-bottom-alt:solid windowtext .75pt;padding:0cm 0cm 1.0pt 0cm">
				<span style="font-size:11.0pt">&nbsp;</span>
		</div>
		<p align="center">
			<b><span style="color: blue; font-size: 18pt;">Files of article</span></b>
		</p>
		<p>
			<b><span style="color:green">Article file of the manuscript only in <span style="color:red">
			Pdf</span> format:</span></b>
			<input type="file" name="art_file1">
		</p>
		<p>
			<b><span style="color:green">Source LaTeX file of the manuscript <span style="color:red">
			</span>:</span></b>
			<input type="file" name="art_file2">
		</p>
		<p><b><i>(If you have more than one file please zip them and send the zipped file)</i></b></p>
			<div style="mso-element:para-border-div;border:none;border-bottom:solid windowtext 1.0pt; mso-border-bottom-alt:solid windowtext .75pt;padding:0cm 0cm 1.0pt 0cm">
				<span style="font-size:11.0pt">&nbsp;</span>
		</div>
		
<p align="center">
			<b><span style="color: blue; font-size: 14pt;">Confirmation</span></b>
		</p>
		<p>
			<b>Do you confirm that <p> (i) all authors of this manuscript have agreed to its submission to KJM if there is more than one author;</p> <p>(ii) you and any other coauthor(s) are responsible for its content and its originality.</p></b>
			<select size="1" name="Confirmation">
			<option value=""></option>
			<option value="YES" >YES</option>
			<option value="NO" >NO</option>
			</select>
			<div style="mso-element:para-border-div;border:none;border-bottom:solid windowtext 1.0pt; mso-border-bottom-alt:solid windowtext .75pt;padding:0cm 0cm 1.0pt 0cm">
				<span style="font-size:11.0pt">&nbsp;</span>
		</div>
		<p align="center">
			<b><span style="color: blue; font-size: 14pt;">Ethics</span></b>
		</p>
		<p>
			<b> Do you confirm publishing ethics of this journal, in particular, not some 
				portions of the results/data/figures in the manuscript have been 
				published or are under consideration for publication elsewhere?</p></b>
			<select size="1" name="Ethics">
			<option value=""></option>
			<option value="YES" >YES</option>
			<option value="NO" >NO</option>
			</select>
			
		</div>
			<p align="center">
		<input type="submit" name="submit" ><input type="reset" value="Reset Form" name="B2">
			
			</div>
</form>
</body>
</html>		
