write jpg php Arabic? - ar-php

I want to write on the picture in Arabic fonts
This is the code that I did, but I could not install the Arabic library correctly
<?php
include('ar-php/src/Arabic.php');
if(isset($_POST['sub']))
{
$font = 'Almarai/Almarai-Bold.ttf';
$font1= "Almarai/Almarai-Light.ttf";
$im =imagecreatefromjpeg("certificate-1.jpg");
$name= $_POST['name'];
$output =$name.".jpg";
$msg="This Certificate is Auto Generated:". date("d/m/Y");
$textColor = imagecolorallocate ($im,0,0,0);
$Arabic = new Arabic('ArGlyphs');
$text = '$name';
$text = $Arabic->utf8Glyphs($text);
// الصورة وحجمها وموقع الخط ونوع الخط ولونه والكتابة
imagettftext($im,80, 0, 2000, 2000,$textColor, $font, ucwords($name));
imagettftext($im, 30, 0, 10, 2400,$textColor, $font1, $msg);
imagejpeg($im,$output);
header('Content-Description: File Transfer');
header('Content-Type: application/image');
header('Content-Disposition: attachment; filename="'.basename($output).'"');
header('Content-Length: ' . filesize($output));
readfile($output);
}
?>
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<title>
موقع شهادات
</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, inital-scale=1">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
<div class="card" style="margin-top:20%">
<div class="card-header bg-success">
<h3 class="text-center text-white">
موقع شهادات تجريبي
</h3>
</div>
<div class="card-body">
<form id="form" method="post" enctype="multipart/form-data">
<div class="form-group">
<label>الاسم:</label>
<input type="text" name="name" autocomplete="off" class="form-control">
</div>
<div class="form-group">
<input type="submit" value="اطبع" name="sub" class="btn btn-primary">
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
I tried to install the Arabic library, but the following error appears:
Warning: Undefined variable $Arabic in C:\xampp\htdocs\Certificate-Print\index.php on line 16
Fatal error: Uncaught Error: Call to a member function utf8Glyphs() on null in C:\xampp\htdocs\Certificate-Print\index.php:16 Stack trace: #0 {main} thrown in C:\xampp\htdocs\Certificate-Print\index.php on line 16
I want to write on the picture in Arabic fonts
This is the code that I did, but I could not install the Arabic library correctly
I want to write on the picture in Arabic fonts
This is the code that I did, but I could not install the Arabic library correctly

You are getting the error because $Arabic is null. I suspect that class name is not called Arabic ?
When I read the docs the class is called I18N_Arabic. So your line should be
$Arabic = new I18N_Arabic ('ArGlyphs');
You have too many things called Arabic for my liking - its a recipe for disaster.

Related

Nested columns always stack?

I am trying to use bootstrap 5.1 to achieve a responsive layout, but don't get the expected outcome.
I have two columns I want to be adjacent in large screens and stacked in small screens. The first column is further subdivided by two (nested) columns; one with the title and one with three buttons. I would like these to stack in large screens (i.e. buttons below title) and position adjacent in small screens (i.e. buttons next to title).
Instead, the nested columns always stack. What am I doing wrong?
fiddle: fiddle
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<title>TITLE</title>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="hidden-sm col-md-1 col-lg-2"></div>
<div class="col-sm-12 col-md-10 col-lg-8">
<div class="row">
<div class="col-xs-12 col-sm-5">
<div class="row">
<div class="col-xs-6 col-sm-12">
<h4>TITLE</h4>
</div>
<div class="col-xs-6 col-sm-12">
<button type="button" class="btn active btn-danger btn-block">1</button>
<button type="button" class="btn active btn-success btn-block">2</button>
<button type="button" class="btn active btn-danger btn-block">3</button>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-7">
<div id="clock" style="background-color:black; height:5rem;">&nbsp &nbsp</div>
</div>
<div class="hidden-sm col-md-1"></div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
</body>
</html>

SyntaxError: missing ) after argument list can't seem to find possible solution

