BG Development


Страници: (5) [1] 2 3 ... последна »  ( Първото ново мнение ) Reply to this topicStart new topicStart Poll

> Труден ли е PHP?
Warcraft3
Публикувано на: 28-04-2020, 21:53
Quote Post



Име:
Група: Потребител
Ранг: Новопостъпил

Мнения: 8
Регистриран на: 28.04.20



От известно време изучавам PHP езика за програмиране с идеята да стана програмист. Не ми се струваше толкова труден, докато не попаднах на няколко примерни кода, които взех от Интернет:

Например това е index.php страницата на miniBB
CODE
<?php
/*
This file is part of miniBB. miniBB is free discussion forums/message board software, supplied with no warranties.
Check COPYING file for more details.
Copyright (C) 2019 Paul Puzyrev. www.minibb.com
Latest File Update: 2019-Sep-30
*/
$unset=array('logged_admin', 'isMod', 'user_id', 'langu', 'includeHeader', 'includeFooter', 'emptySubscribe', 'allForumsReg', 'registerInactiveUsers', 'mod_rewrite', 'enableViews', 'userDeleteMsgs', 'userInfoInPosts', 'inss', 'insres', 'preModerationType', 'textLd', 'adminAcceptsSignup', 'customProfileList', 'correct', 'customTopicSort', 'manualIndex', 'startIndex', 'mTop', 'mdrw', 'metaLocation', 'post', 'reply_to_email', 'csrfchk', 'emailCharset', 'adminUser', 'cook', 'forumClone', 'xtr', 'addMainTitle', 'site_url', 'allowedRefs', 'uname_minlength', 'uname_maxlength', 'enchecked', 'fIconWidth', 'fIconHeight', 'smartLinking', 'pathToTpl', 'archives', 'forumsTt', 'forums_url', 'mysql_set_names', 'eeol', 'startNewTopicLink', 'lastPostIcon', 'disableNavDisplay', 'custom_mobile_actions', 'disableSuperSticky','superStickyModule', 'check_pmquota', 'failedSending', 'rheader', 'allowHyperlinksProfile', 'l_mobilePreviousPage', 'l_mobileNextPage', 'statsDefField', 'emailname', 'minibb_copyright_txt', 'disableDates', 'brtag', 'lastPosterIcon', 'dstr', 'is_mobile_test', 'is_mobile_browser', 'is_mobile', 'l_mobilePages', 'startReplyLink', 'chunkStr', 'splitExpression', 'l_pageN', 'bbimgmrg', 'bzoutput', 'firstPageTopicForm', 'viewUnameLngLim', 'is_mobile_samsung', 'antiSpam', 'removeBlocks', 'reldef');
for($i=0;$i<sizeof($unset);$i++) unset(${$unset[$i]});
if(isset($metaLocation)) $metaLocation=str_replace(array('.','/','\\','admin_'),'',$metaLocation);

$currY=date('Y');

function get_microtime() {
$mtime=explode(' ',microtime());
return $mtime[1]+$mtime[0];
}

$starttime=get_microtime();

if(isset($_SERVER['SERVER_PROTOCOL']) and ($_SERVER['SERVER_PROTOCOL']=='HTTP/1.0' or $_SERVER['SERVER_PROTOCOL']=='HTTP/1.1') ) $proto=$_SERVER['SERVER_PROTOCOL']; else $proto='HTTP/1.1';
if(!isset($_SERVER['QUERY_STRING'])) $_SERVER['QUERY_STRING']='';
$queryStr=(isset($_POST['queryStr'])?$_POST['queryStr']:$_SERVER['QUERY_STRING']);
//$queryStr=(isset($_POST['queryStr'])?rawurlencode(rawurldecode($_POST['queryStr'])):rawurlencode($_SERVER['QUERY_STRING']));

//echo $queryStr;

$queryStr=preg_replace("@[^0-9a-zA-Z./#_&=%-]@", '', $queryStr);
$queryStrDisp=str_replace('&', '&amp;', $queryStr);
$queryStr=str_replace('&amp;', '&', $queryStr);

define ('INCLUDED776',1);

if(defined('CLONE_PATH')) $clonePath=CLONE_PATH; else $clonePath='./';
include ($clonePath.'setup_options.php');

if(isset($bzoutput) and $bzoutput) ob_start("ob_gzhandler");

if(!isset($rheader)) $rheader='Location:';
if(!isset($brtag)) $brtag='<br />';
if(!isset($lastPostIcon)) $lastPostIcon='&raquo;&raquo;';
if(!isset($bbimgmrg)) $bbimgmrg=10;
if(!isset($chunkStr)) $chunkStr='<wbr>';
if(!isset($splitExpression)) $splitExpression='//u';
if(!isset($viewUnameLngLim)) $viewUnameLngLim=15;
if(!isset($reldef)) $reldef='ugc';

$sgcp=session_get_cookie_params();
if(isset($sgcp['httponly'])) $httponlycookie=TRUE; else $httponlycookie=FALSE;

