function parse()
 {
     if ($phpbb_sid = session::get('phpbb_sid')) {
         $this->xml_string = utf8_str_replace('%phpbb_sid%', $phpbb_sid, $this->xml_string);
     }
     return parent::parse();
 }
 function test_template_redirect()
 {
     $strategy =& new meta_redirect_strategy('/redirect_template.html');
     $path = '/to/some/place?t=1&t=2';
     $message = strings::get('redirect_message');
     $message = utf8_str_replace('%path%', $path, $message);
     $this->response->expectOnce('write', array(new WantedPatternExpectation("~<meta http-equiv=refresh content='0;" . "url=" . preg_quote($path) . "'></head>" . "<body bgcolor=white><font color=707070>~")));
     $strategy->redirect($this->response, $path);
 }
Exemplo n.º 3
0
 function locale_format($number, $locale_string = null)
 {
     $locale = locale::instance($locale_string);
     $neg = $number < 0;
     $num = $neg ? -$number : $number;
     $num_text =& number_format($num, $locale->get_currency_fract_digits(), $locale->get_currency_decimal_symbol(), $locale->get_currency_thousand_separator());
     $text =& utf8_str_replace(array('%c', '%p', '%q'), array($locale->get_currency_symbol(), $neg ? $locale->get_currency_negative_symbol() : $locale->get_currency_positive_symbol(), $num_text), $neg ? $locale->get_currency_negative_format() : $locale->get_currency_positive_format());
     return $text;
 }
