PageRenderTime 52ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/public/demo/index.php

https://bitbucket.org/speedealing/speedealing
PHP | 478 lines | 333 code | 62 blank | 83 comment | 70 complexity | 47bc636ab874f8a7d0879e0fd9cf15a8 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/public/demo/index.php
  21. * \ingroup core
  22. * \brief Entry page to access demo
  23. * \author Laurent Destailleur
  24. */
  25. define("NOLOGIN",1); // This means this output page does not require to be logged.
  26. define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
  27. require '../../main.inc.php';
  28. $langs->load("main");
  29. $langs->load("install");
  30. $langs->load("other");
  31. // Security check
  32. global $dolibarr_main_demo;
  33. if (empty($dolibarr_main_demo)) accessforbidden('Parameter dolibarr_main_demo must be defined in conf file with value "default login,default pass" to enable the demo entry page',1,1,1);
  34. // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
  35. $hookmanager->initHooks(array('demo'));
  36. $demoprofiles=array(
  37. array('default'=>'1', 'key'=>'profdemoservonly','label'=>'DemoCompanyServiceOnly',
  38. 'disablemodules'=>'adherent,barcode,boutique,cashdesk,categorie,don,expedition,externalsite,mailmanspip,prelevement,product,stock',
  39. 'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot8.png'),
  40. array('default'=>'-1','key'=>'profdemoshopwithdesk','label'=>'DemoCompanyShopWithCashDesk',
  41. 'disablemodules'=>'adherent,boutique,categorie,don,externalsite,ficheinter,mailmanspip,prelevement,product,stock',
  42. 'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot2.png'),
  43. array('default'=>'0', 'key'=>'profdemoprodstock','label'=>'DemoCompanyProductAndStocks',
  44. 'disablemodules'=>'adherent,boutique,contrat,categorie,don,externalsite,ficheinter,mailmanspip,prelevement,service',
  45. 'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot2.png'),
  46. array('default'=>'0', 'key'=>'profdemoall','label'=>'DemoCompanyAll',
  47. 'disablemodules'=>'adherent,boutique,don,externalsite,mailmanspip',
  48. 'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot9.png'),
  49. array('default'=>'-1', 'key'=>'profdemofun','label'=>'DemoFundation',
  50. 'disablemodules'=>'banque,barcode,boutique,cashdesk,commande,commercial,compta,comptabilite,contrat,expedition,externalsite,facture,ficheinter,fournisseur,mailmanspip,prelevement,product,projet,propal,propale,service,societe,stock,tax',
  51. 'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot6.png'),
  52. array('default'=>'0', 'key'=>'profdemofun2','label'=>'DemoFundation2',
  53. 'disablemodules'=>'barcode,boutique,cashdesk,commande,commercial,compta,comptabilite,contrat,expedition,externalsite,facture,ficheinter,fournisseur,mailmanspip,prelevement,product,projet,propal,propale,service,societe,stock,tax',
  54. 'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot6.png')
  55. );
  56. $tmpaction = 'view';
  57. $parameters=array();
  58. $object=(object) 'nothing';
  59. $reshook=$hookmanager->executeHooks('addDemoProfile', $parameters, $object, $tmpaction); // Note that $action and $object may have been modified by some hooks
  60. $error=$hookmanager->error; $errors=$hookmanager->errors;
  61. /*
  62. $demoprofiles[]=array('default'=>'0', 'key'=>'profdemomed', 'lang'=>'cabinetmed@cabinetmed', 'label'=>'DemoCabinetMed', 'url'=>'http://demodolimed.dolibarr.org',
  63. 'disablemodules'=>'adherent,boutique,don,externalsite',
  64. 'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot6.png');
  65. */
  66. $alwayscheckedmodules=array('barcode','bookmark','externalrss','fckeditor','geoipmaxmind','gravatar','memcached','syslog','user','webservices'); // Technical module we always want
  67. $alwaysuncheckedmodules=array('paybox','paypal','google','scanner','workflow'); // Module we never want
  68. $alwayshiddencheckedmodules=array('accounting','barcode','bookmark','clicktodial','comptabilite','document','domain','externalrss','externalsite','fckeditor','geoipmaxmind','gravatar','label','ldap',
  69. 'mailmanspip','notification','syslog','user','webservices',
  70. // Extended modules
  71. 'memcached','numberwords','zipautofillfr');
  72. $alwayshiddenuncheckedmodules=array('ftp',
  73. // Extended modules
  74. 'awstats','bittorrent','cmcic','concatpdf','filemanager','lightbox','mantis','monitoring','moretemplates','numberingpack','openstreetmap',
  75. 'ovh','phenix','phpsysinfo','pibarcode','postnuke','skincoloreditor','submiteverywhere','survey','thomsonphonebook','topten','tvacerfa','voyage','webcalendar','webmail');
  76. // Search modules
  77. $dirlist=$conf->file->dol_document_root;
  78. // Search modules dirs
  79. $modulesdir = array();
  80. foreach ($conf->file->dol_document_root as $type => $dirroot)
  81. {
  82. $modulesdir[$dirroot . '/core/modules/'] = $dirroot . '/core/modules/';
  83. $handle=@opendir($dirroot);
  84. if (is_resource($handle))
  85. {
  86. while (($file = readdir($handle))!==false)
  87. {
  88. if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes')
  89. {
  90. if (is_dir($dirroot . '/' . $file . '/core/modules/'))
  91. {
  92. $modulesdir[$dirroot . '/' . $file . '/core/modules/'] = $dirroot . '/' . $file . '/core/modules/';
  93. }
  94. }
  95. }
  96. closedir($handle);
  97. }
  98. }
  99. //var_dump($modulesdir);
  100. $filename = array();
  101. $modules = array();
  102. $orders = array();
  103. $categ = array();
  104. $dirmod = array();
  105. $i = 0; // is a sequencer of modules found
  106. $j = 0; // j is module number. Automatically affected if module number not defined.
  107. foreach ($modulesdir as $dir)
  108. {
  109. // Charge tableaux modules, nom, numero, orders depuis repertoire dir
  110. $handle=@opendir($dir);
  111. if (is_resource($handle))
  112. {
  113. while (($file = readdir($handle))!==false)
  114. {
  115. //print "$i ".$file."\n<br>";
  116. if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
  117. {
  118. $modName = substr($file, 0, dol_strlen($file) - 10);
  119. if ($modName)
  120. {
  121. try
  122. {
  123. include_once $dir.$file;
  124. $objMod = new $modName($db);
  125. if ($objMod->numero > 0)
  126. {
  127. $j = $objMod->numero;
  128. }
  129. else
  130. {
  131. $j = 1000 + $i;
  132. }
  133. $modulequalified=1;
  134. // We discard modules according to features level (PS: if module is activated we always show it)
  135. $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod)));
  136. if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && ! $conf->global->$const_name) $modulequalified=0;
  137. if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && ! $conf->global->$const_name) $modulequalified=0;
  138. if ($modulequalified)
  139. {
  140. $modules[$i] = $objMod;
  141. $filename[$i]= $modName;
  142. $orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module
  143. //print "x".$modName." ".$orders[$i]."\n<br>";
  144. if (isset($categ[$objMod->special])) $categ[$objMod->special]++; // Array of all different modules categories
  145. else $categ[$objMod->special]=1;
  146. $dirmod[$i] = $dirroot;
  147. $j++;
  148. $i++;
  149. }
  150. }
  151. catch(Exception $e)
  152. {
  153. dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
  154. }
  155. }
  156. }
  157. }
  158. }
  159. }
  160. asort($orders);
  161. //var_dump($orders);
  162. /*
  163. * Actions
  164. */
  165. if (GETPOST("action") == 'gotodemo')
  166. {
  167. //print 'ee'.GETPOST("demochoice");
  168. $disablestring='';
  169. // If we disable modules using a profile choice
  170. if (GETPOST("demochoice"))
  171. {
  172. foreach ($demoprofiles as $profilearray)
  173. {
  174. if ($profilearray['key'] == GETPOST("demochoice"))
  175. {
  176. $disablestring=$profilearray['disablemodules'];
  177. break;
  178. }
  179. }
  180. }
  181. // If we disable modules using personalized list
  182. foreach($modules as $val)
  183. {
  184. $modulekeyname=strtolower($val->name);
  185. if (empty($_POST[$modulekeyname]) && empty($val->always_enabled) && ! in_array($modulekeyname,$alwayscheckedmodules))
  186. {
  187. $disablestring.=$modulekeyname.',';
  188. if ($modulekeyname=='propale') $disablestring.='propal,';
  189. }
  190. }
  191. // Do redirect to login page
  192. if ($disablestring)
  193. {
  194. $url=DOL_URL_ROOT.'/index.php?disablemodules='.$disablestring;
  195. if (GETPOST('urlfrom','alpha')) $url.='&urlfrom='.GETPOST('urlfrom','alpha');
  196. header("Location: ".$url);
  197. exit;
  198. }
  199. }
  200. /*
  201. * View
  202. */
  203. llxHeaderVierge($langs->trans("SpeedealingDemo"));
  204. ?>
  205. <script type="text/javascript">
  206. var openedId='';
  207. jQuery(document).ready(function () {
  208. jQuery('tr.moduleline').hide();
  209. // Enable this to allow personalized setup
  210. jQuery('.modulelineshow').attr('href','#');
  211. jQuery(".modulelineshow").click(function() {
  212. var currentId = $(this).attr('id').substring(2);
  213. jQuery('tr.moduleline').hide();
  214. if (currentId != openedId)
  215. {
  216. openedId=currentId;
  217. jQuery("#tr1"+currentId).show();
  218. jQuery("#tr2"+currentId).show();
  219. }
  220. else openedId = '';
  221. });
  222. });
  223. </script>
  224. <?php
  225. print "\n";
  226. print '<table style="font-size:14px;" summary="List of Dolibarr demos">';
  227. print '<tr><td>';
  228. print '<center><img src="'.DOL_URL_ROOT.'/theme/dolibarr_logo.png" alt="Dolibarr logo"></center><br>';
  229. print '<br>';
  230. print $langs->trans("DemoDesc").'<br>';
  231. print '<br>';
  232. print '<font color="#555577"><b>'.$langs->trans("ChooseYourDemoProfil").'</b></font>';
  233. print '</td></tr>';
  234. print '<tr><td width="50%">';
  235. print '<table style="font-size:14px;" width="100%" summary="List of Dolibarr demos">'."\n";
  236. $i=0;
  237. foreach ($demoprofiles as $profilearray)
  238. {
  239. if ($profilearray['default'] >= 0)
  240. {
  241. //print $profilearray['lang'];
  242. if (! empty($profilearray['lang'])) $langs->load($profilearray['lang']);
  243. $url=$_SERVER["PHP_SELF"].'?action=gotodemo&amp;urlfrom='.urlencode($_SERVER["PHP_SELF"]);
  244. $urlwithmod=$url.'&amp;demochoice='.$profilearray['key'];
  245. // Should work with DOL_URL_ROOT='' or DOL_URL_ROOT='/dolibarr'
  246. //print "xx".$_SERVER["PHP_SELF"].' '.DOL_URL_ROOT.'<br>';
  247. $urlfrom=preg_replace('/^'.preg_quote(DOL_URL_ROOT,'/').'/i','',$_SERVER["PHP_SELF"]);
  248. //print $urlfrom;
  249. if (! empty($profilearray['url'])) $urlwithmod=$profilearray['url'];
  250. //if ($i % $NBOFCOLS == 0) print '<tr>';
  251. print '<tr>';
  252. print '<td>'."\n";
  253. print '<form method="POST" name="form'.$profilearray['key'].'" action="'.$_SERVER["PHP_SELF"].'">'."\n";
  254. print '<input type="hidden" name="action" value="gotodemo">'."\n";
  255. print '<input type="hidden" name="urlfrom" value="'.urlencode($urlfrom).'">'."\n";
  256. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n";
  257. print '<input type="hidden" name="username" value="demo">'."\n";
  258. print '<table summary="Dolibarr online demonstration for profile '.$profilearray['label'].'" style="font-size:14px;" width="100%" class="CTable CTableRow'.($i%2==0?'1':'0').'">'."\n";
  259. // Title
  260. print '<tr>';
  261. print '<td width="50"><a href="'.$urlwithmod.'" id="a1'.$profilearray['key'].'" class="'.(empty($profilearray['url'])?'modulelineshow':'nomodulelines').'"><img src="'.$profilearray['icon'].'" width="48" border="0" alt="Demo '.$profilearray['label'].'"></a></td>';
  262. print '<td><a href="'.$urlwithmod.'" id="a2'.$profilearray['key'].'" class="'.(empty($profilearray['url'])?'modulelineshow':'nomodulelines').'">'.$langs->trans($profilearray['label']).'</a></td>';
  263. print '</tr>'."\n";
  264. // Modules
  265. if (empty($profilearray['url']))
  266. {
  267. print '<tr id="tr1'.$profilearray['key'].'" class="moduleline">';
  268. print '<td colspan="2">';
  269. print $langs->trans("ThisIsListOfModules").'<br>';
  270. print '<table width="100%">';
  271. $listofdisabledmodules=explode(',',$profilearray['disablemodules']);
  272. $j=0;$nbcolsmod=4;
  273. foreach($modules as $val) // Loop on qualified (enabled) modules
  274. {
  275. $modulekeyname=strtolower($val->name);
  276. $modulequalified=1;
  277. if (! empty($val->always_enabled) || in_array($modulekeyname,$alwayshiddenuncheckedmodules)) $modulequalified=0;
  278. if ($val->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && ! $conf->global->$const_name) $modulequalified=0;
  279. if ($val->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && ! $conf->global->$const_name) $modulequalified=0;
  280. if (! $modulequalified) continue;
  281. if (in_array($modulekeyname,$alwayshiddencheckedmodules))
  282. {
  283. print "\n".'<!-- Module '.$modulekeyname.' hidden and always checked -->';
  284. print '<input type="hidden" name="'.$modulekeyname.'" value="1">';
  285. }
  286. else
  287. {
  288. $modulo=($j % $nbcolsmod);
  289. if ($modulo == 0) print '<tr>';
  290. print '<td><input type="checkbox" class="checkbox" name="'.$modulekeyname.'" value="1"';
  291. if (in_array($modulekeyname,$alwaysuncheckedmodules)) print ' disabled="disabled"';
  292. if (! in_array($modulekeyname,$alwaysuncheckedmodules) && (! in_array($modulekeyname,$listofdisabledmodules) || in_array($modulekeyname,$alwayscheckedmodules))) print ' checked="checked"';
  293. print '> '.$val->getName().' &nbsp;';
  294. print '<!-- id='.$val->numero.' -->';
  295. print '</td>';
  296. if ($modulo == ($nbcolsmod - 1)) print '</tr>';
  297. $j++;
  298. }
  299. }
  300. print '</table>';
  301. print '</td>';
  302. print '</tr>'."\n";
  303. print '<tr id="tr2'.$profilearray['key'].'" class="moduleline"><td colspan="'.$nbcolsmod.'" align="center"><input type="submit" value=" &nbsp; &nbsp; '.$langs->trans("Start").' &nbsp; &nbsp; " class="button"></td></tr>';
  304. }
  305. print '</table></form>'."\n";
  306. print '</td>';
  307. //if ($i % $NBOFCOLS == ($NBOFCOLS-1)) print '</tr>'."\n";
  308. print '</tr>'."\n";
  309. $i++;
  310. }
  311. }
  312. print '</table>';
  313. print '</td>';
  314. print '</tr>';
  315. // Description
  316. print '<tr><td>';
  317. print '</td></tr>';
  318. // Button
  319. /*
  320. print '<tr><td align="center">';
  321. print '<input type="hidden" name="action" value="gotodemo">';
  322. print '<input class="button" type="submit" value=" < '.$langs->trans("GoToDemo").' > ">';
  323. print '</td></tr>';
  324. */
  325. print '</table>';
  326. $db->close();
  327. // Google Adsense (need Google module)
  328. if (! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN_GOOGLE_AD_SLOT))
  329. {
  330. print '<div align="center">'."\n";
  331. print '<script type="text/javascript"><!--'."\n";
  332. print 'google_ad_client = "'.$conf->global->MAIN_GOOGLE_AD_CLIENT.'";'."\n";
  333. print 'google_ad_slot = "'.$conf->global->MAIN_GOOGLE_AD_SLOT.'";'."\n";
  334. print 'google_ad_width = '.$conf->global->MAIN_GOOGLE_AD_WIDTH.';'."\n";
  335. print 'google_ad_height = '.$conf->global->MAIN_GOOGLE_AD_HEIGHT.';'."\n";
  336. print '//-->'."\n";
  337. print '</script>'."\n";
  338. print '<script type="text/javascript"'."\n";
  339. print 'src="http://pagead2.googlesyndication.com/pagead/show_ads.js">'."\n";
  340. print '</script>'."\n";
  341. print '</div>'."\n";
  342. }
  343. llxFooterVierge();
  344. /**
  345. * Show header for demo
  346. *
  347. * @param string $title Title
  348. * @param string $head Head string
  349. * @return void
  350. */
  351. function llxHeaderVierge($title, $head = "")
  352. {
  353. global $user, $conf, $langs;
  354. header("Content-type: text/html; charset=".$conf->file->character_set_client);
  355. print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
  356. //print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd>';
  357. print "\n";
  358. print "<html>\n";
  359. print "<head>\n";
  360. print '<meta name="robots" content="index,nofollow">'."\n";
  361. print '<meta name="keywords" content="dolibarr,demo,online,demonstration,example,test,web,erp,crm,demos,online">'."\n";
  362. print '<meta name="description" content="Dolibarr simple ERP/CRM demo. You can test here several profiles of Dolibarr ERP/CRM demos.">'."\n";
  363. print "<title>".$title."</title>\n";
  364. print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/theme/eldy/style.css.php?lang='.$langs->defaultlang.'">'."\n";
  365. print '<!-- Includes for JQuery -->'."\n";
  366. print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-latest.min.js"></script>'."\n";
  367. print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-ui-latest.custom.min.js"></script>'."\n";
  368. print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/tablednd/jquery.tablednd_0_5.js"></script>'."\n";
  369. if ($head) print $head."\n";
  370. print '<style type="text/css">'."\n";
  371. print '.body { font: 12px arial,verdana,helvetica !important; }'."\n";
  372. print '.CTable {
  373. padding: 6px;
  374. font: 12px arial,verdana,helvetica;
  375. font-weight: normal;
  376. color: #444444 !important;
  377. /* text-shadow: 1px 2px 3px #AFAFAF; */
  378. margin: 8px 0px 8px 2px;
  379. border-left: 1px solid #DDD;
  380. border-right: 1px solid #DDD;
  381. border-bottom: 1px solid #EEE;
  382. border-radius: 8px;
  383. -moz-border-radius: 8px;
  384. -moz-box-shadow: 4px 4px 4px #EEE;
  385. -webkit-box-shadow: 4px 4px 4px #EEE;
  386. box-shadow: 4px 4px 4px #EEE;
  387. background-image: linear-gradient(bottom, rgb(246,248,250) 85%, rgb(235,235,238) 100%);
  388. background-image: -o-linear-gradient(bottom, rgb(246,248,250) 85%, rgb(235,235,238) 100%);
  389. background-image: -moz-linear-gradient(bottom, rgb(246,248,250) 85%, rgb(235,235,238) 100%);
  390. background-image: -webkit-linear-gradient(bottom, rgb(246,248,250) 85%, rgb(235,235,238) 100%);
  391. background-image: -ms-linear-gradient(bottom, rgb(246,248,250) 85%, rgb(235,235,238) 100%);
  392. }';
  393. // print '.CTableRow1 { background: #f0f0f0; color: #000000; }';
  394. // print '.CTableRow0 { background: #fafafa; color: #000000; }';
  395. print '</style>';
  396. print "</head>\n";
  397. print '<body style="margin: 20px;">'."\n";
  398. }
  399. /**
  400. * Show footer for demo
  401. *
  402. * @return void
  403. */
  404. function llxFooterVierge()
  405. {
  406. printCommonFooter('public');
  407. print "\n";
  408. print "</body>\n";
  409. print "</html>\n";
  410. }
  411. ?>