- 1
- 2
- 3
- 4
public function session_set_lifetime($time){
/*NOT USED with cookies, can be used with sessions*/
return null;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+156
public function session_set_lifetime($time){
/*NOT USED with cookies, can be used with sessions*/
return null;
}
тотже мастер класа что и тут:
http://govnokod.ru/9765/
http://govnokod.ru/9777/
+114
private void button8_Click(object sender, EventArgs e)
{
string fn = "";
string st = "";
string value = "";
string dirfile = "";
StreamWriter sw;
if (textBox1.Text != "")
{
dirfile = textBox1.Text + "\\" + GetFileName(openFileDialog1.FileName) + comboBox1.SelectedValue.ToString() + ".csv";
sw = new StreamWriter(dirfile, false, System.Text.Encoding.UTF8);
}
else
{
sw = new StreamWriter(openFileDialog1.FileName + comboBox1.SelectedValue.ToString() + ".csv", false, System.Text.Encoding.UTF8);
}
// Создаем колонки
for (int cl = 0; cl < dt.Columns.Count; cl++)
{
fn = dt.Columns[cl].ColumnName;
if (cl == 0)
{
st = fn.Replace("\n", "").Replace(";", "");
}
else
{
st += ";" + fn.Replace("\n", "").Replace(";", "");
}
}
sw.WriteLine(st);
progressBar1.Minimum = 1;
progressBar1.Maximum = dt.Rows.Count;
for (int i = 0; i < dt.Rows.Count; i++)
{
progressBar1.Value = i + 1;
Application.DoEvents();
for (int j = 0; j < dt.Columns.Count; j++)
{
value = dt.Rows[i][j].ToString();
if (value == "") { value = " "; }
try
{
Convert.ToInt16(value);
if (j == 0)
{
st = value.Replace("\n", "").Replace(";", "");
}
else
{
st += ";" + value.Replace("\n", "").Replace(";", "");
}
}
catch (System.FormatException exp)
{
if (j == 0)
{
st = value.Replace("\n", "").Replace(";", "");
}
else
{
st += ";" + value.Replace("\n", "").Replace(";", "") ;
}
}
catch (OverflowException oe)
{
if (j == 0)
{
st = value.Replace("\n", "").Replace(";", "");
}
else
{
st += ";" + value.Replace("\n", "").Replace(";", "");
}
}
}
sw.WriteLine(st);
}
sw.Close();
MessageBox.Show("Ok");
досталось в наследство, сохранение DataTable в CSV :)
+109
public static MyResultData SqlReturnDataset(string sql, string connection)
{
MyResultData result = new MyResultData();
try
{
MySql.Data.MySqlClient.MySqlConnection connRC = new MySql.Data.MySqlClient.MySqlConnection(connection);
MySql.Data.MySqlClient.MySqlCommand commRC = new MySql.Data.MySqlClient.MySqlCommand(sql, connRC);
connRC.Open();
try
{
MySql.Data.MySqlClient.MySqlDataAdapter AdapterP = new MySql.Data.MySqlClient.MySqlDataAdapter();
AdapterP.SelectCommand = commRC;
DataSet ds1 = new DataSet();
AdapterP.Fill(ds1);
result.ResultData = ds1.Tables[0];
}
catch (Exception ex)
{
result.HasError = true;
result.ErrorText = ex.Message;
}
connRC.Close();
}
catch (Exception ex)//Этот эксепшн на случай отсутствия соединения с сервером.
{
result.ErrorText = ex.Message;
result.HasError = true;
}
return result;
}
+114
private int GetInsertion(byte[] firstArr, byte[] secondArr)
{
int result = -1;
int counter = 0;
if (firstArr.Count() >= secondArr.Count())
{
for (int i = 0; i < firstArr.Count(); i++)
{
if (firstArr[i] == secondArr[counter])
{
counter++;
if (counter == secondArr.Count())
{
result = i - counter + 1;
break;
}
}
else
{
counter = 0;
}
}
}
return result;
}
находит индекс вхождения одного массива в другой
−124
if (param.visible == 'cache')
{
while (parseCacheResult.indexOf('$data') != -1) parseCacheResult = parseCacheResult.replace('$data', '_dataCache');
while (parseCacheResult.indexOf('$name') != -1) parseCacheResult = parseCacheResult.replace('$name', param.nameParam);
while (parseCacheResult.indexOf('$type') != -1) parseCacheResult = parseCacheResult.replace('$type', param.type);
} else if (param.visible == 'static')
{
while (parseStaticResult.indexOf('$data') != -1) parseStaticResult = parseStaticResult.replace('$data', '_dataStatic');
while (parseStaticResult.indexOf('$name') != -1) parseStaticResult = parseStaticResult.replace('$name', param.nameParam);
while (parseStaticResult.indexOf('$type') != -1) parseStaticResult = parseStaticResult.replace('$type', param.type);
}
else
{
while (parseDynamicResult.indexOf('$data') != -1) parseDynamicResult = parseDynamicResult.replace('$data', '_dataDynamic');
while (parseDynamicResult.indexOf('$name') != -1) parseDynamicResult = parseDynamicResult.replace('$name', param.nameParam);
while (parseDynamicResult.indexOf('$type') != -1) parseDynamicResult = parseDynamicResult.replace('$type', param.type);
}
while (setResult.indexOf('$name') != -1) setResult = setResult.replace('$name', param.nameParam);
while (setResult.indexOf('$type') != -1) setResult = setResult.replace('$type', param.type);
while (setResult.indexOf('$className') != -1) setResult = setResult.replace('$className', className);
while (getResult.indexOf('$name') != -1) getResult = getResult.replace('$name', param.nameParam);
while (getResult.indexOf('$type') != -1) getResult = getResult.replace('$type', param.type);
while (varResult.indexOf('$name') != -1) varResult = varResult.replace('$name', param.nameParam);
while (varResult.indexOf('$type') != -1) varResult = varResult.replace('$type', param.type);
while (varResult.indexOf('$comment') != -1) varResult = varResult.replace('$comment', param.comment);
while (varResult.indexOf('$default') != -1) varResult = varResult.replace('$default', param.defaultValue);
}
var result : String = baseTemplate;
while (result.indexOf('$className') != -1) result = result.replace('$className', className);
while (result.indexOf('$comment') != -1) result = result.replace('$comment', comment);
while (result.indexOf('$baseClass') != -1) result = result.replace('$baseClass', baseClass);
while (result.indexOf('$singleton_1') != -1) result = result.replace('$singleton_1', singl_1);
while (result.indexOf('$singleton_2') != -1) result = result.replace('$singleton_2', singl_2);
result = result.replace('$var', varResult);
result = result.replace('$set', setResult);
result = result.replace('$get', getResult);
result = result.replace('$parseDynamic', parseDynamicResult);
result = result.replace('$parseStatic', parseStaticResult);
result = result.replace('$parseCache', parseCacheResult);
result = result.replace('$values', valuesList);
result = result.replace('$dynamic', data.dynamicClass == 1 ? 'dynamic' : '');
Как то родилось в процессе допилок кодогена )
+79
if ("5".equals(pid)) {
} else {
if ("1".equals(pid) || "4".equals(pid)) {
type = "fl";
} else if ("6".equals(pid)){
type = "nw";
}else {
type = "ul";
}
}
Из базы формируется дерево элементов для меню. Там же есть какая-то сортировка. Меняем в базе сортировку, а все работает по-старому. Лезем копать и находим.
+154
static public function vkontakte_enabled()
{
return ( ipsRegistry::$settings['vk_enabled'] AND ipsRegistry::$settings['vk_api_id'] AND ipsRegistry::$settings['vk_secret'] ) ? TRUE : FALSE;
}
* IP.Board v3.1.4
И почему я пишу форумы сам?..
+133
// for cdio:
#include <cdio.h>
#include <cdio_unconfig.h> # remove *all* symbols libcdio defines
// Add back in the ones you want your program
#include <config.h>
But now what about the problem that there are common preprocessor symbols in config_cdio.h that an application may want to define in a different manner, like PACKAGE_NAME?
For this, there is yet another header, <cdio/cdio_unconfig.h>.
+72
LOG.error(msg);
Writer writer = new StringWriter();
e.printStackTrace(new PrintWriter(writer, true));
LOG.error(writer.toString());
Паранойя... А вдруг LOG неправильно стэк трейс напечатает при передаче эксепшена вторым параметром.
+145
$sortBy = "";
if ( isset($_REQUEST['sortBy']) && ! empty($_REQUEST['sortBy'])) {
// Get sort direction and field sort.
$sortByParts = explode("-", $_REQUEST['sortBy']);
if ( is_array($sortByParts) && ! empty($sortByParts[0]) && ! empty($sortByParts[1])) {
$sortBy = $sortByParts[0];
$direction = $sortByParts[1];
}
}
switch ($sortBy)
case "discount":
$sortFieldBy = $sortBy;
break;
case "created":
$sortFieldBy = $sortBy;
break;
case "vendor":
$sortFieldBy = $sortBy;
break;
case "actual_euprice":
$sortFieldBy = $sortBy;
break;
case "actual_euprice":
$sortFieldBy = $sortBy;
break;
case "top_sell_product":
default:
$search->addAdditionalJoins(
"top_sell_product",
array("top_sell_product.prodlevid" => "p.prodlevid"),
SEARCH_ADDITIONAL_JOIN_TYPE_INNER,
array()
);
Очередная самописная CMS.