Exemplo n.º 4
0
function nel_newline_cleanup($string)
{
    if (nel_clear_whitespace($string) !== '') {
        $string = utf8_str_replace("\r", "\n", $string);
        if (utf8_substr_count($string, "\n") < BS_MAX_COMMENT_LINES) {
            $string = utf8_str_replace("\n\n", "<br>", $string);
            $string = utf8_str_replace("\n", "<br>", $string);
        } else {
            $string = utf8_str_replace("\n", "", $string);
            // \n is erased
        }
    }
    return $string;
}
function nel_render_thread_panel_thread($dataforce, $render, $thread_data)
{
    $render->add_data('has_file', $thread_data['has_file']);
    $render->add_multiple_data($thread_data);
    switch (BS_DATE_FORMAT) {
        case 'ISO':
            $render->add_data('post_time', date("Y/m/d H:i:s", floor($thread_data['post_time'] / 1000)));
            break;
        case 'US':
            $render->add_data('post_time', date("m/d/Y H:i:s", floor($thread_data['post_time'] / 1000)));
            break;
        case 'COM':
            $render->add_data('post_time', date("d/m/Y H:i:s", floor($thread_data['post_time'] / 1000)));
            break;
    }
    if (utf8_strlen($thread_data['name']) > 12) {
        $render->add_data('post_name', utf8_substr($thread_data['name'], 0, 11) . "...");
    }
    if (utf8_strlen($thread_data['subject']) > 12) {
        $render->add_data('subject', utf8_substr($thread_data['subject'], 0, 11) . "...");
    }
    if ($thread_data['email']) {
        $render->add_data('post_name', '"<a href="mailto:' . $thread_data['email'] . '">' . $thread_data['name'] . '</a>');
    }
    $thread_data['comment'] = utf8_str_replace("<br>", " ", $thread_data['comment']);
    $render->add_data('comment', htmlspecialchars($thread_data['comment']));
    if (utf8_strlen($thread_data['comment']) > 20) {
        $render->add_data('comment', utf8_substr($render->retrieve_data('comment'), 0, 19) . "...");
    }
    $render->add_data('host', @inet_ntop($thread_data['host']) ? inet_ntop($thread_data['host']) : 'Unknown');
    if ($thread_data['response_to'] == '0') {
        $render->add_data('is_op', TRUE);
    } else {
        $render->add_data('is_op', FALSE);
    }
    if (!empty($thread_data['files'])) {
        $files = $thread_data['files'];
        $filecount = count($files);
        $i = 0;
        while ($i < $filecount) {
            $files[$i]['filesize'] = (int) ceil($files[$i]['filesize'] / 1024);
            ++$i;
        }
        $render->add_data('files', $files);
    }
    $render->add_data('bg_class', $dataforce['j_increment'] % 2 ? 'row1' : 'row2');
    $render->parse('thread_panel_thread.tpl', 'management');
}
Exemplo n.º 6
0
function nel_parse_template($template, $subdirectory, $render, $regen)
{
    if (!empty($subdirectory)) {
        $subdirectory .= '/';
    }
    $template_short = utf8_str_replace('.tpl', '', $template);
    $info = nel_template_info($template, NULL, NULL, TRUE);
    if (is_null($info) || $info['loaded'] === FALSE || $info['loaded'] === NULL) {
        clearstatcache();
        $modify_time = filemtime(TEMPLATE_PATH . $subdirectory . $template);
        if (!isset($info['modify_time']) || $modify_time !== $info['modify_time'] || !file_exists(CACHE_PATH . $template_short . '.nelcache')) {
            $info['modify-time'] = $modify_time;
            $lol = file_get_contents(TEMPLATE_PATH . $subdirectory . $template);
            $lol = trim($lol);
            $begin = '<?php function nel_template_render_' . $template_short . '($render) { $temp = \'';
            // Start of the cached template
            $lol = preg_replace_callback('#({{.*?}})|({(.*?)})|(\')#', 'nel_escape_single_quotes', $lol);
            // Do escaping and variable parse
            $lol = preg_replace('#(})\\s*?({)#', '$1$2', $lol);
            // Clear white space between control statements
            $lol = preg_replace('#{{\\s*?(if|elseif|foreach|for|while)\\s*?(.*?)}}#', '\'; $1($2): $temp .= \'', $lol);
            // Parse opening control statements
            $lol = preg_replace('#{{\\s*?else\\s*?}}#', '\'; else: $temp .= \'', $lol);
            // Parse else statements
            $lol = preg_replace('#{{\\s*?(endif|endforeach|endfor|endwhile|endswitch)\\s*?}}#', '\'; $1; $temp .= \'', $lol);
            // Parse closing control statements
            $lol = preg_replace('#{{{\\s*?(.*?)\\s*?}}}#', '\'; $1; $temp .= \'', $lol);
            // Parse other PHP code
            $end = '\'; return $temp; } ?>';
            // End of the caches template
            $lol_out = $begin . $lol . $end;
            nel_write_file(CACHE_PATH . $template_short . '.nelcache', $lol_out, 0644);
        }
        include CACHE_PATH . $template_short . '.nelcache';
        $info['loaded'] = TRUE;
        nel_template_info($template, NULL, $info, FALSE);
    }
    if (!$regen) {
        $dat_temp = call_user_func('nel_template_render_' . $template_short, $render);
        return $dat_temp;
    }
}
 function _valid_perform(&$request, &$response)
 {
     $mail_data = $this->dataspace->export();
     if (isset($mail_data['sender_name'])) {
         $sender_name = $mail_data['sender_name'];
     } else {
         $sender_name = $mail_data['sender_firstname'] . ' ' . $mail_data['sender_lastname'];
     }
     $body = sprintf(strings::get('body_template', 'feedback'), $sender_name, $mail_data['sender_email'], $mail_data['body']);
     $body = utf8_str_replace('<br>', "\n", $body);
     $subject = $this->_get_mail_subject();
     $recipient_email = $this->_get_email();
     if (!$recipient_email || !send_plain_mail(array($recipient_email), $mail_data['sender_email'], $subject, $body)) {
         message_box::write_error(strings::get('mail_not_sent', 'feedback'));
         $request->set_status(REQUEST_STATUS_FAILUER);
         return;
     }
     message_box::write_error(strings::get('message_was_sent', 'feedback'));
     $request->set_status(REQUEST_STATUS_FORM_SUBMITTED);
     $response->redirect($_SERVER['PHP_SELF']);
 }
 function process($content)
 {
     $content = utf8_strtolower($content);
     $content = utf8_str_replace("\n", ' ', $content);
     $content = utf8_str_replace("\t", ' ', $content);
     $content = utf8_str_replace("\r", ' ', $content);
     $search = array("'<script[^>]*?>.*?</script>'si", "'<[\\/\\!]*?[^<>]*?>'si", "'([\r\n])[\\s]+'");
     $replace = array('', ' ', ' ');
     $content = preg_replace($search, $replace, $content);
     $content = preg_replace("#(\\.){2,}#", ' ', $content);
     $content = preg_replace("#^\\.#", ' ', $content);
     $content = preg_replace("#\\s\\.#", ' ', $content);
     $content = preg_replace("#\\.\\s#", ' ', $content);
     $content = preg_replace("#\\.\$#", ' ', $content);
     //non utf8 chars(�,�)
     $content = preg_replace("#(\\s|^)(\"|'|`|�|�)(\\w)#", '\\1\\3', $content);
     $content = preg_replace("#(\\w)(\"|'|`|�|�)(\\s|\$)#u", '\\1\\3', $content);
     $content = utf8_str_replace("&nbsp;", ' ', $content);
     $content = utf8_str_replace(":", ' ', $content);
     $content = utf8_str_replace(",", ' ', $content);
     $content = utf8_str_replace(";", ' ', $content);
     $content = utf8_str_replace("(", ' ', $content);
     $content = utf8_str_replace(")", ' ', $content);
     $content = utf8_str_replace("-", ' ', $content);
     $content = utf8_str_replace("+", ' ', $content);
     $content = utf8_str_replace("/", ' ', $content);
     $content = utf8_str_replace("!", ' ', $content);
     $content = utf8_str_replace("?", ' ', $content);
     $content = utf8_str_replace("[", ' ', $content);
     $content = utf8_str_replace("]", ' ', $content);
     $content = utf8_str_replace("\$", ' ', $content);
     $content = utf8_str_replace("\\", ' ', $content);
     $content = utf8_str_replace("<", ' ', $content);
     $content = utf8_str_replace(">", ' ', $content);
     $content = utf8_str_replace("*", ' ', $content);
     $content = utf8_trim(preg_replace("~\\s+~u", ' ', $content));
     return $content;
 }
 function send_activate_password_email(&$user_data, $password)
 {
     include_once LIMB_DIR . '/core/lib/mail/mail.inc.php';
     global $_SERVER;
     $http_host = $_SERVER['HTTP_HOST'];
     $filename = PROJECT_DIR . '/design/main/templates/user/generated_password_mail.html';
     if (!file_exists($filename)) {
         $filename = LIMB_DIR . '/design/default/templates/user/generated_password_mail.html';
     }
     if (!file_exists($filename)) {
         error('template file for password notification email not found!', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('file_name' => $filename));
     }
     $fd = fopen($filename, "r");
     $contents = fread($fd, filesize($filename));
     fclose($fd);
     $contents = utf8_str_replace('%website_name%', $http_host, $contents);
     $contents = utf8_str_replace('%user_name%', $user_data['name'] . ' ' . $user_data['lastname'], $contents);
     $contents = utf8_str_replace('%new_password%', $password, $contents);
     $contents = utf8_str_replace('%website_href%', $http_host, $contents);
     $contents = utf8_str_replace('%website_email%', ADMINISTRATOR_EMAIL, $contents);
     $activate_href = 'http://' . $http_host . '/root/activate_password?user='******'email'] . '&id=' . $user_data['password'];
     $contents = utf8_str_replace('%activate_href%', $activate_href, $contents);
     if (!send_plain_mail(array($user_data['email']), ADMINISTRATOR_EMAIL, strings::get('generate_password_theme', 'user'), $contents)) {
         debug::write_error('error while sending password notification email', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
         return false;
     } else {
         return true;
     }
 }
