Skocz do zawartości

Rekomendowane odpowiedzi

Opublikowano

Hej, mam problem, robię integracje kont (Konto z serwera oraz IPS 4). Kompletnie nie wiem co jest źle. Pokazuje się, że login lub hasło są nie prawidłowe, mimo tego, że dobrze wpisuję. Próbowałem robić te zapytanie w ->select i ->query ale ten sam efekt. Kod IPS 4:

		foreach ( \IPS\Db::i( 'amx_db' )->select( 'COUNT(*) as count', 'registersystem', array( 'ipsid=?', \IPS\Member::loggedIn()->member_id )) as $a ) {
			$row[] = $a;
		}
		if (!$row[0]) {
			$form = new \IPS\Helpers\Form( 'form', 'game_authorize');
			$form->addHeader(\IPS\Member::loggedIn()->language()->addToStack( 'Autoryzacja konta' ));
			$form->add( new \IPS\Helpers\Form\Text( 'game_auth_name', NULL, TRUE,
			array( 'minLength' => 2, 'maxLength' => 20), NULL, NULL, NULL, 'nazwa' ) );
			$form->add( new \IPS\Helpers\Form\Password('game_auth_pass', NULL, TRUE,
			array( 'minLength' => 2, 'maxLength' => 20 ), NULL, NULL, NULL, 'pass' ) );		
			
			if ($values = $form->values())
			{
                $qr = [];
				foreach(\IPS\Db::i( 'amx_db' )->query("SELECT * FROM registersystem WHERE Name='".\IPS\Request::i()->game_auth_name."' AND Password='".\IPS\Request::i()->game_auth_pass."'") as $c) {
					$qr[] = $c;
				}

                if (count($qr) == 0) {
                    $error = "Login lub hasło są nie prawidłowe.";
                } else {
                    $x3no = [];
					foreach( \IPS\Db::i( 'amx_db' )->select( '*', 'registersystem', array( 'Name="'.\IPS\Request::i()->game_auth_name.'" AND ipsid!="0"' ) ) as $h ) {
						$x3no[] = $h;
					}

                    if (count($x3no) > 0) {
                        $error = "Konto jest zintegrowane z innym uzytkownikiem";
                    } else {
                        \IPS\Db::i( 'amx_db' )->query("UPDATE registersystem SET ipsid=".\IPS\Member::loggedIn()->member_id." WHERE `Name` LIKE '".\IPS\Request::i()->game_auth_name."'");
                        $sukces = 1;
                    }
                }
                
                if (!empty($error)) {
                   \IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=amxpanel", 'front', 'main' ), \IPS\Member::loggedIn()->language()->addToStack($error) );
                } elseif ($sukces == 1) {
                    \IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=amxpanel", 'front', 'main' ), \IPS\Member::loggedIn()->language()->addToStack('Twoje konta zostały pomyślnie zintegrowane') );
                }
			}
			\IPS\Output::i()->output =  \IPS\Theme::i()->getTemplate( 'main' )->authArea($form);

Kod, który na IPB 3 działał:

                            if (!$check_integration['ipsid'] == $this->memberData['member_id']) {
                                $error = "<center><br/><br/><b>Masz już zintegrowane konto.</b></center>";
                            } else {
                                $this->registry->DB('amx_db')->build( array(
                                    'select' => '*',
                                    'from' => 'registersystem',
                                    'where' => 'Name="'.IPSText::parseCleanValue($_POST['user_nick']).'" AND Password="'.IPSText::parseCleanValue($_POST['user_pass']).'"'
                                ) );
                                $this->registry->DB('amx_db')->execute();
                                if ($this->registry->DB('amx_db')->getTotalRows() == 0) {
                                    $error = "<center><br/><br/><b>Login lub hasło są nie prawidłowe.</b></center>";
                                } else {
                                    $result = $this->registry->DB('amx_db')->buildAndFetch( array(
                                        'select' => '*',
                                        'from' => 'registersystem',
                                        'where' => 'Name="'.htmlentities($_POST['user_nick']).'" AND Password="'.md5(md5(htmlentities($_POST['user_pass']))).'"'
                                    ) );
                                    $this->registry->DB('amx_db')->execute();

                                    $query2 = $this->registry->DB('amx_db')->build( array(
                                        'select' => '*',
                                        'from' => 'registersystem',
                                        'where' => 'Name = "'.$_POST['user_nick'].'" AND ipsid != "0"'
                                    ) );
                                    $this->registry->DB('amx_db')->execute();
                                    if ($this->registry->DB('amx_db')->getTotalRows() > 0) {
                                        $error = "<center><br/><br/><b>Konto jest zintegrowane z innym uzytkownikiem.</b></center>";
                                    } else {
                                        $this->registry->DB('amx_db')->update( "registersystem", array('ipsid' => "".$this->memberData['member_id']."" ), 'Name="'.$_POST['user_nick'].'"' );
                                        $this->registry->DB('amx_db')->execute();
                                        $sukces = 1;
                                    }
                                }
                            }
                            if (isset($error)) {
                                $result = $error;
                            } elseif (isset($sukces)) {
                                $result = "<center><br/><br/><b>Twoje konta zostały pomyślnie zintegrowane!</b></center>";
                            }

                            $panel .= $result;

 

  • 1 miesiąc temu...
Opublikowano (edytowane)

Trochę zmieniłem:

		$check = \IPS\Db::i()->select(
			'id',
			'amx_rejestracja_konta',
			array('ipsid=?', \IPS\Member::loggedIn()->member_id)
		);
		$check = count($check);

			$form = new \IPS\Helpers\Form( 'form', 'amxPanel_auth');
			$form->addHeader(\IPS\Member::loggedIn()->language()->addToStack( 'amxPanel_auth_header' ));
			$form->add( new \IPS\Helpers\Form\Text( 'amxPanel_auth_name', NULL, TRUE,
			array( 'minLength' => 2, 'maxLength' => 20), NULL, NULL, NULL, 'nazwa' ) );
			$form->add( new \IPS\Helpers\Form\Password('amxPanel_auth_pass', NULL, TRUE,
			array( 'minLength' => 2, 'maxLength' => 20 ), NULL, NULL, NULL, 'pass' ) );

			if ($values = $form->values()) {
				$check_values = \IPS\Db::i()->select(
					'id',
					'amx_rejestracja_konta',
					array("Name=? AND Password=?", $values['amxPanel_auth_name'], $values['amxPanel_auth_pass'])
				)->first();
				if ($check_values['id']) {
					$check_authed = \IPS\Db::i()->select(
						'id',
						'amx_rejestracja_konta',
						array("Name=? AND ipsid=?",  $values['amxPanel_auth_name'], 0)
					)->first();
					if ($check_authed) {
						\IPS\Db::i()->update(
							'amx_rejestracja_konta',
							array( "Name=? AND ipsid=?",  $values['amxPanel_auth_name'], \IPS\Member::loggedIn()->member_id )
						)->first();
						\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=amxpanel", 'front', 'main' ), \IPS\Member::loggedIn()->language()->addToStack('Zautoryzowano konto.') );
					} else {
						\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=amxpanel", 'front', 'main' ), \IPS\Member::loggedIn()->language()->addToStack('Podane konto jest już zautoryzowane') );
					}
				} else {
					\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=amxpanel", 'front', 'main' ), \IPS\Member::loggedIn()->language()->addToStack('Podane dane są nieprawidłowe.') );
				}
			}
			\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'main' )->authArea($form);

