- 1
- 2
- 3
- 4
- 5
- 6
- 7
function gp($gp){
$gp_res=$_GET[$gp];
if ($gp_res == ''){
$gp_res=$_POST[$gp];
}
return $gp_res;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+155.3
function gp($gp){
$gp_res=$_GET[$gp];
if ($gp_res == ''){
$gp_res=$_POST[$gp];
}
return $gp_res;
}
а поидее можно было юзать $_REQUEST[$gp]
+75.2
boolean isCustomerWMIDExists = containParameterWithName( request, CUSTOMER_WMID_PARAM_NAME );
boolean isSellerWMIDExists = containParameterWithName( request, SELLER_WMID_PARAM_NAME );
boolean isPurseExists = containParameterWithName( request, PURSE_PARAM_NAME );
boolean isDescriptionExists = containParameterWithName( request, BasePaymentSystem.DESCRIPTION_PARAM_NAME );
boolean isInvAddressExists = containParameterWithName( request, INVADDRESS_PARAM_NAME );
boolean isPeriodExists = containParameterWithName( request, PERIOD_PARAM_NAME );
boolean isExperationExists = containParameterWithName( request, EXPERATION_PARAM_NAME );
boolean isDateCrtExists = containParameterWithName( request, DATECRT_PARAM_NAME );
boolean isDateUpdExists = containParameterWithName( request, DATEUPD_PARAM_NAME );
boolean isWmInvIdExists = containParameterWithName( request, INVID_PARAM_NAME );
boolean isRequestNExists = containParameterWithName( request, REQUESTN_PARAM_NAME );
boolean isProjectIdExists = containParameterWithName( request, BasePaymentSystem.PROJECTID_PARAM_NAME );
boolean isUserIdExists = containParameterWithName( request, BasePaymentSystem.USERID_PARAM_NAME );
boolean isCurrencyExists = containParameterWithName( request, CURRENCY_PARAM_NAME );
if (isCustomerWMIDExists && isSellerWMIDExists && isPurseExists && isDescriptionExists && isInvAddressExists && isPeriodExists
&& isExperationExists && isDateCrtExists && isDateUpdExists && isWmInvIdExists && isRequestNExists && isProjectIdExists
&& isUserIdExists && isCurrencyExists)
{
wminfo.setCustomerWMID( request.getParameter( CUSTOMER_WMID_PARAM_NAME ) );
wminfo.setSellerWMID( request.getParameter( SELLER_WMID_PARAM_NAME ) );
wminfo.setPurse( request.getParameter( PURSE_PARAM_NAME ) );
wminfo.setDescription( request.getParameter( BasePaymentSystem.DESCRIPTION_PARAM_NAME ) );
wminfo.setInvAddress( request.getParameter( INVADDRESS_PARAM_NAME ) );
wminfo.setPeriod( Byte.parseByte( request.getParameter( PERIOD_PARAM_NAME ) ) );
wminfo.setExperation( Byte.parseByte( request.getParameter( EXPERATION_PARAM_NAME ) ) );
wminfo.setDateCrt( ( getWebMoneyDateString( Long.parseLong( request.getParameter( DATECRT_PARAM_NAME ) ) ) ) );
wminfo.setDateUpd( ( getWebMoneyDateString( Long.parseLong( request.getParameter( DATEUPD_PARAM_NAME ) ) ) ) );
wminfo.setWmInvID( request.getParameter( INVID_PARAM_NAME ) );
wminfo.setRequestN( Long.parseLong( request.getParameter( REQUESTN_PARAM_NAME ) ) );
wminfo.setCurrency( Currency.getInstance( request.getParameter( CURRENCY_PARAM_NAME ) ) );
...
}
Разбор параметров GET-запроса, переданных из http://govnokod.ru/2015
// не дай бог, начальство заметит, что я рабочий код публикую
+80.4
StringBuilder sb = new StringBuilder();
sb.append( "?" + BasePaymentSystem.CHECKPAYMENT_PARAM_NAME + "=true&" + WebMoneyXmlSystem.CUSTOMER_WMID_PARAM_NAME + "="
+ getCustomerWMID() + "&" + WebMoneyXmlSystem.CURRENCY_PARAM_NAME + "=" + getCurrency().toString() + "&"
+ WebMoneyXmlSystem.SELLER_WMID_PARAM_NAME + "=" + _sellerWMID + "&" + WebMoneyXmlSystem.PURSE_PARAM_NAME + "=" + _purse
+ "&" + WebMoneyXmlSystem.DESCRIPTION_PARAM_NAME + "=" + getDescription() + "&" + WebMoneyXmlSystem.INVADDRESS_PARAM_NAME
+ "=" + _invAddress + "&" + WebMoneyXmlSystem.PERIOD_PARAM_NAME + "=" + _period + "&"
+ WebMoneyXmlSystem.EXPERATION_PARAM_NAME + "=" + _experation + "&" + WebMoneyXmlSystem.DATECRT_PARAM_NAME + "="
+ dateCreateMills.toString() + "&" + WebMoneyXmlSystem.DATEUPD_PARAM_NAME + "=" + dateUpdateMills.toString() + "&wmInvId="
+ _wmInvId + "&requestN=" + String.valueOf( _requestn ) + "&" + BasePaymentSystem.PROJECTID_PARAM_NAME + "="
+ _projectId.toString() + "&" + BasePaymentSystem.USERID_PARAM_NAME + "=" + _userId.toString() );
return new String( sb );
Формирование строки GET запроса.
+133.7
try
{
var st = ((JsonString)options["tribes"]).Value.Split(',');
foreach (var s in st)
{
if (s != string.Empty)
{
ShowTribes.Add(s);
}
}
}
catch (KeyNotFoundException)
{ }
try
{
ShowNotes = ((JsonString)options["show_comments"]).Equals("true") || (url.IndexOf("#note_id=") != -1);
}
catch (KeyNotFoundException)
{ }
try
{
Rating = ((JsonString)options["eye"]).Value;
}
catch (KeyNotFoundException)
{ }
+77.5
//devPin и pin - массивы байт, а сравниваем мы их так :
if (Utils.bytesToHex(devPin).equals(Utils.bytesToHex(pin))) {
....
:)))
+138.7
$ИF$_PIZDEC()==PIZDEC().eahc(fucntion)({
dacumetn .gэt elementbyid["id"}.stile.displey=none
else{
stile displey=blok
] <\govnosrciptiГГГ}
ыыы
+99
new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
Создание даты
+144.7
<form ....
<a href="#" class="lalalala" onclick="$('#frm').submit()">Подтвердить</a>
...
</form>
изначально было так
в админке ))
+155.2
function search($source,$text)
{
$result = false;
$searchfilms = "#<a class=\"all\" href=\"/level/1/film/(.*?)a>#si";
$searchfilms2 = "#<font color=\"\#999999\">(.*?)</font>#si";
while (preg_match_all ($searchfilms, $source, $matches))
{
preg_match_all($searchfilms2, $source, $matches2);
foreach ($matches as $key => $temparray)
foreach ($temparray as $key2 => $tempresult){
$result[$key2] = $tempresult;
$result[$key2] = preg_replace("#(.*?)/sr/1/\">(.*?)</#is", "<a href=\"?id=\\1\">\\2</a>", $result[$key2])." ".$matches2[$key][$key2];
}
return $result;
}
}
Парсер результатов с кинопоиска, отсюдова: http://bit-torrent.kiev.ua/arser_kinopoisk_ru-t3637/index.html
Может я что-то не понимаю, но зачем так извращаться совсем не ясноне ясно, 3 вложенных цикла О_о. preg_match в while зачем совсем не ясно.
Короче чтобы добавить сюда еще и год фильма, пришлось переписать... А хотелось AFAIK :)
Короче AFAIK вышло вот так:
function search($source, $text) {
$result = array();
$searchfilms = "#<a class=\"all\" href=\"/level/1/film/(.*?)/.*?>(.*?)<.*?a>.*?(\d{4}).*?#si";
$searchfilms2 = "#<font color=\"\#999999\">(.*?)</font>(.*?)#si";
preg_match_all ($searchfilms, $source, $matches);
preg_match_all($searchfilms2, $source, $matches2);
foreach ($matches[1] as $key => $temparray) {
$id = $matches[1][$key];
$name = $matches[2][$key];
$name_eng = $matches2[1][$key];
$year = $matches[3][$key];
$result[] = "<a href=\"?id=$id\">$name..$name_eng...($year)</a>";
}
return $result;
}
p.s. ИМХО читабельнее в разы
+63.6
class WordCount{
private:
string _t;
vector <int> _w;
int wc(){
string tw;
int s = 0;
for(int i = 0; i < _t.size(); ++i){
if(_t[i] == ' '){
tw.clear();
for(int j = s;j < i;++j){
tw += _t[j];
}
size_t z = 0;
for(int k = 0; k < i - s; ++k){
int jj = 1;
for(int d = 0; d < k; ++d)
jj *= 10;
z += jj * static_cast<int>(_t[k]);
}
bool sa = true;
for(int az = 0; az < _w.size(); ++az)
if(_w[az] == z) sa = false;
if(sa)_w.push_back (z);
s = i+1;
}
}
if(s < _t.size() ){
size_t z = 0;
for(int k = s;k < _t.size();++k){
int jj = 1;
for(int d = 0; d < k; ++d)
jj *= 10;
z += jj * static_cast<int>(_t[k]);
}
bool sa = true;
for(int az = 0; az < _w.size(); ++az)
if(_w[az] == z) sa = false;
if(sa)_w.push_back (z);
}
return _w.size();
}
public:
int WordCount(string text){
_t = text;
return wc();
}
};
Клас, который должен был подсчитывать кол-во уникальных слов в строке.
Наслаждайтесь, господа!