Exemplo n.º 10
0
function nel_process_file_info()
{
    global $enabled_types;
    $files = array();
    $i = 0;
    $filetypes_loaded = FALSE;
    foreach ($_FILES as $file) {
        if ($file['error'] === UPLOAD_ERR_OK) {
            if (!empty($file['name'])) {
                if (!$filetypes_loaded) {
                    include INCLUDE_PATH . 'filetype.php';
                    $filetypes_loaded = TRUE;
                }
                // Grab/strip the file extension
                $files[$i]['ext'] = ltrim(strrchr($file['name'], '.'), '.');
                $files[$i]['basic_filename'] = utf8_str_replace('.' . $files[$i]['ext'], "", $file['name']);
                $max_upload = ini_get('upload_max_filesize');
                $size_unit = utf8_strtolower(utf8_substr($max_upload, -1, 1));
                $max_upload = utf8_strtolower(utf8_substr($max_upload, 0, -1));
                if ($size_unit === 'g') {
                    $max_upload = $max_upload * 1024 * 1024 * 1024;
                } else {
                    if ($size_unit === 'm') {
                        $max_upload = $max_upload * 1024 * 1024;
                    } else {
                        if ($size_unit === 'k') {
                            $max_upload = $max_upload * 1024;
                        } else {
                            // Already in bytes
                        }
                    }
                }
                if ($file['size'] > BS_MAX_FILESIZE * 1024) {
                    nel_derp(19, array('origin' => 'POST', 'bad-filename' => $files[i]['basic_filename'] . $files[i]['ext'], 'files' => array($files[$i])));
                }
                $files[$i]['dest'] = SRC_PATH . $file['name'] . '.tmp';
                move_uploaded_file($file['tmp_name'], $files[$i]['dest']);
                chmod($files[$i]['dest'], 0644);
                $files[$i]['fsize'] = filesize($files[$i]['dest']);
                $test_ext = utf8_strtolower($files[$i]['ext']);
                $file_test = file_get_contents($files[$i]['dest'], NULL, NULL, 0, 65535);
                $file_good = FALSE;
                $file_allowed = FALSE;
                // Graphics
                if (array_key_exists($test_ext, $filetypes)) {
                    if ($enabled_types['enable_' . utf8_strtolower($filetypes[$test_ext]['subtype'])] && $enabled_types['enable_' . utf8_strtolower($filetypes[$test_ext]['supertype'])]) {
                        $file_allowed = TRUE;
                        if (preg_match('#' . $filetypes[$test_ext]['id_regex'] . '#', $file_test)) {
                            $files[$i]['supertype'] = $filetypes[$test_ext]['supertype'];
                            $files[$i]['subtype'] = $filetypes[$test_ext]['subtype'];
                            $files[$i]['mime'] = $filetypes[$test_ext]['mime'];
                            $file_good = TRUE;
                        }
                    }
                }
                if (!$file_allowed) {
                    nel_derp(6, array('origin' => 'POST', 'bad-filename' => $files[i]['basic_filename'] . $files[i]['ext'], 'files' => array($files[$i])));
                }
                if (!$file_good) {
                    nel_derp(18, array('origin' => 'POST', 'bad-filename' => $files[i]['basic_filename'] . $files[i]['ext'], 'files' => array($files[$i])));
                }
                ++$i;
            }
            if ($files_count == BS_MAX_POST_FILES) {
                break;
            }
        } else {
            if ($file['error'] === UPLOAD_ERR_INI_SIZE) {
                nel_derp(19, array('origin' => 'POST', 'bad-filename' => $files[i]['basic_filename'] . $files[i]['ext'], 'files' => array($files[$i])));
            }
        }
    }
    return $files;
}
 function data_handler(&$parser, $data)
 {
     $data = utf8_str_replace("\t", '  ', $data);
     $this->html .= $data;
 }
