Error in Reset password joomla 3.0 - passwords

I am facing a problem in joomla 3.0 when i go to reset page after verify code url is ../index.php/registration?view=reset&layout=complete.
The scenario is: fill different values in password and conform password. Then submit form, the error is:
Notice
Completing reset password failed: exception 'UnexpectedValueException' with message 'The passwords you entered do
not match. Please enter your desired password in the password field
and confirm your entry by entering it in the confirm password field.'
in
/home/fiable/public_html/projects/canvasfast/libraries/joomla/form/form.php:1872
Stack trace: #0
/home/fiable/public_html/projects/canvasfast/libraries/joomla/form/form.php(1105):
JForm->validateField(Object(SimpleXMLElement), '', 'dfdefsdfdfdfdf',
Object(JRegistry)) #1
/home/fiable/public_html/projects/canvasfast/components/com_users/models/reset.php(122):
JForm->validate(Array) #2
/home/fiable/public_html/projects/canvasfast/components/com_users/controllers/reset.php(156):
UsersModelReset->processResetComplete(Array) #3
/home/fiable/public_html/projects/canvasfast/libraries/legacy/controller/legacy.php(722): UsersControllerReset->complete() #4
/home/fiable/public_html/projects/canvasfast/components/com_users/users.php(15):
JControllerLegacy->execute('complete') #5
/home/fiable/public_html/projects/canvasfast/libraries/legacy/component/helper.php(359):
require_once('/home/fiable/pu...') #6
/home/fiable/public_html/projects/canvasfast/libraries/legacy/component/helper.php(339):
JComponentHelper::executeComponent('/home/fiable/pu...') #7
/home/fiable/public_html/projects/canvasfast/includes/application.php(205):
JComponentHelper::renderComponent('com_users') #8
/home/fiable/public_html/projects/canvasfast/index.php(52):
JSite->dispatch() #9 {main}

tested in joomla 3.0 go to the line 130 components\com_users\models\reset.php
replace bellow code:
// Check the validation results.
if ($return === false) {
// Get the validation messages from the form.
foreach ($form->getErrors() as $message) {
$this->setError($message);
}
return false;
}
to:
// Check the validation results.
if ($return === false) {
$errors = $form->getErrors();
for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) {
if ($errors[$i] instanceof Exception) {
$this->setError($errors[$i]->getMessage());
} else {
$this->setError($errors[$i]);
}
}
return false;
}

Related

Passing variables to fpdf