if(!isset($Tas) and !isset($Taus) and (!isset($archives) or sizeof($archives)==0)) {
$Tas='minibbtable_archive_stats';
$Taus='minibbtable_archive_userstats';
}

if (isset($_POST['action'])) $action=$_POST['action']; elseif (isset($_GET['action'])) $action=$_GET['action']; else $action='';

/* Allowing to post only from the internal or allowed domain */
if(isset($site_url)) $tUrl=$site_url;
else{
$t=explode('/', $main_url);
$tUrl=implode('/', array($t[0], $t[1], $t[2]));
}

if(isset($_POST) and sizeof($_POST)>0 and (!isset($allowedDirectPostActions) or !in_array($action, $allowedDirectPostActions) ) ){
if(isset($_SERVER['HTTP_REFERER'])) $httpRef=strtolower($_SERVER['HTTP_REFERER']); else $httpRef='';
if(substr_count($httpRef, strtolower($main_url))==0 and substr_count($httpRef, strtolower($tUrl))==0){
$af=FALSE;
if(isset($allowedRefs) and is_array($allowedRefs)) {
foreach($allowedRefs as $a) {
if(substr_count($httpRef, strtolower($a))>0) { $af=TRUE; break; }
}
}
if(!$af) die('Sorry, it seems like an intrusion attempt or your server doesn\'t support HTTP referrers!');
}
}
/* --Allowing to post */

if(!isset($startIndex)) $startIndex=$indexphp;
if(!isset($manualIndex)) $manualIndex=$indexphp.'action=manual';
if($cookiesecure) $csecurejs='1'; else $csecurejs='0';
if(!isset($fIconWidth)) $fIconWidth=16;
if(!isset($fIconHeight)) $fIconHeight=16;
if(!isset($uname_maxlength)) $uname_maxlength=15;
if(!isset($allowHyperlinksProfile)) $allowHyperlinksProfile=$allowHyperlinks;
if(!isset($emailname)) $emailname=$sitename;
if(!isset($reply_to_email)) $reply_to_email=$admin_email;

$langOrig=$lang;

$indexphp=(!isset($GLOBALS['indexphp'])?'index.php':$GLOBALS['indexphp']);
if(isset($mod_rewrite) and $mod_rewrite) $queryStr=str_replace(array('%3D0%26mdrw%3Don', '&amp;mdrw=on'), '', $queryStr);

include ($pathToFiles.'setup_'.$DB.'.php');
include ($pathToFiles.'bb_cookie.php');
include ($pathToFiles.'bb_functions.php');
include ($pathToFiles.'bb_specials.php');

/* Main stuff */

$loginError=0;
$title=$sitename.' - ';

if(!isset($user_id)) $user_id=0;
if(!defined('PAGE1_OFFSET')) define('PAGE1_OFFSET', 0);
if(isset($_GET['page'])) $page=(integer)$_GET['page']+0; elseif(isset($_POST['page'])) $page=(integer)$_POST['page']+0; else $page=PAGE1_OFFSET+1;

if(isset($_GET['forum'])) $forum=(integer)$_GET['forum']+0; elseif(isset($_POST['forum'])) $forum=(integer)$_POST['forum']+0; else $forum=0;
if(isset($_GET['topic'])) $topic=(integer)$_GET['topic']+0; elseif(isset($_POST['topic'])) $topic=(integer)$_POST['topic']+0; else $topic=0;
if (isset($_POST['action'])) $action=$_POST['action']; elseif (isset($_GET['action'])) $action=$_GET['action']; else $action='';
if (isset($_POST['csrfchk'])) $csrfchk=$_POST['csrfchk']; elseif (isset($_GET['csrfchk'])) $csrfchk=$_GET['csrfchk']; else $csrfchk='';

if(!isset($chars_encoding)) $chars_encoding='UTF-8';

if($action!='vthread' and $action!='vtopic' and $page<PAGE1_OFFSET+1) $page=PAGE1_OFFSET+1;

$user_id+=0;
$user_usr='';

$l_adminpanel_link='';
$reqTxt=0;

if(function_exists('defineRobots')) $metaRobots=defineRobots();

else{

function defineRobots(){
$action=$GLOBALS['action'];

$pdcc1=($action=='' or ($action=='vtopic' and isset($GLOBALS['forum']) and !in_array($GLOBALS['forum'], $GLOBALS['clForums'])) or $action=='vthread' or $action=='manual' or $action=='tpl' or ($action=='search' and isset($_GET['searchGo']) and isset($_GET['phrase']) and trim($_GET['phrase'])!=''));
$pdcc2=(isset($_GET['mdrw']));
$pdcc3=(isset($_GET['sortBy']));

if($action=='stats' or $action=='userinfo' or ($action=='' and $GLOBALS['page']>PAGE1_OFFSET+1)) $metaRobots='NOINDEX,FOLLOW';

elseif(isset($GLOBALS['mod_rewrite']) and $GLOBALS['mod_rewrite']){
if($pdcc1 and !$pdcc3) { if($pdcc2 or (!$pdcc2 and ($action=='' or $action=='search')) ) $metaRobots='INDEX,FOLLOW'; else $metaRobots='NOINDEX,NOFOLLOW'; }
else $metaRobots='NOINDEX,NOFOLLOW';
}

else{
if($pdcc1 and !$pdcc3) $metaRobots='INDEX,FOLLOW'; else $metaRobots='NOINDEX,NOFOLLOW';
}

return $metaRobots;
}//func

$metaRobots=defineRobots();

}
//echo $metaRobots;

