- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
switch (achievements.length) {
case 0: return 0;
case 1: return 30;
case 2: return 60;
case 3: return 75;
case 4: return 90;
case 5: return 100;
default: return 0;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+160
switch (achievements.length) {
case 0: return 0;
case 1: return 30;
case 2: return 60;
case 3: return 75;
case 4: return 90;
case 5: return 100;
default: return 0;
}
зато не if'ы
+160
ISQ.Tools.reverseArray=function(a){
var d=a.length;
for(var b=0;b<a.length;++b){
var e=0;
for(var c=1;c<d;++c){
var f=a[e];
a[e]=a[c];
a[c]=f;
++e
}
--d
}
};
Все тот же автор... зачем он все это делал - ума не приложу.
+160
<button type='button' id='button-download'>download zipfile</button>
$("#button-download").live("click", function() {
$.get("http://localhost/admin/zip/002140.zip"); // doesn't work?
})
Ссылка на скачивание файла, современный вариант.
+160
function someFunction(t) {
var y="$('#elementID').find('input[type=\"text\"]:eq(", z=")').focus()", x=")').val()==''";
setTimeout("( "+y+"0"+x+" )? ( "+y+"0"+z+" ):( ( "+y+"1"+x+" )? ( "+y+"1"+z+" ):( "+y+"2"+z+" ) );", t);
}
это какое-то нечто
+160
var HS_ShareButton = new Object();
HS_ShareButton.Info = "ShareButton";
HS_ShareButton.ShareAction = new function(hURL, hTitle, hDescription, hImage, hParams)
{
var hResult = '';
var hURL = this.hURL;
var hTitle = this.hTitle;
var hDescription = this.hDescription;
var hImage = this.hImage;
var hParams = this.hParams;
var hSendData = new Object();
var hSendData = {hURL, hTitle, hDescription, hImage, hParams};
if(hURL == null && hTitle == null && hDescription == null && hImage == null && hParams == null)
{
return hResult = 'Initialization impossible #001';
}
else
{
HS_ShareButton._DoShare(this.hSendData);
}
}
.... еще over 100500 строчек =]
Это кнопка расшаривает материалы для сайта...
+160
if (isset ( $_POST ['atest'] ) && isset ( $_POST ['date_atest'] $_POST ['student'] ) && isset ( $_POST ['point'] ) ) {
( int ) $stud_id = $_POST ['student'];
( int ) $point = $_POST ['point'];
if (strlen ( $_POST ['atest'] ) > 3 && strlen ( $_POST ['date_atest'] ) == 10) {
$sql = "insert into `subjects` (`name`,`date`,`courses`,`group`)";
$sql .= "values (" . $db->qstr ( $_POST ['atest'] ) . "," . $db->qstr ( $_POST ['date_atest'] ) . "," . $course_input . "," . $group_input . ")";
$calc_attestation = "SELECT `users`.`id`, avg (`points`.`point`) attestation FROM `users`, `points`";
$calc_attestation .= "WHERE `users`.`id` = " . $stud_id . " AND `users`.`id` = `points`.`student`";
$result_calc_attestation = mysql_fetch_assoc(mysql_query($calc_attestation));
if ($result_calc_attestation['attestation'] >= 0 && $result_calc_attestation['attestation'] <= 0,5) {
$result_calc_attestation = 0;
$add_attestation = "insert into `points` (`point`, `course`, `student`)";
$add_attestation .= "values (" . $result_calc_attestation . ", " . $course_input . ", " . $group_input;
}
if ($result_calc_attestation['attestation'] >= 0,5 && $result_calc_attestation['attestation'] <= 1) {
$result_calc_attestation = 1;
$add_attestation = "insert into `points` (`point`, `course`, `student`)";
$add_attestation .= "values (" . $result_calc_attestation . ", " . $course_input . ", " . $group_input;
}
if ($result_calc_attestation['attestation'] >= 1 && $result_calc_attestation['attestation'] <= 1,5) {
$result_calc_attestation = 1;
$add_attestation = "insert into `points` (`point`, `course`, `student`)";
$add_attestation .= "values (" . $result_calc_attestation . ", " . $course_input . ", " . $group_input;
}
if ($result_calc_attestation['attestation'] >= 1,5 && $result_calc_attestation['attestation'] <= 2) {
$result_calc_attestation = 2;
$add_attestation = "insert into `points` (`point`, `course`, `student`)";
$add_attestation .= "values (" . $result_calc_attestation . ", " . $course_input . ", " . $group_input;
}
if ($result_calc_attestation['attestation'] >= 2 && $result_calc_attestation['attestation'] <= 2,5) {
$result_calc_attestation = 2;
$add_attestation = "insert into `points` (`point`, `course`, `student`)";
$add_attestation .= "values (" . $result_calc_attestation . ", " . $course_input . ", " . $group_input;
}
[Код сокращен]
if ($result_calc_attestation['attestation'] >= 11,5 && $result_calc_attestation['attestation'] <= 12) {
$result_calc_attestation = 12;
$add_attestation = "insert into `points` (`point`, `course`, `student`)";
$add_attestation .= "values (" . $result_calc_attestation . ", " . $course_input . ", " . $group_input;
}
if ($result_calc_attestation['attestation'] == 12) {
$result_calc_attestation = 12;
$add_attestation = "insert into `points` (`point`, `course`, `student`)";
$add_attestation .= "values (" . $result_calc_attestation . ", " . $course_input . ", " . $group_input;
}
if ($db->Execute ( $sql ) or $db->Execute ( $add_attestation ) === false) {
die ( 'Опаньки: ' . $db->ErrorMsg () );
}
$GLOBALS ['inform'] [] = "Атестація проведена";
} else {
$GLOBALS ['error'] [] = "Помилка додавання пари через те, що довжина назви менше 3-х символів або дата вказана не вірно.";
}
}
Ну и как это использовать? Я уже представил что будет если будет болонская система)
+160
function createfile1($path,$info){
if(file_exists($path))
{
$fp=fopen($path,'a+');
fputs($fp,$info);
fclose($fp);
}
else
{
$fp=fopen($path,'w+');
fputs($fp,$info);
fclose($fp);
}
}
Функция с говорящим названием и пахнущим содержимым
+160
public function return_array_element($array, $element){
/*Return the value of specific array element*/
return $array[$element];
}
тотже мастер класа что и тут:
http://govnokod.ru/9765/
+160
$replace = array(
chr(0) => '',
chr(1) => '',
chr(2) => '',
chr(3) => '',
chr(4) => '',
chr(5) => '',
chr(6) => '',
chr(7) => '',
chr(8) => '',
chr(9) => '',
chr(11) => '',
chr(12) => '',
chr(13) => '',
chr(14) => '',
chr(15) => '',
chr(16) => '',
chr(17) => '',
chr(18) => '',
chr(19) => '',
chr(20) => '',
chr(21) => '',
chr(22) => '',
chr(23) => '',
chr(24) => '',
chr(25) => '',
chr(26) => '',
chr(27) => '',
chr(28) => '',
chr(29) => '',
chr(30) => '',
chr(31) => ''
);
А я так надеялся.
+160
$v2 = str_replace('\"', '"', $v2);
$v2 = str_replace("\'", "'", $v2);
no comments