I have a problem with passing variables to fpdf. First script is getting post text sent to filtering class, the class is returning filtered POST-s as a 2 element array. First script looks like this:
include('service.php');
include('pdf.php');
$pdf_filter = new Pdf_filter;
$filter = $pdf_filter->pdfFilter();
var_dump($filter);
extract($filter);
I'm extracting $filter array to get variables from it (filtering script is creating variables of the POST that are sent and I can echo them so I don't know if this is even necessary).
The second script looks like this:
require('E:\Xampp\php\fpdf181\fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',12);
$pdf->Cell(195,5, $tytul, 0,1,'C');
$pdf->Cell(195,5, $petycja, 0,1,'C');
$pdf->Output();
and I'm getting this error:
Notice: Undefined variable: tytul in E:\Xampp\htdocs\php\bazy_danych\obiektowe\my\pdf.php on line 10
Notice: Undefined variable: petycja in E:\Xampp\htdocs\php\bazy_danych\obiektowe\my\pdf.php on line 11
Fatal error: Uncaught exception 'Exception' with message 'FPDF error: Some data has already been output, can't send PDF file' in E:\Xampp\php\fpdf181\fpdf.php:271
Stack trace: #0 E:\Xampp\php\fpdf181\fpdf.php(1063): FPDF->Error('Some data has a...')
#1 E:\Xampp\php\fpdf181\fpdf.php(999): FPDF->_checkoutput()
#2 E:\Xampp\htdocs\php\bazy_danych\obiektowe\my\pdf.php(12): FPDF->Output()
#3 E:\Xampp\htdocs\php\bazy_danych\obiektowe\my\test.php(3): include('E:\\Xampp\\htdocs...')
#4 {main} thrown in E:\Xampp\php\fpdf181\fpdf.php on line 271
How should I pass the variables? Interesting: it works if I use the unfiltered $_POST with the following code:
require('E:\Xampp\php\fpdf181\fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',12);
$pdf->Cell(195,5, $_POST['tytul'], 0,1,'C');
$pdf->Cell(195,5, $_POST['petycja'], 0,1,'C');
$pdf->Output();
EDIT: I will post the initial form and filtering function:
Form:
<form action="test.php" method="POST">
Wpisz tytuł petycji (35 znaków):<br>
<input type="text" name="tytul" maxlength="35" size="35" placeholder="Tytuł petycji" required><br>
Wpisz treść petycji (500 znaków):<br>
<textarea name="petycja" maxlength="500" rows="4" cols="50" placeholder="Treść petycji" required></textarea><br>
<input type="submit" value="Napisz petycje">
</form>
Filtering function:
class Pdf_filter{
protected $title;
protected $text;
public function pdfFilter(){
if (isset($_POST)){
foreach ($_POST as $key => $val) {
$filterVal = strip_tags($val);
$filterVal = htmlspecialchars($filterVal);
$filterVal = stripslashes($filterVal);
$filterVal = str_replace("\\", "", $filterVal);
$filter = array($key => $filterVal);
foreach ($filter as $key => $val) {
echo "[$$key]";
echo "$val<br>";
${$key} = $val;
}
}
if(!preg_match("/^[\sa-zA-ZĄĆĘŁŃÓŚŹŻąćęłńóśźż0-9-_,.:\'?()]+$/", $tytul)){
echo "Niedozwolone znaki $tytul!";
exit();
}
elseif(!preg_match("/^[\sa-zA-ZĄĆĘŁŃÓŚŹŻąćęłńóśźż0-9-_,.:\'?()]+$/", $petycja)){
echo "Niedozwolone znaki $petycja!";
exit();
}
else{
return $filter = array('tytul'=>$tytul,'petycja'=>$petycja);
}
}
else{
echo "Proszę wypełnić wszytskie pola!";
}
}
}
Well I am dumb. The problem was related with class variables. Code that happened to work for me:
class Pdf extends FPDF{
protected $filter;
protected $tytul;
protected $petycja;
public function __construct($filter){
$this->filter = extract($filter);
$this->tytul = $tytul;
$this->petycja = $petycja;
}
public function tytul(){
return $this->tytul;
}
public function petycja(){
return $this->petycja;
}
public function dokument(){
parent::__construct();
$this->AddPage();
$this->SetFont('Arial','B',15);
$this->Cell(195,5, $this->tytul, 0,1,'C');
$this->Cell(195,5, $this->petycja, 0,1,'C');
$this->Output();
}
}
Now I need to think of a way to display polish symbols in fpdf and line breaks (but that maybe done with text editor isntead of just textbox).

I am stuck, mysqli_query() expects at least 2 parameters

I have a problem with a code in php it shows me this as errors.
register
mysqli_query() expects at least 2 parameters, 1 given in
C:\xampp\htdocs\search_engine\insert.php on line 99
And this is the code :
<?php
$db = new PDO('mysql:host=localhost;dbname=srgn;charset=utf8mb4', 'root', '123456');
if(isset($_POST["submit"]))
{
$s_link = $_POST["s_link"];
$s_key = $_POST["s_key"];
$s_des = $_POST["s_des"];
{
$sql = "insert(site_link, site_key, site_des) values('$s_link', '$s_key', '$s_des')";
$rs = mysqli_query($sql);
if($rs)
{
echo "<script> alert('Site uploaded successfully') </script>";
}
else
{
echo "<script> alert('Uploading failed, please try agin.') </script>";
}
}
}
?>
Where is the error please, and how can I set it?
Pass on the connection link as the first parameter and the SQL query as the second parameter. This is required as you are doing procedural code. Refer to the link below for more details
http://php.net/manual/en/mysqli.query.php

Predis error when using pipeline with redis-cluster

