Exemplo n.º 1
0
} elseif (!empty($_POST['submit']) && empty($error)) {
    $cells = array('partner_name', 'categories_id', 'partner_url', 'partner_alt', 'partner_text', 'partner_priority');
    $values = array($_POST['partner_name'], $categories_id, $_POST['partner_url'], $_POST['partner_alt'], $_POST['partner_text'], $_POST['partner_priority']);
    cs_sql_insert(__FILE__, 'partner', $cells, $values);
    // upload navlist-image
    $where = "partner_name = '" . cs_sql_escape($data['partner']['partner_name']) . "'";
    $getid = cs_sql_select(__FILE__, 'partner', 'partner_id', $where);
    if (!empty($files['partner_nimg']['tmp_name'])) {
        $filename_navimg = 'navbanner-' . $getid['partner_id'] . '.' . $extension_nimg;
        cs_upload('partner', $filename_navimg, $files['partner_nimg']['tmp_name'], 0);
        $cells_navimg = array('partner_nimg');
        $values_navimg = array($filename_navimg);
        cs_sql_update(__FILE__, 'partner', $cells_navimg, $values_navimg, $getid['partner_id']);
    }
    if (!empty($files['partner_limg']['tmp_name'])) {
        $filename_listimg = 'listbanner-' . $getid['partner_id'] . '.' . $extension_limg;
        cs_upload('partner', $filename_listimg, $files['partner_limg']['tmp_name'], 0);
        $cells_listimg = array('partner_limg');
        $values_listimg = array($filename_listimg);
        cs_sql_update(__FILE__, 'partner', $cells_listimg, $values_listimg, $getid['partner_id']);
    }
    if (!empty($files['partner_rimg']['tmp_name'])) {
        $filename_rotimg = 'rotbanner-' . $getid['partner_id'] . '.' . $extension_rimg;
        cs_upload('partner', $filename_rotimg, $files['partner_rimg']['tmp_name'], 0);
        $cells_rotimg = array('partner_rimg');
        $values_rotimg = array($filename_rotimg);
        cs_sql_update(__FILE__, 'partner', $cells_rotimg, $values_rotimg, $getid['partner_id']);
    }
    cs_ajaxfiles_clear();
    cs_redirect($cs_lang['create_done'], 'partner');
}
Exemplo n.º 2
0
function cs_upload($mod, $filename, $upname, $ajaxclean = 1)
{
    global $cs_main;
    $path = $cs_main['def_path'] . '/uploads/' . $mod . '/';
    $target = $path . $filename;
    $bool = empty($_SESSION['ajaxuploads']) ? move_uploaded_file($upname, $target) : rename($upname, $target);
    if ($bool) {
        chmod($target, 0755);
        $return = true;
    } else {
        $message = is_writable($path) ? 'cs_upload - Failed to save the file' : 'cs_upload - Failed to save the file because of missing permission';
        cs_error($target, $message);
        $return = false;
    }
    if (!empty($ajaxclean)) {
        cs_ajaxfiles_clear();
    }
    return $return;
}