function compareObjects(&$o1, &$o2) { echo 'o1 == o2 : ' . bool2str($o1 == $o2) . "\n"; echo 'o1 != o2 : ' . bool2str($o1 != $o2) . "\n"; echo 'o1 === o2 : ' . bool2str($o1 === $o2) . "\n"; echo 'o1 !== o2 : ' . bool2str($o1 !== $o2) . "\n"; }
/** * Generate new config depending on posted data * * @param array $data * @return string */ function wpcfg_generate_config($data) { global $wpdb; $config = $data['wpcfg']; foreach ($config as $k => $v) { if ($v == 'checked' || $v == 'on') { $config[$k] = true; } } $options = wpcfg_all_options(); $added_options = array(); $to_remove_options = array(); $output = ''; $output .= '<?php /** * The base configuration for WordPress * * The wp-config.php automatically created by "wp-config.php Editor" * made by Ehsaan * * This file contains the following configurations: * * * MySQL settings * * Secret keys * * Database table prefix * * Changed settings * * ABSPATH * * @link https://codex.wordpress.org/Editing_wp-config.php * @author Ehsaan <*****@*****.**> * * @package WordPress */ '; // First add required options $added_options = array('db_name', 'db_user', 'db_host', 'db_password', 'db_charset', 'db_collate', 'db_prefix', 'table_prefix', 'wp_debug'); // Don't add them later. $db_name = isset($config['db_name']) ? $config['db_name'] : DB_NAME; $db_user = isset($config['db_user']) ? $config['db_user'] : DB_USER; $db_host = isset($config['db_host']) ? $config['db_host'] : DB_HOST; $db_charset = isset($config['db_charset']) ? $config['db_charset'] : DB_CHARSET; $db_collate = isset($config['db_collate']) ? $config['db_collate'] : DB_COLLATE; $db_password = DB_PASSWORD; $table_prefix = isset($config['db_prefix']) ? $config['db_prefix'] : $wpdb->prefix; if ($_REQUEST['tab'] == 'general') { $wp_debug = isset($config['wp_debug']) && $config['wp_debug'] ? bool2str($config['wp_debug']) : 'false'; } else { $wp_debug = bool2str(WP_DEBUG); } $output .= "\n\n// ** MySQL settings - You can get this info from your web host ** //\n/** The name of the database for WordPress */\ndefine( 'DB_NAME', '{$db_name}' );\n\n/** MySQL database username */\ndefine( 'DB_USER', '{$db_user}' );\n\n/** MySQL database password */\ndefine( 'DB_PASSWORD', '{$db_password}' );\n\n/** MySQL hostname */\ndefine( 'DB_HOST', '{$db_host}' );\n\n/** Database Charset to use in creating database tables. */\ndefine( 'DB_CHARSET', '{$db_charset}' );\n\n/** The Database Collate type. Don't change this if in doubt. */\ndefine( 'DB_COLLATE', '{$db_collate}' );\n\n/**\n * WordPress Database Table prefix.\n *\n * You can have multiple installations in one database if you give each\n * a unique prefix. Only numbers, letters, and underscores please!\n */\n" . '$table_prefix = \'' . $table_prefix . "';\n\n/**\n * For developers: WordPress debugging mode.\n *\n * Change this to true to enable the display of notices during development.\n * It is strongly recommended that plugin and theme developers use WP_DEBUG\n * in their development environments.\n *\n * For information on other constants that can be used for debugging,\n * visit the Codex.\n *\n * @link https://codex.wordpress.org/Debugging_in_WordPress\n */\ndefine( 'WP_DEBUG', {$wp_debug} );\n"; $output .= "\n/**#@+\n * Authentication Unique Keys and Salts.\n *\n * Change these to different unique phrases!\n * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}\n * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.\n *\n * @since 2.6.0\n */\ndefine('AUTH_KEY', '" . AUTH_KEY . "');\ndefine('SECURE_AUTH_KEY', '" . SECURE_AUTH_KEY . "');\ndefine('LOGGED_IN_KEY', '" . LOGGED_IN_KEY . "');\ndefine('NONCE_KEY', '" . NONCE_KEY . "');\ndefine('AUTH_SALT', '" . AUTH_SALT . "');\ndefine('SECURE_AUTH_SALT', '" . SECURE_AUTH_SALT . "');\ndefine('LOGGED_IN_SALT', '" . LOGGED_IN_SALT . "');\ndefine('NONCE_SALT', '" . NONCE_SALT . "');\n\n/**#@-*/\r\n\n"; // Add WordPress network constants. if (defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE == true && defined('MULTISITE') && MULTISITE == true) { // We need to add them all. $output .= "\n/**\n * WordPress Network configuration constants.\n *\n * Don't edit them unless you know what are you doing!\n */\ndefine('MULTISITE', true);\ndefine('SUBDOMAIN_INSTALL', " . bool2str(SUBDOMAIN_INSTALL) . ");\ndefine('DOMAIN_CURRENT_SITE', '" . DOMAIN_CURRENT_SITE . "');\ndefine('PATH_CURRENT_SITE', '" . PATH_CURRENT_SITE . "');\ndefine('SITE_ID_CURRENT_SITE', " . SITE_ID_CURRENT_SITE . ");\ndefine('BLOG_ID_CURRENT_SITE', " . BLOG_ID_CURRENT_SITE . ");\n\r\n\n"; } // Add new options foreach ($config as $key => $value) { $option = $options[$key]; if (in_array($key, $added_options)) { continue; } // Added already if ($option['value'] == $value) { continue; } // We don't need it! if ($value == $option['default']) { $to_remove_options[] = $key; continue; // Neither we don't need it, so we remove it! } $value2 = ''; if ($option['type'] == 'integer') { $value2 = (int) $value; } if ($option['type'] == 'boolean') { $value2 = bool2str($value); } if ($option['type'] == 'string') { $value2 = "'" . $value . "'"; } if ($key == 'wp_limit_memory' || $key == 'wp_max_memory') { $value2 = "'" . $value . "M'"; } $output .= "\ndefine( '" . $option['const'] . "', {$value2} );"; $added_options[] = $key; } // Add previous options foreach ($options as $key => $value) { $option = $value; if (in_array($key, $added_options)) { continue; } // Added already if (in_array($key, $to_remove_options)) { continue; } // Should remove if ($option['input'] == 'hr' || $option['input'] == 'link') { continue; } if (!isset($option['value']) || !isset($option['default']) || !isset($option['const'])) { continue; } // Wrong if ($option['value'] == $option['default']) { continue; } // It's default $value2 = ''; if ($option['type'] == 'integer') { $value2 = (int) $option['value']; } if ($option['type'] == 'boolean') { $value2 = $option['value'] ? 'true' : 'false'; } if ($option['type'] == 'string') { $value2 = "'" . $option['value'] . "'"; } if ($key == 'wp_limit_memory' || $key == 'wp_max_memory') { $value2 = "'" . $option['value'] . "M'"; } $output .= "\ndefine( '" . $option['const'] . "', {$value2} );"; $added_options[] = $key; } $output .= "\r\n"; $output .= "\n/* That's all, stop editing! Happy blogging. */\n\n/** Absolute path to the WordPress directory. */\nif ( !defined('ABSPATH') )\n\tdefine('ABSPATH', dirname(__FILE__) . '/');\n\n/** Sets up WordPress vars and included files. */\nrequire_once(ABSPATH . 'wp-settings.php');\n"; return $output; }
<?php $br = php_sapi_name() == "cli" ? "" : "<br>"; if (!extension_loaded('objects3')) { dl('objects3.' . PHP_SHLIB_SUFFIX); } $obj = new Hello("leon", 32); //var_dump($obj); $obj->foo = "bar"; //var_dump($obj); echo "foo:" . $obj->foo . "\n"; echo "class name111:" . get_class($obj) . "\n"; //echo "obj: "; //$obj->greet(); //echo $obj."_abc"; //echo "obj count:" . count($obj)."\n"; $obj1 = clone $obj; // echo "obj1: "; // $obj1->greet(); //var_dump($obj1); $obj2 = new Hello("jacky", 30); echo "compare:" . bool2str($obj == $obj2) . "\n"; function bool2str($bool) { if ($bool === false) { return 'FALSE'; } else { return 'TRUE'; } }
/** * Returns single value cleaned for sql or if you pass an array a string with all values cleaned comma delimited * @param mixed $val * @return string */ public static function cleanValue($val) { if (!is_bool($val) && !is_null($val)) { if (!is_int($val)) { if (!is_array($val)) { $val = "'" . db::sqlEsc($val) . "'"; } else { $cat = "'"; foreach ($val as $v) { $cat .= self::cleanValue($v) . "',"; } $val = rtrim($cat, ','); } } } else { $val = bool2str($val); } return $val; }
private function _processListing($listing, $type, $arr) { $result = array(); $methodToIncludeItem = '_processItemInclusion_' . $type; foreach ($listing as $item) { $filename = $item['filename']; $itemType = $item['item_type']; $includeMe = true; //build up tooltip $qtip = ''; //default write permissions to false $canWrite = false; //default immutable to false $immutable = false; //first do permissions since they are applicable to both folders and docs $permissions = $item['permissions']; $perms = ''; //iterate through the permissions and convert to human-readable for ($j = 0; $j < strlen($permissions); $j++) { switch (strtoupper($permissions[$j])) { case 'W': $canWrite = true; $perms .= $this->xlate('write, '); break; case 'R': $perms .= $this->xlate('read, '); break; case 'A': $perms .= $this->xlate('add folder, '); break; // default: // $perms .= strtoupper($permissions{$j}); // break; } } //now chop off trailing ', ' if any if (strlen($perms) > 2) { $perms = substr($perms, 0, strlen($perms) - 2); } //folders if ($itemType == 'F') { $qtip .= $this->xlate('Folder name') . ": {$filename}<br>"; $class = 'folder'; //permissions $qtip .= $this->xlate('Permissions:') . " {$perms}<br>"; //comment $qtip .= $canWrite ? $this->xlate('You may add content to this folder') : $this->xlate('You may not add content to this folder'); } else { $qtip = ''; //get file extension so can determine mimetype $extpos = strrpos($filename, '.'); if ($extpos === false) { $class = 'file-unknown'; } else { $ext = substr($filename, $extpos); // Get Extension including the dot $class = 'file-' . substr($filename, $extpos + 1); // Get Extension without the dot } // Convert list to array $extensions = explode(',', $arr['extensions']); //don't include results which don't have the correct file extensions if (!in_array(strtolower($ext), $extensions)) { $includeMe = false; } else { //filename $qtip .= $this->xlate('Filename') . ": {$filename}<br>"; //size $qtip .= $this->xlate('File Size') . ": " . fsize_desc($item['filesize']) . "<br>"; //last modified $qtip .= $this->xlate('Modified') . ": {$item['modified_date']}<br>"; //owner $qtip .= $this->xlate('Owner') . ": {$item['created_by']}<br>"; //version $qtip .= $this->xlate('Version') . ": {$item['version']}<br>"; //immutability if (bool2str(strtolower($item['is_immutable'])) == 'true') { $canWrite = false; $immutable = true; } //status, i.e. checked out or not, or immutable if ($immutable) { $qtip .= $this->xlate('Status: Immutable') . '<br>'; } else { if (strtolower($item['checked_out_by']) != 'n/a' && $item['checked_out_by'] != '') { $qtip .= $this->xlate('Status: Checked out by') . " {$item['checked_out_by']}<br>"; } else { $qtip .= $this->xlate('Status: Available') . '<br>'; } } //permissions $qtip .= $this->xlate('Permissions:') . " {$perms}<br>"; //immutable if ($immutable) { $qtip .= $this->xlate('This document is not editable'); } else { if ($canWrite) { $qtip .= $this->xlate('You may edit this document'); } else { $qtip .= $this->xlate('This document is not editable'); } } } } //end of if for files if ($includeMe) { $result[] = $this->{$methodToIncludeItem}($item, $class, $qtip); } } return $result; }
/** * Retrieves the server policies for this server * * @param string $session_id * @return kt_client_policies_response */ function get_client_policies($session_id, $client = null) { $this->debug("get_client_policies('{$session_id}')"); $config = KTConfig::getSingleton(); $policies = array(array('name' => 'explorer_metadata_capture', 'value' => bool2str($config->get('clientToolPolicies/explorerMetadataCapture')), 'type' => 'boolean'), array('name' => 'office_metadata_capture', 'value' => bool2str($config->get('clientToolPolicies/officeMetadataCapture')), 'type' => 'boolean'), array('name' => 'capture_reasons_delete', 'value' => bool2str($config->get('clientToolPolicies/captureReasonsDelete')), 'type' => 'boolean'), array('name' => 'capture_reasons_checkin', 'value' => bool2str($config->get('clientToolPolicies/captureReasonsCheckin')), 'type' => 'boolean'), array('name' => 'capture_reasons_checkout', 'value' => bool2str($config->get('clientToolPolicies/captureReasonsCheckout')), 'type' => 'boolean'), array('name' => 'capture_reasons_cancelcheckout', 'value' => bool2str($config->get('clientToolPolicies/captureReasonsCancelCheckout')), 'type' => 'boolean'), array('name' => 'capture_reasons_copyinkt', 'value' => bool2str($config->get('clientToolPolicies/captureReasonsCopyInKT')), 'type' => 'boolean'), array('name' => 'capture_reasons_moveinkt', 'value' => bool2str($config->get('clientToolPolicies/captureReasonsMoveInKT')), 'type' => 'boolean'), array('name' => 'allow_remember_password', 'value' => bool2str($config->get('clientToolPolicies/allowRememberPassword')), 'type' => 'boolean')); $response['policies'] = $this->_encode_client_policies($policies); $response['message'] = 'Knowledgetree client policies retrieval succeeded.'; $response['status_code'] = KTWS_SUCCESS; return new SOAP_Value('return', "{urn:{$this->namespace}}kt_client_policies_response", $response); }
/** * Retrieves the server policies for this server * * @author KnowledgeTree Team * @access public * @return array $response The formatted response array */ public function get_client_policies($client = null) { $config = KTConfig::getSingleton(); $policies = array(array('name' => 'explorer_metadata_capture', 'value' => bool2str($config->get('clientToolPolicies/explorerMetadataCapture')), 'type' => 'boolean'), array('name' => 'office_metadata_capture', 'value' => bool2str($config->get('clientToolPolicies/officeMetadataCapture')), 'type' => 'boolean'), array('name' => 'capture_reasons_delete', 'value' => bool2str($config->get('clientToolPolicies/captureReasonsDelete')), 'type' => 'boolean'), array('name' => 'capture_reasons_checkin', 'value' => bool2str($config->get('clientToolPolicies/captureReasonsCheckin')), 'type' => 'boolean'), array('name' => 'capture_reasons_checkout', 'value' => bool2str($config->get('clientToolPolicies/captureReasonsCheckout')), 'type' => 'boolean'), array('name' => 'capture_reasons_cancelcheckout', 'value' => bool2str($config->get('clientToolPolicies/captureReasonsCancelCheckout')), 'type' => 'boolean'), array('name' => 'capture_reasons_copyinkt', 'value' => bool2str($config->get('clientToolPolicies/captureReasonsCopyInKT')), 'type' => 'boolean'), array('name' => 'capture_reasons_moveinkt', 'value' => bool2str($config->get('clientToolPolicies/captureReasonsMoveInKT')), 'type' => 'boolean'), array('name' => 'allow_remember_password', 'value' => bool2str($config->get('clientToolPolicies/allowRememberPassword')), 'type' => 'boolean')); $response['policies'] = $policies; $response['message'] = _kt('Knowledgetree client policies retrieval succeeded.'); $response['status_code'] = 0; return $response; }