PageRenderTime 54ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/sitemanager/user_update.php

https://bitbucket.org/itoxable/chiron-gaming
PHP | 452 lines | 363 code | 45 blank | 44 comment | 37 complexity | 4a7bbc590ba51c40b6fa715eb01d718f MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0
  1. <?php
  2. /*******************************************************************************/
  3. #This page is to add/edit user details
  4. #last Updated : August 25 , 2011
  5. /*******************************************************************************/
  6. error_reporting(0);
  7. include('general_include.php');
  8. include"checklogin.php";
  9. include('/class/payment_class.php');
  10. $u_id = $_REQUEST['u_id'];
  11. $action = $_REQUEST['action'];
  12. //echo "userID :- ".$u_id;
  13. function phpbb_email_hash($email)
  14. {
  15. return sprintf('%u', crc32(strtolower($email))) . strlen($email);
  16. }
  17. function OrderNumberGenerator($tablename,$field)
  18. {
  19. $OrderNumber="";
  20. function make_seed()
  21. {
  22. list($usec, $sec) = explode(' ', microtime());
  23. return (float) $sec + ((float) $usec * 100000);
  24. }
  25. while(!$OrderNumber)
  26. {
  27. mt_srand(make_seed());
  28. $randval = mt_rand();
  29. $randvalw=rand(65,90);
  30. $randvalw=chr($randvalw);
  31. $OrderNumber=$randvalw."-".$randval;
  32. $select_number="SELECT * FROM $tablename WHERE $field = '$OrderNumber' ";
  33. $result_number=mysql_query($select_number) or die("Error In Generating OrderNumber ".mysql_error());
  34. $num=mysql_num_rows($result_number);
  35. if($num>0)
  36. $OrderNumber="";
  37. }
  38. return $OrderNumber;
  39. }
  40. $image_object->SetImagePath("../uploaded/user_images");
  41. if($action=="trans")
  42. {
  43. $is_active = $is_active =="Y" ? "Y" : "N";
  44. $availability_type = $availability_type =="O" ? "O" : "L";
  45. //$is_active = $is_active =="Y" ? "Y" : "N";
  46. if($availability_type=='O')
  47. {
  48. $availability_city = '';
  49. $availability_country = '';
  50. }
  51. /* Holding Data If Error Starts */
  52. $FabricArr['name'] = htmlspecialchars(trim($name));
  53. $FabricArr['email'] = htmlspecialchars(trim($email));
  54. $FabricArr['paypal_email_id'] = htmlspecialchars(trim($paypal_email_id));
  55. $FabricArr['password'] = htmlspecialchars(trim($password));
  56. $FabricArr['contact_no'] = htmlspecialchars(trim($contact_no));
  57. $FabricArr['city'] = trim($city);
  58. $FabricArr['city_name'] = htmlspecialchars(trim($citynm));
  59. $FabricArr['state'] = htmlspecialchars(trim($state));
  60. $FabricArr['user_about'] = htmlspecialchars(trim($user_about));
  61. $FabricArr['description'] = htmlspecialchars(trim($description));
  62. $FabricArr['date_of_birth'] = htmlspecialchars(trim($date_of_birth));
  63. $FabricArr['skype_id'] = htmlspecialchars(trim($skype_id));
  64. $FabricArr['rate'] = htmlspecialchars(trim($rate));
  65. $FabricArr['availability_type1'] = htmlspecialchars(trim($availability_type1));
  66. $FabricArr['availability_type2'] = htmlspecialchars(trim($availability_type2));
  67. $FabricArr['availability_city'] = trim($availability_city);
  68. $FabricArr['acity_name'] = htmlspecialchars(trim($acity_name));
  69. $FabricArr['description'] = htmlspecialchars(trim($description));
  70. $lang_count=count($_POST['language']);
  71. for($l=0; $l<$lang_count; $l++)
  72. {
  73. $language_id.= $language[$l].',';
  74. }
  75. $language_ids = substr($language_id,0,-1);
  76. $FabricArr['calendar_code'] = htmlspecialchars(trim($calendar_code));
  77. $FabricArr['active_calendar'] = $active_calendar;
  78. //$FabricArr['user_type'] = $user_type;
  79. //count($language);
  80. /* Holding Data If Error Ends */
  81. //echo "USERID :--- ".$u_id;
  82. //print_r($FabricArr);
  83. //exit;
  84. /* Error Checking Starts */
  85. $http_image_name=$_FILES['img1']['name'];
  86. $http_image_size=$_FILES['img1']['size'];
  87. $http_image_type=$_FILES['img1']['type'];
  88. $http_image_temp=$_FILES['img1']['tmp_name'];
  89. $PhotoT1=$_POST['PhotoT1'];
  90. $imghidden1=$_POST['imghidden1'];
  91. //echo $date_of_birth;
  92. $err_msgs="";
  93. $err_msgs .=$AdminManagerObjAjax->Validate(strip_tags($email),"Email","EMP",$type="EMAIL");
  94. $err_msgs .=$AdminManagerObjAjax->DuplicateCheck(TABLEPREFIX."_user","email",$email,"Email Address","user_id",$u_id);
  95. $err_msgs .=$AdminManagerObjAjax->Validate(strip_tags($password),"Password","EMP",$type="");
  96. $err_msgs .=$AdminManagerObjAjax->DuplicateCheck(TABLEPREFIX."_user","name",$name,"UserID","user_id",$u_id);
  97. //$err_msgs .=$AdminManagerObjAjax->Validate(strip_tags($contact_no),"Contact Number","EMP",$type="PHONE");
  98. $err_msgs .=$AdminManagerObjAjax->Validate(strip_tags($city),"City","EMP",$type="");
  99. //$err_msgs .=$AdminManagerObjAjax->Validate(strip_tags($date_of_birth),"Date of Birth","EMP",$type="");
  100. //$err_msgs .=$AdminManagerObjAjax->Validate(strip_tags($skype_id),"Skype Id","EMP",$type="");
  101. if($is_coach == 1)
  102. $err_msgs .=$AdminManagerObjAjax->Validate(strip_tags($paypal_email_id),"Paypal Email ID","EMP",$type="EMAIL");
  103. if($availability_type1 == 'L')
  104. {
  105. $err_msgs .=$AdminManagerObjAjax->Validate(strip_tags($availability_city),"Available City","EMP",$type="");
  106. }
  107. //$err_msgs .=$AdminManagerObjAjax->Validate(strip_tags($registration_phone),"Business Phone","EMP",$type="");
  108. /* Error Checking Ends */
  109. //die($err_msgs);
  110. if(empty($err_msgs))// If Empty Error Starts
  111. {
  112. $http_image_name = $_FILES['img1']['name'];
  113. $http_image_temp = $_FILES['img1']['tmp_name'];
  114. //$Picc1 = $image_object->UploadImage($PhotoT1,$imghidden1,$http_image_name,$http_image_temp,140,$resize_type=1,99);
  115. $Picc1 = $image_object->UploadImage($PhotoT1,$imghidden1,$http_image_name,$http_image_temp,37,$resize_type=5,'37','Y',198,$resize_type=5,172,'Y',57,$resize_type=5,50);
  116. $uploadfile = "../uploaded/user_images/".$Picc1;
  117. $mediumimagename = "thumbs/mid_" . $Picc1;
  118. $image_object->create_gdthumbnail($uploadfile,$mediumimagename,105,5,92);
  119. $avatar_path = SITE_URL."/uploaded/user_images/".$Picc1;
  120. // updating avatar to forum user //
  121. //mysql_query("UPDATE forum_users SET user_avatar='".SITE_URL."/uploaded/user_images/".$Picc1."', user_avatar_type='2', user_avatar_width='57', user_avatar_height='50' WHERE //username_clean='".$email."'");
  122. ////
  123. if($city!= '')
  124. {
  125. $sqlCity = "SELECT * FROM ".TABLEPREFIX."_cities WHERE city_id='$city'";
  126. $rowCity = $AdminManagerObjAjax->GetRecords("Row",$sqlCity);
  127. $country = $rowCity['country_id'];
  128. }
  129. if($availability_city != '' && $availability_type1!='')
  130. {
  131. $sqlCity = "SELECT * FROM ".TABLEPREFIX."_cities WHERE city_id='$availability_city'";
  132. $rowCity = $AdminManagerObjAjax->GetRecords("Row",$sqlCity);
  133. $availability_country == $rowCity['country_id'];
  134. }
  135. if(empty($u_id))
  136. {
  137. $PaymentNumber = OrderNumberGenerator(TABLEPREFIX.'_user','registration_number');
  138. /* Insert Into Sponsor Starts */
  139. if($active_calendar=='' && $calendar_code==''){
  140. $active_calendar='N';
  141. $calendar_code="";
  142. }
  143. if($availability_type1!='' && $availability_type2!='')
  144. $availability_type = $availability_type1.','.$availability_type2;
  145. if($availability_type1!='' && $availability_type2=='')
  146. $availability_type = $availability_type1;
  147. if($availability_type2!='' && $availability_type1=='')
  148. $availability_type = $availability_type2;
  149. $table_name = TABLEPREFIX."_user ";
  150. $fields_values = array(
  151. 'registration_number' => $PaymentNumber,
  152. 'name' => $name,
  153. 'email' => $email,
  154. 'password' => $password,
  155. 'paypal_email_id' => $paypal_email_id,
  156. 'contact_no' => $contact_no,
  157. 'city' => $city,
  158. 'state' => $state,
  159. 'country' => $country,
  160. 'photo' => $Picc1,
  161. 'user_about' => $user_about,
  162. 'description' => $description,
  163. 'language_ids' => $language_ids,
  164. 'date_of_birth' => $date_of_birth,
  165. 'skype_id' => $skype_id,
  166. 'is_active' => $is_active,
  167. 'calendar_code' => $calendar_code,
  168. 'active_calendar' => $active_calendar,
  169. 'rate' => $rate,
  170. 'availability_type' => $availability_type,
  171. 'availability_city' => $availability_city,
  172. 'availability_country' => $availability_country,
  173. 'date_registered' => date("Y-m-d H:i:s")
  174. );
  175. //echo "Here I am <BR />".$table_name."<BR />";
  176. //print_r($fields_values);
  177. $msgreport= $AdminManagerObjAjax->InsertRecords($table_name,$fields_values);
  178. $u_id=mysql_insert_id();
  179. $table = TABLEPREFIX."_user_type_user_relation ";
  180. $fields = array(
  181. 'user_id' => $u_id,
  182. 'user_type_id' => 2,
  183. 'date_added' => date("Y-m-d H:i:s")
  184. );
  185. $report= $AdminManagerObjAjax->InsertRecords($table,$fields);
  186. /// inserting into forum user table - prosenjit
  187. $fields = array(
  188. 'username' => $name,
  189. 'username_clean' => $name,
  190. 'user_password' => 'new_password',
  191. 'user_pass_convert' => 0,
  192. 'user_email' => $email,
  193. 'user_email_hash' => phpbb_email_hash($email),
  194. 'group_id' => 2,
  195. 'user_type' => 0,
  196. 'user_permissions' => '',
  197. 'user_timezone' => 0.00,
  198. 'user_dateformat' => 'D M d, Y g:i a',
  199. 'user_lang' => 'en',
  200. 'user_style' => 1,
  201. 'user_actkey' => '',
  202. 'user_ip' => '',
  203. 'user_regdate' => time(),
  204. 'user_passchg' => time(),
  205. 'user_options' => 230271,
  206. // We do not set the new flag here - registration scripts need to specify it
  207. 'user_new' => 0,
  208. 'user_inactive_reason' => 0,
  209. 'user_inactive_time' => 0,
  210. 'user_lastmark' => time(),
  211. 'user_lastvisit' => 0,
  212. 'user_lastpost_time' => 0,
  213. 'user_lastpage' => '',
  214. 'user_posts' => 0,
  215. 'user_dst' => 0,
  216. 'user_colour' => '',
  217. 'user_occ' => '',
  218. 'user_interests' => '',
  219. 'user_avatar' => $avatar_path,
  220. 'user_avatar_type' => 2,
  221. 'user_avatar_width' => 57,
  222. 'user_avatar_height' => 50,
  223. 'user_new_privmsg' => 0,
  224. 'user_unread_privmsg' => 0,
  225. 'user_last_privmsg' => 0,
  226. 'user_message_rules' => 0,
  227. 'user_full_folder' => -3,
  228. 'user_emailtime' => 0,
  229. 'user_notify' => 0,
  230. 'user_notify_pm' => 1,
  231. 'user_notify_type' => 0,
  232. 'user_allow_pm' => 1,
  233. 'user_allow_viewonline' => 1,
  234. 'user_allow_viewemail' => 1,
  235. 'user_allow_massemail' => 1,
  236. 'user_sig' => '',
  237. 'user_sig_bbcode_uid' => '',
  238. 'user_sig_bbcode_bitfield' => ''
  239. );
  240. $AdminManagerObjAjax->InsertRecords("forum_users",$fields);
  241. $userid = mysql_insert_id();
  242. //mysql_query("insert into forum_user_group set group_id=2, user_id='".$userid."', group_leader=0, user_pending=0"); // inserting into user group table
  243. //mysql_query("insert into forum_user_group set group_id=7, user_id='".$userid."', group_leader=0, user_pending=0"); // inserting into user group table
  244. ////
  245. $redirect_pg = 'user_type.php?u_id='.$u_id;
  246. /* Insert Into Sponsor Ends */
  247. }
  248. elseif(!empty($u_id))
  249. {
  250. /* Update Sponsor Starts */
  251. if($availability_type1!='' && $availability_type2!='')
  252. $availability_type = $availability_type1.','.$availability_type2;
  253. if($availability_type2!='' && $availability_type1=='')
  254. {
  255. $availability_city ='';
  256. $availability_country ='';
  257. $availability_type = $availability_type2;
  258. }
  259. if($availability_type1!='' && $availability_type2=='')
  260. $availability_type = $availability_type1;
  261. $SelectCatSql="SELECT * FROM ".TABLEPREFIX."_user WHERE user_id=".$u_id;
  262. $RsCatSql = $AdminManagerObjAjax->GetRecords("Row",$SelectCatSql);
  263. $table_name = TABLEPREFIX."_user ";
  264. $fields_values = array(
  265. 'name' => $name,
  266. 'email' => $email,
  267. 'password' => $password,
  268. 'contact_no' => $contact_no,
  269. 'paypal_email_id' => $paypal_email_id,
  270. 'city' => $city,
  271. 'state' => $state,
  272. 'country' => $country,
  273. 'photo' => $Picc1,
  274. 'user_about' => $user_about,
  275. 'description' => $description,
  276. 'language_ids' => $language_ids,
  277. 'date_of_birth' => $date_of_birth,
  278. 'skype_id' => $skype_id,
  279. 'is_active' => $is_active,
  280. 'calendar_code' => $calendar_code,
  281. 'active_calendar' => $active_calendar,
  282. 'rate' => $rate,
  283. 'availability_type' => $availability_type,
  284. 'availability_city' => $availability_city,
  285. 'availability_country' => $availability_country,
  286. 'date_edited' => date("Y-m-d H:i:s")
  287. );
  288. $where="user_id='$u_id' ";
  289. $msgreport= $AdminManagerObjAjax->UpdateRecords($table_name,$fields_values,$where);
  290. // updating forum user table //
  291. $fields = array(
  292. 'username'=> $name,
  293. 'username_clean' => $name,
  294. 'user_password' => 'new_password',
  295. 'user_email' => $email,
  296. 'user_email_hash' => phpbb_email_hash($email),
  297. 'user_avatar' => $avatar_path,
  298. 'user_avatar_type' => 2,
  299. 'user_avatar_width' => 57,
  300. 'user_avatar_height'=> 50
  301. );
  302. $where = "username='".trim($RsCatSql['email'])."'";
  303. //$AdminManagerObjAjax->UpdateRecords("forum_users",$fields,$where);
  304. if($user_type!='')
  305. {
  306. $table_name = TABLEPREFIX."_user_type_user_relation";
  307. $fields_val = array(
  308. 'user_id' => $u_id,
  309. 'user_type_id' => $user_type,
  310. 'date_added' => date("Y-m-d H:i:s")
  311. );
  312. $AdminManagerObjAjax->InsertRecords($table_name,$fields_val);
  313. $redirect_pg = "member_game.php?u_id=".$u_id."&u_type=".$user_type;
  314. }
  315. else
  316. $redirect_pg = "user_manager.php?messg=".$msgreport."&IsPreserved=Y";
  317. ////
  318. /* Update Sponsor Ends */
  319. }
  320. echo "<script>window.location.href='$redirect_pg'</script>";
  321. exit;
  322. }// If Empty Error Ends
  323. else
  324. {
  325. $smarty->assign('err_msgs',$err_msgs);
  326. }
  327. }
  328. $language=array();
  329. if(!empty($u_id))
  330. {
  331. /* Get Record For Display Starts */
  332. $SelectCatSql="SELECT * FROM ".TABLEPREFIX."_user WHERE user_id=".$u_id;
  333. $RsCatSql = $AdminManagerObjAjax->GetRecords("Row",$SelectCatSql);
  334. $FabricArr['registration_number'] = show_to_control($RsCatSql["registration_number"]);
  335. $FabricArr['name'] = show_to_control($RsCatSql["name"]);
  336. $FabricArr['email'] = show_to_control($RsCatSql["email"]);
  337. $FabricArr['paypal_email_id'] = show_to_control($RsCatSql["paypal_email_id"]);
  338. $FabricArr['password'] = show_to_control($RsCatSql["password"]);
  339. $FabricArr['contact_no'] = show_to_control($RsCatSql["contact_no"]);
  340. $FabricArr['city'] = show_to_control($RsCatSql["city"]);
  341. $FabricArr['state'] = show_to_control($RsCatSql["state"]);
  342. $FabricArr['country'] = $RsCatSql["country"];
  343. $FabricArr['date_of_birth'] = show_to_control($RsCatSql["date_of_birth"]);
  344. $FabricArr['skype_id'] = show_to_control($RsCatSql["skype_id"]);
  345. $FabricArr['is_active'] = $RsCatSql["is_active"];
  346. $FabricArr['availability_type'] = $RsCatSql["availability_type"];
  347. $FabricArr['availability_city'] = $RsCatSql["availability_city"];
  348. $FabricArr['description'] = $RsCatSql["description"];
  349. $FabricArr['char_left'] = 300 - strlen($RsCatSql["description"]);
  350. if($RsCatSql["availability_country"]!='')
  351. $FabricArr['availability_country'] = $RsCatSql["availability_country"];
  352. else
  353. $FabricArr['availability_country'] = $RsCatSql["country"];
  354. $language_id = explode(',',$RsCatSql['language_ids']);
  355. $language_ids = $language_id;
  356. $is_coach = 0;
  357. $is_partner = 0;
  358. $typeSql = "SELECT * FROM ".TABLEPREFIX."_user_type_user_relation WHERE user_id='".$u_id."'";
  359. $typeArr = $adodbcon->GetAll($typeSql);
  360. for($x=0;$x<count($typeArr);$x++)
  361. {
  362. if($typeArr[$x]['user_type_id'] == 1)
  363. $is_coach = 1;
  364. if($typeArr[$x]['user_type_id'] == 3)
  365. $is_partner = 1;
  366. }
  367. $sqlCity = "SELECT * FROM ".TABLEPREFIX."_cities WHERE city_id='".$FabricArr['city']."'";
  368. $sqlArr = $AdminManagerObjAjax->GetRecords("Row",$sqlCity);
  369. $FabricArr['city_name'] = $sqlArr['city_key'];
  370. $sqlAcity = "SELECT * FROM ".TABLEPREFIX."_cities WHERE city_id='".$FabricArr['availability_city']."'";
  371. $sqlAcityArr = $AdminManagerObjAjax->GetRecords("Row",$sqlAcity);
  372. $FabricArr['acity_name'] = $sqlAcityArr['city_key'];
  373. /* Get Record For Display Ends */
  374. $SubmitButton="Update Profile";
  375. $link="user_manager.php";
  376. $flag=1;
  377. }
  378. else
  379. {
  380. $is_coach = 0;
  381. $is_partner = 0;
  382. $SubmitButton="Add User";
  383. $link="user_manager.php";
  384. }
  385. $countrySql = "SELECT country_id,country_name FROM ".TABLEPREFIX."_country ORDER BY country_name";
  386. $CountryArr = $AdminManagerObjAjax->HtmlOptionArrayCreate($countrySql);
  387. //print_r($CountryArr);
  388. $langSql = "SELECT language_id,language_name FROM ".TABLEPREFIX."_language ORDER BY language_name";
  389. $langArr = $AdminManagerObjAjax->GetRecords("All",$langSql);
  390. $DisplayImageControlStr=$image_object->DisplayImageControl("Upload Photo","img1",$RsCatSql['photo'],"imghidden1","PhotoT1",$instuctiontype=1,$mandatory="N","Normal",90);
  391. /* Assign Smarty Variables Starts */
  392. $smarty->assign('is_coach',$is_coach);
  393. $smarty->assign('is_partner',$is_partner);
  394. $smarty->assign('user_type_id',$user_type_id);
  395. $smarty->assign('user_id',$u_id);
  396. $smarty->assign('CountryArr',$CountryArr);
  397. $smarty->assign('langArr',$langArr);
  398. $smarty->assign('language_ids',$language_ids);
  399. $smarty->assign('FabricArr',$FabricArr);
  400. $smarty->assign('DisplayImageControlStr',$DisplayImageControlStr);
  401. $smarty->assign('SubmitButton',$SubmitButton);
  402. $smarty->assign('link',$link);
  403. $smarty->assign('flag',$flag);
  404. $smarty->register_modifier("inarray","in_array");
  405. /* Assign Smarty Variables Ends */
  406. $smarty->display("user_update.tpl");
  407. ?>