Пример #1
0
 function getList($catid, $selected = '')
 {
     $html = '';
     $html = '<ul id="checkList_' . $catid . '" class="chk-list-wrap light clear_fix">';
     $result = returnResult($catid);
     if (!empty($result)) {
         foreach ($result as $cat) {
             $idOne = $cat->id;
             $checked = backChecked($idOne, $selected);
             $html .= '<li><strong class="titles">' . $cat->category_name . '</strong><div class="checkbox chk-all">
                                     <label><input class="' . $cat->category_name . '" name="isCheckedAll" id="' . $cat->id . '"  class="' . $cat->category_name . '" type="checkbox" id="' . $cat->id . '" value="' . $cat->id . '"' . $checked . '><span>All From &nbsp;' . $cat->category_name . '</span></label>
                                 </div>';
             $result_sub = returnResult($idOne);
             if (!empty($result_sub)) {
                 $html .= '<ul class="sub sub1">';
                 foreach ($result_sub as $sub_cat) {
                     $id = $sub_cat->id;
                     $checked = backChecked($id, $selected);
                     $html .= ' <li><div class="checkbox">';
                     $html .= '<label class="checkit"  name="' . $sub_cat->category_name . '" id="' . $sub_cat->id . '"><input name="check_added"  class="' . $sub_cat->category_name . '" type="checkbox" id="' . $sub_cat->id . '" value="' . $sub_cat->id . '"' . $checked . '><span>' . $sub_cat->category_name . '</span></label>';
                     $html .= '</div>';
                     $result_sub_2 = returnResult($id);
                     if (!empty($result_sub_2)) {
                         $html .= '<ul class="sub sub2">';
                         foreach ($result_sub_2 as $sub_cat_2) {
                             $id = $sub_cat_2->id;
                             $checked = backChecked($id, $selected);
                             $html .= '<li><div class="checkbox">';
                             $html .= '<label class="checkit" name="' . $sub_cat_2->category_name . '" id="' . $sub_cat_2->id . '"><input name="check_added"  class="' . $sub_cat_2->category_name . '" type="checkbox" id="' . $sub_cat_2->id . '" name="' . $sub_cat_2->id . '" value="' . $sub_cat_2->id . '"' . $checked . '><span>' . $sub_cat_2->category_name . '</span></label>';
                             $html .= '</div></li>';
                             $result_sub_3 = returnResult($id);
                             if (!empty($result_sub_3)) {
                                 $html .= '<ul class="sub sub3">';
                                 foreach ($result_sub_3 as $sub_cat_3) {
                                     $checked = backChecked($sub_cat_3->id, $selected);
                                     $html .= '<li><div class="checkbox">';
                                     $html .= '<label class="checkit" name="' . $sub_cat_3->category_name . '" id="' . $sub_cat_3->id . '"><input name="check_added"  class="' . $sub_cat_3->category_name . '" type="checkbox" id="' . $sub_cat_3->id . '" name="' . $sub_cat_3->id . '" value="' . $sub_cat_3->id . '"><span>' . $sub_cat_3->category_name . '</span></label>';
                                     $html .= '</div></li>';
                                 }
                                 $html .= '</ul>';
                             }
                             $html .= '</li>';
                         }
                         $html .= '</ul>';
                     }
                     $html .= '</li>';
                 }
                 $html .= '</ul>';
             }
             $html .= '</li>';
         }
     }
     $html .= '</ul>';
     return $html;
 }
Пример #2
0
    // loop through each request, stop & return the first error if encountered
    foreach ($requests as $action => $data) {
        if ($data == null) {
            $data = new stdClass();
        }
        $tempresult = routeApiCall($action, $data, $result);
        if ($tempresult['error'] == "OK") {
            // set data and move to the next request
            $result['data'][$action] = $tempresult['data'];
        } else {
            $result['error'] = $tempresult['error'];
            break;
        }
    }
}
returnResult($result);
// API FUNCTIONS
/**
 * routes api calls and returns the result, allows for multiple API calls at once
 * @param $action
 * @param $data
 * @param $result
 * @return array|mixed
 */
