Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> integracja aplikacji z phpbb3, dodanie konta uzytkownika forum z innej aplikacji
r3dsky
post
Post #1





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 18.12.2009

Ostrzeżenie: (0%)
-----


Witam

Problem mam nastepujący pisze aplikacje i musze dodac kawalek kodu ktory przy rejestracji w mojej aplikacji bedzie tworzyl kontu usera w phpbb3 udalo mi sie dodac usera dodajac username,username_clean i user_password (zahashowany wg algorytmu phpbb3)
po dodaniu usera moge zalogowac sie do forum wiec jest sukces
ale niestety nie mam do niego dostepu tzn
w miejscu gdzie powinny byc dzialy tematy itd pojawia mi sie napis This board has no forums.

moge prosic o jakies wskazówki ? moze ktos sie juz tym zajmowal i wie na co nalezy zwrocic uwage.

Dzieki z gory

Ten post edytował r3dsky 15.01.2010, 15:06:39
Go to the top of the page
+Quote Post
pgrzelka
post
Post #2





Grupa: Zarejestrowani
Postów: 313
Pomógł: 24
Dołączył: 9.08.2008
Skąd: Kielce

Ostrzeżenie: (0%)
-----


jest w google gotowa klasa do integracji phpbb3, wiem bo robiłem jakiś czas temu taką integrację, nawet logowanie mi działało, musisz poszukać bo ja nie mam już dostępu do tamtego serwisu.
Go to the top of the page
+Quote Post
paBlas16
post
Post #3





Grupa: Zarejestrowani
Postów: 45
Pomógł: 3
Dołączył: 27.09.2009
Skąd: Toruń

Ostrzeżenie: (0%)
-----


A czy mógłbyś jakoś podpowiedzieć dokładnie gdzie szukać tej klasy. Co wpisać w google b ja tego szukam już od chyba miesiąca i nic. Byłbym bardzo wdzięczny.
Go to the top of the page
+Quote Post
pgrzelka
post
Post #4





Grupa: Zarejestrowani
Postów: 313
Pomógł: 24
Dołączył: 9.08.2008
Skąd: Kielce

Ostrzeżenie: (0%)
-----


