示例#1
0
文件: site_news.php 项目: babae/etano
$loop = array();
if (!empty($totalrows)) {
    if ($o >= $totalrows) {
        $o = $totalrows - $r;
        $o = $o >= 0 ? $o : 0;
    }
    $query = "SELECT * FROM {$from} WHERE {$where} ORDER BY `news_id` DESC LIMIT {$o},{$r}";
    if (!($res = @mysql_query($query))) {
        trigger_error(mysql_error(), E_USER_ERROR);
    }
    while ($rsrow = mysql_fetch_assoc($res)) {
        $rsrow['news_title'] = sanitize_and_format($rsrow['news_title'], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]);
        $loop[] = $rsrow;
    }
    $output['pager2'] = pager($totalrows, $o, $r);
}
$output['return2me'] = 'site_news.php';
if (!empty($_SERVER['QUERY_STRING'])) {
    $output['return2me'] .= '?' . $_SERVER['QUERY_STRING'];
}
$output['return2me'] = rawurlencode($output['return2me']);
$tpl->set_file('content', 'site_news.html');
$tpl->set_loop('loop', $loop);
$tpl->set_var('output', $output);
$tpl->process('content', 'content', TPL_LOOP | TPL_NOLOOP);
$tpl->drop_loop('loop');
$tpl->drop_var('output.pager2');
unset($loop);
$tplvars['title'] = 'Site news';
$tplvars['page'] = 'site_news';
include 'frame.php';
示例#2
0
文件: search.php 项目: babae/etano
    $temp = $user_cache->get_cache_array($user_ids, 'result_user', $inject_by_uid);
    if (!empty($temp)) {
        $output['results'] = smart_table($temp, 5, $rv_mode, $cell_css_classes);
        $output['pager2'] = pager($output['totalrows'], $o, $r);
    } else {
        unset($output['totalrows']);
    }
    unset($user_cache, $temp);
    if (!$skip_cache) {
        // set $_GET for the pager.
        $_GET = array('search' => $output['search_md5'], 'v' => !empty($_GET['v']) ? $_GET['v'] : 'l');
    }
} else {
    unset($output['totalrows']);
}
$output['lang_253'] = sanitize_and_format($GLOBALS['_lang'][253], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]);
$output['lang_254'] = sanitize_and_format($GLOBALS['_lang'][254], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]);
$tpl->set_file('content', 'search.html');
$tpl->set_var('output', $output);
$tpl->process('content', 'content', TPL_OPTIONAL);
$tpl->drop_var('output.results');
$tpl->drop_var('output.pager2');
unset($output['results'], $output['pager2']);
$tplvars['title'] = $GLOBALS['_lang'][107];
$tplvars['page_title'] = $GLOBALS['_lang'][107];
$tplvars['page'] = 'search';
$tplvars['css'] = 'search.css.php';
if (is_file('search_left.php')) {
    include 'search_left.php';
}
include 'frame.php';
示例#3
0
文件: reject.php 项目: babae/etano
        $topass['message']['type'] = MESSAGE_ERROR;
        $topass['message']['text'] = 'Please enter the subject.';
    }
    if (empty($input['reject_reason'])) {
        $error = true;
        $topass['message']['type'] = MESSAGE_ERROR;
        $topass['message']['text'] = 'Please enter the reason.';
    }
}
if (!$error) {
    $tpl = new phemplate(_BASEPATH_ . '/skins_site/' . $def_skin . '/', 'remove_nonjs');
    $tpl->set_file('temp', 'emails/general.html');
    $tpl->set_var('output.content', $input['reject_reason']);
    $tpl->set_var('tplvars', $tplvars);
    $input['reject_reason'] = $tpl->process('temp', 'temp', TPL_FINISH | TPL_OPTIONAL | TPL_INCLUDE);
    $tpl->drop_var('temp');
    $tpl->drop_var('output.content');
    $reject_reason_email = $input['reject_reason'];
    // for email
    $input['reject_reason'] = sanitize_and_format($input['reject_reason'], TYPE_STRING, $__field2format[FIELD_TEXTAREA]);
    switch ($input['t']) {
        case AMTPL_REJECT_MEMBER:
            $query = "UPDATE `{$dbtable_prefix}user_profiles` SET `status`=" . STAT_EDIT . ",`last_changed`='" . gmdate('YmdHis') . "',`reject_reason`='" . $input['reject_reason'] . "' WHERE `fk_user_id`=" . $input['id'];
            if (!($res = @mysql_query($query))) {
                trigger_error(mysql_error(), E_USER_ERROR);
            }
            if (!empty($input['send_email'])) {
                $query = "SELECT `email` FROM `" . USER_ACCOUNTS_TABLE . "` WHERE `" . USER_ACCOUNT_ID . "`=" . $input['id'];
                if (!($res = @mysql_query($query))) {
                    trigger_error(mysql_error(), E_USER_ERROR);
                }
示例#4
0
function regenerate_skin_cache($skin_module_code = '', $last_id = 0)
{
    $timeout = 120;
    require _BASEPATH_ . '/includes/classes/Cache/Lite.php';
    $cache = new Cache_Lite($GLOBALS['_cache_config']);
    global $dbtable_prefix, $_pfields, $_pcats, $__field2format;
    $tpl = new phemplate(_BASEPATH_ . '/skins_site/', 'remove_nonjs');
    if (empty($skin_module_code)) {
        $query = "SELECT b.`config_value` as `skin_dir` FROM `{$dbtable_prefix}modules` a,`{$dbtable_prefix}site_options3` b WHERE a.`module_type`=" . MODULE_SKIN . " AND a.`module_code`=b.`fk_module_code` AND b.`config_option`='skin_dir'";
    } else {
        $query = "SELECT `config_value` as `skin_dir` FROM `{$dbtable_prefix}site_options3` WHERE `config_option`='skin_dir' AND `fk_module_code`='{$skin_module_code}'";
    }
    if (!($res = @mysql_query($query))) {
        trigger_error(mysql_error(), E_USER_ERROR);
    }
    for ($i = 0; $i < mysql_num_rows($res); ++$i) {
        $skins[] = mysql_result($res, $i, 0);
    }
    $now = gmdate('YmdHis');
    $select = '`fk_user_id`,`status`,`del`,UNIX_TIMESTAMP(`last_changed`) as `last_changed`,UNIX_TIMESTAMP(`date_added`) as `date_added`,`_user`,`_photo`,`rad_longitude`,`rad_latitude`';
    $used_fields = array();
    foreach ($_pfields as $field_id => $field) {
        if ($field->config['visible']) {
            $select .= ',' . $field->query_select();
            $used_fields[] = $field_id;
        }
    }
    // create the cache in every skin
    for ($s = 0; isset($skins[$s]); ++$s) {
        $GLOBALS['_lang'] = array();
        $GLOBALS['_pfields'] = array();
        $GLOBALS['_pcats'] = array();
        include _BASEPATH_ . '/skins_site/' . $skins[$s] . '/lang/global.inc.php';
        include _BASEPATH_ . '/includes/fields.inc.php';
        $query = "SELECT {$select} FROM `{$dbtable_prefix}user_profiles` WHERE `status`=" . STAT_APPROVED;
        if (!empty($last_id)) {
            $query .= " AND `fk_user_id`>{$last_id}";
        }
        $query .= " ORDER BY `fk_user_id`";
        if (!($res = @mysql_query($query))) {
            trigger_error(mysql_error(), E_USER_ERROR);
        }
        $start_time = (int) time();
        while ($profile = mysql_fetch_assoc($res)) {
            for ($i = 0; isset($used_fields[$i]); ++$i) {
                $field =& $_pfields[$used_fields[$i]];
                $field->set_value($profile, false);
                $profile[$field->config['dbfield']] = $field->display();
                // the label should be set after the call to display(). See field_birthdate::display() for explanation.
                $profile[$field->config['dbfield'] . '_label'] = $field->config['label'];
            }
            if (empty($profile['_photo']) || !is_file(_PHOTOPATH_ . '/t1/' . $profile['_photo']) || !is_file(_PHOTOPATH_ . '/t2/' . $profile['_photo']) || !is_file(_PHOTOPATH_ . '/' . $profile['_photo'])) {
                $profile['_photo'] = 'no_photo.gif';
            } else {
                $profile['has_photo'] = true;
            }
            $tpl->set_var('profile', $profile);
            // generate the user details for result lists
            $tpl->set_file('temp', $skins[$s] . '/static/result_user.html');
            $towrite = $tpl->process('', 'temp', TPL_OPTIONAL);
            $cache->save($towrite, 'skin' . $skins[$s] . $profile['fk_user_id'] . 'result_user');
            // generate the categories to be used on profile.php page
            $categs = array();
            $tpl->set_file('temp', $skins[$s] . '/static/profile_categ.html');
            foreach ($_pcats as $pcat_id => $pcat) {
                $fields = array();
                $j = 0;
                for ($k = 0; isset($pcat['fields'][$k]); ++$k) {
                    if (in_array($pcat['fields'][$k], $used_fields) && !empty($profile[$_pfields[$pcat['fields'][$k]]->config['dbfield']])) {
                        $fields[$j]['label'] = $profile[$_pfields[$pcat['fields'][$k]]->config['dbfield'] . '_label'];
                        $fields[$j]['field'] = $profile[$_pfields[$pcat['fields'][$k]]->config['dbfield']];
                        $fields[$j]['dbfield'] = $_pfields[$pcat['fields'][$k]]->config['dbfield'];
                        ++$j;
                    }
                }
                $categs['pcat_name'] = $pcat['pcat_name'];
                $categs['pcat_id'] = $pcat_id;
                $tpl->set_loop('fields', $fields);
                $tpl->set_var('categs', $categs);
                $towrite = $tpl->process('', 'temp', TPL_LOOP);
                $cache->save($towrite, 'skin' . $skins[$s] . $profile['fk_user_id'] . 'pcat' . $pcat_id);
                $tpl->drop_loop('fields');
                $tpl->drop_var('categs');
            }
            $tpl->drop_var('profile');
            if ((int) time() - $start_time > $timeout) {
                echo 'To prevent timeouts this script interrupts every few minutes. Press the continue button to resume.<br />';
                echo 'Last user ID processed: ', $profile['fk_user_id'], '<br />';
                echo '<form action="regenerate_skin.php" method="get">';
                echo '<input type="hidden" name="last_id" value="', $profile['fk_user_id'], '" />';
                if (!empty($skin_module_code)) {
                    echo '<input type="hidden" name="s" value="', $skin_module_code, '" />';
                }
                echo '<input type="submit" value="Continue" />';
                echo '</form>';
                die;
            }
        }
    }
}
示例#5
0
文件: gen_users.php 项目: babae/etano
function gen_user_cache()
{
    global $dbtable_prefix, $_pfields, $_pcats;
    $dirname = dirname(__FILE__);
    $temp = array();
    if ($dirname[0] == '/') {
        // unixes here
        $temp = explode('/', $dirname);
    } else {
        // windows here
        $temp = explode('\\', $dirname);
    }
    $interval = (int) $temp[count($temp) - 1];
    // that's how often we're executed ;)
    $tpl = new phemplate(_BASEPATH_ . '/skins_site/', 'remove_nonjs');
    $query = "SELECT a.`config_value` FROM `{$dbtable_prefix}site_options3` a,`{$dbtable_prefix}modules` b WHERE a.`config_option`='skin_dir' AND a.`fk_module_code`=b.`module_code` AND b.`module_type`=" . MODULE_SKIN;
    if (!($res = @mysql_query($query))) {
        trigger_error(mysql_error(), E_USER_ERROR);
    }
    $skins = array();
    for ($i = 0; $i < mysql_num_rows($res); ++$i) {
        $skins[] = mysql_result($res, $i, 0);
    }
    require _BASEPATH_ . '/includes/classes/Cache/Lite.php';
    $cache = new Cache_Lite($GLOBALS['_cache_config']);
    $now = gmdate('YmdHis');
    $select = '`fk_user_id`,`status`,`del`,UNIX_TIMESTAMP(`last_changed`) as `last_changed`,UNIX_TIMESTAMP(`date_added`) as `date_added`,`_user`,`_photo`,`rad_longitude`,`rad_latitude`';
    $used_fields = array();
    foreach ($_pfields as $field_id => $field) {
        if ($field->config['visible']) {
            $select .= ',' . $field->query_select();
            $used_fields[] = $field_id;
        }
    }
    // create the cache in every skin
    for ($s = 0; isset($skins[$s]); ++$s) {
        $GLOBALS['_lang'] = array();
        $GLOBALS['_pfields'] = array();
        $GLOBALS['_pcats'] = array();
        include _BASEPATH_ . '/skins_site/' . $skins[$s] . '/lang/global.inc.php';
        include _BASEPATH_ . '/includes/fields.inc.php';
        $query = "SELECT {$select} FROM `{$dbtable_prefix}user_profiles` WHERE `status`=" . STAT_APPROVED . " AND `last_changed`>=DATE_SUB('{$now}',INTERVAL " . ($interval + 2) . " MINUTE)";
        //print $query;
        if (!($res = @mysql_query($query))) {
            trigger_error(mysql_error(), E_USER_ERROR);
        }
        while ($profile = mysql_fetch_assoc($res)) {
            for ($i = 0; isset($used_fields[$i]); ++$i) {
                $field =& $_pfields[$used_fields[$i]];
                $field->set_value($profile, false);
                $profile[$field->config['dbfield']] = $field->display();
                // the label should be set after the call to display(). See field_birthdate::display() for explanation.
                $profile[$field->config['dbfield'] . '_label'] = $field->config['label'];
                /*
                				} elseif ($field['field_type']==FIELD_INT || $field['field_type']==FIELD_FLOAT) {
                		//			$profile[$field['dbfield']]=$profile[$field['dbfield']];
                */
            }
            if (empty($profile['_photo']) || !is_file(_PHOTOPATH_ . '/t1/' . $profile['_photo']) || !is_file(_PHOTOPATH_ . '/t2/' . $profile['_photo']) || !is_file(_PHOTOPATH_ . '/' . $profile['_photo'])) {
                $profile['_photo'] = 'no_photo.gif';
            } else {
                $profile['has_photo'] = true;
            }
            $tpl->set_var('profile', $profile);
            // generate the user details for result lists
            $tpl->set_file('temp', $skins[$s] . '/static/result_user.html');
            $towrite = $tpl->process('', 'temp', TPL_OPTIONAL);
            $cache->save($towrite, 'skin' . $skins[$s] . $profile['fk_user_id'] . 'result_user');
            // generate the categories to be used on profile.php page
            $categs = array();
            $tpl->set_file('temp', $skins[$s] . '/static/profile_categ.html');
            foreach ($_pcats as $pcat_id => $pcat) {
                $fields = array();
                $j = 0;
                for ($k = 0; isset($pcat['fields'][$k]); ++$k) {
                    if (in_array($pcat['fields'][$k], $used_fields) && !empty($profile[$_pfields[$pcat['fields'][$k]]->config['dbfield']])) {
                        $fields[$j]['label'] = $profile[$_pfields[$pcat['fields'][$k]]->config['dbfield'] . '_label'];
                        $fields[$j]['field'] = $profile[$_pfields[$pcat['fields'][$k]]->config['dbfield']];
                        $fields[$j]['dbfield'] = $_pfields[$pcat['fields'][$k]]->config['dbfield'];
                        ++$j;
                    }
                }
                $categs['pcat_name'] = $pcat['pcat_name'];
                $categs['pcat_id'] = $pcat_id;
                $tpl->set_loop('fields', $fields);
                $tpl->set_var('categs', $categs);
                $towrite = $tpl->process('', 'temp', TPL_LOOP);
                $cache->save($towrite, 'skin' . $skins[$s] . $profile['fk_user_id'] . 'pcat' . $pcat_id);
                $tpl->drop_loop('fields');
                $tpl->drop_var('categs');
            }
            $tpl->drop_var('profile');
        }
    }
    return true;
}
示例#6
0
function send_template_email($to, $subject, $template, $skin, $output = array(), $message_body = '')
{
    $myreturn = true;
    if (empty($message_body)) {
        if (isset($GLOBALS['tpl'])) {
            global $tpl;
            $old_root = $tpl->get_root();
            $tpl->set_root(_BASEPATH_ . '/skins_site/' . $skin . '/');
        } else {
            $tpl = new phemplate(_BASEPATH_ . '/skins_site/' . $skin . '/', 'remove_nonjs');
        }
        $tpl->set_file('temp', 'emails/' . $template);
        if (!empty($output)) {
            $tpl->set_var('output', $output);
        }
        global $tplvars;
        $tpl->set_var('tplvars', $tplvars);
        $message_body = $tpl->process('temp', 'temp', TPL_LOOP | TPL_OPTLOOP | TPL_OPTIONAL | TPL_FINISH);
        $tpl->drop_var('temp');
        $tpl->drop_var('output');
    }
    $config = get_site_option(array('mail_from', 'mail_crlf'), 'core');
    require_once _BASEPATH_ . '/includes/classes/phpmailer.class.php';
    $mail = new PHPMailer();
    $mail->IsHTML(true);
    $mail->From = $config['mail_from'];
    $mail->Sender = $config['mail_from'];
    $mail->FromName = _SITENAME_;
    if ($config['mail_crlf']) {
        $mail->LE = "\r\n";
    } else {
        $mail->LE = "\n";
    }
    $mail->IsMail();
    $mail->AddAddress($to);
    $mail->Subject = $subject;
    $mail->Body = $message_body;
    if (!$mail->Send()) {
        $myreturn = false;
        $GLOBALS['topass']['message']['type'] = MESSAGE_ERROR;
        $GLOBALS['topass']['message']['text'] = $mail->ErrorInfo;
        require_once _BASEPATH_ . '/includes/classes/log_error.class.php';
        new log_error(array('module_name' => 'send_template_email', 'text' => 'sending mail to ' . $to . ' failed:' . $message_body));
    }
    if (isset($old_root)) {
        $tpl->set_root($old_root);
    }
    return $myreturn;
}