Lecz po wpisaniu danych do formularza mam błąd nomessage związany z first():

UnderflowException thrown with message ""

Stacktrace:
#5 UnderflowException in /public_html/system/Db/Select.php:333
#4 IPS\Db\_Select:first in /public_html/applications/amxpanel/modules/front/main/index.php:44
#3 IPS\amxpanel\modules\front\main\_index:manage in /public_html/system/Dispatcher/Controller.php:96
#2 IPS\Dispatcher\_Controller:execute in /public_html/applications/amxpanel/modules/front/main/index.php:14
#1 IPS\amxpanel\modules\front\main\_index:execute in /public_html/system/Dispatcher/Dispatcher.php:129
#0 IPS\_Dispatcher:run in /public_html/index.php:1

Edytowane przez X3nO
  • Manager
Opublikowano
			try
			{
    			\IPS\Db::i()->update(
    				'amx_rejestracja_konta',
    				array( "Name=? AND ipsid=?",  $values['amxPanel_auth_name'], \IPS\Member::loggedIn()->member_id )
    			)->first();
			}
			catch( \UnderflowException $e )
			{
			}

 

intermedia - profesjonalne rozwiązania Invision Power Board

---

Chcesz uzyskać szybko i sprawnie pomoc? Uzupełnij wersję i adres w profilu.