/* Predefining variables */
if($reldef!='') $relFollowUrl=' rel="'.$reldef.'"'; else $relFollowUrl='';

$sortingTopics+=0;

if (isset($_GET['sortBy'])) {
$sortBy=$_GET['sortBy']; $sdef=1;
} else {
$sortBy=$sortingTopics; $sdef=0;
}

if(!($sortBy==1 or $sortBy==0 or $sortBy==2)) $sortBy=$sortingTopics;

if(isset($_POST['mode']) and $_POST['mode']=='login') require($pathToFiles.'bb_func_login.php');

if($loginError==0) {

if(isset($_GET['mode']) and $_GET['mode']=='logout') {
if(!defined('ARCHIVE')) $relocUrl=$main_url; else $relocUrl=$forums_url;
deleteMyCookie();
if(isset($metaLocation)) { $meta_relocate="{$relocUrl}/{$startIndex}"; echo ParseTpl(makeUp($metaLocation)); exit; } else { header("{$rheader}{$relocUrl}/{$startIndex}"); exit; }
}

user_logged_in();

if($user_id!=0 and isset($langu) and $langu=str_replace(array('.','/','\\'),'',$langu) and file_exists($pathToFiles."lang/{$langu}.php")) $lang=$langu;
elseif($user_id==0 and isset($_GET['setlang']) and $setlang=str_replace(array('.','/','\\'),'',$_GET['setlang']) and file_exists($pathToFiles."lang/{$setlang}.php")) {$lang=$setlang; $indexphp.='setlang='.$setlang.'&';}

if($user_id>0 and !isset($_COOKIE[$cookiename.'_csrfchk'])) setCSRFCheckCookie();

include ($pathToFiles."lang/$lang.php");

/*(c)*/
$registerButton=registerButton($user_id, $enableNewRegistrations, $l_menu, $main_url, $indexphp);

$actEnable=(isset($GLOBALS['user_activity'])?$GLOBALS['user_activity']:1);
$actTrue=($actEnable==-1 and ($action=='prefs' OR $action=='editprefs' OR $action=='confirmpasswd'));

if($actEnable==0 or ($actEnable!=1 and !$actTrue)) $forb=2;

else{

if($action=='vtopic' or $action=='vthread' or $action=='delAvatarAdmin' or ($action=='' and $viewTopicsIfOnlyOneForum==1)){
if( (isset($allForumsReg) and $allForumsReg) OR ( isset($regUsrForums) and is_array($regUsrForums) and in_array($forum, $regUsrForums) and $user_id==0) ) { $l_anonTxt=$l_anonDisallowed; $anonPost=0; } else { $l_anonTxt=$l_anonAllowed; $anonPost=1; }
if($user_id==0) $l_anonTxt='<span class="txtSm">'.$brtag.$l_anonTxt.'</span>'; else $l_anonTxt='';
$l_anonDisallowedClr=strip_tags($l_anonDisallowed);
}

if ($user_id!=0) {
if($sdef==1) $user_sort=$sortBy;
}
else {
if($sdef==0) $user_sort=$sortingTopics; else $user_sort=$sortBy;
}

if(!isset($user_sort)) $user_sort=0;
if($user_sort==0) { $sortByNew=1; $sortedByT=$l_newAnswers; $sortByT=$l_newTopics; }
else { $sortByNew=0; $sortedByT=$l_newTopics; $sortByT=$l_newAnswers; }

/* Protected forums stuff */
if(isset($_POST['allForums']) and $_POST['allForums']==$protectWholeForumPwd) {
$allForums=writeUserPwd($protectWholeForumPwd);
if($httponlycookie){
setcookie($cookiename.'allForumsPwd', '', (time() - 2592000), $cookiepath, $cookiedomain, $cookiesecure, TRUE);
setcookie($cookiename.'allForumsPwd', $allForums, 0, $cookiepath, $cookiedomain, $cookiesecure, TRUE);
}
else{
setcookie($cookiename.'allForumsPwd', '', (time() - 2592000), $cookiepath, $cookiedomain, $cookiesecure);
setcookie($cookiename.'allForumsPwd', $allForums, 0, $cookiepath, $cookiedomain, $cookiesecure);
}
if(isset($metaLocation)) { $meta_relocate="{$main_url}/{$indexphp}{$queryStr}"; echo ParseTpl(makeUp($metaLocation));
exit; } else header("{$rheader}{$main_url}/{$indexphp}{$queryStr}");
}
elseif (!isset($_POST['allForums']) and isset($_COOKIE[$cookiename.'allForumsPwd'])) { $allForums=$_COOKIE[$cookiename.'allForumsPwd']; }
elseif (!isset($_POST['allForums']) and !isset($_COOKIE[$cookiename.'allForumsPwd']) and isset($_SESSION['allForums'])) $allForums=$_SESSION['allForums'];
else $allForums='';

if ($protectWholeForum==1) {
if ($allForums!=writeUserPwd($protectWholeForumPwd)) {
$title=$sitename.' - '.$l_forumProtected;
echo ParseTpl(makeUp('protect_forums')); exit;
}
}

if($viewTopicsIfOnlyOneForum==1 and ($action=='' or $action=='vtopic' or $action=='vthread')){
$row=db_simpleSelect(0,$Tf,'forum_id, forum_name, forum_icon, forum_desc, topics_count', '', '', '', 'forum_id asc', 1);
$forumsArray[$row[0]]=array($row[1], $row[2], $row[3], $row[4]); $forum=$row[0];
if($action=='') $action='vtopic';
}

if(!isset($logged_admin)) $logged_admin=0;

if ($logged_admin==1) {
if(defined('ARCHIVE')) $fUrl=$forums_url; else $fUrl=$main_url;
$l_adminpanel_link='<span class="txtNr"><a href="'.$fUrl.'/'.substr($bb_admin, 0, strlen($bb_admin)-1).'" class="mnblnk">'.$l_adminpanel.'</a></span>'.$brtag;
}
else $l_adminpanel_link='';

if(isset($archives_url) or isset($forums_url)){
if(!defined('ARCHIVE')) $archivesLink="<a href=\"{$archives_url}\" class=\"mnblnk\">{$l_arcForumArchives}</a> {$l_sepr} "; else $archivesLink="<a href=\"{$forums_url}/{$startIndex}\" class=\"mnblnk\">{$l_arcBackToForums}</a> {$l_sepr} ";
}

/* Moderator's definition */
$isMod=0;
if($forum!=0){
if(isset($mods[$forum]) and in_array($user_id,$mods[$forum])) $isMod=1;
}
else{
foreach($mods as $key=>$val) if(is_array($val) and in_array($user_id, $val)) { $isMod=1; break; }
}

if($action=='vthread' or $action=='delAvatarAdmin' or $action=='deltopic' or $action=='delmsg'){

$topicData=db_simpleSelect(0,$Tt,'topic_title, topic_status, topic_poster, topic_poster_name, forum_id, posts_count, sticky, topic_views, topic_time, topic_last_post_id,topic_last_post_time','topic_id','=',$topic);
if($topicData and $topicData[4]!=$forum and !isset($_GET['goPost']) and !isset($_GET['user'])) {
//topic was moved - permanent redirect here
if(isset($mod_rewrite) and $mod_rewrite) $rcurl=addTopicURLPage(genTopicURL($main_url, $topicData[4], '#GET#', $topic, $topicData[0]), $page);
else $rcurl=addGenURLPage("{$main_url}/{$indexphp}action=vthread&forum={$topicData[4]}&topic={$topic}", $page, '&');

header($proto.' 301 Moved Permanently');

if(isset($metaLocation)) {
$meta_relocate="{$rcurl}"; echo ParseTpl(makeUp($metaLocation));
}
else{
header("{$rheader}{$rcurl}");
}
exit;

}
elseif(isset($_GET['goPost']) and isset($_GET['user'])) $forum=$topicData[4];

$totalPosts=$topicData[5];
//else $forb=1;
unset($result);unset($countRes);
}

}//forb

/* Private, archive and post-only forums stuff */
if(!isset($forb)) $forb=0;

if ($user_id!=1 and $forum!=0) {
if (isset($clForums) and in_array($forum, $clForums)) {
if (isset($clForumsUsers[$forum]) and !in_array($user_id,$clForumsUsers[$forum])) $forb=2;
}
if (isset($roForums) and in_array($forum, $roForums) and $isMod!=1) {
if (in_array($action, array('pthread', 'ptopic', 'editmsg', 'editmsg2', 'delmsg', 'locktopic', 'unlocktopic', 'deltopic', 'movetopic', 'movetopic2', 'sticky', 'unsticky'))) $forb=1;
}
if (isset($poForums) and in_array($forum, $poForums) and $isMod!=1){
if ($action!='' and in_array($action, array('ptopic'))) $forb=1;
}
}

if ($forb>0) {
header($proto.' 403 Forbidden');
$metaRobots='NOINDEX,NOFOLLOW';
$title.=$l_accessDenied;
echo load_header();
if($forb==2) $errorMSG=$l_accessDenied; else $errorMSG=$l_forbidden;

if(isset($_POST) and sizeof($_POST)>0){
$antiWarn=$l_deniedWhilePost;
$fieldsReadOnly=1;
$displayFormElements=array('topicTitle'=>1, 'postText'=>1);
include($pathToFiles.'bb_func_posthold.php');
echo ParseTpl(makeUp('main_posthold'));
}
else{
$l_returntoforums=''; $correctErr='';
echo ParseTpl(makeUp('main_warning'));
}
display_footer();
exit;

//$l_loadingtime='';

//echo ParseTpl(makeUp('main_footer'));
//exit;
}
else {

/* End stuff */

/* Banned IPs/IDs stuff */
$thisIp=getIP();
$cen=explode('.', $thisIp);

if(isset($cen[0]) and isset($cen[1]) and isset($cen[2])){
$thisIpMask[0]=$cen[0].'.'.$cen[1].'.'.$cen[2].'.+';
$thisIpMask[1]=$cen[0].'.'.$cen[1].'.+';
$thisIpMask[2]=$cen[0].'.+';
}
else {
$thisIpMask[0]='0.0.0.+';
$thisIpMask[1]='0.0.+';
$thisIpMask[2]='0.+';
}

if($logged_admin!=1 and $isMod!=1 and isset($_POST) and sizeof($_POST)>0 and $banRes=db_ipCheck($thisIp,$thisIpMask,$user_id)) {
if($banRes===TRUE) $banRes='';
$title=$sitename.' - '.$l_forbidden;
echo ParseTpl(makeUp('main_access_denied')); exit;
}

$backErrorLink="<a href=\"JavaScript:history.back(-1)\" class=\"mnblnk\">$l_back</a>";

if ($user_id>0) {
$loginLogout=ParseTpl(makeUp('user_logged_in'));
$user_logging=$loginLogout;
}
else {
$loginTop=0;
$ulg=makeUp('user_login_form');
$loginLogoutTmp=ParseTpl($ulg);
if(isset($is_mobile) and $is_mobile) {
$brMobile=$brtag;
$ulg=str_replace('{$l_anonTxt}', '', $ulg);
$ulg=preg_replace('#[ ]tabindex="[0-9]+"#', '', $ulg);
}
$loginTop=1;
$loginLogout=ParseTpl($ulg);
$user_logging_top=ParseTpl(makeUp('user_login_only_form'));
$loginLogout=$loginLogoutTmp;
$user_logging=ParseTpl(makeUp('user_login_only_form'));
//if(!in_array($action,array('registernew','register','sendpass','sendpass2'))) $user_logging=ParseTpl(makeUp('user_login_only_form')); else $user_logging='';
}

include ($pathToFiles.'bb_plugins.php');

/* Main actions */
function getPage($topic, $totalPosts){
if(isset($GLOBALS['themeDesc']) and in_array($topic,$GLOBALS['themeDesc'])) $page=PAGE1_OFFSET+1;
elseif($totalPosts<=$GLOBALS['viewmaxreplys']) $page=PAGE1_OFFSET+1;
else $page=ceil($totalPosts/$GLOBALS['viewmaxreplys'])+PAGE1_OFFSET;
return $page;
}

if($action=='pthread') {if($reqTxt!=1)require_once($pathToFiles.'bb_func_txt.php');require($pathToFiles.'bb_func_pthread.php');}
elseif($action=='ptopic') {if($reqTxt!=1)require_once($pathToFiles.'bb_func_txt.php');require($pathToFiles.'bb_func_ptopic.php');}

if(($action=='pthread' or $action=='ptopic') and isset($totalPosts)) {
$page=getPage($topic, $totalPosts);
}

if($action=='pthread') {
if (!isset($errorMSG)) {
if(isset($anchor) and $anchor!='') $anchor='#msg'.$anchor; elseif($postText=='') $anchor='#newreply'; else $anchor='';
if(file_exists($pathToFiles.'bb_plugins2.php')) require_once($pathToFiles.'bb_plugins2.php');
if(isset($metaLocation)) {
$meta_relocate="{$main_url}/{$indexphp}action=vthread&amp;forum=$forum&amp;topic=$topic&amp;page=$page{$anchor}";
echo ParseTpl(makeUp($metaLocation));
exit;
}
else {
if(isset($mod_rewrite) and $mod_rewrite) $furl=addTopicURLPage(genTopicURL($main_url, $forum, '#GET#', $topic, '#GET#'), $page).$anchor;
else $furl=addGenURLPage("{$main_url}/{$indexphp}action=vthread&forum=$forum&topic=$topic", $page, '&').$anchor;
header("{$rheader}{$furl}"); exit;
}
}
}

elseif($action=='vthread') {

require_once($pathToFiles.'bb_func_txt.php');

/* Redirect to the regular URL and update sendmails table, if user is accessing topic from email message */
if(isset($_GET['user'])) $resetUser=(int)$_GET['user']+0; else $resetUser=$user_id;

if(!isset($activeEmailsDisable) and $genEmailDisable==0 and $emailusers>0 and $user_id>0 and $sendid=db_simpleSelect(0,$Ts,'id,active,user_id','user_id','=',$resetUser,'','','topic_id','=',$topic) and $sendid[1]==0){
$active=1; updateArray(array('active'),$Ts,'id',$sendid[0]);
}

if(isset($_GET['goPost']) and isset($_GET['user'])){

$goPost=(int)$_GET['goPost']+0;

if($sendid=db_simpleSelect(0,$Ts,'id,active','user_id','=',$resetUser,'','','topic_id','=',$topic) and $sendid[1]==0){
$active=1; updateArray(array('active'),$Ts,'id',$sendid[0]);
}

$anchor='#msg'.$goPost;

if($row=db_simpleSelect(0, $Tp, 'count(*)', 'post_id', '<=', $goPost, '', '', 'topic_id', '=', $topic)) $totalPosts=$row[0]; else $totalPosts=0;
$page=getPage($topic, $totalPosts);

if(isset($metaLocation)) {
$meta_relocate="{$main_url}/{$indexphp}action=vthread&amp;forum=$forum&amp;topic=$topic&amp;page=$page{$anchor}"; echo ParseTpl(makeUp($metaLocation)); exit;
}
else {
if(isset($mod_rewrite) and $mod_rewrite) $furl=addTopicURLPage(genTopicURL($main_url, $forum, '#GET#', $topic, '#GET#'), $page).$anchor;
else $furl=addGenURLPage("{$main_url}/{$indexphp}action=vthread&forum=$forum&topic=$topic", $page, '&').$anchor;
}
header("{$rheader}{$furl}"); exit;
}

require($pathToFiles.'bb_func_vthread.php');

}

elseif($action=='vtopic') {
if(isset($redthread) and is_array($redthread) and isset($redthread[$forum])) {
if(isset($metaLocation)) {
$meta_relocate=addGenURLPage("{$main_url}/{$indexphp}action=vthread&forum=$forum&topic={$redthread[$forum]}", PAGE1_OFFSET+1, '&');
echo ParseTpl(makeUp($metaLocation)); exit;
} else {
if(isset($mod_rewrite) and $mod_rewrite) $furl=addTopicURLPage(genTopicURL($main_url, $forum, '#GET#', $redthread[$forum], '#GET#'), PAGE1_OFFSET+1); else $furl=addGenURLPage("{$main_url}/{$indexphp}action=vthread&forum=$forum&topic={$redthread[$forum]}", PAGE1_OFFSET+1, '&');
header("{$rheader}{$furl}");
exit;
}
}
else require($pathToFiles.'bb_func_vtopic.php');
}

elseif($action=='ptopic') {
$page=PAGE1_OFFSET+1;
if(file_exists($pathToFiles.'bb_plugins2.php')) require_once($pathToFiles.'bb_plugins2.php');
if (!isset($errorMSG)) {
if(isset($metaLocation)) {
$meta_relocate=addGenURLPage("{$main_url}/{$indexphp}action=vthread&forum={$forum}&topic={$topic}", PAGE1_OFFSET+1, '&');
echo ParseTpl(makeUp($metaLocation));
exit;
}
else {
if(isset($mod_rewrite) and $mod_rewrite) $furl=addTopicURLPage(genTopicURL($main_url, $forum, '#GET#', $topic, '#GET#'), PAGE1_OFFSET+1); else $furl=addGenURLPage("{$main_url}/{$indexphp}action=vthread&forum=$forum&topic=$topic", PAGE1_OFFSET+1, '&');
header("{$rheader}{$furl}"); exit;
}
}
}

elseif($action=='search') {if($reqTxt!=1)require($pathToFiles.'bb_func_txt.php');require($pathToFiles.'bb_func_search.php');}

elseif($action=='deltopic') require($pathToFiles.'bb_func_deltopic.php');

elseif($action=='locktopic') require($pathToFiles.'bb_func_locktop.php');

elseif($action=='editmsg') {$step=0;require($pathToFiles.'bb_func_editmsg.php');}

elseif($action=='editmsg2') {require_once($pathToFiles.'bb_func_txt.php');$step=1;require($pathToFiles.'bb_func_editmsg.php');}

elseif($action=='delmsg') {$step=0;require($pathToFiles.'bb_func_delmsg.php');}

elseif($action=='movetopic') {$step=0;require($pathToFiles.'bb_func_movetpc.php');}

elseif($action=='movetopic2') {$step=1;require($pathToFiles.'bb_func_movetpc.php');}

elseif($action=='userinfo') require($pathToFiles.'bb_func_usernfo.php');

elseif($action=='sendpass' and file_exists($pathToFiles.'bb_func_sendpwd.php')) {$step=0;require($pathToFiles.'bb_func_sendpwd.php');}

elseif($action=='sendpass2' and file_exists($pathToFiles.'bb_func_sendpwd.php')) {$step=1;require($pathToFiles.'bb_func_sendpwd.php');}

elseif($action=='confirmpasswd') { require($pathToFiles.'bb_func_confpwd.php');}

elseif($action=='stats' and file_exists($pathToFiles.'bb_func_stats.php')) require($pathToFiles.'bb_func_stats.php');

elseif($action=='manual') require($pathToFiles.'bb_func_man.php');

elseif($action=='registernew' and ($user_id==1 or $enableNewRegistrations)) {$step=0;require($pathToFiles.'bb_func_regusr.php');}

elseif($action=='register' and ($user_id==1 or $enableNewRegistrations)) {$step=1;require($pathToFiles.'bb_func_regusr.php');}

elseif($action=='prefs' and $enableProfileUpdate) {$step=0;require($pathToFiles.'bb_func_editprf.php');}

elseif($action=='editprefs' and $enableProfileUpdate) {$step=1;require($pathToFiles.'bb_func_editprf.php');}

elseif($action=='unsubscribe') require($pathToFiles.'bb_func_unsub.php');

elseif($action=='sticky') {$status=9;require($pathToFiles.'bb_func_sticky.php');}

elseif($action=='unsticky') {$status=0;require($pathToFiles.'bb_func_sticky.php');}

elseif($action=='viewipuser') {require($pathToFiles.'bb_func_viewip.php');}

elseif($action=='banip') {require($pathToFiles.'bb_func_banip.php');}

elseif($action=='removeuser') {require($pathToFiles.'bb_func_deluser.php');}

elseif($action=='tpl') {
if(isset($_GET['tplName'])) $tplName=str_replace(array('.','/','\\','admin_'),'',$_GET['tplName']); else $tplName='';
if ($tplName!='' and file_exists ($pathToFiles.'templates/'.$tplName.'.html')){
if(!isset($_GET['nh'])) echo load_header();
echo ParseTpl(makeUp($tplName));
if(isset($_GET['nh'])) exit;
}
else {
if(isset($metaLocation)) { $meta_relocate="{$main_url}/{$indexphp}"; echo ParseTpl(makeUp($metaLocation)); } else header("{$rheader}{$main_url}/{$indexphp}");
exit;
}
}

elseif($action==''){

$where=1; $forum=0;
$searchBox=ParseTpl(makeUp('search_box'));

if($page>PAGE1_OFFSET+1) {
$tpage=' - '.$l_page.' '.($page-PAGE1_OFFSET);
$description.=' ('.$l_page.' '.($page-PAGE1_OFFSET).')';
$title1=$title;
$title=$sitename;
if(isset($addMainTitle) and $page==PAGE1_OFFSET+1) $title.=' - '.str_replace(' - ','',$title1);
$title.=$tpage;
}
else $title=$sitename;

require($pathToFiles.'bb_func_vforum.php');
if ($viewlastdiscussions!=0) {
require($pathToFiles.'bb_func_ldisc.php');
//$listTopics=$list_topics;
if($list_forums!='') {
if($page==PAGE1_OFFSET+1){
if(isset($startPageModern) and $startPageModern) $tplPr=ParseTpl(makeUp('main_modern_layout')); else $tplPr=ParseTpl(makeUp('main_last_discussions'));
if(!isset($pageNavExtra) or $pageNavExtra=='') $tplPr=preg_replace("#<!--pageNav-->(.*?)<!--/pageNav-->#is", '', $tplPr);
}
else $tplPr=ParseTpl(makeUp('main_last_discuss_more'));
}
}
else $tplPr='';

if(!isset($tplPr)) $tplPr='';
echo load_header().$forumsTpl.$tplPr;

}

}//forb

}

