functions.common.tmpl.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <?php
  2. /* $Id: functions.common.tmpl.php 3156 2007-07-08 14:07:23Z danez $ */
  3. /*******************************************************************************
  4. LICENSE
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License (GPL)
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. To read the license please visit http://www.gnu.org/copyleft/gpl.html
  14. *******************************************************************************/
  15. /**
  16. * set vars for form of index page settings
  17. */
  18. function tmplSetIndexPageFormVars() {
  19. global $cfg, $tmpl;
  20. // set vars
  21. $tmpl->setvar('enable_index_meta_refresh', $cfg["enable_index_meta_refresh"]);
  22. $tmpl->setvar('page_refresh', $cfg["page_refresh"]);
  23. $tmpl->setvar('enable_index_ajax_update', $cfg["enable_index_ajax_update"]);
  24. $tmpl->setvar('enable_index_ajax_update_title', $cfg["enable_index_ajax_update_title"]);
  25. $tmpl->setvar('enable_index_ajax_update_users', $cfg["enable_index_ajax_update_users"]);
  26. $tmpl->setvar('enable_index_ajax_update_list', $cfg["enable_index_ajax_update_list"]);
  27. $tmpl->setvar('enable_index_ajax_update_silent', $cfg["enable_index_ajax_update_silent"]);
  28. $tmpl->setvar('index_ajax_update', $cfg["index_ajax_update"]);
  29. $tmpl->setvar('index_show_seeding', $cfg["index_show_seeding"]);
  30. $tmpl->setvar('enable_multiupload', $cfg["enable_multiupload"]);
  31. $tmpl->setvar('hack_multiupload_rows', $cfg["hack_multiupload_rows"]);
  32. $tmpl->setvar('ui_displaylinks', $cfg["ui_displaylinks"]);
  33. $tmpl->setvar('ui_displayusers', $cfg["ui_displayusers"]);
  34. $tmpl->setvar('ui_displaybandwidthbars', $cfg["ui_displaybandwidthbars"]);
  35. $tmpl->setvar('bandwidthbar', $cfg["bandwidthbar"]);
  36. $tmpl->setvar('bandwidth_up', $cfg["bandwidth_up"]);
  37. $tmpl->setvar('bandwidth_down', $cfg["bandwidth_down"]);
  38. $tmpl->setvar('enable_goodlookstats', $cfg["enable_goodlookstats"]);
  39. $tmpl->setvar('enable_bigboldwarning', $cfg["enable_bigboldwarning"]);
  40. $tmpl->setvar('enable_search', $cfg["enable_search"]);
  41. $tmpl->setvar('index_page_stats', $cfg["index_page_stats"]);
  42. $tmpl->setvar('show_server_load', $cfg["show_server_load"]);
  43. $tmpl->setvar('index_page_connections', $cfg["index_page_connections"]);
  44. $tmpl->setvar('enable_restrictivetview', $cfg["enable_restrictivetview"]);
  45. $tmpl->setvar('enable_metafile_download', $cfg["enable_metafile_download"]);
  46. $tmpl->setvar('enable_sorttable', $cfg["enable_sorttable"]);
  47. $tmpl->setvar('enable_multiops', $cfg["enable_multiops"]);
  48. $tmpl->setvar('enable_bulkops', $cfg["enable_bulkops"]);
  49. $tmpl->setvar('display_seeding_time', $cfg["display_seeding_time"]);
  50. $tmpl->setvar('index_page_sortorder', $cfg["index_page_sortorder"]);
  51. $tmpl->setloop('Engine_List', tmplSetSearchEngineDDL($cfg["searchEngine"]));
  52. $transferWindowDefaultList = array();
  53. array_push($transferWindowDefaultList, array(
  54. 'name' => 'Stats',
  55. 'value' => 'transferStats',
  56. 'is_selected' => ('transferStats' == $cfg["transfer_window_default"]) ? 1 : 0
  57. )
  58. );
  59. array_push($transferWindowDefaultList, array(
  60. 'name' => 'Hosts',
  61. 'value' => 'transferHosts',
  62. 'is_selected' => ('transferHosts' == $cfg["transfer_window_default"]) ? 1 : 0
  63. )
  64. );
  65. array_push($transferWindowDefaultList, array(
  66. 'name' => 'Scrape',
  67. 'value' => 'transferScrape',
  68. 'is_selected' => ('transferScrape' == $cfg["transfer_window_default"]) ? 1 : 0
  69. )
  70. );
  71. array_push($transferWindowDefaultList, array(
  72. 'name' => 'Images',
  73. 'value' => 'transferImages',
  74. 'is_selected' => ('transferImages' == $cfg["transfer_window_default"]) ? 1 : 0
  75. )
  76. );
  77. array_push($transferWindowDefaultList, array(
  78. 'name' => 'Log',
  79. 'value' => 'transferLog',
  80. 'is_selected' => ('transferLog' == $cfg["transfer_window_default"]) ? 1 : 0
  81. )
  82. );
  83. array_push($transferWindowDefaultList, array(
  84. 'name' => 'Details',
  85. 'value' => 'transferDetails',
  86. 'is_selected' => ('transferDetails' == $cfg["transfer_window_default"]) ? 1 : 0
  87. )
  88. );
  89. array_push($transferWindowDefaultList, array(
  90. 'name' => 'Files',
  91. 'value' => 'transferFiles',
  92. 'is_selected' => ('transferFiles' == $cfg["transfer_window_default"]) ? 1 : 0
  93. )
  94. );
  95. array_push($transferWindowDefaultList, array(
  96. 'name' => 'Settings',
  97. 'value' => 'transferSettings',
  98. 'is_selected' => ('transferSettings' == $cfg["transfer_window_default"]) ? 1 : 0
  99. )
  100. );
  101. array_push($transferWindowDefaultList, array(
  102. 'name' => 'Control',
  103. 'value' => 'transferControl',
  104. 'is_selected' => ('transferControl' == $cfg["transfer_window_default"]) ? 1 : 0
  105. )
  106. );
  107. $tmpl->setloop('transfer_window_default_list', $transferWindowDefaultList);
  108. //
  109. tmplSetGoodLookingStatsForm();
  110. tmplSetIndexPageSettingsForm();
  111. }
  112. /**
  113. * set vars for form of index page settings (0-2047)
  114. *
  115. * User [0]
  116. * Size [1]
  117. * DLed [2]
  118. * ULed [3]
  119. * Status [4]
  120. * Progress [5]
  121. * DL Speed [6]
  122. * UL Speed [7]
  123. * Seeds [8]
  124. * Peers [9]
  125. * ETA [10]
  126. * TorrentClient [11]
  127. *
  128. */
  129. function tmplSetIndexPageSettingsForm() {
  130. global $cfg, $tmpl;
  131. $settingsIndexPage = convertIntegerToArray($cfg["index_page_settings"]);
  132. $tmpl->setvar('indexPageSettingsForm_settings_0', $settingsIndexPage[0]);
  133. $tmpl->setvar('indexPageSettingsForm_settings_1', $settingsIndexPage[1]);
  134. $tmpl->setvar('indexPageSettingsForm_settings_2', $settingsIndexPage[2]);
  135. $tmpl->setvar('indexPageSettingsForm_settings_3', $settingsIndexPage[3]);
  136. $tmpl->setvar('indexPageSettingsForm_settings_4', $settingsIndexPage[4]);
  137. $tmpl->setvar('indexPageSettingsForm_settings_5', $settingsIndexPage[5]);
  138. $tmpl->setvar('indexPageSettingsForm_settings_6', $settingsIndexPage[6]);
  139. $tmpl->setvar('indexPageSettingsForm_settings_7', $settingsIndexPage[7]);
  140. $tmpl->setvar('indexPageSettingsForm_settings_8', $settingsIndexPage[8]);
  141. $tmpl->setvar('indexPageSettingsForm_settings_9', $settingsIndexPage[9]);
  142. $tmpl->setvar('indexPageSettingsForm_settings_10', $settingsIndexPage[10]);
  143. $tmpl->setvar('indexPageSettingsForm_settings_11', $settingsIndexPage[11]);
  144. }
  145. /**
  146. * set vars for form of good looking stats (0-63)
  147. */
  148. function tmplSetGoodLookingStatsForm() {
  149. global $cfg, $tmpl;
  150. $settingsHackStats = convertByteToArray($cfg["hack_goodlookstats_settings"]);
  151. $tmpl->setvar('goodLookingStatsForm_settings_0', $settingsHackStats[0]);
  152. $tmpl->setvar('goodLookingStatsForm_settings_1', $settingsHackStats[1]);
  153. $tmpl->setvar('goodLookingStatsForm_settings_2', $settingsHackStats[2]);
  154. $tmpl->setvar('goodLookingStatsForm_settings_3', $settingsHackStats[3]);
  155. $tmpl->setvar('goodLookingStatsForm_settings_4', $settingsHackStats[4]);
  156. $tmpl->setvar('goodLookingStatsForm_settings_5', $settingsHackStats[5]);
  157. }
  158. /**
  159. * Set Client Select Form vars
  160. *
  161. * @param $client
  162. */
  163. function tmplSetClientSelectForm($client = 'tornado') {
  164. global $cfg, $tmpl;
  165. $clients = array("tornado", "transmission", "mainline", "azureus");
  166. $client_list = array();
  167. foreach ($clients as $clnt) {
  168. array_push($client_list, array(
  169. 'client' => $clnt,
  170. 'selected' => ($client == $clnt) ? 1 : 0
  171. )
  172. );
  173. }
  174. $tmpl->setloop('clientSelectForm_client_list', $client_list);
  175. }
  176. /**
  177. * set dir tree vars
  178. *
  179. * @param $dir
  180. * @param $maxdepth
  181. */
  182. function tmplSetDirTree($dir, $maxdepth) {
  183. global $cfg, $tmpl;
  184. $tmpl->setvar('dirtree_dir', $dir);
  185. if (is_numeric($maxdepth)) {
  186. $retvar_list = array();
  187. $last = ($maxdepth == 0)
  188. ? exec("find ".tfb_shellencode($dir)." -type d | sort && echo", $retval)
  189. : exec("find ".tfb_shellencode($dir)." -maxdepth ".tfb_shellencode($maxdepth)." -type d | sort && echo", $retval);
  190. for ($i = 1; $i < (count ($retval) - 1); $i++)
  191. array_push($retvar_list, array('retval' => $retval[$i]));
  192. $tmpl->setloop('dirtree_retvar_list', $retvar_list);
  193. }
  194. }
  195. /**
  196. * set vars for form of move-settings
  197. */
  198. function tmplSetMoveSettings() {
  199. global $cfg, $tmpl;
  200. if ((isset($cfg["move_paths"])) && (strlen($cfg["move_paths"]) > 0)) {
  201. $dirs = explode(":", trim($cfg["move_paths"]));
  202. $dir_list = array();
  203. foreach ($dirs as $dir) {
  204. $target = trim($dir);
  205. if ((strlen($target) > 0) && ((substr($target, 0, 1)) != ";"))
  206. array_push($dir_list, array('target' => $target));
  207. }
  208. $tmpl->setloop('moveSettings_move_list', $dir_list);
  209. }
  210. $tmpl->setvar('moveSettings_move_paths', $cfg["move_paths"]);
  211. }
  212. /**
  213. * get superadmin-popup-link-html-snip.
  214. *
  215. * @param $param
  216. * @param $linkText
  217. * @return string
  218. */
  219. function getSuperAdminLink($param = "", $linkText = "") {
  220. global $cfg;
  221. // create template-instance
  222. $_tmpl = tmplGetInstance($cfg["theme"], "component.superAdminLink.tmpl");
  223. $_tmpl->setvar('param', $param);
  224. if ((isset($linkText)) && ($linkText != ""))
  225. $_tmpl->setvar('linkText', $linkText);
  226. // grab the template
  227. $output = $_tmpl->grab();
  228. return $output;
  229. }
  230. ?>