Opublikowano
		$check = \IPS\Db::i()->select(
			'id',
			'amx_rejestracja_konta',
			array('ipsid=?', \IPS\Member::loggedIn()->member_id)
		);
		$check = count($check);

		if (!$check) {
			$form = new \IPS\Helpers\Form( 'form', 'amxPanel_auth');
			$form->addHeader(\IPS\Member::loggedIn()->language()->addToStack( 'amxPanel_auth_header' ));
			$form->add( new \IPS\Helpers\Form\Text( 'amxPanel_auth_name', NULL, TRUE,
			array( 'minLength' => 2, 'maxLength' => 20), NULL, NULL, NULL, 'nazwa' ) );
			$form->add( new \IPS\Helpers\Form\Password('amxPanel_auth_pass', NULL, TRUE,
			array( 'minLength' => 2, 'maxLength' => 20 ), NULL, NULL, NULL, 'pass' ) );

			if ($values = $form->values()) {
				try {
					$check_values = \IPS\Db::i()->select(
						'id',
						'amx_rejestracja_konta',
						array("Name=? AND Password=?", $values['amxPanel_auth_name'], $values['amxPanel_auth_pass'])
					)->first();
				}
				catch(\UnderflowException $e) {}
				if ($check_values['id']) {
					try {
						$check_authed = \IPS\Db::i()->select(
							'id',
							'amx_rejestracja_konta',
							array("Name=? AND ipsid=?",  $values['amxPanel_auth_name'], 0)
						)->first();
					}
					catch(\UnderflowException $e) {}
					if ($check_authed) {
						try {
    						\IPS\Db::i()->update(
    							'amx_rejestracja_konta',
    							array( "Name=? AND ipsid=?",  $values['amxPanel_auth_name'], \IPS\Member::loggedIn()->member_id )
    						)->first();
						}
						catch(\UnderflowException $e) {}
						\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=amxpanel", 'front', 'main' ), \IPS\Member::loggedIn()->language()->addToStack('Zautoryzowano konto.') );
					} else {
						\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=amxpanel", 'front', 'main' ), \IPS\Member::loggedIn()->language()->addToStack('Podane konto jest już zautoryzowane') );
					}
				} else {
					\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=amxpanel", 'front', 'main' ), \IPS\Member::loggedIn()->language()->addToStack('Podane dane są nieprawidłowe.') );
				}
			}
			\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'main' )->authArea($form);
} else {
//ZALOGOWANY
}

I wyświetla się wiadomość "Podane dane są nieprawidłowe." mimo wpisania dobrych ;/

Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto

Jedynie zarejestrowani użytkownicy mogą komentować zawartość tej strony.

Zarejestruj nowe konto

Załóż nowe konto. To bardzo proste!

Zarejestruj się

Zaloguj się

Posiadasz już konto? Zaloguj się poniżej.

Zaloguj się
  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...

Powiadomienie o plikach cookie

Umieściliśmy na Twoim urządzeniu pliki cookie, aby pomóc Ci usprawnić przeglądanie strony. Możesz dostosować ustawienia plików cookie, w przeciwnym wypadku zakładamy, że wyrażasz na to zgodę.