$msg = "<div class='alert alert-error' id='error_box'>" . $msg . "</div>";
 } else {
     $gbizObj = new Business();
     $package = $gbizObj->getPkg($requested_pkg);
     $gbizObj->setBizInfo($id, $title, $tagline, $category, $subCategory, $description, $listingUrl);
     $gbizObj->setContactInfo($email, $phone, $fax, $mobile, $contactP);
     $gbizObj->setLocationInfo($street, $city, $country, $zip, $latitude, $longitude);
     $gbizObj->setKeywordInfo($keywords);
     $gbizObj->setPkg($package);
     $result = $gbizObj->add();
     // Cause insert a new business record in to the database
     if ($result) {
         $bizId = $gbizObj->business_id;
         $gbannerObj = new Banner();
         $gbannerObj->setBannerInfo($banerType, $caption, $adUrl, $bizId, $id);
         $gbannerObj->add();
         $bannerId = $gdbObj->insert_id();
         $msg .= "<b>You have successfully added a new business with the Id of " . $bizId . "</b>";
         $msg = "<div class='alert alert-info' id='error_box'>" . $msg . "</div>";
         //upload the logo file
         mkdir(SITE_ROOT . "/biz/{$bizId}", 0755);
         $tmp_file = $_FILES['file_upload']['tmp_name'];
         $originalFile = basename($_FILES['file_upload']['name']);
         $extension = substr($originalFile, strripos($originalFile, '.'), strlen($originalFile));
         $renamedFile = "logo" . $extension;
         $upload_dir = "biz/{$bizId}";
         move_uploaded_file($tmp_file, $upload_dir . "/" . $renamedFile);
         //upload banner image file
         $tmp_file = $_FILES['banner_upload']['tmp_name'];
         $originalFile = basename($_FILES['banner_upload']['name']);
         $extension = substr($originalFile, strripos($originalFile, '.'), strlen($originalFile));
 $adUrl = $urlProtocol . $destination;
 if ($destination == NULL) {
     $adUrl = "";
 } else {
     if ($destination != NULL && !$gvalObj->isURL($adUrl)) {
         $msg = $msg . "Invalid banner URL<br>";
         $status = "NOTOK";
     }
 }
 if ($status == "NOTOK") {
     $msg = "<div class='alert alert-error' id='error_box'>" . $msg . "</div>";
 } else {
     $gbannerObj = new Banner();
     $gbannerObj->setListingId($lid);
     $gbannerObj->setBannerInfo($banerType, $caption, $adUrl);
     $result = $gbannerObj->add();
     $bannerID = $gbannerObj->getBannerId();
     if ($result) {
         //upload banner image file
         $tmp_file = $_FILES['banner_upload']['tmp_name'];
         $originalFile = basename($_FILES['banner_upload']['name']);
         $extension = substr($originalFile, strripos($originalFile, '.'), strlen($originalFile));
         $renamedFile = $bannerID . "" . $extension;
         $upload_dir = "ads/{$banerType}";
         move_uploaded_file($tmp_file, $upload_dir . "/" . $renamedFile);
         $msg .= "<b>Listing updated successfully</b>";
         $msg = "<div class='alert alert-info'>" . $msg . "</div>";
     } else {
         $msg .= "An error occurred while updating data. Please try again.";
         $msg = "<div class='alert alert-error' id='error_box'>" . $msg . "</div>";
     }
示例#3
0
$data = new Banner();
require_once '../../models/BannerCategoria.php';
$bannerCategoria = new BannerCategoria();
require_once '../../models/Imagem.php';
$imagem = new Imagem();
foreach ($_REQUEST as $key => $value) {
    if (!is_array($value)) {
        $_REQUEST[$key] = utf8_decode($value);
    } elseif (is_array($value)) {
        foreach ($value as $key2 => $value2) {
            $_REQUEST[$key][$key2] = utf8_decode($value2);
        }
    }
}
if ($_REQUEST['acao'] == 1 && $_REQUEST['operacao'] == 2) {
    if ($data->add()) {
        echo json_encode(array('success' => 1));
    } else {
        echo json_encode(array('success' => 0));
    }
} elseif ($_REQUEST['acao'] == 2 && $_REQUEST['operacao'] == 2) {
    if ($data->edit()) {
        echo json_encode(array('success' => 1));
    } else {
        echo json_encode(array('success' => 0));
    }
} elseif ($_REQUEST['acao'] == 3 && $_REQUEST['operacao'] == 2) {
    if ($data->delete()) {
        echo json_encode(array('success' => 1));
    } else {
        echo json_encode(array('success' => 0));
 */
ini_set('error_reporting', E_ALL);
include "includes/functions.php";
include "includes/classes/class.banner.php";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    /*echo "<pre>";
    		print_r($_POST);
    		print_r($_FILES); exit;*/
    $banner = new Banner();
    $arrData = array();
    $arrData['name'] = addslashes(ucwords($_POST['name']));
    $arrData['details'] = addslashes($_POST['details']);
    $arrData['status'] = addslashes($_POST['status']);
    if (empty($_POST['id'])) {
        $arrData['added_date'] = date('Y-m-d H:i:s');
        $insert = $banner->add($arrData);
        if ($insert) {
            $cover = '';
            if ($_FILES['image']['name'] != '') {
                $cover = 'banner_' . $insert . '.jpg';
                saveBannerImage($_FILES['image'], $insert, 'banner');
            }
            $_SESSION['insert_banner'] = 'added';
        } else {
            $_SESSION['insert_banner'] = 'insert_faild';
        }
    } else {
        $arrData['id'] = $_POST['id'];
        // $arrData['banner'] = 'banner_' . $_POST['id'] . '.jpg';
        if ($_FILES['image']['name'] != '') {
            $cover = 'banner_' . $arrData['id'] . '.jpg';