Exemplo n.º 12
0
/**
* Adds further quotes to a regex pattern
*/
function preg_replacement_quote($replacement)
{
    $replacement = utf8_str_replace("\\", "\\\\", $replacement);
    $replacement = utf8_str_replace("\$", "\\\$", $replacement);
    return $replacement;
}
Exemplo n.º 13
0
 function write($string, $verbosity_level = MESSAGE_LEVEL_NOTICE, $label = '')
 {
     $this->strings[] = array('string' => utf8_str_replace("'", "\\'", $string), 'level' => $verbosity_level, 'label' => utf8_str_replace("'", "\\'", $label));
 }
Exemplo n.º 14
0
function nel_render_post($dataforce, $render, $response, $partial, $gen_data, $treeline, $dbh)
{
    global $link_resno;
    $render->add_data('insert_hr', $gen_data['insert_hr']);
    $post_data = $treeline[$gen_data['post_counter']];
    $render->add_multiple_data($post_data);
    if ($partial) {
        $link_resno = 0;
    } else {
        $link_resno = $dataforce['response_id'];
    }
    $render->add_data('expand_post', $gen_data['expand_post']);
    $render->add_data('first100', $gen_data['first100']);
    $render->add_data('response_id', $dataforce['response_id']);
    $render->add_data('tripcode', !is_null($post_data['tripcode']) ? BS_TRIPKEY_MARKER . $post_data['tripcode'] : '');
    $render->add_data('secure_tripcode', !is_null($post_data['secure_tripcode']) ? BS_TRIPKEY_MARKER . BS_TRIPKEY_MARKER . $post_data['secure_tripcode'] : '');
    $post_data['comment'] = nel_newline_cleanup($post_data['comment']);
    $post_data['comment'] = preg_replace('#(^|>)(&gt;[^<]*|ÅÑ[^<]*)#', '$1<span class="post-quote">$2</span>', $post_data['comment']);
    $post_data['comment'] = preg_replace_callback('#&gt;&gt;([0-9]+)#', 'nel_parse_links', $post_data['comment']);
    if (nel_clear_whitespace($post_data['comment']) === '') {
        $post_data['comment'] = nel_stext('THREAD_NOTEXT');
    }
    $render->add_sanitized_data('comment-part', utf8_str_replace('>><a href="../"', '>><a href="', $post_data['comment']));
    $render->add_sanitized_data('comment', $post_data['comment']);
    $render->add_sanitized_data('name', $post_data['name']);
    $render->add_sanitized_data('email', $post_data['email']);
    $render->add_sanitized_data('subject', $post_data['subject']);
    $render->add_data('sticky', (bool) $post_data['sticky']);
    $temp_dot = $partial ? '' : $dataforce['dotdot'];
    $post_id = $response ? $post_data['response_to'] : $post_data['post_number'];
    if (!$dataforce['omitted_done']) {
        $render->add_data('omitted_count', $gen_data['post_count'] - BS_ABBREVIATE_THREAD);
        $render->add_data('omitted_posts', TRUE);
    } else {
        $render->add_data('omitted_posts', FALSE);
    }
    if ($gen_data['has_file']) {
        $render->add_data('has_file', TRUE);
        $filecount = count($gen_data['files']);
        $render->add_data('multifile', $filecount > 1 ? TRUE : FALSE);
        $i = 0;
        $files = $gen_data['files'];
        while ($i < $filecount) {
            $files[$i]['img_dim'] = !is_null($files[$i]['image_width']) && !is_null($files[$i]['image_height']) ? TRUE : FALSE;
            $files[$i]['file_location'] = $temp_dot . SRC_DIR . $post_id . '/' . $files[$i]['filename'] . "." . $files[$i]['extension'];
            $files[$i]['filesize'] = round((int) $files[$i]['filesize'] / 1024, 2);
            if (BS1_USE_THUMB) {
                if (isset($files[$i]['preview_name'])) {
                    $files[$i]['has_preview'] = TRUE;
                    $files[$i]['preview_location'] = $temp_dot . THUMB_DIR . $post_id . '/' . $files[$i]['preview_name'];
                    if ($files[$i]['preview_width'] != 0) {
                        if ($files[$i]['preview_width'] > BS_MAX_MULTI_WIDTH || $files[$i]['preview_height'] > BS_MAX_MULTI_HEIGHT) {
                            $ratio = min(BS_MAX_MULTI_HEIGHT / $files[$i]['preview_height'], BS_MAX_MULTI_WIDTH / $files[$i]['preview_width']);
                            $files[$i]['preview_width'] = intval($ratio * $files[$i]['preview_width']);
                            $files[$i]['preview_height'] = intval($ratio * $files[$i]['preview_height']);
                        }
                    }
                } else {
                    if (BS1_USE_FILE_ICON && file_exists(BOARD_FILES . 'imagez/nelliel/filetype/' . utf8_strtolower($files[$i]['supertype']) . '/' . utf8_strtolower($files[$i]['subtype']) . '.png')) {
                        $files[$i]['has_preview'] = TRUE;
                        $files[$i]['preview_location'] = $temp_dot . BOARD_FILES . '/imagez/nelliel/filetype/' . utf8_strtolower($files[$i]['supertype']) . '/' . utf8_strtolower($files[$i]['subtype']) . '.png';
                        $files[$i]['preview_width'] = BS_MAX_WIDTH < 64 ? BS_MAX_WIDTH : '128';
                        $files[$i]['preview_height'] = BS_MAX_HEIGHT < 64 ? BS_MAX_HEIGHT : '128';
                    } else {
                        $files[$i]['has_preview'] = FALSE;
                    }
                }
            } else {
                $files[$i]['has_preview'] = FALSE;
            }
            $files[$i]['source'] = nel_cleanse_the_aids($files[$i]['source']);
            $files[$i]['license'] = nel_cleanse_the_aids($files[$i]['license']);
            $files[$i]['endline'] = ($i + 1) % BS_MAX_FILES_ROW == 0 ? TRUE : FALSE;
            ++$i;
        }
        $render->add_data('files', $files);
    } else {
        $render->add_data('multifile', FALSE);
    }
    $curr_time = floor($render->retrieve_data('post_time') / 1000);
    switch (BS_DATE_FORMAT) {
        case 'ISO':
            $render->add_data('post_time', date("Y", $curr_time) . BS_DATE_SEPARATOR . date("m", $curr_time) . BS_DATE_SEPARATOR . date("d (D) H:i:s", $curr_time));
            break;
        case 'US':
            $render->add_data('post_time', date("m", $curr_time) . BS_DATE_SEPARATOR . date("d", $curr_time) . BS_DATE_SEPARATOR . date("Y (D) H:i:s", $curr_time));
            break;
        case 'COM':
            $render->add_data('post_time', date("d", $curr_time) . BS_DATE_SEPARATOR . date("m", $curr_time) . BS_DATE_SEPARATOR . date("Y (D) H:i:s", $curr_time));
            break;
    }
    switch ($render->retrieve_data('mod_post')) {
        case '1':
            $render->add_data('staff_post', nel_stext('THREAD_JANPOST'));
            $render->add_data('secure_tripcode', '');
            break;
        case '2':
            $render->add_data('staff_post', nel_stext('THREAD_MODPOST'));
            $render->add_data('secure_tripcode', '');
            break;
        case '3':
            $render->add_data('staff_post', nel_stext('THREAD_ADMINPOST'));
            $render->add_data('secure_tripcode', '');
            break;
        default:
            $render->add_data('staff_post', '');
    }
    $render->add_data('logged_in', FALSE);
    $render->add_data('page_ref1', PHP_SELF2 . PHP_EXT);
    $render->add_data('page_ref2', '');
    if (!empty($_SESSION) && !$_SESSION['ignore_login']) {
        $render->add_data('logged_in', TRUE);
        $render->add_data('host', @inet_ntop($render->retrieve_data('host')) ? inet_ntop($render->retrieve_data('host')) : 'Unknown');
        $render->add_data('perm_ban', $_SESSION['perms']['perm_ban']);
        $render->add_data('page_ref1', PHP_SELF . '?mode=display&page=0');
        $render->add_data('page_ref2', PHP_SELF . '?page=');
        $render->add_data('the_session', session_id());
    }
    if ($response) {
        $render->parse('response_post.tpl', '');
    } else {
        $render->parse('op_post.tpl', '');
    }
}
Exemplo n.º 15
0
/**
 * utf8_clean( )
 * 
 * Accepts a string and removes all non-UTF-8 characters from it.
 * @since 1.0
 * 
 * @param    string $str The string to be sanitized.
 * @return   string Clean UTF-8 encoded string
 */
