I've been jogging my mind on how to enable my users to change their passwords using the cPanels XML API. I've googled, played with example code, and could not find anything that remotely works. Can someone please tell me what I'm doing wrong? Thanks!
require_once('../includes/xmlapi.php');
$ip = '127.0.0.1';
$root_pass = 'secret';
$account = 'accountna';
$email_account = $_POST['email'];
$email_domain = "mydomain.com";
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth("root",$root_pass);
$xmlapi->set_debug(1);
$args = array(
'domain'=>$email_domain,
'email'=>$email_account
);
if ($xmlapi->api2_query($account, "Email", "passwdpop", array( 'domain' => "domain name", 'email' => "user name", 'password' => "new password") )) {
echo "Success!";
};
you neet to set port!
before password_auth
$xmlapi->set_port ( 2083 );
$xmlapi->password_auth("root",$root_pass);
Related
I am trying to send email to multiple recipient address in cake php 3.
my codes are :
$this->loadModel('AsIndividualDetails');
$EmailDetails = $this-> AsIndividualDetails->find('all',['fields'=>'email']);
$EmailDetails = $EmailDetails->toArray();
foreach ($EmailDetails as $key => $a) {
$this->loadModel('DomainEmailDetails');
$DomainEmailDetails = $this-> DomainEmailDetails->find('all')->first();
$DomainEmailDetails = $DomainEmailDetails->toArray();
$host = 'ssl://'.$DomainEmailDetails['host_name'];
$username = $DomainEmailDetails['user_name'];
$password = $DomainEmailDetails['user_password'];
$port = $DomainEmailDetails['port'];
$email_to = $a['email'];
$senderName = 'abc';
$email_id ='xyz110#gmail.com';
Email::configTransport('WebMail', [
'className' => 'Smtp',
'host' => $host,
'port' => $port,
'timeout' => 30,
'username' => $username,
'password' => $password,
'client' => null,
'tls' => null,
]);
////////// SEND MAIL
$email = new Email('WebMail');
$email ->template('default','default')
->emailFormat('both')
->from([$username => $senderName])
->to($email_to)
->replyTo($email_id)
->subject('Client Message');
$response = $email->send('My msg');
if($response){
echo 'success';
}else{
echo 'failed';
}
}
When I run this script just only one mail send successfully and after that an error has come :
Cannot modify an existing config "WebMail"
How to solve this error and send mail to all recipient mail address.
If you really need set the config inside a loop, you could delete it before rewrite the config:
use Cake\Mailer\Email;
Email::dropTransport($key);
See Class Email API for more info
Make your email configuration outside of the loop. You don't want to try and establish the configuration every time you send the emails - just one time. Then send all the emails based on that one configuration.
I am trying to get data from Google spreadsheet by some specific value, currently I have tried the following method:
$spreadsheetService = new Google\Spreadsheet\SpreadsheetService();
$spreadsheetFeed = $spreadsheetService->getSpreadsheets();
$spreadsheet = $spreadsheetFeed->getByTitle(APPLICATION_GOOGLE_SPREADSHEETS_BOOK);
$worksheetFeed = $spreadsheet->getWorksheets();
$worksheet = $worksheetFeed->getByTitle(APPLICATION_GOOGLE_SPREADSHEETS_SHEET);
It works fine when I use this:
$listFeed = $worksheet->getListFeed(array("sq" => "name = henryhwong", "reverse" => "true"));
but when it do the same for email it gives error:
$listFeed = $worksheet->getListFeed(array("sq" => "email = henryhwong#gmail.com", "reverse" => "true"));
The error is because of "#", if search anything else which doesn't contain "#" sign then it works perfectly, I am unable to find the cause behind this.
Had a similar problem before. Try put email in double quotes:
$listFeed = $worksheet->getListFeed(array("sq" => 'email = "henryhwong#gmail.com"', "reverse" => "true"));
Try this code below. Hope it helps you.
$listFeed = $worksheet->getListFeed(array("sq" => "email" = "henryhwong#gmail.com", "reverse" => "true"));
I've been successfully uploading videos to YouTube using some code I found (Zend with YouTube API).
I modified it so that I can upload via a proxy server, but I've hit a brick wall. I've commented which lines I added to implement the proxy support. Here is the code:
<?php
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_YouTube');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Http_Client_Exception'); //added for proxy support
Zend_Loader::loadClass('Zend_Http_Client'); //added for proxy support
Zend_Loader::loadClass('Zend_Http_Client_Adapter_Proxy'); //added for proxy support
Zend_Loader::loadClass('Zend_Gdata_App_HttpException'); //added for proxy support
$config = array(
'adapter' => 'Zend_Http_Client_Adapter_Proxy',
'proxy_host' => 'MY_PROXY_IP',
'proxy_port' => 8080,
'proxy_user' => 'USER',
'proxy_pass' => 'PASS'
); //added for proxy support
$proxiedHttpClient = new Zend_Gdata_HttpClient('http://www.google.com/', $config); //added for proxy support
try
{
$authenticationURL= 'https://www.google.com/accounts/ClientLogin';
$httpClient = Zend_Gdata_ClientLogin::getHttpClient(
$username = 'YOUTUBE EMAIL ID',
$password = 'YOUTUBE PASSWORD',
$service = 'youtube',
$client = $proxiedHttpClient, //changed from "$client = null"
$source = 'mysource',
$loginToken = null,
$loginCaptcha = null,
$authenticationURL);
}
catch (Zend_Gdata_App_Exception $e)
{
$arry['data']['flag'] = false;
$arry['data']['msg'] = 'Username or Password Invalid.';
print_r(json_encode($arry));
die();
}
$httpClient->setConfig($config); //added for proxy support
$developerKey='DEVELOPER KEY';
$applicationId = 'not require';
$clientId = 'not require';
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);
$fileName = "FILENAME";
$fileType = "video/mp4";
$newEntry = new Zend_Gdata_YouTube_VideoEntry();
$filesource = $yt->newMediaFileSource($fileName);
$filesource->setContentType('video/mp4');
$filesource->setSlug($fileName);
$newEntry->setMediaSource($filesource);
$newEntry->setVideoTitle("VIDEO TITLE");
$newEntry->setVideoDescription("VIDEO DESCRIPTION HERE");
$newEntry->setVideoCategory("VIDEO CATEGORY HERE");
$newEntry->setVideoTags("VIDEO TAGS");
try {
$newEntry = $yt->insertEntry($newEntry, 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads', 'Zend_Gdata_YouTube_VideoEntry');
$state = $newEntry->getVideoState();
if ($state)
{
$videourl = $newEntry->getVideoWatchPageUrl();
$arry['data']['flag'] = true;
$arry['data']['url'] = $videourl;
$arry['data']['msg'] = "Video Uploaded Successfully.";
}
else
{
$arry['data']['flag'] = false;
$arry['data']['msg'] = "Not able to retrieve the video status information yet. " ."Please try again later.\n";
}
}
catch (Zend_Gdata_App_Exception $e) {
$arry['data']['flag'] = false;
$arry['data']['msg'] = $e->getMessage();
}
echo "<pre>";
print_r($arry);
?>
When I execute the PHP from the command line, the message it gives back is:
Trying to write but we are connected to the wrong proxy server
The proxies I've been testing with definitely work - in fact, if I use a broken proxy it just says "Username or Password is invalid." I only get the error message above when using working proxies.
Any guidance or solution would be greatly appreciated.
I had the same problem and I found a solution that worked for me. I used the built in cURL Adapter instead of the Proxy adapter.
See my example below...
$config = array(
'adapter' => 'Zend_Http_Client_Adapter_Curl',
'curloptions' => array(CURLOPT_FOLLOWLOCATION => true, CURLOPT_PROXY => "proxy:port", CURLOPT_PROXYUSERPWD => "username:password")
);
This code is using turned down GData API and deprecated clientlogin
Please update to v3 API, here are PHP examples to get you started.
this seems pretty straightforward but i just can't get mailchimp to get the emails. I have a checkbox and all I want to do is say, if check then subscribe.
I get an error 500 and I have no idea where to go with this.
<?php echo CHtml::CheckBox('[subscribe]',true, array ( 'value'=>'yes',)); ?>
if ( $_POST['subscribe'])
{
Yii::import('application.vendors.mailchimp');
$mailchimp = new Mailchimp(Yii::app()->params['mailchimp']['key']);
$listId = '*******';
$email = array(
'email' => trim($_POST['User']['email']));
$subscriber = $mailchimp->list->subscribe(
$listId,
$email,
$merge_vars=null,
false,
false
);
}
I'm having trouble getting the Authentication to work with laravel 4. This is my whole sign in function when a user enters their email and password into the form.
public function getSignin() {
$return_arr = array();
$email = Input::get('email');
$password = Input::get('password');
$validation = Validator::make(
array(
'Email' => $email,
'Password' => $password
), array(
'Email' => 'required|Email',
'Password' => 'required'
)
);
if ($validation->passes()) {
$pass = base64_encode($password);
$details = array ('email' => $email, 'password' => $pass);
if (Auth::attempt($details)) {
$return_arr['frm_check'] = 'success';
$return_arr['msg'] = 'logged in';
} else {
$return_arr['frm_check'] = 'error';
$return_arr['msg'] = 'log in failed';
}
} else {
$errors = $validation->messages();
$return_arr['frm_check'] = 'error';
$return_arr['msg'] = $errors->first();
}
echo json_encode($return_arr);
$this->layout = null;
return;
}
Even though the email and password are in the same row in the database, it still returns log in failed, was wondering if anyone could shed some light on to this situation?
If I've missed off any other crucial details let me know and I'll post them right away. Thanks in advance.
Based on your comments...
When you're creating your $user, use Hash::make($password) to hash the password using BCrypt, before saving it in your db.
Then, when the user's logging in just use Auth::attempt($credentials) as you are, but don't use base_64 to encrypt it, the Auth method does it all for you!
Much more on the excellent Laravel docs: http://laravel.com/docs/security
Unless you have base64 encoded your password on save(), remove this line from your code:
$pass = base64_encode($password);
And edit this one to:
$details = array ('email' => $email, 'password' => $password);
Auth::attempt() will hash it for you, using something safer than base64.
EDIT:
To correctly save your passwords you have to do something like this:
$user = new User;
$user->email = 'me#me.com';
$user->password = Hash::make('mySuperSecretPassword');
$user->save();
Then you can user attempt just passing it unhashed.
Here's a tutorial I wrote; which might help!
https://medium.com/on-coding/e8d93c9ce0e2