What is the issue, Where did I go wrong? This is the code for index.ejs i made minor changes to my previous old_index.ejs. i have been struggling with this issue and the backend does have await function for calling aleph-js (aleph.im) so i don't think it's any issue about async.
**strong text**<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-3 rooms-sidebar">
<div class="card no-outline">
<div class="card-body">
<small>Logged in as</small><br>
<b>
hook this up later<br>
</b>
</div>
</div>
<hr>
<hr>
<div class="card no-outline mb-2 room-card">
<div class="card-body">
<span class='name'>
Chat
</span><br>
<span class='member-count'>
<small>
99 Members
</small>
</span>
</div>
</div>
</div>
<div class="col-9">
<div class="chat-room">
<nav class="navbar navbar-light">
<span class="navbar-brand" href="#">
<b>
Chat
</b>
</span>
<small>
99 Members
</small>
</nav>
<div id="messages">
<% posts.forEach((post)=> { %>
<% var parsed_item=JSON.parse(post.item_content) %>
<div class="message mb-2">
<div class="content-container">
<div class="content">
<%= parsed_item.content.body %>
</div>
<div class="author">
<%= parsed_item.address %>
</div>
</div>
</div>
<% }) %>
</div>
<div class="chat-box">
<form action="/messages" method="post" id='message-form'>
<div class="input-group">
<input type='text' name="message" id="message" cols="30" rows="10" class="form-control">
<div class="input-group-append"></div>
<input type="submit" value="Post Message" class="btn btn-primary">
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<%= posts %>
<script type='text/javascript'>
$(document).ready(() => {
const socket = new WebSocket('wss://api2.aleph.im/api/ws0/messages?msgType=POST&contentType=chat')
socket.onmessage = (e) => {
let message = JSON.parse(e.data)
console.log(message)
let content = message.content.content.body;
$('#messages-list').prepend(`<li>${content}</li>`)
}
$('#message-form').submit((e) => {
e.preventDefault();
$.post('/messages', $('#message-form').serialize())
$('#message-form textarea').val('')
})
})
</script>
</body>
</html>
<%= 'me' if message.user == current_user %>
Refer The Image

CSS And Other Few Elements Not Working In Express Website. Node.js

I am making a discord bot with website, and i have defined css and other stuff in .html file but its still not showing when i go to the website.
res.status(200).sendFile(path.resolve(__dirname, "../../website/command.html"))
})
Thats how i require the html file.
The Html File:
<html lang="en-US">
<head>
<title>Commandli</title>
<link rel="icon" href="https://cdn.discordapp.com/avatars/746706292562853888/0b578635739cbd7e5b076e65f2c04a4c.png?size=2048">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./css/commands.css" />
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght#300;500;600;700&display=swap" rel="stylesheet">
</head>
<body>
<header class="header">
<img src="https://cdn.discordapp.com/avatars/"/> bot
<input class="menu-btn" type="checkbox" id="menu-btn" />
<label class="menu-icon" for="menu-btn"><span class="navicon"></span></label>
<ul class="menu">
<li>Home</li>
<li><a class="active" href="commands.html">Commands</a></li>
<li>About us</li>
<li>Contact us</li>
<li>Invite bot</li>
</ul>
</header>
<main>
<section class="tabs">
<div class="tab-header">
<div class="tablink tab-active" onclick="openCity(event,'Utility')">Utility</div>
<div class="tablink " onclick="openCity(event,'Fun')">Fun</div>
<div class="tablink" onclick="openCity(event,'Economy')">Economy</div>
<div class="tablink" onclick="openCity(event,'Info')">Info</div>
<div class="tablink" onclick="openCity(event,'Games')">Games</div>
<div class="tablink" onclick="openCity(event,'Misc')">Misc</div>
<div class="tablink" onclick="openCity(event,'All commands')">All commands</div>
</div>
<div style="margin-left:130px">
<div id="Utility" class="tab-content category" style="display:block">
<p><a>Utility commnads</a><br>Those commands help you with some things</p>
<p><a>=dungeon</a><br>Sends information about the current dungeon.</p>
<p><a>=help</a><br>Sends help!</p>
<p><a>=gamepedia</a><br>Search what you want on gamepedia</p>
<p><a>=welcome info</a><br>Information about the welcome system</p>
<p><a>Soon more!</a><br>Stay tuned!</p>
</div>
</div>
<script type="text/javascript" src="../js/commands.js"></script>
</section>
</main>
</body>
</html>
HTML file in bin = https://sourceb.in/DEA1wBlvs2
(Had to remove some code because it was huge)

my ejs page is not loading like other ejs page

