Exemplo n.º 1
0
 /**
  * @covers Ad::tableName
  * @todo   Implement CreateAd().
  */
 public function testCreateAd()
 {
     $this->object->name = 'test Ad1';
     $this->object->description = 'test Ad1 description';
     $this->object->html = '<p>This is a test Ad</p>';
     $this->assertTrue($this->object->save() === TRUE);
 }
Exemplo n.º 2
0
 protected function createFakerAd()
 {
     $faker = Faker::create();
     $adtype = array("Informal Jam", "Formal Jam/Practice/Rehearsal", "Payed Gig", "Offering Lessons", "Wanting Lessons");
     $level = array("Beginner", "Intermediate", "Semi-Pro", "Professional");
     $original = array("Originals", "Covers", "Both");
     $venuetype = array("House", "Venue", "Recording Studio", "Event");
     $usertype = array("Band", "Musician");
     $genre = array("Acoustic Blues", "Electric Blues", "Bluegrass", "Classical", "Pop Country", "Traditional Country", "House", "Deep House", "Dubstep", "Trap", "Techno", "Downtempo", "Ambient", "Drums & Bass", "Video Game", "Americana", "Acoustic Folk", "Cajun Folk", "Celtic Folk", "Singer/Songwriter Folk", "Combo Jazz", "Dixieland Jazz", "Ensemble Jazz", "Fusion Jazz", "Latin Jazz", "Standards", "Acid Jazz", "Latin", "New Age", "Ambient", "Christian", "Classic Rock", "Dance", "Hard Rock", "Heavy Metal", "Indie Rock", "Latin Rock", "New Wave", "Pop", "Psychedelic", "Punk Rock", "Rock & Roll", "Rockabilly", "Singer/Songwriter", "Ska", "Soft Rock", "Southern Rock", "Top 40", "Hip Hop/Rap", "Classic Soul", "Neo-Soul", "Gospel", "Contemporary R&B", "Reggae", "Soundtrack", "World Music");
     $instrument = array("Full Band, Acoustic Guitar", "Classical Guitar", "Electric Guitar", "Steel Guitar", "Electric Bass", "Double Bass", "Ukelele", "Piano", "Keyboard", "Organ", "Accordion", "Drums", "Lead Rock/Pop Vocals", "Lead Jazz Vocals", "Bass Singer", "Baritone Singer", "Tenor Singer", "Alto Singer", "Mezzo-Soprano Singer", "Soprano Singer", "Cello", "Viola", "Violin", "Fiddle", "Banjo", "Harp", "Mandolin", "Trumpet", "Trombone", "Tuba", "French Horn", "Alto Sax", "Tenor Sax", "Flute", "Oboe", "Clarinet", "Harmonica", "Piccolo", "Bassoon");
     $equipment = array("P/A System", "Guitar Amp", "Bass Amp", "Drum Set", "Keyboard");
     for ($i = 1; $i <= 200; $i++) {
         $ad = new Ad();
         $ad->ad_type = $faker->randomElement($adtype);
         $ad->ad_need = implode(", ", $faker->randomElements($instrument, $count = rand(1, 3)));
         $ad->ad_title = $faker->state . " " . $faker->lastName;
         $ad->level = $faker->randomElement($level);
         $ad->comp = rand(0, 200);
         $ad->genre = implode(", ", $faker->randomElements($genre, $count = rand(1, 3)));
         $ad->date = $faker->dateTimeBetween($startDate = 'now', $endDate = '3 months');
         $ad->start_time = $faker->time($format = 'H:i:s', $min = 'now');
         $ad->description = $faker->realText;
         $ad->equipment = implode(", ", $faker->randomElements($equipment, $count = rand(0, 5)));
         $ad->venue_type = $faker->randomElement($venuetype);
         $ad->venue = "Tycoon Flats";
         $ad->address = "2926 N. St. Marys Street";
         $ad->city = "San Antonio";
         $ad->state = "TX";
         $ad->zip_code = "78212";
         $ad->user_id = User::all()->random(1)->id;
         $ad->ad_img = $faker->imageUrl($width = 640, $height = 480, $category = 'nightlife');
         $ad->save();
     }
 }
