-
+152
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
$db = Db::getInstance();
$result = $db->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'payment_module_settings`;');
$text = "";
for($i=2;$i<sizeof($result[0]);$i++)
{
if($i == 2)
{
$text .= "[general]"."\n";
$text .= "url = '".$result[0][url]."'"."\n";
}
if($i == 3)
{
$text .= "[payment]"."\n";
$text .= "sequritySender = '".$result[0][security_sender]."'"."\n";
}
if($i == 4)
{
$text .= "transactionChannel = '".$result[0][transaction_Channel]."'"."\n";
}
if($i == 5)
{
$text .= "transactionMode = '".$result[0][transaction_Mode]."'"."\n";
}
if($i == 6)
{
$text .= "userLogin = '".$result[0][user_Login]."'"."\n";
}
if($i == 7)
{
$text .= "userPwd = '".$result[0][user_Pwd]."'"."\n";
}
if($i == 8)
{
$text .= "paymentType = '".$result[0][payment_Type]."'"."\n";
}
if($i == 9)
{
$text .= "presentationCurrency = '".$result[0][presentation_Currency]."'"."\n";
}
if($i == 10)
{
$text .= "[view]"."\n";
$text .= "src = '".$result[0][src]."'"."\n";
}
if($i == 11)
{
$text .= "language = '".$result[0][language]."'"."\n";
}
if($i == 12)
{
$text .= "style = '".$result[0][style]."'"."\n";
}
}
if($_GET['paymentType'] == 'CC')
{
$text .= "brands[] = 'VISA'"."\n";
$text .= "brands[] = 'MASTER'"."\n";
}
if($_GET['paymentType'] == 'VA')
{
$text .= "brands[] = 'PAYPAL'"."\n";
}
$text .= "[soap]"."\n";
$text .= "url = 'http://debugservices.fine-trade.org/PayOnOrderHandling.svc?WSDL'"."\n";
$text .= "username = 'extensions'"."\n";
$text .= "password = 'testExtensions'"."\n";
$text .= "options[] = false"."\n";
$text .= "importIfPending = false"."\n";
if (file_exists('LoviitLib/config.ini')) {
unlink('LoviitLib/config.ini');
}
$myFile = "LoviitLib/testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $text);
fclose($fh);
rename("LoviitLib/testFile.txt","LoviitLib/config.ini");
Преамбула: для конфигурации библиотеки передаётся ассоциативный массив в конструктор. Если передаётся null, то для конфигурации используется файл config.ini с дефолтными настройками, который находится в корне библиотеки.
Этот код исполняется при каждой инициализации библиотеки (при каждом чекауте).
Ремарка: после запроса к db результатом является ассоциативный массив.
И да, это код из модуля для prestashop cms.
aronsky,
15 Апреля 2014
-
+155
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
$hlblock_id = 3;
$hlblock = HL\HighloadBlockTable::getById($hlblock_id)->fetch();
$entity = HL\HighloadBlockTable::compileEntity($hlblock);
$main_query = new Entity\Query($entity);
$main_query->setSelect(array('*'));
$main_query->setFilter(array('=UF_NAME' => $arOLDItem['material']));
$result = $main_query->exec();
$result = new CDBResult($result);
$row = $result->Fetch();
Bitrix, HIGHLOAD инфоблоки, данная запись равносильна SQL запросу SELECT * FROM %таблица_название_которой_хранится_в_бд_ под_номером_3% WHERE UF_NAME = $arOLDItem['material']
+зацените супер CamelCase от битрикса
TBoolean,
15 Апреля 2014
-
+133
Сосево из ширинки, ебля с порога.
KonardStuard,
14 Апреля 2014
-
+152
- 1
- 2
- 3
- 4
if (ctype_space($text[$pos] && $pos < $len)) {
while (ctype_space($text[$pos++]) && $pos < $len);
$pos--;
}
Написал я когда-то такое и подумал: а какой смысл в $pos++ в последней итерации, если потом сразу $pos--?
И тут до меня дошло, что
while (ctype_space($text[$pos++]) && $pos < $len);
это не то же самое, что
while (ctype_space($text[$pos]) && $pos < $len) $pos++;
ибо в первом случае $pos++ выполнится в последней итерации, даже если ctype_space возвратит false.
И в итоге заоптимизировал до while (ctype_space($text[$pos]) && $pos < $len) $pos++; (уже без ифа и декремента).
Мораль: нефиг выпендриваться (ставить инкременты и декременты в условия), если можно написать по-простому.
arzeth,
14 Апреля 2014
-
+153
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
<?php if(isset($the_cat_id)): ?>
<?php
$query_args['showposts'] = $brp_count_category;
$query_args['cat'] = $the_cat_id;
?>
<?php else: ?>
<?php
$query_args['showposts'] = $brp_count_index;
?>
<?php endif; ?>
{ }? Нет, не слышали...
russling,
14 Апреля 2014
-
+128
Дебил ХДДДДДДД
Pizda,
12 Апреля 2014
-
+153
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
public function filters($collection)
{
$className = $collection->modelName();
$filters = null;
$config = $this->getConfig($className)->admin_panel;
if (!empty($config['filters'])) {
$filters = $config['filters'];
}
if (!$filters) {
return $collection->raw();
}
foreach ($filters as $field => $value) {
if (strpos($value, '||')) {
$or = explode('||', $value);
$where = "";
foreach ($or as $value) {
if (strpos($value, '::') !== false) {
$value = call_user_func(trim($value));
}
$where .= $field . '="' . $value . '" OR ';
}
$collection->where('(' . substr($where, 0, -4) . ')');
} else {
if (strpos($value, '::') !== false) {
$value = call_user_func(trim($value));
}
$collection->where($field, trim($value));
}
}
return $collectio->raw();
}
фильтруем коллекцию блять!
greshnik,
11 Апреля 2014
-
+163
- 1
$model = new $_POST['form_model'];
Краткость,
сестра таланта,
Yii,
FormController,
...
BroadcastAddress,
10 Апреля 2014
-
+152
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
// Will we have a result object instantiated? If not - we'll simply return TRUE
if ($return_object !== TRUE) {
if ($this->cache_on === TRUE && $this->cache_autodel === TRUE && $this->_cache_init()) {
$this->CACHE->delete();
}
return TRUE;
}
// Return TRUE if we don't need to create a result object
if ($return_object !== TRUE) {
return TRUE;
}
Codeigniter / классика
https://github.com/EllisLab/CodeIgniter/blob/develop/system/database/DB_driver.php#L668
Fike,
09 Апреля 2014
-
+150
- 1
- 2
- 3
- 4
while ($row = db_fetch_assoc($q)){
if(!isset($output[$row['id']])) $output[$row['id']] = array();
$output[$row['id']][] = $row;
}
govnokoder2,
09 Апреля 2014