Exemple #1
0
function search($n)
{
    global $number;
    global $formula;
    global $sentinels;
    global $commutations;
    if (1 == $n) {
        if (abs($number[0] - 24) <= PRECISION) {
            $fml = convertRPN2Infix($formula[0]);
            if (check_exist($fml, $sentinels) && check_commutation($fml, $commutations)) {
                $sentinels[] = $fml;
                echo $fml;
                echo "<br>";
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else {
        for ($i = 0; $i < $n; $i++) {
            for ($j = $i + 1; $j < $n; $j++) {
                $a = $number[$i];
                $b = $number[$j];
                $number[$j] = $number[$n - 1];
                $formula_a = $formula[$i];
                $formula_b = $formula[$j];
                $formula[$j] = $formula[$n - 1];
                $formula[$i] = $formula_a . $formula_b . '+';
                $number[$i] = $a + $b;
                search($n - 1);
                $formula[$i] = $formula_a . $formula_b . '-';
                $number[$i] = $a - $b;
                search($n - 1);
                $formula[$i] = $formula_b . $formula_a . '-';
                $number[$i] = $b - $a;
                search($n - 1);
                $formula[$i] = $formula_a . $formula_b . '*';
                $number[$i] = $a * $b;
                search($n - 1);
                if ($b != 0) {
                    $formula[$i] = $formula_a . $formula_b . '/';
                    $number[$i] = $a / $b;
                    search($n - 1);
                }
                if ($a != 0) {
                    $formula[$i] = $formula_b . $formula_a . '/';
                    $number[$i] = $b / $a;
                    search($n - 1);
                }
                $number[$i] = $a;
                $number[$j] = $b;
                $formula[$i] = $formula_a;
                $formula[$j] = $formula_b;
            }
        }
        return false;
    }
}
Exemple #2
0
function search($n)
{
    global $number;
    global $formula;
    global $sentinels;
    if (1 == $n) {
        if (abs($number[0] - 24) <= PRECISION) {
            $fml = escape_brackets($formula[0]);
            if (check_exist($fml, $sentinels)) {
                $sentinels[] = $fml;
                print_formula($fml);
                var_dump($fml);
                echo "<br>";
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else {
        for ($i = 0; $i < $n; $i++) {
            for ($j = $i + 1; $j < $n; $j++) {
                $a = $number[$i];
                $b = $number[$j];
                $number[$j] = $number[$n - 1];
                $formula_a = $formula[$i];
                $formula_b = $formula[$j];
                $formula[$j] = $formula[$n - 1];
                $formula[$i] = $formula_a . $formula_b . '+';
                $number[$i] = $a + $b;
                search($n - 1);
                $formula[$i] = $formula_a . $formula_b . '-';
                $number[$i] = $a - $b;
                search($n - 1);
                $formula[$i] = $formula_b . $formula_a . '-';
                $number[$i] = $b - $a;
                search($n - 1);
                $formula[$i] = $formula_a . $formula_b . '*';
                $number[$i] = $a * $b;
                search($n - 1);
                if ($b != 0) {
                    $formula[$i] = $formula_a . $formula_b . '/';
                    $number[$i] = $a / $b;
                    search($n - 1);
                }
                if ($a != 0) {
                    $formula[$i] = $formula_b . $formula_a . '/';
                    $number[$i] = $b / $a;
                    search($n - 1);
                }
                $number[$i] = $a;
                $number[$j] = $b;
                $formula[$i] = $formula_a;
                $formula[$j] = $formula_b;
            }
        }
        return false;
    }
}
Exemple #3
0
}
//Function check good password
function check_Password_complex($pass)
{
    if (strlen($pass) < 8 || !preg_match("#[0-9]+#", $pass) || !preg_match("#[a-zA-Z]+#", $pass)) {
        exit("false");
        //
    } else {
        exit("true");
        //.
    }
}
//Check username avalaible
if (Mreq::tp('f') != null && Mreq::tp('f') != 'pass') {
    $champs = Mreq::tp('f');
    $table = Mreq::tp('t');
    $value = Mreq::tp($champs);
    //exit($champs.' '.$table.' '.$value);
    check_exist($table, $champs, $value, Mreq::tp('isedit'));
}
if (Mreq::tp('f') == "pass") {
    check_Password_complex(Mreq::tp('pass'));
}
/*//Check username avalaible

//Check email adress exist for existing account
if(Mreq::tp('f') == "mail"){check_exist('users_sys', 'mail', Mreq::tp('email'), Mreq::tp('isedit'));}
//Check app task exist for existing  task
if(Mreq::tp('f') == "app"){check_exist('users_sys', 'mail', Mreq::tp('email'), Mreq::tp('isedit'));}
//Check password is good
if(Mreq::tp('f') == "pass"){check_Password_complex(Mreq::tp('pass'));}*/
function calculate_ratings($seller_id)
{
    $arr = seller_total($seller_id);
    if ($arr['count'] > 0) {
        $rate = $arr['sum'] / $arr['count'];
    } else {
        $rate = 0;
    }
    return round($rate);
}
if (Params::getParam('seller_rating') == "submit_it") {
    if (osc_is_web_user_logged_in()) {
        $user = Params::getParam('rating_user');
        $seller = Params::getParam('rating_seller');
        $rating = Params::getParam('rating_data');
        if (check_exist($user, $seller)) {
            //UPDATE DATA
            update_rating($seller, $user, $rating);
        } else {
            //INSERT DATA
            insert_rating($seller, $user, $rating);
        }
    }
}
?>


<!-- HTML CODE -->


<!-- JS to add -->
</td>
                                               <td><?php 
        echo $row_menu['menu_name'];
        ?>
</td>
                                               <td><?php 
        echo $row_menu['menu_type_name'];
        ?>
</td>
                                               <td style="text-align:right;"><?php 
        echo number_format($row_menu['menu_price'], 0);
        ?>
</td>
                                               <td style="text-align:center;">
                                                    <?php 
        $check_status = check_exist($id, $row_menu['menu_id']);
        ?>
                                                   <input type="checkbox" name="i_check_<?php 
        echo $row_menu['menu_id'];
        ?>
" value="1" <?php 
        if ($check_status > 0) {
            ?>
checked="checked"<?php 
        }
        ?>
>

                                                </td> 
                                            </tr>
                                            <?php 
     $id = get_isset($_GET['id']);
     $i_name = get_isset($i_name);
     $i_phone = get_isset($i_phone);
     $i_email = get_isset($i_email);
     $i_settlement = get_isset($i_settlement);
     $i_discount = get_isset($i_discount);
     $i_discount_type = get_isset($i_discount_type);
     $data = " member_name = '{$i_name}',\n\t\t\t\t\t\t\tmember_phone = '{$i_phone}',\n\t\t\t\t\t\t\tmember_email = '{$i_email}',\n\t\t\t\t\t\t\tmember_settlement = '{$i_settlement}',\n\t\t\t\t\t\t\tmember_discount = '{$i_discount}',\n\t\t\t\t\t\t\tmember_discount_type = '{$i_discount_type}'\n\t\t\t\t\t\t\t";
     update($data, $id);
     $query_partner = select_partner();
     while ($row_partner = mysql_fetch_array($query_partner)) {
         $query_menu = mysql_query("select a.*, b.menu_type_name\n                                                from menus a    \n                                                join menu_types b on b.menu_type_id = a.menu_type_id\n                                                where partner_id = '" . $row_partner['partner_id'] . "'\n                                                order by menu_id");
         while ($row_menu = mysql_fetch_array($query_menu)) {
             $i_check = isset($_POST['i_check_' . $row_menu['menu_id']]) ? $_POST['i_check_' . $row_menu['menu_id']] : "";
             if ($i_check) {
                 $check_exist = check_exist($id, $row_menu['menu_id']);
                 if ($check_exist == 0) {
                     $data = "'',\n\t\t\t\t\t\t\t\t\t'{$id}',\n\t\t\t\t\t\t\t\t\t'" . $row_menu['menu_id'] . "'\n\t\t\t\t\t\t\t";
                     create_item($data);
                 }
             } else {
                 delete_member_item($id, $row_menu['menu_id']);
             }
         }
     }
     header("Location: member.php");
     break;
 case 'delete':
     $id = get_isset($_GET['id']);
     delete($id);
     header('Location: member.php?page=list&did=3');
Exemple #7
0
function calculate_ratings($item_id)
{
    $arr = item_total($item_id);
    if ($arr['count'] > 0) {
        $rate = $arr['sum'] / $arr['count'];
    } else {
        $rate = 0;
    }
    return round($rate);
}
if (Params::getParam('item_rating') == "submit_it") {
    if (osc_is_web_user_logged_in()) {
        $user = Params::getParam('rating_user');
        $item = Params::getParam('rating_item');
        $rating = Params::getParam('rating_data');
        if (check_exist($user, $item)) {
            //UPDATE DATA
            update_rating($item, $user, $rating);
        } else {
            //INSERT DATA
            insert_rating($item, $user, $rating);
        }
    }
}
?>



<!-- HTML CODE -->

Exemple #8
0
    if ($result == "0") {
        exit("true");
        //."SELECT * FROM $table where $colomn = '$value'");  //good to register
    } else {
        exit("false");
        //."SELECT * FROM $table where $colomn = '$value'"); //already registered
    }
}
//Function check good password
function check_Password_complex($pass)
{
    if (strlen($pass) < 8 || !preg_match("#[0-9]+#", $pass) || !preg_match("#[a-zA-Z]+#", $pass)) {
        exit("false");
        //
    } else {
        exit("true");
        //.
    }
}
//Check username avalaible
if (Mreq::tp('f') == "user") {
    check_exist('users_sys', 'nom', Mreq::tp('pseudo'), Mreq::tp('isedit'));
}
//Check email adress exist for existing account
if (Mreq::tp('f') == "mail") {
    check_exist('users_sys', 'mail', Mreq::tp('email'), Mreq::tp('isedit'));
}
//Check password is good
if (Mreq::tp('f') == "pass") {
    check_Password_complex(Mreq::tp('pass'));
}