else{
//loginError=1
if($loginError==1) {
$isMod=0;
$tpl='main_warning';
include ($pathToFiles."lang/{$lang}.php");
include ($pathToFiles.'bb_plugins.php');
}
else {
$tpl='main_posthold';
}

echo load_header(); echo ParseTpl(makeUp($tpl));
}

if(!defined('HEADER_CALLED')) { header("{$rheader}{$main_url}/"); exit; }

if(file_exists($pathToFiles.'bb_plugins2.php')) require_once($pathToFiles.'bb_plugins2.php');

//Loading footer
display_footer();
/*
$endtime=get_microtime();
$totaltime=sprintf ("%01.3f", ($endtime-$starttime));
if(isset($includeFooter) and $includeFooter!='') include($includeFooter); else echo ParseTpl(makeUp('main_footer'));
*/

if(isset($bzoutput) and $bzoutput) ob_end_flush();
?>



Този код ми се стори изключително труден и едва ли ще успея да напиша и аз нещо такова. Много дълъг е.

Как успяват програмистите да пишат такъв дълъг код? И наистина ли е толкова трудно, колкото изглежда?
PMEmail Poster
Top
Stilgar
Публикувано на: 28-04-2020, 22:50
Quote Post



Име:
Група: Потребител
Ранг: Почетен член

