function isExsistDomain($domain, $client_srl = null) { $result = new Object(); $domain = str_replace(array('http://', 'www.'), '', $domain); // DB에서 검색 $args->domain = $domain; $args->client_srl = $client_srl; $output = executeQueryArray('socialxeserver.getClientByDomain', $args); if (!$output->toBool()) { return $output; } // 검색 결과가 없으면 false if (!$output->data) { $result->add('result', false); return $result; } // DB 검색 결과에서 도메인을 하나씩 체크 foreach ($output->data as $client) { $domain_array = explode(',', $client->domain); foreach ($domain_array as $val) { // 정확히 일치하는지를 검사 if (trim($val) == $domain) { $result->add('result', true); return $result; } } } // 일치하는 도메인이 없으면 false $result->add('result', false); return $result; }
/** * Test matching in various positions with various keys etc * * * @return void * @author Dan Cox */ public function test_aBunchOfMatchCases() { $this->collection->add('test1', 'value'); $this->collection->add('test2', 'val'); $this->collection->add('s./28', 'weird'); $str1 = '[test1]'; $str2 = '[test1][test2]'; $str3 = '[test1] [test2]'; $str4 = 'Text [nomask] first [test1]'; $str5 = '[test1] then text, then [test2]'; $str6 = '[s./28]'; $str8 = 'Test then value str [test1, value="value"]'; // Lets get matching! $matches1 = $this->matcher->load($str1, $this->collection)->search()->getRawMatches(); $matches2 = $this->matcher->load($str2, $this->collection)->search()->getRawMatches(); $matches3 = $this->matcher->load($str3, $this->collection)->search()->getRawMatches(); $matches4 = $this->matcher->load($str4, $this->collection)->search()->getRawMatches(); $matches5 = $this->matcher->load($str5, $this->collection)->search()->getRawMatches(); $matches6 = $this->matcher->load($str6, $this->collection)->search()->getRawMatches(); $matches8 = $this->matcher->load($str8, $this->collection)->search()->getRawMatches(); $this->assertEquals(array('[test1]'), $matches1); $this->assertEquals(array('[test1]', '[test2]'), $matches2); $this->assertEquals(array('[test1]', '[test2]'), $matches3); $this->assertEquals(array('[test1]'), $matches4); $this->assertEquals(array('[test1]', '[test2]'), $matches5); $this->assertEquals(array(), $matches6); $this->assertEquals(array('[test1, value="value"]'), $matches8); }
/** * Test the basic functions of the collection bag * * @return void * @author Dan Cox */ public function test_gettingSettingCollectionBag() { $this->collection->add('foo', 'bar'); $this->assertTrue($this->collection->getMethod()->has('foo')); $this->assertEquals('bar', $this->collection->getMethod()->get('foo')); $this->assertEquals(array('foo' => 'bar'), $this->collection->getMethod()->all()); }
public function Load() { parent::$PAGE_TITLE = __(ERROR_USER_BANNED) . " - " . __(SITE_NAME); parent::$PAGE_META_ROBOTS = "noindex, nofollow"; $can_use_captacha = true; if (WspBannedVisitors::isBannedIp($this->getRemoteIP())) { $last_access = new DateTime(WspBannedVisitors::getBannedIpLastAccess($this->getRemoteIP())); $duration = WspBannedVisitors::getBannedIpDuration($this->getRemoteIP()); $dte_ban = $last_access->modify("+" . $duration . " seconds"); if ($dte_ban > new DateTime()) { $can_use_captacha = false; } } $obj_error_msg = new Object(new Picture("wsp/img/warning.png", 48, 48, 0, "absmidlle"), "<br/><br/>"); $obj_error_msg->add(new Label(__(ERROR_USER_BANNED_MSG_1), true), "<br/>"); if ($can_use_captacha) { $obj_error_msg->add(new Label(__(ERROR_USER_BANNED_MSG_2), true), "<br/><br/>"); $this->captcha_error_obj = new Object(); $form = new Form($this); $this->captcha = new Captcha($form); $this->captcha->setFocus(); $unblock_btn = new Button($form); $unblock_btn->setValue(__(ERROR_USER_BUTTON))->onClick("onClickUnblock"); $form->setContent(new Object($this->captcha, "<br/>", $unblock_btn)); $obj_error_msg->add($this->captcha_error_obj, "<br/>", $form); } $obj_error_msg->add("<br/><br/>", __(MAIN_PAGE_GO_BACK), new Link(BASE_URL, Link::TARGET_NONE, __(SITE_NAME))); $this->render = new ErrorTemplate($obj_error_msg, __(ERROR_USER_BANNED)); }
/** * Test adding and getting back class * * @return void * @author Dan Cox */ public function test_addGet() { $arr = array('task' => array('name' => 'Command', 'description' => '', 'actions' => ['main', 'run']), 'class' => 'TEST'); $this->library->add($arr); // Now find this by its command name $val = $this->library->find('Command:run'); $this->assertEquals('TEST', $val); }
public function Load() { parent::$PAGE_TITLE = __(CONFIGURE_MODULES); $config_modules_obj = new Object(); $construction_page = new Object(__(PAGE_IN_CONSTRUCTION)); $construction_page->setClass("warning"); $config_modules_obj->add($construction_page); $config_modules_obj->add("<br/>", __(PRESENTATION), "<br/><br/>"); $sort_event_install = new SortableEvent($this); $sort_event_install->onSort("onChangeModule")->setAjaxEvent()->disableAjaxWaitMessage(); $this->list_install_modules_obj = new Object(); $this->list_install_modules_obj->setId("list_install_modules"); $this->list_install_modules_obj->setSortable(true, $sort_event_install); $list_all_install_modules_obj = new Object(); $module_style = "cursor:pointer;width:100px;border:1px solid gray;padding:2px;margin:2px;"; $array_active_modules = array(); $module_file = new File(dirname(__FILE__) . "/../../../wsp/config/modules.cnf"); while (($line = $module_file->read_line()) != false) { if (trim($line) != "") { $array_active_modules[] = trim($line); $module_obj = new Object(trim($line)); $module_obj->setId("module_" . str_replace("-", "_", trim($line)))->forceDivTag(); if (trim($line) != "Authentication") { $module_obj->setStyle($module_style); $module_obj->setDraggable(true, false, null, true); $this->list_install_modules_obj->add($module_obj); } else { $module_obj->setStyle($module_style . "cursor:none;"); $list_all_install_modules_obj->add($module_obj); } } } $module_file->close(); $list_all_install_modules_obj->add($this->list_install_modules_obj); $sort_event = new SortableEvent($this); $sort_event->onSort("onChangeModule")->setAjaxEvent()->disableAjaxWaitMessage(); $this->list_modules_obj = new Object(); $this->list_modules_obj->setId("list_modules"); $this->list_modules_obj->setSortable(true, $sort_event); $folder = dirname(__FILE__) . "/../../../wsp/class/modules"; $array_module_dir = scandir($folder); for ($i = 0; $i < sizeof($array_module_dir); $i++) { if (is_dir($folder . "/" . $array_module_dir[$i]) && !in_array($array_module_dir[$i], $array_active_modules) && $array_module_dir[$i] != "." && $array_module_dir[$i] != ".." && $array_module_dir[$i] != ".svn") { $module_obj = new Object($array_module_dir[$i]); $module_obj->setId("module_" . str_replace("-", "_", $array_module_dir[$i]))->forceDivTag(); $module_obj->setDraggable(true, false, null, true)->setStyle($module_style); $this->list_modules_obj->add($module_obj); } } $config_table = new Table(); $config_table->setWidth(400)->setDefaultAlign(RowTable::ALIGN_CENTER); $config_table->setDefaultValign(RowTable::VALIGN_TOP); $config_table->addRowColumns(new Object(new Label(__(ALL_MODULES), true), "<br/>", $this->list_modules_obj), " ", new Object(new Label(__(INSTALLED_MODULES), true), "<br/>", $list_all_install_modules_obj)); $config_modules_obj->add($config_table, "<br/><br/>"); $this->render = new AdminTemplateForm($this, $config_modules_obj); }
/** * Set up test vars * * @return void * @author Dan Cox */ public function setUp() { $this->CT = new CommandTester(); // Setup some fake app details $app = $this->CT->getApplication(); $app->setName('Test CLI'); $app->setVersion('1.0.0'); // Add some tasks to play with $this->CT->add(new FakeTask()); }
public function testArrays() { $Split1 = new Split(1.0, 260, false); $Split2 = new Split(1.0, 200, true); $Splits1 = new Object(array($Split1, $Split2)); $Splits2 = new Object(); $Splits2->add($Split1); $Splits2->add($Split2); $this->assertEquals(2, count($Splits1->asArray())); $this->assertEquals($Splits1->asArray(), $Splits2->asArray()); }
public function Load() { parent::$PAGE_TITLE = __(CONFIGURE_USERS); $config_users_obj = new Object("<br/>"); $this->result_obj = new Object(); $this->result_obj->setId("page_result_area"); $config_users_obj->add($this->result_obj); $this->users_table_obj = new Object(); $this->users_table_obj->setId("users_table_obj"); $config_users_obj->add($this->users_table_obj, "<br/><br/>"); $user_table = new Table(); $form = new Form($this); if (extension_loaded('openssl')) { $form->setEncryptObject(new EncryptDataWspObject()); } $this->edt_login = new TextBox($form); $validation = new LiveValidation(); $user_table->addRowColumns(__(LOGIN) . ": ", $this->edt_login->setLiveValidation($validation->addValidatePresence())); $this->cmb_rights = new ComboBox($form); $this->cmb_rights->addItem(Page::RIGHTS_ADMINISTRATOR, "Administrator"); $this->cmb_rights->addItem(Page::RIGHTS_MODERATOR, "Moderator"); $this->cmb_rights->addItem(Page::RIGHTS_TRANSLATOR, "Translator"); $this->cmb_rights->addItem(Page::RIGHTS_DEVELOPER, "Developer"); $this->cmb_rights->addItem(Page::RIGHTS_AUTH_USER, "Authentificated user"); $this->cmb_rights->addItem(Page::RIGHTS_GUEST, "Guest"); $user_table->addRowColumns(__(RIGHTS) . ": ", $this->cmb_rights); $this->edt_old_password = new Password($form); $validation = new LiveValidation(); $this->old_passwd_row = $user_table->addRowColumns(__(OLD_PASSWORD) . ": ", $this->edt_old_password->setLiveValidation($validation->addValidatePresence()->setFieldName(__(OLD_PASSWORD)))); $this->old_passwd_row->setId("old_passwd_row"); $this->edt_password = new Password($form); $validation = new LiveValidation(); $user_table->addRowColumns(__(PASSWORD) . ": ", $this->edt_password->setLiveValidation($validation->addValidatePresence()->setFieldName(__(PASSWORD)))); $this->edt_confirm_passwd = new Password($form); $live_validation = new LiveValidation(); $live_validation->addValidatePresence()->setFieldName(__(CONFIRM_PASSWD)); $live_validation->addValidateConfirmation($this->edt_password->getId()); $user_table->addRowColumns(__(CONFIRM_PASSWD) . " : ", $this->edt_confirm_passwd->setLiveValidation($live_validation))->setStyle("color:black;"); $user_table->addRow(); $this->validate_btn = new Button($form); $this->validate_btn->setValue(__(ADD))->onClick("addWspUser")->setAjaxEvent()->disableAjaxWaitMessage()->assignEnterKey(); $this->modify_btn = new Button($form); $this->modify_btn->setValue(__(SAVE))->onClick("changeWspUser")->setAjaxEvent()->disableAjaxWaitMessage()->assignEnterKey(); $this->cancel_btn = new Button($this); $this->cancel_btn->setValue(__(CANCEL))->onClick("refresh")->setAjaxEvent()->disableAjaxWaitMessage(); $modif_btn_table = new Table(); $modif_btn_table->addRowColumns($this->validate_btn, " ", $this->modify_btn, " ", $this->cancel_btn); $user_table->addRow($modif_btn_table)->setColspan(2)->setAlign(RowTable::ALIGN_CENTER); $config_users_obj->add($form->setContent($user_table), "<br/><br/>"); $this->render = new AdminTemplateForm($this, $config_users_obj); }
/** * @brief LDAP 연동하여 정보를 return하는 method **/ function ldap_conn($user_id, $password, $ldap_userdn_prefix, $ldap_userdn_suffix, $base_dn, $ldap_server, $ldap_port = 389) { if (!function_exists('ldap_connect')) { return new Object(-1, 'ldap module is not exists'); } $ds = @ldap_connect($ldap_server, $ldap_port); if (!$ds) { return new Object(-1, 'server not connected'); } if (!ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)) { return new Object(-1, 'fail to set option'); } $userdn = $ldap_userdn_prefix . $user_id . $ldap_userdn_suffix; if (!@ldap_bind($ds, $userdn, $password)) { return new Object(-1, 'fail to bind'); } $ldap_sr = @ldap_search($ds, $base_dn, '(cn=' . $user_id . ')', array('*')); if (!$ldap_sr) { return new Object(-1, 'fail to search'); } $info = ldap_get_entries($ds, $ldap_sr); if ($info['count'] < 1 || !is_array($info) || !count($info[0])) { return new Object(-1, 'not found'); } $obj = new Object(); foreach ($info[0] as $key => $val) { if (preg_match('/^[0-9]*$/', $key) || $key == 'objectclass') { continue; } $obj->add($key, $val[0]); } return $obj; }
function __construct($content, $title) { parent::__construct(); define(GOOGLE_CODE_TRACKER_NOT_ACTIF, true); $this->render = new Table(); $this->render->setWidth("100%"); // Header if (defined('SITE_META_OPENGRAPH_IMAGE') && SITE_META_OPENGRAPH_IMAGE != "") { $logo = new Picture(SITE_META_OPENGRAPH_IMAGE); } else { $logo = new Picture("img/logo_128x400_" . $_SESSION['lang'] . ".png", 128, 400); } $logo->setTitle(__(SITE_NAME)); $logo_link = new Link($this->getPage()->getBaseLanguageURL(), Link::TARGET_NONE, $logo); $img_obj = new Object($logo_link); $img_obj->add("<br/><br/>"); $this->render->addRow($img_obj); $this->render->addRow(); // Error message $small_img = new Picture("wsp/img/warning_16.png", 16, 16, 0, "absmiddle"); $title_header = new Object($small_img, $title); $error_box = new Box($title_header, true, Box::STYLE_MAIN, Box::STYLE_MAIN, '', 'error_box', 700); $error_box->setContent($content); $this->render->addRow($error_box); }
function processPayment($args) { $output = new Object(); $output->add('state', '2'); // not completed $output->add('payment_method', 'ZP'); $output->add('payment_amount', $args->price); $output->add('result_code', '0'); $output->add('result_message', 'success'); $output->add('pg_tid', $this->keygen()); $output->add('vact_bankname', $this->plugin_info->bank_name); $output->add('vact_num', $this->plugin_info->account_number); $output->add('vact_name', $this->plugin_info->account_holder); $output->add('vact_inputname', $args->depositor_name); return $output; }
public function Load() { parent::$PAGE_TITLE = __(CONFIGURE_BANNED_VISITORS); if (!defined('MAX_BAD_URL_BEFORE_BANNED')) { define("MAX_BAD_URL_BEFORE_BANNED", 4); } $this->array_wsp_banned_users = WspBannedVisitors::getBannedVisitors(); $this->table_ban = new Table(); $this->table_ban->setId("table_ban")->activateAdvanceTable()->activatePagination()->activateSort(2, "desc")->setWidth(500); $this->table_ban->addRowColumns("IP", __(LAST_ACCESS), __(DURATION), __(AUTHORIZE))->setHeaderClass(0); $ban_vistors_obj = new Object("<br/><br/>", $this->table_ban, "<br/><br/>"); $ban_ip_table = new Table(); $form = new Form($this); $this->ip_edt = new TextBox($form); $validation = new LiveValidation(); $validation->addValidatePresence(); $this->ip_edt->setLiveValidation($validation); $this->duration_edt = new TextBox($form); $this->duration_edt->setValue(0); $validation = new LiveValidation(); $validation->addValidatePresence()->addValidateNumericality(true); $this->duration_edt->setLiveValidation($validation); $ip_btn = new Button($form); $ip_btn->setValue(__(BAN_IP))->onClick("onBannedIP")->setAjaxEvent(); $ban_ip_table->addRowColumns("IP : ", $this->ip_edt); $ban_ip_table->addRowColumns(__(DURATION) . " : ", $this->duration_edt); $form->setContent(new Object($ban_ip_table, $ip_btn)); $ban_vistors_obj->add($form, "<br/><br/>"); $this->render = new AdminTemplateForm($this, $ban_vistors_obj); }
/** * Adds a route to the appropriate collection * * @param String $name * @param SymfonyRoute $route * @return void * @author Dan Cox **/ public function processRoute($name, $route) { if (!is_null($this->activeGroup)) { $this->activeGroup->add($name, $route); } else { $this->collection->add($name, $route); } }
public function Load() { header($_SERVER["SERVER_PROTOCOL"] . " 401 Unauthorized"); parent::$PAGE_TITLE = __(ERROR_USER_RIGHTS) . " - " . __(SITE_NAME); parent::$PAGE_META_ROBOTS = "noindex, nofollow"; $obj_error_msg = new Object(new Picture("wsp/img/warning.png", 48, 48, 0, "absmidlle"), "<br/>", new Label(__(ERROR_USER_RIGHTS_MSG))); $obj_error_msg->add("<br/><br/>", __(MAIN_PAGE_GO_BACK), new Link(BASE_URL, Link::TARGET_NONE, __(SITE_NAME))); $this->render = new ErrorTemplate($obj_error_msg, __(ERROR_USER_RIGHTS)); }
function __construct() { // Footer $footer_obj = new Object("<br/>", "Copyright © 2013-" . date("Y")); $footer_link = new Link(BASE_URL, Link::TARGET_NONE, __(SITE_NAME)); $footer_obj->add($footer_link); $footer_obj = new Font($footer_obj, 9); $this->render = $footer_obj; }
function __construct() { // Header $logo = new Picture("img/logo_128x400_" . $_SESSION['lang'] . ".png", 128, 400); $logo->setTitle(__(SITE_NAME)); $logo_link = new Link(BASE_URL . $_SESSION['lang'] . "/", Link::TARGET_NONE, $logo); $img_obj = new Object($logo_link); $img_obj->add("<br/><br/>"); $this->render = $img_obj; }
public function Load() { if (defined('SEND_ERROR_BY_MAIL') && SEND_ERROR_BY_MAIL == true && !isLocalDebug()) { if ($this->is_trace) { // standard msg "administrator is notified" parent::$PAGE_TITLE = __(ERROR) . " - " . __(SITE_NAME); $box_title = __(ERROR); $debug_msg = __(ERROR_DEBUG_MAIL_SENT); } else { // no trace in the debug information parent::$PAGE_TITLE = "Debug error - " . __(SITE_NAME); $box_title = "Debug error"; $debug_msg = $_POST['debug']; } } else { parent::$PAGE_TITLE = "Debug error - " . __(SITE_NAME); $box_title = "Debug error"; $debug_msg = $_POST['debug']; } $error_title_table = new Table(); $error_title_table->addRowColumns(new Picture("wsp/img/warning.png", 48, 48, 0, "absmidlle"), " ", new Label(__(ERROR), true)); $obj_error_msg = new Object($error_title_table, "<br/>"); $debug_obj = new Object(utf8encode($debug_msg)); $debug_obj->setAlign(Object::ALIGN_LEFT); $debug_obj->setWidth("80%"); $obj_error_msg->add($debug_obj, "<br/><br/>"); if ($GLOBALS['__AJAX_LOAD_PAGE__'] == false) { $obj_error_msg->add("<a href=\"" . $_GET['from_url'] . "\">Refresh this page</a>", "<br/><br/>"); } $obj_error_msg->add("<b>Consult <a href=\"http://www.php.net\" target=\"_blank\">PHP</a> or <a href=\"http://www.website-php.com\" target=\"_blank\">WebSite-PHP</a> documentations.</b>", "<br/>"); $obj_error_msg->add("<br/><br/>", "Go back to the main page", new Link(BASE_URL, Link::TARGET_NONE, __(SITE_NAME))); $this->render = new ErrorTemplate($obj_error_msg, $box_title); if (trim($_POST['debug']) != "") { $cache_filename = ""; if (isset($_POST['cache_filename']) && trim($_POST['cache_filename']) != "") { $cache_filename = $this->getRealCacheFileName($_POST['cache_filename']); if (!file_exists($cache_filename)) { $cache_filename = ""; } } NewException::sendErrorByMail($_POST['debug'], $cache_filename); } }
/** * This function is to build the date range - relative or absolute * * @param Object $form the form object that we are operating on * * @static * @access public */ static function buildDateRange(&$form, $fieldName, $count = 1, $required = false) { $selector = array('Choose Date Range', 'this.year' => 'This Year', 'this.fiscal_year' => 'This Fiscal Year', 'this.quarter' => 'This Quarter', 'this.month' => 'This Month', 'this.week' => 'This Week', 'this.day' => 'This Day', 'previous.year' => 'Previous Year', 'previous.fiscal_year' => 'Previous Fiscal Year', 'previous.quarter' => 'Previous Quarter', 'previous.month' => 'Previous Month', 'previous.week' => 'Previous Week', 'previous.day' => 'Previous Day', 'previous_before.year' => 'Previous Before Year', 'previous_before.quarter' => 'Previous Before Quarter', 'previous_before.month' => 'Previous Before Month', 'previous_before.week' => 'Previous Before Week', 'previous_before.day' => 'Previous Before Day', 'previous_2.year' => 'Previous 2 Years', 'previous_2.quarter' => 'Previous 2 Quarters', 'previous_2.month' => 'Previous 2 Months', 'previous_2.week' => 'Previous 2 Weeks', 'previous_2.day' => 'Previous 2 Days', 'earlier.year' => 'Earlier Year', 'earlier.quarter' => 'Earlier Quarter', 'earlier.month' => 'Earlier Month', 'earlier.week' => 'Earlier Week', 'earlier.day' => 'Earlier Day', 'greater.year' => 'Greater Year', 'greater.quarter' => 'Greater Quarter', 'greater.month' => 'Greater Month', 'greater.week' => 'Greater Week', 'greater.day' => 'Greater Day'); $config =& CRM_Core_Config::singleton(); //if fiscal year start on 1 jan then remove fiscal year task //form list if ($config->fiscalYearStart['d'] == 1 & $config->fiscalYearStart['M'] == 1) { unset($selector['this.fiscal_year']); unset($selector['previous.fiscal_year']); } $form->add('select', "{$fieldName}_relative", ts('Relative Date Range'), $selector, $required, array('onclick' => "showAbsoluteRange(this.value, '{$fieldName}_relative');")); $form->addDateRange($fieldName); }
public function Load() { parent::$PAGE_TITLE = __(HOME_PAGE_TITLE); // Welcome message $small_img = new Picture("img/logo_16x16.png", 16, 16, 0, Picture::ALIGN_ABSMIDDLE); $title_header = new Object($small_img, __(WELCOME)); $welcome_box = new Box($title_header, true, Box::STYLE_SECOND, Box::STYLE_SECOND, "", "welcome_box", 600); $welcome_obj = new Object(__(WELCOME_MSG)); list($strAdminLogin, $strAdminPasswd, $strAdminRights) = getWspUserRightsInfo("admin"); $quickstart_obj = new Object(new Picture("img/quickstart_128.png", 64, 64), "<br/>", __(QUICKSTART)); $quickstart_link = new Link("http://www.website-php.com/" . $this->getLanguage() . "/quick-start.html", Link::TARGET_BLANK, $quickstart_obj); $quickstart_box = new RoundBox(3, "quickstart_box", 120, 120); $quickstart_box->setValign(RoundBox::VALIGN_CENTER); $quickstart_box->setContent($quickstart_link); $tutorial_obj = new Object(new Picture("img/tutorials_128.png", 64, 64), "<br/>", __(TUTORIALS)); $tutorial_link = new Link("http://www.website-php.com/" . $this->getLanguage() . "/tutorials.html", Link::TARGET_BLANK, $tutorial_obj); $tutorial_box = new RoundBox(3, "tutorial_box", 120, 120); $tutorial_box->setValign(RoundBox::VALIGN_CENTER); $tutorial_box->setContent($tutorial_link); $connect_obj = new Object(new Picture("img/wsp-admin/admin_128.png", 64, 64), "<br/>", __(CONNECT)); $connect_link = new Link("wsp-admin/connect.html", Link::TARGET_BLANK, $connect_obj); $connect_box = new RoundBox(3, "connect_box", 120, 120); $connect_box->setValign(RoundBox::VALIGN_CENTER); $connect_box->setContent($connect_link); $icon_table = new Table(); $icon_table->setDefaultAlign(RowTable::ALIGN_CENTER)->setDefaultValign(RowTable::VALIGN_TOP); $icon_row = $icon_table->addRowColumns($quickstart_box, " ", $tutorial_box, " ", $connect_box); $icon_row->setColumnWidth(5, 120); if ($strAdminLogin == "admin" && $strAdminPasswd == sha1("admin")) { $finalize = new Font(__(FINALIZE_INSTALL)); $finalize->setFontColor("red"); $finalize->setFontWeight(Font::FONT_WEIGHT_BOLD); $welcome_obj->add("<br/>", $finalize, "<br/>", __(CONNECT_DEFAULT_PASSWD), "<br/>"); } $welcome_obj->add("<br/>", $icon_table); $welcome_box->setContent($welcome_obj); // Footer $this->render = new Template($welcome_box); }
/** * Adds commands to the application instance * * @return void * @author Dan Cox */ public function addCommands() { $commands = (require BOOTSTRAP . '/Commands.php'); if (isset($this->settings['commands']) && !empty($this->settings['commands'])) { $commands = array_merge($commands, $this->settings['commands']); } foreach ($commands as $cmd) { if (!is_object($cmd)) { $cmd = new $cmd(); } $this->app->add($cmd); } }
function processPayment($args) { $output = new Object(); $output->add('state', '1'); // not completed $output->add('payment_method', 'MO'); $output->add('payment_amount', $args->price); $output->add('result_code', '0'); $output->add('result_message', 'success'); $output->add('pg_tid', $this->keygen()); return $output; }
function editPost($postid, $oDocument, $category = null) { $oXmlParser = new XmlParser(); $output = $this->getUsersBlogs(); if (!$output->toBool()) { return $output; } $this->blogid = $output->get('blogid'); $input = sprintf('<?xml version="1.0"?>' . '<methodcall>' . '<methodname>blogger.editPost</methodname>' . '<params>' . '<param><value><string>%s</string></value></param>' . '<param><value><string>%s</string></value></param>' . '<param><value><string>%s</string></value></param>' . '<param><value><string>%s</string></value></param>' . '<param><value><string>%s<string></value></param>' . '<param><value><boolean>1</boolean></value></param>' . '</params>' . '</methodcall>', '0123456789ABCDEF', $postid, $this->user_id, $this->password, str_replace(array('&', '<', '>'), array('&', '<', '>'), $oDocument->get('content'))); $output = $this->_request($this->url, $input, 'application/octet-stream', 'POST'); $xmlDoc = $oXmlParser->parse($output); if (isset($xmlDoc->methodresponse->fault)) { $code = $xmlDoc->methodresponse->fault->value->struct->member[0]->value->int->body; $message = $xmlDoc->methodresponse->fault->value->struct->member[1]->value->string->body; return new Object($code, $message); } $output = new Object(); $output->add('postid', $postid); return $output; }
/** * Copy the post * @param array $document_srl_list * @param int $module_srl * @param int $category_srl * @return object */ function copyDocumentModule($document_srl_list, $module_srl, $category_srl) { if (count($document_srl_list) < 1) { return; } $oDocumentModel = getModel('document'); $oDocumentController = getController('document'); $oFileModel = getModel('file'); $oDB =& DB::getInstance(); $oDB->begin(); $triggerObj = new stdClass(); $triggerObj->document_srls = implode(',', $document_srl_list); $triggerObj->module_srl = $module_srl; $triggerObj->category_srl = $category_srl; // Call a trigger (before) $output = ModuleHandler::triggerCall('document.copyDocumentModule', 'before', $triggerObj); if (!$output->toBool()) { $oDB->rollback(); return $output; } $extraVarsList = $oDocumentModel->getDocumentExtraVarsFromDB($document_srl_list); $extraVarsListByDocumentSrl = array(); if (is_array($extraVarsList->data)) { foreach ($extraVarsList->data as $value) { if (!isset($extraVarsListByDocumentSrl[$value->document_srl])) { $extraVarsListByDocumentSrl[$value->document_srl] = array(); } $extraVarsListByDocumentSrl[$value->document_srl][] = $value; } } for ($i = count($document_srl_list) - 1; $i >= 0; $i--) { $document_srl = $document_srl_list[$i]; $oDocument = $oDocumentModel->getDocument($document_srl); if (!$oDocument->isExists()) { continue; } $obj = $oDocument->getObjectVars(); $extraVars = $extraVarsListByDocumentSrl[$document_srl]; if ($module_srl == $obj->module_srl) { if (is_array($extraVars)) { foreach ($extraVars as $extraItem) { if ($extraItem->var_idx >= 0) { $obj->{'extra_vars' . $extraItem->var_idx} = $extraItem->value; } } } } $obj->module_srl = $module_srl; $obj->document_srl = getNextSequence(); $obj->category_srl = $category_srl; $obj->password_is_hashed = true; $obj->comment_count = 0; $obj->trackback_count = 0; // Pre-register the attachment if ($oDocument->hasUploadedFiles()) { $files = $oDocument->getUploadedFiles(); foreach ($files as $val) { $file_info = array(); $file_info['tmp_name'] = $val->uploaded_filename; $file_info['name'] = $val->source_filename; $oFileController = getController('file'); $inserted_file = $oFileController->insertFile($file_info, $module_srl, $obj->document_srl, 0, true); // if image/video files if ($val->direct_download == 'Y') { $source_filename = substr($val->uploaded_filename, 2); $target_filename = substr($inserted_file->get('uploaded_filename'), 2); $obj->content = str_replace($source_filename, $target_filename, $obj->content); // If binary file } else { $obj->content = str_replace('file_srl=' . $val->file_srl, 'file_srl=' . $inserted_file->get('file_srl'), $obj->content); $obj->content = str_replace('sid=' . $val->sid, 'sid=' . $inserted_file->get('sid'), $obj->content); } } } // Write a post $output = $oDocumentController->insertDocument($obj, true, true); if (!$output->toBool()) { $oDB->rollback(); return $output; } // copy multi language contents if (is_array($extraVars)) { foreach ($extraVars as $value) { if ($value->idx >= 0 && $value->lang_code == Context::getLangType()) { continue; } if ($value->var_idx < 0 || $module_srl == $value->module_srl && $value->var_idx >= 0) { $oDocumentController->insertDocumentExtraVar($value->module_srl, $obj->document_srl, $value->var_idx, $value->value, $value->eid, $value->lang_code); } } } // Move the comments if ($oDocument->getCommentCount()) { $oCommentModel = getModel('comment'); $comment_output = $oCommentModel->getCommentList($document_srl, 0, true, 99999999); $comments = $comment_output->data; if (count($comments) > 0) { $oCommentController = getController('comment'); $success_count = 0; $p_comment_srl = array(); foreach ($comments as $comment_obj) { $comment_srl = getNextSequence(); $p_comment_srl[$comment_obj->comment_srl] = $comment_srl; // Pre-register the attachment if ($comment_obj->uploaded_count) { $files = $oFileModel->getFiles($comment_obj->comment_srl, true); foreach ($files as $val) { $file_info = array(); $file_info['tmp_name'] = $val->uploaded_filename; $file_info['name'] = $val->source_filename; $oFileController = getController('file'); $inserted_file = $oFileController->insertFile($file_info, $module_srl, $comment_srl, 0, true); // if image/video files if ($val->direct_download == 'Y') { $source_filename = substr($val->uploaded_filename, 2); $target_filename = substr($inserted_file->get('uploaded_filename'), 2); $comment_obj->content = str_replace($source_filename, $target_filename, $comment_obj->content); // If binary file } else { $comment_obj->content = str_replace('file_srl=' . $val->file_srl, 'file_srl=' . $inserted_file->get('file_srl'), $comment_obj->content); $comment_obj->content = str_replace('sid=' . $val->sid, 'sid=' . $inserted_file->get('sid'), $comment_obj->content); } } } $comment_obj->module_srl = $obj->module_srl; $comment_obj->document_srl = $obj->document_srl; $comment_obj->comment_srl = $comment_srl; if ($comment_obj->parent_srl) { $comment_obj->parent_srl = $p_comment_srl[$comment_obj->parent_srl]; } $output = $oCommentController->insertComment($comment_obj, true); if ($output->toBool()) { $success_count++; } } $oDocumentController->updateCommentCount($obj->document_srl, $success_count, $comment_obj->nick_name, true); } } // Move the trackbacks $oTrackbackModel = getModel('trackback'); if ($oTrackbackModel && $oDocument->getTrackbackCount()) { $trackbacks = $oTrackbackModel->getTrackbackList($oDocument->document_srl); if (count($trackbacks)) { $success_count = 0; foreach ($trackbacks as $trackback_obj) { $trackback_obj->trackback_srl = getNextSequence(); $trackback_obj->module_srl = $obj->module_srl; $trackback_obj->document_srl = $obj->document_srl; $output = executeQuery('trackback.insertTrackback', $trackback_obj); if ($output->toBool()) { $success_count++; } } // Update the number of trackbacks $oDocumentController->updateTrackbackCount($obj->document_srl, $success_count); } } $copied_srls[$document_srl] = $obj->document_srl; } // Call a trigger (before) $triggerObj->copied_srls = $copied_srls; $output = ModuleHandler::triggerCall('document.copyDocumentModule', 'after', $triggerObj); if (!$output->toBool()) { $oDB->rollback(); return $output; } $oDB->commit(); $output = new Object(); $output->add('copied_srls', $copied_srls); return $output; }
/** * This function is to build the date range - relative or absolute * * @param Object $form the form object that we are operating on * @param string $fieldName * @param Array $selector array of option values to add * @param integer $count * @param string $from * @param stringe $to * @param string $from Label * @param boolean $required * @param string $dateFormat * @param boolean $displayTime * @return null */ static function addDateRangeToForm(&$form, $fieldName, $selector, $from = '_from', $to = '_to', $fromLabel = 'From:', $required = FALSE, $dateFormat = 'searchDate', $displayTime = FALSE) { $form->add('select', "{$fieldName}_relative", ts('Relative Date Range'), $selector, $required); $form->addDateRange($fieldName, $from, $to, $fromLabel, $dateFormat, FALSE, $displayTime); }
/** * Set up test vars * * @return void * @author Dan Cox */ public function setUp() { $this->CT = new CommandTester(); $this->CT->add(new UtilityTask()); }
/** * Increase the number of vote-up of the document * @param int $document_srl * @param int $point * @return Object */ function updateVotedCount($document_srl, $point = 1) { if ($point > 0) { $failed_voted = 'failed_voted'; } else { $failed_voted = 'failed_blamed'; } // Return fail if session already has information about votes if ($_SESSION['voted_document'][$document_srl]) { return new Object(-1, $failed_voted); } // Get the original document $oDocumentModel = getModel('document'); $oDocument = $oDocumentModel->getDocument($document_srl, false, false); // Pass if the author's IP address is as same as visitor's. if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) { $_SESSION['voted_document'][$document_srl] = false; return new Object(-1, $failed_voted); } // Create a member model object $oMemberModel = getModel('member'); $member_srl = $oMemberModel->getLoggedMemberSrl(); // Check if document's author is a member. if ($oDocument->get('member_srl')) { // Pass after registering a session if author's information is same as the currently logged-in user's. if ($member_srl && $member_srl == abs($oDocument->get('member_srl'))) { $_SESSION['voted_document'][$document_srl] = false; return new Object(-1, $failed_voted); } } // Use member_srl for logged-in members and IP address for non-members. $args = new stdClass(); if ($member_srl) { $args->member_srl = $member_srl; } else { $args->ipaddress = $_SERVER['REMOTE_ADDR']; } $args->document_srl = $document_srl; $output = executeQuery('document.getDocumentVotedLogInfo', $args); // Pass after registering a session if log information has vote-up logs if ($output->data->count) { $_SESSION['voted_document'][$document_srl] = false; return new Object(-1, $failed_voted); } // begin transaction $oDB = DB::getInstance(); $oDB->begin(); // Update the voted count if ($point < 0) { $args->blamed_count = $oDocument->get('blamed_count') + $point; // Leave in the session information $_SESSION['voted_document'][$document_srl] = $point; $output = executeQuery('document.updateBlamedCount', $args); } else { $args->voted_count = $oDocument->get('voted_count') + $point; // Leave in the session information $_SESSION['voted_document'][$document_srl] = $point; $output = executeQuery('document.updateVotedCount', $args); } if (!$output->toBool()) { return $output; } // Leave logs $args->point = $point; $output = executeQuery('document.insertDocumentVotedLog', $args); if (!$output->toBool()) { return $output; } $obj = new stdClass(); $obj->member_srl = $oDocument->get('member_srl'); $obj->module_srl = $oDocument->get('module_srl'); $obj->document_srl = $oDocument->get('document_srl'); $obj->update_target = $point < 0 ? 'blamed_count' : 'voted_count'; $obj->point = $point; $obj->before_point = $point < 0 ? $oDocument->get('blamed_count') : $oDocument->get('voted_count'); $obj->after_point = $point < 0 ? $args->blamed_count : $args->voted_count; ModuleHandler::triggerCall('document.updateVotedCount', 'after', $obj); $oDB->commit(); //remove document item from cache Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($document_srl) . $document_srl); // Return result $output = new Object(); if ($point > 0) { $output->setMessage('success_voted'); $output->add('voted_count', $obj->after_point); } else { $output->setMessage('success_blamed'); $output->add('blamed_count', $obj->after_point); } return $output; }
/** * Increase vote-up counts of the comment * @param int $comment_srl * @param int $point * @return Object */ function updateVotedCount($comment_srl, $point = 1) { if ($point > 0) { $failed_voted = 'failed_voted'; $success_message = 'success_voted'; } else { $failed_voted = 'failed_blamed'; $success_message = 'success_blamed'; } // invalid vote if vote info exists in the session info. if ($_SESSION['voted_comment'][$comment_srl]) { return new Object(-1, $failed_voted); } $oCommentModel = getModel('comment'); $oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE); // invalid vote if both ip addresses between author's and the current user are same. if ($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR']) { $_SESSION['voted_comment'][$comment_srl] = TRUE; return new Object(-1, $failed_voted); } // if the comment author is a member if ($oComment->get('member_srl')) { // create the member model object $oMemberModel = getModel('member'); $member_srl = $oMemberModel->getLoggedMemberSrl(); // session registered if the author information matches to the current logged-in user's. if ($member_srl && $member_srl == $oComment->get('member_srl')) { $_SESSION['voted_comment'][$comment_srl] = TRUE; return new Object(-1, $failed_voted); } } $args = new stdClass(); // If logged-in, use the member_srl. otherwise use the ipaddress. if ($member_srl) { $args->member_srl = $member_srl; } else { $args->ipaddress = $_SERVER['REMOTE_ADDR']; } $args->comment_srl = $comment_srl; $output = executeQuery('comment.getCommentVotedLogInfo', $args); // session registered if log info contains recommendation vote log. if ($output->data->count) { $_SESSION['voted_comment'][$comment_srl] = TRUE; return new Object(-1, $failed_voted); } // begin transaction $oDB = DB::getInstance(); $oDB->begin(); // update the number of votes if ($point < 0) { $args->blamed_count = $oComment->get('blamed_count') + $point; $output = executeQuery('comment.updateBlamedCount', $args); } else { $args->voted_count = $oComment->get('voted_count') + $point; $output = executeQuery('comment.updateVotedCount', $args); } // leave logs $args->point = $point; $output = executeQuery('comment.insertCommentVotedLog', $args); $obj = new stdClass(); $obj->member_srl = $oComment->get('member_srl'); $obj->module_srl = $oComment->get('module_srl'); $obj->comment_srl = $oComment->get('comment_srl'); $obj->update_target = $point < 0 ? 'blamed_count' : 'voted_count'; $obj->point = $point; $obj->before_point = $point < 0 ? $oComment->get('blamed_count') : $oComment->get('voted_count'); $obj->after_point = $point < 0 ? $args->blamed_count : $args->voted_count; $trigger_output = ModuleHandler::triggerCall('comment.updateVotedCount', 'after', $obj); if (!$trigger_output->toBool()) { $oDB->rollback(); return $trigger_output; } $oDB->commit(); // leave into session information $_SESSION['voted_comment'][$comment_srl] = TRUE; // Return the result $output = new Object(0, $success_message); if ($point > 0) { $output->add('voted_count', $obj->after_point); } else { $output->add('blamed_count', $obj->after_point); } return $output; }
/** * Test a start to finish run through with a basic string mask * * @return void * @author Dan Cox */ public function test_runThroughBasicStringMask() { $this->masquerade->add('foo', 'bar'); $str = $this->masquerade->searchAndReplace('my first mask [foo]'); $this->assertEquals('my first mask bar', $str); }
/** * Content List * * @param Object $oModule * * @return void **/ function dispSavedDocumentList(&$oModule) { $document_list = $this->arrangeContentList(Context::get('document_list')); $oModule->add('document_list', $document_list); $oModule->add('page_navigation', Context::get('page_navigation')); }