Exemplo n.º 3
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     /*
      * Verifies access to the particular AD.
      */
     if (Yii::app()->user->checkAccess('AdCreate', $this->bizruleCreate())) {
         $model = new Ad();
         // Uncomment the following line if AJAX validation is needed
         // $this->performAjaxValidation($model);
         if (isset($_POST['Ad'])) {
             $model->attributes = $_POST['Ad'];
             if ($model->save()) {
                 $screenAdAssignment = new ScreenAdAssignment();
                 $screenAdAssignment->ad_id = $model->id;
                 $screenAdAssignment->screen_id = $this->_screen->id;
                 if ($screenAdAssignment->save()) {
                     Yii::app()->user->setFlash('success', YII::t('ad', 'Ad created successfully.'));
                     $this->redirect(array('screen/view', 'id' => $this->_screen->id));
                 } else {
                     Yii::app()->user->setFlash('error', YII::t('ad', 'Could not assign the Ad to the Screen.'));
                     $model->delete();
                 }
             }
         }
         $this->render('create', array('model' => $model));
     } else {
         throw new CHttpException(403, YII::t('default', 'You are not authorized to perform this action.'));
     }
 }
Exemplo n.º 4
0
 public function run()
 {
     $model = new Ad();
     if (isset($_POST['Ad'])) {
         $model->attributes = $_POST['Ad'];
         //图片
         $model->attach_file = isset($_POST['attach_file']) ? $_POST['attach_file'] : '';
         if ($model->save()) {
             $this->controller->message('success', Yii::t('admin', 'Add Success'), $this->controller->createUrl('index'));
         }
     }
     $this->controller->render('create', array('model' => $model));
 }
Exemplo n.º 5
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Ad('create');
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Ad'])) {
         $model->attributes = $_POST['Ad'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Exemplo n.º 6
0
Arquivo: Ad.php Projeto: gorvic/L16
 public static function handlePostQuery(array $sanitized_post_array)
 {
     // The result of the request
     $ajax_result = array('status' => '', 'message' => '', 'data' => '');
     $is_edit_mode = isset($sanitized_post_array['id']);
     $ad = new Ad($sanitized_post_array);
     $result = $ad->save();
     $sanitized_title = htmlentities($ad->getTitle());
     if ($result) {
         $ajax_result['status'] = 'success';
         $ajax_result['message'] = 'Ad "' . $sanitized_title . '" has been ' . ($is_edit_mode ? '" updated' : '"added') . ' successfully .';
         $ajax_result['data'] = ['id' => $ad->getId()];
     } else {
         $ajax_result['status'] = 'error';
         $ajax_result['message'] = 'Error while ad "' . $sanitized_title . ($is_edit_mode ? '" updating ' : '" adding') . '.';
     }
     return $ajax_result;
 }
Exemplo n.º 7
0
Arquivo: Ad.php Projeto: gorvic/L17
 public static function handlePostQuery(array $sanitized_post_array, $view)
 {
     /* @var $view Smarty */
     // The result of the request
     $ajax_result = array('status' => '', 'message' => '', 'data' => '');
     $is_edit_mode = isset($sanitized_post_array['id']);
     $ad = new Ad($sanitized_post_array);
     $result = $ad->save();
     $sanitized_title = htmlentities($ad->getTitle());
     if ($result) {
         $ajax_result['status'] = 'success';
         $ajax_result['message'] = 'Ad "' . $sanitized_title . '" has been ' . ($is_edit_mode ? '" updated' : '"added') . ' successfully .';
         $view->assign('ad_in_table', $ad);
         $class_name = $ad->getOrganizationFormId() == '1' ? 'organization' : 'individual';
         $ajax_result['data'] = $view->fetch('table_row_' . $class_name . '.tpl.html');
     } else {
         $ajax_result['status'] = 'error';
         $ajax_result['message'] = 'Error while ad "' . $sanitized_title . ($is_edit_mode ? '" updating ' : '" adding') . '.';
     }
     return $ajax_result;
 }
Exemplo n.º 8
0
 /**
  * 广告添加
  *
  */
 public function actionAdCreate()
 {
     $model = new Ad();
     if (isset($_POST['Ad'])) {
         $model->attributes = $_POST['Ad'];
         if ($_FILES['attach']['error'] == UPLOAD_ERR_OK) {
             $upload = new Uploader();
             $upload->uploadFile($_FILES['attach']);
             if ($upload->_error) {
                 $this->message('error', Yii::t('admin', $upload->_error));
                 return;
             }
             $model->attach_file = $upload->_file_name;
             $model->create_time = time();
         }
         if ($model->save()) {
             $this->message('success', Yii::t('admin', 'Add Success'), $this->createUrl('index'));
         }
     }
     $this->render('ad_create', array('model' => $model));
 }
 /**
  * testTreeWithContainable method
  *
  * @return void
  */
 public function testTreeWithContainable()
 {
     $this->loadFixtures('Ad', 'Campaign');
     $TestModel = new Ad();
     $TestModel->Behaviors->load('Tree');
     $TestModel->Behaviors->load('Containable');
     $node = $TestModel->findById(2);
     $node['Ad']['parent_id'] = 1;
     $TestModel->save($node);
     $result = $TestModel->getParentNode(array('id' => 2, 'contain' => 'Campaign'));
     $this->assertTrue(array_key_exists('Campaign', $result));
     $result = $TestModel->children(array('id' => 1, 'contain' => 'Campaign'));
     $this->assertTrue(array_key_exists('Campaign', $result[0]));
     $result = $TestModel->getPath(array('id' => 2, 'contain' => 'Campaign'));
     $this->assertTrue(array_key_exists('Campaign', $result[0]));
     $this->assertTrue(array_key_exists('Campaign', $result[1]));
 }
Exemplo n.º 10
0
        $ad->vintage = Input::getNumber('vintage', 1, 25);
    } catch (Exception $e) {
        $errors[] = $e->getMessage();
    }
    try {
        $ad->price = Input::getString('price', 1, 1000);
    } catch (Exception $e) {
        $errors[] = $e->getMessage();
    }
    try {
        $ad->description = Input::getString('description', 1, 1000);
    } catch (Exception $e) {
        $errors[] = $e->getMessage();
    }
    $ad->post_date = date('Y-m-d h:i');
    $ad->save();
    /*model then handles the save on object*/
}
var_dump($_REQUEST);
?>


