what i want to achieve is, user login in my wordpress website and also login on vanilla forum, i have installed jsconnect plugin in vanilla forum, and using the php's jsconnect library from following location jsConnectPHP
Here is my code:
require_once('functions.jsconnect.php');
$clientID = "1501569466";
$secret = "xxxxxxxxxxxxxxxxxxxxxx";
$userD = array();
if( isset($_POST['log']) ){
$data = array();
$data['user_login'] = $_POST['u_user'];
$data['user_password'] = $_POST['u_pass'];
$data['remember'] = TRUE;
$user = wp_signon($data, FALSE);
if(!is_wp_error($user)){
$userD['uniqueid'] = $user->ID;
$userD['name'] = $user->user_login;
$userD['email'] = $user->user_email;
$userD['photourl'] = '';
$secure = true;
WriteJsConnect($user, $_GET, $clientID, $secret, $secure);
$redirect = "http://localhost/vanilla/entry/jsconnect?client_id={$clientID}";
echo "<script>document.location.href='".$redirect."';</script>";
}
}
when the user login on wordpress i redirect it to jsconnect url in vanilla where i just found only a progress image, and can't figure out where is the problem..
jsconnect authentication url expects jsonp array like the following:
test({"email":"test#test.com",
"name":"testuser",
"photourl":"",
"uniqueid":1234,
"client_id":"12345678",
"signature":"XXXX"})
You authorization url you specify inside jsconnect should see this output to process further. In fact I am stuck at that point. I could see vanilla forum when loaded gets this input but no login happens.
Related
I am currently working on an automated site creation function on my local installation of wordpress. In essence, a form is filled out on an already existing site and that info is pulled to create a new site automatically via an endpoint that activates some queries. So far I have been able to successfully pull the information into an array and then pass that to the wpmu_create_blog function. The issue is that the $domain isn't being called correctly(that is to say, how I intend it to be called), the '/' is lost between 'localhost' and 'wordpress'.
public function create_endpoint($request) {
$key = $request['key'];
if ($this->validate_key($key)) {
$newsite = array (
$title = $request['name'],
$path = $request['slug'],
$admin_user = $request['admin_user'],
);
$domain = 'localhost/wordpress';
$site_id = get_blog_id_from_url($domain, $path);
$user_id = get_user_by('login', $admin_user);
if ( !empty($title) and !empty($domain) and !empty($path) and empty($user_id) ) {
return wpmu_create_blog($domain, $path, $title, $user_id, $site_id);
}
else {
return "Not enough information";
}
}
else {
return $this->invalid_key_message;
}
}
Everything but the domain being called as intended is working as intended. This is also just the static prototype, my end goal is that this is entirely dynamic including the $domain variable.
I'm just totally lost on where to go from here. I've tried some appendage stuff and moving syntax around in all types of ways but keep hitting a wall. Any input or suggestions are happily accepted.
I have a solution implemented. In the array $path has been changed to $slug (use of slug is specific to my code). The $domain now only calls 'localhost' and I create $path using plain text the 'wordpress' and then add the slug via a $request.
$newsite = array (
$title = $request['name'],
$slug = $request['slug'],
$admin_user = $request['admin_user'],
);
$domain = 'localhost';
$path = 'wordpress/'.$request['slug'];
We are using CleverReach to redirect people to our website after they have double opt-in their mail account. We redirect the email as a query parameter to our website, like: example.com/thanks?email=foo#bar.com (by setting up a redirect in the CleverReach backend like example.com/thanks?email={EMAIL}). Apparently, the email parameter doesnt get urlencoded by cleverreach.
Now, in Drupal, if the URL is like so: example.com/thanks?email=hello+world#bar.com and using this code:
$request = \Drupal::request();
$email = $request->query->get('email');
$email is hello world#bar.com. Now, I dont know what the correct processing is here. Obviously, I cant tell CleverReach to urlencode their redirects beforehand. I dont even know if that would be best practice or if I need to imlement something...
The only thing I found out is that $_SERVER['QUERY_STRING'] contains the "real" string, which I can urlencode and then redirect, and then, by reading the query params, urldecode them. But I feel like I am missing some crucial inbuilt functionality.
TL;DR
If a website redirects to my website using not urlencoded query params, how do I read them?
My current approach:
<?php
public function redirectIfIllegalUri() {
$request = \Drupal::request();
$email = $request->query->get('email', '');
$needsRedirect = (false !== strpos($email, ' ') || false !== strpos($email, '#'));
if ($needsRedirect && isset($_SERVER['QUERY_STRING']) && false !== strpos($_SERVER['QUERY_STRING'], 'email=')) {
$sqs = $_SERVER['QUERY_STRING'];
$sqs = htmlspecialchars($sqs);
$sqs = filter_var($sqs, FILTER_SANITIZE_STRING);
$sqs = filter_var($sqs, FILTER_SANITIZE_ENCODED);
$sqs = urldecode($sqs);
$sqs = explode('&', $sqs);
foreach ($sqs as $queryParam) {
if (false === strpos($queryParam, 'email=')) continue;
$values = explode('=', $queryParam);
$email = $values[1];
}
$emailEncoded = urlencode($email);
$query = $request->query->all();
$query['email'] = $emailEncoded;
$refreshUrl = Url::fromRoute('<current>');
$refreshUrl->setOptions([
'query' => $query,
]);
$response = new RedirectResponse($refreshUrl->toString(), 301);
$response->send();
return;
}
}
$request = \Drupal::request();
$email = urldecode($request->query->get('email', false));
drupal request() docs
The problem you are facing is that the + will be treated as a space when you get the value from $_GET global variable.
Currently in PHP doesn't exist a method that returns these values without urldecoding and you need to build a custom function to achieve what you are asking:
A simple function will return not encoded input is by using this function:
function get_params() {
$getData = $_SERVER['QUERY_STRING'];
$getParams = explode('&', $getData);
$getParameters = [];
foreach ($getParams as $getParam) {
$parsed = explode('=', $getParam);
$getParameters[$parsed[0]] = $parsed[1];
}
return $getParameters;
}
This solution can be used if you do not have any other option. By using this function you will always get the data encoded.
If you can encode the value from cleverreach then the best approach is to encode it there.
Encoding the value in cleverreach for email hello+world#bar.com will give you this url example.com/thanks?email=hello%2Bworld%40bar.com and in $_GET you will have the email containing the + sign.
I set up a custom registration page to my http server (apache) which hosts a number of services, including a wiki.
The intended goal is to have the user sign-up at once to all these services including the wiki of course.
For the wiki I'm trying to rearrange the "CreateAndPromote" maintenance script and fit it into my page. By now I came up with this snippet
$path = "/wiki";
putenv("MW_INSTALL_PATH={$path}");
require_once ("/wiki/includes/WebStart.php");
chdir("wiki");
$mediaWiki = new MediaWiki();
$name = $_POST['username'];
$pass = $_POST['password'];
$user = User::newFromName( $name );
if ( !is_object( $user ) ) {
die("Invalid user!\n");
}
$exists = ( 0 !== $user->idForName() );
if ( !$exists ) {
$user->addToDatabase();
}
try {
$user->setPassword( $pass );
} catch ( PasswordError $pwe ) {
die("password error:" . $pwe->getText()."");
}
$user->addGroup("editor");
$user->saveSettings();
$ssu = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
$ssu->doUpdate();
But i get
Error: LightnCandy class not defined
MediaWiki 1.25.2
PHP 5.6.12 (apache2handler)
The problem was simple as that:
declaring the MW_INSTALL_PATH like that apparently did not work
$path = "/wiki";
putenv("MW_INSTALL_PATH={$path}");
require_once ("/wiki/includes/WebStart.php");
so I had to change dir to the wiki BEFORE requiring the webstart.php
chdir("wiki");
require_once ("/includes/WebStart.php");
Every time I'm trying to login into dokuwiki with my LDAP credentials I'm getting the error below:
However once when I tried to log in with Internet Explorer rather than with Chrome I logged in successfully, but that never happened again.
Would someone please help me with configuring dokuwiki to authenticate users with LDAP credentials using AuthLDAP plugin.
Please see the content of conf/local.php file:
$conf['title'] = 'SomeNameOfDokuWiki';
$conf['license'] = '0';
$conf['useacl'] = 1;
$conf['authtype'] = 'authldap';
$conf['passcrypt'] = 'md5';
$conf['superuser'] = 'xander';
$conf['disableactions'] = 'register';
$conf['proxy']['user'] = 'SomeUserName';
$conf['proxy']['pass'] = 'SomeEncryptedPassword';
$conf['plugin']['authldap']['server'] = 'ldap://some.local.ip.address.129:389';
$conf['plugin']['authldap']['usertree'] = 'ou=Users,dc=example,dc=max,dc=net';
$conf['plugin']['authldap']['grouptree'] = 'ou=Groups,dc=xander,dc=max,dc=net';
$conf['plugin']['authldap']['userfilter'] = '(&(cn=%{user})(objectClass=inetOrgPerson))';
$conf['plugin']['authldap']['groupfilter'] = '(&(objectClass=posixGroup)(|(gidNumber=%{gid})(memberUID=%{user})))';
$conf['plugin']['authldap']['version'] = 3;
$conf['plugin']['authldap']['bindpw'] = 'SomeBindPassword';
$conf['plugin']['authldap']['userkey'] = 'cn';
$conf['plugin']['authldap']['debug'] = 1;
$conf['plugin']['authldap']['modPass'] = 0;
I'm sure that following queries are correct (I checked them through phpldapadmin):
(&(cn=%{user})(objectClass=inetOrgPerson))
(&(objectClass=posixGroup)(|(gidNumber=%{gid})(memberUID=%{user})))
Thanks.
I think perhaps you are missing this.
$conf['plugin']['authldap']['binddn'] = 'CN=ad user with enough rights to see other accounts,CN=Users,DC=yourdomain,DC=com';
I am a beginner in Joomla, I want to integrate Facebook login with my website (using Joomla 3.0), I want to know how to store the user info into my database after receiving them from facebook. Any suggestion?
Try this,
If you are using FB SDK for PHP
$path = realpath('.');
require_once($path."/facebook/fbmain.php");
$user = $facebook->getUser();
// print_r($user);
// echo "user<br/>";
// print_r($userInfo);
// echo "<br/>Info<br/>";
// print_r($fqlResult);
// foreach($fqlResult as $key=>$value){
// print_r($value);
// echo '<br>';
// }
// exit;
if ($user){
$fname = $userInfo['first_name'];
$last_name = $userInfo['last_name'];
$username = $userInfo['id'];
$dob = date("d-m-Y",strtotime($userInfo['birthday']));
foreach($fqlResult as $key=>$value);
$user_email = $value['email'];
$profile_image = $value['pic_square'];
$sex = $value['sex'];
$city = $value['hometown_location']['city'];
$state = $value['hometown_location']['state'];
$country = $value['hometown_location']['country'];
$zip = $value['hometown_location']['zip'];
//Then simply call model and write save db query.
$model = $this->getModel('Registration', 'UsersModel');
}
You want to make a FB authentication plugin and then have that pass off the data to the Joomla user plugin if possible. If you want to use a different user table you would need to make your own user plugin as well. Joomla auth first authenticates (authentication plugin), then authorsises, then logs in (user plugin)