<commit_before><?php
/*
 * Copyright (C) 2015 uClass Developers <NAME> & <NAME>
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

// Stop/fix cors error
header("Access-Control-Allow-Origin: *");

// If api key is correct connect to database and make sure it is coded in utf8
if ($_GET['apikey'] == "enter new key here please") {
   
    header("Content-type: application/json; charset=utf-8");
    $servername = "";
    $username = "";
    $password = "";
    $database = "";

    mysqli_set_charset("utf8");
    $con=mysqli_connect("$servername",$username, $password, $database);

   
  // Check connection
  if (mysqli_connect_errno())
  {
   echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
    if ($_GET['courses-slider'] == "1") {
      $query = "SELECT * FROM `wp_eter_courses_slider` ORDER BY `id` ASC";
      mysqli_query("SET names utf8;");
      mysqli_set_charset("utf8");
      mysqli_set_charset('utf8');
      $rs = mysqli_query($con,$query);

    if (mysqli_num_rows($rs) > 0) {
        $response["courses-slider"]= array();

        //Construct the Startpage array    
        while($obj = mysqli_fetch_array($rs)) {
          $info = array(
                "id" => $obj['id'], "title" => utf8_encode($obj['title']), "course" => utf8_encode($obj['course']), "image_url" => utf8_encode($obj['image_url']), "on_link" => utf8_encode($obj['on_link']), "row" => $obj['row'], "position" => $obj['position']

        );
         array_push($response["courses-slider"], $info);
        }

        $response["success"] = 1;
        header("Content-type: application/json; charset=utf-8");
        header("Access-Control-Allow-Origin: *");
        echo json_encode($response);
    } else {
        $response["success"] = 0;
        $response["message"] = "Inga slides hittades";
        header("Content-type: application/json; charset=utf-8");
        header("Access-Control-Allow-Origin: *");
        echo json_encode($response);
    }
} else if ($_GET['list-all-courses'] == "1") {
      $query = "SELECT * FROM `wp_term_taxonomy` WHERE parent=".$_GET['parent']." ORDER BY `term_id` ASC";
      mysqli_query("SET names utf8;");
      mysqli_set_charset("utf8");
      mysqli_set_charset('utf8');
      $rs = mysqli_query($con,$query);
      
      $all_courses_posts_url= "http://eter.rudbeck.info/category/kurser/?json=1&count=10&apikey=ErtYnDsKATCzmuf6";
      $json_elements = file_get_contents($all_courses_posts_url);
      $elements_arr = json_decode($json_elements, TRUE);<commit_msg>added  column "description" to courses slider api<commit_after><?php
/*
 * Copyright (C) 2015 uClass Developers <NAME> & <NAME>
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

// Stop/fix cors error
header("Access-Control-Allow-Origin: *");

// If api key is correct connect to database and make sure it is coded in utf8
if ($_GET['apikey'] == "enter new key here please") {
   
    header("Content-type: application/json; charset=utf-8");
    $servername = "";
    $username = "";
    $password = "";
    $database = "";

    mysqli_set_charset("utf8");
    $con=mysqli_connect("$servername",$username, $password, $database);

   
  // Check connection
  if (mysqli_connect_errno())
  {
   echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
    if ($_GET['courses-slider'] == "1") {
      $query = "SELECT * FROM `wp_eter_courses_slider` ORDER BY `id` ASC";
      mysqli_query("SET names utf8;");
      mysqli_set_charset("utf8");
      mysqli_set_charset('utf8');
      $rs = mysqli_query($con,$query);

    if (mysqli_num_rows($rs) > 0) {
        $response["courses-slider"]= array();

        //Construct the Startpage array    
        while($obj = mysqli_fetch_array($rs)) {
          $info = array(
                "id" => $obj['id'], "title" => utf8_encode($obj['title']), "course" => utf8_encode($obj['course']), "image_url" => utf8_encode($obj['image_url']), "on_link" => utf8_encode($obj['on_link']), "row" => $obj['row'], "position" => $obj['position'],"description" => utf8_encode($obj['content'])

        );
         array_push($response["courses-slider"], $info);
        }

        $response["success"] = 1;
        header("Content-type: application/json; charset=utf-8");
        header("Access-Control-Allow-Origin: *");
        echo json_encode($response);
    } else {
        $response["success"] = 0;
        $response["message"] = "Inga slides hittades";
        header("Content-type: application/json; charset=utf-8");
        header("Access-Control-Allow-Origin: *");
        echo json_encode($response);
    }
} else if ($_GET['list-all-courses'] == "1") {
      $query = "SELECT * FROM `wp_term_taxonomy` WHERE parent=".$_GET['parent']." ORDER BY `term_id` ASC";
      mysqli_query("SET names utf8;");
      mysqli_set_charset("utf8");
      mysqli_set_charset('utf8');
      $rs = mysqli_query($con,$query);
      
      $all_courses_posts_url= "http://eter.rudbeck.info/category/kurser/?json=1&count=10&apikey=ErtYnDsKATCzmuf6";
      $json_elements = file_get_contents($all_courses_posts_url);
      $elements_arr = json_decode($json_elements, TRUE);
{'fraction_non_alphanumeric': 0.1496680748340374, 'fraction_numerical': 0.009806879903439952, 'mean_word_length': 3.5341997264021887, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5156759', 'n_tokens_mistral': 2104, 'n_tokens_neox': 2030, 'n_words': 536}