to jest ta klasa, trochę przerobiona (IMG:style_emoticons/default/winksmiley.jpg)

  1. <?php
  2.  
  3. class Zadoo_Phpbb{
  4.  
  5. protected $table_fields = array();
  6.  
  7. public static function getInstance()
  8. {
  9. static $instance;
  10. if(!isset($instance)) {
  11. $instance = new Zadoo_Phpbb;
  12. }
  13. return $instance;
  14. }
  15.  
  16. public function __construct()
  17. {
  18. global $phpbb_root_path, $phpEx, $db, $config, $user, $auth, $cache, $template;
  19.  
  20. define('IN_PHPBB', true);
  21.  
  22. $phpbb_root_path = APPLICATION_ROOT . '/forum/';
  23. $phpEx = 'php';
  24.  
  25. $this->instance = $this;
  26. }
  27.  
  28.  
  29. function init($prepare_for_login = false)
  30. {
  31. global $phpbb_root_path, $phpEx, $db, $config, $user, $auth, $cache, $template;
  32.  
  33. if($prepare_for_login && !defined("IN_LOGIN")) define("IN_LOGIN", true);
  34.  
  35. require_once($phpbb_root_path.'common.'.$phpEx);
  36.  
  37. $user->session_begin();
  38. $auth->acl($user->data);
  39. }
  40.  
  41.  
  42. public function user_login($phpbb_vars)
  43. {
  44. global $phpbb_root_path, $phpEx, $db, $config, $user, $auth, $cache, $template;
  45. $phpbb_result = "FAIL";
  46.  
  47. $this->init(true);
  48.  
  49. if(!isset($phpbb_vars["autologin"])) $phpbb_vars["autologin"] = false;
  50. if(!isset($phpbb_vars["viewonline"])) $phpbb_vars["viewonline"] = 1;
  51. if(!isset($phpbb_vars["admin"])) $phpbb_vars["admin"] = 0;
  52.  
  53. $validation = login_db($phpbb_vars["username"], $phpbb_vars["password"]);
  54. if($validation['status'] == 3 && $auth->login($phpbb_vars["username"], $phpbb_vars["password"], $phpbb_vars["autologin"], $phpbb_vars["viewonline"], $phpbb_vars["admin"])) $phpbb_result = "SUCCESS";
  55.  
  56. return $phpbb_result;
  57. }
  58.  
  59. //user_logout
  60. public function user_logout(){
  61. global $phpbb_root_path, $phpEx, $db, $config, $user, $auth, $cache, $template;
  62. //prezumtia de fail
  63. $phpbb_result = "FAIL";
  64.  
  65. //general info
  66. $this->init(true);
  67.  
  68. //session management
  69. $user->session_begin();
  70. $auth->acl($user->data);
  71.  
  72. //destroy session if needed
  73. if($user->data['user_id'] != ANONYMOUS){
  74. $user->session_kill();
  75. $user->session_begin();
  76. $phpbb_result = "SUCCESS";
  77. }
  78.  
  79. return $phpbb_result;
  80. }
  81.  
  82. //user_loggedin
  83. function user_loggedin(){
  84. global $phpbb_root_path, $phpEx, $db, $config, $user, $auth, $cache, $template;
  85. //fail presumtion
  86. $phpbb_result = "FAIL";
  87.  
  88. //general info
  89. $this->init(false);
  90.  
  91. //session management
  92. $user->session_begin();
  93.  
  94. if(is_array($user->data) && isset($user->data["user_id"]) && $user->data["user_id"] > 0) $phpbb_result = "SUCCESS";
  95.  
  96. return $phpbb_result;
  97. }
  98.  
  99. //user_add
  100. public function user_add($phpbb_vars){
  101. global $phpbb_root_path, $phpEx, $db, $config, $user, $auth, $cache, $template;
  102. //fail presumtion
  103. $phpbb_result = "FAIL";
  104.  
  105. //if the mandatory parameters are not given fail
  106. if(trim(@$phpbb_vars['username']) == '' || !isset($phpbb_vars['group_id']) || !isset($phpbb_vars['user_email']))
  107. return $phpbb_result;
  108.  
  109. //general info
  110. $this->init(false);
  111.  
  112. //user functions
  113. require_once($phpbb_root_path ."includes/functions_user.".$phpEx);
  114.  
  115. //default user info
  116. $user_row = array(
  117. "username" => $phpbb_vars["username"],
  118. "user_password" => phpbb_hash($phpbb_vars["password"]),
  119. "user_email" => $phpbb_vars["user_email"],
  120. "group_id" => !isset($phpbb_vars["group_id"])?"2":$phpbb_vars["group_id"],
  121. "user_timezone" => "2.00",
  122. "user_dst" => 0,
  123. "user_lang" => "ro",
  124. "user_type" => !isset($phpbb_vars["user_type"])?"0":$phpbb_vars["user_type"],
  125. "user_actkey" => "",
  126. "user_dateformat" => "D M d, Y g:i a",
  127. "user_style" => "1",
  128. "user_regdate" => time(),
  129. "user_colour" => "9E8DA7",
  130. );
  131.  
  132. //replace default values with the ones in phpbb_vars array (not yet tested / implemented)
  133. //foreach($user_row as $key => $value) if(isset($phpbb_vars[$key])) $user_row[$key] = $phpbb_vars[$key];
  134.  
  135. //register user
  136. if($phpbb_user_id = user_add($user_row)) $phpbb_result = "SUCCESS";
  137.  
  138. //update the rest of the fields
  139. $this->user_update($phpbb_vars);
  140.  
  141. return $phpbb_result;
  142. }
  143.  
  144. //user_delete
  145. public function user_delete($phpbb_vars){
  146. global $phpbb_root_path, $phpEx, $db, $config, $user, $auth, $cache, $template;
  147. //fail presumtion
  148. $phpbb_result = "FAIL";
  149.  
  150. //general info
  151. $this->init(false);
  152.  
  153. //user functions
  154. require_once($phpbb_root_path ."includes/functions_user.".$phpEx);
  155.  
  156. //get user_id if possible
  157. if(!isset($phpbb_vars["user_id"]))
  158. if(!$phpbb_vars["user_id"] = $this->get_user_id_from_name($phpbb_vars["username"]))
  159. return $phpbb_result;
  160.  
  161. //delete user (always returns false)
  162. user_delete("remove", $phpbb_vars["user_id"]);
  163. $phpbb_result = "SUCCESS";
  164.  
  165. return $phpbb_result;
  166. }
  167.  
  168. //user_update
  169. public function user_update($phpbb_vars){
  170. global $phpbb_root_path, $phpEx, $db, $config, $user, $auth, $cache, $template;
  171. //fail presumtion
  172. $phpbb_result = "FAIL";
  173.  
  174. //general info
  175. $this->init(false);
  176.  
  177. //user functions
  178. require_once($phpbb_root_path ."includes/functions_user.".$phpEx);
  179.  
  180. //get user_id if possible
  181. if(!isset($phpbb_vars["user_id"]))
  182. if(!$phpbb_vars["user_id"] = $this->get_user_id_from_name($phpbb_vars["username"]))
  183. return $phpbb_result;
  184.  
  185.  
  186. $this->get_table_fields(USERS_TABLE);
  187. $ignore_fields = array("username", "user_id");
  188.  
  189. if(isset($phpbb_vars["user_password"])) $phpbb_vars["user_password"] = phpbb_hash($phpbb_vars["user_password"]);
  190. if(isset($phpbb_vars["user_newpasswd"])) $phpbb_vars["user_newpasswd"] = phpbb_hash($phpbb_vars["user_newpasswd"]);
  191. $sql = "";
  192. //generate sql
  193. for($i = 0;$i < count($this->table_fields[USERS_TABLE]); $i++)
  194. if(isset($phpbb_vars[$this->table_fields[USERS_TABLE][$i]]) && !in_array($this->table_fields[USERS_TABLE][$i], $ignore_fields))
  195. $sql .= ", ".$this->table_fields[USERS_TABLE][$i]." = '".$db->sql_escape($phpbb_vars[$this->table_fields[USERS_TABLE][$i]])."'";
  196.  
  197. if(strlen($sql) != 0){
  198. $db->sql_query("UPDATE ".USERS_TABLE." SET ".substr($sql, 2)." WHERE user_id = '".$phpbb_vars["user_id"]."'");
  199. $phpbb_result = "SUCCESS";
  200. }
  201.  
  202. return $phpbb_result;
  203. }
  204.  
  205. //user_change_password
  206. public function user_change_password($phpbb_vars){
  207. global $phpbb_root_path, $phpEx, $db, $config, $user, $auth, $cache, $template;
  208. //fail presumtion
  209. $phpbb_result = "FAIL";
  210.  
  211. //general info
  212. $this->init(false);
  213.  
  214. //user functions
  215. require_once($phpbb_root_path ."includes/functions_user.".$phpEx);
  216.  
  217. //get user_id if possible
  218. if(!isset($phpbb_vars["user_id"]))
  219. if(!$phpbb_vars["user_id"] = $this->get_user_id_from_name($phpbb_vars["username"]))
  220. return $phpbb_result;
  221.  
  222. $db->sql_query("UPDATE ".USERS_TABLE." SET user_password = '".phpbb_hash($phpbb_vars["password"])."' WHERE user_id = '".$phpbb_vars["user_id"]."'");
  223. $phpbb_result = "SUCCESS";
  224.  
  225. return $phpbb_result;
  226. }
  227.  
  228. private function get_table_fields($table){
  229. //if already got table fields once
  230. if(isset($this->table_fields[$table])) return true;
  231.  
  232. global $phpbb_root_path, $phpEx, $db, $config, $user, $auth, $cache, $template;
  233.  
  234. //general info
  235. $this->init(false);
  236.  
  237. //get table fields
  238. $this->table_fields[$table] = array();
  239. if(!$result = $db->sql_query("SHOW FIELDS FROM ".$table)) return false;
  240. while($row = $db->sql_fetchrow($result)) $this->table_fields[$table][] = $row["Field"];
  241. $db->sql_freeresult($result);
  242.  
  243. return true;
  244. }
  245.  
  246. //get user id if we know username
  247. public function get_user_id_from_name($username){
  248. global $phpbb_root_path, $phpEx, $db, $config, $user, $auth, $cache, $template;
  249.  
  250. //user functions
  251. require_once($phpbb_root_path ."includes/functions_user.".$phpEx);
  252.  
  253. $user_id = false;
  254. if(!isset($username)) return false;
  255. user_get_id_name($user_id, $username);
  256. if(!isset($user_id[0])) return false;
  257. return $user_id[0];
  258. }
  259. }
  260. ?>


