Example #1
0
     DB::run()->query("INSERT INTO `posts` (`posts_topics_id`, `posts_forums_id`, `posts_user`, `posts_text`, `posts_time`, `posts_ip`, `posts_brow`) VALUES (?, ?, ?, ?, ?, ?, ?);", array($tid, $topics['topics_forums_id'], $log, $msg, SITETIME, $ip, $brow));
     $lastid = DB::run()->lastInsertId();
     DB::run()->query("UPDATE `users` SET `users_allforum`=`users_allforum`+1, `users_point`=`users_point`+1, `users_money`=`users_money`+5 WHERE `users_login`=? LIMIT 1;", array($log));
     DB::run()->query("UPDATE `topics` SET `topics_posts`=`topics_posts`+1, `topics_last_user`=?, `topics_last_time`=? WHERE `topics_id`=?;", array($log, SITETIME, $tid));
     DB::run()->query("UPDATE `forums` SET `forums_posts`=`forums_posts`+1, `forums_last_id`=?, `forums_last_themes`=?, `forums_last_user`=?, `forums_last_time`=? WHERE `forums_id`=?;", array($tid, $topics['topics_title'], $log, SITETIME, $topics['topics_forums_id']));
     // Обновление родительского форума
     if ($topics['forums_parent'] > 0) {
         DB::run()->query("UPDATE `forums` SET `forums_last_id`=?, `forums_last_themes`=?, `forums_last_user`=?, `forums_last_time`=? WHERE `forums_id`=?;", array($tid, $topics['topics_title'], $log, SITETIME, $topics['forums_parent']));
     }
 }
 // -- Загрузка файла -- //
 if (!empty($_FILES['file']['name']) && !empty($lastid)) {
     if ($udata['users_point'] >= $config['forumloadpoints']) {
         if (is_uploaded_file($_FILES['file']['tmp_name'])) {
             $filename = check($_FILES['file']['name']);
             $filename = !is_utf($filename) ? utf_lower(win_to_utf($filename)) : utf_lower($filename);
             $filesize = $_FILES['file']['size'];
             if ($filesize > 0 && $filesize <= $config['forumloadsize']) {
                 $arrext = explode(',', $config['forumextload']);
                 $ext = getExtension($filename);
                 if (in_array($ext, $arrext) && $ext != 'php') {
                     if (utf_strlen($filename) > 50) {
                         $filename = utf_substr($filename, 0, 45) . '.' . $ext;
                     }
                     if (!file_exists(BASEDIR . '/upload/forum/' . $topics['topics_id'])) {
                         $old = umask(0);
                         mkdir(BASEDIR . '/upload/forum/' . $topics['topics_id'], 0777, true);
                         umask($old);
                     }
                     $num = 0;
                     $hash = $lastid . '.' . $ext;
Example #2
0
         show_error('Разделы форума еще не созданы!');
     }
     break;
     ############################################################################################
     ##                                          Поиск                                         ##
     ############################################################################################
 ############################################################################################
 ##                                          Поиск                                         ##
 ############################################################################################
 case 'search':
     $find = check(strval($_GET['find']));
     $type = abs(intval($_GET['type']));
     $where = abs(intval($_GET['where']));
     $period = abs(intval($_GET['period']));
     $section = abs(intval($_GET['section']));
     if (!is_utf($find)) {
         $find = win_to_utf($find);
     }
     if (utf_strlen($find) >= 3 && utf_strlen($find) <= 50) {
         $findmewords = explode(" ", utf_lower($find));
         $arrfind = array();
         foreach ($findmewords as $val) {
             if (utf_strlen($val) >= 3) {
                 $arrfind[] = empty($type) ? '+' . $val . '*' : $val . '*';
             }
         }
         $findme = implode(" ", $arrfind);
         if ($type == 2 && count($findmewords) > 1) {
             $findme = "\"{$find}\"";
         }
         $config['newtitle'] = $find . ' - Результаты поиска';
Example #3
0
 case 'preview':
     $view = isset($_GET['view']) ? abs(intval($_GET['view'])) : '';
     $downs = DB::run()->queryFetch("SELECT * FROM `downs` WHERE `downs_id`=? LIMIT 1;", array($id));
     if (!empty($downs) && $view !== '') {
         if (!empty($downs['downs_active'])) {
             $zip = new PclZip('files/' . $downs['downs_link']);
             $content = $zip->extract(PCLZIP_OPT_BY_INDEX, $view, PCLZIP_OPT_EXTRACT_AS_STRING);
             if (!empty($content)) {
                 $filecontent = $content[0]['content'];
                 $filename = $content[0]['filename'];
                 $config['newtitle'] = 'Просмотр файла - ' . $filename;
                 echo '<img src="/images/img/zip.gif" alt="image" /> <b>' . $downs['downs_title'] . '</b><br /><br />';
                 echo '<b>' . $filename . '</b> (' . formatsize($content[0]['size']) . ')<hr />';
                 if (!preg_match("/\\.(gif|png|bmp|wbmp|jpg|jpeg)\$/", $filename)) {
                     if ($content[0]['size'] > 0) {
                         if (is_utf($filecontent)) {
                             echo '<pre class="prettyprint linenums">' . htmlspecialchars($filecontent) . '</pre><br />';
                         } else {
                             echo '<pre class="prettyprint linenums">' . win_to_utf(htmlspecialchars($filecontent)) . '</pre><br />';
                         }
                     } else {
                         show_error('Данный файл пустой!');
                     }
                 } else {
                     if (!empty($_GET['img'])) {
                         $ext = getExtension($filename);
                         while (ob_get_level()) {
                             ob_end_clean();
                         }
                         header("Content-Encoding: none");
                         header("Content-type: image/{$ext}");
Example #4
0
     $arraytags = unserialize(file_get_contents(DATADIR . "/temp/tagcloud.dat"));
     $max = max($arraytags);
     $min = min($arraytags);
     render('blog/tags', array('tags' => $arraytags, 'max' => $max, 'min' => $min));
     break;
     ############################################################################################
     ##                                    Главная страница                                    ##
     ############################################################################################
 ############################################################################################
 ##                                    Главная страница                                    ##
 ############################################################################################
 case 'search':
     show_title('Поиск по тегам');
     $config['newtitle'] = 'Блоги - Поиск по тегам';
     $tags = isset($_GET['tags']) ? check($_GET['tags']) : '';
     if (!is_utf($tags)) {
         $tags = win_to_utf($tags);
     }
     if (utf_strlen($tags) >= 2) {
         if (empty($_SESSION['findresult']) || empty($_SESSION['blogfind']) || $tags != $_SESSION['blogfind']) {
             $querysearch = DB::run()->query("SELECT `blogs_id` FROM `blogs` WHERE `blogs_tags` LIKE '%" . $tags . "%' LIMIT 500;");
             $result = $querysearch->fetchAll(PDO::FETCH_COLUMN);
             $_SESSION['blogfind'] = $tags;
             $_SESSION['findresult'] = $result;
         }
         $total = count($_SESSION['findresult']);
         if ($total > 0) {
             if ($start >= $total) {
                 $start = last_page($total, $config['blogpost']);
             }
             $result = implode(',', $_SESSION['findresult']);
Example #5
0
File: sql.php Project: GGF/oldbaza
	//header('Location: http://'.$_SERVER['HTTP_HOST'].'');
	echo "<script>window.location='http://".$_SERVER['HTTP_HOST']."'</script>";
}

function is_utf($t) { if (@preg_match ('/.+/u', $t)) return true; else return false; }

function utf8_to_cp1251($t) { return iconv("UTF-8", "CP1251", $t);}
function cp1251_to_utf8($t) { return iconv( "CP1251","UTF-8", $t);}

// запускается - не функция
if(!headers_sent()  && !isset($print)) {
	header('Content-type: text/html; charset=windows-1251');
}

foreach ($_GET as $key => $val) {
	if (is_utf($val)) 
		${$key}=utf8_to_cp1251($val);
}
foreach ($_POST as $key => $val) {
	if (is_utf($val)) 
		${$key}=utf8_to_cp1251($val);
}

importmodules();

if (!isset($dbname)) $dbname='zaompp';
if (!mySQLconnect()) {
	my_error('Not connect to base!');
}

?>
Example #6
0
 $nutf = 0;
 while ($crow = $cs->row_query($cres)) {
     $nchk++;
     $value = $crow[$field];
     $chk = is_utf($value);
     if (!$chk) {
         /*				print "============\n";
         				print "$table $field";
         				if (isset($crow['ordid']))
         					print " ".$crow['ordid'];
         				print "\n===========\n";
         				print "$value\n";
         				print "============\n";*/
         $niso++;
         $conv = iconv('Windows-1252', 'UTF-8', $value);
         $chk = is_utf($conv);
         if (!$chk) {
             print "error converting {$value} to {$conv}\n";
         }
         //				print "$conv\n";
         if ($doconvert && isset($crow['ordid'])) {
             $uquery = "UPDATE {$table} SET {$field}='" . addslashes($conv) . "' WHERE ordid=" . $crow['ordid'];
             $cs->do_query($uquery);
         } elseif ($doconvert) {
             print "Unable to do conversion for {$table} . {$field}\n";
         }
     } else {
         //				print "$value\n";
         $nutf++;
     }
 }