PageRenderTime 49ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/accounts.php

https://github.com/intelliants/elitius
PHP | 308 lines | 262 code | 26 blank | 20 comment | 9 complexity | 3b46e36cb18d89bd7d973f0aa49db580 MD5 | raw file
  1. <?php
  2. /***************************************************************************
  3. *
  4. * PROJECT: eLitius Open Source Affiliate Software
  5. * VERSION: 1.0
  6. * LISENSE: GNU GPL (http://www.opensource.org/licenses/gpl-license.html)
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation.
  11. *
  12. * Link to eLitius.com can not be removed from the software pages without
  13. * permission of the eLitius respective owners. It is the only requirement
  14. * for using this software.
  15. *
  16. * Copyright 2009 Intelliants LLC
  17. * http://www.intelliants.com/
  18. *
  19. ***************************************************************************/
  20. require_once('./init.php');
  21. $gPage = $gXpLang['account_manager'];
  22. $gPath = 'account-manager';
  23. $gDesc = $gXpLang['manage_accounts'];
  24. $buttons = array(0 => array('name'=>'create','img'=> $gXpConfig['xpurl'].'admin/images/new_f2.gif', 'text' => $gXpLang['create']));
  25. require_once('header.php');
  26. switch($_GET['sgn'])
  27. {
  28. case 1:
  29. $msg = $gXpLang['msg_new_account_created'];
  30. break;
  31. case 2:
  32. $msg = $gXpLang['msg_cannot_modify'];
  33. break;
  34. case 3:
  35. $msg = $gXpLang['msg_select_account'];
  36. break;
  37. case 4:
  38. $msg = $gXpLang['msg_select_account2delete'];
  39. break;
  40. case 5:
  41. $msg = $gXpLang['msg_account_success_delete'];
  42. break;
  43. case 6:
  44. $msg = $gXpLang['msg_account_success_modify'];
  45. break;
  46. case 7:
  47. $msg = $gXpLang['msg_account_success_disapproved'];
  48. break;
  49. case 8:
  50. $msg = $gXpLang['msg_account_success_approved'];
  51. break;
  52. case 9:
  53. $msg = $gXpLang['msg_account_success_pending'];
  54. break;
  55. case 10:
  56. $msg = $gXpLang['msg_accounts_success_delete'];
  57. break;
  58. case 11:
  59. $msg = $gXpLang['msg_accounts_success_modify'];
  60. break;
  61. case 12:
  62. $msg = $gXpLang['msg_accounts_success_disapproved'];
  63. break;
  64. case 13:
  65. $msg = $gXpLang['msg_accounts_success_approved'];
  66. break;
  67. case 14:
  68. $msg = $gXpLang['msg_accounts_success_pending'];
  69. break;
  70. default: ;
  71. }
  72. $items = (int)$_GET['items'];
  73. $items = $items ? $items : 5 ;
  74. $query_items = '';
  75. if ((INT)$_GET['items']>0)
  76. {
  77. $query_items = '&items='.(INT)$_GET['items'];
  78. }
  79. define(ITEMS_PER_PAGE, $items);
  80. $page = (int)$_GET['page'];
  81. $page = ($page < 1) ? 1 : $page;
  82. $start = ($page - 1) * ITEMS_PER_PAGE;
  83. $suser = addslashes(htmlentities(strip_tags($_GET['su'])));
  84. $smail = addslashes(htmlentities(strip_tags($_GET['sm'])));
  85. $accounts_num =& $gXpAdmin->getNumAccounts();
  86. $accounts =& $gXpAdmin->getAllAccounts($start, ITEMS_PER_PAGE, $suser, $smail);
  87. ?>
  88. <br />
  89. <?php
  90. print_box($error, $msg);
  91. ?>
  92. <form id="form_affiliate" action="manage-account.php<?php echo str_replace("&","?",$query_items)?>" method="post" name="adminForm">
  93. <table class="adminlist" style="text-align: left;">
  94. <tr>
  95. <th style="text-align: right; border-bottom: 1px solid #fff;" colspan="3"><?php echo $gXpLang['filter_accounts']; ?>: </th>
  96. <th style="border-bottom: 1px solid #fff;">
  97. <input id="search_user" type="text" name="user" value="<?php echo $suser;?>" style="margin:0" />
  98. </th>
  99. <th style="border-bottom: 1px solid #fff;">
  100. <input id="search_mail" type="text" name="email" value="<?php echo $smail;?>" style="margin:0" />
  101. </th>
  102. <th style="border-bottom: 1px solid #fff;" colspan="6">
  103. <input type="button" value="Search in Accounts" onclick="setAction();" />
  104. </th>
  105. </tr>
  106. <tr>
  107. <th width="20"><input type="checkbox" name="toggle" value="" onClick="checkAll(<?php echo count($accounts);?>);" /></th>
  108. <th>ID</th>
  109. <th><?php echo $gXpLang['tier_tree']; ?></th>
  110. <th><?php echo $gXpLang['username']; ?></th>
  111. <th><?php echo $gXpLang['email']; ?></th>
  112. <th><?php echo $gXpLang['hits']; ?></th>
  113. <th><?php echo $gXpLang['level']; ?></th>
  114. <th><?php echo $gXpLang['sales']; ?></th>
  115. <th class="empty"><?php echo $gXpLang['status']; ?></th>
  116. <th></th>
  117. <th><?php echo $gXpLang['action']; ?></th>
  118. </tr>
  119. <?php
  120. for($i=0; $i<count($accounts); $i++)
  121. {
  122. if($accounts[$i]['aff_tier']>0)
  123. {
  124. $tier = '<img alt="" src="img/user_go.gif" style="cursor: pointer" border="0" align="top" onclick="viewModal(this, '.$accounts[$i]['id'].', \''.$accounts[$i]['username'].'\')" />';
  125. }
  126. else
  127. {
  128. $tier = '<img alt="" src="img/user_gray.gif" border="0" align="top" />';
  129. }
  130. ?>
  131. <tr class="row<?php echo ($i%2) ? '0' : '1' ;?>">
  132. <td><input id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $accounts[$i]['id'];?>" onclick="isChecked(this.checked);" type="checkbox" /></td>
  133. <td><?php echo $accounts[$i]['id'];?></td>
  134. <td><?php echo $tier;?></td>
  135. <td><a href="view-account.php?id=<?php echo $accounts[$i]['id'];?>" title="<?php echo $gXpLang['view_account_details']; ?>"><?php echo $accounts[$i]['username'];?></a></td>
  136. <td><?php echo $accounts[$i]['email'];?></td>
  137. <td><?php echo $accounts[$i]['hits'];?></td>
  138. <td><?php echo ($accounts[$i]['level']>0? $gXpLang['level'].' - '.$accounts[$i]['level'] : $gXpLang['default_level']); ?></td>
  139. <td><?php echo $accounts[$i]['sales'];?></td>
  140. <?php
  141. $tierContent.='<div id="tier_'.$accounts[$i]['id'].'" style="display: none"><img src="img/spinner2.gif" border="0" align="top" /><font style="padding: 4px;"> Loading...</font></div>';
  142. switch ($accounts[$i]['approved'])
  143. {
  144. case 0:
  145. $bgcolor = "bgcolor='#FFBBBB'";
  146. $status = $gXpLang['status_disapproved'];
  147. break;
  148. case 1:
  149. $bgcolor = "bgcolor='#FFF4CD'";
  150. $status = $gXpLang['status_pending'];
  151. break;
  152. case 2:
  153. $bgcolor = "bgcolor='#BBFFBB'";
  154. $status = $gXpLang['status_approved'];
  155. break;
  156. }
  157. ?>
  158. <td width="50" <?php echo $bgcolor; ?>><?php echo $status;?></td>
  159. <td></td>
  160. <td><a href="manage-account.php?id=<?php echo $accounts[$i]['id'];?>" title="<?php echo $gXpLang['edit_account']; ?>"><img src="images/edit.gif" border="0" /></a></td>
  161. </tr>
  162. <?php
  163. }
  164. if(count($accounts)==0)
  165. { ?>
  166. <tr class="row0">
  167. <td colspan="9" align="center">No Items</td>
  168. </tr>
  169. <?php
  170. }
  171. ?>
  172. </table>
  173. <div class="bottom-controls" style="margin-top: 10px; display:none">
  174. <select name="action" id="action">
  175. <option value="">-- select --</option>
  176. <option value="approve"><?php echo $gXpLang['approve'];?></option>
  177. <option value="pending"><?php echo $gXpLang['pending'];?></option>
  178. <option value="disapprove"><?php echo $gXpLang['disapprove'];?></option>
  179. <option value="delete"><?php echo $gXpLang['delete'];?></option>
  180. </select>
  181. <input type="submit" value=" Go " />
  182. </div>
  183. <input type="hidden" id="boxchecked" name="boxchecked" value="0" />
  184. <input type="hidden" name="task" value="" />
  185. </form>
  186. <div style="height: 5px;"></div>
  187. <?php
  188. $url = "accounts.php?items=".ITEMS_PER_PAGE.(($smail or $suser)? "&su=".$suser."&sm=".$sm:"");
  189. navigation($accounts_num, $start, count($accounts), $url, ITEMS_PER_PAGE);
  190. ?>
  191. <!--main part ends-->
  192. <div id="modal" style="z-index:999; position: absolute; top: 0px; left:0px; width: 250px; display: none;" class="jqDnR">
  193. <img class="close" alt="" src="img/close.gif" border="0" style="position: absolute; right: 3px; top:3px; cursor:pointer" />
  194. <div style="cursor: move;height: 27px; background: url('img/box-caption-bg.gif') top left repeat-x;" class="jqHandle jqDrag">
  195. <div class="box-top-right">
  196. <img alt="" border="0" src="img/box-caption-left.gif" align="left" />
  197. <div style="padding: 6px 4px 2px 0px; font-weight: bold"><?php echo $gXpLang['tier_tree']; ?>
  198. </div>
  199. </div>
  200. </div>
  201. <div class="box-content" style="overflow:auto; clear: both; height:250px; background: #fff;">
  202. <div id="treePanel">
  203. </div>
  204. </div>
  205. <div style="background: url('img/box-bottom-left.gif') #fff bottom left no-repeat; border-top: 1px solid #A7A7A9">
  206. <div style="background: url('img/box-bottom-right.gif') bottom right no-repeat; margin-left: 5px;">
  207. <img class="jqHandle jqResize" alt="" src="img/resize.gif" border="0" style="position: absolute; right:0px; bottom:1px; margin: 1px 2px; cursor: e-resize;" />&nbsp;
  208. </div>
  209. </div>
  210. </div>
  211. <?php echo $tierContent;?>
  212. <script type="text/javascript">
  213. function setAction()
  214. {
  215. var suser = $("#search_user").val();
  216. var smail = $("#search_mail").val();
  217. var link = 'accounts.php';
  218. link += suser? "?su="+suser :"";
  219. link += smail? (suser? "&":"?")+"sm="+smail : "";
  220. document.location.href = link;
  221. }
  222. function viewModal(obj, data, username)
  223. {
  224. var pos = $(obj).getElementDimensions();
  225. $("#modal").css({top:pos.top+"px", left:pos.left+20+"px"}).show();
  226. $("#treePanel").empty();
  227. var code = $("#tier_"+data).html()||"";
  228. $("#treePanel").html(code);
  229. $("#treePanel ul, #treePanel li").unbind();
  230. if(code.indexOf('spinner2.gif')>0)
  231. {
  232. $.ajax({
  233. type: "POST",
  234. url: "get-tier-tree.php",
  235. data: "id="+data,
  236. async: false,
  237. success: function(tree){
  238. tree = '<img src="img/user.gif" border="0" align="top" style="margin-left: 4px;" \/> '+username+tree;
  239. $("#tier_"+data).html(tree);
  240. $("#treePanel").html(tree);
  241. }
  242. });
  243. }
  244. $("#treePanel > ul:first").addClass("dir").Treeview({ speed: "normal", collapsed: true});
  245. }
  246. $().require('css/tree.css');
  247. $().require('js/jquery.treeview.js');
  248. $(document).ready(function(){
  249. jQuery.fn.enterEscape = function()
  250. {
  251. this.keypress(
  252. function(e)
  253. {
  254. // get key pressed (charCode from Mozilla/Firefox and Opera / keyCode in IE)
  255. var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
  256. if(key == 13)
  257. {
  258. setAction();
  259. return false;
  260. }
  261. });
  262. return this;
  263. }
  264. $(document).enterEscape();
  265. if (jQuery.browser.msie) {
  266. // we put a styled iframe behind the modal so HTML SELECT elements don't show through
  267. var iframe = [ '<iframe class="bgiframe" tabindex="-1" src="about:blank" ',
  268. 'style="display:block; position:absolute;',
  269. 'top: 0;',
  270. 'left:0;',
  271. 'z-index:-1; filter:Alpha(Opacity=\'0\');',
  272. 'width:100%;',
  273. 'height:313px" frameborder="0" \/>'].join('');
  274. $("#modal").prepend(iframe);
  275. }
  276. $('#modal').jqDrag('.jqDrag').jqResize('.jqResize').jqClose('.close');
  277. $("#modal").prependTo("body:first");
  278. });
  279. </script>
  280. <?php
  281. require_once('footer.php');
  282. ?>