Мнения: 13130
Регистриран на: 13.05.08



На мен ми е много труден


--------------------
Опитахме се да го направим както трябва, но стана както винаги.
PMEmail PosterUsers Website
Top
!TuringComplete
Публикувано на: 28-04-2020, 22:54
Quote Post



Име:
Група: Потребител
Ранг: Посетител

Мнения: 65
Регистриран на: 28.02.19



И аз се чудя същото, ама ме е срам да питам.
PMEmail Poster
Top
qtakabg
Публикувано на: 28-04-2020, 23:12
Quote Post



Име:
Група: Потребител
Ранг: Почетен член

Мнения: 1322
Регистриран на: 26.02.15



Ако имаш какво да напишеш на него, ще го научиш. Ако само цъкаш туториали, няма. Измисли си някакъв проект и го направи и сам ще разбереш за какво става дума. Основно практикуване се иска.
PMEmail Poster
Top
Delegate
Публикувано на: 29-04-2020, 07:49
Quote Post



Име:
Група: Потребител
Ранг: Почетен член

Мнения: 2273
Регистриран на: 30.05.09



Като стигнеш да ползваш unicode стрингове и кирилица например ще видиш, че труден не е точния термин. Елементарен пример - не миожеш да махнеш спесовете отзад и отпред на стринг без да станеш гуру и в регулярнуте изрази, а там кво е...
PMEmail Poster
Top
bvbfan
Публикувано на: 29-04-2020, 07:52
Quote Post