<html>
<head>
  <title>Edit an Existing Wineseller Ad</title>
   <meta name="viewport" content="width=device-width, initial-scale=1">
        
            <link rel="stylesheet" href="bootstrap.css">
            <link rel="stylesheet" href="bootstrap.min.css">
            <link rel="stylesheet" href="../css/wineseller.css">
      <meta charset="utf-8">
Exemplo n.º 11
0
require_once '../bootstrap.php';
// $character = Character::where("name", "Ryno");
// var_dump($character);
if (!Auth::checkUser()) {
    header("Location: auth.login.php");
    exit;
}
if (!empty($_POST)) {
    $create_Ad = new Ad();
    $create_Ad->item_name = Input::get('item_name');
    $create_Ad->item_type = Input::get('item_type');
    $create_Ad->date_listed = Input::get('date_listed');
    $create_Ad->price = Input::get('price');
    $create_Ad->description = Input::get('description');
    $create_Ad->item_number = Input::get('item_number');
    $create_Ad->save();
}
?>
<html>
<head>
	<title>WoW Header</title>
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
	<link rel="stylesheet" href="/css/main.css">

	
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

	<style>

		.well {
Exemplo n.º 12
0
 /**
  * 广告录入
  *
  */
 public function actionAdCreate()
 {
     parent::_acl('ad_create');
     $model = new Ad();
     if (isset($_POST['Ad'])) {
         $model->attributes = $_POST['Ad'];
         $file = XUpload::upload($_FILES['attach']);
         if (is_array($file)) {
             $model->attach_file = $file['pathname'];
         }
         $model->expired_time = intval(strtotime($model->expired_time));
         $model->start_time = intval(strtotime($model->start_time));
         if ($model->save()) {
             XXcache::refresh('_ad');
             AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入广告,ID:' . $model->id));
             $this->redirect(array('ad'));
         }
     }
     $model->start_time = date('Y-m-d');
     $model->expired_time = date('Y-m-d', time() + 86499);
     $this->render('ad_create', array('model' => $model));
 }
Exemplo n.º 13
0
        // Create a person
        $description = Input::getString('description');
    } catch (LengthException $e) {
        // Report any errors
        $errors[] = "Description - " . $e->getMessage();
    } catch (InvalidArgumentException $e) {
        $errors[] = "Description - " . $e->getMessage();
    }
    if ($_FILES) {
        $uploads_directory = 'img/uploads/';
        $filename = $uploads_directory . basename($_FILES['somefile']['name']);
        if (move_uploaded_file($_FILES['somefile']['tmp_name'], $filename)) {
            echo '<p>The file ' . basename($_FILES['somefile']['name']) . ' has been uploaded.</p>';
        } else {
            echo "Sorry, there was an error uploading your file.";
        }
    }
    if (empty($errors)) {
        // $user_id = (int)$_SESSION['user_id'];
        $new_ad = new Ad();
        $new_ad->name = $item;
        $new_ad->price = $price;
        $new_ad->image_url = $filename;
        $new_ad->description = $description;
        $new_ad->postdate = date('Y-m-d h:i');
        // $new_ad->user_id      = $user_id;
        $new_ad->save();
        header("Location: /");
        exit;
    }
}
Exemplo n.º 14
0
function pageController()
{
    session_start();
    if (!Auth::check()) {
        header('Location: /auth/login');
        exit;
    }
    $username = Auth::user();
    $user = User::findUserByUsername($username);
    $errors = array();
    if (!empty($_POST)) {
        $item_name = ValidateAd::getItemName();
        $price = ValidateAd::getPrice();
        $description = ValidateAd::getDescription();
        $contact = ValidateAd::getContact();
        $errors = ValidateAd::getErrors();
        $finfo = new finfo(FILEINFO_MIME_TYPE);
        try {
            $ext = array_search($finfo->file($_FILES['image']['tmp_name']), array('jpg' => 'image/jpeg', 'png' => 'image/png', 'gif' => 'image/gif'), true);
            if (false === $ext) {
                throw new RuntimeException('Invalid file format.');
            }
        } catch (RunTimeException $e) {
            $error = $e->getMessage();
            array_push($errors, $error);
        }
        $target = "public/upload_images";
        if (Input::notEmpty('item_name') && Input::notEmpty('price') && Input::notEmpty('description') && Input::notEmpty('contact')) {
            if (empty($errors)) {
                if (array_key_exists('image', $_FILES)) {
                    if ($_FILES["image"]["error"] == UPLOAD_ERR_OK) {
                        $tmp_name = $_FILES["image"]["tmp_name"];
                        $name = $_FILES["image"]["name"];
                        try {
                            if ($name != "jpg" && $name != "png" && $name != "jpeg" && $name != "gif") {
                                throw new RuntimeException('Invalid file format.');
                            }
                        } catch (RunTimeException $e) {
                            $error = $e->getMessage();
                            array_push($errors, $error);
                        }
                        move_uploaded_file($tmp_name, "{$target}/{$name}");
                    }
                } else {
                }
                $ad = new Ad();
                $ad->item_name = $item_name;
                $ad->price = $price;
                $ad->description = $description;
                $ad->contact = $contact;
                $ad->user_id = $user->attributes['id'];
                $ad->image_path = "{$target}/{$name}";
                $ad->save();
                // redirect from add to the users profile so they can see what they added
                header('Location: /users');
                exit;
            }
        }
    }
    return array('username' => $username, 'errors' => $errors);
}
Exemplo n.º 15
0
 /**
  * @before _secure
  */
 public function create()
 {
     $this->_create();
     $view = $this->getActionView();
     if (RM::type() == 'POST') {
         $img = null;
         // give preference to uploaded image
         $img = $this->_upload('image', 'images', ['extension' => 'jpe?g|gif|bmp|png|tif']);
         if (!$img) {
             $img_url = RM::post("image_url");
             $img = Shared\Utils::downloadImage($img_url);
         }
         if (!$img) {
             return $view->set('message', 'Failed to upload the image');
         }
         $expiry = RM::post('expiry');
         $campaign = new \Ad(['user_id' => RM::post('advert_id'), 'title' => RM::post('title'), 'description' => RM::post('description'), 'org_id' => $this->org->_id, 'url' => RM::post('url'), 'preview_url' => RM::post('preview_url'), 'category' => \Ad::setCategories(RM::post('category')), 'image' => $img, 'type' => RM::post('type', 'article'), 'device' => RM::post('device', ['all']), 'live' => false]);
         $visibility = RM::post('visibility', 'public');
         if ($visibility === "private") {
             $campaign->meta = ['private' => true];
         }
         $permission = RM::post('permission', false);
         if ($permission == "yes") {
             $campaign->meta = ['permission' => true];
         }
         if ($expiry) {
             $campaign->expiry = $expiry;
         }
         try {
             if ($campaign->type === "video") {
                 $url = RM::post('videoUrl');
                 $ytdl = new Downloader($url);
                 $campaign->getMeta()['processing'] = true;
                 $campaign->getMeta()['videoUrl'] = $ytdl->getUrl();
             }
         } catch (\Exception $e) {
             // Invalid URL
             return $view->set("errors", ['videoUrl' => ["Pass a valid youtube video URL"]]);
         }
         if (!$campaign->validate()) {
             return $view->set("errors", $campaign->errors);
         }
         $campaign->save();
         $models = RM::post('model');
         $comm_desc = RM::post('comm_desc');
         $revenue = RM::post('revenue');
         $rate = RM::post('rate');
         $coverage = RM::post('coverage');
         foreach ($models as $key => $value) {
             $commission = new \Commission(['ad_id' => $campaign->_id, 'description' => $comm_desc[$key], 'model' => $value, 'rate' => $this->currency($rate[$key]), 'revenue' => $this->currency($revenue[$key]), 'coverage' => $coverage[$key]]);
             $commission->save();
         }
         Registry::get("session")->set('$flashMessage', 'Campaign Created successfully!!');
         $this->redirect("/campaign/manage.html");
     }
 }