i try to add a key-value-pair in my redis-cluster and set expire for the new key in one pipeline. Every time i get an error that the key is moved, but i think that Predis should follow the MOVED-statement like without pipelining.
Isn't it possible to make an expire-call in the pipe? I'm using Predis 1.0.2-dev
with redis_version: 3.0.2
This works:
$parameters = ['tcp://10.9.200.51:47801', 'tcp://10.9.200.52:47801', 'tcp://10.9.200.53:47801', 'tcp://10.9.200.54:47801'];
$options = ['cluster' => 'redis'];
$redis = new Predis\Client($parameters, $options);
for($i = 0; $i < 10; $i++)
{
$rand = mt_rand(1111111,9999999);
$k = 'test_'.$rand;
try{
$redis->set($k, 1);
$redis->expire($k, 10);
}
catch(Exception $ex)
{
print_r($ex);
}
}
?>
This does not work:
$parameters = ['tcp://10.9.200.51:47801', 'tcp://10.9.200.52:47801', 'tcp://10.9.200.53:47801', 'tcp://10.9.200.54:47801'];
$options = ['cluster' => 'redis'];
$redis = new Predis\Client($parameters, $options);
$pipe = $redis->pipeline();
for($i = 0; $i < 10; $i++)
{
$rand = mt_rand(1111111,9999999);
$k = 'test_'.$rand;
try{
$pipe->set($k, 1);
$pipe->expire($k, 10);
}
catch(Exception $ex)
{
print_r($ex);
}
}
$pipe->execute();
?>
I get this error:
PHP Fatal error: Uncaught exception 'Predis\Response\ServerException' with message 'MOVED 7276 10.9.200.61:47902' in /var/www/predis_test/Predis/Pipeline/Pipeline.php:105
Stack trace:
#0 /var/www/predis_test/Predis/Pipeline/Pipeline.php(149): Predis\Pipeline\Pipeline->exception(Object(Predis\Connection\Aggregate\RedisCluster), Object(Predis\Response\Error))
#1 /var/www/predis_test/Predis/Pipeline/Pipeline.php(168): Predis\Pipeline\Pipeline->executePipeline(Object(Predis\Connection\Aggregate\RedisCluster), Object(SplQueue))
#2 /var/www/predis_test/Predis/Pipeline/Pipeline.php(217): Predis\Pipeline\Pipeline->flushPipeline()
#3 /var/www/predis_test/lasttest.php(31): Predis\Pipeline\Pipeline->execute()
#4 {main}
thrown in /var/www/predis_test/Predis/Pipeline/Pipeline.php on line 105
EDIT: Seems that pipelining doens't work on redis-cluster. I get the same error when I remove the expire call and have only the set call in a pipe.
Predis pipeline requires the keys in the same SLOT in cluster(for cluster support auto sharding), which makes it hard for client to handle received moved message from redis cluster server.
More details please refer to the following issue and discussion:
Issue: Pipelining with redis-cluster throws exception #267
Discussion: Redis Cluster with Pipeline
The Conclusion is: do not use pipeline under redis cluster.

Getting error messages from gmail api batch request