Име:
Група: Потребител
Ранг: Почетен член

Мнения: 3706
Регистриран на: 08.12.13



Не.


--------------------
QUOTE (Bender @ 23-04-2015, 19:11)
Xamarin: ЛАПАЙ!
Ти: Добре...
PMEmail Poster
Top
Gamma Goblin
Публикувано на: 29-04-2020, 08:26
Quote Post



Име:
Група: Потребител
Ранг: Почетен член

Мнения: 3789
Регистриран на: 21.02.18



Всички езици са горе-долу еднакво трудни. Разликата е, че с някои могат да се правят смислени неща. ПХП не е от тях.


--------------------
https://ncase.me/trust-bg/
---
Misanthropy is the general hatred, dislike, distrust or contempt of the human species or human nature. A misanthrope or misanthropist is someone who holds such views or feelings.
---
INTJ’s are good at being very good at everything
---
"Чувството за вина дето искаш да ни го вмениш, може да си го навиеш на руло и да си го пъхнеш отзад." - stewe
PMEmail PosterUsers Website
Top
thrawn
Публикувано на: 29-04-2020, 08:40
Quote Post



Име:
Група: Потребител
Ранг: Почетен член

Мнения: 2920
Регистриран на: 17.01.17



QUOTE (Warcraft3 @ 28-04-2020, 21:53)
Този код ми се стори изключително труден и едва ли ще успея да напиша и аз нещо такова. Много дълъг е.

