- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
private function onEnterFrame(e:Event):void {
if (success)
{
}
else
{
}
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−119
private function onEnterFrame(e:Event):void {
if (success)
{
}
else
{
}
}
24 раза в секунду: "У вас всё хорошо? Вот и славно. Всё плохо? Да и чёрт с ним."
−109
for (var i:int = 0; i < _levelingScores[i]; i++)
Три дня багу искал :D Подумываю сходить к доктору.
+156
/**
* форматирование даты - преобразует дату в формат ДД-ММ-ГГГГ
*
* @param unknown_type $inDate - дата
* @return unknown
*/
public static function getDateFormatted($inDate, $forView = false, $inTime = '') {
//2011-05-03 20:27:26
$a_tmp = explode(' ', $inDate);
if ($forView) {
$time = substr($a_tmp[1], 0, 5);
if ($a_tmp[0] == date('Y-m-d')) {
if ($time == '') {
$time = substr($inTime, 11, 5);
if ($time == '') {
$time = $inTime;
}
}
if ($time != '') {
return 'Сегодня, ' . $time;
}
}
$a_tmp = explode('-', $a_tmp[0]);
return $a_tmp[2] . '-' . $a_tmp[1] . '-' . $a_tmp[0];
}
$inDate = substr($inDate, 0 , 10);
$inDate = str_replace(' ', '', $inDate);
$inDate = str_replace('.', '-', $inDate);
$a_tmp = explode('-', $inDate);
if (strlen($a_tmp[0]) == 4) {
$inDate = str_pad($a_tmp[2], 2, '0', STR_PAD_LEFT) . '-' . $a_tmp[1] . '-' . $a_tmp[0];
}
return $inDate;
}
+165
function show_price_list() {
$period_1 = $period_2 = $period_3 = $period_4 = $period_5 = $period_6 = "";
$query = "
SELECT id, price, type
FROM price
ORDER BY type, start
";
$this->registry['sql']->query($query);
if ($this->registry['sql']->getNumberRows()>0) {
foreach ($this->registry['sql']->getFetchObject() as $oRow) {
switch($oRow->type) {
case 0: $period_1 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
break;
case 1: $period_2 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
break;
case 2: $period_3 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
break;
case 3: $period_4 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
break;
case 4: $period_5 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
break;
case 5: $period_6 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
break;
}
}
}
@$this->registry['template']->set('period_1', $period_1);
@$this->registry['template']->set('period_2', $period_2);
@$this->registry['template']->set('period_3', $period_3);
@$this->registry['template']->set('period_4', $period_4);
@$this->registry['template']->set('period_5', $period_5);
@$this->registry['template']->set('period_6', $period_6);
}
Модель в шаблоне MVC
+159
if (strlen($_POST["NEW_PASSWORD"]) <= 0)
$arResult["ERROR"][] = GetMessage("STOF_ERROR_REG_FLAG1");
if (strlen($_POST["NEW_PASSWORD"]) > 0 && strlen($_POST["NEW_PASSWORD_CONFIRM"]) <= 0)
$arResult["ERROR"][] = GetMessage("STOF_ERROR_REG_FLAG1");
if (strlen($_POST["NEW_PASSWORD"]) > 0
&& strlen($_POST["NEW_PASSWORD_CONFIRM"]) > 0
&& $_POST["NEW_PASSWORD"] != $_POST["NEW_PASSWORD_CONFIRM"])
$arResult["ERROR"][] = GetMessage("STOF_ERROR_REG_PASS");
Взято из Битрикса /bitrix/components/bitrix/sale.order.ajax/component.php
Потрясающие идентификаторы мессаджей. Ну а то, что прочитать код без слома глаз нельзя отдельная песня.
В целом там такого внутри много.
+174
function get_field_by_id($tbl,$field,$id){ //получить field по id
$res=mysql_query($v="SELECT * FROM $tbl where `id`=$id");
$rez=mysql_fetch_array($res);
return $rez["$field"];
}
+164
function prepare_graph_query($query, $date_column, $date_format="%b %d") {
$date_format = empty($date_format) ? "%Y %b" : $date_format;
//...
}
+157
function utf8win1251($s){
$out=""; $c1=""; $byte2=false;
for ($c=0;$c<strlen($s);$c++){
$i=ord($s[$c]); if ($i<=127) $out.=$s[$c];
if ($byte2) { $new_c2=($c1&3)*64+($i&63); $new_c1=($c1>>2)&5;
$new_i=$new_c1*256+$new_c2;
if ($new_i==1025) $out_i=168; else
if ($new_i==1105) $out_i=184; else $out_i=$new_i-848;
$out.=chr($out_i); $byte2=false; }
if (($i>>5)==6) {$c1=$i;$byte2=true; } }
return $out; }
Я ничо не понял, но это круто.
http://letopisi.ru/index.php/Знаете-ли-что%3F_скрипт
−104
def entities(model, params = {})
@entities ||= {}
@entities[model] ||= []
if @entities[model].blank? or parameters_changed?(model, params)
@entities[model] = []
include = params[:include] || nil
group = params[:group] || nil
order = params[:order] || nil
page = params[:page] || nil
entity_ids = []
model_role = nil
model_class = model.to_s.classify.constantize
if self.has_role_for?(model_class)
self.roles_for(model_class).uniq.each do |role|
if role.authorizable_id.blank?
raise "Authorization problem! Found more than one #{model_class} model permission!" unless model_role.blank?
model_role = role.name
next
end
if !role.authorizable_id.blank? && MerchantRole::MERCHANT_ROLES.include?(role.name)
entity_ids << role.authorizable.id
end
end
if entity_ids.blank? and MerchantRole::MERCHANT_ROLES.include?(model_role)
#WARNING! RECURSION! EVIL!
if MerchantRole.has_entity_parent?(model)
parent_model = MerchantRole.entity_parent(model)
parent_entities = self.entities(parent_model)
unless parent_entities.blank?
_params = {
:conditions => conditions_and_parameters(params, nil, ["`#{model.to_s}`.`#{parent_model.to_s.singularize}_id` IN (?)", parent_entities.map(&:id)]),
:include => include,
:order => order,
:group => group
}
_params.merge!(:page => page) if params.keys.include?(:page)
if block_given?
(self.is_reseller? ? self.reseller.send(model) : model_class).each(_params) do |o|
yield o
end
else
@entities[model] = (self.is_reseller? ? self.reseller.send(model) : model_class).send(params.keys.include?(:page) ? :paginate : :find, :all, _params)
end
end
else
_params = {
:conditions => conditions_and_parameters(params, nil),
:include => include,
:order => order,
:group => group
}
_params.merge!(:page => page) if params.keys.include?(:page)
if block_given? #Find only merchants associated with the reseller or all merchants if we are no reseller.
(self.is_reseller? ? self.reseller.send(model) : model_class).each(_params) do |o|
yield o
end
else
@entities[model] = (self.is_reseller? ? self.reseller.send(model) : model_class).send(params.keys.include?(:page) ? :paginate : :find, :all, _params)
end
end
else
_params = { :conditions => conditions_and_parameters(params, nil, ["`#{model.to_s}`.`id` IN (?)", entity_ids]),
:include => include,
:order => order,
:group => group }
_params.merge!(:page => page) if params.keys.include?(:page)
if block_given?
model_class.each(_params) do |o|
yield o
end
else
@entities[model] = model_class.send(params.keys.include?(:page) ? :paginate : :find, :all, _params)
end
end
end
end
entities[@model]
end
This method does the following (you guessed it, right?):
#Fetch entities for which we have a read permission.
#This is now it should work:
#1. : If we don't have any role on the model, we won't get anything.
#2a.: Check roles we have for whole model. If no role for whole model we can only fetch instances we have assigned.
#2b.: Check all instances we have a role for and store them.
#3a.: We have roles for instances -> Goto(#7)
#3b.: We have no instance roles but have a role for the whole model.
#4. : Check recusively if we have roles fro a parent model (channels -> merchants).
#5a.: If we have a parent role and got parent entities returned we only fetch instances belonging to the parent entities.
#6a.: If we have a parent role and got no entities back, then we won't get anything since we are not supposed to.
#7. : Get all instances based on our reseller or globally for the system.
+155
function otherString($str,$style)
{
$str=trim($str);
switch($style)
{
case 1: $str=strip_tags($str); $str=str_replace("\n",'<br />',$str); break;
case 2: break;
case 3: $str=strip_tags($str); $str=str_replace("\n",'',$str); $str=str_replace('<br />',"\n",$str); break;
case 4: $str=ereg_replace('(mailto:|mailto|http://|http:/|http:|http|ftp://|ftp:/|ftp:|ftp)','',$str);break;
case 5: $str=stripslashes($str); break;
case 6: $str=stripslashes($str); $str=strip_tags($str); break;
case 7: $str=strip_tags($str); break;
}
return $str;
}
web-based cms