public function sociallogin_getapi($ApiSecrete) { $IsAuthenticated = false; $lr_settings = plgSystemSocialLoginTools::sociallogin_getsettings(); if (isset($_REQUEST['token'])) { $ValidateUrl = "https://hub.loginradius.com/userprofile.ashx?token=" . $_REQUEST['token'] . "&apisecrete=" . $ApiSecrete . ""; if ($lr_settings['useapi'] == 1) { $curl_handle = curl_init(); curl_setopt($curl_handle, CURLOPT_URL, $ValidateUrl); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($curl_handle, CURLOPT_TIMEOUT, 5); curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false); if (ini_get('open_basedir') == '' && (ini_get('safe_mode') == 'Off' or !ini_get('safe_mode'))) { curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true); } else { curl_setopt($curl_handle, CURLOPT_HEADER, 1); $url = curl_getinfo($curl_handle, CURLINFO_EFFECTIVE_URL); curl_close($curl_handle); $curl_handle = curl_init(); $url = str_replace('?', '/?', $url); curl_setopt($curl_handle, CURLOPT_URL, $url); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true); } $JsonResponse = curl_exec($curl_handle); $httpCode = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE); if (in_array($httpCode, array(400, 401, 403, 404, 500, 503, 0)) && $httpCode != 200) { return JTEXT::_('COM_LOGINRADIUS_SERVICE_AND_TIMEOUT_ERROR'); } else { if (curl_errno($curl_handle) == 28) { return JTEXT::_('COM_LOGINRADIUS_SERVICE_AND_TIMEOUT_ERROR'); } } $UserProfile = json_decode($JsonResponse); curl_close($curl_handle); if (isset($UserProfile->ID) && $UserProfile->ID != '') { $this->IsAuthenticated = true; return $UserProfile; } } else { $JsonResponse = @file_get_contents($ValidateUrl); if (strpos(@$http_response_header[0], "400") !== false || strpos(@$http_response_header[0], "401") !== false || strpos(@$http_response_header[0], "403") !== false || strpos(@$http_response_header[0], "404") !== false || strpos(@$http_response_header[0], "500") !== false || strpos(@$http_response_header[0], "503") !== false) { return JTEXT::_('COM_LOGINRADIUS_SERVICE_AND_TIMEOUT_ERROR'); } else { $UserProfile = json_decode($JsonResponse); if (isset($UserProfile->ID) && $UserProfile->ID != '') { $this->IsAuthenticated = true; return $UserProfile; } } } } }
public function sociallogin_getapi($ApiSecrete) { $IsAuthenticated = false; $lr_settings = plgSystemSocialLoginTools::sociallogin_getsettings(); if (isset($_REQUEST['token'])) { $ValidateUrl = "https://hub.loginradius.com/userprofile.ashx?token=" . $_REQUEST['token'] . "&apisecrete=" . $ApiSecrete . ""; if ($lr_settings['useapi'] == 1) { $curl_handle = curl_init(); curl_setopt($curl_handle, CURLOPT_URL, $ValidateUrl); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 3); curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false); if (ini_get('open_basedir') == '' && (ini_get('safe_mode') == 'Off' or !ini_get('safe_mode'))) { curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true); $JsonResponse = curl_exec($curl_handle); } else { curl_setopt($curl_handle, CURLOPT_HEADER, 1); $url = curl_getinfo($curl_handle, CURLINFO_EFFECTIVE_URL); curl_close($curl_handle); $ch = curl_init(); $url = str_replace('?', '/?', $url); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $JsonResponse = curl_exec($ch); curl_close($ch); } $UserProfile = json_decode($JsonResponse); } else { $JsonResponse = file_get_contents($ValidateUrl); $UserProfile = json_decode($JsonResponse); } if (isset($UserProfile->ID) && $UserProfile->ID != '') { $this->IsAuthenticated = true; return $UserProfile; } } }
public static function check_exist_comk2($user_id, $username, $profile_Image, $userImage, $lrdata) { $lr_settings = plgSystemSocialLoginTools::sociallogin_getsettings(); JPlugin::loadLanguage('com_k2'); JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'tables'); $row =& JTable::getInstance('K2User', 'Table'); $k2id = self::getK2UserID($user_id); JRequest::setVar('id', $k2id, 'post'); $row->bind(JRequest::get('post')); $row->set('userID', $user_id); $row->set('userName', $username); $row->set('ip', $_SERVER['REMOTE_ADDR']); $row->set('hostname', gethostbyaddr($_SERVER['REMOTE_ADDR'])); $row->set('notes', ''); $row->set('group', trim($lr_settings['k2group'])); if ($lrdata['gender'] == 'M' or $lrdata['gender'] == 'm' or $lrdata['gender'] == 'Male' or $lrdata['gender'] == 'male') { $lrdata['gender'] = 'm'; } else { if ($lrdata['gender'] == 'F' or $lrdata['gender'] == 'f' or $lrdata['gender'] == 'Female' or $lrdata['gender'] == 'female') { $lrdata['gender'] = 'f'; } } $row->set('gender', $lrdata['gender']); $row->set('url', $lrdata['website']); $row->set('description', $lrdata['aboutme']); $savepath = JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'users' . DS; self::insert_user_picture($savepath, $profile_Image, $userImage); $row->set('image', $userImage); $row->store(); }
function _sendMail(&$user, $usermessgae) { // Compile the notification mail values. $lr_settings = plgSystemSocialLoginTools::sociallogin_getsettings (); $config = JFactory::getConfig(); $data = $user->getProperties(); $data['fromname'] = $config->get('fromname'); $data['mailfrom'] = $config->get('mailfrom'); $data['sitename'] = $config->get('sitename'); $data['siteurl'] = JUri::base(); $uri = JURI::getInstance(); $base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port')); $data['activate'] = $base.JRoute::_('index.php?option=com_users&task=registration.activate&token='.$data['activation'], false); $emailSubject = JText::sprintf('COM_USERS_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']); if($usermessgae == 1) { $emailBody = JText::sprintf('COM_SOCIALLOGIN_EMAIL_REGISTERED_WITH_ADMIN_ACTIVATION_BODY', $data['name'], $data['sitename'], $data['siteurl'].'index.php?option=com_users&task=registration.activate&token='.$data['activation'], $data['siteurl'], $data['username'], $data['password_clear']); } else if ($usermessgae == 2) { $emailBody = JText::sprintf('COM_SOCIALLOGIN_SEND_MSG', $data['name'], $data['sitename'], $data['siteurl'].'index.php', $data['username'],$data['password_clear']); } else if ($usermessgae == 3) { $emailBody = JText::sprintf('COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY', $data['name'], $data['sitename'], $data['siteurl'].'index.php?option=com_users&task=registration.activate&token='.$data['activation'], $data['siteurl'], $data['username'], $data['password_clear']); } // Send the registration email. $return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $data['email'], $emailSubject, $emailBody); // Check for an error. if ($return !== true) { $this->setError(JText::_('COM_USERS_REGISTRATION_SEND_MAIL_FAILED')); // Send a system message to administrators receiving system mails $db = JFactory::getDBO(); $q = "SELECT id FROM #__users WHERE block = 0 AND sendEmail = 1"; $db->setQuery($q); $sendEmail = $db->loadColumn(); if (count($sendEmail) > 0) { $jdate = new JDate(); // Build the query to add the messages $q = "INSERT INTO `#__messages` (`user_id_from`, `user_id_to`, `date_time`, `subject`, `message`) VALUES "; $messages = array(); foreach ($sendEmail as $userid) { $messages[] = "(".$userid.", ".$userid.", '".$jdate->toSql()."', '".JText::_('COM_USERS_MAIL_SEND_FAILURE_SUBJECT')."', '".JText::sprintf('COM_USERS_MAIL_SEND_FAILURE_BODY', $return, $data['username'])."')"; } $q .= implode(',', $messages); $db->setQuery($q); $db->execute(); } return false; } elseif ($usermessgae == 2) { $db = JFactory::getDBO(); // get all admin users $query = 'SELECT name, email, sendEmail' . ' FROM #__users' . ' WHERE sendEmail=1'; $db->setQuery( $query ); $rows = $db->loadObjectList(); // Send mail to all superadministrators id foreach ( $rows as $row ) { JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $row->email, $emailSubject, JText::sprintf('COM_SOCIALLOGIN_SEND_MSG_ADMIN', $row->name, $data['sitename'], $data['siteurl'], $data['email'], $data['username'], $data['password_clear'])); } } return false; }