Skip to content
Permalink
Browse files

first init

  • Loading branch information...
Metrax committed May 9, 2012
0 parents commit e05b7bb8f0f5af17f468140f3e33f29a54f6e873
Showing 6,205 changed files with 395,435 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
@@ -0,0 +1,183 @@
#!/usr/bin/php
<?php
/* refresh cached files and translations
*
* stop/start apache
* delete/recreate cached files
*
* TODO: quick&dirty to test functionality
*/
$opt['rootpath'] = '../htdocs/';
require($opt['rootpath'] . 'lib2/web.inc.php');
// stop apache
system($opt['httpd']['stop']);
echo "Delete cached files\n";
clearCache();
echo "Create translation files for gettext()\n";
$translationHandler->createMessageFiles();
echo "Create menu cache file\n";
createMenuCache();
echo "Create label cache file\n";
createLabelCache();
echo "Precompiling template files\n";
precompileAllTemplates();
// start apache
system($opt['httpd']['start']);
function precompileAllTemplates()
{
global $opt;
if ($hDir = opendir($opt['stylepath']))
{
while (($sFilename = readdir($hDir)) !== false)
{
if (substr($sFilename, -4) == '.tpl')
{
//echo substr($sFilename, 0, strlen($sFilename) - 4) . "\n";
precompileTemplate(substr($sFilename, 0, strlen($sFilename) - 4));
}
}
closedir($hDir);
}
// fix file ownership
$sCompileDir = $opt['rootpath'] . 'cache2/smarty/compiled/';
if ($hDir = opendir($sCompileDir))
{
while (($sFilename = readdir($hDir)) !== false)
{
if (filetype($sCompileDir . $sFilename) == 'file')
{
chown($sCompileDir . $sFilename, $opt['httpd']['user']);
chgrp($sCompileDir . $sFilename, $opt['httpd']['group']);
}
}
closedir($hDir);
}
}
function precompileTemplate($sTemplate)
{
global $opt;
foreach ($opt['locale'] AS $sLanguage => $v)
{
precompileTemplateWithLanguage($sTemplate, $sLanguage);
}
}
function precompileTemplateWithLanguage($sTemplate, $sLanguage)
{
global $opt, $translate;
// cheating a little bit
$opt['template']['locale'] = $sLanguage;
setlocale(LC_MONETARY, $opt['locale'][$opt['template']['locale']]['locales']);
setlocale(LC_TIME, $opt['locale'][$opt['template']['locale']]['locales']);
if (defined('LC_MESSAGES'))
setlocale(LC_MESSAGES, $opt['locale'][$opt['template']['locale']]['locales']);
if ($translate->t('INTERNAL_LANG', 'all', 'OcSmarty.class.php', '') != $sLanguage)
{
die("setlocale() failed to set language to " . $sLanguage . ". Is the translation of INTERNAL_LANG correct?\n");
}
$preTemplate = new OcSmarty();
$preTemplate->name = $sTemplate;
$preTemplate->compile($sTemplate . '.tpl', $preTemplate->get_compile_id());
}
function createMenuCache()
{
global $opt, $translate;
foreach ($opt['locale'] AS $sLanguage => $v)
{
// cheating a little bit
$opt['template']['locale'] = $sLanguage;
setlocale(LC_MONETARY, $opt['locale'][$opt['template']['locale']]['locales']);
setlocale(LC_TIME, $opt['locale'][$opt['template']['locale']]['locales']);
if (defined('LC_MESSAGES'))
setlocale(LC_MESSAGES, $opt['locale'][$opt['template']['locale']]['locales']);
if ($translate->t('INTERNAL_LANG', 'all', 'OcSmarty.class.php', '') != $sLanguage)
{
die("setlocale() failed to set language to " . $sLanguage . ". Is the translation of INTERNAL_LANG correct?\n");
}
// this will create the cache file
$menu = new Menu();
// change to file owner
chown($menu->sMenuFilename, $opt['httpd']['user']);
chgrp($menu->sMenuFilename, $opt['httpd']['group']);
}
}
function createLabelCache()
{
global $opt;
foreach ($opt['locale'] AS $sLanguage => $v)
{
// cheating a little bit
$opt['template']['locale'] = $sLanguage;
labels::CreateCacheFile();
// change to file owner
$sFilename = $opt['rootpath'] . 'cache2/labels-' . $opt['template']['locale'] . '.inc.php';
chown($sFilename, $opt['httpd']['user']);
chgrp($sFilename, $opt['httpd']['group']);
}
}
function clearCache()
{
global $tpl, $translang, $translate;
unlinkFiles('cache2', 'php');
unlinkFiles('cache2/smarty/cache', 'tpl');
unlinkFiles('cache2/smarty/compiled', 'inc');
unlinkFiles('cache2/smarty/compiled', 'php');
unlinkFiles('cache2/captcha', 'jpg');
unlinkFiles('cache2/captcha', 'txt');
}
function unlinkFiles($relbasedir, $ext)
{
global $opt;
if (substr($relbasedir, -1, 1) != '/')
$relbasedir .= '/';
if ($opt['rootpath'] . $relbasedir)
{
if ($dh = opendir($opt['rootpath'] . $relbasedir))
{
while (($file = readdir($dh)) !== false)
{
if ($file != '.' && $file != '..' && is_file($opt['rootpath'] . $relbasedir . $file))
{
if (substr($file, -(strlen($ext)+1), strlen($ext)+1) == '.' . $ext)
{
unlink($opt['rootpath'] . $relbasedir . $file);
}
}
}
}
closedir($dh);
}
}
?>
@@ -0,0 +1,57 @@
<?php
/***************************************************************************
* You can find the license in the docs directory
*
* Unicode Reminder メモ
***************************************************************************/
require('./lib2/web.inc.php');
$email = isset($_REQUEST['email']) ? trim($_REQUEST['email']) : '';
$code = isset($_REQUEST['code']) ? trim($_REQUEST['code']) : '';
$tpl->name = 'activation';
$tpl->menuitem = MNU_START_REGISTER_ACTIVATION;
$tpl->assign('errorEMail', false);
$tpl->assign('errorCode', false);
$tpl->assign('errorAlreadyActivated', false);
$tpl->assign('sucess', false);
if (isset($_REQUEST['submit']))
{
$email_not_ok = is_valid_email_address($email) ? false : true;
if ($email_not_ok == false)
{
$rs = sql("SELECT `user_id` `id`, `activation_code` `code` FROM `user` WHERE `email`='&1'", $email);
if ($r = sql_fetch_array($rs))
{
if (($r['code'] == $code) && ($code != ''))
{
// ok, account aktivieren
sql("UPDATE `user` SET `is_active_flag`=1, `activation_code`='' WHERE `user_id`='&1'", $r['id']);
$tpl->assign('sucess', true);
}
else
{
if ($r['code'] == '')
$tpl->assign('errorAlreadyActivated', true);
else
$tpl->assign('errorCode', true);
}
}
else
$tpl->assign('errorCode', true);
sql_free_result($rs);
}
else
$tpl->assign('errorEMail', true);
}
$tpl->assign('email', $email);
$tpl->assign('code', $code);
$tpl->display();
?>
Oops, something went wrong.

0 comments on commit e05b7bb

Please sign in to comment.
You can’t perform that action at this time.