i adapter logowania dla zend frameworka mojego autorstwa
  1. <?php
  2.  
  3. class Zadoo_Auth_Adapter_Phpbb implements Zend_Auth_Adapter_Interface {
  4.  
  5. protected $username;
  6. protected $password;
  7.  
  8. public function setPassword($password)
  9. {
  10. $this->password = $password;
  11. }
  12.  
  13. public function setUsername($username)
  14. {
  15. $this->username = $username;
  16. }
  17.  
  18. public function authenticate()
  19. {
  20. $phpbb = Zadoo_Phpbb::getInstance();
  21. $result = $phpbb->user_login(array('username'=>$this->username, 'password'=>$this->password));
  22.  
  23. if ($result == 'SUCCESS') {
  24. return new Zend_Auth_Result(1, 'HMM', array());
  25. }
  26.  
  27. return new Zend_Auth_Result(0, '', array());
  28.  
  29. }
  30.  
  31. public function getData()
  32. {
  33. global $user;
  34. return $user->data;
  35. }
  36.  
  37. }
Go to the top of the page
+Quote Post
ArekJ
post
Post #5





Grupa: Zarejestrowani
Postów: 266
Pomógł: 9
Dołączył: 21.05.2008
Skąd: Łomianki

Ostrzeżenie: (0%)
-----