enter image description here this is my edit_admin code
Only in this page my html css is not getting load gretting an 404
error
i've tried alot but i can't get what's the actual reason behind this
kind of error
Refused to apply style from '' because its MIME type
('text/html') is not a supported stylesheet MIME type,andstrict MIME
checking is enabled in nodejs
Refused to apply style from 'http://localhost:5000/admin/css/bootstrap3.3.7.min.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Admin</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" type="text/css" href="../css/bootstrap3.3.7.min.css">
<link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.7.0/css/font-
awesome.min.css">
<link rel="stylesheet" type="text/css" href="../css/dashboard.css">
</head>
<body>
<!-- SIDE BAR START -->
<%- include('../partials/admin_sidebar.ejs'); %>
<!-- SIDE BAR END -->
<section id="contents">
<nav class="navbar navbar-default">
<!-- NAV BAR START -->
<%- include('../partials/admin_navbar.ejs'); %>
<!-- NAV BAR END -->
</nav>
<div class="container-fluid">
<div class="row" style="background-color: white;">
<div class="col-md-8">
<form action="/admin/edit_admin/<%- admin.id %>" method="post">
<div class="form-group">
<label for="email">Email address</label>
<input type="email" value="<%- admin.email %>" name="email" class="form-control" id="email" placeholder="name#example.com">
</div>
<!-- <div class="form-group">
<label for="exampleFormControlSelect1">Example select</label>
<select class="form-control" id="exampleFormControlSelect1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div> -->
<div class="form-group">
<label for="password">Password</label>
<input type="password" value="<%- admin.password %>" name="password" class="form-control" id="password" placeholder="password">
</div>
<div class="form-group">
<input type="submit" class="btn btn-success" name="submit">
</div>
</form>
</div>
</div>
</div>
</section>
<script src='http://code.jquery.com/jquery-latest.js' type="text/javascript"></script>
<script src='../js/main.js' type="text/javascript"></script>
<script src='../js/dashboard.js' type="text/javascript"></script>
I think you need to specify your assets folder in your nodejs app file.
app.use(“ASSETS_FOLDER”, express.static(“ASSETS_FOLDER”);
Your css file path for http://localhost:5000/admin/css/bootstrap3.3.7.min.css is incorrect.
Because it can not find the file on specified path, it goes to the 404 & returns html page of 404, which causes you to see this error
I would suggest to use absolute path for referring to your static css/js resource files as it might need to be accessed from various locations, relative path might not work if accessed from different places
To be sure that this is the error you have, just paste this url http://localhost:5000/admin/css/bootstrap3.3.7.min.css in your browser & see if you get css file there, if you see 404 page, the error is exactly what I explained above.
UPDATE > Ideal way giving reference to assets in ejs
You can pass base_url like this in your routes while rendering ejs
res.render('edit', {
base_url: "http://" + req.headers.host
})
And then specify link urls like this show it always catches the exact file no matter where you call it from
<link rel="stylesheet" type="text/css" href="<%= base_url%>/css/bootstrap3.3.7.min.css">
<link rel="stylesheet" type="text/css" href="<%= base_url%>/fonts/font-awesome-4.7.0/css/font-
awesome.min.css">
<link rel="stylesheet" type="text/css" href="<%= base_url%>/css/dashboard.css">

How to Change SAPI VOICES in Windows [PHP]

I have basic code which works as:
$voice = new COM("SAPI.SpVoice");
voice .Speak("hello world");
I am getting RID of default voice, So
I am now looking at a way to change which voice is getting used for the TTS.
I want to change SAPI voice to ZIRA
What is the correct way to change the default voice, I read some thread here , But it is in javascript, and it is not working.
my code :
#$submit = $_POST['process'];
#$word = $_POST['texttospeech'];
$voice = new COM("SAPI.SpVoice");
if($_SERVER["REQUEST_METHOD"] == "POST" and isset($submit) and !empty($word)){
$voice->Speak($word);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="robots" content="noindex, nofollow">
<title>PHP Text to Speech</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="img/fav.png" type="image/png">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
</head>
<body onload="startTime()">
<nav class="navbar-inverse" role="navigation">
<a href="https://google.com/" target="_blank">
<img src="img/cod.png" class="hederimg">
</a>
<div id="clockdate">
<div class="clockdate-wrapper">
<div id="clock"></div>
<div id="date"><?php echo date('l, F j, Y'); ?></div>
</div>
</div>
</nav>
<div class="topmost">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
<center>
<strong class="panelinputtitle">PHP Text to Speech Converter Using Microsoft Speech API</strong>
</center>
</div>
<div class="panel-body">
<form method = "POST">
<div class = "form-group">
<textarea class="form-control input-sm" rows="6" name="texttospeech" placeholder="Type your Text Here..."></textarea>
</div>
<div class = "form-group">
<input type = "submit" class = "btn btn-primary btn-block" name="process" value="Speak">
</div>
</form>
</div>
</div>
</div>
</div>
<script src="js/bootstrap.min.js"></script>
<script src="js/script.js"></script>
</body>
</html>
Thanks in advance.
I've searched this one a long time ..
At least selecting Zira within the control panel as default voice works

Resources