public function testInstantArticleAlmostEmpty() { $article = InstantArticle::create()->withCanonicalUrl('')->withHeader(Header::create())->addChild(Paragraph::create()->appendText('Some text to be within a paragraph for testing.'))->addChild(Paragraph::create())->addChild(Paragraph::create()->appendText(" \n \t "))->addChild(Image::create())->addChild(Image::create()->withURL(''))->addChild(SlideShow::create()->addImage(Image::create()->withURL('https://jpeg.org/images/jpegls-home.jpg'))->addImage(Image::create()))->addChild(Ad::create())->addChild(Paragraph::create()->appendText('Other text to be within a second paragraph for testing.'))->addChild(Analytics::create())->withFooter(Footer::create()); $expected = '<!doctype html>' . '<html>' . '<head>' . '<link rel="canonical" href=""/>' . '<meta charset="utf-8"/>' . '<meta property="op:generator" content="facebook-instant-articles-sdk-php"/>' . '<meta property="op:generator:version" content="' . InstantArticle::CURRENT_VERSION . '"/>' . '<meta property="op:markup_version" content="v1.0"/>' . '</head>' . '<body>' . '<article>' . '<p>Some text to be within a paragraph for testing.</p>' . '<figure class="op-slideshow">' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home.jpg"/>' . '</figure>' . '</figure>' . '<p>Other text to be within a second paragraph for testing.</p>' . '</article>' . '</body>' . '</html>'; $result = $article->render(); $this->assertEquals($expected, $result); }
public function testHeaderWithSingleDefaultAd() { $header = Header::create()->addAd(Ad::create()->withSource('http://foo.com')->withWidth(350)->withHeight(50)->enableDefaultForReuse()); // It should not set op-ad-default $expected = '<header>' . '<figure class="op-ad">' . '<iframe src="http://foo.com" width="350" height="50"></iframe>' . '</figure>' . '</header>'; $rendered = $header->render(); $this->assertEquals($expected, $rendered); }
if ($p_webpage != '' && !preg_match('/^((http|https):\\/\\/)?[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}((:[0-9]{1,5})?\\/.*)?$/i', $p_webpage)) { $success = false; array_push($errors, "The format of webpage is incorrect."); } if (isset($p_picture) && isset($p_picture['name']) && $p_picture['name'] != '') { list($postedon_year, $postedon_month, $postedon_day) = explode('-', $today); $picture_path = "{$postedon_year}/{$postedon_month}/{$postedon_day}/picture"; $thumb_path = "{$upload_path}/{$postedon_year}/{$postedon_month}/{$postedon_day}/thumb"; include "upload_picture.php"; } else { $p_picture = ''; } if ($success) { $expiry = date("Y-m-d H:i:s", time() + $p_expiry * 24 * 60 * 60); $code = md5(uniqid(rand(), true)); $last = Ad::create(array('name' => $p_name, 'email' => $p_email, 'telephone' => $p_telephone, 'title' => $p_title, 'description' => $p_description, 'picture' => $p_picture, 'category' => $p_category, 'price' => $p_price, 'city' => $p_city, 'region' => $p_region, 'expiry' => $expiry, 'webpage' => $p_webpage, 'code' => $code)); Ad::activate($last); } } $expiries = Expiry::get_all(); include "page-header.php"; ?> <div id="wrapper"> <?php include "page-left.php"; ?> <div id="content">
$success = false; array_push($errors, "You should agree with the Terms and Conditions."); } if ($success) { $ipaddr = $_SERVER['REMOTE_ADDR']; if (UserBanned::exists(0, array(), "(email='{$p_email}' OR ipaddr='{$ipaddr}')")) { $last = 666666; } else { $postedon = date("Y-m-d H:i:s", time()); $expiry = date("Y-m-d", time() + $p_expiry * 24 * 60 * 60); $code = md5(uniqid(rand(), true)); if (User::is_logged_in()) { $p_name = User::get_name(); $p_email = User::get_email(); } $last = Ad::create(array('user_id' => User::get_id(), 'name' => $p_name, 'email' => $p_email, 'telephone' => $p_telephone, 'title' => $p_title, 'description' => $p_description, 'picture' => $p_picture, 'category' => $p_category, 'price' => $p_price, 'city' => $p_city, 'region' => $p_region, 'expiry' => $expiry, 'webpage' => $p_webpage, 'code' => $code, 'ipaddr' => $ipaddr, 'postedon' => $postedon, 'lastmodified' => $postedon)); if (User::is_logged_in()) { Ad::activate($last); } else { if (!($user_exists = User::exists(0, array('email' => $p_email)))) { $p_em = explode('@', $p_email); $username = substr($p_em[0], 0, 6); $active = 0; $createdon = date("Y-m-d H:i:s", time()); $password = substr($code, 0, 6); $userid = User::create(array('email' => $p_email, 'username' => $username, 'password' => $password, 'name' => $p_name, 'active' => $active, 'createdon' => $createdon, 'ipaddr' => $ipaddr, 'code' => $code)); $registration_message = StaticContent::get_content('user-registration-email'); eval("\$registration_message = \"{$registration_message}\";"); } else { $user = User::get_one(0, array('email' => $p_email)); $username = $user['username'];
function add_ad($db, $POST) { if (isset($POST['allow_mails'])) { $allow_mails = $POST['allow_mails']; } else { $allow_mails = ''; } $ad1 = new Ad(); $this->ads[] = $ad1->create($_POST['title'], $_POST['price'], $_POST['seller_name'], $_POST['email'], $_POST['phone'], $_POST['description'], $_POST['location_id'], $_POST['metro_id'], $_POST['category_id'], $_POST['private'], $allow_mails); //вставили значение $mysql_last_id = $db->query('INSERT into ads ' . '(title, price, user_name, email, tel, descr, id_city, ' . 'id_tube_station, id_subcategory, private, send_to_email) ' . 'VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )', $_POST['title'], $_POST['price'], $_POST['seller_name'], $_POST['email'], $_POST['phone'], $_POST['description'], $_POST['location_id'], $_POST['metro_id'], $_POST['category_id'], $_POST['private'], $allow_mails); return $mysql_last_id; }