/** * Initialize instance * * @param Charcoal_Config $config configuration data */ public function configure($config) { parent::configure($config); $this->debug_mode = ub($config->getBoolean('debug_mode', FALSE)); $this->smarty->caching = 0; //$config->getBoolean( 'caching' )->unbox(); $this->smarty->compile_check = ub($config->getBoolean('compile_check', FALSE)); $this->smarty->template_dir = us($config->getString('template_dir', '', TRUE)); $this->smarty->compile_dir = us($config->getString('compile_dir', '', TRUE)); $this->smarty->config_dir = us($config->getString('config_dir', '', TRUE)); $this->smarty->cache_dir = us($config->getString('cache_dir', '', TRUE)); $this->smarty->left_delimiter = us($config->getString('left_delimiter', '{', FALSE)); $this->smarty->right_delimiter = us($config->getString('right_delimiter', '}', FALSE)); // $this->smarty->default_modifiers = $config->getArray( 'default_modifiers', array() )->unbox(); $plugins_dir = uv($config->getArray('plugins_dir', array(), TRUE)); // add default plugins_dir: Smarty/Smarty/plugins $reflector = new ReflectionClass($this->smarty); $plugins_dir[] = dirname($reflector->getFileName()) . '/plugins'; $this->smarty->plugins_dir = $plugins_dir; log_debug("smarty", "smarty->plugins_dir=" . print_r($this->smarty->plugins_dir, true), self::TAG); log_debug("smarty", "smarty=" . spl_object_hash($this->smarty), self::TAG); if ($this->debug_mode) { $smarty_options = array('caching' => $this->smarty->caching, 'compile_check' => $this->smarty->compile_check, 'template_dir' => $this->smarty->template_dir, 'compile_dir' => $this->smarty->compile_dir, 'config_dir' => $this->smarty->config_dir, 'cache_dir' => $this->smarty->cache_dir, 'default_modifiers' => $this->smarty->default_modifiers, 'plugins_dir' => $this->smarty->plugins_dir, 'left_delimiter' => $this->smarty->left_delimiter, 'right_delimiter' => $this->smarty->right_delimiter); ad($smarty_options); foreach ($smarty_options as $key => $value) { log_debug('system, debug, smarty', "smarty option: [{$key}]=" . Charcoal_System::toString($value)); } } }
/** * load config * * @param string|Charcoal_String $key config key * * @return mixed configure data */ public function loadConfig($key) { // Charcoal_ParamTrait::validateString( 1, $key ); $source = $key . '.ini'; $is_debug = b($this->debug)->isTrue(); $result = NULL; if (!is_file($source)) { if ($is_debug) { print "ini file[{$source}] does not exist." . eol(); log_warning("system, debug, config", "config", "ini file[{$source}] does not exist."); } } else { // read ini file $result = @parse_ini_file($source, TRUE); if ($is_debug) { print "[{$source}] parse_ini_file({$source})=" . eol(); ad($result); if ($result === FALSE) { print "parse_ini_file failed: [{$source}]" . eol(); log_warning("system, debug, config", "config", "parse_ini_file failed: [{$source}]"); } else { log_debug("system, debug, config", "config", "read ini file[{$source}]:" . print_r($result, true)); } } } return $result; }
/** * execute tests */ public function test($action, $context) { $action = us($action); $simple_router = $context->createObject('simple_router', 'router', 'Charcoal_IRouter'); $routing_rule = $context->createObject('array', 'routing_rule', 'Charcoal_IRoutingRule'); $config = new Charcoal_Config($context->getEnvironment(), array('routing rules' => array('/path/to/check/' => '@:path:to:check', '/path/to/check/:param' => '@:path:to:check'))); $routing_rule->configure($config); $proc_key = $context->getProfile()->getString('PROC_KEY', 'proc'); switch ($action) { case "no_param": $request = $context->getRequest(); $_SERVER["REQUEST_URI"] = '/path/to/check/'; $_SERVER["SCRIPT_NAME"] = ''; $result = $simple_router->route($request, $routing_rule); $proc = $request->get($proc_key); $this->assertEquals("@:path:to:check", $proc); break; case "one_param": $request = $context->getRequest(); $_SERVER["REQUEST_URI"] = '/path/to/check/1'; $_SERVER["SCRIPT_NAME"] = ''; $result = $simple_router->route($request, $routing_rule); $proc = $request->get($proc_key); ad($result); $this->assertEquals("@:path:to:check", $proc); break; } }
public function load($debug_mode, $profile_name) { $config_file = "{$profile_name}.profile.ini"; try { // get profile directory path $profile_dir = Charcoal_ResourceLocator::getApplicationFile('config/profile'); // make config file object $config_file = new Charcoal_File($config_file, $profile_dir); // check if profile directory exists if (!$profile_dir->exists()) { if ($debug_mode) { echo "profile directory not exists: [{$profile_dir}]" . eol(); } log_error("debug,config,profile", "profile directory not exists: [{$profile_dir}]"); _throw(new Charcoal_ProfileDirectoryNotFoundException($profile_dir)); } // throw exception when config file is not found if (!$config_file->isFile() || !$config_file->canRead()) { if ($debug_mode) { echo "profile config file not exists or not readable: [{$config_file}]" . eol(); } log_error("debug,config,profile", "profile config file not exists or not readable: [{$config_file}]"); _throw(new Charcoal_ProfileConfigFileNotFoundException($config_file)); } // parse config file // log_debug( "debug,config,profile", "profile", "parsing config file: [$config_file]" ); $config_file = $config_file->getAbsolutePath(); if ($debug_mode) { echo "executing parse_ini_file: [{$config_file}]" . eol(); } $config = @parse_ini_file($config_file, FALSE); if ($config === FALSE) { if ($debug_mode) { echo "profile config file format error: [{$config_file}]" . eol(); } log_error("debug,config,profile", "profile config file format error: [{$config_file}]"); _throw(new Charcoal_ProfileConfigFileFormatException($config_file)); } if ($debug_mode) { echo "executed parse_ini_file: " . ad($config) . eol(); } // log_debug( "profile", "profile", "parse_ini_file: " . print_r($config,TRUE) ); // 設定を保存 parent::mergeArray($config); // log_debug( "debug,config,profile", "profile", "marged profile:" . print_r($config,TRUE) ); } catch (Exception $ex) { // log_debug( "system,error,debug", "catch $e" ); _catch($ex); _throw(new Charcoal_ProfileLoadingException($config_file, $profile_name, $ex)); } }
/** * execute tests */ public function test($action, $context) { $request = $context->getRequest(); $action = us($action); // SimplePie $simplepie = $context->getComponent('simplepie@:rss:simplepie'); $config = new Charcoal_Config($this->getSandbox()->getEnvironment()); $config->set('enable_cahche', true); $config->set('cache_dir', CHARCOAL_CACHE_DIR . '/simplepie'); $config->set('duration', 1800); $simplepie->configure($config); switch ($action) { // Send mail case "get_feed": //$feed = $simplepie->getFeed( 'http://charcoalphp.org/test/rss/index.xml' ); $feed = $simplepie->getFeed('http://1000mg.jp/feed'); ad($feed); return TRUE; } return FALSE; }
/** * テスト * * @param string $action * @param Charcoal_IEventContext $context * * @return boolean */ public function test($action, $context) { $action = us($action); /** @var Charcoal_SmartGateway $gw */ $gw = $context->getComponent('smart_gateway@:charcoal:db'); $gw->reset(); switch ($action) { case "commit": // トランザクション開始 $gw->beginTrans(); $gw->autoCommit(FALSE); // 初期データの確認 $result = $gw->query(NULL, "SELECT * FROM posts WHERE post_id=1"); $this->assertEquals('stk2k', $result[0]['post_user'], true); // 更新 $gw->execute(NULL, "UPDATE posts set post_user = '******' where post_id = 1"); // コミット $gw->commitTrans(); // 検索 $result = $gw->query(NULL, "SELECT * FROM posts WHERE post_id=1"); $this->assertEquals('hoge', $result[0]['post_user']); return TRUE; case "query": $sql = "SELECT * FROM blogs WHERE blog_id = 1"; $result = $gw->query("query #1", $sql); $blog_name = ''; foreach ($result as $row) { $blog_name = $row['blog_name']; echo "blog_name:{$blog_name}" . eol(); } $this->assertEquals(1, count($result)); $this->assertEquals("my blog", $blog_name); return TRUE; case "select": $where = "blog_id = ?"; $criteria = new Charcoal_SQLCriteria($where, array(1)); $result = $gw->findAll("select #1", 'blogs', $criteria); $blog_name = ''; foreach ($result as $row) { $blog_name = $row['blog_name']; echo "blog_name:{$blog_name}" . eol(); } $this->assertEquals(1, count($result)); $this->assertEquals("my blog", $blog_name); return TRUE; case "select_alias": $where = "b.blog_id = ?"; $criteria = new Charcoal_SQLCriteria($where, array(1)); $result = $gw->findAll("select_alias #1", 'blogs as b', $criteria); $blog_name = ''; foreach ($result as $row) { $blog_name = $row['blog_name']; echo "blog_name:{$blog_name}" . eol(); } $this->assertEquals(1, count($result)); $this->assertEquals("my blog", $blog_name); return TRUE; case "select_alias_forupdate": $where = "blog_name like ?"; $criteria = new Charcoal_SQLCriteria($where, array("My First Blog")); $result = $gw->findAllForUpdate("select_alias_forupdate #1", 'blogs as b', $criteria); foreach ($result as $row) { print print_r($row, true) . PHP_EOL; } return TRUE; case "inner_join": $where = "blogs.blog_id = ?"; $criteria = new Charcoal_SQLCriteria($where, array(1)); $result = $gw->findAll("inner_join #1", 'blogs + posts on "blogs.blog_id = posts.blog_id" + comments on "posts.post_id = comments.post_id"', $criteria); $blog_name = ''; foreach ($result as $row) { $blog_name = $row['blog_name']; echo "blog_name:{$blog_name}" . eol(); } $this->assertEquals(3, count($result)); $this->assertEquals("my blog", $blog_name); return TRUE; case "left_join": $where = "blogs.blog_id = ?"; $criteria = new Charcoal_SQLCriteria($where, array(1)); $result = $gw->findAll("left_join #1", 'blogs (+ posts on "blogs.blog_id = posts.blog_id"', $criteria); $blog_name = ''; foreach ($result as $row) { $blog_name = $row['blog_name']; echo "blog_name:{$blog_name}" . eol(); } $this->assertEquals(2, count($result)); $this->assertEquals("my blog", $blog_name); return TRUE; case "right_join": $where = "blogs.blog_id = ?"; $criteria = new Charcoal_SQLCriteria($where, array(1)); $result = $gw->findAll("right_join #1", 'blogs +) posts on "blogs.blog_id = posts.blog_id"', $criteria); $blog_name = ''; foreach ($result as $row) { $blog_name = $row['blog_name']; echo "blog_name:{$blog_name}" . eol(); } // 評価 $this->assertEquals(2, count($result)); $this->assertEquals("my blog", $blog_name); return TRUE; case "inner_join_alias": $where = "b.blog_id = ?"; $criteria = new Charcoal_SQLCriteria($where, array(1)); $result = $gw->findAll("inner_join_alias #1", 'blogs as b + posts as p on "b.blog_id = p.blog_id"', $criteria); $blog_name = ''; foreach ($result as $row) { $blog_name = $row['blog_name']; echo "blog_name:{$blog_name}" . eol(); } $this->assertEquals(2, count($result)); $this->assertEquals("my blog", $blog_name); return TRUE; case "inner_join_multi": $where = "blogs.blog_id = ?"; $criteria = new Charcoal_SQLCriteria($where, array(1)); $result = $gw->findAll("inner_join_multi #1", 'blogs + posts on "blogs.blog_id = posts.blog_id" + comments on "posts.post_id = comments.post_id"', $criteria); $blog_name = ''; foreach ($result as $row) { $blog_name = $row['blog_name']; echo "blog_name:{$blog_name}" . eol(); } $this->assertEquals(3, count($result)); $this->assertEquals("my blog", $blog_name); return TRUE; case "inner_join_multi_alias": $where = "b.blog_id = ?"; $criteria = new Charcoal_SQLCriteria($where, array(1)); $result = $gw->findAll("inner_join_multi_alias #1", 'blogs as b + posts as p on "b.blog_id = p.blog_id" + comments as c on "p.post_id = c.post_id"', $criteria); $blog_name = ''; foreach ($result as $row) { $blog_name = $row['blog_name']; echo "blog_name:{$blog_name}" . eol(); } $this->assertEquals(3, count($result)); $this->assertEquals("my blog", $blog_name); return TRUE; case "count": $criteria = new Charcoal_SQLCriteria(); $result = $gw->count("count #1", 'posts', $criteria, '*'); echo "result:" . $result . eol(); // 評価 $this->assertEquals(3, $result); return TRUE; case "max": $criteria = new Charcoal_SQLCriteria(); $result = $gw->max("max #1", 'posts', $criteria, 'favorite'); echo "result:" . $result . eol(); $this->assertEquals(11, $result); return TRUE; case "min": $criteria = new Charcoal_SQLCriteria(); $result = $gw->min("min #1", 'posts', $criteria, 'favorite'); echo "result:" . $result . eol(); // 評価 $this->assertEquals(5, $result); return TRUE; case "avg": $criteria = new Charcoal_SQLCriteria(); $result = $gw->avg("avg #1", 'posts', $criteria, 'favorite'); echo "result:" . $result . eol(); $this->assertEquals(8, $result); return TRUE; case "count_alias": $criteria = new Charcoal_SQLCriteria(); $result = $gw->count("count_alias #1", 'posts as p', $criteria, '*'); echo "result:" . $result . eol(); $this->assertEquals(3, $result); return TRUE; case "max_alias": $criteria = new Charcoal_SQLCriteria(); $result = $gw->max("max_alias #1", 'posts as p + comments as c on "p.post_id = c.post_id"', $criteria, 'favorite'); echo "result:" . $result . eol(); $this->assertEquals(11, $result); return TRUE; case "find_first": $criteria = new Charcoal_SQLCriteria(); $criteria->setOrderBy('favorite'); $result = $gw->findFirst("find_first #1", 'posts', $criteria); echo "result:" . $result['post_title'] . eol(); $this->assertEquals('How does it work?', $result['post_title']); return TRUE; case "find_by_id": $result = $gw->findAll("find_by_id #1", 'posts', new Charcoal_SQLCriteria()); foreach ($result as $row) { $blog_id = $row['blog_id']; $blog = $gw->findById("find_by_id #2", 'blogs', $blog_id); $this->assertEquals($this->blog_name_expected[$blog_id], $blog['blog_name']); $blog_category_id = $blog['blog_category_id']; $category = $gw->findById("find_by_id #3", 'blog_category', $blog_category_id); $this->assertEquals($this->category_name_expected[$blog_category_id], $category['blog_category_name']); } return TRUE; case "save": // save by INSERT $dto = new PostTableDTO(); $dto->post_title = 'New Post'; $dto->post_body = 'New Post Body'; $dto->post_user = '******'; $count = $gw->count(NULL, 'posts', new Charcoal_SQLCriteria(), NULL); //echo $gw->popSQLHistory() . PHP_EOL; //echo "count(before save):" . $count . eol(); $this->assertEquals(3, $count); $new_id = $gw->save(NULL, "posts", $dto); //echo $gw->popSQLHistory() . PHP_EOL; $criteria = new Charcoal_SQLCriteria(); $criteria->setWhere("post_id = ?"); $criteria->setParams(array($new_id)); $new_record = $gw->findFirst(NULL, 'posts', $criteria); //echo $gw->popSQLHistory() . PHP_EOL; $count = $gw->count(NULL, 'posts', new Charcoal_SQLCriteria()); //echo $gw->popSQLHistory() . PHP_EOL; //echo "count(after save):" . $count . eol(); $this->assertEquals(4, $count); $this->assertEquals(4, $new_record['post_id']); $this->assertEquals('New Post', $new_record['post_title']); $this->assertEquals('New Post Body', $new_record['post_body']); $this->assertEquals('Ichiro', $new_record['post_user']); // save by UPDATE $dto->post_id = $new_id; $dto->post_date = array('function', 'now'); $dto->post_user = array('value', 'null'); $dto->post_body = array(1, 2, "apple", array('name' => 'stk2k'), array('sex' => 'male')); $time_before_update = time(); sleep(1); $gw->save(NULL, "posts", $dto); sleep(1); $time_after_update = time(); $criteria = new Charcoal_SQLCriteria(); $criteria->setWhere("post_id = ?"); $criteria->setParams(array($dto->post_id)); $the_record = $gw->findFirst(NULL, 'posts', $criteria); // check post date $this->assertGreaterThan($time_before_update, strtotime($the_record['post_date'])); $this->assertLessThan($time_after_update, strtotime($the_record['post_date'])); // check post user $this->assertEquals(NULL, $the_record['post_user']); // check post body(JSON) $post_body = json_decode($the_record['post_body'], true); $expeced = array(1, 2, "apple", array('name' => 'stk2k'), array('sex' => 'male')); $this->assertEquals($expeced, $post_body); return TRUE; case "fluent_api": $gw->select("b.blog_name, b.post_total, p.post_user, p.post_title")->from(s("blogs"), s("b"))->leftJoin(s("posts"), s("p"))->on("b.blog_id = p.blog_id")->where()->gt(s("b.post_total"), i(1))->orderBy(s("b.post_total DESC"))->limit(i(5))->offset(i(0))->prepareExecute()->findFirst("fluent_api #1")->result(); echo $gw->popSQLHistory() . PHP_EOL; // echo print_r($rs,true) . eol(); // echo "last SQL:" . $gw->getLastSQL() . eol(); // echo "last params:" . $gw->getLastParams() . eol(); return TRUE; case "recordset_query": $rsfactory1 = $gw->createRecordsetFactory(); // fetch mode: FETCHMODE_BOTH $sql = "SELECT * FROM blogs WHERE blog_id = 1"; $result = $gw->query("recordset_query #1", $sql, NULL, $rsfactory1, NULL); echo $gw->popSQLHistory() . PHP_EOL; foreach ($result as $row) { $this->assertEquals($this->blog_name_expected[$row['blog_id']], $row['blog_name']); } $rsfactory2 = $gw->createRecordsetFactory(Charcoal_IRecordset::FETCHMODE_ASSOC); $sql = "SELECT * FROM blogs WHERE blog_id = 1"; $result = $gw->query("recordset_query #2", $sql, NULL, $rsfactory2, NULL); echo $gw->popSQLHistory() . PHP_EOL; foreach ($result as $row) { $this->assertEquals($this->blog_name_expected[$row['blog_id']], $row['blog_name']); } $rsfactory3 = $gw->createRecordsetFactory(Charcoal_IRecordset::FETCHMODE_NUM); $sql = "SELECT blog_id, blog_name, post_total FROM blogs WHERE blog_id = 1"; $result = $gw->query("recordset_query #3", $sql, NULL, $rsfactory3, NULL); echo $gw->popSQLHistory() . PHP_EOL; foreach ($result as $row) { $this->assertEquals($this->blog_name_expected[$row[0]], $row[1]); } return TRUE; case "recordset_find": $rsfactory1 = $gw->createRecordsetFactory(); // fetch mode: FETCHMODE_ASSOC $sql = "SELECT * FROM blogs WHERE blog_id = 1"; $result = $gw->query("recordset_find #1", $sql, NULL, $rsfactory1, NULL); echo $gw->popSQLHistory() . PHP_EOL; foreach ($result as $row) { $this->assertEquals($this->blog_name_expected[$row['blog_id']], $row['blog_name']); } $rsfactory2 = $gw->createRecordsetFactory(Charcoal_IRecordset::FETCHMODE_ASSOC); $sql = "SELECT * FROM blogs WHERE blog_id = 1"; $result = $gw->query("recordset_find #2", $sql, NULL, $rsfactory2, NULL); echo $gw->popSQLHistory() . PHP_EOL; foreach ($result as $row) { $this->assertEquals($this->blog_name_expected[$row['blog_id']], $row['blog_name']); } $rsfactory3 = $gw->createRecordsetFactory(Charcoal_IRecordset::FETCHMODE_NUM); $sql = "SELECT blog_id, blog_name, post_total FROM blogs WHERE blog_id = 1"; $result = $gw->query("recordset_find #3", $sql, NULL, $rsfactory3, NULL); echo $gw->popSQLHistory() . PHP_EOL; foreach ($result as $row) { $this->assertEquals($this->blog_name_expected[$row[0]], $row[1]); } return TRUE; case "nested_recordset_query": $rsfactory1 = $gw->createRecordsetFactory(); // fetch mode: FETCHMODE_BOTH $sql = "SELECT * FROM blogs WHERE blog_id = 1"; $result = $gw->query(NULL, $sql, NULL, $rsfactory1); foreach ($result as $row) { $this->assertEquals(1, $row['blog_id']); $this->assertEquals($this->blog_name_expected[1], $row['blog_name']); $blog_category_id = $row['blog_category_id']; $sql = "SELECT * FROM blog_category WHERE blog_category_id = ?"; $result2 = $gw->query(NULL, $sql, array($blog_category_id), $rsfactory1); foreach ($result2 as $row2) { $this->assertEquals($blog_category_id, $row2['blog_category_id']); $this->assertEquals($this->category_name_expected[$blog_category_id], $row2['blog_category_name']); } } /* $rsfactory2 = $gw->createRecordsetFactory( Charcoal_IRecordset::FETCHMODE_ASSOC ); $sql = "SELECT * FROM blogs WHERE blog_id = 1"; $result = $gw->query( $sql, NULL, $rsfactory2 ); foreach( $result as $row ){ $this->assertEquals( 1, $row['blog_id'] ); $this->assertEquals( $this->blog_name_expected[1], $row['blog_name'] ); $blog_category_id = $row['blog_category_id']; $sql = "SELECT * FROM blog_category WHERE blog_category_id = ?"; $result2 = $gw->query( $sql, array($blog_category_id), $rsfactory2 ); foreach( $result2 as $row ){ $this->assertEquals( $blog_category_id, $row['blog_category_id'] ); $this->assertEquals( $this->category_name_expected[$blog_category_id], $row['blog_category_name'] ); } } $rsfactory3 = $gw->createRecordsetFactory( Charcoal_IRecordset::FETCHMODE_NUM ); $sql = "SELECT blog_id, blog_name, post_total, blog_category_id FROM blogs WHERE blog_id = 1"; $result = $gw->query( $sql, NULL, $rsfactory3 ); foreach( $result as $row ){ $this->assertEquals( 1, $row[0] ); $this->assertEquals( $this->blog_name_expected[1], $row[1] ); $blog_category_id = $row[3]; $sql = "SELECT blog_category_id, blog_category_name FROM blog_category WHERE blog_category_id = ?"; $result2 = $gw->query( $sql, array($blog_category_id), $rsfactory3 ); foreach( $result2 as $row ){ $this->assertEquals( $blog_category_id, $row[0] ); $this->assertEquals( $this->category_name_expected[$blog_category_id], $row[1] ); } } */ $another_ds = $context->createObject('PDO', 'data_source'); $default_ds_config = $gw->getDataSource()->getConfig(); //ad($default_ds_config); $config = $context->createConfig($default_ds_config->getAll()); $GLOBALS['hoge'] = true; ad($config); $config->set('token_key', 'foo'); $another_ds->configure($config); return TRUE; case "nested_recordset_find": return TRUE; case "delete_by_id": $gw->deleteById("delete_by_id #1", 'blog_category', 1); echo $gw->popSQLHistory() . PHP_EOL; $criteria = new Charcoal_SQLCriteria(''); $cnt = $gw->count("delete_by_id #2", 'blog_category', $criteria); echo 'cnt:' . $cnt . PHP_EOL; echo $gw->popSQLHistory() . PHP_EOL; return TRUE; case "delete_by_ids": $gw->deleteByIds("delete_by_ids #1", 'blog_category', array(1, 3)); echo $gw->popSQLHistory() . PHP_EOL; $criteria = new Charcoal_SQLCriteria(''); $cnt = $gw->count("delete_by_ids #2", 'blog_category', $criteria); echo 'cnt:' . $cnt . PHP_EOL; echo $gw->popSQLHistory() . PHP_EOL; return TRUE; /* ------------------------------ increment/decrement test */ /* ------------------------------ increment/decrement test */ case "increment_field": // increment post_toal by 1 $gw->incrementField("increment_field #1", 'blogs', 1, 'post_total'); //echo $gw->popSQLHistory() . PHP_EOL; // post_total must be 2 => 3 $pdo = new DuplicatedPdo($gw); $post_total = $pdo->queryValue("SELECT post_total FROM blogs WHERE blog_id = ?", [1]); //var_dump($post_total); $this->assertEquals(3, $post_total); // increment post_toal by 2 $gw->incrementField("increment_field #1", 'blogs', 1, 'post_total', 2); //echo $gw->popSQLHistory() . PHP_EOL; // post_total must be 3 => 5 $pdo = new DuplicatedPdo($gw); $post_total = $pdo->queryValue("SELECT post_total FROM blogs WHERE blog_id = ?", [1]); //var_dump($post_total); $this->assertEquals(5, $post_total); // increment post_toal by -5 $gw->incrementField("increment_field #1", 'blogs', 1, 'post_total', -5); //echo $gw->popSQLHistory() . PHP_EOL; // post_total must be 5 => 0 $pdo = new DuplicatedPdo($gw); $post_total = $pdo->queryValue("SELECT post_total FROM blogs WHERE blog_id = ?", [1]); //var_dump($post_total); $this->assertEquals(0, $post_total); return TRUE; case "increment_field_by": // increment post_toal by 1 $gw->incrementFieldBy("increment_field_by #1", 'blogs', 'post_total', 'blog_name', 'my blog'); //echo $gw->popSQLHistory() . PHP_EOL; // post_total must be 2 => 3 $pdo = new DuplicatedPdo($gw); $post_total = $pdo->queryValue("SELECT post_total FROM blogs WHERE blog_id = ?", [1]); //var_dump($post_total); $this->assertEquals(3, $post_total); // increment post_toal by 2 $gw->incrementFieldBy("increment_field_by #2", 'blogs', 'post_total', 'blog_name', 'my blog', 2); //echo $gw->popSQLHistory() . PHP_EOL; // post_total must be 3 => 5 $pdo = new DuplicatedPdo($gw); $post_total = $pdo->queryValue("SELECT post_total FROM blogs WHERE blog_id = ?", [1]); //var_dump($post_total); $this->assertEquals(5, $post_total); // increment post_toal by -5 $gw->incrementFieldBy("increment_field_by #3", 'blogs', 'post_total', 'blog_name', 'my blog', -5); //echo $gw->popSQLHistory() . PHP_EOL; // post_total must be 5 => 0 $pdo = new DuplicatedPdo($gw); $post_total = $pdo->queryValue("SELECT post_total FROM blogs WHERE blog_id = ?", [1]); //var_dump($post_total); $this->assertEquals(0, $post_total); return TRUE; case "decrement_field": // decrement post_toal by 1 $gw->decrementField("decrement_field #1", 'blogs', 1, 'post_total'); //echo $gw->popSQLHistory() . PHP_EOL; // post_total must be 2 => 1 $pdo = new DuplicatedPdo($gw); $post_total = $pdo->queryValue("SELECT post_total FROM blogs WHERE blog_id = ?", [1]); //var_dump($post_total); $this->assertEquals(1, $post_total); // decrement post_toal by 2 $gw->decrementField("decrement_field #2", 'blogs', 1, 'post_total', 2); //echo $gw->popSQLHistory() . PHP_EOL; // post_total must be 1 => -1 $pdo = new DuplicatedPdo($gw); $post_total = $pdo->queryValue("SELECT post_total FROM blogs WHERE blog_id = ?", [1]); var_dump($post_total); $this->assertEquals(-1, $post_total); // decrement post_toal by -5 $gw->decrementField("decrement_field #3", 'blogs', 1, 'post_total', -5); //echo $gw->popSQLHistory() . PHP_EOL; // post_total must be -1 => 4 $pdo = new DuplicatedPdo($gw); $post_total = $pdo->queryValue("SELECT post_total FROM blogs WHERE blog_id = ?", [1]); //var_dump($post_total); $this->assertEquals(4, $post_total); return TRUE; case "decrement_field_by": // decrement post_toal by 1 $gw->decrementFieldBy("decrement_field_by #1", 'blogs', 'post_total', 'blog_name', 'my blog'); //echo $gw->popSQLHistory() . PHP_EOL; // post_total must be 2 => 1 $pdo = new DuplicatedPdo($gw); $post_total = $pdo->queryValue("SELECT post_total FROM blogs WHERE blog_id = ?", [1]); //var_dump($post_total); $this->assertEquals(1, $post_total); // decrement post_toal by 2 $gw->decrementFieldBy("decrement_field_by #2", 'blogs', 'post_total', 'blog_name', 'my blog', 2); //echo $gw->popSQLHistory() . PHP_EOL; // post_total must be 1 => -1 $pdo = new DuplicatedPdo($gw); $post_total = $pdo->queryValue("SELECT post_total FROM blogs WHERE blog_id = ?", [1]); //ar_dump($post_total); $this->assertEquals(-1, $post_total); // decrement post_toal by -5 $gw->decrementFieldBy("decrement_field_by #3", 'blogs', 'post_total', 'blog_name', 'my blog', -5); //echo $gw->popSQLHistory() . PHP_EOL; // post_total must be -1 => 4 $pdo = new DuplicatedPdo($gw); $post_total = $pdo->queryValue("SELECT post_total FROM blogs WHERE blog_id = ?", [1]); //var_dump($post_total); $this->assertEquals(4, $post_total); return TRUE; /* ------------------------------ insert test */ /* ------------------------------ insert test */ case "insert": // INSERT $blog = new BlogTableDTO(); $blog->blog_name = 'my new blog'; $blog->post_total = 123; $blog->created_date = array('function', 'now'); $blog->modified_date = array('function', 'now'); $time_insert_before = time(); sleep(1); $gw->insert(NULL, 'blogs', $blog); sleep(1); $time_insert_after = time(); $blog_id = $gw->getLastInsertId(); $this->assertEquals(3, $blog_id); // INSERTの確認 $where = "blog_id = ?"; $criteria = new Charcoal_SQLCriteria($where, array($blog_id)); $blog = $gw->findFirst("insert #1", 'blogs', $criteria); $this->assertEquals(3, $blog['blog_id']); $this->assertEquals('my new blog', $blog['blog_name']); $this->assertEquals(123, $blog['post_total']); $this->assertGreaterThan($time_insert_before, strtotime($blog['created_date'])); $this->assertLessThan($time_insert_after, strtotime($blog['created_date'])); return TRUE; case "bulk_insert": // BULK INSERT $blogs = array(); $blog = new BlogTableDTO(); $blog->blog_name = 'my new blog'; $blog->post_total = 123; $blog->created_date = array('function', 'now'); $blog->modified_date = array('function', 'now'); $blogs[] = $blog; $blog = new BlogTableDTO(); $blog->blog_name = 'my new blog2'; $blog->post_total = 44; $blog->created_date = array('function', 'now'); $blog->modified_date = array('function', 'now'); $blogs[] = $blog; $time_insert_before = time(); sleep(1); $inserted_rows = $gw->insertAll(NULL, 'blogs', $blogs); $this->assertEquals(2, $inserted_rows); sleep(1); $time_insert_after = time(); // INSERTの確認 $where = "blog_name like 'my new blog%'"; $criteria = new Charcoal_SQLCriteria($where, NULL, 'blog_id'); $result = $gw->findAll(NULL, 'blogs', $criteria); $blog = array_shift($result); $this->assertEquals(3, $blog['blog_id']); $this->assertEquals('my new blog', $blog['blog_name']); $this->assertEquals(123, $blog['post_total']); $this->assertGreaterThan($time_insert_before, strtotime($blog['created_date'])); $this->assertLessThan($time_insert_after, strtotime($blog['created_date'])); $blog = array_shift($result); $this->assertEquals(4, $blog['blog_id']); $this->assertEquals('my new blog2', $blog['blog_name']); $this->assertEquals(44, $blog['post_total']); $this->assertGreaterThan($time_insert_before, strtotime($blog['created_date'])); $this->assertLessThan($time_insert_after, strtotime($blog['created_date'])); return TRUE; /* ------------------------------ update test */ /* ------------------------------ update test */ case "update_field": echo "selected database:" . $gw->getSelectedDatabase() . PHP_EOL; // update a field $gw->updateField('update_field #1', 'blogs', 1, 'post_total', 5); echo $gw->popSQLHistory() . PHP_EOL; // confirm result $pdo = new DuplicatedPdo($gw); $rows = $pdo->queryRows("SELECT * FROM blogs"); //var_dump($rows); foreach ($rows as $row) { switch ($row['blog_id']) { case 1: $this->assertEquals(1, $row['blog_category_id']); $this->assertEquals('my blog', $row['blog_name']); $this->assertEquals(5, $row['post_total']); break; case 2: $this->assertEquals(2, $row['blog_category_id']); $this->assertEquals('another blog', $row['blog_name']); $this->assertEquals(1, $row['post_total']); break; } } return TRUE; case "update_fields": // update fields $fields = array('post_total' => 999, 'blog_name' => 'super popular blog'); $gw->updateFields('update_fields #1', 'blogs', 1, $fields); echo $gw->popSQLHistory() . PHP_EOL; // confirm result $pdo = new DuplicatedPdo($gw); $rows = $pdo->queryRows("SELECT * FROM blogs"); //var_dump($rows); foreach ($rows as $row) { switch ($row['blog_id']) { case 1: $this->assertEquals(1, $row['blog_category_id']); $this->assertEquals('super popular blog', $row['blog_name']); $this->assertEquals(999, $row['post_total']); break; case 2: $this->assertEquals(2, $row['blog_category_id']); $this->assertEquals('another blog', $row['blog_name']); $this->assertEquals(1, $row['post_total']); break; } } return TRUE; case "update_field_by": // update fields in a row $rows = $gw->updateFieldBy('update_field_by #1', 'blogs', 'blog_name', 'another blog', 'blog_id', 1); echo $gw->popSQLHistory() . PHP_EOL; $this->assertEquals(1, $rows); // confirm result $pdo = new DuplicatedPdo($gw); $rows = $pdo->queryRows("SELECT * FROM blogs"); //var_dump($rows); foreach ($rows as $row) { switch ($row['blog_id']) { case 1: $this->assertEquals(1, $row['blog_category_id']); $this->assertEquals('another blog', $row['blog_name']); $this->assertEquals(2, $row['post_total']); break; case 2: $this->assertEquals(2, $row['blog_category_id']); $this->assertEquals('another blog', $row['blog_name']); $this->assertEquals(1, $row['post_total']); break; } } // update fields in multiple rows $rows = $gw->updateFieldBy('update_field_by #1', 'blogs', 'post_total', 3, 'blog_name', 'another blog'); echo $gw->popSQLHistory() . PHP_EOL; $this->assertEquals(2, $rows); // confirm result $pdo = new DuplicatedPdo($gw); $rows = $pdo->queryRows("SELECT * FROM blogs"); //var_dump($rows); foreach ($rows as $row) { switch ($row['blog_id']) { case 1: $this->assertEquals(1, $row['blog_category_id']); $this->assertEquals('another blog', $row['blog_name']); $this->assertEquals(3, $row['post_total']); break; case 2: $this->assertEquals(2, $row['blog_category_id']); $this->assertEquals('another blog', $row['blog_name']); $this->assertEquals(3, $row['post_total']); break; } } return TRUE; case "update_field_now": $start_time = time(); // update field to current time $gw->updateFieldNow('update_field_now #1', 'blogs', 1, 'modified_date'); echo $gw->popSQLHistory() . PHP_EOL; // confirm result $pdo = new DuplicatedPdo($gw); $rows = $pdo->queryRows("SELECT * FROM blogs"); //var_dump($rows); foreach ($rows as $row) { switch ($row['blog_id']) { case 1: $this->assertEquals(1, $row['blog_category_id']); $this->assertEquals('my blog', $row['blog_name']); $this->assertEquals(2, $row['post_total']); $this->assertEquals('2010-01-02 12:56:12', $row['created_date']); $this->assertLessThanOrEqual($start_time, strtotime($row['modified_date'])); $this->assertGreaterThanOrEqual(time(), strtotime($row['modified_date'])); break; case 2: $this->assertEquals(2, $row['blog_category_id']); $this->assertEquals('another blog', $row['blog_name']); $this->assertEquals(1, $row['post_total']); $this->assertEquals('2010-01-12 02:12:32', $row['created_date']); $this->assertEquals('2010-01-15 11:42:02', $row['modified_date']); break; } } return TRUE; case "update_field_null": // update fields in a row $gw->updateFieldNull('update_field_null #1', 'blogs', 1, 'blog_name'); echo $gw->popSQLHistory() . PHP_EOL; // confirm result $pdo = new DuplicatedPdo($gw); $rows = $pdo->queryRows("SELECT * FROM blogs"); //var_dump($rows); foreach ($rows as $row) { switch ($row['blog_id']) { case 1: $this->assertEquals(1, $row['blog_category_id']); $this->assertEquals(null, $row['blog_name']); $this->assertEquals(2, $row['post_total']); break; case 2: $this->assertEquals(2, $row['blog_category_id']); $this->assertEquals('another blog', $row['blog_name']); $this->assertEquals(1, $row['post_total']); break; } } return TRUE; /* ------------------------------ select db test */ /* ------------------------------ select db test */ case "select_db": echo "selected database:" . $gw->getSelectedDatabase() . PHP_EOL; $exists = $gw->existsTable('item'); $this->assertEquals(true, $exists); $exists = $gw->existsTable('item2'); $this->assertEquals(false, $exists); $gw->selectDatabase('test2'); echo "selected database:" . $gw->getSelectedDatabase() . PHP_EOL; $exists = $gw->existsTable('item'); $this->assertEquals(false, $exists); $exists = $gw->existsTable('item2'); $this->assertEquals(true, $exists); return TRUE; /* ------------------------------ list models test */ /* ------------------------------ list models test */ case "list_models_all": $models = $gw->listModels(); $this->assertEquals(7, count($models)); $bundled_models = array('Charcoal_SessionTableModel', 'BlogCategoryTableModel', 'BlogTableModel', 'CommentTableModel', 'ItemTableModel', 'Item2TableModel', 'PostTableModel', 'TestTableModel'); foreach ($models as $model) { $this->assertTrue($model instanceof Charcoal_ITableModel); $clazz = get_class($model); echo $clazz . PHP_EOL; $this->assertTrue(in_array($clazz, $bundled_models)); } return TRUE; case "list_models_framework": $models = $gw->listModels(Charcoal_EnumFindPath::FIND_PATH_FRAMEWORK); $this->assertEquals(1, count($models)); $bundled_models = array('Charcoal_SessionTableModel'); foreach ($models as $model) { $this->assertTrue($model instanceof Charcoal_ITableModel); $clazz = get_class($model); echo $clazz . PHP_EOL; $this->assertTrue(in_array($clazz, $bundled_models)); } return TRUE; case "list_models_project": $models = $gw->listModels(Charcoal_EnumFindPath::FIND_PATH_PROJECT); $this->assertEquals(6, count($models)); $bundled_models = array('BlogCategoryTableModel', 'BlogTableModel', 'CommentTableModel', 'ItemTableModel', 'Item2TableModel', 'PostTableModel', 'TestTableModel'); foreach ($models as $model) { $this->assertTrue($model instanceof Charcoal_ITableModel); $clazz = get_class($model); echo $clazz . PHP_EOL; $this->assertTrue(in_array($clazz, $bundled_models)); } return TRUE; case "list_models_application": $models = $gw->listModels(Charcoal_EnumFindPath::FIND_PATH_APPLICATION); $this->assertEquals(0, count($models)); return TRUE; default: break; } return FALSE; }
/** * This wil get an Advertisment from database and display it * * @global type $adsObj * @param ARRAY (style,class,align,place) * style = Css Styling on div wrapping AD * class = class of div wrapping AD * place = AD placement code e.g ad_300x250 * @return string */ function getAd($params) { global $adsObj; $data = ''; if ($params['style'] || $params['class'] || $params['align']) { $data .= '<div style="' . $params['style'] . '" class="' . $params['class'] . '" align="' . $params['align'] . '">'; } $data .= ad($adsObj->getAd($params['place'])); if ($params['style'] || $params['class'] || $params['align']) { $data .= '</div>'; } return $data; }
<tr class="bg"> <td class="first" width="172"><strong>Submit</strong></td> <td class="last"><input type="hidden" name="date" /><input type="submit" class="button" name="add" value="Add Media!" /></td> </tr> </table> </div> </form> <br/><br/> <center>*Youtube videos will automatically get title, description and image from the Youtube API. <br/>Just put the video url in the 'File path' box, choose category and click 'Add Media'.</center><br/> <?php } ?> </div> <div class="clear"></div></div> <div class="container_box1" style="min-height:0px"><div class="header">Advertisement</div><div align="center" style="padding:6px"> <?php if (ad("6") == 'Put AD code here') { ?> <img src="<?php echo $setting['siteurl'] . 'templates/' . $setting['theme'] . '/skins/' . $setting['skin'] . '/images/468x60.PNG'; ?> " width="468" height="60" /> <?php } else { echo ad("6"); } ?> </div> <div class="clear"></div></div>
function contentheader() { echo '<div id="header">'; echo '<div class="frame">'; echo '<div id="top_section">'; banner(""); menu(""); echo '</div>'; echo '<div id="upper_section" class="middletext">'; ad(); //user(); echo '</div>'; echo '</div>'; echo '</div>'; }
public function validate($sequence, $form_token, $throws = TRUE) { Charcoal_ParamTrait::validateIsA(1, 'Charcoal_ISequence', $sequence); Charcoal_ParamTrait::validateString(2, $form_token); Charcoal_ParamTrait::validateBoolean(3, $throws); $throws = ub($throws); log_debug("debug", "sequence: " . print_r($sequence, true)); log_debug("debug", "form_token: " . print_r($form_token, true)); if ($this->getSandbox()->isDebug() && $this->debug_mode) { ad($sequence, array('title' => "sequence")); } $token_key = $this->token_key; log_debug("debug", "token_key: " . print_r($token_key, true)); if ($this->getSandbox()->isDebug() && $this->debug_mode) { ad($token_key, array('title' => "token_key", "type" => "div")); } // get token container from session. $token_list = $sequence->get(s($token_key)); if ($this->getSandbox()->isDebug() && $this->debug_mode) { ad($token_list, array('title' => "token list")); } log_debug("debug", "token_list: " . print_r($token_list, true)); if ($token_list === NULL || !is_array($token_list)) { $token_list = array(); } // find token from token list. $token_index = NULL; foreach ($token_list as $idx => $token) { log_info("debug", "token: {$token}"); if ($this->getSandbox()->isDebug() && $this->debug_mode) { ad($token, array('title' => "token", "type" => "div")); } if ($token == $form_token) { $token_index = $idx; break; } } if ($token_index === NULL) { // illegal access log_warning("system, debug", "token not found: {$form_token}"); if ($this->getSandbox()->isDebug() && $this->debug_mode) { ad($form_token, array('title' => "token not found", "type" => "div")); } if ($throws) { _throw(new Charcoal_FormTokenValidationException('token not found in sequence:' . $form_token), FALSE); } return FALSE; } else { // authorized access log_debug("debug", "token accepted: {$form_token}"); if ($this->getSandbox()->isDebug() && $this->debug_mode) { ad($form_token, array('title' => "token accepted", "type" => "div")); } // erase token from token list to prevent duplicate form submission. unset($token_list[$token_index]); } // update token list in sequence. $sequence->set($token_key, $token_list); // the event was successfully processed. return TRUE; }
</a></div> </div> <div class="clear"></div><br style="clear: both"/></div> <?php } } $query->close(); ?> <div class="clear"></div></div> <!-- end of featured box --> <!-- start of ads_box box --> <div class="container_ad1"> <div class="header_ad1">Advertisement</div> <div class="ad_300x250"> <?php echo ad("3"); ?> </div> </div> <div class="container_ad2"> <div class="header_ad2">Newest Games</div> <?php $query = yasDB_select("SELECT id, title, thumbnail, description, plays FROM games ORDER BY id DESC LIMIT 6"); if ($query->num_rows == 0) { echo '<center><h3>We have no Featured games yet!</h3></center>'; } if ($query->num_rows > 0) { $pic_settings = array('w' => 120, 'h' => 100); while ($games = $query->fetch_array(MYSQLI_ASSOC)) { $gameurl = prepgame($games['title']);
echo ad(24); ?> </td> <td><?php echo ad(25); ?> </td> </tr> </table> </div> <div class="m b10"> </div> <div class="m"> <div class="m_l f_l"> <div class="topr"> <div><?php echo ad(14); ?> </div> <div class="b10"> </div> <?php if ($DT['page_trade']) { ?> <div id="trades"> <div class="tab_head"> <ul> <li class="tab_2" id="trade_t_1" onmouseover="Tb(1, 3, 'trade', 'tab');"><a href="<?php echo $MODULE['6']['linkurl']; ?> ">求购</a></li> <li class="tab_1" id="trade_t_2" onmouseover="Tb(2, 3, 'trade', 'tab');"><a href="<?php echo $MODULE['5']['linkurl'];
<div class="nav_box"><div class="nav">Banner</div> <div class="nav_box2"><center> <?php if (ad("7") == "Put AD code here") { ?> <img src="<?php echo $setting['siteurl'] . 'templates/' . $setting['theme'] . '/skins/' . $setting['skin'] . '/images/100x100banner.png'; ?> " width="100" height="100" alt="banner exchange"/> <?php } else { echo ad("7"); } ?> </center> </div> </div>
} ?> </div> <div class="clear"></div> <div id="blog_box_ad"> <div id="blog_ad"> <?php if (ad("4") == 'Put AD code here') { ?> <img src="<?php echo $setting['siteurl'] . 'templates/' . $setting['theme'] . '/skins/' . $setting['skin'] . '/images/468x60.PNG'; ?> " width="468" height="60" /> <?php } else { echo ad("4"); } ?> </div> </div> <div class="clear"></div> <div class="news_box"> <?php $query = yasDB_select("SELECT * FROM newsblog"); $prefix = $setting['siteurl'] . 'templates/' . $setting['theme'] . '/skins/' . $setting['skin'] . '/images/smileys/'; if ($query->num_rows == 0) { echo '<div id="newsblog_text">This news blog has no comments, become a member and be the first to add one!</div>'; } else { $query = yasDB_select("SELECT * FROM newsblog WHERE userid = '{$id}'"); while ($row = $query->fetch_array(MYSQLI_ASSOC)) { $text = $row['comment'];
include 'rightcolumn.php'; ?> <!-- begin footer --> <div id="footer"> Copyright 2011 © <b><a href="<?php echo $setting['siteurl']; ?> "><?php echo $setting['sitename']; ?> </a></b><br> <?php //Don't remove unless you purchased copyright removal ?> Powered by <a href="http://www.yourarcadescript.com" target="blank">YourArcadeScript <?php echo $setting['version']; ?> </a> </div> <!-- end footer --> </div> <!-- end content_wrapper --> </div> </div> <!--end body_wrapper --> <?php echo ad("11"); // Google Analytics ad spot ?> </body> </html>
<div class="navh3">Advertisement</div> <center> <?php if (ad("2") == 'Put AD code here') { ?> <img src="<?php echo $setting['siteurl'] . 'templates/' . $setting['theme'] . '/skins/' . $setting['skin'] . '/images/160x600.png'; ?> " width="160" height="600" /> <?php } else { echo ad("2"); } ?> </center>
<!-- begin center --> <div id="center"> <div id="home_container"> <!-- start of ads_box box --> <div class="container_box1" style="height:100px;width:100px;float:left;margin-left:12px;padding:4px;"><?php echo ad("8"); ?> </div> <div class="container_box1" style="height:100px;width:468px;float:left;margin-left:10px;padding:2px 5px 4px 5px;"> <div id="headergames2" style="width:468px;margin:0 0 10px 0;padding:0;"><span style="padding-left:40px;">Advertisement</span></div> <?php echo ad("4"); ?> </div> <div class="container_box1" style="height:100px;width:100px;float:left;margin-left:12px;padding:4px"><?php echo ad("9"); ?> </div><div style="clear:both"></div> <!-- end of ads box --> <!-- start of featured box --> <div class="container_box1"><div id="headergames2">Featured Games</div> <?php $query = yasDB_select("SELECT `id` , `title` , `thumbnail` , `description` , `plays` FROM `games` INNER JOIN `featuredgames` ON `games`.`id` = `featuredgames`.`gameid` ORDER BY rand()"); $pic_settings = array('w' => 130, 'h' => 100); if ($query->num_rows == 0) { $query->close(); $query = yasDB_select("SELECT id, title, thumbnail, description, plays FROM games ORDER BY rand() LIMIT 5"); if ($query->num_rows == 0) { echo '<center><h3>We have no Featured Games games yet!</h3></center>'; } }
<?php 'a' . ($b['c'] == 'd' ? "e{$f}g{$h['i']}" . j('k') . "l" . m('n') . "o" : "p{$q}r{$s['t']}u" . ($v['w'] != X ? "y" . z('aa') . "'ab" : "ac" . ad('ae') . "af") . "ag" . ah('ai') . "aj") . "ak";
<div class="game_ad"> <?php if (ad("4") == 'Put AD code here') { ?> <img src="<?php echo $setting['siteurl'] . 'templates/' . $setting['theme'] . '/skins/' . $setting['skin'] . '/images/468x60.png'; ?> " width="468" height="60" /> <?php } else { echo ad("4"); } ?> </div> <div class="game_banner"><?php echo ad("10"); ?> </div> <div class="game_box_inline"> <!-- |||||||||=========== Slider Start =============== |||||| --> <?php // this slider is only for swf games, should work with other formats, try them if ($row['type'] != '') { ?> <br> <center> <div style=" float: left; margin: 2px 2px 4px 140px; text-align: center; width: 500px;"> <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/base/jquery-ui.css"> <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.3.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js"></script> <?php
/** * execute tests */ public function test($action, $context) { $action = us($action); switch ($action) { case "get_object_var": $child = new ChildClass(); $actual = Charcoal_System::getObjectVar($child, 'child_public_var'); $this->assertEquals(4, $actual); $actual = Charcoal_System::getObjectVar($child, 'child_protected_var'); $this->assertEquals(5, $actual); $actual = Charcoal_System::getObjectVar($child, 'child_private_var'); $this->assertEquals(6, $actual); $actual = Charcoal_System::getObjectVar($child, 'public_var'); $this->assertEquals(4, $actual); $actual = Charcoal_System::getObjectVar($child, 'protected_var'); $this->assertEquals(5, $actual); $actual = Charcoal_System::getObjectVar($child, 'private_var'); $this->assertEquals(6, $actual); return TRUE; case "get_object_vars": $grandchild = new GrandChildClass(); $grandchild_vars = Charcoal_System::getObjectVars($grandchild); // foreach( $grandchild_vars as $k => $v ){ // echo "grandchild vars: [$k]=$v" . eol(); // } $grandchild_vars_actual = $grandchild->getObjectVars(); // foreach( $grandchild_vars_actual as $k => $v ){ // echo "grandchild vars_actual: [$k]=$v" . eol(); // } $this->assertEquals(1, $grandchild_vars_actual['grandparent_public_var']); $this->assertEquals(2, $grandchild_vars_actual['grandparent_protected_var']); $this->assertEquals(3, $grandchild_vars_actual['grandparent_private_var']); $this->assertEquals(4, $grandchild_vars_actual['child_public_var']); $this->assertEquals(5, $grandchild_vars_actual['child_protected_var']); $this->assertEquals(6, $grandchild_vars_actual['child_private_var']); $this->assertEquals(7, $grandchild_vars_actual['grandchild_public_var']); $this->assertEquals(8, $grandchild_vars_actual['grandchild_protected_var']); $this->assertEquals(9, $grandchild_vars_actual['grandchild_private_var']); $this->assertEquals(7, $grandchild_vars_actual['public_var']); $this->assertEquals(8, $grandchild_vars_actual['protected_var']); $this->assertEquals(9, $grandchild_vars_actual['private_var']); $child = new ChildClass(); $child_vars = Charcoal_System::getObjectVars($child); // foreach( $child_vars as $k => $v ){ // echo "child vars: [$k]=$v" . eol(); // } $child_vars_actual = $child->getObjectVars(); // foreach( $child_vars_actual as $k => $v ){ // echo "child vars_actual: [$k]=$v" . eol(); // } $this->assertEquals(1, $child_vars_actual['grandparent_public_var']); $this->assertEquals(2, $child_vars_actual['grandparent_protected_var']); $this->assertEquals(3, $child_vars_actual['grandparent_private_var']); $this->assertEquals(4, $child_vars_actual['child_public_var']); $this->assertEquals(5, $child_vars_actual['child_protected_var']); $this->assertEquals(6, $child_vars_actual['child_private_var']); $this->assertEquals(4, $child_vars_actual['public_var']); $this->assertEquals(5, $child_vars_actual['protected_var']); $this->assertEquals(6, $child_vars_actual['private_var']); $parent = new ParentClass(); $parent_vars = Charcoal_System::getObjectVars($parent); // foreach( $parent_vars as $k => $v ){ // echo "parent vars: [$k]=$v" . eol(); // } $parent_vars_actual = $parent->getObjectVars(); // foreach( $parent_vars_actual as $k => $v ){ // echo "parent vars_actual: [$k]=$v" . eol(); // } $this->assertEquals(1, $parent_vars_actual['grandparent_public_var']); $this->assertEquals(2, $parent_vars_actual['grandparent_protected_var']); $this->assertEquals(3, $parent_vars_actual['grandparent_private_var']); $this->assertEquals(1, $parent_vars_actual['public_var']); $this->assertEquals(2, $parent_vars_actual['protected_var']); $this->assertEquals(3, $parent_vars_actual['private_var']); return TRUE; case "snake_case": $data = array('CharcoalPhp' => 'charcoal_php', 'CharcoalPHP' => 'charcoal_php', 'charcoalPhp' => 'charcoal_php', 'charcoalPHP' => 'charcoal_php', 'charcoalphp' => 'charcoalphp', 'Charcoalphp' => 'charcoalphp', 'charcoalpHp' => 'charcoalp_hp', 'charcoalphP' => 'charcoalph_p', 'charCoalphp' => 'char_coalphp', 'charcoal_php' => 'charcoal_php', 'charcoal_PHP' => 'charcoal_php', 'Charcoal_PHP' => 'charcoal_php', 'Charcoal_Php' => 'charcoal_php', 'Charcoal_pHp' => 'charcoal_p_hp', 'Charcoal_phP' => 'charcoal_ph_p', 'CharCoal_php' => 'char_coal_php', 'charcoal_php_5.3' => 'charcoal_php_5.3', 'charcoal_php_ver5.3' => 'charcoal_php_ver5.3', 'charcoal_php_Ver5.3' => 'charcoal_php_ver5.3', 'charcoal_php_vEr5.3' => 'charcoal_php_v_er5.3', 'charcoal_php_5.3-dev' => 'charcoal_php_5.3-dev', 'charcoal_php_5.3-Dev' => 'charcoal_php_5.3-dev', 'charcoal_php_5.3-dEv' => 'charcoal_php_5.3-d_ev', 'charcoal_php0a2c' => 'charcoal_php0a2c'); foreach ($data as $key => $expected) { $actual = Charcoal_System::snakeCase($key); // echo "[original]$key [expected]$expected [actual]$actual" . eol(); $this->assertEquals($expected, $actual); } return TRUE; case "pascal_case": $data = array('CharcoalPhp' => 'Charcoalphp', 'CharcoalPHP' => 'Charcoalphp', 'charcoalPhp' => 'Charcoalphp', 'charcoalPHP' => 'Charcoalphp', 'charcoalphp' => 'Charcoalphp', 'Charcoalphp' => 'Charcoalphp', 'charcoalpHp' => 'Charcoalphp', 'charcoalphP' => 'Charcoalphp', 'charCoalphp' => 'Charcoalphp', 'charcoal_php' => 'CharcoalPhp', 'charcoal_PHP' => 'CharcoalPhp', 'Charcoal_PHP' => 'CharcoalPhp', 'Charcoal_Php' => 'CharcoalPhp', 'Charcoal_pHp' => 'CharcoalPhp', 'Charcoal_phP' => 'CharcoalPhp', 'CharCoal_php' => 'CharcoalPhp', 'charcoal_php_5.3' => 'CharcoalPhp5.3', 'charcoal_php_ver5.3' => 'CharcoalPhpVer5.3', 'charcoal_php_Ver5.3' => 'CharcoalPhpVer5.3', 'charcoal_php_vEr5.3' => 'CharcoalPhpVer5.3', 'charcoal_php_5.3-dev' => 'CharcoalPhp5.3-dev', 'charcoal_php_5.3-Dev' => 'CharcoalPhp5.3-dev', 'charcoal_php_5.3-dEv' => 'CharcoalPhp5.3-dev', 'charcoal_php0a2c' => 'CharcoalPhp0a2c'); foreach ($data as $key => $expected) { $actual = Charcoal_System::pascalCase($key); // echo "[original]$key [expected]$expected [actual]$actual" . eol(); $this->assertEquals($expected, $actual); } return TRUE; case "hash_collision": $hashes = array(); $max = 1000000; for ($i = 0; $i < $max; $i++) { $hash = Charcoal_System::hash(); if (!isset($hashes[$hash])) { $hashes[$hash] = 0; } $hashes[$hash]++; $p = (double) $i / $max * 100; echo sprintf("[%0.2f %%]\r", $p); } $collisions = array_filter($hashes, function ($item) { return $item >= 2; }); ad($collisions); return TRUE; } return FALSE; }
<div id="textbox"><div class="topicbox"><h2>' . $row['topic'] . '</h2></div><div id="topic">' . $row['news_text'] . '</div> <div class="topicbox"> <iframe src="http://www.facebook.com/plugins/like.php?href=' . urlencode($setting['siteurl']) . '&layout=standard& show_faces=true&width=500&action=like&font=lucida+grande&colorscheme=light&height=28" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:500px; height:28px;" allowTransparency="false"></iframe> </div> </div> </div>'; ?> <div class="clear"></div> </div> <div class="container_box1" style="min-height:90px;"> <div class="header">Advertisement</div> <div style="width:728px;height:90px;background-color:#fff;color:#000;margin-left:5px;"> <?php echo ad("12"); ?> </div> <div class="clear"></div> </div> <div class="container_box1"> <div class="header">Comments:</div> <div class="container_box3"> <div id="messages"> <?php $query = yasDB_select("SELECT * FROM newsblog"); $prefix = $setting['siteurl'] . 'templates/' . $setting['theme'] . '/skins/' . $setting['skin'] . '/images/smileys/'; if ($query->num_rows == 0) { echo '<div id="newsblog_text">This news blog has no comments, become a member and be the first to add one!</div>'; } else { $query = yasDB_select("SELECT comment, username FROM newsblog WHERE newsid = '{$id}'");