I am trying to get gmail attachments using batch requests on the gmail API. It sometimes works, but if I rerun it, I'll get errors a large percentage of the time. I'd like to catch the errors and take appropriate action - like exponential backoff, which will (hopefully) fix the problem. But it's not working.
Here is the code:
for ($n = 0; $n < 5; ++$n) {
try {
$results = $batch->execute();
break;
} catch (Google_Service_Exception $e) {
if ($e->getError() != '') { //placeholder
// Apply exponential backoff.
usleep((1 << $n) * 1000 + rand(0, 1000));
}
}
}
for ($i=1; $i < $stop+1; $i++) {
$message = $results['response-'.$i];
if ($message2->getPayload()) { ...
The error logs show that sometimes I'm immediately trying to call Google_Service_Exception::getPayload. It's as if each response in the batch was itself a Google_Service_Exception object, or at least the first one.
How do I catch errors in a batch?

i am having a issue with json codeigniter rest its not closing the tag

i am having a problem with json codeigniter rest
i am making this call to the server and the problem its that its not closing the json tags
s, USA","clientUID":"7","email":null,"idipad":"2","dateModified":null},{"id":"19","uid":null,"name":"Wayne Corporation, Inc.","phone":"932345324","address":"Second st. 312, Gotham City","clientUID":"7","email":"waynecorp#gmail.com","idipad":"1","dateModified":null}]
its missing the final }
this is the code that creates the response :
$this->response(array('login'=>'login success!','user_admin_id'=>$user_id,'client'=>$client,'users'=>$users,'projects'=>$projects,'plans'=>$plans,'meetings'=>$meetings,'demands'=>$demands,'tasks'=>$tasks,'presences'=>$presences,'contractors'=>$contractors,'companies'=>$companies), 200);
this is the client call using curl :
$this->curl->create('http://dev.onplans.ch/onplans/index.php/api/example/login/format/json');
// Option & Options
$this->curl->option(CURLOPT_BUFFERSIZE, 10);
$this->curl->options(array(CURLOPT_BUFFERSIZE => 10));
// More human looking options
$this->curl->option('buffersize', 10);
// Login to HTTP user authentication
$this->curl->http_login('admin', '1234');
// Post - If you do not use post, it will just run a GET request
//$post = array('remember'=>'true','email'=>'admin.architect#onplans.ch','password'=>'password');
$post = array('remember'=>'true','email'=>'admin.architect#onplans.ch','password'=>'password');
$this->curl->post($post);
// Cookies - If you do not use post, it will just run a GET request
$vars = array('remember'=>'true','email'=>'manuel#ffff.com','password'=>'password');
$this->curl->set_cookies($vars);
// Proxy - Request the page through a proxy server
// Port is optional, defaults to 80
//$this->curl->proxy('http://example.com', 1080);
//$this->curl->proxy('http://example.com');
// Proxy login
//$this->curl->proxy_login('username', 'password');
// Execute - returns responce
echo $this->curl->execute();
// Debug data ------------------------------------------------
// Errors
$this->curl->error_code; // int
$this->curl->error_string;
print_r('error :::::LOGINN REMOTE:::::'.$this->curl->error_string);
// Information
$this->curl->info; // array
print_r('info :::::::::::::'.$this->curl->info);
the response belong to the rest api codeigniter from phil
/**
* Response
*
* Takes pure data and optionally a status code, then creates the response.
*
* #param array $data
* #param null|int $http_code
*/
public function response($data = array(), $http_code = null)
{
global $CFG;
// If data is empty and not code provide, error and bail
if (empty($data) && $http_code === null)
{
$http_code = 404;
// create the output variable here in the case of $this->response(array());
$output = NULL;
}
// If data is empty but http code provided, keep the output empty
else if (empty($data) && is_numeric($http_code))
{
$output = NULL;
}
// Otherwise (if no data but 200 provided) or some data, carry on camping!
else
{
// Is compression requested?
if ($CFG->item('compress_output') === TRUE && $this->_zlib_oc == FALSE)
{
if (extension_loaded('zlib'))
{
if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) AND strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE)
{
ob_start('ob_gzhandler');
}
}
}
is_numeric($http_code) OR $http_code = 200;
// If the format method exists, call and return the output in that format
if (method_exists($this, '_format_'.$this->response->format))
{
// Set the correct format header
header('Content-Type: '.$this->_supported_formats[$this->response->format]);
$output = $this->{'_format_'.$this->response->format}($data);
}
// If the format method exists, call and return the output in that format
elseif (method_exists($this->format, 'to_'.$this->response->format))
{
// Set the correct format header
header('Content-Type: '.$this->_supported_formats[$this->response->format]);
$output = $this->format->factory($data)->{'to_'.$this->response->format}();
}
// Format not supported, output directly
else
{
$output = $data;
}
}
header('HTTP/1.1: ' . $http_code);
header('Status: ' . $http_code);
// If zlib.output_compression is enabled it will compress the output,
// but it will not modify the content-length header to compensate for
// the reduction, causing the browser to hang waiting for more data.
// We'll just skip content-length in those cases.
if ( ! $this->_zlib_oc && ! $CFG->item('compress_output'))
{
header('Content-Length: ' . strlen($output));
}
exit($output);
}
This answer was referenced from Github issue. Also raised by Pedro Dinis, i guest.
I met this problem today and take me long hours to search for the solution. I share here with hope to help someone like me.
The key is to replace around line 430 in the library file: REST_Controller.php :
header('Content-Length: ' . strlen($output));
by
header('Content-Length: ' . strlen("'".$output."'"));
UPDATE: The problem was solved here
Or you can just comment out the code, it will run fine. :)