i want to generate a 30 sec preview from the mp3 file using custom php script. the script will automatically trip the clip to 30 sec preview and after that the audio file will stop automatically.
moreover, i am not sure of any libraries on the system so please share step by step process with me.
It's no good idea but:
SELECT * FROM users where (email = 'mohsin#ac.com' OR username = 'mosin')
and password = 'sdssd'
I think you must authenticate only with username, you can decide to use email field as username.
$i_want_to_login_by_email = true;
$field = 'username';
if( $i_want_to_login_by_email )
{
$field = 'email';
}
$qry =<<<Rohit
SELECT * FROM users where {$field} = "{$value}" and password = 'sdssd'
Rohit;
Related
Here what I want to do is :
Send an email by mail merge by writing a script in App Script. (Success)
I have configured 2 domain email addresses in my Gmail along with my basic Gmail address.
I want to send an email via xyz#domainname.com instead of xyz#gmail.com, the Google Sheets owner.
here what I have done to send an email via Gmail
var first = 0;
var last = 1;
var email = 2;
var emailTemp = HtmlService.createTemplateFromFile("email");
var ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("NAJ");
var data = ws.getRange("A2:C" + ws.getLastRow()).getValues();
data.forEach(function(row){
emailTemp.fn = row[first];
emailTemp.ln = row[last];
var htmlMessage = emailTemp.evaluate().getContent();
GmailApp.sendEmail(row[email], "Important Test", "Your email does not support HTML.",
{name: "Email App", htmlBody: htmlMessage}
);
});
}
The only thing I need is to change the sending email address.
Any help would be highly appreciated. pardon my bad English
Explanation:
Your goal is to send emails from a specific email account regardless of the email account that is currently executing the script.
Approach 1:
One way to approach that is to use an installable trigger. As per the documentation:
Installable triggers always run under the account of the person who
created them. For example, if you create an installable open trigger,
it runs when your colleague opens the document (if your colleague has
edit access), but it runs as your account. This means that if you
create a trigger to send an email when a document is opened, the email
is always be sent from your account, not necessarily the account that
opened the document.
The idea here is to create an installable onEdit trigger from xyz#domainname.com so whenever the other emails edit a particular cell, the emails will be send.
The limitation of this approach is that we need to make sure that we trigger the code when we really want to and not every time a cell is edited. We can create a checkbox, and upon clicking on the checkbox (it does not matter which account did that) then the script will be executed and the emails will sent by the email account who created the installable trigger.
Approach 2:
Create email aliases. Here is the official documentation on how to do that and also this thread might be useful to create them programmatically. The restriction here is that to add an email alias, you must be a Google Workspace administrator.
Solutions:
Solution 1:
Create a checkbox in cell D1 of the sheet NAJ. The cell is up to you but you need to adjust the script accordingly.
Change the name of the function to add the event object. This will allow us to get edit info such as which cell is edited.
The new function will be:
function myInstallableOnEditFunction(e) {
const arng = e.range;
if(arng.getSheet().getName()=="NAJ" && arng.getA1Notation()=='D1' && arng.getValue()==true){
var first = 0;
var last = 1;
var email = 2;
var emailTemp = HtmlService.createTemplateFromFile("email");
var ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("NAJ");
var data = ws.getRange("A2:C" + ws.getLastRow()).getValues();
data.forEach(function(row){
emailTemp.fn = row[first];
emailTemp.ln = row[last];
var htmlMessage = emailTemp.evaluate().getContent();
GmailApp.sendEmail(row[email], "Important Test", "Your email does not support HTML.",
{name: "Email App", htmlBody: htmlMessage}
);
});
}
}
Finally, create an installable onEdit trigger function from the xyz#domainname.com account. You can do that either manually from the current project's trigger menu or programmatically.
After that, upon clicking on cell D1 by any account, the emails will be sent by xyz#domainname.com.
Solution 2:
After you have created email aliases (see Approach 2), you can use the getAliases() method, here is a sample script. I haven't tested on my own, but you can explore also this possibility.
// Log the aliases for this Gmail account and send an email as the first one.
var me = Session.getActiveUser().getEmail();
var aliases = GmailApp.getAliases();
Logger.log(aliases);
if (aliases.length > 0) {
GmailApp.sendEmail(me, 'From an alias', 'A message from an alias!', {'from': aliases[0]});
} else {
GmailApp.sendEmail(me, 'No aliases found', 'You have no aliases.');
}
I'm using Registration Form from the link below.
https://github.com/simfatic/RegistrationForm/tree/master/source
The only problem I'm facing is that I'm not getting the confirmation code/link on my(user) email ID.
On my other(admin) email ID, I'm getting the mail that a new user has registered. Even in my SQL, I'm receiving all the information like username, password and confirmation code. But it is not sending the confirmation code/link to the user.
Please Help.
Thank you
I just had a look through the code and it looks fine, you need to double check you corrected all the placeholders correctly, it might be you forgot to change one of them so now it can't push data to the users email.
I can't see what you changed the code to so unable to help you much more.
#AnonyMate
Emails can be sent when it's the live server.
BUT if you want to set email working facility in localhost, then you have to set SMTP configuration as below.
NOTE:- This is just basic setup for SMTP configuration. Different Email libraries may have different syntax.
$mailconfig['charset'] = 'utf-8';
$mailconfig['mailtype'] = 'html';
$mailconfig['newline'] = "\r\n";
if($_SERVER['HTTP_HOST']=="localhost")
{
//SMTP configuration
$mailconfig['protocol'] = 'smtp';
$mailconfig['smtp_host'] = 'ssl://smtp.gmail.com';
$mailconfig['smtp_port'] = 465;
$mailconfig['smtp_user'] = 'your Gmail Email-ID';
$mailconfig['smtp_pass'] = 'your Gmail Email-password';
}
So in your project, please refer source/include/class.phpmailer.php, change SMTP settings accordingly. Also find on which page there is an "email send" functionality. And set above variables values on that page as per that syntax.
EDIT:- Found the page on which there is an email send functionality.
/source/include/fg_membersite.php
In above file, in this function SendUserWelcomeEmail(&$user_rec)
Also in this file /source/include/class.phpmailer.php, make below changes.
NOTE :- Dont't delete old data. just comment it.
//var $Mailer = 'mail';
var $Mailer = 'smtp';
//var $Host = 'localhost';
var $Host = 'ssl://smtp.gmail.com';
//var $Port = 25;
var $Port = 465;
var $SMTPSecure = "ssl";
var $Username = 'your Gmail Email-ID';
var $Password = 'your Gmail Email-password';
I'm stuck and the plugin owner of wp-courseware don't wan't to offer assistance with this.
I am trying to grab the wordpress user data (email and country) and then put it into a file that will send this data dynamically.
I am using wp-courseware and I have found the following code and trying to intergrate the users details (mainly country into the code)
function WPCW_actions_users_moduleCompleted($userID, $unitID,
$unitParentData)
{
if (!$userID || !$unitID || !$unitParentData) {
return;
}
$userDetails = get_userdata($userID);
// Admin wants an email notification, and email address exists. Assumption
is that it's valid.
if ($unitParentData->email_complete_module_option_admin == 'send_email' &&
$unitParentData->course_to_email)
{
$adminSubject = __("Module Complete Notification - {USER_NAME} - Module
{MODULE_NUMBER}", 'wp_courseware');
$adminBody = __("Hi Trainer!
Just to let you know, {USER_NAME} has just completed 'Module {MODULE_NUMBER} - {MODULE_TITLE}'.
{SITE_NAME}
{SITE_URL}
", 'wp_courseware');
// Do email sending now
WPCW_email_sendEmail($unitParentData,
$userDetails, // User who's done the completion
$unitParentData->course_to_email,
$adminSubject, $adminBody);
}
// Check if admin wants user to have an email.
if ($unitParentData->email_complete_module_option == 'send_email')
{
WPCW_email_sendEmail($unitParentData,
$userDetails, // User who's done the completion
$userDetails->user_email,
$unitParentData->email_complete_module_subject, // Use subject template in the settings
$unitParentData->email_complete_module_body // Use body template in the settings
);
}
// Any additional admin-level notifications?
do_action("wpcw_user_completed_module_notification", $unitParentData,
$userDetails, $adminSubject, $adminBody);
}
This would depend on how you, or the plugin you're using, is saving the Country data to the database. Check out the wp_usermeta table and look for the key under which the country is saved. Or, since the function above is already grabbing all of the user's meta with $userDetails = get_userdata($userID);, you could print the $userDetails array and see what you have to work with.
Note how the email is grabbed by using $userDetails->user_email;. It will be similar to this, using that country meta_key instead.
So I'm developing a website using php, mysql and javascript, and also 'sha512' to encrypt passwords of members using the code :
$password = filter_input(INPUT_POST, 'p', FILTER_SANITIZE_STRING);
$random_salt = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true));
$password = hash('sha512', $password . $random_salt);
the p value is comming from :
function formhash(form) {
var password = randomString();
var p = document.createElement("input");
form.appendChild(p);
p.name = "p";
p.type = "hidden";
p.value = hex_sha512(password.value);
password.value = "";
form.submit();
}
function randomString() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0; i < 9; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
My idea here is to reset user password by entering their email and generate random 8 characters then send it directly to their email.
The problem I'm facing now is how to get the actual password (not encrypted) that has been generated so it can be automatically sent to the email of the member who requested to reset their password?
Good question.
First, you should never send users their passwords in plaintext. It's considered a bad security practice for a few reasons. If anyone gets access to the email, then they have the password and can hijack the user account. Second, hashing is a one-way form of encryption where you turn the password into gibberish. The big value in hashing is that the same password will always be turned into the same gibberish-- everytime. This means you can do password matching without ever storing the raw password. The reason you're supposed to hash a password and not do 2-way encryption like AES-256, is that 2-way encryption requires the creation, management, and securing of encryption keys which can be hard. Hashing is just easier and more secure for the vast majority of developers.
So how should you implement password reset if you can't send the raw password?
You send the user an email with a link to a secure reset page AND a one-time use reset token that expires within a certain window. This way, if someone get's access to the email then the window of risk is limited to the short window.
There are a variety of ways to build this yourself but an easy approach to getting a one-time use token you don't have to store or manage is to offload user management to a microservice like Stormpath where it takes care of all the user management for you-- password reset, password storage, user profiles, authentication, etc.
For password reset here's what it would look like:
User initiates password reset work on a web page
You make API call to stormpath with user's email address or username
Stormpath sends out reset email to user (your "from" address, custom HTML, etc) with a link + token. The reset token that is unique, one-time use, and expires if not used within 24 hours
User clicks on the link and lands on the reset page
You pull the token from the URL and check Stormpath for token verification
User submits new password
Stormpath sends out reset success message (your "from" address, custom HTML, etc)
You can build your own UIs in this flow so the user never knows Stormpath exists.
Now, you don't have to manage, store, or secure any passwords or reset tokens in your database.
Here's are some links to the community-managed PHP SDK.
http://docs.stormpath.com/php/quickstart/
http://docs.stormpath.com/php/product-guide/
Full Disclosure - I work at Stormpath
and also 'sha512' to encrypt passwords
You're not encrypting them, you're hashing them. A hash is a one-way function. You can't take the result of a hash function and get the original. There are many possible original chunks of data that can result in the same hash.
The whole point of hashing in this context is to be able to check passwords without ever actually storing the user's password. You shouldn't send the user their password in e-mail, as e-mail is sent over the internet unencrypted. If you must have the original pre-hashed data for some reason, you must store it before you hash it.
I'm currently fetching a query (e.g, http://localhost:49781/HTML/index.html?inputName=Marcus) from a html form using this following JavaScript:
function setSignedName() {
if (window.location.search.indexOf("=") >= 0) {
var split = window.location.search.split("=");
document.getElementById("signed_in_name").innerHTML += split[1];
} else {
document.getElementById("signed_in_name").innerHTML = "Not signed in";
}
running the script will get the result: Marcus.
I want this string to be persisted through out my site, so when the user navigates to another page the inputName will still be Marcus.
What is the best way of achieving this?
Edit: This approach is only for display/non-production use, I know using a server side language like PHP is the best approach.
I believe the best way is using localStorage. It works in all major browsers and it's easy to use:
function setSignedName() {
var userName = "";
if (window.location.search.indexOf("=") >= 0) {
var split = window.location.search.split("=");
userName += split[1];
} else {
userName = "Not signed in";
}
document.getElementById("signed_in_name").innerHTML = userName;
localStorage.setItem("userName", userName);
}
To access it:
var userName = localStorage.getItem("userName");
And this is it. Check for it in the Resources tab in Developer tools(F12) in your fav broswer.
You'll want to either repopulate it through GET parameters in your server side language, or if you want to hack it together, use a cookie and repopulate it with JavaScript on page load with "pushState".
https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history#The_pushState()_method