function utf8_clean($str, $remove_bom = false)
{
    //http://stackoverflow.com/questions/1401317/remove-non-utf8-characters-from-string
    //caused connection reset problem on larger strings
    //$regx = '/((?:[\x00-\x7F]|[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}){1,})|./';
    $regx = '/([\\x00-\\x7F]|[\\xC0-\\xDF][\\x80-\\xBF]|[\\xE0-\\xEF][\\x80-\\xBF]{2}|[\\xF0-\\xF7][\\x80-\\xBF]{3})|./s';
    $str = preg_replace($regx, '$1', $str);
    if ($remove_bom) {
        $str = utf8_str_replace(utf8_bom(), '', $str);
    }
    return $str;
}
 function utf8_str_replace($s, $r, $str)
 {
     return utf8_str_replace($s, $r, $str);
 }
Exemplo n.º 17
0
     $User_cat = mysql_query("SELECT * from " . table_users . "");
     while ($row = mysql_fetch_array($User_cat)) {
         $UserId = $row['user_id'];
         $new_cat = $row['user_categories'] . "," . $last_IDsql;
         $sql = "UPDATE " . table_users . " set user_categories='{$new_cat}' WHERE user_id = '{$UserId}'";
         $query = mysql_query($sql);
     }
     rebuild_the_tree();
     ordernew();
     Cat_Safe_Names();
     header("Location: admin_categories.php");
 }
 if ($action == "changecolor") {
     $id = sanitize($_REQUEST['id'], 3);
     $color = sanitize($_REQUEST['color'], 3);
     $color = utf8_str_replace('#', '', $color);
     if (!is_numeric($id)) {
         die;
     }
     $sql = "update " . table_categories . " set category_color = '" . $color . "' where category__auto_id=" . $id . ";";
     echo $sql;
     $db->query($sql);
     Cat_Safe_Names();
 }
 if ($action == "remove") {
     $id = sanitize($_REQUEST['id'], 3);
     if (!is_numeric($id)) {
         die;
     }
     $sql = "delete from " . table_categories . " where category__auto_id=" . $id . ";";
     $db->query($sql);
Exemplo n.º 18
0
<?php
Exemplo n.º 19
0
function nel_cache_rules($dbh)
{
    $gmode = '';
    $amode = '';
    $vmode = '';
    $dmode = '';
    $rmode = '';
    $omode = '';
    $result = $dbh->query('SELECT * FROM ' . CONFIGTABLE . ' WHERE config_type IN ("filetype_allow_g","filetype_allow_a","filetype_allow_o","filetype_allow_p","filetype_allow_d","filetype_allow_r")');
    $config_list = $result->fetchALL(PDO::FETCH_ASSOC);
    $result_count = count($config_list);
    $config_list2 = array();
    foreach ($config_list as $array) {
        if (array_search('enable_graphics', $array) !== FALSE) {
            $config_list2['graphics'] = $array['setting'];
        } else {
            if (array_search('enable_audio', $array) !== FALSE) {
                $config_list2['audio'] = $array['setting'];
            } else {
                if (array_search('enable_video', $array) !== FALSE) {
                    $config_list2['video'] = $array['setting'];
                } else {
                    if (array_search('enable_other', $array) !== FALSE) {
                        $config_list2['other'] = $array['setting'];
                    } else {
                        if (array_search('enable_package', $array) !== FALSE) {
                            $config_list2['package'] = $array['setting'];
                        } else {
                            if (array_search('enable_document', $array) !== FALSE) {
                                $config_list2['document'] = $array['setting'];
                            } else {
                                if (array_search('enable_archive', $array) !== FALSE) {
                                    $config_list2['archive'] = $array['setting'];
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $i = 0;
    while ($i < $result_count) {
        $t_element = utf8_str_replace('enable_', '', $config_list[$i]['config_name']);
        if ($config_list[$i]['setting'] !== '1') {
            ++$i;
            continue;
        }
        if ($config_list[$i]['config_type'] === 'filetype_allow_g' && $t_element !== 'graphics' && $config_list2['graphics'] === '1') {
            $gmode = $gmode . $t_element . ', ';
        } else {
            if ($config_list[$i]['config_type'] === 'filetype_allow_a' && $t_element !== 'audio' && $config_list2['audio'] === '1') {
                $amode = $amode . $t_element . ', ';
            } else {
                if ($config_list[$i]['config_type'] === 'filetype_allow_v' && $t_element !== 'video' && $config_list2['video'] === '1') {
                    $vmode = $vmode . $t_element . ', ';
                } else {
                    if ($config_list[$i]['config_type'] === 'filetype_allow_o' && $t_element !== 'other' && $config_list2['other'] === '1') {
                        $omode = $omode . $t_element . ', ';
                    } else {
                        if ($config_list[$i]['config_type'] === 'filetype_allow_d' && $t_element !== 'document' && $config_list2['document'] === '1') {
                            $dmode = $dmode . $t_element . ', ';
                        } else {
                            if ($config_list[$i]['config_type'] === 'filetype_allow_r' && $t_element !== 'archive' && $config_list2['archive'] === '1') {
                                $rmode = $rmode . $t_element . ', ';
                            }
                        }
                    }
                }
            }
        }
        ++$i;
    }
    $rule_list = '';
    if ($gmode !== '') {
        $gmode = utf8_substr($gmode, 0, -2);
        $rule_list .= '<li>' . nel_stext('FILES_GRAPHICS') . utf8_strtoupper($gmode) . '</li>';
    }
    if ($amode !== '') {
        $amode = utf8_substr($amode, 0, -2);
        $rule_list .= '
							<li>' . nel_stext('FILES_AUDIO') . utf8_strtoupper($amode) . '</li>';
    }
    if ($vmode !== '') {
        $vmode = utf8_substr($vmode, 0, -2);
        $rule_list .= '
							<li>' . nel_stext('FILES_VIDEO') . utf8_strtoupper($vmode) . '</li>';
    }
    if ($dmode !== '') {
        $dmode = utf8_substr($dmode, 0, -2);
        $rule_list .= '
							<li>' . nel_stext('FILES_DOCUMENT') . utf8_strtoupper($dmode) . '</li>';
    }
    if ($rmode !== '') {
        $rmode = utf8_substr($rmode, 0, -2);
        $rule_list .= '
							<li>' . nel_stext('FILES_ARCHIVE') . utf8_strtoupper($rmode) . '</li>';
    }
    if ($omode !== '') {
        $omode = utf8_substr($omode, 0, -2);
        $rule_list .= '
							<li>' . nel_stext('FILES_OTHER') . utf8_strtoupper($omode) . '</li>';
    }
    return $rule_list;
}
Exemplo n.º 20
0
 /**
  * Correctly adjust LIKE expression for special characters
  * Some DBMS are handling them in a different way
  *
  * @param string $expression The expression to use. Every wildcard is escaped, except $this->any_char and $this->one_char
  * @return string LIKE expression including the keyword!
  */
 function sql_like_expression($expression)
 {
     $expression = utf8_str_replace(array('_', '%'), array("\\_", "\\%"), $expression);
     $expression = utf8_str_replace(array(chr(0) . "\\_", chr(0) . "\\%"), array('_', '%'), $expression);
     return $this->_sql_like_expression('LIKE \'' . $this->sql_escape($expression) . '\'');
 }
 function _prepare_localized_message($path)
 {
     $message = strings::get('redirect_message');
     //???
     return utf8_str_replace('%path%', $path, $message);
 }