Súbor: [Platon] / Metafox / admin / inc-db / articles.inc.php (stiahnutie)
Revízia 1.35, Tue Nov 7 08:43:22 2017 UTC (6 years, 4 months ago) by nepto
Zmeny od 1.34: +1 -1 [lines]
Reuse existing DB handle in $ezin_db_handle variable instead of creating
a new one. Not only this needs more resources, but also newly created
handle does not have proper encoding initialized via SET NAMES query
(for example default UTF-8 vs required LATIN2)
|
<?php
// Authentification
if (@file_exists('inc/auth.inc.php') && @include_once 'inc/auth.inc.php');
else exit;
// General options
$ezin_opts['dbh'] = $ezin_db_handle;
$ezin_opts['tb'] = $ezin_sys['db']['tables']['articles'];
$ezin_opts['key'] = 'id';
$ezin_opts['key_type'] = 'int';
$ezin_opts['inc'] = 15;
$ezin_opts['options'] = $ezin_user['role_articles'];
$ezin_opts['multiple'] = '4';
$ezin_opts['navigation'] = $ezin_cfg['admin_navigation'].$ezin_cfg['admin_buttons_pos'];
$ezin_opts['display'] = array('query' => false, 'sort' => false, 'time' => false);
$ezin_opts['url'] = array('images' => 'icons/');
$ezin_opts['sort_field'] = array($ezin_admin_action=='pages'?'access_key':'-datetime', '-id');
$ezin_opts['language'] = 'EN';
$ezin_opts['encoding'] = $ezin_cfg['encoding'];
$ezin_opts['ext_hsc'] = false;
// Buttons
$ezin_opts['buttons']['C']['up'] = array('save','more','cancel', ' ',
array('name' => 'wordclean', 'value' => 'Word Clean', 'css' => 'pme-wordclean', 'disabled' => false),
array('name' => 'switch', 'value' => 'Move to '.($ezin_admin_action=='pages'?'Articles':'Pages'),
'css' => 'pme-switch', 'disabled' => false));
$ezin_opts['buttons']['C']['down'] = $ezin_opts['buttons']['C']['up'];
// Triggers
$ezin_opts['triggers']['insert']['before'][] = 'inc-db/triggers/word-count.trigger';
$ezin_opts['triggers']['update']['before'][] = 'inc-db/triggers/word-count.trigger';
$ezin_opts['triggers']['insert']['before'][] = 'inc-db/triggers/text-flags.trigger';
$ezin_opts['triggers']['update']['before'][] = 'inc-db/triggers/text-flags.trigger';
$ezin_opts['triggers']['insert']['before'][] = 'inc-db/triggers/access-key.trigger';
$ezin_opts['triggers']['update']['before'][] = 'inc-db/triggers/access-key.trigger';
$ezin_opts['triggers']['insert']['after'][] = 'inc-db/triggers/articles.after';
$ezin_opts['triggers']['update']['after'][] = 'inc-db/triggers/articles.after';
$ezin_opts['triggers']['delete']['after'][] = 'inc-db/triggers/articles.after';
$ezin_opts['triggers']['insert']['after'][] = 'inc-db/triggers/access-key.insert.after';
$ezin_opts['triggers']['update']['after'][] = 'inc-db/triggers/access-key.update.after';
$ezin_opts['triggers']['delete']['after'][] = 'inc-db/triggers/access-key.delete.after';
// Filters
if ($ezin_admin_action == 'pages') {
$ezin_opts['filters'] = '(datetime IS NULL OR UNIX_TIMESTAMP(datetime) = 0 OR UNIX_TIMESTAMP(datetime) IS NULL)';
} else {
$ezin_opts['filters'] = 'UNIX_TIMESTAMP(datetime) != 0 AND UNIX_TIMESTAMP(datetime) IS NOT NULL';
}
if (ezin_admin_is_blog()) {
$ezin_opts['filters'] .= ' AND PMEtable0.author_id = '.intval($ezin_user['author_id']);
$ezin_opts['filters'] .= ' AND PMEjoin10.type = "normal"';
}
// Field definitions
$ezin_opts['fdd']['id'] = array(
'name'=>($ezin_admin_action=='pages'?'Page ID':'Article ID'),
'name|LF'=>'ID',
'select'=>'T',
'sort'=>true,
'size'=>5,
'default'=>'',
'options'=>'LDVFPCR',
'URL'=>ezin_get_link('A', '$value'),
// TODO: fix for length >= 5
'sql|LF'=>'IF(TRIM(PMEtable0.access_key) != "",'
.' CONCAT(LPAD(PMEtable0.id,4,"0"), "<!--", PMEtable0.access_key, "-->"), LPAD(PMEtable0.id,4,"0"))',
'escape' => false,
'colattrs|LF'=>'align="center"',
);
/*
$ezin_opts['fdd']['status'] = array(
'name'=>'Status',
'name|LF'=>'S',
'select'=>'D',
'values'=>array(),
'values2'=> array(
'showed' => '<b>showed</b> (default)',
'partly_showed' => '<b>partly showed</b> (hidden from global sections)',
'hidden' => '<b>not showed</b> (hidden, but accessible)',
'disabled' => '<b>disabled</b> (unaccessible)'),
'values2|LF'=>array(
'' => '<code>S?</code>',
'showed' => '<code>S</code>',
'partly_showed' => '<code>s</code>',
'hidden' => '<code>H</code>',
'disabled' => '<code>D</code>'),
'sort'=>true,
'colattrs|LF'=>'align="center"',
);
*/
$ezin_opts['fdd']['display'] = array(
'name'=>'Display',
'name|LF'=>'D',
'select'=>'C',
'select|LF'=>'M',
'values'=>array(),
'values2'=> array(
'enabled' => 'Enabled',
'in_normal' => 'Display in normal section',
'in_global' => 'Display in global section'),
'values2|LF'=>array(
'' => '<code>Disabled</code>',
'enabled' => '<code>E</code>',
'in_normal' => '<code>N</code>',
'in_global' => '<code>G</code>'),
'sort'=>true,
'colattrs|LF'=>'align="center"',
);
$template_keys = array_unique(array_merge(
ezin_admin_get_template_keys($ezin_sys['tmpl']['article']),
ezin_admin_get_template_keys($ezin_sys['tmpl']['article_item'])));
if (count($template_keys) > 0) {
$ezin_opts['fdd']['template_key'] = array(
'name'=>Platon::htmlspecialchars2('Template key'),
'sort'=>true,
'select'=>'T',
'options'=>'ACPDV',
'values2'=> array(''=>' - default template - '),
'values' => $template_keys
);
}
$ezin_opts['fdd']['access_key'] = array(
'name'=>Platon::htmlspecialchars2('Access key'),
'name|LF'=>'Key',
'sort'=>true,
'select'=>'T',
'options'=>'ACPDV'.($ezin_admin_action == 'pages' ? 'LF' : ''),
'colattrs|LF'=>'width="15%"',
);
$ezin_opts['fdd']['datetime'] = array(
'name'=>Platon::htmlspecialchars2('Date & Time'),
'select'=>'T',
'sort'=>true,
'required'=>true,
'mask'=>'%.10s',
'options'=>($ezin_admin_action == 'pages' ? 'ACPVDRH' : 'ACPVDLF'),
'default'=>($ezin_admin_action == 'pages' ? '0000-00-00' : date('Y-m-d H:i:s')),
'colattrs|LF'=>'align="center"',
);
if ($ezin_cfg['calendar'] == '1') {
$ezin_opts['fdd']['calendar_flag'] = array(
'name'=>'Calendar flag',
'select'=>'T',
'sort'=>true,
'mask'=>'%.10s',
'options'=>'ACPDV',
'colattrs|LF'=>'align="center"',
'sqlw' => 'IF($val_qas = "", NULL, $val_qas)'
);
}
if ($ezin_cfg['featured_articles'] == '1') {
$ezin_opts['fdd']['featured_articles_flag'] = array(
'name'=>'Featured articles flag',
'select'=>'T',
'sort'=>true,
'mask'=>'%.10s',
'options'=>'ACPDV',
'colattrs|LF'=>'align="center"',
'sqlw' => 'IF($val_qas = "", NULL, $val_qas)'
);
}
$ezin_opts['fdd']['bind_lang'] = array(
'name'=>Platon::htmlspecialchars2('Language bind'),
'select'=>'D',
'sort'=>true,
'options' => 0 && is_array($ezin_cfg['languages']) ? 'ACPVD' : ''
);
$ezin_opts['fdd']['bind_theme'] = array(
'name'=>Platon::htmlspecialchars2('Theme bind'),
'select'=>'D',
'sort'=>true,
'options' => 0 && 1 ? 'ACPVD' : ''
);
$ezin_opts['fdd']['accesses_count'] = array(
'name'=>Platon::htmlspecialchars2('Accesses count'),
'options'=>'VDACP'.'HR',
'default'=>'0'
);
$ezin_opts['fdd']['sessions_count'] = array(
'name'=>Platon::htmlspecialchars2('Sessions count'),
'options'=>'VDACP'.'HR',
'default'=>'0'
);
$ezin_opts['fdd']['message_count'] = array(
'name'=>Platon::htmlspecialchars2('Message count'),
'options'=>'VDACP'.'HR',
'default'=>'0'
);
$ezin_opts['fdd']['author_id'] = array(
'name'=>'Author',
'select'=>'D',
'sort'=>true,
'required'=>true,
'strip_tags'=>true,
'values'=>array(
'table' => $ezin_sys['db']['tables']['authors'],
'column' => 'id',
'filters' => 'type = "internal"',
'description' => 'name')
);
if (ezin_admin_is_blog()) {
$ezin_opts['fdd']['author_id']['options'] = 'LFACPVDR';
$ezin_opts['fdd']['author_id']['default'] = $ezin_user['author_id'];
} elseif ($ezin_cfg['single_author_id'] >= 0) {
/* If we have just one Author in DB, we do not need to show him */
$ezin_opts['fdd']['author_id']['options'] = 'ACPVDRH';
$ezin_opts['fdd']['author_id']['default'] = $ezin_cfg['single_author_id'];
}
$ezin_opts['fdd']['section_id'] = array(
'name'=>'Section',
'select'=>'D',
'sort'=>true,
'required'=>true,
'strip_tags'=>true,
'values'=>array(
'table' => $ezin_sys['db']['tables']['sections'],
'orderby' => 'lang,ord,id',
'column' => 'id',
'description' => array(
'columns' => array('name', 'id', 'lang'),
'divs' => array(' (', ') ',''))),
);
if (ezin_admin_is_blog()) {
$ezin_opts['fdd']['section_id']['values|AP']=$ezin_opts['fdd']['section_id']['values'];
$ezin_opts['fdd']['section_id']['values|AP']['filters'] = 'type = "normal"';
$ezin_opts['fdd']['section_id']['options|C'] = 'CR';
$ezin_opts['fdd']['datetime']['options|C'] = 'CR';
}
if ($ezin_admin_action == 'articles') {
$ezin_opts['fdd']['section_id']['values']['filters'] = 'FIND_IN_SET("articles", `select`) > 0';
}
if ($ezin_admin_action == 'pages') {
$ezin_opts['fdd']['section_id']['values']['filters'] = 'FIND_IN_SET("pages", `select`) > 0';
}
if ($ezin_admin_action != 'pages') {
$ezin_opts['fdd']['atitle'] = array(
'name'=>Platon::htmlspecialchars2('Annotation title'),
'select'=>'T',
'maxlen'=>255,
'sort'=>true,
'options'=>'ACPVD',
);
}
$ezin_opts['fdd']['title'] = array(
'name'=>'Title',
'select'=>'T',
'maxlen'=>255,
'sort'=>true,
'trimlen|LF'=>35,
'sql|LF'=>'IF(TRIM(title) != "", title, atitle)'
);
$ezin_opts['fdd']['ghometext_wordcount'] = array(
'name'=>Platon::htmlspecialchars2('Global anotation word count'),
'select'=>'T',
'options'=>'HCAP'
);
$ezin_opts['fdd']['hometext_wordcount'] = array(
'name'=>Platon::htmlspecialchars2('Anotation word count'),
'select'=>'T',
'options'=>'HCAP'
);
$ezin_opts['fdd']['bodytext_wordcount'] = array(
'name'=>Platon::htmlspecialchars2('Text word count'),
'select'=>'T',
'options'=>'HCAP'
);
$ezin_opts['fdd']['ghometext_flags'] = array(
'name'=>Platon::htmlspecialchars2('Global anotation flags'),
'select'=>'T',
'options'=>'HCAP'
);
$ezin_opts['fdd']['hometext_flags'] = array(
'name'=>Platon::htmlspecialchars2('Anotation flags'),
'select'=>'T',
'options'=>'HCAP'
);
$ezin_opts['fdd']['bodytext_flags'] = array(
'name'=>Platon::htmlspecialchars2('Text flags'),
'select'=>'T',
'options'=>'HCAP'
);
if ($ezin_admin_action != 'pages') {
$ezin_opts['fdd']['ghometext'] = array(
'name'=>'Global anotation',
'select'=>'T',
'textarea'=>array(
'rows'=>4,
'cols'=>65,
),
'options'=>'ACPV'
);
$ezin_opts['fdd']['hometext'] = array(
'name'=>'Anotation',
'select'=>'T',
'textarea'=>array(
'rows'=>8,
'cols'=>65,
),
'options'=>'ACPV'
);
}
$ezin_opts['fdd']['bodytext'] = array(
'name'=>Platon::htmlspecialchars2('Article text'),
'select'=>'T',
'textarea'=>array(
'rows'=>15,
'cols'=>65,
'wrap'=>'virtual'
),
'options'=>'ACPV'
);
include dirname(__FILE__).'/_credentials.inc.php';
// Execution code
if (! ezin_admin_check_list_privileges($ezin_opts['options'])) {
require 'inc-html/permdenied.html';
} else {
/* if (! ezin_admin_check_privileges($ezin_opts['options'],
isset($author_id) && $author_id == $ezin_user['author_id'])) {
require 'inc-html/permdenied.html';
} */
require_once 'phpMyEdit/phpMyEdit.class.php';
$ezin_opts['execute'] = 0;
$phpMyEdit = new phpMyEdit($ezin_opts);
if ($phpMyEdit->get_sys_cgi_var('wordclean')) {
$content = $phpMyEdit->get_data_cgi_var('bodytext');
$content = ezin_admin_word_clean($content);
$phpMyEdit->myQuery(sprintf('UPDATE %s SET bodytext = "%s" WHERE id = %d',
$ezin_opts['tb'], addslashes($content), $phpMyEdit->rec));
} elseif ($phpMyEdit->get_sys_cgi_var('switch')) {
$datetime = $phpMyEdit->get_data_cgi_var('datetime');
if (strncmp($datetime, '0000-00-00', 10)) {
$phpMyEdit->myQuery(sprintf('UPDATE %s SET datetime = "0000-00-00"
WHERE id = %d AND UNIX_TIMESTAMP(datetime) != 0 AND UNIX_TIMESTAMP(datetime) IS NOT NULL',
$ezin_opts['tb'], $phpMyEdit->rec));
} else {
$phpMyEdit->myQuery(sprintf('UPDATE %s SET datetime = SYSDATE()
WHERE id = %d AND (UNIX_TIMESTAMP(datetime) = 0 OR UNIX_TIMESTAMP(datetime) IS NULL)',
$ezin_opts['tb'], $phpMyEdit->rec));
}
}
$phpMyEdit->execute();
}
?>
Platon Group <platon@platon.sk> http://platon.sk/
|