예제 #1
0
        if ($_POST['old_countries'][$i] != $_POST['new_countries'][$i]) {
            $query = "UPDATE " . $DBPrefix . "countries SET\n\t\t\t\t\tcountry = :country_new\n\t\t\t\t\tWHERE country = :country_old";
            $params = array();
            $params[] = array(':country_new', $system->cleanvars($_POST['new_countries'][$i]), 'str');
            $params[] = array(':country_old', $system->cleanvars($_POST['old_countries'][$i]), 'str');
            $db->query($query, $params);
        }
    }
    // If a new country was added, insert it into database
    if (!empty($_POST['new_countries'][count($_POST['new_countries']) - 1])) {
        $query = "INSERT INTO " . $DBPrefix . "countries (country) VALUES (:country)";
        $params = array();
        $params[] = array(':country', $system->cleanvars($_POST['new_countries'][count($_POST['new_countries']) - 1]), 'str');
        $db->query($query, $params);
    }
    rebuild_html_file('countries');
    $ERR = $MSG['1028'];
}
include $main_path . 'language/' . $language . '/countries.inc.php';
foreach ($countries as $country) {
    // check if the country is being used by a user
    $query = "SELECT id FROM " . $DBPrefix . "users WHERE country = :country LIMIT 1";
    $params = array();
    $params[] = array(':country', $country, 'str');
    $db->query($query, $params);
    $USEDINUSERS = $db->numrows();
    $template->assign_block_vars('countries', array('COUNTRY' => $country, 'SELECTBOX' => $USEDINUSERS == 0 ? '<input type="checkbox" name="delete[]" value="' . $country . '">' : '<img src="../images/nodelete.gif" alt="You cannot delete this">'));
}
$template->assign_vars(array('ERROR' => isset($ERR) ? $ERR : ''));
$template->set_filenames(array('body' => 'countries.tpl'));
$template->display('body');
예제 #2
0
        if ($old_countries[$i] != $new_countries[$i]) {
            $sqlstr = "UPDATE " . $DBPrefix . "countries SET\r\n\t  country = '" . $system->cleanvars($new_countries[$i]) . "'\r\n\t  WHERE country = '" . $system->cleanvars($old_countries[$i]) . "'";
            $DBGSTR .= "<br>" . $sqlstr;
            $result = mysql_query($sqlstr);
        }
    }
    /* If a new country was added, insert it into database */
    if ($new_countries[count($new_countries) - 1]) {
        $sqlstr = "INSERT INTO " . $DBPrefix . "countries (country) VALUES ('";
        $sqlstr .= $system->cleanvars($new_countries[count($new_countries) - 1]) . "');";
        $result = mysql_query($sqlstr);
        if (!$result) {
            $TPL_info_err = $ERR_001;
        }
    }
    rebuild_html_file("countries");
}
include $include_path . "countries.inc.php";
?>
<HTML>
<HEAD>
<link rel='stylesheet' type='text/css' href='style.css' />
<SCRIPT type="text/javascript">
function selectAll(formObj, isInverse) 
{
   for (var i=0;i < formObj.length;i++) 
   {
      fldObj = formObj.elements[i];
      if (fldObj.type == 'checkbox' && fldObj.name.substring(0,6)=='delete')
      { 
         if(isInverse)