Kiedyś nosiłem się z planami stworzenia portalu i integrowaniu go z phpBB3, jednak wszystko się jakoś rozeszło i nic z tego nie wyszło, jednak odpowiedź na pytanie znajduje się również tutaj:
http://phpbb3.pl/viewtopic.php?f=5&t=8406
Pozdrawiam.
Go to the top of the page
+Quote Post
paBlas16
post
Post #6





Grupa: Zarejestrowani
Postów: 45
Pomógł: 3
Dołączył: 27.09.2009
Skąd: Toruń

Ostrzeżenie: (0%)
-----


A czy mógłby ktoś napisać jak korzystać z tej klasy? Jak zrobić logowanie. Chociaż komentarze do linijek kodu.
Go to the top of the page
+Quote Post
pgrzelka
post
Post #7





Grupa: Zarejestrowani
Postów: 313
Pomógł: 24
Dołączył: 9.08.2008
Skąd: Kielce

Ostrzeżenie: (0%)
-----


przeczytaj nazwy funkcji

w twoim skrypcie w miejscu gdzie przesyłasz dane z formularza logowania wywołujesz funkcję user_login z tej klasy
Go to the top of the page
+Quote Post
paBlas16
post
Post #8





Grupa: Zarejestrowani
Postów: 45
Pomógł: 3
Dołączył: 27.09.2009
Skąd: Toruń

Ostrzeżenie: (0%)
-----


A czy mógłby ktoś objaśnić pozostałe funkcje? I ich działanie.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 15.09.2025 - 10:44