Как успяват програмистите да пишат такъв дълъг код? И наистина ли е толкова трудно, колкото изглежда?

Дълъг и труден са две различни неща.
Като цяло, "заблудата" ти идва от това, че четеш кода като роман - от горе на долу, и съответно предполагаш, че така и се пише.
Това е комплексен код, в който постепенно, във времето, е добавяна функционалност. Накрая се получава подобна мацаница която се разбира/поддържа все по-трудно. Това е особено актуално за php който основно се ползва като процедурен език.
PMEmail Poster
Top
DarkOne
Публикувано на: 29-04-2020, 08:50
Quote Post


Group Icon
Име: Александър Петков
Група: Администратор
Ранг: Почетен член

Мнения: 3508
Регистриран на: 30.01.04



Този код е дълъг, но въобще не е сложен. Просто обработва много случаи по чисто императивен начин. Половината код на Linux kernel-а изглежда по същия начин, нищо че е на С *flame on?*.


--------------------
The man who learns only what others know
is as ignorant as if he learns nothing.
The treasures of knowledge are the most rare,
and guarded most harshly.
-- Chronicle of the First Age
PMICQ
Top
SoftUniBog
Публикувано на: 29-04-2020, 09:42
Quote Post



Име:
Група: Потребител
Ранг: Редовен член

Мнения: 389
Регистриран на: 02.10.19



Бе не знам дали е труден, ама ти си попаднал на доста куц код, да не кажа манджа с грозде направо.

PHP тука много хора ще се ебават с него, но ако го подхванеш от правилните места, мое да не е толкова зле като горния код. Потърси Laravel фреймуърка, най-читав е за ПХП и там кода изглежда все едно е друг език.
PMEmail Poster
Top
0 потребители преглеждат тази тема в момента (0 гости, 0 анонимни потребители)
Потребители, преглеждащи темата в момента:

Topic Options Страници: (5) [1] 2 3 ... последна » Reply to this topicStart new topicStart Poll

 


Copyright © 2003-2019 | BG Development | All Rights Reserved
RSS 2.0