Exemplo n.º 16
0
 /**
  * Process the Meta table for campaign urls and create the
  * campaign from the corresponding URL
  */
 protected function importCampaigns()
 {
     $metas = \Meta::all(['prop = ?' => 'campImport']);
     $users = [];
     $orgs = [];
     foreach ($metas as $m) {
         $user = Usr::find($users, $m->propid, ['_id', 'org_id', 'email', 'meta']);
         $org = \Organization::find($orgs, $user->org_id);
         $categories = \Category::all(['org_id' => $org->_id], ['_id', 'name']);
         $categories = array_values($categories);
         $category = $categories[array_rand($categories)];
         // fetch ad info foreach URL
         $advert_id = $m->value['advert_id'];
         $comm = $m->value['campaign'] ?? $org->meta;
         if (!isset($comm['model']) || !isset($comm['rate'])) {
             continue;
         }
         $urls = $m->value['urls'];
         foreach ($urls as $url) {
             $ad = \Ad::first(['org_id' => $org->_id, 'url' => $url]);
             if ($ad) {
                 continue;
             }
             // already crawled URL may be due to failed cron earlier
             $data = Utils::fetchCampaign($url);
             $image = Utils::downloadImage($data['image']);
             if (!$image) {
                 $image = '';
             }
             $ad = new \Ad(['user_id' => $advert_id, 'org_id' => $org->_id, 'title' => $data['title'], 'description' => $data['description'], 'url' => $url, 'image' => $image, 'category' => [$category->_id], 'type' => 'article', 'live' => false, 'device' => ['ALL']]);
             if ($ad->validate()) {
                 $ad->save();
                 $rev = $comm['revenue'] ?? 1.25 * (double) $comm['rate'];
                 $commission = new \Commission(['ad_id' => $ad->_id, 'model' => $comm['model'], 'rate' => $comm['rate'], 'revenue' => round($rev, 6), 'coverage' => ['ALL']]);
                 $commission->save();
             } else {
                 var_dump($ad->getErrors());
             }
         }
         $msg = 'Campaigns imported for the user: ' . $user->email;
         $this->log($msg);
         $m->delete();
     }
 }