- 1
- 2
- 3
return ("" + ((10 - (acn = "229" + acn)
.Select((c, с) => (int)(c - '0') * (с % 2 + 1))
.Sum(c => c / 10 + c % 10) % 10) % 10)).Insert(0, acn);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+142
return ("" + ((10 - (acn = "229" + acn)
.Select((c, с) => (int)(c - '0') * (с % 2 + 1))
.Sum(c => c / 10 + c % 10) % 10) % 10)).Insert(0, acn);
+143
//выбираем игру для которой будем выводить таблицу
$query="SELECT * FROM a_stavki WHERE igra='$igra0' AND datigr='$datigr0'";
$db->setQuery($query);
$results0 = $db->loadObjectList();
if($userstavka1=="1"){$nam_1=$procent;}
if($userstavka1=="2"){$nam_2=$procent;}
if($userstavka1=="Х"){$nam_X=$procent;}
if($userstavka1=="ТБ"){$nam_TB=$procent;}
if($userstavka1=="ТМ"){$nam_TM=$procent;}
if($userstavka1=="ТБ2,5"){$nam_TB25=$procent;}
if($userstavka1=="ТМ2,5"){$nam_TM25=$procent;}
if($userstavka1=="ТБ3,5"){$nam_TB35=$procent;}
if($userstavka1=="ТМ3,5"){$nam_TM35=$procent;}
if($userstavka1=="ТБ4,5"){$nam_TB45=$procent;}
if($userstavka1=="ТМ4,5"){$nam_TM45=$procent;}
if($userstavka1=="ТБ5,5"){$nam_TB55=$procent;}
if($userstavka1=="ТМ5,5"){$nam_TM55=$procent;}
if($userstavka1=="ТБ150,5"){$nam_TB1505=$procent;}
if($userstavka1=="ТМ150,5"){$nam_TM1505=$procent;}
if($userstavka1=="ТБ160,5"){$nam_TB1605=$procent;}
if($userstavka1=="ТМ160,5"){$nam_TM1605=$procent;}
if($userstavka1=="1x"){$nam_1x=$procent;}
if($userstavka1=="x2"){$nam_x2=$procent;}
$stavok=0;
foreach ($results0 as $note0)
{//бежим циклом по таблице выбирая все ставки конкретной игры
$datigr1=$note0->datigr;
$userstavka1=$note0->userstavka;
$query="SELECT *,COUNT('$userstavka1') AS OrderTotal FROM a_stavki WHERE userstavka='$userstavka1' AND igra='$igra0' AND datigr='$datigr0'";
$db->setQuery($query);
$results = $db->loadObjectList();
if($results){
foreach ($results as $note)
{
$stavok=$note->OrderTotal;
}
}
$stavok=($stavok/$allstav)*100;
//$stavok=substr($stavok,0,2);
$procent="<div class='grafcss0'><p class='grafcss' style='width:".$stavok."%'>   </p></div>";
if($nam_1!=''){$rez.="<tr><td>1</td><td>".$nam_1."</td></tr>";}
if($nam_2!=''){$rez.="<tr><td>2</td><td>".$nam_2."</td></tr>";}
if($nam_X!=''){$rez.="<tr><td>Х</td><td>".$nam_X."</td></tr>";}
if($nam_TB!=''){$rez.="<tr><td>ТБ</td><td>".$nam_TB."</td></tr>";}
if($nam_TM!=''){$rez.="<tr><td>ТМ</td><td>".$nam_TM."</td></tr>";}
if($nam_TB25!=''){$rez.="<tr><td>ТБ2,5</td><td>".$nam_TB25."</td></tr>";}
if($nam_TM25!=''){$rez.="<tr><td>ТМ2,5</td><td>".$nam_TM25."</td></tr>";}
if($nam_TB35!=''){$rez.="<tr><td>ТБ3,5</td><td>".$nam_TB35."</td></tr>";}
if($nam_TM35!=''){$rez.="<tr><td>ТМ3,5</td><td>".$nam_TM35."</td></tr>";}
if($nam_TB45!=''){$rez.="<tr><td>ТБ4,5</td><td>".$nam_TB45."</td></tr>";}
if($nam_TM45!=''){$rez.="<tr><td>ТМ4,5</td><td>".$nam_TM45."</td></tr>";}
if($nam_TB55!=''){$rez.="<tr><td>ТБ5,5</td><td>".$nam_TB55."</td></tr>";}
if($nam_TM55!=''){$rez.="<tr><td>ТМ5,5</td><td>".$nam_TM55."</td></tr>";}
if($nam_TB1505!=''){$rez.="<tr><td>ТБ150,5</td><td>".$nam_TB1505."</td></tr>";}
if($nam_TM1505!=''){$rez.="<tr><td>ТМ150,5</td><td>".$nam_TM1505."</td></tr>";}
if($nam_TB1605!=''){$rez.="<tr><td>ТБ160,5</td><td>".$nam_TB1605."</td></tr>";}
if($nam_TM1605!=''){$rez.="<tr><td>ТМ160,5</td><td>".$nam_TM1605."</td></tr>";}
if($nam_1x!=''){$rez.="<tr><td>1x</td><td>".$nam_1x."</td></tr>";}
if($nam_x2!=''){$rez.="<tr><td>x2</td><td>".$nam_x2."</td></tr>";}
}//-------end $results0
$rez="<tr><td style='width:100px;'>ставка</td><td>поставило в %</td></tr>";
if($nam_1!=''){$rez.="<tr><td>1</td><td>".$nam_1."</td></tr>";}
if($nam_2!=''){$rez.="<tr><td>2</td><td>".$nam_2."</td></tr>";}
if($nam_X!=''){$rez.="<tr><td>Х</td><td>".$nam_X."</td></tr>";}
if($nam_TB!=''){$rez.="<tr><td>ТБ</td><td>".$nam_TB."</td></tr>";}
if($nam_TM!=''){$rez.="<tr><td>ТМ</td><td>".$nam_TM."</td></tr>";}
if($nam_TB25!=''){$rez.="<tr><td>ТБ2,5</td><td>".$nam_TB25."</td></tr>";}
if($nam_TM25!=''){$rez.="<tr><td>ТМ2,5</td><td>".$nam_TM25."</td></tr>";}
if($nam_TB35!=''){$rez.="<tr><td>ТБ3,5</td><td>".$nam_TB35."</td></tr>";}
if($nam_TM35!=''){$rez.="<tr><td>ТМ3,5</td><td>".$nam_TM35."</td></tr>";}
if($nam_TB45!=''){$rez.="<tr><td>ТБ4,5</td><td>".$nam_TB45."</td></tr>";}
if($nam_TM45!=''){$rez.="<tr><td>ТМ4,5</td><td>".$nam_TM45."</td></tr>";}
if($nam_TB55!=''){$rez.="<tr><td>ТБ5,5</td><td>".$nam_TB55."</td></tr>";}
if($nam_TM55!=''){$rez.="<tr><td>ТМ5,5</td><td>".$nam_TM55."</td></tr>";}
if($nam_TB1505!=''){$rez.="<tr><td>ТБ150,5</td><td>".$nam_TB1505."</td></tr>";}
if($nam_TM1505!=''){$rez.="<tr><td>ТМ150,5</td><td>".$nam_TM1505."</td></tr>";}
if($nam_TB1605!=''){$rez.="<tr><td>ТБ160,5</td><td>".$nam_TB1605."</td></tr>";}
if($nam_TM1605!=''){$rez.="<tr><td>ТМ160,5</td><td>".$nam_TM1605."</td></tr>";}
if($nam_1x!=''){$rez.="<tr><td>1x</td><td>".$nam_1x."</td></tr>";}
if($nam_x2!=''){$rez.="<tr><td>x2</td><td>".$nam_x2."</td></tr>";}
$nam_1='';
$nam_2='';
$nam_X='';
$nam_TB='';
$nam_TM='';
$nam_TB25='';
$nam_TM25='';
$nam_TB35='';
$nam_TM35='';
$nam_TB45='';
$nam_TM45='';
$nam_TB55='';
$nam_TM55='';
$nam_TB1505='';
$nam_TM1505='';
$nam_TB1605='';
Фрилансер и джумла....Вот так мне повезло....
+142
int a = 0;
bool is09 = false;
for(int i=0;i<=9;i++){ //Проверяем каждую от 0 до 9
if(a == i) { is09 = true; break; } //Если таковым является то true
}
//И само условие :)
if(is09){
//Если 0 - 9
} else {
//Если нет
}
Зацените такой индуссо-китайский код (да я знаю как правильно), но для прикола
+144
$baner->disabled = !empty($input['disabled'])?!$input['disabled']:TRUE;
огонь)
+144
if(count($proxy) === 0 ){
echo 'SMTH went wrong or all proxy pososali vse' . PHP_EOL;
exit;
}
Останавливаемся если закончились прокси
+142
}
if(selector.length!=0 && selector.charAt(0)=='z'){
$('html').find(selector.substr(1,selector.length))
.attr('value',value);
}
проект-клондайк, пример с сегодняшнего коммита
+145
<?
for ($i = 1; $i <= 100; $i++) {
$t1 = $i / 3;
$t2 = $i / 5;
if (preg_match("/\./", "$t1") == false && preg_match("/\./", "$t2") == false) {
echo "FizzBuzz<br>";
} else {
if (preg_match("/\./", "$t1") == false) {
echo "Fizz<br>";
} else {
if (preg_match("/\./", "$t2") == false) {
echo "Buzz<br>";
} else {
echo "$i<br>";
}
}
}
}
?>
ZF...
+144
private static class NoNullListMap<KEY, VALUES> extends HashMap<KEY, List<VALUES>> {
@Override
public List<VALUES> get(Object key) {
List<VALUES> res = super.get(key);
if (res == null) {
res = new ArrayList();
super.put((KEY) key, res);
}
return res;
}
}
мапа, возвращающая пустые списки вместо null
+143
<script type="text/javascript">
function Show(a) {
obj1=document.getElementById("mydiv1");
obj2=document.getElementById("mydiv2");
obj3=document.getElementById("mydiv3");
obj4=document.getElementById("mydiv4");
obj5=document.getElementById("mydiv5");
uslugia=document.getElementById("uslugi");
uslugib=document.getElementById("uslugi1");
if (a == 1 || a == 2 || a == 3 || a == 4) {obj1.style.display="block"; uslugia.style.display="block"; infa.style.display="block";
obj5.style.display="none"; uslugib.style.display="none";
}
if (a == 5) {obj5.style.display="block"; infa.style.display="block";
obj1.style.display="none"; uslugia.style.display="none";
}
calc ();
}
function ShowServices(a) {
if (a == 'premium') {
console.log ("a")
us1.checked = us2.checked = us3.checked = us4.checked = us5.checked = false
us1.disabled = us2.disabled = us3.disabled = us4.disabled = us5.disabled = true;
} else {
console.log ("b")
us1.disabled = us2.disabled = us3.disabled = us4.disabled = us5.disabled = false;
}
if (a == 'premium5') {
uslugi1.style.display="block"
} else {
uslugi1.style.display="none"
}
if (a == 'min' || a == 'stan' || a == 'premium' || a == 'min5' || a == 'stan5' || a == 'premium') {
infa.style.display="none";
}
calc ();
}
function ShowUs(a) {
{calc();};
}
function ShowV (a) {
if (a == 1 || a == 2 || a == 3 || a == 4) {
min5.checked = stan5.checked = prem5.checked = false;
}
if (a == 5) {
min1.checked = stan1.checked = prem1.checked = false;
}
}
function calc() {
var d = document, usl1 = usl2 = usl3 = usl4 = usl5 = ull1 = ull2 = 0;
var
min1 = d.getElementById("min1"),
stan1 = d.getElementById("stan1"),
prem1 = d.getElementById("prem1"),
min5 = d.getElementById("min5"),
stan5 = d.getElementById("stan5"),
prem5 = d.getElementById("prem5"),
us1 = d.getElementById("us1"),
us2 = d.getElementById("us2"),
us3 = d.getElementById("us3"),
us4 = d.getElementById("us4"),
us5 = d.getElementById("us5"),
result = d.getElementById("result");
console.log ('c');
if (us1.checked) usl1 = +us1.value;
if (us2.checked) usl2 = +us2.value;
if (us3.checked) usl3 = +us3.value;
if (us4.checked) usl4 = +us4.value;
if (us5.checked) usl5 = +us5.value;
if (min1.checked) cina = +min1.value;
if (stan1.checked) cina = +stan1.value;
if (prem1.checked) cina = +prem1.value;
if (min5.checked) cina = +min5.value;
if (stan5.checked) cina = +stan5.value;
if (prem5.checked) cina = +prem5.value;
if (ul1.checked) ull1 = +ul1.value;
if (ul2.checked) ull2 = +ul2.value;
result.innerHTML = Math.ceil(cina + usl1 + usl2 + usl3 + usl4 + usl5 + ull1 +ull2);
};
document.body.onload = function() {
console.log ('d');
calc ();
}
</script>
Пишу сайт, опыт программирования нулевой, но 2 сайта уже сделал...
Решил показать свой код, так как точно чувствую что он подходит для этого сайта =)
+142
public function api() {
...
if ($this->validate()) {
if ($store_info) {
$url = $store_info['ssl'];
} else {
$url = HTTPS_CATALOG;
}
if (isset($this->session->data['cookie']) && isset($this->request->get['api'])) {
...
$curl = curl_init();
// Set SSL if required
if (substr($url, 0, 5) == 'https') {
curl_setopt($curl, CURLOPT_PORT, 443);
}
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
curl_setopt($curl, CURLOPT_USERAGENT, $this->request->server['HTTP_USER_AGENT']);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_FORBID_REUSE, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, $url . 'index.php?route=' . $this->request->get['api'] . ($url_data ? '&' . http_build_query($url_data) : ''));
if ($this->request->post) {
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($this->request->post));
}
curl_setopt($curl, CURLOPT_COOKIE, session_name() . '=' . $this->session->data['cookie'] . ';');
$json = curl_exec($curl);
curl_close($curl);
API в опенкарте. Ну, короч, приходит пользователь, дергает АПИ, а я сам в контроллере дергаю свое АПИ. Такая практика.
https://github.com/opencart/opencart/blob/4a151334efc702729071bd8d45a7e4af4e07b3ef/upload/admin/controller/sale/order.php#L2152