Ejemplo n.º 1
0
    case "register":
        reg();
        break;
    case "login":
        logi();
        break;
    case "logout":
        $_SESSION = array();
        session_destroy();
        header("Location: ?");
        // pealehele
        break;
    case "post":
        kuva_post();
        break;
    case "posts":
        kuva_postitused();
        break;
    case "postit":
        post_it();
        break;
    case "edit":
        edit_post();
        break;
    default:
        $postitused = hangi_postitused();
        include "views/head.html";
        include "views/pealeht.html";
        include "views/foot.html";
        break;
}
Ejemplo n.º 2
0
    // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    // THE SOFTWARE.
    function post_it($content)
    {
        $url1 = "https://api.filter8.com/content/item.js";
        $timestamp = time();
        $nonceParam = 'nonce=' . $timestamp;
        $url = $url1 . '?' . $nonceParam;
        $credentials = "0c0a793e693148ca89b690e17c01145f" . ':' . md5($timestamp . "0af7106099014e5cac9347b093c32862");
        $data = 'content=' . urlencode($content);
        // construct the url request
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        curl_setopt($ch, CURLOPT_USERPWD, $credentials);
        curl_setopt($ch, CURLOPT_POST, TRUE);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        $response = curl_exec($ch);
        curl_close($ch);
        $response_json = json_decode($response);
        // return the json object
        return $response_json;
    }
    $my_sentence = $_POST['my_sentence'];
    $response = post_it($my_sentence);
    $response = $response . filter . response;
    echo $response;
}