| Server IP : 192.169.170.185 / Your IP : 216.73.216.97 Web Server : Apache System : Linux p3plmcpnl495852.prod.phx3.secureserver.net 4.18.0-553.52.1.lve.el8.x86_64 #1 SMP Wed May 21 15:31:29 UTC 2025 x86_64 User : akhilnew ( 1712764) PHP Version : 5.6.40 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/akhilnew/public_html/electrojournal.com/admin/inc/ |
Upload File : |
<?php
function insertfonts($name, $oldfile, $i)
{
global $dbhost;
if($dbhost === '127.0.0.1'):
$mysqli = new mysqli('127.0.0.1', 'root', '', 'akinikjaccess');
$uploadpath = 'akinik/';
else:
$mysqli = new mysqli('localhost', 'akinikjaccess', 'Ox%dMvF@JfL~', 'akinikjaccess');
$uploadpath = '';
endif;
$stmt = $mysqli->prepare("SELECT * FROM fonts WHERE name = ? LIMIT 1") or die(output($mysqli->error));
$stmt->bind_param('s', $name);
$stmt->execute();
$stmt->store_result();
$count_rows = $stmt->num_rows();
$stmt->close();
if($count_rows == 0):
$newfile = str_pad(time().$i, 16, 0, STR_PAD_LEFT).'.'.strtolower(pathinfo($oldfile, PATHINFO_EXTENSION));
@copy($oldfile, '../../'.$uploadpath.'jaccess/uploads/fonts/'.$newfile);
$stmt = $mysqli->prepare("INSERT INTO fonts(name, file) VALUES(?, ?)") or die(output($mysqli->error));
$stmt->bind_param('ss', $name, $newfile);
$stmt->execute();
$stmt->close();
endif;
}
if($option === 'delete'):
if( ! $dataid):
die(output('Nothing selected.'));
endif;
foreach($dataid as $id):
$stmt = $mysqli->prepare("SELECT file FROM $table WHERE $firstcol = ? LIMIT 1") or die(output($mysqli->error));
$stmt->bind_param('i', $id);
$stmt->execute();
$stmt->store_result();
$count_rows = $stmt->num_rows();
$stmt->bind_result($file);
$stmt->fetch();
$stmt->close();
if($count_rows === 1):
$stmt = $mysqli->prepare("DELETE FROM $table WHERE $firstcol = ? LIMIT 1") or die(output($mysqli->error));
$stmt->bind_param('i', $id);
$e = $stmt->execute();
$stmt->close();
if($e):
$fn->delete_file($uploadpath.$page.'/'.$file);
$text = 'Content has been deleted.';
$stat = true;
else:
die(output('Content has not been deleted.'));
endif;
else:
die(output('Content is not found.'));
endif;
endforeach;
die(output(array('text' => $text, 'stat' => $stat)));
elseif($option === 'add' OR ($option === 'edit' && $dataid)):
$fontname = $fn->escape($_POST['name']);
$fontname = str_replace(' ', '-', strtolower($fontname));
$fontname = stripslashes($fontname);
$my_font = $fn->escape($_FILES['font']['name']);
$fonttmp = $_FILES['font']['tmp_name'];
$fontext = strtolower(pathinfo($my_font, PATHINFO_EXTENSION));
$newfont = date('ymdhis').'.'.$fontext;
$validext = array('ttf', 'otf');
if(!is_dir(rtrim($uploadpath, '/'))):
@mkdir(rtrim($uploadpath, '/'));
endif;
if(!is_dir($uploadpath.$page)):
@mkdir($uploadpath.$page);
endif;
$stmt = $mysqli->prepare("SELECT * FROM $table WHERE name = ?") or die(output($mysqli->error));
$stmt->bind_param('s', $fontname);
$stmt->execute();
$stmt->store_result();
$count_rows = $stmt->num_rows();
$stmt->close();
if(empty($fontname)):
die(output('Please enter your font name.'));
elseif(($option === 'add' && $count_rows > 0)):
die(output('That record already exist.'));
else:
if($option === 'add'):
if(empty($my_font)):
die(output('Please choose your font.'));
elseif( ! in_array($fontext, $validext)):
die(output('Please choose a valid font. (TTF, OTF)'));
endif;
if(move_uploaded_file($fonttmp, $uploadpath.$page.'/'.$newfont)):
$stmt = $mysqli->prepare("INSERT INTO $table(name, file, creation) VALUES(?, ?, ?)") or die(output($mysqli->error));
$stmt->bind_param('sss', $fontname, $newfont, $creation);
$e = $stmt->execute();
$stmt->close();
$mysqli->close();
if($e):
insertfonts($fontname, $uploadurl.$page.'/'.$newfont, 1);
die(output(array('text' => 'Content has been added.', 'stat' => true)));
else:
die(output('Content has not been added.'));
endif;
else:
die(output('Font has not been uploaded.'));
endif;
elseif($option === 'edit'):
$stmt = $mysqli->prepare("SELECT * FROM $table WHERE ($firstcol != ? AND name = ?)") or die(output($mysqli->error));
$stmt->bind_param('is', $dataid, $fontname);
$stmt->execute();
$stmt->store_result();
$count_rows = $stmt->num_rows();
$stmt->close();
if($count_rows > 0):
die(output('That record already exist.'));
endif;
$stmt = $mysqli->prepare("SELECT file FROM $table WHERE $firstcol = ? LIMIT 1") or die(output($mysqli->error));
$stmt->bind_param('i', $dataid);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($efontfile);
$stmt->fetch();
$stmt->close();
if($my_font):
if( ! in_array($fontext, $validext)):
die(output('Please choose a valid font. (TTF, OTF)'));
endif;
if( ! move_uploaded_file($fonttmp, $uploadpath.$page.'/'.$newfont)):
die(output('Font has not been uploaded.'));
endif;
if($efontfile && file_exists($uploadpath.$page.'/'.$efontfile)):
@unlink($uploadpath.$page.'/'.$efontfile);
endif;
else:
$newfont = $efontfile;
endif;
$stmt = $mysqli->prepare("UPDATE $table SET name = ?, file = ? WHERE $firstcol = ? LIMIT 1") or die(output($mysqli->error));
$stmt->bind_param('ssi', $fontname, $newfont, $dataid);
$e = $stmt->execute();
$stmt->close();
$mysqli->close();
if($e):
die(output(array('text' => 'Your changes have been saved.', 'stat' => true)));
else:
die(output('Your changes have not been saved.'));
endif;
else:
die(output('No valid action found.'));
endif;
endif;
elseif($option === 'transfertojaccess'):
$i = 1;
$stmt = $mysqli->prepare("SELECT name, file FROM $table") or die(output($mysqli->error));
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($name, $file);
while($stmt->fetch()):
insertfonts($name, $uploadurl.$page.'/'.$file, $i++);
endwhile;
$stmt->close();
die(output('Transfered.'));
else:
die(output('No valid action found.'));
endif;
?>