Exemplo n.º 1
0
         }
         header('Location:index.php?ac=3');
         exit;
     } else {
         header('Location:index.php?ac=1&f=' . urlencode('index.php?ac=3'));
         exit;
     }
     break;
 case '7':
     // create category
     if (!referer_check()) {
         die;
     }
     if (admin_check()) {
         if ($category_name != 'general') {
             category_create($category_name);
         }
         header('Location:index.php?ac=3');
         exit;
     } else {
         header('Location:index.php?ac=1&f=' . urlencode('index.php?ac=3'));
         exit;
     }
     break;
 case '8':
     // save blog
     if (!referer_check()) {
         die;
     }
     if (admin_check()) {
         if (!empty($blog_serial)) {
function product_post()
{
    global $txp_user, $vars, $txpcfg, $prefs;
    extract($prefs);
    define("IMPATH", $path_to_site . '/' . $img_dir . '/');
    $incoming = psa($vars);
    $import = false;
    $message = '';
    $wrapper = new TXP_Wrapper();
    $incoming = $wrapper->textile_main_fields($incoming, $use_textile);
    extract(doSlash($incoming));
    extract(array_map('assert_int', psa(array('Status', 'textile_body', 'textile_excerpt'))));
    $Annotate = ps('Annotate') ? assert_int(ps('Annotate')) : 0;
    if ($import) {
        $Status = $product['Status'];
    }
    $when = 'now()';
    if ($Title or $Body or $Excerpt) {
        if (!has_privs('article.publish') && $Status >= 4) {
            $Status = 3;
        }
        if (empty($url_title)) {
            $url_title = stripSpace($Title_plain, 1);
        }
        if (!$Annotate) {
            $Annotate = 0;
        }
        if (isset($new_category_name) && !empty($new_category_name)) {
            $Category1 = $new_category_name;
            category_create($Category1, "Products");
        } else {
            if (isset($category)) {
                $Category1 = $category;
            }
        }
        if (isset($new_vendor_name) && !empty($new_vendor_name)) {
            $Category2 = $new_vendor_name;
            category_create($Category2, "Vendors");
        } else {
            if (isset($vendor)) {
                $Category2 = $vendor;
            }
        }
        safe_insert("textpattern", "Title           = '{$Title}',\r\n\t\t\t\tBody            = '{$Body}',\r\n\t\t\t\tBody_html       = '{$Body_html}',\r\n\t\t\t\tExcerpt         = '{$Excerpt}',\r\n\t\t\t\tExcerpt_html    = '{$Excerpt_html}',\r\n\t\t\t\tImage           = '{$Image}',\r\n\t\t\t\tKeywords        = '{$Keywords}',\r\n\t\t\t\tStatus          =  {$Status},\r\n\t\t\t\tPosted          =  {$when},\r\n\t\t\t\tLastMod         =  now(),\r\n\t\t\t\tAuthorID        = '{$txp_user}',\r\n\t\t\t\tSection         = '{$Section}',\r\n\t\t\t\tCategory1       = '{$Category1}',\r\n\t\t\t\tCategory2       = '{$Category2}',\r\n\t\t\t\ttextile_body    =  {$textile_body},\r\n\t\t\t\ttextile_excerpt =  {$textile_excerpt},\r\n\t\t\t\tAnnotate        =  {$Annotate},\r\n\t\t\t\toverride_form   = '{$override_form}',\r\n\t\t\t\turl_title       = '{$url_title}',\r\n\t\t\t\tAnnotateInvite  = '{$AnnotateInvite}',\r\n\t\t\t\tcustom_1        = '{$custom_1}',\r\n\t\t\t\tcustom_2        = '{$custom_2}',\r\n\t\t\t\tcustom_3        = '{$custom_3}',\r\n\t\t\t\tcustom_4        = '{$custom_4}',\r\n\t\t\t\tcustom_5        = '{$custom_5}',\r\n\t\t\t\tcustom_6        = '{$custom_6}',\r\n\t\t\t\tcustom_7        = '{$custom_7}',\r\n\t\t\t\tcustom_8        = '{$custom_8}',\r\n\t\t\t\tcustom_9        = '{$custom_9}',\r\n\t\t\t\tcustom_10       = '{$custom_10}',\r\n\t\t\t\tuid\t\t\t\t= '" . md5(uniqid(rand(), true)) . "',\r\n\t\t\t\tfeed_time\t\t= now()");
        $GLOBALS['ID'] = mysql_insert_id();
        $ID = $GLOBALS['ID'];
        //print_r($_FILES);
        //CUSTOM FIELDS
        save_custom_fields($_REQUEST['custom_fields'], $ID);
        //IMAGE UPLOAD
        //=======================
        if ($_FILES["uploadFile"]["type"] == "image/gif" || $_FILES["uploadFile"]["type"] == "image/jpeg" || $_FILES["uploadFile"]["type"] == "image/png") {
            // prepare the image for insertion
            $img = $_FILES['uploadFile']['tmp_name'];
            upload_image($img, 1, $ID);
        }
        //END IMAGE UPLOAD
        //=======================
        if ($Status >= 4) {
            if (!function_exists("do_pings")) {
                require_once txpath . '/include/txp_article.php';
                do_pings();
            }
            update_lastmod();
        }
        product_edit("", "", "Product Saved");
    } else {
        product_edit();
    }
}