function routeApiCall($action, $data, $result)
{
    global $auth;
    $notinprev = false;
    switch ($action) {
        case 'register':
            $wCust = new WposCustomerAccess($data);
Пример #3
0
<?php

require_once 'recaptchalib.php';
$privatekey = "xxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxx";
// Insert your reCaptcha private key
function returnResult($status, $message)
{
    $result = array('status' => $status, 'message' => $message);
    echo json_encode($result);
    exit;
}
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["challenge"], $_POST["captcha"]);
if (!$resp->is_valid) {
    $status = 0;
    $message = "Captcha is not correct";
    returnResult($status, $message);
} else {
    $status = 1;
    $message = "Captcha is correct";
    returnResult($status, $message);
}
Пример #4
0
		<p><h1>Homework #2</h2></p>
		<p><input type = "text" name="num_one" value="0"><h4>X</h4></input></br></p>
		<p><input type ="text" name="num_two" value="0"><h4>Y</h4></input></br></p>
		<input type = "submit" name ="function" value="+"></input>
		<input type = "submit" name = "function" value="-"></input>
		<input type = "submit" name = "function" value="*"></input>
		<input type = "submit" name = "function" value ="/"></input>
		<input type = "submit" name = "function" value ="^"></input>

		</br></br>
		<p><h2>Output of Arithmetic</h2></p>
		<?php 
if (is_numeric($_GET["num_one"]) && is_numeric($_GET["num_two"])) {
    if ($_GET["num_one"] >= 0 && $_GET["num_two"] >= 0) {
        if (isset($_GET["function"])) {
            returnResult($_GET["num_one"], $_GET["num_two"], $_GET["function"]);
        } else {
            echo "<h3>Not available yet?</h3>";
        }
    } else {
        echo "<h3>No Negatives!!</p><h3>";
    }
} else {
    echo "Enter Numeric numbers.";
}
function returnResult($var1, $var2, $operand)
{
    switch ($operand) {
        case '+':
            $result = $var1 + $var2;
            echo "<h3>{$var1} + {$var2} = {$result}</h3>";
Пример #5
0
    $sth = $db->prepare('SELECT * FROM bookmark WHERE id = ? LIMIT 1;');
    $sth->execute([intval($id)]);
    echo json_encode($sth->fetchAll(PDO::FETCH_CLASS)[0]);
});
$app->post('/bookmark', function () use($db, $app) {
    $title = $app->request()->post('title');
    $sth = $db->prepare('INSERT INTO bookmark (url, title) VALUES (?, ?);');
    $sth->execute([$url = $app->request()->post('url'), empty($title) ? getTitleFromUrl($url) : $title]);
    saveFavicon($url, $id = $db->lastInsertId());
    returnResult('add', $sth->rowCount() == 1, $id);
});
$app->put('/bookmark/:id', function ($id) use($db, $app) {
    $sth = $db->prepare('UPDATE bookmark SET title = ?, url = ? WHERE id = ?;');
    $sth->execute([$app->request()->post('title'), $url = $app->request()->post('url'), intval($id)]);
    saveFavicon($url, $id);
    returnResult('add', $sth->rowCount() == 1, $id);
});
$app->delete('/bookmark/:id', function ($id) use($db) {
    $sth = $db->prepare('DELETE FROM bookmark WHERE id = ?;');
    $sth->execute([intval($id)]);
    unlink("../icons/{$id}.ico");
    returnResult('delete', $sth->rowCount() == 1, $id);
});
$app->get('/install', function () use($db) {
    $db->exec('	CREATE TABLE IF NOT EXISTS bookmark (
					id INTEGER PRIMARY KEY, 
					title TEXT, 
					url TEXT UNIQUE);');
    returnResult('install');
});
$app->run();
Пример #6
0
        } else {
            if (isset($_GET["subtract"])) {
                returnResult($_GET["num_one"], $_GET["num_two"], "-");
            } else {
                if (isset($_GET["multiply"])) {
                    returnResult($_GET["num_one"], $_GET["num_two"], "*");
                } else {
                    if (isset($_GET["divide"])) {
                        if ($_GET["num_two"] > 0) {
                            returnResult($_GET["num_one"], $_GET["num_two"], "/");
                        } else {
                            echo "<h3>Can not divide by zero</h3>";
                        }
                    } else {
                        if (isset($_GET["power"])) {
                            returnResult($_GET["num_one"], $_GET["num_two"], "^");
                        } else {
                            echo "<h3>Not available yet?</h3>";
                        }
                    }
                }
            }
        }
    } else {
        echo "<h3>No Negatives!!</p><h3>";
    }
} else {
    echo "Enter Numeric numbers.";
}
function returnResult($var1, $var2, $operand)
{