function get_categs_tree($id = 0) { global $db, $tables; static $categs = array("0" => "[Top]"); static $level = 0; $level++; $rs = $db->Execute("SELECT `ID`, `TITLE` FROM `{$tables['category']['name']}` WHERE `STATUS` = '2' AND `PARENT_ID` = " . $db->qstr($id) . " AND `SYMBOLIC` <> 1 ORDER BY `TITLE`"); while (!$rs->EOF) { if (empty($_SESSION['user_id']) || $_SESSION['is_admin']) { $categs[$rs->Fields('ID')] = str_repeat('| ', $level - 1) . '|___' . $rs->Fields('TITLE'); } else { if (in_array($rs->Fields('ID'), $_SESSION['user_permission_array'])) { $categs[$rs->Fields('ID')] = str_repeat('| ', $level - 1) . '|___' . $rs->Fields('TITLE'); } } get_categs_tree($rs->Fields('ID')); $rs->MoveNext(); } $level--; return $categs; }
} } else { $tpl->assign('sql_error', $db->ErrorMsg()); } } else { $tpl->assign('send_error', true); } } } $rs = $db->Execute("SELECT `ID`, `TITLE` FROM `{$tables['email_tpl']['name']}` WHERE `TPL_TYPE` = '3'"); $tpls = $rs->GetAssoc(); $tpl->assign('tpls', $tpls); $tpl->assign($full_data); $tpl->assign('EMAIL_TPL_ID', $_REQUEST['EMAIL_TPL_ID']); $tpl->assign('IGNORE', $_REQUEST['IGNORE']); $categs = get_categs_tree(0); $tpl->assign('categs', $categs); $content = $tpl->fetch('email_send_and_add_link.tpl'); $tpl->assign('content', $content); //Clean whitespace $tpl->loadFilter('output', 'trimwhitespace'); //Make output echo $tpl->fetch('main.tpl'); function check_email($value, $empty, &$params, &$form) { global $db, $tpl, $tables; $rs = $db->Execute("SELECT `ID`, `TITLE`, `URL` FROM `{$tables['link']['name']}` WHERE `URL` = " . $db->qstr($form['URL']) . " OR `TITLE` = " . $db->qstr($form['TITLE'])); $err['dir'] = array(); while (!$rs->EOF) { if (strcasecmp($rs->Fields('URL'), $form['URL']) == 0) { $err['dir'][] = 'URL';
} break; case 'E': if (empty($_REQUEST['submit'])) { $data = $db->GetRow("SELECT * FROM `{$tables['link']['name']}` WHERE `ID` = " . $db->qstr($id)); } case 'N': default: if ($action == 'N') { $data['STATUS'] = 2; $data['RECPR_REQUIRED'] = REQUIRE_RECIPROCAL; if (FTR_ENABLE == 1) { $data['FEATURED'] = isset($_REQUEST['f']) && $_REQUEST['f'] == 1 ? 1 : 0; } } $categs = get_categs_tree($db, 0); $tpl->assign('categs', $categs); if (empty($_REQUEST['submit'])) { SmartyValidate::connect($tpl); SmartyValidate::register_form('dir_links_edit', true); SmartyValidate::register_criteria('isValueUnique', 'validate_unique', 'dir_links_edit'); SmartyValidate::register_criteria('isNotEqual', 'validate_not_equal', 'dir_links_edit'); SmartyValidate::register_validator('v_TITLE', 'TITLE', 'notEmpty', false, false, 'trim', 'dir_links_edit'); SmartyValidate::register_validator('v_TITLE_U', "TITLE:link:{$id}:CATEGORY_ID", 'isValueUnique', false, false, null, 'dir_links_edit'); SmartyValidate::register_validator('v_URL', 'URL', 'isURL', false, false, 'trim', 'dir_links_edit'); SmartyValidate::register_validator('v_URL_U', 'URL:link:' . $id . (ALLOW_MULTIPLE ? ':CATEGORY_ID' : ''), 'isValueUnique', false, false, null, 'dir_links_edit'); SmartyValidate::register_validator('v_CATEGORY_ID', 'CATEGORY_ID:0', 'isNotEqual', true, false, null, 'dir_links_edit'); SmartyValidate::register_validator('v_RECPR_URL', 'RECPR_URL', 'isURL', true, false, 'trim', 'dir_links_edit'); SmartyValidate::register_validator('v_OWNER_NAME', 'OWNER_NAME', 'notEmpty', true, false, 'trim', 'dir_links_edit'); SmartyValidate::register_validator('v_OWNER_EMAIL', 'OWNER_EMAIL', 'isEmail', true, false, 'trim', 'dir_links_edit'); SmartyValidate::register_validator('v_EXPIRY_DATE', 'EXPIRY_DATE', 'isDate', true, false, 'trim', 'dir_links_edit');