blob_id
stringlengths
40
40
language
stringclasses
1 value
repo_name
stringlengths
5
116
path
stringlengths
2
241
src_encoding
stringclasses
31 values
length_bytes
int64
14
3.6M
score
float64
2.52
5.13
int_score
int64
3
5
detected_licenses
listlengths
0
41
license_type
stringclasses
2 values
text
stringlengths
14
3.57M
download_success
bool
1 class
6b7484f1f945633d5012b6ad873b7d36de7edf46
PHP
qwert19981228/P4
/课件/bobo-redis/redis4个列子/lesson/demo4/class/Model.class.php
UTF-8
816
2.984375
3
[]
no_license
<?php class Model { public $pdo; //PDO对象 public $redis; //Redis对象 public $sql; //SQL语句 public $key; //SQL生成的KEY public function __construct() { $this->redis = new Redis(); $this->redis->connect('127.0.0.1', 6379); $this->redis->auth('123456'); } public function get($sql) { //根据SQL生成KEY $this->sql = $sql; $this->key = md5($sql); //尝试获取KEY $data = json_decode($this->redis->get($this->key),true); if(!$data){ //不存在则执行sql查询 $this->pdo = new PDO('mysql:host=127.0.0.1;dbname=dy;charset=utf8;port=3306','root','123456'); $stmt = $this->pdo->query($this->sql); $data = $stmt->fetchAll(PDO::FETCH_ASSOC); //写入 $this->redis->set($this->key,json_encode($data)); } return $data; } }
true
8aad3e60fd24501122473798fa4ba10960e283ce
PHP
ferrl/personal-website
/src/database/migrations/2017_11_11_202031_create_resume_translations_table.php
UTF-8
1,089
2.5625
3
[]
no_license
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateResumeTranslationsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('resume_translations', function (Blueprint $table) { $table->increments('id'); $table->string('position'); $table->string('location'); $table->longText('contact'); $table->longText('specialties'); $table->longText('skills'); $table->longText('about'); $table->string('locale')->index(); $table->integer('resume_id')->unsigned(); $table->foreign('resume_id')->references('id')->on('resumes')->onDelete('cascade'); $table->unique(['resume_id','locale']); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('resume_translations'); } }
true
5787499d56ea5613e480db53d57490ba708ec5af
PHP
bedrift/travelholic
/src/app/Placeholders/Translate.php
UTF-8
2,150
2.671875
3
[]
no_license
<?php namespace App\Placeholders; class Translate { private $language; function __construct($language) { $this->language = $language; } function __invoke($m) { $language = $this->language; $placeholder = $m[0]; $handler = $m[1]?? null; $options = $m[2]?? null; $default = $m[3]?? null; $translation = [ "menu" => [ "children" => [ "places" => [ "da" => "Rejsemål" ], "accommodations" => [ "da" => "Ophold" ], "restaurants" => [ "da" => "Mad & Drikke" ], "todo" => [ "da" => "Seværdigheder" ], "deals" => [ "da" => "Rejser" ] ] ] ]; $data = $translation; while(preg_match("#^([a-z0-9-]+)\.(.+)$#i",$handler,$m)) { $main = $m[1]; if (array_key_exists($main,$data) && array_key_exists("children",$data[$main])) { $data = $data[$main]["children"]; $handler = $m[2]; } else return $default; } $translation = null; if (array_key_exists($handler,$data)) { if (array_key_exists($language,$data[$handler])) $translation = $data[$handler][$language]; } elseif (array_key_exists($language,$data)) $translation = $data[$language]; if ($translation) { if ($options && ($options = array_flip(explode(":",substr($options,1))))) { if (array_key_exists("dehtml",$options) == false) $translation = htmlspecialchars($translation); return $translation; } } return $default ?? $placeholder; } }
true
4e23a932c347811bf4ec19f184ee3f254e0e6a63
PHP
sumanengbd/How-to-change-collation-of-database-table-column-
/functions.php
UTF-8
483
2.71875
3
[]
no_license
<?php $con = mysql_connect('localhost', 'user', 'password'); if (!$con) { echo "Cannot connect to the database "; die(); } mysql_select_db('dbname'); $result = mysql_query('show tables'); while ($tables = mysql_fetch_array($result)) { foreach ($tables as $key => $value) { mysql_query("ALTER TABLE $value CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin"); } } echo "The collation of your database has been successfully changed!"; ?>
true
adc2c936ca986dc0350d8cf8f81285f63ab4e0d8
PHP
james2302smith/kostenlosspielen
/wp-content/plugins/kos_favorites/KosFavorites.php
UTF-8
6,051
2.578125
3
[]
no_license
<?php /** * Created by JetBrains PhpStorm. * User: nttuyen * Date: 1/22/14 * Time: 10:06 PM * To change this template use File | Settings | File Templates. */ class KosFavorites { private $perPage = 2; private $currentPage = 1; private $total = 0; private $orderType; private $games; private $userid; private function __construct($userid) { $this->userid = $userid; } private static $instances = array(); /** * @param int $postId * @return KosFavorites */ public static function getInstance($userid = 0) { if(empty($userid)) { $userid = get_current_user_id(); } if(empty(self::$instances[$userid])) { self::$instances[$userid] = new KosFavorites($userid); } return self::$instances[$userid]; } public function isFavoritedGame($postid = 0) { if(empty($postid)) { $postid = get_the_ID(); } if(empty($postid) || empty($this->userid)) { return false; } global $wpdb; global $table_prefix; $sql = 'SELECT * FROM '.$table_prefix.'favorite_games AS fav WHERE fav.user_id = '.(int)$this->userid.' AND fav.post_id = '.(int)$postid; $result = $wpdb->get_row($sql); return !empty($result); } public function addToFavorite($postid) { if(empty($postid)) { $postid = get_the_ID(); } if(empty($postid) || empty($this->userid)) { return false; } if($this->isFavoritedGame($postid)) { return true; } global $table_prefix; $table = $table_prefix.'favorite_games'; $data = array( 'user_id' => $this->userid, 'post_id' => $postid, 'timestamp' => time() ); $format = array('%d', '%d', '%d'); global $wpdb; $result = $wpdb->insert($table, $data, $format); if($result === false) { return false; } return true; } public function removeFromFavorite($postid) { if(empty($postid)) { $postid = get_the_ID(); } if(empty($postid) || empty($this->userid)) { return true; } global $table_prefix; $table = $table_prefix.'favorite_games'; $where = array( 'user_id' => $this->userid, 'post_id' => $postid ); $where_format = array('%d', '%d'); global $wpdb; $wpdb->delete($table, $where, $where_format); return true; } public function init($currentPage = 1, $limit = 20, $orderType = 'last_add_to_favorite') { if(empty($this->userid)){ return; } $this->currentPage = $currentPage; $this->perPage = $limit; $this->orderType = $orderType; $start = ($this->currentPage - 1) * $this->perPage; global $wpdb; global $table_prefix; $select = 'SELECT SQL_CALC_FOUND_ROWS DISTINCT post.*'; $from = 'FROM '.$table_prefix.'posts as post INNER JOIN '.$table_prefix.'favorite_games AS fav ON fav.post_id = post.ID'; $where = "WHERE post.post_status = 'publish' "; $where .= " AND fav.user_id = ".(int)$this->userid; $where .= " AND post.post_type = 'post' "; //$where .= " AND post.category2 = ".(int)$this->id.' '; $orderby = 'ORDER BY fav.timestamp DESC'; if($this->orderType == 'new') { $orderby = 'ORDER BY post.post_date DESC'; } else if($this->orderType == 'best') { $select .= ' ,(m1.meta_value+0.00) AS ratings_average, (m2.meta_value + 0.00) AS ratings_users'; $from .= ' LEFT JOIN '.$table_prefix.'postmeta as m1 ON (m1.post_id = post.ID AND m1.meta_key = \'ratings_average\')'; $from .= ' LEFT JOIN '.$table_prefix.'postmeta as m2 ON (m2.post_id = post.ID AND m2.meta_key = \'ratings_users\')'; $where .= " "; $orderby = 'ORDER BY ratings_average DESC, ratings_users DESC'; } else if($this->orderType == 'vote') { $select .= ' ,(m4.meta_value + 0.00) as ratings_users'; $from .= ' LEFT JOIN '.$table_prefix.'postmeta as m4 ON (m4.post_id = post.ID AND m4.meta_key = \'ratings_users\')'; $where .= " "; $orderby = 'ORDER BY ratings_users DESC'; } else if($this->orderType == 'view') { $orderby = 'ORDER BY post.game_views DESC'; } $query = $select.' '.$from.' '.$where.' '.$orderby; $query .= ' LIMIT '.$start.', '.$limit; //print_r($query);die; //$sql = 'SELECT SQL_CALC_FOUND_ROWS post.* FROM '.$table_prefix.'posts AS post INNER JOIN '.$table_prefix.'favorite_games AS fav ON fav.post_id = post.ID WHERE fav.user_id = '.(int)$this->userid.' ORDER BY fav.timestamp DESC LIMIT '.(int)$start.', '.(int)$limit; $this->games = $wpdb->get_results($query); $countQuery = 'SELECT FOUND_ROWS() as count'; $countResult = $wpdb->get_results($countQuery, ARRAY_A); $this->total = $countResult[0]['count']; } public function getGames() { if(empty($this->games)) { $this->init(); } return $this->games; } public function getTotal() { if(empty($this->total)) { $this->init(); } return $this->total; } public function getCurrentPage() { return $this->currentPage > 1 ? $this->currentPage : 1; } public function getNoItemPerPage() { return $this->perPage; } public function getNoPage() { if($this->perPage > 0 && $this->total > 0) { return ceil($this->total / $this->perPage); } else { return $this->total; } } public function getOrderType() { return $this->orderType; } }
true
a9d6b50828c42d198a7ca900ba3f39d9b12fad74
PHP
kudejwiktor/rest-challenge
/src/Application/Product/Commands/CreateProductValidator.php
UTF-8
1,141
3.03125
3
[]
no_license
<?php namespace Dogadamycie\Application\Product\Commands; use Dogadamycie\Application\Command\{CommandValidator, CommandValidatorException}; /** * Class CreateProductValidator * @package Dogadamycie\Application\Product\Commands */ class CreateProductValidator { /** * @var array */ private $rules = [ 'name' => 'required|min:3|max:100', 'price' => 'required|numeric|min:0|max:9999999999999', 'currency' => 'required|currency' ]; /** * @var CommandValidator */ private $validator; /** * CreateProductValidator constructor. * @param CommandValidator $validator */ public function __construct(CommandValidator $validator) { $this->validator = $validator; } /** * @param CreateProductCommand $command * @throws CommandValidatorException */ public function validate(CreateProductCommand $command) { $this->validator->validate([ 'name' => $command->getName(), 'price' => $command->getPrice(), 'currency' => $command->getCurrency() ], $this->rules); } }
true
74e99887c439de2980774fbfcb7ef89e070d9bd4
PHP
wybcp/wechat
/src/Kernel/Client.php
UTF-8
4,797
2.5625
3
[ "MIT" ]
permissive
<?php declare(strict_types=1); namespace EasyWeChat\Kernel; use EasyWeChat\Kernel\Contracts\AccessToken as AccessTokenInterface; use EasyWeChat\Kernel\Contracts\AccessTokenAwareHttpClient as AccessTokenAwareHttpClientInterface; use JetBrains\PhpStorm\Pure; use Symfony\Component\HttpClient\DecoratorTrait; use Symfony\Component\HttpClient\HttpClient; use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\HttpClient\Response\MockResponse; use Symfony\Contracts\HttpClient\HttpClientInterface; class Client implements AccessTokenAwareHttpClientInterface { use DecoratorTrait; public function __construct( ?HttpClientInterface $client = null, protected ?AccessTokenInterface $accessToken = null, ) { $this->client = $client ?? HttpClient::create(); } public function withAccessToken(AccessTokenInterface $accessToken): static { $clone = clone $this; $clone->accessToken = $accessToken; return $clone; } /** * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface */ public function request(string $method, string $url, array $options = []): \Symfony\Contracts\HttpClient\ResponseInterface { if ($this->accessToken) { $options['query'] = \array_merge($options['query'] ?? [], $this->accessToken->toQuery()); } return $this->client->request($method, ltrim($url, '/'), $options); } /** * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface */ public function get(string $url, array $options = []): \Symfony\Contracts\HttpClient\ResponseInterface { return $this->request('GET', $url, $options); } /** * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface */ public function post(string $url, array $options = []): \Symfony\Contracts\HttpClient\ResponseInterface { if (!\array_key_exists('body', $options) && !\array_key_exists('json', $options)) { $options['body'] = $options; } return $this->request('POST', $url, $options); } /** * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface */ public function patch(string $url, array $options = []): \Symfony\Contracts\HttpClient\ResponseInterface { if (!\array_key_exists('body', $options) && !\array_key_exists('json', $options)) { $options['body'] = $options; } return $this->request('PATCH', $url, $options); } /** * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface */ public function put(string $url, array $options = []): \Symfony\Contracts\HttpClient\ResponseInterface { if (!\array_key_exists('body', $options) && !\array_key_exists('json', $options)) { $options['body'] = $options; } return $this->request('PUT', $url, $options); } /** * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface */ public function delete(string $url, array $options = []): \Symfony\Contracts\HttpClient\ResponseInterface { return $this->request('DELETE', $url, $options); } public function __call(string $name, array $arguments) { return \call_user_func_array([$this->client, $name], $arguments); } public static function mock(string $response = '', ?int $status = 200, ?string $contentType = 'application/json', array $headers = [], string $baseUri = 'https://example.com'): object { $mockResponse = new MockResponse( $response, array_merge([ 'http_code' => $status, 'content_type' => $contentType, ], $headers) ); return new class ($mockResponse, $baseUri) { use DecoratorTrait; public function __construct(public MockResponse $mockResponse, $baseUri) { $this->client = new Client(new MockHttpClient($this->mockResponse, $baseUri)); } public function __call(string $name, array $arguments) { return \call_user_func_array([$this->client, $name], $arguments); } #[Pure] public function getRequestMethod() { return $this->mockResponse->getRequestMethod(); } #[Pure] public function getRequestUrl() { return $this->mockResponse->getRequestUrl(); } #[Pure] public function getRequestOptions() { return $this->mockResponse->getRequestOptions(); } }; } }
true
b1e0ca8cf08b1c88e36effc6f5c355ed83f2042b
PHP
EnRodage/Blade-Codeigniter-3
/application/controllers/admin/Login.php
UTF-8
1,665
2.515625
3
[]
no_license
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Login extends MY_Controller { public function __construct() { parent::__construct(); $this->load->model('User_model', 'user'); } public $viewData = array('title' => 'Login'); /** * Login Page */ public function index() { $this->bladeView('login/login_page', $this->dataView); } /** * Login request * * @return redirect to admin page or login page if fails */ public function login() { if (!$this->input->post() || (!$this->input->post('username') && !$this->input->post('password') )) { $this->load->view('errors/html/error_general', array('heading' => 'Erro', 'message' => 'User and password are required')); return; } $this->db->limit(1); $qryUser = $this->user->get_by(array('user_login' => $this->input->post('username'))); if (!$qryUser) { $this->load->view('errors/html/error_general', array('heading' => 'Erro', 'message' => "User or password are incorrect")); return; } $qryPass = password_verify($this->input->post('password'), $qryUser->user_password); if ($qryPass) { $this->session->set_userdata(array('logged' => TRUE, 'user' => $qryUser)); redirect('admin/home'); } } /** * Logout request */ public function logout() { if ($this->session->userdata('logged')) { $this->session->sess_destroy(); } redirect('welcome'); } }
true
3a4ab741de0142f56657e2c800cdcd1007c79f03
PHP
kvesskrishna/21csskpias
/webservices/lib/global_template_sample.php
UTF-8
4,740
2.53125
3
[]
no_license
<?php require_once('api_auth.php'); if ($response['auth_status']==1) { $verb = $_SERVER['REQUEST_METHOD']; switch ($verb) { case 'GET': if(!empty($_GET["service_id"])) { $service_id=intval($_GET["service_id"]); get_services($service_id); } else { get_services(); } break; case 'POST': insert_service(); break; case 'PUT': $service_id=intval($_GET["service_id"]); update_service($service_id); break; case 'DELETE': $service_id=intval($_GET["service_id"]); delete_service($service_id); break; default: http_response_code(405); break; } //HANDLE GET REQUEST START //----------------------- function get_services($service_id=0) { $query="SELECT * FROM 21css_services WHERE service_status='active'"; if($service_id != 0) { $query.=" AND service_id=".$service_id." LIMIT 1"; } $result=$mysqli->query($query); while($row=$result->fetch_assoc()) { $response[]=$row; } header('Content-Type: application/json'); echo json_encode($response, JSON_UNESCAPED_SLASHES); } //----------------------- //HANDLE GET REQUEST END //HANDLE POST REQUEST START //----------------------- function insert_service() { $service_name=$_POST["service_name"]; $about=$_POST["about"]; $key_offerings=$_POST['key_offerings']; $implementation_services=$_POST["implementation_services"]; $service_image="http://www.21cssindia.com/img/services/default.png"; if (is_uploaded_file($_FILES['service_image']['tmp_name'])) { # code... $tmp_file=$_FILES['service_image']['tmp_name']; $file_name=time().$_FILES['service_image']['name']; $upload_dir="../img/services/".$file_name; if (move_uploaded_file($tmp_file, $upload_dir)) { # code... $service_image="http://www.21cssindia.com/img/services/".$file_name; } } $query="INSERT INTO 21css_services (service_name, about, key_offerings, implementation_services, service_image) values ('{$service_name}', '{$about}', '{$key_offerings}', '{$implementation_services}', '{$service_image}')"; if($mysqli->query($query)) { $response=array( 'status' => 1, 'status_message' =>'Service Added Successfully.' ); } else { $response=array( 'status' => 0, 'status_message' =>'Service Addition Failed.' ); } header('Content-Type: application/json'); echo json_encode($response, JSON_UNESCAPED_SLASHES); } //----------------------- //HANDLE POST REQUEST END //HANDLE PUT REQUEST START //----------------------- function update_service($service_id) { $query_existing="SELECT * FROM 21css_services WHERE service_id=$service_id"; if ($mysqli->query($query_existing)) { # code... $result_existing=$mysqli->query($query_existing); while ($row_existing=$result_existing->fetch_assoc()) { # code... $service_name=$row_existing['service_name']; $about=$row_existing['about']; $key_offerings=$row_existing['key_offerings']; $implementation_services=$row_existing['implementation_services']; $service_status=$row_existing['service_status']; } parse_str(file_get_contents("php://input"),$post_vars); if(!empty($post_vars['service_name'])) $service_name=$post_vars["service_name"]; if(!empty($post_vars['about'])) $about=$post_vars["about"]; if(!empty($post_vars['key_offerings'])) $key_offerings=$post_vars["key_offerings"]; if(!empty($post_vars['implementation_services'])) $implementation_services=$post_vars["implementation_services"]; if(!empty($post_vars['service_status'])) $service_status=$post_vars["service_status"]; $query="UPDATE 21css_services SET service_name='{$service_name}',about='{$about}',key_offerings='{$key_offerings}',implementation_services='{$implementation_services}',service_status='{$service_status}' WHERE service_id=$service_id"; if($mysqli->query($query)) { $response=array( 'status' => 1, 'status_message' =>'Service Update Successfully.' ); } else { $response=array( 'status' => 0, 'status_message' =>'Service Update Failed.' ); } } header('Content-Type: application/json'); echo json_encode($response, JSON_UNESCAPED_SLASHES); } //----------------------- //HANDLE PUT REQUEST END //HANDLE DELETE REQUEST START //----------------------- function delete_service($service_id) { $query="DELETE FROM 21css_services WHERE service_id=".$service_id; if($mysqli->query($query)) { $response=array( 'status' => 1, 'status_message' =>'Service Deleted Successfully.' ); } else { $response=array( 'status' => 0, 'status_message' =>'Service Deletion Failed.' ); } header('Content-Type: application/json'); echo json_encode($response, JSON_UNESCAPED_SLASHES); } //----------------------- //HANDLE DELETE REQUEST END } ?>
true
3d0afbdbee63c13c249dd3e011d173e58d72cef7
PHP
nicklaw5/twitch-api-php
/src/HelixGuzzleClient.php
UTF-8
1,009
2.765625
3
[ "MIT" ]
permissive
<?php declare(strict_types=1); namespace TwitchApi; use GuzzleHttp\Client; class HelixGuzzleClient { private $client; private const BASE_URI = 'https://api.twitch.tv/helix/'; public function __construct(string $clientId, array $config = [], string $baseUri = null) { if ($baseUri == null) { $baseUri = self::BASE_URI; } $headers = [ 'Client-ID' => $clientId, 'Content-Type' => 'application/json', ]; $client_config = [ 'base_uri' => $baseUri, 'headers' => $headers, ]; if (isset($config['handler'])) { $client_config = []; } $client_config = array_merge($client_config, $config); $this->client = new Client($client_config); } public function getConfig($option = null) { return $this->client->getConfig($option); } public function send($request) { return $this->client->send($request); } }
true
80abe78d873024f14680f7498b044cd346d26894
PHP
andrewjwolf/frankintelligence
/app/database/seeds/FieldTypesTableSeeder.php
UTF-8
386
2.59375
3
[ "MIT" ]
permissive
<?php class FieldTypesTableSeeder extends Seeder { public function run() { // Uncomment the below to wipe the table clean before populating DB::table('field_types')->truncate(); $field_types = array( ['name' => 'type1'], ['name' => 'type2'], ); // Uncomment the below to run the seeder DB::table('field_types')->insert($field_types); } }
true
fff15fee6cf117a9552c04f0295000cf0351928f
PHP
zf424zf/phpms
/flow-control.php
UTF-8
501
3.171875
3
[]
no_license
<?php /** * Created by PhpStorm. * User: Administrator * Date: 2018/5/8 0008 * Time: 上午 11:37 */ //php遍历数组的三种方式 //1.for 只能循环索引数组 //2.foreach 可以循环索引和关联数组,会对数组指针重置 //3.while,list(),each() 同上,且不会进行reset()操作-不会把指针重置 //php如何优化if else if -> 1.概率较大的尽量往前放。2如果是比较复杂的结构,如果是整形,字符串,浮点类型,可以使用switch case
true
60718f1def5cf0c49a64b2c9c92bee50050d0ac8
PHP
mattiaruberto/GestioneAcquariMarini
/Implementazione/ProgettoGestioneAcquariMarini/GestioneAcquariMarini/libs/ValidationFunction/validationFunction.php
UTF-8
9,960
3.0625
3
[]
no_license
<?php class ValidationFunction{ /** * Costante per identificare quando un parametro è già usato. */ const ALREDY_EXIST = "alredy_exist"; /** * Costante per identificare quando un parametro è sbagliato. */ const INCORRECT_INPUT = "incorrect"; /** * Costante per identificare quando un parametro è corretto. */ const CORRECT_INPUT = "correct"; /** * Costante per identificare quando il tipo di abitante è un pesce. */ const FISH_TYPE = "Pesce"; /** * Costante per identificare quando il tipo di abitante è un corallo. */ const CORAL_TYPE = "Corallo"; /** * Costante per identificare quando il tipo di abitante è un crostaceo. */ const SHELLFISH_TYPE = "Crostaceo"; /** * Costante per identificare quando il sesso dell'abitante è maschio. */ const MALE_SEX = "M"; /** * Costante per identificare quando il sesso dell'abitante è femmina. */ const FEMALE_SEX = "F"; /** * Costante per identificare quando il sesso dell'abitante è altro. */ const OTHER_SEX = "Altro"; /** * Costante per identificare quando il tipo di utente è admin. */ const ADMIN_USER = "Admin"; /** * Costante per identificare quando il tipo di utente è normale. */ const NORMAL_USER = "User"; /** * Attributo che rappresenta la classe TankModel. */ private $tankModel; /** * Attributo che rappresenta la classe UserModel. */ private $userModel; /** * Attributo che rappresenta la classe HabitantModel. */ private $habitantModel; /** * Attributo rappresentante l'array che contiene tutti i nomi delle vasche. */ private $allNameTank; /** * Attributo rappresentante l'array che contiene tutte l'emal delle vasche. */ private $allEmailUsers; /** * Attributo rappresentante l'array che contiene tutti gli abitanti. */ private $allHabitants; /** * Meodo costruttore che istanzia le classi e ricava i valori degli array. */ public function __construct(){ require_once "GestioneAcquariMarini/models/tankModel.php"; require_once "GestioneAcquariMarini/models/userModel.php"; require_once "GestioneAcquariMarini/models/habitantModel.php"; $this->tankModel = new TankModel(); $this->userModel = new UserModel(); $this->habitantModel = new HabitantModel(); $this->allNameTank = $this->tankModel->getAllTankName(); $this->allEmailUsers = $this->userModel->getAllEmail(); } /** * Validazione dei numeri interi * @param $number valore da validare * @param $min valore minimo * @param $max valore massimo * @return bool valore di ritorno booleano */ public function validateInt($number, $min, $max){ if(is_numeric($number) && $number >= $min && $number <= $max){ return true; }else{ return false; } } /** * Funzione che esegue la convalida del nome dell'acquario. * @param $tankName stringa da convalidare * @return string costante rappresentante il tipo di risultato. */ public function validateTankName($tankName) { $validElement = $this->generalValidation($tankName); $pattern = '/^[A-Za-z0-9_-]+$/'; $arrayAllNameTank = $this->multidimensionalArrayToNormalArray($this->allNameTank); if (preg_match($pattern, $validElement) && strlen($validElement) > 0 && strlen($validElement) <= 45) { if (in_array(strtolower($tankName), $arrayAllNameTank)){ return self::ALREDY_EXIST; }else{ return self::CORRECT_INPUT; } }else{ return self::INCORRECT_INPUT; } } /** * Funzione che convalida la specie dell'abitante. * @param $species parametro da convalidare. * @return bool varibile booleana da ritornare. */ public function validateSpeciesHabitant($species){ $validElement = $this->generalValidation($species); $pattern = '/^[A-Za-z_-]+$/'; if (preg_match($pattern, $validElement) && strlen($validElement) > 0 && strlen($validElement) <= 45) { return true; } return false; } /** * Validazione della primary key dell'abitante. * @param $species specie dell'abitante. * @param $sex sesso dell'abitante. * @return bool varibile booleana da ritornare. */ public function validatePrimaryKeysHabitant($species, $sex){ $this->allHabitants = $this->habitantModel->getAllHabitantBySpeciesAndSex($species, $sex); if(count($this->allHabitants) > 0){ return false; } return true; } /** * Validazione dell'email * @param $email email dell'utente. * @return string valore rappresentante il risultato tramite costante. */ public function validateEmail($email){ $validElement = $this->generalValidation($email); $pattern = '/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/'; $arrayAllEmailUser = $this->multidimensionalArrayToNormalArray($this->allEmailUsers); if( preg_match($pattern, $validElement)){ if (in_array(strtolower($email), $arrayAllEmailUser)){ return self::ALREDY_EXIST; }else{ return self::CORRECT_INPUT; } }else{ return self::INCORRECT_INPUT; } } /** * Funzione che effettua la validazione della data. * @param $stringDate data da convalidare sottoforma di stringa. * @return bool varibile booleana da ritornare. */ public function validateDate($stringDate){ $date_arr = explode('-', $stringDate); $date = new DateTime($stringDate); $current_date = new DateTime(); $dateOk = false; if (count($date_arr) == 3 && strlen($stringDate) == 10) { if (checkdate($date_arr[2],$date_arr[1],$date_arr[0])) { if ($date <= $current_date) { $dateOk = true; } } } return $dateOk; } /** * Funzione che esegue la validazione del numero di telefono. * @param $phoneNumber numero di telefono da convalidare. * @return bool varibile booleana da ritornare. */ public function validatePhoneNumber($phoneNumber){ $validElement = $this->generalValidation($phoneNumber); $pattern = '/^[0-9\s+#]+$/'; if (strlen($phoneNumber) > 0 && strlen($phoneNumber) <= 45 && preg_match($pattern, $validElement)) { return true; } else { return false; } } /** * Funzione che esegue la convalidazione delle stringhe. * @param $string stringa da convalidare. * @return bool varibile booleana da ritornare. */ public function validateString($string){ $validElement = $this->generalValidation($string); $pattern = '/^[a-zèéëàáäìíòöóüùú\s]*$/i'; if (strlen($validElement) > 0 && strlen($validElement) <= 45 && preg_match($pattern, $validElement)) { return true; } else { return false; } } /** * Validazione dei permessi dell'utente * @param $permission permesso da convalidare * @return bool varibile booleana da ritornare. */ public function validatePermission($permission){ if($permission == self::NORMAL_USER || $permission == self::ADMIN_USER){ return true; }else{ return false; } } /** * Funzione che controlla che il parametro inserito per dire se la password da cambiare è corretto. * @param $passowrdToChange valore inserito per la password da cambiare. * @return bool varibile booleana da ritornare. */ public function validatePasswordToChange($passowrdToChange) { if ($passowrdToChange == TOCHANGEPASSWORD || $passowrdToChange == NOTCHANGEPASSWORD) { return true; } else { return false; } } /** * Validazione del genere dell'abitante. * @param $sex sesso dell'abitante. * @return bool varibile booleana da ritornare. */ public function validateSex($sex){ if ($sex == self::MALE_SEX || $sex == self::FEMALE_SEX || $sex == self::OTHER_SEX) { return true; } else { return false; } } /** * Funzione che esegue la validazione del tipo di abitante * @param $habitantType tipo di abitante * @return bool varibile booleana da ritornare. */ public function validateHabitantType($habitantType) { if ($habitantType == self::SHELLFISH_TYPE || $habitantType == self::FISH_TYPE || $habitantType == self::CORAL_TYPE) { return true; } else { return false; } } /** * Funzione che prende un'array multidimensionale e ne ritorna uno normale. * @param $arrayMultidimensional array multidimensionale. * @return array array normale. */ private function multidimensionalArrayToNormalArray($arrayMultidimensional){ $result = array(); foreach ($arrayMultidimensional as $row) { foreach ($row as $param){ $result[] = strtolower($param); } } return $result; } /** * Funzione base che fa la validazione dell'input. * @param $element string da convalidare * @return string ritorna la stringa convalidata */ public function generalValidation($element){ $element = trim(stripslashes(htmlspecialchars($element))); return $element; } } ?>
true
bfc7502bddf1f82b20f9b9af38adcf1e81784d3e
PHP
Quark-X10/Micro-rezo
/modele/administration.php
UTF-8
3,114
2.65625
3
[]
no_license
<?php require_once("connection_requetes_bdd.php"); function changer_mot_de_passe($utilisateur_id,$mot_de_passe){ $bdd = connection_bdd(); $requete = 'UPDATE utilisateur SET mot_de_passe = :mot_de_passe WHERE utilisateur_id = :utilisateur_id'; $changement = $bdd->prepare($requete); $donnees = array('utilisateur_id' => $utilisateur_id, 'mot_de_passe' => $mot_de_passe); $changement->execute($donnees); $changement->closeCursor(); $requete = 'SELECT utilisateur_id FROM utilisateur WHERE utilisateur_id = :utilisateur_id AND mot_de_passe = :mot_de_passe'; $verification = $bdd->prepare($requete); $verification->execute($donnees); if($verification->rowCount() != 1){ $verification->closeCursor(); return false; } else{ $verification->closeCursor(); return true; } } function ajouter_utilisateur($login,$mot_de_passe,$droits){ $bdd = connection_bdd(); $requete = 'INSERT INTO utilisateur(utilisateur_id, login, mot_de_passe, droits) VALUES(:utilisateur_id, :login, :mot_de_passe, :droits)'; $ajout = $bdd->prepare($requete); $utilisateur_id = array('utilisateur_id' => NULL); $donnees = array('login' => $login, 'mot_de_passe' => $mot_de_passe, 'droits' => $droits); $ajout->execute($utilisateur_id + $donnees); $ajout->closeCursor(); $requete = 'SELECT utilisateur_id FROM utilisateur WHERE login = :login AND mot_de_passe = :mot_de_passe AND droits = :droits'; $verification = $bdd->prepare($requete); $verification->execute($donnees); if($verification->rowCount() != 1){ $verification->closeCursor(); return false; } else{ $verification->closeCursor(); return true; } } function supprimer_utilisateur($utilisateur_id){ $bdd = connection_bdd(); $requete = 'DELETE FROM utilisateur WHERE utilisateur_id = :utilisateur_id'; $suppression = $bdd->prepare($requete); $donnees = array('utilisateur_id' => $utilisateur_id); $suppression->execute($donnees); $suppression->closeCursor(); $requete = 'SELECT utilisateur_id FROM utilisateur WHERE utilisateur_id = :utilisateur_id'; $verification = $bdd->prepare($requete); $verification->execute($donnees); if($verification->rowCount() != 0){ $verification->closeCursor(); return false; } else{ $verification->closeCursor(); return true; } } function liste_utilisateurs($utilisateur_courant){ $bdd = connection_bdd(); $requete = 'SELECT utilisateur_id, login FROM utilisateur WHERE utilisateur_id != :utilisateur_courant'; $reponse = $bdd->prepare($requete); $donnees = array('utilisateur_courant' => $utilisateur_courant); $reponse->execute($donnees); if($reponse->rowCount() < 1){ $reponse->closeCursor(); return false; } else{ $resultat = $reponse->fetchAll(); $reponse->closeCursor(); return $resultat; } } function verification_existence($login){ $bdd = connection_bdd(); $requete = 'SELECT utilisateur_id FROM utilisateur WHERE login = :login'; $reponse = $bdd->prepare($requete); $donnees = array('login' => $login); $reponse->execute($donnees); if($reponse->rowCount() > 0){ $reponse->closeCursor(); return true; } else{ $reponse->closeCursor(); return false; } } ?>
true
1569e95faddf8b084369804a8f1ac2795bd85912
PHP
cuppss/RezParse
/Code/DEMO/tag_management/language/insert_language.php
UTF-8
1,224
3.328125
3
[]
no_license
<?php //data is being pulled from clearance.php if (isset($_POST['alpha'])) { //if the user inputs a value into the certification box //then assign the input to a variable and remove any whitespace from the ends $alpha = trim($_POST['alpha']); //this if statement block catches possible mistakes in the entering of data. currently only checking //the tag value, not the abbreviation if (is_null($alpha)) { //use javascript for popup output echo '<script>alert("That was a null string, please enter proper data for the certification value")</script>'; exit; } elseif ($alpha == "") { //use javascript for popup output echo '<script>alert("That was an empty string, please enter proper data for the certification value")</script>'; exit; } //insert user input into the database $sql = "INSERT INTO languages_table (languages) VALUES ('$alpha')"; //use mysqli_query to execute sql string. if (mysqli_query($link, $sql)) { echo "New record created successfully"; header('Location: ../language/language.php'); //reload the page } else { echo "Error: " . $sql . "<br>" . mysqli_error($link); } }
true
884b3ba033198c0b3a5deb12c8ecbbba233f634d
PHP
JosephMos/ASPprojects
/2020.05.ia.01.login.signup.php
UTF-8
1,356
2.546875
3
[]
no_license
<?php require "2020.05.ia.01.login.header.php"; ?> <main> <?php echo "<br>"; if (isset ($_GET['error'])){ if ($_GET['error']=="emptyfields"){ echo "<font color='#ff2626'>Empty Fields</font>"; } elseif ($_GET['error']=="invalidmailuid"){ echo "<font color='#ff2626'>Invalid Email and Username</font>"; } elseif ($_GET['error']=="invalidmail"){ echo "<font color='#ff2626'>Invalid Email</font>"; } elseif ($_GET['error']=="invaliduid"){ echo "<font color='#ff2626'>Invalid Username</font>"; } elseif ($_GET['error']=="passwordcheck"){ echo "<font color='#ff2626'>Passwords do not match</font>"; } } ?> <h1 style="color:#d1d1d1">Signup</h1> <form class="form-signup" action="2020.05.ia.01.login.signup.inc.php" method="post"> <input type="text" name="uid" placeholder="Username" value=<?=$_GET['uid']?>><br> <input type="text" name="mail" placeholder="Email" value=<?=$_GET['mail']?>><br> <input type="password" name="pwd" placeholder="Password"><br> <input type="password" name="pwd-repeat" placeholder="Repeat Password"><br> <button type="submit" name="signup-submit">Signup</button> </form> </main> <?php require "2020.05.ia.01.login.footer.php"; ?>
true
d7cac86d1f052b600701c4220f55304b7f234402
PHP
CleverStyle/cleverstyle.org
/core/classes/Session.php
UTF-8
1,796
2.53125
3
[ "MIT" ]
permissive
<?php /** * @package CleverStyle Framework * @author Nazar Mokrynskyi <nazar@mokrynskyi.com> * @copyright Copyright (c) 2011-2016, Nazar Mokrynskyi * @license MIT License, see license.txt */ namespace cs; use cs\Session\Data, cs\Session\Management; /** * Class responsible for current user session * * Provides next events: * * System/Session/init/before * * System/Session/init/after * * System/Session/load * ['session_data' => $session_data] * * System/Session/add * ['session_data' => $session_data] * * System/Session/del/before * ['id' => $session_id] * * System/Session/del/after * ['id' => $session_id] * * System/Session/del_all * ['id' => $user_id] * * @method static $this instance($check = false) */ class Session { use CRUD, Singleton, Data, Management; const INIT_STATE_METHOD = 'init'; const INITIAL_SESSION_EXPIRATION = 300; /** * @var Cache\Prefix */ protected $cache; /** * @var Cache\Prefix */ protected $users_cache; protected $data_model = [ 'id' => 'text', 'user' => 'int:0', 'created' => 'int:0', 'expire' => 'int:0', 'user_agent' => 'text', 'remote_addr' => 'text', 'ip' => 'text', 'data' => 'json' ]; protected $table = '[prefix]sessions'; /** * Returns database index * * @return int */ protected function cdb () { return Config::instance()->module('System')->db('users'); } protected function init () { if (!$this->cache) { $this->cache = Cache::prefix('sessions'); $this->users_cache = Cache::prefix('users'); } $this->session_id = null; $this->user_id = User::GUEST_ID; Event::instance()->fire('System/Session/init/before'); $this->init_session(); Event::instance()->fire('System/Session/init/after'); } }
true
998b1ba48bd54c78004605d37cf78512ca542612
PHP
tranminhtrong102/code
/convert-url-youtube.php
UTF-8
436
2.5625
3
[]
no_license
if( !function_exists( 'convertUrlYoutube' ) ) { function convertUrlYoutube( $url ) { preg_match('/[\\?\\&]v=([^\\?\\&]+)/', $url, $matches); $id = $matches[1]; $width = '800px'; $height = '450px'; echo'<iframe id="ytplayer" type="text/html" width="'.$width.'" height="'.$height.'" src="https://www.youtube.com/embed/'.$id.'?rel=0&showinfo=0&color=white&iv_load_policy=3" frameborder="0" allowfullscreen></iframe> '; } }
true
2aaa665192ecd984fec89bda07de80dc8e000b7a
PHP
AndreyShamis/the-game
/Matrix.php
UTF-8
6,278
3.609375
4
[ "Apache-2.0" ]
permissive
<?php /** * User: Andrey Shamis * Date: 12/18/14 * Time: 6:14 PM */ require_once "Vector.php"; class Matrix { protected $m_Matrix; protected $m_Columns = array(); protected $m_Rows = array(); protected $m_DimensionX = 0; protected $m_DimensionY = 0; public function getRowsSize(){ return count($this->m_Rows); } public function getColumnsSize(){ return count($this->m_Columns); } /* * 4 x 6 * C O L U M N S * * R 1 2 3 4 3 3 * O 8 7 5 4 2 3 * W 6 7 5 8 0 5 * S 7 9 6 4 8 0 */ public function __construct($y=3,$x=6){ $this->m_DimensionX = $x; $this->m_DimensionY = $y; for($a=0;$a<$this->m_DimensionX;$a++){ for($b=0;$b<$this->m_DimensionY;$b++){ $this->m_Matrix[$b][$a] = 0; $this->m_Columns[$b][$a] = & $this->m_Matrix[$b][$a]; $this->m_Rows [$a][$b] = & $this->m_Matrix[$b][$a]; } } } /** * The size of a matrix is defined by the number of rows and columns that it contains. * A matrix with m rows and n columns is called an m × n matrix or m-by-n matrix, * while m and n are called its dimensions * @return int */ public function Size(){ //return array($this->m_DimensionX,$this->m_DimensionY); return array(count($this->m_Rows),count($this->m_Columns)); } protected function SizeToString(array &$arr){ return $arr[0] . "x" . $arr[1]; } public function SizeString(){ return $this->SizeToString($this->Size()); } public function ScalarMultiplication($scalar){ $newMatrix = new Matrix($this->m_DimensionY,$this->m_DimensionX); for($a=0;$a<$this->m_DimensionX;$a++){ for($b=0;$b<$this->m_DimensionY;$b++){ $newMatrix->m_Matrix[$b][$a] = $this->m_Matrix[$b][$a] * $scalar; } } return $newMatrix; } public function Transposition(){ $newMatrix = new Matrix($this->m_DimensionX,$this->m_DimensionY); for($a=0;$a<$this->m_DimensionX;$a++){ for($b=0;$b<$this->m_DimensionY;$b++){ $newMatrix->m_Matrix[$a][$b] = $this->m_Matrix[$b][$a]; } } return $newMatrix; } public function setElement($x,$y,$val){ $this->m_Matrix[$x][$y] = $val; } public function __toString(){ $ret = ""; //echo "<pre>" . print_r($this->m_Matrix,1) . "</pre>"; for($a=0;$a<$this->m_DimensionX;$a++){ $ret .= "|"; for($b=0;$b<$this->m_DimensionY;$b++){ $ret .= $this->m_Matrix[$b][$a] ; if($b+1 != $this->m_DimensionY){ $ret .= " "; } } $ret .= "|\n<br/>"; } return $ret; } /** * @param Matrix $otherMatrix * @return Matrix * @throws Exception */ public function Multiplication(Matrix &$otherMatrix){ if(count($this->m_Columns) != count($otherMatrix->m_Rows)){ throw new Exception("Multiplication of two matrices is defined if and only if the number of columns of the left matrix is the same as the number of rows of the right matrix. [Left = " . count($this->m_Columns) . "] != [Right = ". count($otherMatrix->m_Rows) . "]",1 ); } $newMatrix = new Matrix(count($this->m_Rows),count($otherMatrix->m_Columns)); for($a=0;$a<$this->m_DimensionX;$a++){ for($b=0;$b<$otherMatrix->m_DimensionY;$b++){ //echo "Calling vector<br/>"; //print_r($this->m_Rows[$a]); //print_r($otherMatrix->m_Columns[$b]); $r = new Vector($this->m_Rows[$a]); $c = new Vector($otherMatrix->m_Columns[$b]); //echo " $r $c <br/>"; $newMatrix->m_Matrix[$a][$b] = $r->DotProduction($c); } } return $newMatrix; } /** * @param $rowX * @param $rowY */ public function RowSwitch($rowX,$rowY){ //$tmp = $this->m_Rows[$rowX]; //$this->m_Rows[$rowX] = $this->m_Rows[$rowY]; //$this->m_Rows[$rowY] = $tmp; } /** * @param $value * @param $rowX * @return Vector * @throws Exception */ public function RowMultiplication($multiplier,$rowX){ if($multiplier == 0 ){ throw new Exception("[Row multiplication] Each element in a row can be multiplied by a non-zero constant.",3); } $vector = new Vector($this->m_Rows[$rowX-1]); $vector = $vector->ScalarMultiplication($multiplier); print_r($vector); $this->m_Rows[$rowX-1] = $vector->toArray(); //return $vector; // $size = count($this->m_Rows[$rowX]); // for($i=0;$i<$size;$i++){ // $this->m_Rows[$rowX]=$this->m_Rows[$rowX]*$value; // } } public function RowAddition($rowDestination,$rowSource,$multiplier){ if($multiplier == 0 ){ throw new Exception("[Row multiplication] Each element in a row can be multiplied by a non-zero constant.",3); } $rD = new Vector($this->m_Rows[$rowDestination-1]); $rS = new Vector($this->m_Rows[$rowSource-1]); $rS = $rS->ScalarMultiplication($multiplier); print_r($this->m_Rows[$rowSource-1]); $rD = $rD->Add($rS); $this->m_Rows[$rowDestination-1] = $rD; return $this; } public function Add(Matrix &$otherMatrix){ if($otherMatrix->SizeString() != $this->SizeString()){ throw new Exception("Matrix dimensions are different " . $otherMatrix->SizeString() . "!=". $this->SizeString(),1 ); } $newMatrix = new Matrix($this->m_DimensionY,$this->m_DimensionX); for($a=0;$a<$this->m_DimensionX;$a++){ for($b=0;$b<$this->m_DimensionY;$b++){ $newMatrix->m_Matrix[$b][$a] = $this->m_Matrix[$b][$a]+$otherMatrix->m_Matrix[$b][$a]; } } return $newMatrix; } }
true
a0c75b530048576fd82bbc361a04e0d008c426f7
PHP
zendraxl/laravel-string
/tests/Unit/StrProxyTest.php
UTF-8
9,566
2.75
3
[ "MIT" ]
permissive
<?php namespace Zendraxl\LaravelString\Tests\Unit; use Illuminate\Support\Str; use PHPUnit\Framework\TestCase; use Zendraxl\LaravelString\StrProxy; class StrProxyTest extends TestCase { /** @test */ public function str_after(): void { $this->assertSame( Str::after('This is my name', 'This is'), (new StrProxy('This is my name'))->after('This is')->get() ); } /** @test */ public function str_ascii(): void { $this->assertSame(Str::ascii('@'), (new StrProxy('@'))->ascii()->get()); $this->assertSame(Str::ascii('ü'), (new StrProxy('ü'))->ascii()->get()); $this->assertSame( Str::ascii('х Х щ Щ ъ Ъ ь Ь', 'bg'), (new StrProxy('х Х щ Щ ъ Ъ ь Ь'))->ascii('bg')->get() ); $this->assertSame( Str::ascii('ä ö ü Ä Ö Ü', 'de'), (new StrProxy('ä ö ü Ä Ö Ü'))->ascii('de')->get() ); } /** @test */ public function str_before(): void { $this->assertSame( Str::before('This is my name', 'my name'), (new StrProxy('This is my name'))->before('my name')->get() ); } /** @test */ public function str_camel(): void { $this->assertSame(Str::camel('foo_bar'), (new StrProxy('foo_bar'))->camel()->get()); } /** @test */ public function str_contains(): void { $this->assertSame( Str::contains('This is my name', 'my'), (new StrProxy('This is my name'))->contains('my') ); $this->assertSame( Str::contains('This is my name', ['my', 'foo']), (new StrProxy('This is my name'))->contains(['my', 'foo']) ); } /** @test */ public function str_contains_all(): void { $this->assertSame( Str::containsAll('This is my name', ['my', 'name']), (new StrProxy('This is my name'))->containsAll(['my', 'name']) ); } /** @test */ public function str_ends_with(): void { $this->assertSame( Str::endsWith('This is my name', 'name'), (new StrProxy('This is my name'))->endsWith('name') ); } /** @test */ public function str_finish(): void { $this->assertSame( Str::finish('this/string', '/'), (new StrProxy('this/string'))->finish('/')->get() ); $this->assertSame( Str::finish('this/string/', '/'), (new StrProxy('this/string/'))->finish('/')->get() ); } /** @test */ public function str_is(): void { $this->assertSame(Str::is('foo*', 'foobar'), (new StrProxy('foobar'))->is('foo*')); $this->assertSame(Str::is('baz*', 'foobar'), (new StrProxy('foobar'))->is('baz*')); } /** @test */ public function str_kebab(): void { $this->assertSame(Str::kebab('fooBar'), (new StrProxy('fooBar'))->kebab()->get()); } /** @test */ public function str_length(): void { $this->assertSame(Str::length('foo bar baz'), (new StrProxy('foo bar baz'))->length()); $this->assertSame( Str::length('foo bar baz', 'UTF-8'), (new StrProxy('foo bar baz'))->length('UTF-8') ); } /** @test */ public function str_limit(): void { $this->assertSame( Str::limit('The quick brown fox jumps over the lazy dog', 20), (new StrProxy('The quick brown fox jumps over the lazy dog'))->limit(20)->get() ); $this->assertSame( Str::limit('The quick brown fox jumps over the lazy dog', 20, ' (...)'), (new StrProxy('The quick brown fox jumps over the lazy dog'))->limit(20, ' (...)')->get() ); } /** @test */ public function str_lower(): void { $this->assertSame(Str::lower('FOO BAR BAZ'), (new StrProxy('FOO BAR BAZ'))->lower()->get()); $this->assertSame(Str::lower('fOo Bar bAz'), (new StrProxy('fOo Bar bAz'))->lower()->get()); } /** @test */ public function str_ordered_uuid(): void { $pattern = '/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/'; $this->assertRegExp($pattern, (string) Str::orderedUuid()); $this->assertRegExp($pattern, (string) (new StrProxy(''))->orderedUuid()); } /** @test */ public function str_parse_callback(): void { $this->assertSame( Str::parseCallback('Class@method', 'foo'), (new StrProxy('Class@method'))->parseCallback('foo') ); $this->assertSame( Str::parseCallback('Class', 'foo'), (new StrProxy('Class'))->parseCallback('foo') ); } /** @test */ public function str_plural(): void { $this->assertSame(Str::plural('car'), (new StrProxy('car'))->plural()->get()); $this->assertSame(Str::plural('child'), (new StrProxy('child'))->plural()->get()); $this->assertSame(Str::plural('child', 2), (new StrProxy('child'))->plural(2)->get()); $this->assertSame(Str::plural('child', 1), (new StrProxy('child'))->plural(1)->get()); } /** @test */ public function str_random(): void { $pattern = '/\w{40}/'; $this->assertRegExp($pattern, Str::random(40)); // StrProxy $string = new StrProxy(''); $this->assertRegExp($pattern, $string->random(40)->get()); } /** @test */ public function str_replace_array(): void { $this->assertSame( Str::replaceArray('?', ['8:30', '9:00'], 'The event will take place between ? and ?'), (new StrProxy('The event will take place between ? and ?'))->replaceArray('?', ['8:30', '9:00'])->get() ); } /** @test */ public function str_replace_first(): void { $this->assertSame( Str::replaceFirst('the', 'a', 'the quick brown fox jumps over the lazy dog'), (new StrProxy('the quick brown fox jumps over the lazy dog'))->replaceFirst('the', 'a')->get() ); } /** @test */ public function str_replace_last(): void { $this->assertSame( Str::replaceLast('the', 'a', 'the quick brown fox jumps over the lazy dog'), (new StrProxy('the quick brown fox jumps over the lazy dog'))->replaceLast('the', 'a')->get() ); } /** @test */ public function str_singular(): void { $this->assertSame(Str::singular('cars'), (new StrProxy('cars'))->singular()->get()); $this->assertSame(Str::singular('children'), (new StrProxy('children'))->singular()->get()); } /** @test */ public function str_slug(): void { $this->assertSame( Str::slug('Laravel 5 Framework', '-'), (new StrProxy('Laravel 5 Framework'))->slug('-')->get() ); } /** @test */ public function str_snake(): void { $this->assertSame(Str::snake('fooBar'), (new StrProxy('fooBar'))->snake()->get()); } /** @test */ public function str_start(): void { $this->assertSame(Str::start('this/string', '/'), (new StrProxy('this/string'))->start('/')->get()); $this->assertSame(Str::start('/this/string', '/'), (new StrProxy('/this/string'))->start('/')->get()); } /** @test */ public function str_starts_with(): void { $this->assertSame( Str::startsWith('This is my name', 'This'), (new StrProxy('This is my name'))->startsWith('This') ); } /** @test */ public function str_studly(): void { $this->assertSame(Str::studly('foo_bar'), (new StrProxy('foo_bar'))->studly()->get()); } /** @test */ public function str_substr(): void { $this->assertSame(Str::substr('foobar', -1), (new StrProxy('foobar'))->substr(-1)->get()); } /** @test */ public function str_title(): void { $this->assertSame( Str::title('a nice title uses the correct case'), (new StrProxy('a nice title uses the correct case'))->title()->get() ); } /** @test */ public function str_uc_first(): void { $this->assertSame(Str::ucfirst('laravel'), (new StrProxy('laravel'))->ucfirst()->get()); $this->assertSame(Str::ucfirst('laravel framework'), (new StrProxy('laravel framework'))->ucfirst()->get()); } /** @test */ public function str_upper(): void { $this->assertSame(Str::upper('foo bar baz'), (new StrProxy('foo bar baz'))->upper()->get()); $this->assertSame(Str::upper('foO bAr BaZ'), (new StrProxy('foO bAr BaZ'))->upper()->get()); } /** @test */ public function str_uuid(): void { $pattern = '/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/'; $this->assertRegExp($pattern, (string) Str::uuid()); $this->assertRegExp($pattern, (string) (new StrProxy(''))->uuid()); } /** @test */ public function str_words(): void { $this->assertSame( Str::words('Perfectly balanced, as all things should be.', 3, ' >>>'), (new StrProxy('Perfectly balanced, as all things should be.'))->words(3, ' >>>')->get() ); } /** @test */ public function utterly_not_so_complex_example(): void { $this->assertSame( Str::title(Str::replaceArray('_', [' '], Str::snake('fooBar'))), (new StrProxy('fooBar'))->snake()->replaceArray('_', [' '])->title()->get() ); } }
true
cc60aaca89444ebc5a74234fb785f8e455ebbbe3
PHP
mutaimwiti/php-framework
/tests/Routing/RouteActionTest.php
UTF-8
905
2.6875
3
[ "MIT" ]
permissive
<?php namespace Tests\Routing; use Tests\TestCase; use Framework\Routing\RouteAction; class RouteActionTest extends TestCase { /** @test */ function it_allows_access_of_handler_and_arguments() { $handler = 'FooController@index'; $arguments = ['foo', 'bar']; $routeAction = new RouteAction($handler, $arguments); $this->assertEquals($handler, $routeAction->handler); $this->assertEquals($arguments, $routeAction->arguments); } /** @test */ function it_defaults_to_empty_array_for_arguments() { $routeAction = new RouteAction('FooController@index'); $this->assertEquals([], $routeAction->arguments); } /** @test */ function it_returns_null_on_access_of_non_exitent_properties() { $routeAction = new RouteAction('FooController@index'); $this->assertEquals(null, $routeAction->somthing); } }
true
f4883c379e6a87cf80aef4c2bca704d755b5a9cf
PHP
github-co/aichallenge
/website/find_user.php
UTF-8
948
2.671875
3
[]
no_license
<?php require_once("mysql_login.php"); require_once("lookup.php"); $username = mysql_real_escape_string(stripslashes($_GET['username'])); if (!isset($username) || !$username) { $users = NULL; } else { $users = search_user_row($username); if (count($users) === 1) { header("Location: profile.php?user=".$users[0]['user_id']); die(); } } require_once("header.php"); require_once("nice.php"); if ($users === NULL) { echo "<p>No search string given.</p>"; } else { echo "<h2>Users with '$username'</h2>"; if (count($users) > 0) { echo "<ul>"; foreach ($users as $user) { $username = htmlentities($user['username'], ENT_COMPAT, "UTF-8"); echo "<li>".nice_user($user['user_id'], $user['username'])."</li>"; } echo "</ul>"; } else { echo "<p>Sorry could not find any user with that name.</p>"; } } require_once("footer.php"); ?>
true
a328e6b13822b2954fc1c5d55e7b32960e73539d
PHP
yuuuuu0412/kadai
/kadai04.php
UTF-8
848
3.75
4
[]
no_license
<?php //1 function f1($value){ $result = $value *= 2; return $result; } //echo f1(); //2 function f2($a, $b){ $result = $a + $b; return $result; } //echo f2( , ); //3 $arr = array(1,3,5,7,9); function f3($arr){ $result = 1; foreach ($arr as $arr) { $result *= $arr; } return $result; } //echo f3($arr); //4 function max_array($arr){ $max_number = $arr[0]; foreach($arr as $arr){ if($max_number <= $arr){ $max_number = $arr; } } return $max_number; } //echo max_array($arr); //5 $string = "<h1>タイトル</h1>"; strip_tags($string); $array2 = array("1", "2" ); array_push($array2, "3"); $array3 = array("1", "2", "3"); $array4 = array("4", "5", "6"); array_merge($array3, $array4); echo date("Y年m月d日 l", time()); echo date("l", mktime(0,0,0,8,15,1945)); ?>
true
1c55ab8453b451c7cfefda7a919e0fd91d3dc4d8
PHP
crazymeeks/php-shopify
/src/App/Exceptions/BadRequestException.php
UTF-8
613
2.609375
3
[]
no_license
<?php declare(strict_types=1); namespace Crazymeeks\App\Exceptions; class BadRequestException extends \Exception { public static function requiredShopUrlOrAccessToken() { return new static("Access token or shop url is required."); } public static function orderIdIsRequired() { return new static("Order id is required."); } public static function collectionIdIsRequired() { return new static("Collection id is required."); } public static function scriptTagIdIsRequired() { return new static("Script tag id is required."); } }
true
4e95d836677e7d41e4caec052e22e1c57a908e0a
PHP
Namaumbo/Inventory
/app/Http/Controllers/brandsController.php
UTF-8
3,365
2.640625
3
[ "MIT" ]
permissive
<?php namespace App\Http\Controllers; use http\Exception\BadHeaderException; use http\Exception\BadMessageException; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Http\Response; use App\brands; class brandsController extends Controller { /** * Display a listing of the resource. * * @return JsonResponse */ public function index(): JsonResponse { return response()->json(brands::all()); } /** * Store a newly created resource in storage. * * @param Request $request * @return JsonResponse */ public function store(Request $request): JsonResponse { $New_brand = new brands(); $New_brand->brandName = $request->get("brandName"); $New_brand->address = $request->get("address"); $Available = brands::where('brandName',"=", $request->input('brandName'))->first(); if($Available){ return response()->json([ "message"=>"already in the database", "status"=>"401" ],401); } else { try { //saving to the database if ($New_brand->save()) { return response()->json([ "message" => "success", "status" => "ok" ], 201); } } catch (BadMessageException $ex) { }; } } /** * Display the specified resource. * * @param $brandName * @return JsonResponse */ public function show($brandName): JsonResponse { $wantedBrand = brands::find($brandName); if(($wantedBrand)){ return response()->json(["brand"=>$wantedBrand]); } else{ return response()->json(["message"=>"brand not found"],401); } } /** * Update the specified resource in storage. * * @param Request $request * @param $brandName * @return JsonResponse */ public function update(Request $request, $brandName): JsonResponse { $requestedBrand = brands::find($brandName); if(!$requestedBrand){ return response()->json(["message"=>" item not found"],401); } else{ $requestedBrand->brandName = $request->get("brandName"); $requestedBrand->address = $request->get("address"); } try { if ($requestedBrand->save()){ return response()->json([ "message" => "change done", "status" => "complete" ],201); } }catch(BadHeaderException $evt){}; } /** * Remove the specified resource from storage. * * @param $brandName * @return JsonResponse */ public function destroy($brandName): JsonResponse { $unwantedBrand = brands::find($brandName); if(is_null($unwantedBrand)){ return response()->json(["message"=>"not found"],401); } if(!$unwantedBrand){ return response()->json(["message" => "no such item in the database"],401); } else{ $unwantedBrand->delete(); return response()->json(["message"=>"items deleted successfully"],201); } } }
true
87fba9887afff909f84995627db115a070d11743
PHP
huadaxiaa/awesome-algorithm
/ranking/hackernews/hackernews.php
UTF-8
249
3.0625
3
[ "MIT" ]
permissive
<?php /** * hackernews 网站的排名算法,php 的实现 * @param $p 帖子得票数 * @param $t 发帖时间 * @param $g 重力因子 */ function hackernews($p, $t, $g){ $score = ($p -1) / pow(($t +2 ), $g); return $score; } ?>
true
a7304bb714df32a99a748f8b772e07d12c0a9d6f
PHP
JordanLiebe/TouchAndTalkPi
/talk/index.php
UTF-8
2,795
2.578125
3
[]
no_license
<html> <head> <link rel="stylesheet" type="text/css" href="../style.css"> <script src="../jquery.js"></script> </head> <body> <div id="main"> <?php $owner = "0014'; $err = 0; if ($owner == "0014"){ $sql = "Select * From touchntalkpro Where owner = '".$owner."'"; try{ $dbc = new PDO('sqlite:/home/pi/temp/main.db'); } catch(PDOException $e) { echo $e->getMessage(); $err = 1; } if($err == 0) { foreach ($dbc->query($sql) as $row) { $id = $row['id']; //$teacherABC = $row['teacher']; $owner = $row['owner']; echo '<div style="position:fixed;top:5px;left:5px;">id = ' . $id . " owner = " . $owner . "</div>"; echo '<div id="first" class="sounds" onclick="playing(1)">'; echo $row['words1']; echo '</div>'; echo '<div id="second" class="sounds" onclick="playing(2)">'; echo $row['words2']; echo '</div>'; echo '<div id="third" class="sounds" onclick="playing(3)">'; echo $row['words3']; echo '</div>'; echo '<div id="fourth" class="sounds" onclick="playing(4)">'; echo $row['words4']; echo '</div>'; echo '<script>'; echo '$(document).keydown(function(e){ ';//up echo 'if (e.keyCode == 38 ) { '; echo 'playing(1); '; echo '} '; echo '}); '; echo '$(document).keydown(function(e){ ';//down echo 'if (e.keyCode == 40 ) { '; echo 'playing(2); '; echo '} '; echo '}); '; echo '$(document).keydown(function(e){ ';//right echo 'if (e.keyCode == 39 ) { '; echo 'playing(4); '; echo '} '; echo '}); '; echo '$(document).keydown(function(e){ ';//left echo 'if (e.keyCode == 37 ) { '; echo 'playing(3); '; echo '} '; echo '}); '; echo 'function playing(num) { '; echo "if (num == 1){ "; echo 'var audio = new Audio("../sounds/'.$owner.'-1.mp3");'; echo 'audio.play();'; echo ' }'; echo "else if (num == 2){ "; echo 'var audio = new Audio("../sounds/'.$owner.'-2.mp3");'; echo 'audio.play();'; echo ' }'; echo "else if (num == 3){ "; echo 'var audio = new Audio("../sounds/'.$owner.'-3.mp3");'; echo 'audio.play();'; echo ' }'; echo "else if (num == 4){ "; echo 'var audio = new Audio("../sounds/'.$owner.'-4.mp3");'; echo 'audio.play();'; echo ' }'; echo ' }'; echo '</script>'; } } else { echo '<p>'.mysqli_error($dbc).'</p>'; echo 'Query issue'; } } else { echo "You might have come to this page my mistake, if you believe you are in the correct spot please ask your teacher for the correct URL"; } ?> </div> </body> </html>
true
50fd7187924d1bcdf11446771d8cc214505a7c00
PHP
utiamaguilherme/AMS
/AMS - FORUM/leticket/modules/shared/initializer.php
UTF-8
576
2.515625
3
[]
no_license
<?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ function getImg($img, $alt=null, $width=null){ $w = ""; if($width != null){ $w=" width=\"".$width."\" "; } $a = ""; if($alt != null){ $a=" alt=\"".$width."\" "; } return "<img $w $a src='modules/shared/images/".$img."'/>"; } function eGetImg($img, $alt=null, $width=null){ echo getImg($img, $alt, $width); }
true
af5162bbb6755362e25223798d6e67055bcb2a4d
PHP
SimonasB88/Shopware
/Exceptions/OrderNotFoundException.php
UTF-8
269
2.609375
3
[]
no_license
<?php namespace MollieShopware\Exceptions; class OrderNotFoundException extends \Exception { /** * @param $orderNumber */ public function __construct($orderNumber) { parent::__construct('Order ' . $orderNumber . ' not found!'); } }
true
2756b3745a6a6de70020368ff71f00d17abd23dc
PHP
anilpokhariyal/easyapi
/app/Http/Controllers/APIController.php
UTF-8
7,462
2.75
3
[]
no_license
<?php namespace App\Http\Controllers; use Illuminate\Http\JsonResponse; use Illuminate\Support\Facades\DB; use Illuminate\Http\Request; use Illuminate\Support\Facades\Schema; class APIController extends Controller { /** * Common api for all get apis on database tables * select = * * from = table_name * where = {field=value,field=value} * limit = 100 * order_by = {field=field_name,order=asc} * group_by = field * @example * /api/get?from=users&where={id=2,username=test}&order_by={field=id,order=asc}&select=id,full_name * @param Request $request * @return JsonResponse|void */ public function getData(Request $request){ $select = $request->get('select', null); $from = $request->get('from',null); $where = $request->get('where',0); $limit = $request->get('limit',100); $order_by = $request->get('order_by',null); $group_by = $request->get('group_by','id'); if(!$select){ $select = '*'; }else{ $select = explode(",", $select); foreach ($select as $field){ if(!Schema::hasColumn($from, $field)){ return abort(400, "Field ".$field." not exists in table which is used in select param"); } } } if(!$from){ return abort(400, "from is required."); } if(!Schema::hasTable($from)){ return abort(400, "Table does not exits in database"); } if(!$where){ $where = 0; }else{ $where = $this->decorateArray($where); foreach ($where as $field=>$value){ if(!Schema::hasColumn($from, $field)){ return abort(400, "Field ".$field." not exists in table which is used in where param"); } } } if(!$order_by){ $order_by['field'] = 'id'; $order_by['order'] = 'ASC'; }else{ $order_by = $this->decorateArray($order_by); if(!isset($order_by['field'])){ return abort(400, "Order by in wrong format"); } if(!isset($order_by['order'])){ return abort(400, "Order by in wrong format"); } if(!Schema::hasColumn($from, $order_by['field'])){ return abort(400, "Order by column not found in table"); } if(!in_array($order_by['order'],['asc','desc','ASC','DESC'])){ return abort(400, "Order by column can be sort by only asc or desc"); } } $data = DB::table($from)->select($select); if($where) { $data->where($where); } $data = $data->orderBy($order_by['field'], $order_by['order'])->groupBy($group_by)->limit($limit)->get(); return response()->json($data,200); } /** * Create entry in table * @example * curl -X POST \ * /api/create \ * -H 'cache-control: no-cache' \ * -H 'content-type: application/x-www-form-urlencoded' \ * -H 'postman-token: f5cd31d5-ce84-5326-ff4d-3a2f9664d5b7' \ * -d 'table=users&data=%7Busername%3Dtest%2Cfull_name%3DAnil%20Pokhariyal%2Cphone%3D9675517098%2Cemail%3Dtest%40gmail.com%2Ccity%3Dtest%20city%7D' * @param Request $request * @return JsonResponse|void */ public function createData(Request $request){ $table = $request->get('table',null); $create = $request->get('data','{}'); if(!$table){ return abort(400, "table param is required"); } if(!Schema::hasTable($table)){ return abort(400, "Table does not exits in database"); } $create = $this->decorateArray($create); if(count($create)==0){ return abort(400,"data param is missing to update"); }else{ foreach ($create as $field=>$value){ if(!Schema::hasColumn($table, $field)){ return abort(400, "Field ".$field." not exists in table which is used in where param"); } } } $columns = Schema::getColumnListing($table); $param_keys = ['id','created_at','updated_at','deleted_at']; $param_keys = array_merge(array_keys($create),$param_keys); foreach ($columns as $column){ if(!in_array($column,$param_keys)){ return abort(400, $column." field is required in data"); } } DB::table($table)->insert($create); return response()->json("Table data created succesfully.",200); } /** * To update all tables with id param * @example * curl -X POST \ * /api/update \ * -H 'cache-control: no-cache' \ * -H 'content-type: application/x-www-form-urlencoded' \ * -H 'postman-token: 3f516fa9-0abc-cf62-8d2f-839e90d4b4bd' \ * -d 'table=users&data=%7Bfull_name%3DAnil%20Pokhariyal%2Cphone%3D9699919998%7D&id=1' * @param Request $request * @return JsonResponse|void */ public function updateData(Request $request){ $table = $request->get('table',null); $update = $request->get('data','{}'); $id = $request->get('id',0); if(!$id){ return abort(400,"id param is required"); } if(!$table){ return abort(400, "table param is required"); } if(!Schema::hasTable($table)){ return abort(400, "Table does not exits in database"); } $update = $this->decorateArray($update); if(count($update)==0){ return abort(400,"data param is missing to update"); }else{ foreach ($update as $field=>$value){ if(!Schema::hasColumn($table, $field)){ return abort(400, "Field ".$field." not exists in table which is used in where param"); } } } DB::table($table)->where('id',$id)->update($update); return response()->json("Table updated succesfully.",200); } /** * @example * curl -X DELETE \ * /api/delete \ * -H 'cache-control: no-cache' \ * -H 'content-type: application/x-www-form-urlencoded' \ * -H 'postman-token: 68ca247d-ed29-281c-96ff-1ec5804f3e88' \ * -d 'id=2&table=users' * @param Request $request * @return JsonResponse|void */ public function deleteData(Request $request){ $table = $request->get('table',null); $id = $request->get('id',null); if(!$id){ return abort(400,"id param is required"); } if(!$table){ return abort(400, "table param is required"); } if(!Schema::hasTable($table)){ return abort(400, "Table does not exits in database"); } DB::table($table)->where('id',$id)->delete(); return response()->json("Table data deleted succesfully.",200); } /** * for creating array from request params * @param $param * @return array */ public function decorateArray($param){ $paramArr = explode(",", str_replace('}','',str_replace('{','',$param))); $output = []; foreach ($paramArr as $arr){ $tempArr = explode("=", $arr); if(count($tempArr)) { $output[$tempArr[0]] = $tempArr[1]; } } return $output; } }
true
5f73d5cbbb873c8803a32696c271f7cefab44ceb
PHP
musialbartek/zsk
/23_09.php
UTF-8
1,162
2.875
3
[]
no_license
<?php $x=1; $y=1.0; if($x===$y){ echo "identyczne<hr>"; }else{ echo "różne<hr>"; } $x=2; echo $x++;// echo ++$x;// echo $x;// $y = $x++; echo $y;// $y=++$x; echo $y;// echo ++$y;// $text='123ssd'; $x=(int)$text; echo $x,'<hr>'; //123 $text1=12; $x1=(bool)$text1; echo $x1; $text2=100; $x2=(unset)$text2; echo $x2; ######################################### $c; echo $c; echo @gettype($c);//NULL echo PHP_INT_SIZE;//4 //echo phpinfo();//PHP Version 7.2.1 ######################################## $x=10; echo is_string($x);//false echo is_int($x);//1= echo is_bools($x); echo is_float($x); echo is_null($x); ################################## //zmienne superglobalne //$_GET, $_POST, $_COOKIE, $_FILES, $_SESSION, $_SEREVER echo $_SERVER['SERVER_PORT']; echo $_SEREVER['SERVER_NAME']; echo $SERVER['SCRIPT_NAME']; echo $_SERVER['SERVER_PROTOCOL']; echo $_SERVER['DOCUMENT_ROOT']; $lokalPliku = $_SERVER['DOCUMENT_ROOT']; $_SERVER['SCRIPT_NAME']; echo $lokalPliku,'<hr>'; ########################################### define('NAZWISKO','KOWAL'); echo NAZWISKO; define('imie','Janusz'); echo imie; define ('WIEK',18,true); echo wiek; ?>
true
8776ce647af7203cf211c30952411a0a0f2c9958
PHP
lalocespedes/slim3-skeleton
/app/Middleware/AuthMiddleware.php
UTF-8
636
2.671875
3
[ "MIT" ]
permissive
<?php namespace App\Middleware; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; class AuthMiddleware extends Middleware { private $container; public function __construct($container) { $this->container = $container; } public function __invoke(Request $request, Response $response, $next) { if(!$this->container->get('App\Auth\Auth')->check()) { return $response->withRedirect($this->container->get('router')->pathFor('login')); } $response = $next($request, $response); return $response; } }
true
fa50a4a2902d75844a2a1c6e0fde97d8d286bd8a
PHP
AeonDigital/PHP-HTTP
/src/Data/File.php
UTF-8
6,428
2.734375
3
[ "MIT" ]
permissive
<?php declare (strict_types = 1); namespace AeonDigital\Http\Data; use AeonDigital\Interfaces\Http\Data\iFile as iFile; use AeonDigital\Interfaces\Stream\iFileStream as iFileStream; use AeonDigital\BObject as BObject; /** * Representa um arquivo sendo enviado por um ``UA``. * * Esta classe implementa a interface * ``Psr\Http\Message\UploadedFileInterface`` através da interface ``iFile``. * * @package AeonDigital\Http\Data * @author Rianna Cantarelli <rianna@aeondigital.com.br> * @copyright 2020, Rianna Cantarelli * @license MIT */ class File extends BObject implements iFile { use \AeonDigital\Http\Traits\MimeTypeData; /** * Identifica quando o arquivo já foi removido do local original para o local final. * * @var bool */ protected bool $isMoved = false; /** * Nome do arquivo conforme foi postado pelo ``UA``. * * @var ?string */ protected ?string $clientFilename = null; /** * Stream do arquivo. * * @var iFileStream */ protected iFileStream $fileStream; /** * Retorna o caminho completo até onde o arquivo está no momento. * * @return iFileStream */ public function getStream() : iFileStream { return $this->fileStream; } /** * Retorna o tamanho (em bytes) do ``Stream`` carregado. * Retornará ``null`` quando o stream for liberado usando o método ``dropStream``. * * @return ?int */ public function getSize() : ?int { return $this->fileStream->getSize(); } /** * Retorna o caminho completo para onde o arquivo está salvo no servidor. * * @return string */ public function getPathToFile() : string { return $this->fileStream->getPathToFile(); } /** * Retorna o nome do arquivo que está sendo enviado. * * @return string */ public function getClientFilename() : string { return ($this->clientFilename === null) ? $this->fileStream->getFilename() : $this->clientFilename; } /** * Resgata o mimetype do arquivo que está sendo enviado. * * @return string */ public function getClientMediaType() : string { return ( ($this->clientFilename === null) ? $this->fileStream->getMimeType() : $this->retrieveFileMimeType($this->clientFilename) ); } /** * Libera o ``stream`` para que o recurso possa ser usado por outra tarefa. * * Após esta ação os métodos da instância que dependem diretamente do recurso que foi * liberado não irão funcionar. * * @return void */ public function dropStream() : void { $this->fileStream->close(); } /** * Código de erro ao efetuar o upload do arquivo. * * @var ?int */ protected int $uploadError = \UPLOAD_ERR_OK; /** * Retorna o erro ao efetuar o upload do arquivo, se houver. * Não havendo erro o valor retornado é equivalente a constante ``UPLOAD_ERR_OK`` * * @return int */ public function getError() : int { return $this->uploadError; } /** * Identifica quando o ambiente atual pode ser identificado como sendo ``SAPI``. * * @return bool */ protected function isSapi() : bool { return (\substr(\php_sapi_name(), 0, 3) == "cgi"); } /** * Inicia um novo objeto ``File``. * * @param iFileStream $fileStream * Stream que representa o arquivo que está sendo enviado pelo ``UA``. * * @param ?string $clientFileName * Nome do arquivo conforme foi postado pelo ``UA``. * * @param int $uploadError * Código de erro ao efetuar o upload, caso exista. * * @throws \InvalidArgumentException * Caso o arquivo indicado não exista. */ function __construct( iFileStream $fileStream, ?string $clientFilename = null, int $uploadError = \UPLOAD_ERR_OK ) { $this->fileStream = $fileStream; $this->clientFilename = $clientFilename; $this->uploadError = $uploadError; } /** * Move o arquivo carregado para a nova localização. * * Esta ação só pode ser executada 1 vez pois o arquivo na posição original será excluido ao * final do processo. * * @codeCoverageIgnore * * @param string $targetPath * Caminho completo até o novo local onde o arquivo deve ser salvo. * * @throws \InvalidArgumentException * Caso o destino especificado seja inválido * * @throws \RuntimeException * Quando alguma operação de mover ou excluir falhar. */ public function moveTo($targetPath) : void { $isStream = \strpos($targetPath, '://') > 0; if ($isStream === false && \is_writable(\dirname($targetPath)) === false) { throw new \InvalidArgumentException("Upload target path is not writable."); } else { $errMsg = null; $this->dropStream(); if ($this->isMoved === true) { $errMsg = "Target uploaded file already moved."; } else { if ($isStream === true || $this->isSapi() === true) { if (\copy($this->getPathToFile(), $targetPath) === false) { $errMsg = "Can not move the uploaded file."; } if (\unlink($this->getPathToFile()) === false) { $errMsg = "Can not remove uploaded file from original location."; } } else { if (\rename($this->getPathToFile(), $targetPath) === false) { $errMsg = "Can not remove uploaded file from original location."; } } } if ($errMsg !== null) { throw new \RuntimeException($errMsg); } else { $this->isMoved = true; $this->fileStream->setFileStream($targetPath); } } } }
true
704be069703f4edc36ac146603bc8af9416a2d1f
PHP
jgonzalezdr/usvn
/src/library/USVN/SVNUtils.php
UTF-8
18,095
2.578125
3
[]
no_license
<?php /** * Usefull static method to manipulate an svn repository * * @author Team USVN <contact@usvn.info> * @link http://www.usvn.info * @license http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt CeCILL V2 * @copyright Copyright 2007, Team USVN * @since 0.5 * @package client * @subpackage utils * * This software has been written at EPITECH <http://www.epitech.net> * EPITECH, European Institute of Technology, Paris - FRANCE - * This project has been realised as part of * end of studies project. * * $Id: SVNUtils.php 1536 2008-11-01 16:08:37Z duponc_j $ */ class USVN_SVNUtils { public static $hooks = array('post-commit', 'post-unlock', 'pre-revprop-change', 'post-lock', 'pre-commit', 'pre-unlock', 'post-revprop-change', 'pre-lock', 'start-commit'); /** * @param string Path of subversion repository * @return bool */ public static function isSVNRepository($path, $available = false) { if (file_exists($path . "/hooks") && file_exists($path . "/db")){ return true; } if ($available && is_dir($path)) { $not_dir = false; foreach (array_diff(scandir($path), array('.', '..')) as $file) { if (!is_dir($path.'/'.$file)) { $not_dir = true; } } if ($not_dir === false) { return true; } } return false; } /** * @param string Output of svnlook changed * @return array Exemple array(array('M', 'tutu'), array('M', 'dir/tata')) */ public static function changedFiles($list) { $res = array(); $list = explode("\n", $list); foreach($list as $line) { if ($line) { $ex = explode(" ", $line, 2); array_push($res, $ex); } } return $res; } /** * Call the svnlook binary on an svn transaction. * * @param string svnlook command (see svnlook help) * @param string repository path * @param string transaction (call TXN into svn hooks samples) * @return string Output of svnlook * @see http://svnbook.red-bean.com/en/1.1/ch09s03.html */ public static function svnLookTransaction($command, $repository, $transaction) { $command = escapeshellarg($command); $transaction = escapeshellarg($transaction); $repository = escapeshellarg($repository); return USVN_ConsoleUtils::runCmdCaptureMessage(USVN_SVNUtils::svnCommand("$command -t $transaction $repository"), $return); } /** * Call the svnlook binary on an svn revision. * * @param string svnlook command (see svnlook help) * @param string repository path * @param integer revision * @return string Output of svnlook * @see http://svnbook.red-bean.com/en/1.1/ch09s03.html */ public static function svnLookRevision($command, $repository, $revision) { $command = escapeshellarg($command); $revision = escapeshellarg($revision); $repository = escapeshellarg($repository); return USVN_ConsoleUtils::runCmdCaptureMessage(USVN_SVNUtils::svnCommand("$command -r $revision $repository"), $return); } /** * Return minor version of svn client * * @return int (ex for svn 1.3.4 return 3) */ public static function getSvnMinorVersion() { $version = USVN_SVNUtils::getSvnVersion(); return $version[1]; } /** * Return version of svn client * * @return array (ex: for svn version 1.3.3 array(1, 3, 3)) */ public static function getSvnVersion() { return USVN_SVNUtils::parseSvnVersion(USVN_ConsoleUtils::runCmdCaptureMessage(USVN_SVNUtils::svnCommand("--version --quiet"), $return)); } /** * Parse output of svn --version for return the version number * * @param string output of svn --version * @return array (ex: for svn version 1.3.3 array(1, 3, 3)) */ public static function parseSvnVersion($version) { $version = rtrim($version); return explode(".", $version); } /** * Get the command svn * * @param string Parameters */ public static function svnCommand($cmd) { return "svn --config-dir /USVN/fake $cmd"; } /** * Get the command svnadmin * * @param string Parameters */ public static function svnadminCommand($cmd) { return "svnadmin --config-dir /USVN/fake $cmd"; } /** * Import file into subversion repository * * @param string path to server repository * @param string path to directory to import */ private static function _svnImport($server, $local) { $server = USVN_SVNUtils::getRepositoryFileUrl($server); $local = escapeshellarg($local); $cmd = USVN_SVNUtils::svnCommand("import --non-interactive --username USVN -m \"" . T_("Commit by USVN") ."\" $local $server"); $message = USVN_ConsoleUtils::runCmdCaptureMessage($cmd, $return); if ($return) { throw new USVN_Exception(T_("Can't import into subversion repository.\nCommand:\n%s\n\nError:\n%s"), $cmd, $message); } } /** * Create empty SVN repository * * @param string Path to create subversion */ public static function createSvn($path) { $escape_path = escapeshellarg($path); $message = USVN_ConsoleUtils::runCmdCaptureMessage(USVN_SVNUtils::svnadminCommand("create $escape_path"), $return); if ($return) { throw new USVN_Exception(T_("Can't create subversion repository: %s"), $message); } } /** * Create standard svn directories * /trunk * /tags * /branches * * @param string Path to create subversion */ public static function createStandardDirectories($path) { $tmpdir = USVN_DirectoryUtils::getTmpDirectory(); try { mkdir($tmpdir . DIRECTORY_SEPARATOR . "trunk"); mkdir($tmpdir . DIRECTORY_SEPARATOR . "branches"); mkdir($tmpdir . DIRECTORY_SEPARATOR . "tags"); USVN_SVNUtils::_svnImport($path, $tmpdir); } catch (Exception $e) { USVN_DirectoryUtils::removeDirectory($path); USVN_DirectoryUtils::removeDirectory($tmpdir); throw $e; } USVN_DirectoryUtils::removeDirectory($tmpdir); } /** * Checkout SVN repository into filesystem * @param string Path to subversion repository * @param string Path to destination */ public static function checkoutSvn($src, $dst) { $dst = escapeshellarg($dst); $src = USVN_SVNUtils::getRepositoryFileUrl($src); $message = USVN_ConsoleUtils::runCmdCaptureMessage(USVN_SVNUtils::svnCommand("co $src $dst"), $return); if ($return) { throw new USVN_Exception(T_("Can't checkout subversion repository: %s"), $message); } } /** * List files into Subversion * * @param string Path to subversion repository * @param string Path into subversion repository * @return associative array like: array(array(name => "tutu", isDirectory => true)) */ public static function listSvn($repository, $path) { $escape_path = USVN_SVNUtils::getRepositoryFileUrl($repository . '/' . $path); $lists = USVN_ConsoleUtils::runCmdCaptureMessageUnsafe(USVN_SVNUtils::svnCommand("ls --xml $escape_path"), $return); if ($return) { throw new USVN_Exception(T_("Can't list subversion repository: %s"), $lists); } $res = array(); $xml = new SimpleXMLElement($lists); foreach ($xml->list->entry as $list) { if ($list['kind'] == 'file') { array_push($res, array( "name" => (string)$list->name, "isDirectory" => false, "path" => str_replace('//', '/', $path . "/" . $list->name), "size" => $list->size, "revision" => $list->commit['revision'], "author" => $list->commit->author, "date" => $list->commit->date )); } else { array_push($res, array("name" => (string)$list->name, "isDirectory" => true, "path" => str_replace('//', '/', $path . "/" . $list->name . '/'))); } } usort($res, array("USVN_SVNUtils", "listSvnSort")); return $res; } private static function listSvnSort($a,$b){ if($a["isDirectory"]){ if($b["isDirectory"]){ return (strcasecmp($a["name"], $b["name"])); }else{ return -1; } } if($b["isDirectory"]){ return 1; } return (strcasecmp($a["name"], $b["name"])); } /** * This code work only for directory * Directory separator need to be / */ private static function getCannocialPath($path) { $origpath = $path; $path = preg_replace('#//+#', '/', $path); $list_path = preg_split('#/#', $path, -1, PREG_SPLIT_NO_EMPTY); $i = 0; while (isset($list_path[$i])) { if ($list_path[$i] == '..') { unset($list_path[$i]); if ($i > 0) { unset($list_path[$i - 1]); } $list_path = array_values($list_path); $i = 0; } elseif ($list_path[$i] == '.') { unset($list_path[$i]); $list_path = array_values($list_path); $i = 0; } else { $i++; } } $newpath = ''; $first = true; foreach ($list_path as $path) { if (!$first) { $newpath .= '/'; } else { $first = false; } $newpath .= $path; } if ($origpath[0] == '/') { return '/' . $newpath; } if(strtoupper(substr(PHP_OS, 0,3)) == 'WIN' ) { return $newpath; } else { return getcwd() . '/' . $newpath; } } /** * Return clean version of a Subversion repository path between double quotes and with file:// before * * @param string Path to repository * @return string absolute path to repository */ public static function getRepositoryFileUrl($path) { if(strtoupper(substr(PHP_OS, 0,3)) == 'WIN' ) { $newpath = realpath($path); if ($newpath === FALSE) { $path = str_replace('//', '/', str_replace('\\', '/', $path)); $path = USVN_SVNUtils::getCannocialPath($path); } else { $path = $newpath; } return '"file:///' . str_replace('\\', '/', $path) . '"'; } $newpath = realpath($path); if ($newpath === FALSE) { $newpath = USVN_SVNUtils::getCannocialPath($path); } return escapeshellarg('file://' . $newpath); } /** * * @param string Project name * @param string Path into Subversion * @return string Return url of files into Subversion */ public static function getSubversionUrl($project, $path) { $config = Zend_Registry::get('config'); $url = $config->subversion->url; if (substr($url, -1, 1) != '/') { $url .= '/'; } $url .= $project . $path; return $url; } /** * Get the path in the filesystem to the given repository. * * @param USVN_Config_Ini $config [in] Global configuration * @param string $repo_name [in] Name of the repository * @return string Path in the filesystem to the given repository */ public static function getRepositoryFilesystemPath( $config, $repo_name ) { return $config->subversion->path . DIRECTORY_SEPARATOR . 'svn' . DIRECTORY_SEPARATOR . $repo_name; } /** * Get the path in the filesystem to the templates repository. * * @param USVN_Config_Ini $config [in] Global configuration * @return string Path in the filesystem to the templates repository. */ private static function getTemplatesRepoFilesystemPath( $config ) { if( empty( $config->projectTemplates ) || empty( $config->projectTemplates->repoName ) ) { return NULL; } return self::getRepositoryFilesystemPath( $config, $config->projectTemplates->repoName ); } /** * Get the path to the templates repository in URL form (file://...). * * @param USVN_Config_Ini $config [in] Global configuration * @return string Path in URL form to the templates repository. */ private static function getTemplatesRepoFileUrl( $config ) { $path = self::getTemplatesRepoFilesystemPath( $config ); if( empty( $path ) ) { return NULL; } return self::getRepositoryFileUrl( $path ); } /** * Get the list of repository templates. * * @return array List of templates as a hashed array * @throws USVN_Exception */ public static function getRepositoryTemplates() { $config = Zend_Registry::get('config'); $path = self::getTemplatesRepoFileUrl( $config ); if( empty( $path ) ) { return NULL; } $cmd_output = USVN_ConsoleUtils::runCmdCaptureMessageUnsafe( USVN_SVNUtils::svnCommand("ls $path"), $return_code ); if ($return_code) { throw new USVN_Exception(T_("Can't list subversion templates repository: %s"), $cmd_output); } $template_list = explode("\n", $cmd_output); $template_hash = array(); foreach( $template_list as $value ) { if( empty($value) ) continue; $trimmed_value = substr( $value, 0, -1 ); $template_hash[$trimmed_value] = $trimmed_value; } return $template_hash; } /** * Get a descriptive message for the last JSON decoding error. * @return string Message for the last JSON decoding error. */ private static function getJsonErrorMsg() { if( function_exists('json_last_error_msg') ) { return json_last_error_msg(); } else { switch( json_last_error() ) { case JSON_ERROR_NONE: return 'No error'; case JSON_ERROR_DEPTH: return 'Maximum stack depth exceeded'; case JSON_ERROR_STATE_MISMATCH: return 'Underflow or the modes mismatch'; case JSON_ERROR_CTRL_CHAR: return 'Unexpected control character found'; case JSON_ERROR_SYNTAX: return 'Syntax error, malformed JSON'; case JSON_ERROR_UTF8: return 'Malformed UTF-8 characters, possibly incorrectly encoded'; default: return 'Unknown error'; } } } /** * Decode the SVN access control file (that shall be in JSON form) into * a hashed array containing the decoded elements. * * @param string $svnaccess_contents [in] SVN access control file in JSON form. * @return array Decoded elements * @throws USVN_Exception */ private static function parseAccessFile( $svnaccess_contents ) { $svnaccess_specs = json_decode( $svnaccess_contents, TRUE ); if( json_last_error() != JSON_ERROR_NONE ) { throw new USVN_Exception( "Error parsing SVN access control file: %s", self::getJsonErrorMsg() ); } return $svnaccess_specs; } /** * Get the initializer script for a new repository from a repository template, * along with the access control specs (if defined in the template). * * @param string $template_name [in] The name of the template to copy * @param string $new_repo_name [in] The name of the new repository * @param array $svnaccess_specs [out] SVN access control specs * @return string Initializer script * @throws USVN_Exception */ public static function getInitScriptFromTemplate( $template_name, $new_repo_name, &$svnaccess_specs ) { $config = Zend_Registry::get('config'); $template_svn_path = self::getTemplatesRepoFilesystemPath( $config ); if( empty( $template_svn_path ) ) { throw new USVN_Exception( T_("Can't get templates repository path from configuration.") ); } // Get template dump $cmd = 'svnadmin dump -r HEAD "'.$template_svn_path.'"'; $initial_dump = USVN_ConsoleUtils::runCmdCaptureMessageUnsafe( $cmd, $return_code, false ); if( $return_code ) { throw new USVN_Exception(T_("Can't retrieve project template from repository: %s."), $initial_dump); } // Delete the entries for other templates and for the template's root directory $new_dump = preg_replace( "~^Node-path: (?!".$template_name."\/).*?(?=(?:^Node-path:|\Z))~sm", "", $initial_dump ); // Rebase remaining entries paths $new_dump = preg_replace( "~^Node-path: ".$template_name."\/~m", "Node-path: ", $new_dump ); // Find access control file $svnaccess_filename = "svnaccess.json"; $svnaccess_specs = NULL; if( preg_match( "~^Node-path: ".$svnaccess_filename."$.*?PROPS-END$(.*?)(?:^Node-path:|\Z)~sm", $new_dump, $svnaccess_matches) ) { // Delete access control file $new_dump = preg_replace( "~^Node-path: ".$svnaccess_filename."$.*?(?=(?:Node-path:|\Z))~sm", "", $new_dump, 1, $regex_count ); if( $regex_count != 1 ) { throw new USVN_Exception(T_("Couldn't delete the access file from template:\n%s"), $initial_dump); } // Parse access control file $svnaccess_specs = USVN_SVNUtils::parseAccessFile( $svnaccess_matches[1] ); } // Replace log $new_dump = preg_replace( "~svn:log\nV.*?\n.*?((\nK \d+\n)|(\nPROPS-END\n))~sm", "svn:log\nV 8\nCreation$1", $new_dump, 1, $regex_count ); if( $regex_count != 1 ) { throw new USVN_Exception(T_("Couldn't replace the template log:\n%s"), $initial_dump); } // Replace author $new_dump = preg_replace( "~svn:author\nV.*?\n.*?\n~sm", "svn:author\nV 4\nUSVN\n", $new_dump, 1, $regex_count ); if( $regex_count != 1 ) { throw new USVN_Exception(T_("Couldn't replace the template log:\n%s"), $initial_dump); } // Replace log date $log_date = gmdate( "Y-m-d\TH:i:s.u\Z" ); $new_dump = preg_replace( "~svn:date\nV.*?\n.*?\n~sm", "svn:date\nV ".strlen($log_date)."\n".$log_date."\n", $new_dump, 1, $regex_count ); if( $regex_count != 1 ) { throw new USVN_Exception(T_("Couldn't replace the template date:\n%s"), $initial_dump); } // Replace project name placeholders (only in paths) $new_dump = preg_replace( "~(Node-path: .*?)#ProjectName#(.*)~s", "$1".$new_repo_name."$2", $new_dump ); return $new_dump; } /** * Initializes a repository from an initialization script. * * @param string $new_repo_name [in] The name of the new repository * @param string $init_script [in] Initializer script for the new repository * @throws USVN_Exception */ public static function initRepositoryFromScript( $new_repo_name, $init_script ) { $config = Zend_Registry::get('config'); $new_repo_svn_path = self::getRepositoryFilesystemPath( $config, $new_repo_name ); // Load template dump $cmd = "svnadmin load $new_repo_svn_path"; $load_msg = USVN_ConsoleUtils::runCmdSendMessageToStdin( $cmd, $return_code, $init_script ); if( $return_code ) { throw new USVN_Exception(T_("Can't import project template into the new repository: %s"), $load_msg); } } }
true
02dc7ed87f9a04ebd1053a360e08a3ff1e4d85b4
PHP
php-task/php-task
/src/Task/Lock/Storage/FileLockStorage.php
UTF-8
1,690
2.90625
3
[ "MIT" ]
permissive
<?php /* * This file is part of php-task library. * * (c) php-task * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace Task\Lock\Storage; use Task\Lock\LockStorageInterface; /** * Save locks in the filesystem. */ class FileLockStorage implements LockStorageInterface { /** * @var string */ private $lockPath; /** * @param string $lockPath */ public function __construct($lockPath) { $this->lockPath = $lockPath; if (!is_dir($this->lockPath)) { mkdir($this->lockPath, 0777, true); } } /** * {@inheritdoc} */ public function save($key, $ttl) { $fileName = $this->getFileName($key); if (!@file_put_contents($fileName, time() + $ttl)) { return false; } return true; } /** * {@inheritdoc} */ public function delete($key) { $fileName = $this->getFileName($key); if (!file_exists($fileName)) { return true; } if (!@unlink($fileName)) { return false; } return true; } /** * {@inheritdoc} */ public function exists($key) { $fileName = $this->getFileName($key); if (!file_exists($fileName)) { return false; } $content = file_get_contents($fileName); return time() <= $content; } /** * {@inheritdoc} */ private function getFileName($key) { return $this->lockPath . DIRECTORY_SEPARATOR . preg_replace('/[^a-zA-Z0-9]/', '_', $key) . '.lock'; } }
true
603a5d039c225f0962a60f998046b5f08c0638d2
PHP
rongcloud/server-sdk-php
/RongCloud/Lib/Chatroom/Gag/Gag.php
UTF-8
4,036
2.5625
3
[ "MIT" ]
permissive
<?php /** * 聊天室成员禁言 */ namespace RongCloud\Lib\Chatroom\Gag; use RongCloud\Lib\Request; use RongCloud\Lib\Utils; class Gag { /** * 聊天室成员禁言路径 * * @var string */ private $jsonPath = 'Lib/Chatroom/Gag/'; /** * 请求配置文件 * * @var string */ private $conf = ""; /** * 校验配置文件 * * @var string */ private $verify = ""; /** * Gag constructor. */ function __construct() { $this->conf = Utils::getJson($this->jsonPath.'api.json'); $this->verify = Utils::getJson($this->jsonPath.'../verify.json');; } /** * 添加成员禁言 * * @param array $Chatroom * $Chatroom = [ 'id'=> 'ujadk90ha',//聊天室 id 'members'=> [ ['id'=>'seal9901']//禁言成员 id ], 'minute'=>30//禁言时长 ]; * @return mixed|null */ public function add(array $Chatroom=[]){ $conf = $this->conf['add']; $verify = $this->verify['chatroom'] ; $verify = ['id'=>$verify['id'],'members'=>$verify['members'],'minute'=>$verify['minute']]; $error = (new Utils())->check([ 'api'=> $conf, 'model'=> 'chatroom', 'data'=> $Chatroom, 'verify'=> $verify ]); if($error) return $error; foreach ($Chatroom['members'] as &$v){ $v = $v['id']; } $Chatroom = (new Utils())->rename($Chatroom, [ 'members'=>'userId', 'id'=>'chatroomId' ]); $result = (new Request())->Request($conf['url'],$Chatroom); $result = (new Utils())->responseError($result, $conf['response']['fail']); return $result; } /** * 解除聊天室成员禁言 * * @param array $Chatroom * $Chatroom = [ 'id'=> 'ujadk90ha',//聊天室 id 'members'=> [ ['id'=>'seal9901']//人员 id ] ]; * @return mixed|null */ public function remove(array $Chatroom=[]){ $conf = $this->conf['remove']; $verify = $this->verify['chatroom'] ; $verify = ['id'=>$verify['id'],'members'=>$verify['members']]; $error = (new Utils())->check([ 'api'=> $conf, 'model'=> 'chatroom', 'data'=> $Chatroom, 'verify'=> $verify ]); if($error) return $error; foreach ($Chatroom['members'] as &$v){ $v = $v['id']; } $Chatroom = (new Utils())->rename($Chatroom, [ 'id'=>'chatroomId', 'members'=>'userId' ]); $result = (new Request())->Request($conf['url'],$Chatroom); $result = (new Utils())->responseError($result, $conf['response']['fail']); return $result; } /** * 获取聊天室成员禁言列表 * * @param array $Chatroom * $Chatroom = [ 'id'=> 'ujadk90ha',//聊天室 id ]; * @return mixed|null */ public function getList(array $Chatroom=[]){ $conf = $this->conf['getList']; $verify = $this->verify['chatroom'] ; $verify = ['id'=>$verify['id']]; $error = (new Utils())->check([ 'api'=> $conf, 'model'=> 'chatroom', 'data'=> $Chatroom, 'verify'=> $verify ]); if($error) return $error; $Chatroom = (new Utils())->rename($Chatroom, [ 'id'=>'chatroomId' ]); $result = (new Request())->Request($conf['url'],$Chatroom); $result = (new Utils())->responseError($result, $conf['response']['fail']); if($result['code'] == 200){ $result = (new Utils())->rename($result,['users'=>'members']); foreach ($result['members'] as $k=>&$v){ $v = (new Utils())->rename($v,['userId'=>'id']); } } return $result; } }
true
4260efaf367936d9c0f4129a4584094b518d5d74
PHP
taginnovationschool/codemaster-mailup
/src/HttpClient/Formatter/HttpClientFormatterInterface.php
UTF-8
920
2.9375
3
[]
no_license
<?php namespace Codemaster\MailUp\HttpClient\Formatter; /** * Interface implemented by formatter implementations for the http client */ interface HttpClientFormatterInterface { /** * Serializes arbitrary data to the implemented format. * * @param mixed $data * The data that should be serialized. * * @return string * The serialized data as a string. */ public function serialize($data); /** * Unserializes data in the implemented format. * * @param string $data * The data that should be unserialized. * * @return mixed * The unserialized data. */ public function unserialize($data); /** * Return the mime type that the formatter can parse. */ public function accepts(); /** * Return the content type form the data the formatter generates. */ public function contentType(); }
true
6deaba38365361d428df573ddab36d5b40881620
PHP
admix/php_pracc_fun
/array_funcs/array_map_exmpl.php
UTF-8
448
4.21875
4
[ "Apache-2.0" ]
permissive
<?php function fourth($num) //calculated the fourth degree of the $num { return ($num * $num * $num * $num); } $a = array(1,2,3,4,5,6,7); $b = array_map("fourth", $a); print_r($b); /* ---------------------------------------- */ function concat($str) //making all letters in the string UPPERCASE { return strtoupper($str); } $str = array("Bob","Matt","Tom","Alex","Michael"); $out = array_map("concat", $str); print_r($out); ?>
true
c898f1cb25aac325b2a357e7895b2688ff7d5137
PHP
darrenwilly/bot-skeleton
/lib/global-autoload.php
UTF-8
5,966
2.703125
3
[ "MIT" ]
permissive
<?php declare(strict_types=1) ; /** * Logic that create a loadable PSR array dataset include file for autoloader base on available modular folder * * @param $psrTypeFile */ function _generate_psr_file($dirToGenerate=__DIR__) { /** * Please note that before this __FILE__ is called, master autoload must have been called or loaded * Also, this class \Laminas\Code\Generator\FileGenerator() must be available */ if(! class_exists('\Laminas\Code\Generator\FileGenerator')) { trigger_error('Laminas Code Generator Class is required to generated Autoloader script files'); die; } ## load all the extra lib in this directory $dirIterator = new \DirectoryIterator($dirToGenerate) ; ## $lib_autoloader_list = [] ; ## $psrbody = function ($lib_autoloader_list) { ## $return = vsprintf(' $rootDir = __DIR__ ; $config = %s ; ## return $config ; ', var_export($lib_autoloader_list, true)); ## return $return; } ; $psr4_template_filename = 'autoload_psr4.php' ; $psr0_template_filename = 'autoload_psr0.php' ; $lib_autoloader_list = [] ; $lib_autoloader_list0 = [] ; ## iterate it foreach ($dirIterator as $dirItem) { ## if($dirItem->isFile() || $dirItem->isDot()) { ## skip all files continue ; } ## check and make sure they are not dot if ($dirItem->isDir()) { ## create the composer.json file $composerJsonFile = $dirItem->getRealPath() . '/composer.json'; ## check if the composer json file exist if (file_exists($composerJsonFile)) { ## fetch the json content $jsonContent = file_get_contents($composerJsonFile); ## decode the composer.json sir $composerJsonObject = json_decode($jsonContent , true); ## check and make sure that psr4 is set if(isset($composerJsonObject['autoload']['psr-4'])) { ## bcos autoload/psr4 is always array, so iterate foreach ($composerJsonObject['autoload']['psr-4'] as $psr4Namespace => $psr4NamespaceDir) { ## add the psr dir to the project autoloader #$autoloader->addPsr4($psr4Namespace , $dir->getRealPath().DIRECTORY_SEPARATOR.$psr4NamespaceDir); $lib_autoloader_list[$psr4Namespace][] = realpath($dirItem->getRealPath().DIRECTORY_SEPARATOR.$psr4NamespaceDir) ; } } elseif(isset($composerJsonObject['autoload']['psr-0'])) { /** * add the psr0 dir variant */ foreach ($composerJsonObject['autoload']['psr-0'] as $psr0Namespace => $psr0NamespaceDir) { ## $lib_autoloader_list0[$psr0Namespace][] = __DIR__.DIRECTORY_SEPARATOR.$dirItem->getBasename().DIRECTORY_SEPARATOR.$psr0NamespaceDir; } } } ## what happends when the director to load does not have a composer.json file, I think we needto be able to create sample composer.json file } } ## initialize the code generator $Laminas_code_generator = new \Laminas\Code\Generator\FileGenerator() ; /** * Now it is time to generate the PSR4 file autoloader */ if(0 < count($lib_autoloader_list)) { ## set the body template and pass the value to generate $Laminas_code_generator->setBody($psrbody($lib_autoloader_list)) ; file_put_contents(sprintf('%s/%s' , $dirToGenerate ,$psr4_template_filename) , $Laminas_code_generator->generate()) ; } /** * Now it is time to generate the PSR0 file autoloader */ if(0 < count($lib_autoloader_list0)) { ## set the body template and pass the value to generate $Laminas_code_generator->setBody($psrbody($lib_autoloader_list0)) ; ## file_put_contents(sprintf('%s/%s' , $dirToGenerate , $psr0_template_filename) , $Laminas_code_generator->generate()) ; } } ; ## function _load_global_lib(array $project) { $projectName = key($project) ; $projectDir = $project[$projectName] ; ## check for existence of vendor folder in the project if(! is_dir($projectDir . '/vendor')) { ## return false ; } ## $autoloaderFile = $projectDir . '/vendor/autoload.php'; if(! file_exists($autoloaderFile)) { return false ; } ## autoload the project autoloader generator in vendor $autoloader = include $autoloaderFile ; /** * We always want the LIB to be load bcos in situation where a library is having dependencies issues or some requireemnt are not meant, * we can manually download the library and load it ourselves */ require __DIR__.'/_external_autoloader.php' ; ## __autoload_external_modules_namespace($autoloader); /** * Bcos this application is a modular one, we are going to make it load other modular folder in the SRC too * Therefore, we need to create a logic that check the PSR4 for his own set of autoloader file */ if(defined('ENABLE_PLUGGABLE_MODULE')) { ## require PLUGGABLE_MODULE_AUTOLOAD_FILE ; ## __autoload_pluggable_modules_namespace($autoloader) ; } ## return $autoloader ; } ## set a value that show that global autoload has been called if(! defined('GLOBAL_AUTOLOAD_ALREADY_CALLED')) { ## define('GLOBAL_AUTOLOAD_ALREADY_CALLED' , 1) ; ## load the current project and add the extra library to his dependency return _load_global_lib(CURRENT_PROJECT_TO_AUTOLOAD) ; }
true
4adf0387b8ee25678f173ac16eda11bebbd2926e
PHP
alexandre-ostacolpin/coursPHP
/inc/tete.inc.php
UTF-8
808
3.0625
3
[]
no_license
<!DOCTYPE html> <?php $variable1 = " la page faite avec des fichiers en INC"; ?> <html lang="fr"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <?php echo " <title>Page faite avec des fichiers inc </title> "; ?> </head> <body> <?php echo "<div><h1 style=\"border-width:5;border-style:double;background-color:#ffcc99;\">Bienvenue sur $variable1 </h1>"; /*ceci est un commentaire sur plusieur lignes pour le php */ echo "<p>Une fonction qui donne le nom du fichier exécuté : ", $_SERVER['PHP_SELF'],"<p></div>"; //Si on le souhaite, il n'est pas utile de fermer le passage php car il se poursuit dans le fichier qui vient après
true
337635ba49ab3137e2886332ff5417e44c5e3220
PHP
tsorelle/austinquakers.net
/web.root/tops/tops_lib/vr/vr_api_response.php
UTF-8
904
3.0625
3
[]
no_license
<?php namespace VerticalResponse\API; /** * Response class for the VR API. */ class Response { public $url; public $items; public $attributes; public $links; public $success; public $error; function __construct($response) { $this->items = $this->extract("items", $response); $this->attributes = $this->extract("attributes", $response); $this->links = $this->extract("links", $response); $this->success = $this->extract("success", $response); $this->error = $this->extract("error", $response); $this->url = $this->extract("url", $response); } // Extracts the content of the response with the given key private function extract($key, $response) { $result = null; if(array_key_exists($key, $response)) { $result = $response[$key]; } return $result; } } ?>
true
277abb5ed5a42647539adccea2ef62b7a7f33897
PHP
pchauvelin/supply
/src/Entity/Sale.php
UTF-8
2,904
2.734375
3
[]
no_license
<?php namespace App\Entity; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity(repositoryClass="App\Repository\SaleRepository") */ class Sale { /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255, unique=true) */ private $saleNumber; /** * @ORM\Column(type="datetime") */ private $createdAt; /** * @ORM\OneToMany(targetEntity="SaleItem", mappedBy="sale", cascade={"persist", "remove"}) */ private $items; /** * @ORM\Column(type="boolean", options={"default": false}) */ private $isLocked = false; /** * Sale constructor. */ public function __construct() { $this->items = new ArrayCollection(); } /** * @return int|null */ public function getId(): ?int { return $this->id; } /** * @return null|string */ public function getSaleNumber(): ?string { return $this->saleNumber; } /** * @param string $saleNumber * @return Sale */ public function setSaleNumber(string $saleNumber): self { $this->saleNumber = $saleNumber; return $this; } /** * @return \DateTimeInterface|null */ public function getCreatedAt(): ?\DateTimeInterface { return $this->createdAt; } /** * @param \DateTimeInterface $createdAt * @return Sale */ public function setCreatedAt(\DateTimeInterface $createdAt): self { $this->createdAt = $createdAt; return $this; } /** * @return Collection|SaleItem[] */ public function getItems(): Collection { return $this->items; } /** * @param SaleItem $item * @return Sale */ public function addItem(SaleItem $item): self { if (!$this->items->contains($item)) { $this->items[] = $item; $item->setSale($this); } return $this; } /** * @param SaleItem $item * @return Sale */ public function removeItem(SaleItem $item): self { if ($this->items->contains($item)) { $this->items->removeElement($item); // set the owning side to null (unless already changed) if ($item->getSale() === $this) { $item->setSale(null); } } return $this; } /** * @return bool|null */ public function isLocked(): ?bool { return $this->isLocked; } /** * @param bool $isLocked * @return Sale */ public function setIsLocked(bool $isLocked): self { $this->isLocked = $isLocked; return $this; } }
true
ec8b96a5f3d0343e25a74864fec5698f947d6e6d
PHP
lamquanghagisc/kinhdoanh_q4
/widgets/maps/types/DivIcon.php
UTF-8
3,544
2.6875
3
[ "BSD-3-Clause" ]
permissive
<?php /** * @copyright Copyright (c) 2013-2015 2amigOS! Consulting Group LLC * @link http://2amigos.us * @license http://www.opensource.org/licenses/bsd-license.php New BSD License */ namespace app\widgets\maps\types; use dosamigos\leaflet\LeafLet; use yii\helpers\Json; use yii\web\JsExpression; /** * * DivIcon represents a lightweight icon for markers that uses a simple div element instead of an image. * * @see http://leafletjs.com/reference.html#divicon * @author Antonio Ramirez <amigo.cobos@gmail.com> * @link http://www.ramirezcobos.com/ * @link http://www.2amigos.us/ * @package dosamigos\leaflet\types */ class DivIcon extends Type { /** * @var string the variable name. If not null, then the js icon creation script * will be returned as a variable: * * ``` * var iconName = L.divIcon({...}); * // after it can be shared among other markers * L.marker({icon: iconName, ...).addTo(map); * L.marker({icon: iconName, ...).addTo(map); * ``` * If null, the js icon creation script will be returned to be used as constructor so it can be used within another * constructor options: * * ``` * L.marker({icon: L.icon({...}), ...).addTo(map); * ``` */ public $name; /** * @var string a custom class name to assign to both icon and shadow images. Empty by default. */ public $className; /** * @var string a custom HTML code to put inside the div element, empty by default. */ public $html; /** * @var Point size of the icon image in pixels. */ private $_iconSize; /** * @var Point the coordinates of the "tip" of the icon (relative to its top left corner). The icon will be aligned so * that this point is at the marker's geographical location. Centered by default if size is specified, also can be * set in CSS with negative margins. */ private $_iconAnchor; /** * @param Point $iconSize */ public function setIconSize(Point $iconSize) { $this->_iconSize = $iconSize; } /** * @return Point */ public function getIconSize() { return $this->_iconSize; } /** * @param Point $iconAnchor */ public function setIconAnchor(Point $iconAnchor) { $this->_iconAnchor = $iconAnchor; } /** * @return Point */ public function getIconAnchor() { return $this->_iconAnchor; } /** * @return \yii\web\JsExpression the js initialization code of the object */ public function encode() { $options = Json::encode($this->getOptions(), LeafLet::JSON_OPTIONS); $js = "L.divIcon($options)"; if ($this->name) { $js = "var $this->name = $js;"; } return new JsExpression($js); } /** * @return array the configuration options of the array */ public function getOptions() { $options = []; $class = new \ReflectionClass(__CLASS__); foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { if (!$property->isStatic()) { $name = $property->getName(); $options[$name] = $this->$name; } } foreach (['iconSize', 'iconAnchor'] as $property) { $point = $this->$property; if ($point instanceof Point) { $options[$property] = $point->toArray(true); } } return array_filter($options); } }
true
08ff63bd2d4f1b23829918207e5d3a7704a84f70
PHP
sebastian-lenz/craft-utils
/src/events/AnchorsEvent.php
UTF-8
1,840
2.921875
3
[ "MIT" ]
permissive
<?php namespace lenz\craft\utils\events; use craft\base\ElementInterface; use yii\base\Event; /** * Class AnchorsEvent */ class AnchorsEvent extends AbstractElementEvent { /** * @var array */ private array $_anchors = []; /** * @var string */ const EVENT_FIND_ANCHORS = 'findAnchors'; /** * @param string $anchor The anchor as it appears in the document (the id or fragment) * @param string|null $title A human-readable label for the anchor * @param string|null $id A unique id that identifies this anchor * @noinspection PhpUnused (API) */ public function addAnchor(string $anchor, string $title = null, string $id = null) { if (!is_null($id) && !AnchorEvent::isAnchorId($id)) { $id = AnchorEvent::ID_PREFIX . $id; } $this->_anchors[] = [ 'anchor' => $anchor, 'id' => $id, 'title' => empty($title) ? $anchor : $title, ]; } /** * @return array */ public function getAnchors(): array { return $this->_anchors; } // Static methods // -------------- /** * @param ElementInterface $element * @return array */ static public function findAnchors(ElementInterface $element): array { $event = new AnchorsEvent([ 'element' => $element, ]); Event::trigger(AnchorsEvent::class, self::EVENT_FIND_ANCHORS, $event); return $event->getAnchors(); } /** * @param int|string $elementId * @param int|string|null $siteId * @return array * @noinspection PhpUnused (API) */ static public function findAnchorsById(int|string $elementId, int|string $siteId = null): array { $event = new AnchorsEvent([ 'elementId' => $elementId, 'siteId' => $siteId, ]); Event::trigger(AnchorsEvent::class, self::EVENT_FIND_ANCHORS, $event); return $event->getAnchors(); } }
true
0742a2e37cc1237dbba21070b465e8537d69c5a5
PHP
msredhotero/crmcreditos
/includes/zulmaQuitar.php
UTF-8
7,631
2.515625
3
[ "MIT" ]
permissive
<?php function columnaTablaModificar($id,$lblid,$tabla,$nombreCampo,$columnaSize,$catalogos) { $serviciosFunciones = new Servicios(); switch ($tabla) { default: $sqlMod = "select * from ".$tabla." where ".$lblid." = ".$id; $resMod = $this->query($sqlMod,0); } $lblcambio = $serviciosFunciones->traerLblCambioReemplazo($tabla,'lblCambio'); $lblreemplazo =$serviciosFunciones->traerLblCambioReemplazo($tabla,'lblreemplazo'); $sql = "show columns from ".$tabla; $res = $this->query($sql,0); $ocultar = array("fechacrea","fechamodi","usuacrea","usuamodi"); $camposEscondido = ""; if ($res == false) { return 'Error al traer datos'; } else { $camposFormulario= array(); $form = ''; while ($row = mysql_fetch_array($res)) { $label = $row[0]; $i = 0; $refdescripcion = array(); $refCampo = array(); $lblcambio = array(); $lblreemplazo = array(); if(preg_match("/^ref/", $label)){ // se trata de un catalogo se debe buscar su tabla $resCatalogo = $this->traerDatosCatalogo($catalogos[$label]); $cadRef2 = $serviciosFunciones->devolverSelectBox($resCatalogo,array(1),''); $refdescripcion[]=$cadRef2; $refCampo[]=$label; } foreach ($lblcambio as $cambio) { if ($row[0] == $cambio) { $label = $lblreemplazo[$i]; $i = 0; break; } else { $label = $row[0]; } $i = $i + 1; } if (in_array($row[0],$ocultar)) { $lblOculta = "none"; } else { $lblOculta = "block"; } if ($row[3] != 'PRI') { if (strpos($row[1],"decimal") !== false) { $camposFormulario[$nombreCampo] = ' <div class="form-group col-md-6" style="display:'.$lblOculta.'"> <label for="'.$label.'" class="control-label" style="text-align:left">'.ucwords($label).'</label> <div class="input-group col-md-12"> <span class="input-group-addon">€</span> <input type="text" class="form-control" id="'.strtolower($row[0]).'" name="'.strtolower($row[0]).'" value="'.mysql_result($resMod,0,$row[0]).'" required> <span class="input-group-addon">.00</span> </div> </div> '; } else { if ( in_array($row[0],$refCampo) ) { $campo = strtolower($row[0]); $option = $refdescripcion[array_search($row[0], $refCampo)]; $form1 =' <div class="form-group col-md-6" style="display:'.$lblOculta.'"> <label for="'.$campo.'" class="control-label" style="text-align:left">'.$label.'</label> <div class="input-group col-md-12"> <select class="form-control" id="'.strtolower($campo).'" name="'.strtolower($campo).'"> '; $form1 .= $option; $form1 = '</select> </div> </div> '; $camposFormulario[$nombreCampo] = $form1; } else { if (strpos($row[1],"bit") !== false) { $label = ucwords($label); $campo = strtolower($row[0]); $activo = ''; if (mysql_result($resMod,0,$row[0])==1){ $activo = 'checked'; } $camposFormulario[$nombreCampo] =' <div class="form-group col-md-6" style="display:'.$lblOculta.'"> <label for="'.$campo.'" class="control-label" style="text-align:left">'.$label.'</label> <div class="input-group col-md-12 fontcheck"> <input type="checkbox" '.$activo.' class="form-control" id="'.$campo.'" name="'.$campo.'" style="width:50px;" required> <p>Si/No</p> </div> </div>'; } else { if (strpos($row[1],"date") !== false) { $label = ucwords($label); $campo = strtolower($row[0]); $camposFormulario[$nombreCampo]= ' <div class="form-group col-md-6" style="display:'.$lblOculta.'"> <label for="'.$campo.'" class="control-label" style="text-align:left">'.$label.'</label> <div class="input-group date form_date col-md-6" data-date="" data-date-format="dd MM yyyy" data-link-field="'.$campo.'" data-link-format="yyyy-mm-dd"> <input class="form-control" value="'.mysql_result($resMod,0,$row[0]).'" size="50" type="text" value="" readonly> <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span> </div> <input type="hidden" name="'.$campo.'" id="'.$campo.'" value="'.mysql_result($resMod,0,$row[0]).'" /> </div> '; } else { if (strpos($row[1],"time") !== false) { $label = ucwords($label); $campo = strtolower($row[0]); $camposFormulario[$nombreCampo]= ' <div class="form-group col-md-6" style="display:'.$lblOculta.'"> <label for="'.$campo.'" class="control-label" style="text-align:left">'.$label.'</label> <div class="input-group bootstrap-timepicker col-md-6"> <input id="timepicker2" value="'.mysql_result($resMod,0,$row[0]).'" name="'.$campo.'" class="form-control"> <span class="input-group-addon"> <span class="glyphicon glyphicon-time"></span> </span> </div> </div> '; } else { if ((integer)(str_replace('varchar(','',$row[1])) > 200) { $label = ucwords($label); $campo = strtolower($row[0]); $camposFormulario[$nombreCampo]= ' <div class="form-group col-md-6" style="display:'.$lblOculta.'"> <label for="'.$campo.'" class="control-label" style="text-align:left">'.$label.'</label> <div class="input-group col-md-12"> <textarea type="text" rows="10" cols="6" class="form-control" id="'.$campo.'" name="'.$campo.'" placeholder="Ingrese el '.$label.'..." required>'.utf8_encode(mysql_result($resMod,0,$row[0])).'</textarea> </div> </div> '; } else { if ($row[1] == 'MEDIUMTEXT') { $label = ucwords($label); $campo = strtolower($row[0]); $camposFormulario[$nombreCampo]= ' <div class="form-group col-md-12" style="display:'.$lblOculta.'"> <label for="'.$campo.'" class="control-label" style="text-align:left">'.$label.'</label> <div class="input-group col-md-12"> <textarea name="'.$campo.'" id="'.$campo.'" rows="200" cols="160"> Ingrese la noticia. </textarea> </div> </div>'; } else { $label = ucwords($label); $campo = strtolower($row[0]); $camposFormulario[$nombreCampo] = ' <div class="form-group col-md-6" style="display:'.$lblOculta.'"> <label for="'.$campo.'" class="control-label" style="text-align:left">'.$label.'</label> <div class="input-group col-md-12"> <input type="text" value="'.(mysql_result($resMod,0,$row[0])).'" class="form-control" id="'.$campo.'" name="'.$campo.'" placeholder="Ingrese el '.$label.'..." required> </div> </div>'; } } } } } } } } else { $camposFormulario[$nombreCampo] = '<input type="hidden" id="accion" name="accion" value="'.$accion.'"/>'.'<input type="hidden" id="id" name="id" value="'.$id.'"/>'; } } $formulario = $form."<br><br>".$camposEscondido; return $camposFormulario; } } ?>
true
0dce561790f5812484c98549e4d5666013da910d
PHP
flaviovs/uconfig
/tests/config.php
UTF-8
896
2.5625
3
[ "MIT" ]
permissive
<?php use UConfig\Config; class ConfigTestCase extends PHPUnit_Framework_TestCase { public function testConstructorDefaults() { $defaults = [ 'section' => [ 'foo' => 'bar', ], ]; $cfg = new Config($defaults); $this->assertEquals($defaults, $cfg->getItems()); } public function testGet() { $cfg = new Config([ 'section' => [ 'a' => 'b', ], ]); $this->assertEquals($cfg->get('section', 'a'), 'b'); } public function testNonexistentSectionThrowsException() { $cfg = new Config(); $this->setExpectedException('UConfig\SectionNotFoundException'); $cfg->get('foo', 'bar'); } public function testNonexistentOptionThrowsException() { $cfg = new Config(['section' => []]); $this->setExpectedException('UConfig\OptionNotFoundException'); $cfg->get('section', 'bar'); } }
true
b493c6e5c617be9979241ed79d208aeeea849452
PHP
MDobak/DoctrineDynamicShardsBundle
/src/Doctrine/DBAL/DynamicShardConnection.php
UTF-8
2,999
2.578125
3
[]
no_license
<?php namespace MDobak\DoctrineDynamicShardsBundle\Doctrine\DBAL; use Doctrine\Common\EventManager; use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Sharding\PoolingShardConnection; use MDobak\DoctrineDynamicShardsBundle\Shard\ShardRegistryInterface; /** * Class DynamicShardConnection * * @author Michał Dobaczewski <mdobak@gmail.com> */ class DynamicShardConnection extends PoolingShardConnection implements DynamicShardConnectionInterface { /** * @var array */ private $knownShards = []; /** * @var ShardRegistryInterface */ private $shardRegistry; /** * @var array */ private $globalParams; /** * @param array $params * @param \Doctrine\DBAL\Driver $driver * @param \Doctrine\DBAL\Configuration $config * @param \Doctrine\Common\EventManager $eventManager * * @throws \InvalidArgumentException */ public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null) { $params['shards'] = $params['shards'] ?? []; $params['global'] = $params['global'] ?? $params; if (isset($params['driverOptions']['shard_registry'])) { $this->shardRegistry = $params['driverOptions']['shard_registry']; } parent::__construct($params, $driver, $config, $eventManager); $this->globalParams = array_merge($params, $params['global']); $this->knownShards = [0]; // Shard "0" maps to "global" config on PoolingShardConnection. foreach ($params['shards'] as $shard) { $this->knownShards[] = $shard['id']; } } /** * {@inheritdoc} */ public function getParams() { return isset($this->knownShards[$this->getActiveShardId()]) ? $this->getParams() : $this->getParamsForShard($this->getActiveShardId()); } /** * Connects to a specific connection. * * @param string $shardId * * @return \Doctrine\DBAL\Driver\Connection */ protected function connectTo($shardId) { if (in_array($shardId, $this->knownShards, true)) { return parent::connectTo($shardId); } $connectionParams = $this->getParamsForShard($shardId); $user = isset($connectionParams['user']) ? $connectionParams['user'] : null; $password = isset($connectionParams['password']) ? $connectionParams['password'] : null; $driverOptions = isset($params['driverOptions']) ? $params['driverOptions'] : []; return $this->_driver->connect($connectionParams, $user, $password, $driverOptions); } /** * @param $shardId * * @return array */ protected function getParamsForShard($shardId): array { $params = $this->globalParams; $shard = $this->shardRegistry->getShard($shardId); return array_merge($params, $shard); } }
true
ec29d997c08e96b8b16d480c8d602b16bdcef77b
PHP
yordan-kovachev/BoxGifts
/customer/cust_details_update.php
UTF-8
5,664
2.5625
3
[]
no_license
<?php /*Created by *author name: Yordan Kovachev *author id: abdt361 *date created: 04/2012 */ //This block check if the customer is logged in or not session_start(); if(!isset($_SESSION["customer"])){ header("location: customer_login.php"); exit(); } //Now establish DB connection include('../store/storescripts/config.php'); ?> <?php //Error reporting block error_reporting(E_ALL); ini_set('display_errors','1'); ?> <?php //Parse the information from the personal details form on to the system if(isset($_POST['firstname']) && isset($_POST['lastname']) && isset($_POST['dob']) && isset($_POST['gender']) && isset($_POST['phone']) && isset($_POST['email']) && isset($_POST['username']) && isset($_POST['password'])){ $cid = ($_GET['id']); $firstname = ($_POST['firstname']); $lastname = ($_POST['lastname']); $dob = ($_POST['dob']); $gender = ($_POST['gender']); $phone = ($_POST['phone']); $email = ($_POST['email']); $username = ($_POST['username']); $password = ($_POST['password']); //Check if the new customer details exists in the db already $sql = "UPDATE customers SET firstname='$firstname', lastname='$lastname', dob='$dob', gender='$gender', phone='$phone', email='$email', username='$username', password='$password' WHERE id='$cid'"; $res = iQuery($sql); header("location: customer_details.php"); exit(); } ?> <?php //Get all of the information for the selected customer id and display it on the form bellow for edit purposes if (isset($_GET['cid'])){ $targetID = $_GET['cid']; $sql = "SELECT * FROM customers WHERE id='$targetID'"; $res = query($sql); if($res) { foreach ($res as $row) { $firstname = $row["firstname"]; $lastname = $row["lastname"]; $dob = $row["dob"]; $gender = $row["gender"]; $phone = $row["phone"]; $email = $row["email"]; $username = $row["username"]; $password = $row["password"]; } }else{ echo"Error - the customer details do not exist in the system. You should't see this message at all if customer is already logged in the system."; exit(); } } ?> <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>BoxGifts-Customer</title> <link rel="stylesheet" href="../css/mainStyle.css" type="text/css" media="screen"> </head> <body> <div align="center" id="mainWraper"> <?php include_once("../store/template_header.php");?> <div align="left"; style="margin-right: 24px; width: 920px; margin-left:auto; margin-right:auto; border: 1px solid #000;"> </div> <div id="pageContent" style="width:920px;"><br/> <div align="right" style="padding-right:120px; padding-top: 20px; margin-left:auto; margin-right:auto; width:920px"><a href="../customer/c_home.php"><strong>Back to My Account</strong></a></div> <div align="left"; style="padding-left: 24px; width:920px; margin-left:auto; margin-right:auto;"> <h1 style="text-align:left; color:#900;">Manage Personal Details :</h1> <h2>Here you can update your personal information <?php echo $firstname; ?><br/><br/></h2> </div> <h3>Enter Your New Personal Details</h3> <table width="720px" border="1"> <tr> <td width="30%" align="right" valign="top" bgcolor="#FFFFFF"><strong><a href="../customer/cust_details_update.php">Manage Personal Details</a></strong></td> <td width="70%" colspan="3" align="center" bgcolor="#CCCCCC"> <form action="../customer/cust_details_update.php?cid=<?php echo $targetID; ?>" enctype="multipart/form-data" name="myForm" id="myForm" method="POST"> <table width="620px" border="0" cellspacing="0" cellpadding="5"> <tr> <td width="228" align="right">First Name</td> <td width="472"><label> <input name="firstname" type="text" id="firstname" value="<?php echo $firstname;?>"/> </label>*</td> </tr> <tr> <td align="right">Last Name</td> <td><label> <input name="lastname" type="text" id="textfield" value="<?php echo $lastname;?>"/> </label>*</td> </tr> <tr> <td align="right">Date of Birth</td> <td><label> <input name="dob" type="text" id="textfield" value="<?php echo $dob;?>"/> </label>*</td> </tr> <tr> <td align="right">Gender</td> <td><label> <select name="gender" id="gender"> <option value="<?php echo $gender;?>"><?php echo $gender;?>-Select-</option> <option value="Male">Male</option> <option value="Female">Female</option> </select> </label>*</td> </tr> <tr> <td align="right">Phone Number</td> <td><label> <input name="phone" type="text" id="phone" value="<?php echo $phone;?>"> </label>*</td> </tr> <td align="right">User Name</td> <td><label> <input name="username" type="text" id="username" value="<?php echo $username;?>"> </label>*</td> </tr> <tr> <td align="right">Password</td> <td><label> <input name="password" type="password" id="password" value="<?php echo $password;?>"> </label>*</td> </tr> <tr> <td height="52">&nbsp;</td> <td><label>All fields marked with * must be completed!<br/> <input name="thisID" type="hidden" value="<?php echo $targetID;?>"/> <input type="submit" name="button" id="button" value="Update Customer Details"/> </label></td> </tr> </table> </form> </td> </tr> </table> <br/> <br/> </div> <?php include_once("../store/template_footer.php");?> </div> </body> </html>
true
e6f97ffe470e1818e64301cbfcfeb42f791b299e
PHP
marscore/hhvm
/hphp/test/slow/compilation/1320.php
UTF-8
238
2.78125
3
[ "Zend-2.0", "PHP-3.01", "MIT" ]
permissive
<?php class X { static function foo() { return new X; } function bar() { var_dump(__METHOD__); } } function id($x) { return $x; } function test() { id(X::foo(1))->bar(); } <<__EntryPoint>> function main_1320() { ; test(); }
true
df610dccc3da2483acf0fb2301fb47a75f775173
PHP
mschnitzer/de.mschnitzer.wcf.useriplog
/files/lib/system/event/listener/UserIPLogFetchUserIPListener.class.php
UTF-8
1,664
2.5625
3
[]
no_license
<?php namespace wcf\system\event\listener; use wcf\system\event\EventHandler; use wcf\system\event\IEventListener; use wcf\system\WCF; use wcf\util\UserUtil; /** * Collecting the IP address and the user agent from the current user * * @author Manuel Schnitzer * @copyright 2015-2015 Manuel Schnitzer * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> * @package com.woltlab.wcf * @category Community Framework */ class UserIPLogFetchUserIPListener implements IEventListener { /** * @see \wcf\system\event\IEventListener::execute() */ public function execute($eventObj, $className, $eventName) { // ignore guests if (!WCF::getUser()->userID) { return 0; } // check if there is already an entry in the database $sql = "SELECT COUNT(entryID) AS count FROM wcf".WCF_N."_user_iplog WHERE userID = ? AND ipAddress = ? AND userAgent = ?;"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array( WCF::getUser()->userID, UserUtil::getIpAddress(), UserUtil::getUserAgent() )); $row = $statement->fetchArray(); if (!$row['count']) { // no entry was found => insert a new one $sql = "INSERT INTO wcf".WCF_N."_user_iplog (userID, ipAddress, userAgent, timestamp) VALUES (?, ?, ?, ?);"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array( WCF::getUser()->userID, UserUtil::getIpAddress(), UserUtil::getUserAgent(), TIME_NOW )); // fire event for the multi account checker EventHandler::getInstance()->fireAction($this, 'newIP'); } return 1; } }
true
a50bc67d313cc729c4f8ce3a3194514e56d367f6
PHP
Wonghzx/apiSwoole
/Core/Component/Error/ErrorHandler.php
UTF-8
1,993
2.640625
3
[]
no_license
<?php /** * Created by PhpStorm. * User: Administrator * Date: 2017/12/15/015 * Time: 14:50 */ namespace Core\Component\Error; use Core\AbstractInterface\AbstractErrorHandler; use Core\Component\Logger; use Core\Swoole\HttpServer\Storage\Request; use Core\Swoole\HttpServer\Storage\Response; class ErrorHandler extends AbstractErrorHandler { /** * handler [description] * @param $msg * @param null $file * @param null $line * @param null $errorCode * @param $trace * @copyright Copyright (c) * @author Wongzx <842687571@qq.com> * @return mixed */ public function handler($msg, $file = null, $line = null, $errorCode = null, $trace) { // TODO: Implement handler() method. } /** * display [页面输出] * @param $msg * @param null $file * @param null $line * @param null $errorCode * @param $trace * @copyright Copyright (c) * @author Wongzx <842687571@qq.com> * @return mixed */ public function display($msg, $file = null, $line = null, $errorCode = null, $trace) { // TODO: Implement display() method. //判断是否在HTTP模式下 if (Request::getInstance()) { Response::getInstance()->assign(nl2br($msg) . " in file {$file} line {$line}"); } else { Logger::getInstance('error')->console($msg . " in file {$file} line {$line}", false); } } /** * log [记录Log文件] * @param $msg * @param null $file * @param null $line * @param null $errorCode * @param $trace * @copyright Copyright (c) * @author Wongzx <842687571@qq.com> * @return mixed */ public function log($msg, $file = null, $line = null, $errorCode = null, $trace) { // TODO: Implement log() method. Logger::getInstance('error')->log($msg . " in file {$file} line {$line}"); } }
true
a838ba01f9995d86b6b81adbf756cf3736f4b45b
PHP
DevSazal/APIATO-crud-restful-api
/app/Containers/AppSection/Authorization/Tasks/DetachPermissionsFromRoleTask.php
UTF-8
775
2.515625
3
[ "MIT" ]
permissive
<?php namespace App\Containers\AppSection\Authorization\Tasks; use App\Containers\AppSection\Authorization\Models\Role; use App\Ship\Parents\Tasks\Task; class DetachPermissionsFromRoleTask extends Task { public function run(Role $role, $singleOrMultiplePermissionIds): Role { if (!is_array($singleOrMultiplePermissionIds)) { $singleOrMultiplePermissionIds = [$singleOrMultiplePermissionIds]; } // remove each permission ID found in the array from that role. array_map(static function ($permissionId) use ($role) { $permission = app(FindPermissionTask::class)->run($permissionId); $role->revokePermissionTo($permission); }, $singleOrMultiplePermissionIds); return $role; } }
true
0758dfb45b0582f2422659eff5256e3960ced8b3
PHP
andy1992/react-redux-crud
/api/read_all_categories.php
UTF-8
407
2.71875
3
[ "Apache-2.0" ]
permissive
<?php // include core configuration include_once '../config/core.php'; // include database connection include_once '../config/database.php'; // product object include_once '../objects/category.php'; // class instance $database = new Database(); $db = $database->getConnection(); $category = new Category($db); // read all products $results=$category->readAll(); // output in json format echo $results;
true
a9a2eccb2089fe812a6f95f529111fe5eb6bf890
PHP
rainsens/adm
/tests/Unit/Models/AdmUserTest.php
UTF-8
584
2.515625
3
[]
no_license
<?php namespace Rainsens\Adm\Tests\Unit\Models; use Illuminate\Foundation\Testing\RefreshDatabase; use Rainsens\Adm\Models\AdmUser; use Rainsens\Adm\Tests\TestCase; class AdmUserTest extends TestCase { use RefreshDatabase; /** @test */ public function a_adm_user_has_a_name() { $admUser = create(AdmUser::class, ['name' => 'Rainsen']); $this->assertEquals('Rainsen', $admUser->name); } /** @test */ public function a_adm_user_has_a_password() { $admUser = create(AdmUser::class, ['password' => '123']); $this->assertEquals('123', $admUser->password); } }
true
5c92e81f961397fc0356732dc01ad80f6fa03b28
PHP
a59715a/Library-Management-System-in-Codeigniter
/ciproject/application/models/author_model.php
UTF-8
1,213
2.90625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
<?php class Author_model extends CI_Model{ public function addAuthorData($data){ $this->db->insert('tbl_author', $data); } public function getAuthorData(){ $this->db->select('*'); $this->db->from('tbl_author'); $this->db->order_by('aId', 'desc'); $qresult = $this->db->get(); $result = $qresult->result(); return $result; } public function getAuthorById($id){ $this->db->select('*'); $this->db->from('tbl_author'); $this->db->where('aId', $id); $qresult = $this->db->get(); $result = $qresult->row(); return $result; } public function updateAthrById($data){ $this->db->set('author', $data['author']); $this->db->where('aId', $data['aId']); $result = $this->db->update('tbl_author'); return $result; } public function deleteAthrById($id){ $this->db->where('aId', $id); $this->db->delete('tbl_author'); } public function getAuthor($athrid){ $this->db->select('*'); $this->db->from('tbl_author'); $this->db->where('aId', $athrid); $qresult = $this->db->get(); $result = $qresult->row(); return $result; } }
true
6c54f6a5ab7d0b97d016edca39f13386841fe3e6
PHP
moElwan/my-laravel-starter
/database/migrations/2017_03_26_094432_create_metables_table.php
UTF-8
866
2.5625
3
[ "MIT" ]
permissive
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateMetablesTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('metables', function (Blueprint $table) { $table->integer('meta_id')->unsigned(); $table->integer('metable_id')->unsigned(); $table->integer('metable_type')->unsigned(); $table->timestamps(); $table->primary(['meta_id', 'metable_id', 'metable_type']); $table->foreign('meta_id')->references('id')->on('metas'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('metables'); } }
true
1f26c23c097e70d511591653fdfdf011a4c2a1d9
PHP
lalofee/php_day_1
/exercise_2.php
UTF-8
230
2.703125
3
[]
no_license
<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="style.css"> <title>php uebungen</title> </head> <body> <?php if(date('D') == 'Mon') { echo "Happy Monday!"; } else { echo "Have a nice day!"; } ?> </body> </html>
true
b76f8c98a9cdb0d3b4ae36e4b5ee436c76485b2d
PHP
ruslanix/code-samples
/1_CatalogParser/Application/ParserChain/Chain/ChainInterface.php
UTF-8
321
2.765625
3
[]
no_license
<?php namespace Application\ParserChain\Chain; use Application\ParserChain\ParserUnit\ParserUnitInterface; interface ChainInterface { public function addParserUnit(ParserUnitInterface $parserUnit); public function getParserUnits(); public function getResultContainer(); public function parse($text); }
true
ce429e908278fc40ece73d10def68bc85fbd79e0
PHP
MarekPadd13/ug
/models/DictAngle.php
UTF-8
979
2.625
3
[ "BSD-3-Clause" ]
permissive
<?php namespace app\models; use phpbb\session; use Yii; /** * This is the model class for table "dict_angle". * * @property int $id * @property string $name * */ class DictAngle extends \yii\db\ActiveRecord { public static function tableName() { return 'dict_angle'; } /** * {@inheritdoc} */ public function rules() { return [ [['name'], 'required'], [['name'], 'string', 'max' => 255], ['name', 'unique', 'targetClass' => self::class, 'message' => 'Такой ракурс уже есть в списке'], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'name' => 'Название ракурса', ]; } public static function allColumn() { return self::find()->select('name, id')->orderBy(['name'=> SORT_ASC])->indexBy('id')->column(); } }
true
6be787daa42049509a8ddd559415a485de5e7a1a
PHP
nboyraz/portalBoyraz
/models/event.php
UTF-8
1,779
2.5625
3
[]
no_license
<?php require_once(ROOT.DS."entity".DS."EventItem.php"); class Event extends Model{ public function GetLatestEvents($pagenum,$pageSize){ $res = []; $select = "select * from (select @rownum:=@rownum+1 'rank', p.* from `events` p, (SELECT @rownum:=0) r order by ID desc limit ".($pagenum*$pageSize+1).") as T where rank between ".(($pagenum-1)*$pageSize+1)." and ".($pagenum*$pageSize+1); $result = $this->db->query($select); if(count($result)>0){ for($i=0;$i<count($result);$i++){ $ei = new EventItem(); $ei->EventId = $result[$i]["ID"]; $ei->EventType = $result[$i]["EVENT_TYPE"]; $ei->CreatorUser = $result[$i]["CREATOR_USER"]; $ei->PublisherInfo = $result[$i]["PUBLISHER_INFO"]; $ei->PublishDate = $result[$i]["PUBLISH_DATE"]; $ei->Content = $result[$i]["CONTENT"]; $ei->FullContent = $result[$i]["FULL_CONTENT"]; $res[] = $ei; } } return $res; } public function GetEventContent($eventId){ $event = new EventItem(); $select = "select * from `events` where ID = ".$eventId." limit 1"; $result = $this->db->query($select); if(count($result)>0){ $event->EventId = $result[0]["ID"]; $event->EventType = $result[0]["EVENT_TYPE"]; $event->CreatorUser = $result[0]["CREATOR_USER"]; $event->PublisherInfo = $result[0]["PUBLISHER_INFO"]; $event->PublishDate = $result[0]["PUBLISH_DATE"]; $event->Content = $result[0]["CONTENT"]; $event->FullContent = $result[0]["FULL_CONTENT"]; } return $event; } } ?>
true
638fa9f9cef729d064ecda3f02613035b7267cc9
PHP
Rufaro1964/logisticsManagementSystem
/controller/signInController.php
UTF-8
1,707
2.90625
3
[]
no_license
<?php session_start(); require('../database/connection.php'); class SignInController{ /** * we need to create helper functions to do some simple tasks like encrypting the password... */ private $database; private $dbConnection; public function __construct(){ $this->database = new Database(); $this->dbConnection = $this->database->connect(); } /** * @return: bool->false OR redirects to a page. * @param: $username (String) * @param: $password (String) * * If the DB query is successful and a row is returned, the user is directed to details-entry page * to finish up with the registration process. */ public function signIn($username, $password){ $statement = $this->dbConnection->prepare("SELECT * FROM users WHERE `email`=? AND `password`=? LIMIT 1"); $statement->bind_param("ss", $username, $password); $statement->execute(); $result = $statement->get_result(); if($result->num_rows > 0){ $user = $result->fetch_assoc(); $_SESSION['id'] = $user['id']; $firstLogin = $user['first_login']; if(isset($_SESSION['id'])){ if($firstLogin === 'yes'){ header('Location: details-entry-form.php'); }else{ header('Location: home.php'); } } }else{ return false; } } } ?>
true
70b0f29c3639b5522743955cf0ad7a54d2516037
PHP
stasRevin/phpProjects
/Project2/php/userProfile.php
UTF-8
3,960
2.734375
3
[]
no_license
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" type="text/css" href="index.css"> </head> <body> <div class="base"> <div class="background-image"></div> <div class="container"> <?php require_once('menu.html'); require_once('connectvars.php'); session_start(); $firstName = ""; $lastName = ""; $gender = ""; $username = ""; $birthdate = ""; $weight = ""; $photoLocation = ""; $user_id = ""; $exercises = array(); if (session_id() === $_SESSION['session_id']) { $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die("Error connection to DB_NAME server."); $username = $_SESSION['username']; $user_id = $_SESSION['user_id']; $query = "SELECT first_name, last_name, gender, birthdate, weight, photo_location " . "FROM exercise_user WHERE username = '$username'"; $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 1) { $row = mysqli_fetch_array($data); $firstName = $row['first_name']; $lastName = $row['last_name']; $gender = $row['gender']; $birthdate = $row['birthdate']; $weight = $row['weight']; $photoLocation = $row['photo_location']; } $query = "SELECT date, exercise_id, exercise_name, time_in_minutes, " . "heartrate, calories FROM exercises_view WHERE user_id = '$user_id'"; $data = mysqli_query($dbc, $query); while ($row = mysqli_fetch_array($data)) { $exercises[] = $row; error_log("exercise_name: " . $row['exercise_name']); } mysqli_close($dbc); } else { header('Location: index.php'); exit(); } ?> <img class="profileImage" src="<?php echo $photoLocation; ?>" alt="test"> <h1>Exercise Tracker</h1> <h4>Hello, <?php echo $firstName; ?></h4> <table id="userInfo"> <tr> <td>Username:</td> <td><?php echo $username; ?></td> </tr> <tr> <td>First name:</td> <td><?php echo $firstName; ?></td> </tr> <tr> <td>Last name:</td> <td><?php echo $lastName; ?></td> </tr> <tr> <td>Gender:</td> <td> <?php $displayGender = $gender == "f" ? "Female" : "Male"; echo $displayGender; ?> </td> </tr> <tr> <td>Birthdate:</td> <td><?php echo $birthdate; ?></td> </tr> <tr> <td>Weight:</td> <td><?php echo $weight; ?></td> </tr> </table> <br/><br/> <table id="userWorkout"> <tr> <th>Date</th> <th>Type</th> <th>Time in Minutes</th> <th>Heart Rate</th> <th>Calories Burned</th> <?php foreach($exercises as $exercise) { echo "<tr>"; echo "<td>" . $exercise['date'] . "</td>"; echo "<td>" . $exercise['exercise_name'] . "</td>"; echo "<td>" . $exercise['time_in_minutes'] . "</td>"; echo "<td>" . $exercise['heartrate'] . "</td>"; echo "<td>" . $exercise['calories'] . "</td>"; echo "<td class='deleteColumn'><a href='/php/removeExercise.php?id=" . $exercise['exercise_id'] . "'><img id='trashCan' src='images/trashCan.png' alt='trash can'></a></td>"; echo "<tr/>"; } ?> </table> </div> </div> </body> </html>
true
56985a959712a35439495c23ad51baf9c4d1f35a
PHP
cuchakma/Task-Manager
/Task Manager/index.php
UTF-8
5,058
2.59375
3
[]
no_license
<?php include_once "config.php"; $connection = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if(!$connection) { throw new Exception("Not Connected To Database"); } $query = "SELECT * FROM tasks WHERE complete = 0 ORDER BY ID DESC"; $result = mysqli_query($connection, $query); $complete_tasks_query = "SELECT * FROM tasks WHERE complete = 1 ORDER BY ID DESC"; $result_complete_tasks = mysqli_query($connection, $complete_tasks_query); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/milligram/1.4.1/milligram.css"> <style> body{ margin-top: 30px; } #main{ padding: 0px 150px 0x 150px; } #action{ width: 150px; } </style> </head> <body> <div class="container" id="main"> <h1>Task Manager</h1> <?php if(mysqli_num_rows($result_complete_tasks) > 0){ ?> <h4>Complete Tasks</h4> <table> <thead> <tr> <th></th> <th>ID</th> <th>Task</th> <th>Date</th> <th>Action</th> </tr> </thead> <tbody> <?php while($cdata = mysqli_fetch_assoc($result_complete_tasks)) { $time_stamp = strtotime($cdata['date']); $cdate = date("jS M, Y", $time_stamp); ?> <tr> <td><input class="label-inline" type="checkbox" value="<?php echo $cdata['id']; ?>"></td> <td><?php echo $cdata['id']; ?></td> <td><?php echo $cdata['task']; ?></td> <td><?php echo $cdate; ?></td> <td><a href="#">Delete</a></td> </tr> <?php } ?> </tbody> </table> <p>...</p> <?php } ?> <?php if(mysqli_num_rows($result) == 0){ ?> <p>No Tasks Found</p> <?php } else { ?> <h4>Upcoming Tasks</h4> <table> <thead> <tr> <th></th> <th>ID</th> <th>Task</th> <th>Date</th> <th>Action</th> </tr> </thead> <?php while( $data = mysqli_fetch_assoc( $result ) ) { $time_stamp = strtotime($data['date']); $date = date("jS M, Y", $time_stamp); ?><tr> <td><input class="label-inline" type="checkbox" value="<?php echo $data['id']; ?>"></td> <td><?php echo $data['id']; ?></td> <td><?php echo $data['task']; ?></td> <td><?php echo $date; ?></td> <td><a href="index.php?delete=1">Delete</a> | <a href="#">Edit</a> | <a href="#">Complete</a></td> </tr> <?php } mysqli_close($connection); ?> </tbody> </table> <select id=""> <option value="0">With Selected</option> <option value="del">Delete</option> <option value="complete">Mark As Complete</option> </select> <input class="button-primary" type="submit" value="submit"> <?php } ?> <p>...</p> <h4>Add Task</h4> <form method="post" action="tasks.php"> <fieldset> <?php $added = $_GET['added']??''; if($added) { echo "<p>Task Successfully Added</p>"; } ?> <label for="task">Task</label> <input type="text" placeholder="Task Details" id="task" name="task" value="<?php ?>"> <label for="date">Date</label> <input type="date" placeholder="Task Date" id="date" name="date" value="<?php ?>"> <input class="button-primary" type="submit" value="Add Task"> <input type="hidden" name="action" value="add"> </fieldset> </form> </div> </body> </html>
true
2dbb001d0e60ec861e4ad3accbe30e70438a334f
PHP
zartata/icicle
/src/Loop/Events/ImmediateInterface.php
UTF-8
495
2.796875
3
[ "Apache-2.0" ]
permissive
<?php namespace Icicle\Loop\Events; interface ImmediateInterface { /** * @return bool */ public function isPending(); /** * Execute the immediate if not pending. */ public function execute(); /** * Cancels the immediate if pending. */ public function cancel(); /** * Calls the callback associated with the timer. */ public function call(); /** * Alias of call(). */ public function __invoke(); }
true
3546bfa4f9c7d4c9aeea48cc2828fe2e2a1b9e85
PHP
trisonsystem/stock-management
/application/models/MAddress.php
UTF-8
537
2.578125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
<?php class MAddress extends CI_Model { public function __construct(){ parent::__construct(); } public function get_data( $id = "" ){ $where = ($id == "") ? "" : " where id = '".$id."'"; $keysearch = $this->input->get('term'); $arr = array(); $sql = "select * from address ".$where.""; $query = $this->db->query($sql); $arr = array(); foreach ($query->result_array() as $key => $value) { $arr[] = $value; } // debug($arr); if ($id == "") { return $arr; }else{ return $arr[0]; } } }
true
c7f6d55d239d3b3a60bf93972c5e90bbe753f2da
PHP
jeyroik/extas-jsonrpc
/src/interfaces/stages/IStageJsonRpcCommand.php
UTF-8
379
2.546875
3
[ "MIT" ]
permissive
<?php namespace extas\interfaces\stages; use extas\commands\JsonrpcCommand; /** * Interface IStageJsonRpcCommand * * @package extas\interfaces\stages * @author jeyroik@gmail.com */ interface IStageJsonRpcCommand { public const NAME = 'extas.jsonrpc.command'; /** * @param JsonrpcCommand $command */ public function __invoke(JsonrpcCommand &$command): void; }
true
4d267057c4013a67c98f025c6f195ed6c293b855
PHP
wenzhan510/sosadfun-2019
/backend/app/Http/Resources/QuizCollection.php
UTF-8
924
2.65625
3
[]
no_license
<?php namespace App\Http\Resources; use App\Models\Quiz; use Illuminate\Http\Resources\Json\ResourceCollection; class QuizCollection extends ResourceCollection { protected $include_answer; /** * QuizCollection constructor. * @param mixed $resource * @param bool $include_answer include answer in returned resource by default */ public function __construct($resource, bool $include_answer = false) { parent::__construct($resource); $this->include_answer = $include_answer; } /** * Transform the resource collection into an array. * * @param \Illuminate\Http\Request $request * @return array */ public function toArray($request) { return $this->collection->map(function(Quiz $resource) use($request){ return QuizResource::make($resource,$this->include_answer)->toArray($request); })->all(); } }
true
8022e47667a45d315addb1bb60ac79c5e929ebc0
PHP
alifazel/FootballPrediction
/app/commands/CompleteRoundCommand.php
UTF-8
2,091
2.8125
3
[]
no_license
<?php use Illuminate\Console\Command; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; class CompleteRoundCommand extends Command { /** * The console command name. * * @var string */ protected $name = 'lts:completeround'; /** * The console command description. * * @var string */ protected $description = 'Completes a Round.'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return mixed */ public function fire() { $gameId = $this->argument('game_id'); $roundId = $this->argument('round_id'); $winningTeamIds = array(); $fixtures = Fixture::where('round_id', '=', $roundId)->get(); foreach($fixtures as $fixture) { if($fixture->home_team_score > $fixture->away_team_score) { $winningTeamIds[] = $fixture->home_team_id; } if($fixture->away_team_score > $fixture->home_team_score) { $winningTeamIds[] = $fixture->away_team_id; } } // compute round results, $userPicks = UserPick::where('round_id', '=', $roundId)->get(); foreach($userPicks as $pick) { $user = User::find($pick->user_id); $roundResult = new RoundResult(); $roundResult->round_id = $roundId; $roundResult->user_id = $pick->user_id; if(in_array($pick->team_id, $winningTeamIds)) { $roundResult->continue = true; $user->final_round_id = $roundId; $user->save(); } else { $roundResult->continue = false; } $roundResult->save(); } // complete round $round = Round::find($roundId); $round->completed = true; $round->save(); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return array( array('game_id', InputArgument::REQUIRED, 'ID of the Game.'), array('round_id', InputArgument::REQUIRED, 'ID of the Round.'), ); } /** * Get the console command options. * * @return array */ protected function getOptions() { return array( ); } }
true
c7a702dc9de87daffcbf5b924ed72f02771ba9b8
PHP
mbube2/Universities-Ranking-System-
/php/Untitled-1.php
UTF-8
181,064
2.828125
3
[]
no_license
<?php function entropy($Prob1,$Prob2,$Prob3) { $ent = -($Prob1 * log($Prob1,2.0))-($Prob2 * log($Prob2,2.0))-($Prob3 * log($Prob3,2.0)); return $ent; //echo(log(2.7183) . "<br>"); //echo log(0,2.0); //echo "<br>"; } function decision() { mySQL_connect("localhost","root","1234") or die(mySQL_error()); //echo "MySQL Connection Established"; mySQL_select_DB("universityrankingsystem") or die(mySQL_error()); //echo "DB Connected <br>"; $result = mySQL_Query("SELECT CL FROM ranking") or die(mySQL_error()); $Drow = array(); $CL = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $CL[$i] = $Drow[0]; $i++; } $totalCL = sizeof($CL); print_r($CL); echo "<br>"; echo "Total Class Labels: " . $totalCL; echo "<br>"; $totalE=0; $totalG=0; $totalS=0; for($a = 0; $a < $totalCL; $a++) { if(isset($CL[$a])) { if($CL[$a] == "Excellent") { $totalE++; } else if($CL[$a] == "Good") { $totalG++; } else if($CL[$a] == "Satisfactory") { $totalS++; } } } session_start(); $_SESSION["totslE"] = $totalE; $_SESSION["totalG"] = $totalG; $_SESSION["totalS"] = $totalS; $totalEnt=0; $ProbE=$totalE/$totalCL; $ProbG=$totalG/$totalCL; $ProbS=$totalS/$totalCL; $totalEnt=-($ProbE * log($ProbE,2.0))-($ProbG * log($ProbG,2.0))-($ProbS * log($ProbS,2.0)); echo "Total Excellent: " . $totalE; echo "<br>"; echo "Total Good: " . $totalG; echo "<br>"; echo "Total Satisfactory: " . $totalS; echo "<br>" . "Total Entropy: " . $totalEnt; $result = mySQL_Query("SELECT R1 FROM ranking") or die(mySQL_error()); $Drow = array(); $R1 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R1[$i] = $Drow[0]; $i++; } $totalR1 = sizeof($R1); echo "<br>"; print_r($R1); echo "<br>"; echo "Total R1: " . $totalR1; echo "<br>"; echo "<h2>R1 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R1 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R1E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R1E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR1E = sizeof($R1E); echo "Total R1 Excellent: " . $totalR1E . "<br>"; $ProbR1E = $totalR1E/$totalR1; $result = mySQL_Query("SELECT CL FROM ranking WHERE R1 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R1EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R1EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR1EE = sizeof($R1EE); $ProbR1EE = $totalR1EE/$totalR1E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R1 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R1EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R1EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR1EG = sizeof($R1EG); $ProbR1EG = $totalR1EG/$totalR1E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R1 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R1ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R1ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR1ES = sizeof($R1ES); $ProbR1ES = $totalR1ES/$totalR1E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R1 = 'Good'") or die(mySQL_error()); $Drow = array(); $R1G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R1G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR1G = sizeof($R1G); echo "Total R1 Good: " . $totalR1G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R1 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R1GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R1GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR1GE = sizeof($R1GE); $ProbR1GE = $totalR1GE/$totalR1G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R1 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R1GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R1GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR1GG = sizeof($R1GG); $ProbR1GG = $totalR1GG/$totalR1G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R1 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R1GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R1GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR1GS = sizeof($R1GS); $ProbR1GS = $totalR1GS/$totalR1G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R1 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R1S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R1S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR1S = sizeof($R1S); echo "Total R1 Satisfactory: " . $totalR1S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R1 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R1SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R1SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR1SE = sizeof($R1SE); $ProbR1SE = $totalR1SE/$totalR1S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R1 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R1SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R1SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR1SG = sizeof($R1SG); $ProbR1SG = $totalR1SG/$totalR1S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R1 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R1SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R1SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR1SS = sizeof($R1SS); $ProbR1SS = $totalR1SS/$totalR1S; //Entropy of R1 $ProbR1E= $totalR1E/$totalR1; $ProbR1G= $totalR1G/$totalR1; $ProbR1S= $totalR1S/$totalR1; //$EntR1E = -($ProbR1E * log($ProbR1E,2.0))-($ProbR1G * log($ProbR1G,2.0))-($ProbR1S * log($ProbR1S,2.0)); //$EntR1G = -($ProbR1G * log($ProbR1G,2.0))-($ProbR1G * log($ProbR1G,2.0))-($ProbR1S * log($ProbR1S,2.0)); //$EntR1S = -($ProbR1S * log($ProbR1S,2.0))-($ProbR1S * log($ProbR1G,2.0))-($ProbR1S * log($ProbR1S,2.0)); if($ProbR1EE == 0 || $ProbR1EG == 0 || $ProbR1ES == 0) { $EntR1 = 0; } else { $EntR1= $ProbR1E * entropy($ProbR1EE,$ProbR1EG,$ProbR1ES) + $ProbR1G * entropy($ProbR1GE,$ProbR1GG,$ProbR1GS) + $ProbR1S * entropy($ProbR1SE,$ProbR1SG,$ProbR1SS); } echo "<br>"; echo "Entropy of R1 AND CL is: " . $EntR1; echo "<br>"; //R2 $result = mySQL_Query("SELECT R2 FROM ranking") or die(mySQL_error()); $Drow = array(); $R2 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R2[$i] = $Drow[0]; $i++; } $totalR2 = sizeof($R2); echo "<br>"; print_r($R2); echo "<br>"; echo "Total R2: " . $totalR2; //R2 Prob echo "<h2>R2 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R2 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R2E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R2E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR2E = sizeof($R2E); echo "Total R2 Excellent: " . $totalR2E . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R2 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R2EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R2EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR2EE = sizeof($R2EE); $ProbR2EE = $totalR2EE/$totalR2E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R2 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R2EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R2EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR2EG = sizeof($R2EG); $ProbR2EG = $totalR2EG/$totalR2E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R2 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R2ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R2ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR2ES = sizeof($R2ES); $ProbR2ES = $totalR2ES/$totalR2E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R2 = 'Good'") or die(mySQL_error()); $Drow = array(); $R2G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R2G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR2G = sizeof($R2G); echo "Total R2 Good: " . $totalR2G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R2 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R2GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R2GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR2GE = sizeof($R2GE); $ProbR2GE = $totalR2GE/$totalR2G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R2 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R2GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R2GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR2GG = sizeof($R2GG); $ProbR2GG = $totalR2GG/$totalR2G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R2 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R2GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R2GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR2GS = sizeof($R2GS); $ProbR2GS = $totalR2GS/$totalR2G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R2 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R2S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R2S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR2S = sizeof($R2S); echo "Total R2 Satisfactory: " . $totalR2S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R2 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R2SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R2SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR2SE = sizeof($R2SE); $ProbR2SE = $totalR2SE/$totalR2S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R2 = 'Satisfactory' AND CL ='Good'") or die(mySQL_error()); $Drow = array(); $R2SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R2SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR2SG = sizeof($R2SG); $ProbR2SG = $totalR2SG/$totalR2S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R2 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R2SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R2SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR2SS = sizeof($R2SS); $ProbR2SS = $totalR2SS/$totalR2S; //Entropy of R2 $ProbR2E= $totalR2E/$totalR2; $ProbR2G= $totalR2G/$totalR2; $ProbR2S= $totalR2S/$totalR2; if($ProbR2EE == 0 || $ProbR2EG == 0 || $ProbR2ES == 0) { $EntR2 = 0; } else { $EntR2= $ProbR2E * entropy($ProbR2EE,$ProbR2EG,$ProbR2ES) + $ProbR2G * entropy($ProbR2GE,$ProbR2GG,$ProbR2GS) + $ProbR2S * entropy($ProbR2SE,$ProbR2SG,$ProbR2SS); } echo "<br>"; echo "Entropy of R2 AND CL is: " . $EntR2; echo "<br>"; //R3 $result = mySQL_Query("SELECT R3 FROM ranking") or die(mySQL_error()); $Drow = array(); $R3 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R3[$i] = $Drow[0]; $i++; } $totalR3 = sizeof($R3); echo "<br>"; print_r($R3); echo "<br>"; echo "Total R3: " . $totalR3; //R3 Prob echo "<h2>R3 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R3 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R3E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R3E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR3E = sizeof($R3E); echo "Total R3 Excellent: " . $totalR3E . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R3 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R3EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R3EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR3EE = sizeof($R3EE); $ProbR3EE = $totalR3EE/$totalR3E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R3 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R3EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R3EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR3EG = sizeof($R3EG); $ProbR3EG = $totalR3EG/$totalR3E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R3 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R3ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R3ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR3ES = sizeof($R3ES); $ProbR3ES = $totalR3ES/$totalR3E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R3 = 'Good'") or die(mySQL_error()); $Drow = array(); $R3G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R3G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR3G = sizeof($R3G); echo "Total R3 Good: " . $totalR3G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R3 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R3GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R3GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR3GE = sizeof($R3GE); $ProbR3GE = $totalR3GE/$totalR3G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R3 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R3GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R3GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR3GG = sizeof($R3GG); $ProbR3GG = $totalR3GG/$totalR3G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R3 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R3GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R3GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR3GS = sizeof($R3GS); $ProbR3GS = $totalR3GS/$totalR3G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R3 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R3S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R3S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR3S = sizeof($R3S); echo "Total R3 Satisfactory: " . $totalR3S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R3 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R3SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R3SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR3SE = sizeof($R3SE); $ProbR3SE = $totalR3SE/$totalR3S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R3 = 'Satisfactory' AND CL ='Good'") or die(mySQL_error()); $Drow = array(); $R3SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R3SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR3SG = sizeof($R3SG); $ProbR3SG = $totalR3SG/$totalR3S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R3 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R3SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R3SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR3SS = sizeof($R3SS); $ProbR3SS = $totalR3SS/$totalR3S; //Entropy of R3 $ProbR3E= $totalR3E/$totalR3; $ProbR3G= $totalR3G/$totalR3; $ProbR3S= $totalR3S/$totalR3; if($ProbR3EE == 0 || $ProbR3EG == 0 || $ProbR3ES == 0) { $EntR3 = 0; } else { $EntR3= $ProbR3E * entropy($ProbR3EE,$ProbR3EG,$ProbR3ES) + $ProbR3G * entropy($ProbR3GE,$ProbR3GG,$ProbR3GS) + $ProbR3S * entropy($ProbR3SE,$ProbR3SG,$ProbR3SS); } echo "<br>"; echo "Entropy of R3 AND CL is: " . $EntR3; echo "<br>"; //R4 $result = mySQL_Query("SELECT R4 FROM ranking") or die(mySQL_error()); $Drow = array(); $R4 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R4[$i] = $Drow[0]; $i++; } $totalR4 = sizeof($R4); echo "<br>"; print_r($R4); echo "<br>"; echo "Total R4: " . $totalR4; //R4 Prob echo "<h2>R4 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R4 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R4E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R4E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR4E = sizeof($R4E); echo "Total R4 Excellent: " . $totalR4E . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R4 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R4EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R4EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR4EE = sizeof($R4EE); $ProbR4EE = $totalR4EE/$totalR4E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R4 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R4EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R4EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR4EG = sizeof($R4EG); $ProbR4EG = $totalR4EG/$totalR4E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R4 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R4ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R4ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR4ES = sizeof($R4ES); $ProbR4ES = $totalR4ES/$totalR4E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R4 = 'Good'") or die(mySQL_error()); $Drow = array(); $R4G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R4G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR4G = sizeof($R4G); echo "Total R4 Good: " . $totalR4G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R4 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R4GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R4GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR4GE = sizeof($R4GE); $ProbR4GE = $totalR4GE/$totalR4G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R4 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R4GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R4GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR4GG = sizeof($R4GG); $ProbR4GG = $totalR4GG/$totalR4G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R4 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R4GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R4GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR4GS = sizeof($R4GS); $ProbR4GS = $totalR4GS/$totalR4G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R4 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R4S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R4S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR4S = sizeof($R4S); echo "Total R4 Satisfactory: " . $totalR4S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R4 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R4SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R4SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR4SE = sizeof($R4SE); $ProbR4SE = $totalR4SE/$totalR4S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R4 = 'Satisfactory' AND CL ='Good'") or die(mySQL_error()); $Drow = array(); $R4SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R4SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR4SG = sizeof($R4SG); $ProbR4SG = $totalR4SG/$totalR4S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R4 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R4SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R4SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR4SS = sizeof($R4SS); $ProbR4SS = $totalR4SS/$totalR4S; //Entropy of R4 $ProbR4E= $totalR4E/$totalR4; $ProbR4G= $totalR4G/$totalR4; $ProbR4S= $totalR4S/$totalR4; if($ProbR4EE == 0 || $ProbR4EG == 0 || $ProbR4ES == 0) { $EntR4 = 0; } else { $EntR4= $ProbR4E * entropy($ProbR4EE,$ProbR4EG,$ProbR4ES) + $ProbR4G * entropy($ProbR4GE,$ProbR4GG,$ProbR4GS) + $ProbR4S * entropy($ProbR4SE,$ProbR4SG,$ProbR4SS); } echo "<br>"; echo "Entropy of R4 AND CL is: " . $EntR4; echo "<br>"; //R5 $result = mySQL_Query("SELECT R5 FROM ranking") or die(mySQL_error()); $Drow = array(); $R5 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R5[$i] = $Drow[0]; $i++; } $totalR5 = sizeof($R5); echo "<br>"; print_r($R5); echo "<br>"; echo "Total R5: " . $totalR5; //R5 Prob echo "<h2>R5 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R5 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R5E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R5E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR5E = sizeof($R5E); echo "Total R5 Excellent: " . $totalR5E . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R5 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R5EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R5EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR5EE = sizeof($R5EE); $ProbR5EE = $totalR5EE/$totalR5E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R5 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R5EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R5EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR5EG = sizeof($R5EG); $ProbR5EG = $totalR5EG/$totalR5E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R5 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R5ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R5ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR5ES = sizeof($R5ES); $ProbR5ES = $totalR5ES/$totalR5E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R5 = 'Good'") or die(mySQL_error()); $Drow = array(); $R5G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R5G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR5G = sizeof($R5G); echo "Total R5 Good: " . $totalR5G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R5 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R5GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R5GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR5GE = sizeof($R5GE); $ProbR5GE = $totalR5GE/$totalR5G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R5 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R5GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R5GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR5GG = sizeof($R5GG); $ProbR5GG = $totalR5GG/$totalR5G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R5 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R5GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R5GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR5GS = sizeof($R5GS); $ProbR5GS = $totalR5GS/$totalR5G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R5 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R5S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R5S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR5S = sizeof($R5S); echo "Total R5 Satisfactory: " . $totalR5S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R5 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R5SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R5SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR5SE = sizeof($R5SE); $ProbR5SE = $totalR5SE/$totalR5S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R5 = 'Satisfactory' AND CL ='Good'") or die(mySQL_error()); $Drow = array(); $R5SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R5SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR5SG = sizeof($R5SG); $ProbR5SG = $totalR5SG/$totalR5S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R5 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R5SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R5SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR5SS = sizeof($R5SS); $ProbR5SS = $totalR5SS/$totalR5S; //Entropy of R5 $ProbR5E= $totalR5E/$totalR5; $ProbR5G= $totalR5G/$totalR5; $ProbR5S= $totalR5S/$totalR5; if($ProbR5EE == 0 || $ProbR5EG == 0 || $ProbR5ES == 0) { $EntR5 = 0; } else { $EntR5= $ProbR5E * entropy($ProbR5EE,$ProbR5EG,$ProbR5ES) + $ProbR5G * entropy($ProbR5GE,$ProbR5GG,$ProbR5GS) + $ProbR5S * entropy($ProbR5SE,$ProbR5SG,$ProbR5SS); } echo "<br>"; echo "Entropy of R5 AND CL is: " . $EntR5; echo "<br>"; //R6 $result = mySQL_Query("SELECT R6 FROM ranking") or die(mySQL_error()); $Drow = array(); $R6 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R6[$i] = $Drow[0]; $i++; } $totalR6 = sizeof($R6); echo "<br>"; print_r($R6); echo "<br>"; echo "Total R6: " . $totalR6; //R6 Prob echo "<h2>R6 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R6 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R6E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R6E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR6E = sizeof($R6E); echo "Total R6 Excellent: " . $totalR6E . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R6 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R6EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R6EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR6EE = sizeof($R6EE); $ProbR6EE = $totalR6EE/$totalR6E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R6 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R6EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R6EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR6EG = sizeof($R6EG); $ProbR6EG = $totalR6EG/$totalR6E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R6 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R6ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R6ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR6ES = sizeof($R6ES); $ProbR6ES = $totalR6ES/$totalR6E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R6 = 'Good'") or die(mySQL_error()); $Drow = array(); $R6G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R6G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR6G = sizeof($R6G); echo "Total R6 Good: " . $totalR6G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R6 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R6GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R6GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR6GE = sizeof($R6GE); $ProbR6GE = $totalR6GE/$totalR6G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R6 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R6GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R6GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR6GG = sizeof($R6GG); $ProbR6GG = $totalR6GG/$totalR6G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R6 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R6GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R6GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR6GS = sizeof($R6GS); $ProbR6GS = $totalR6GS/$totalR6G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R6 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R6S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R6S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR6S = sizeof($R6S); echo "Total R6 Satisfactory: " . $totalR6S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R6 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R6SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R6SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR6SE = sizeof($R6SE); $ProbR6SE = $totalR6SE/$totalR6S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R6 = 'Satisfactory' AND CL ='Good'") or die(mySQL_error()); $Drow = array(); $R6SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R6SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR6SG = sizeof($R6SG); $ProbR6SG = $totalR6SG/$totalR6S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R6 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R6SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R6SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR6SS = sizeof($R6SS); $ProbR6SS = $totalR6SS/$totalR6S; //Entropy of R6 $ProbR6E= $totalR6E/$totalR6; $ProbR6G= $totalR6G/$totalR6; $ProbR6S= $totalR6S/$totalR6; if($ProbR6EE == 0 || $ProbR6EG == 0 || $ProbR6ES == 0) { $EntR6 = 0; } else { $EntR6= $ProbR6E * entropy($ProbR6EE,$ProbR6EG,$ProbR6ES) + $ProbR6G * entropy($ProbR6GE,$ProbR6GG,$ProbR6GS) + $ProbR6S * entropy($ProbR6SE,$ProbR6SG,$ProbR6SS); } echo "<br>"; echo "Entropy of R6 AND CL is: " . $EntR6; echo "<br>"; //R7 $result = mySQL_Query("SELECT R7 FROM ranking") or die(mySQL_error()); $Drow = array(); $R7 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R7[$i] = $Drow[0]; $i++; } $totalR7 = sizeof($R7); echo "<br>"; print_r($R7); echo "<br>"; echo "Total R7: " . $totalR7; //R7 Prob echo "<h2>R7 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R7 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R7E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R7E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR7E = sizeof($R7E); echo "Total R7 Excellent: " . $totalR7E . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R7 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R7EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R7EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR7EE = sizeof($R7EE); $ProbR7EE = $totalR7EE/$totalR7E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R7 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R7EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R7EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR7EG = sizeof($R7EG); $ProbR7EG = $totalR7EG/$totalR7E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R7 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R7ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R7ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR7ES = sizeof($R7ES); $ProbR7ES = $totalR7ES/$totalR7E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R7 = 'Good'") or die(mySQL_error()); $Drow = array(); $R7G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R7G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR7G = sizeof($R7G); echo "Total R7 Good: " . $totalR7G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R7 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R7GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R7GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR7GE = sizeof($R7GE); $ProbR7GE = $totalR7GE/$totalR7G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R7 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R7GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R7GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR7GG = sizeof($R7GG); $ProbR7GG = $totalR7GG/$totalR7G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R7 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R7GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R7GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR7GS = sizeof($R7GS); $ProbR7GS = $totalR7GS/$totalR7G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R7 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R7S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R7S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR7S = sizeof($R7S); echo "Total R7 Satisfactory: " . $totalR7S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R7 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R7SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R7SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR7SE = sizeof($R7SE); $ProbR7SE = $totalR7SE/$totalR7S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R7 = 'Satisfactory' AND CL ='Good'") or die(mySQL_error()); $Drow = array(); $R7SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R7SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR7SG = sizeof($R7SG); $ProbR7SG = $totalR7SG/$totalR7S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R7 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R7SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R7SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR7SS = sizeof($R7SS); $ProbR7SS = $totalR7SS/$totalR7S; //Entropy of R7 $ProbR7E= $totalR7E/$totalR7; $ProbR7G= $totalR7G/$totalR7; $ProbR7S= $totalR7S/$totalR7; if($ProbR7EE == 0 || $ProbR7EG == 0 || $ProbR7ES == 0) { $EntR7 = 0; } else { $EntR7= $ProbR7E * entropy($ProbR7EE,$ProbR7EG,$ProbR7ES) + $ProbR7G * entropy($ProbR7GE,$ProbR7GG,$ProbR7GS) + $ProbR7S * entropy($ProbR7SE,$ProbR7SG,$ProbR7SS); } echo "<br>"; echo "Entropy of R7 AND CL is: " . $EntR7; echo "<br>"; //R8 $result = mySQL_Query("SELECT R8 FROM ranking") or die(mySQL_error()); $Drow = array(); $R8 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R8[$i] = $Drow[0]; $i++; } $totalR8 = sizeof($R8); echo "<br>"; print_r($R8); echo "<br>"; echo "Total R8: " . $totalR8; //R8 Prob echo "<h2>R8 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R8 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R8E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R8E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR8E = sizeof($R8E); echo "Total R8 Excellent: " . $totalR8E . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R8 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R8EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R8EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR8EE = sizeof($R8EE); $ProbR8EE = $totalR8EE/$totalR8E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R8 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R8EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R8EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR8EG = sizeof($R8EG); $ProbR8EG = $totalR8EG/$totalR8E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R8 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R8ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R8ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR8ES = sizeof($R8ES); $ProbR8ES = $totalR8ES/$totalR8E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R8 = 'Good'") or die(mySQL_error()); $Drow = array(); $R8G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R8G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR8G = sizeof($R8G); echo "Total R8 Good: " . $totalR8G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R8 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R8GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R8GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR8GE = sizeof($R8GE); $ProbR8GE = $totalR8GE/$totalR8G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R8 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R8GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R8GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR8GG = sizeof($R8GG); $ProbR8GG = $totalR8GG/$totalR8G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R8 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R8GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R8GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR8GS = sizeof($R8GS); $ProbR8GS = $totalR8GS/$totalR8G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R8 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R8S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R8S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR8S = sizeof($R8S); echo "Total R8 Satisfactory: " . $totalR8S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R8 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R8SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R8SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR8SE = sizeof($R8SE); $ProbR8SE = $totalR8SE/$totalR8S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R8 = 'Satisfactory' AND CL ='Good'") or die(mySQL_error()); $Drow = array(); $R8SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R8SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR8SG = sizeof($R8SG); $ProbR8SG = $totalR8SG/$totalR8S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R8 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R8SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R8SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR8SS = sizeof($R8SS); $ProbR8SS = $totalR8SS/$totalR8S; //Entropy of R8 $ProbR8E= $totalR8E/$totalR8; $ProbR8G= $totalR8G/$totalR8; $ProbR8S= $totalR8S/$totalR8; if($ProbR8EE == 0 || $ProbR8EG == 0 || $ProbR8ES == 0) { $EntR8 = 0; } else { $EntR8= $ProbR8E * entropy($ProbR8EE,$ProbR8EG,$ProbR8ES) + $ProbR8G * entropy($ProbR8GE,$ProbR8GG,$ProbR8GS) + $ProbR8S * entropy($ProbR8SE,$ProbR8SG,$ProbR8SS); } echo "<br>"; echo "Entropy of R8 AND CL is: " . $EntR8; echo "<br>"; //R9 $result = mySQL_Query("SELECT R9 FROM ranking") or die(mySQL_error()); $Drow = array(); $R9 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R9[$i] = $Drow[0]; $i++; } $totalR9 = sizeof($R9); echo "<br>"; print_r($R9); echo "<br>"; echo "Total R9: " . $totalR9; //R9 Prob echo "<h2>R9 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R9 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R9E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R9E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR9E = sizeof($R9E); echo "Total R9 Excellent: " . $totalR9E . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R9 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R9EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R9EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR9EE = sizeof($R9EE); $ProbR9EE = $totalR9EE/$totalR9E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R9 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R9EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R9EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR9EG = sizeof($R9EG); $ProbR9EG = $totalR9EG/$totalR9E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R9 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R9ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R9ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR9ES = sizeof($R9ES); $ProbR9ES = $totalR9ES/$totalR9E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R9 = 'Good'") or die(mySQL_error()); $Drow = array(); $R9G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R9G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR9G = sizeof($R9G); echo "Total R9 Good: " . $totalR9G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R9 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R9GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R9GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR9GE = sizeof($R9GE); $ProbR9GE = $totalR9GE/$totalR9G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R9 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R9GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R9GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR9GG = sizeof($R9GG); $ProbR9GG = $totalR9GG/$totalR9G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R9 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R9GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R9GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR9GS = sizeof($R9GS); $ProbR9GS = $totalR9GS/$totalR9G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R9 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R9S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R9S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR9S = sizeof($R9S); echo "Total R9 Satisfactory: " . $totalR9S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R9 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R9SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R9SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR9SE = sizeof($R9SE); $ProbR9SE = $totalR9SE/$totalR9S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R9 = 'Satisfactory' AND CL ='Good'") or die(mySQL_error()); $Drow = array(); $R9SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R9SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR9SG = sizeof($R9SG); $ProbR9SG = $totalR9SG/$totalR9S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R9 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R9SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R9SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR9SS = sizeof($R9SS); $ProbR9SS = $totalR9SS/$totalR9S; //Entropy of R9 $ProbR9E= $totalR9E/$totalR9; $ProbR9G= $totalR9G/$totalR9; $ProbR9S= $totalR9S/$totalR9; if($ProbR9EE == 0 || $ProbR9EG == 0 || $ProbR9ES == 0) { $EntR9 = 0; } else { $EntR9= $ProbR9E * entropy($ProbR9EE,$ProbR9EG,$ProbR9ES) + $ProbR9G * entropy($ProbR9GE,$ProbR9GG,$ProbR9GS) + $ProbR9S * entropy($ProbR9SE,$ProbR9SG,$ProbR9SS); } echo "<br>"; echo "Entropy of R9 AND CL is: " . $EntR9; echo "<br>"; //R10 $result = mySQL_Query("SELECT R10 FROM ranking") or die(mySQL_error()); $Drow = array(); $R10 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R10[$i] = $Drow[0]; $i++; } $totalR10 = sizeof($R10); echo "<br>"; print_r($R10); echo "<br>"; echo "Total R10: " . $totalR10; //R10 Prob echo "<h2>R10 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R10 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R10E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R10E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR10E = sizeof($R10E); echo "Total R10 Excellent: " . $totalR10E . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R10 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R10EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R10EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR10EE = sizeof($R10EE); $ProbR10EE = $totalR10EE/$totalR10E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R10 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R10EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R10EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR10EG = sizeof($R10EG); $ProbR10EG = $totalR10EG/$totalR10E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R10 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R10ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R10ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR10ES = sizeof($R10ES); $ProbR10ES = $totalR10ES/$totalR10E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R10 = 'Good'") or die(mySQL_error()); $Drow = array(); $R10G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R10G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR10G = sizeof($R10G); echo "Total R10 Good: " . $totalR10G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R10 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R10GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R10GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR10GE = sizeof($R10GE); $ProbR10GE = $totalR10GE/$totalR10G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R10 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R10GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R10GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR10GG = sizeof($R10GG); $ProbR10GG = $totalR10GG/$totalR10G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R10 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R10GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R10GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR10GS = sizeof($R10GS); $ProbR10GS = $totalR10GS/$totalR10G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R10 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R10S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R10S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR10S = sizeof($R10S); echo "Total R10 Satisfactory: " . $totalR10S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R10 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R10SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R10SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR10SE = sizeof($R10SE); $ProbR10SE = $totalR10SE/$totalR10S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R10 = 'Satisfactory' AND CL ='Good'") or die(mySQL_error()); $Drow = array(); $R10SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R10SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR10SG = sizeof($R10SG); $ProbR10SG = $totalR10SG/$totalR10S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R10 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R10SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R10SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR10SS = sizeof($R10SS); $ProbR10SS = $totalR10SS/$totalR10S; //Entropy of R10 $ProbR10E= $totalR10E/$totalR10; $ProbR10G= $totalR10G/$totalR10; $ProbR10S= $totalR10S/$totalR10; if($ProbR10EE == 0 || $ProbR10EG == 0 || $ProbR10ES == 0) { $EntR10 = 0; } else { $EntR10= $ProbR10E * entropy($ProbR10EE,$ProbR10EG,$ProbR10ES) + $ProbR10G * entropy($ProbR10GE,$ProbR10GG,$ProbR10GS) + $ProbR10S * entropy($ProbR10SE,$ProbR10SG,$ProbR10SS); } echo "<br>"; echo "Entropy of R10 AND CL is: " . $EntR10; echo "<br>"; //R11 $result = mySQL_Query("SELECT R11 FROM ranking") or die(mySQL_error()); $Drow = array(); $R11 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R11[$i] = $Drow[0]; $i++; } $totalR11 = sizeof($R11); echo "<br>"; print_r($R11); echo "<br>"; echo "Total R11: " . $totalR11; //R11 Prob echo "<h2>R11 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R11 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R11E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R11E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR11E = sizeof($R11E); echo "Total R11 Excellent: " . $totalR11E . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R11 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R11EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R11EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR11EE = sizeof($R11EE); $ProbR11EE = $totalR11EE/$totalR11E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R11 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R11EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R11EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR11EG = sizeof($R11EG); $ProbR11EG = $totalR11EG/$totalR11E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R11 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R11ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R11ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR11ES = sizeof($R11ES); $ProbR11ES = $totalR11ES/$totalR11E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R11 = 'Good'") or die(mySQL_error()); $Drow = array(); $R11G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R11G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR11G = sizeof($R11G); echo "Total R11 Good: " . $totalR11G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R11 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R11GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R11GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR11GE = sizeof($R11GE); $ProbR11GE = $totalR11GE/$totalR11G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R11 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R11GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R11GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR11GG = sizeof($R11GG); $ProbR11GG = $totalR11GG/$totalR11G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R11 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R11GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R11GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR11GS = sizeof($R11GS); $ProbR11GS = $totalR11GS/$totalR11G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R11 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R11S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R11S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR11S = sizeof($R11S); echo "Total R11 Satisfactory: " . $totalR11S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R11 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R11SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R11SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR11SE = sizeof($R11SE); $ProbR11SE = $totalR11SE/$totalR11S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R11 = 'Satisfactory' AND CL ='Good'") or die(mySQL_error()); $Drow = array(); $R11SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R11SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR11SG = sizeof($R11SG); $ProbR11SG = $totalR11SG/$totalR11S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R11 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R11SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R11SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR11SS = sizeof($R11SS); $ProbR11SS = $totalR11SS/$totalR11S; //Entropy of R11 $ProbR11E= $totalR11E/$totalR11; $ProbR11G= $totalR11G/$totalR11; $ProbR11S= $totalR11S/$totalR11; if($ProbR11EE == 0 || $ProbR11EG == 0 || $ProbR11ES == 0) { $EntR11 = 0; } else { $EntR11= $ProbR11E * entropy($ProbR11EE,$ProbR11EG,$ProbR11ES) + $ProbR11G * entropy($ProbR11GE,$ProbR11GG,$ProbR11GS) + $ProbR11S * entropy($ProbR11SE,$ProbR11SG,$ProbR11SS); } echo "<br>"; echo "Entropy of R11 AND CL is: " . $EntR11; echo "<br>"; //R12 $result = mySQL_Query("SELECT R12 FROM ranking") or die(mySQL_error()); $Drow = array(); $R12 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R12[$i] = $Drow[0]; $i++; } $totalR12 = sizeof($R12); echo "<br>"; print_r($R12); echo "<br>"; echo "Total R12: " . $totalR12; //R12 Prob echo "<h2>R12 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R12 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R12E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R12E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR12E = sizeof($R12E); echo "Total R12 Excellent: " . $totalR12E . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R12 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R12EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R12EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR12EE = sizeof($R12EE); $ProbR12EE = $totalR12EE/$totalR12E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R12 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R12EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R12EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR12EG = sizeof($R12EG); $ProbR12EG = $totalR12EG/$totalR12E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R12 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R12ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R12ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR12ES = sizeof($R12ES); $ProbR12ES = $totalR12ES/$totalR12E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R12 = 'Good'") or die(mySQL_error()); $Drow = array(); $R12G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R12G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR12G = sizeof($R12G); echo "Total R12 Good: " . $totalR12G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R12 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R12GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R12GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR12GE = sizeof($R12GE); $ProbR12GE = $totalR12GE/$totalR12G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R12 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R12GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R12GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR12GG = sizeof($R12GG); $ProbR12GG = $totalR12GG/$totalR12G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R12 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R12GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R12GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR12GS = sizeof($R12GS); $ProbR12GS = $totalR12GS/$totalR12G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R12 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R12S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R12S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR12S = sizeof($R12S); echo "Total R12 Satisfactory: " . $totalR12S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R12 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R12SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R12SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR12SE = sizeof($R12SE); $ProbR12SE = $totalR12SE/$totalR12S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R12 = 'Satisfactory' AND CL ='Good'") or die(mySQL_error()); $Drow = array(); $R12SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R12SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR12SG = sizeof($R12SG); $ProbR12SG = $totalR12SG/$totalR12S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R12 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R12SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R12SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR12SS = sizeof($R12SS); $ProbR12SS = $totalR12SS/$totalR12S; //Entropy of R12 $ProbR12E= $totalR12E/$totalR12; $ProbR12G= $totalR12G/$totalR12; $ProbR12S= $totalR12S/$totalR12; if($ProbR12EE == 0 || $ProbR12EG == 0 || $ProbR12ES == 0) { $EntR12 = 0; } else { $EntR12= $ProbR12E * entropy($ProbR12EE,$ProbR12EG,$ProbR12ES) + $ProbR12G * entropy($ProbR12GE,$ProbR12GG,$ProbR12GS) + $ProbR12S * entropy($ProbR12SE,$ProbR12SG,$ProbR12SS); } echo "<br>"; echo "Entropy of R12 AND CL is: " . $EntR12; echo "<br>"; //R13 $result = mySQL_Query("SELECT R13 FROM ranking") or die(mySQL_error()); $Drow = array(); $R13 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R13[$i] = $Drow[0]; $i++; } $totalR13 = sizeof($R13); echo "<br>"; print_r($R13); echo "<br>"; echo "Total R13: " . $totalR13; //R13 Prob echo "<h2>R13 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R13 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R13E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R13E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR13E = sizeof($R13E); echo "Total R13 Excellent: " . $totalR13E . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R13 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R13EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R13EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR13EE = sizeof($R13EE); $ProbR13EE = $totalR13EE/$totalR13E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R13 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R13EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R13EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR13EG = sizeof($R13EG); $ProbR13EG = $totalR13EG/$totalR13E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R13 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R13ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R13ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR13ES = sizeof($R13ES); $ProbR13ES = $totalR13ES/$totalR13E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R13 = 'Good'") or die(mySQL_error()); $Drow = array(); $R13G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R13G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR13G = sizeof($R13G); echo "Total R13 Good: " . $totalR13G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R13 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R13GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R13GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR13GE = sizeof($R13GE); $ProbR13GE = $totalR13GE/$totalR13G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R13 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R13GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R13GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR13GG = sizeof($R13GG); $ProbR13GG = $totalR13GG/$totalR13G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R13 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R13GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R13GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR13GS = sizeof($R13GS); $ProbR13GS = $totalR13GS/$totalR13G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R13 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R13S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R13S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR13S = sizeof($R13S); echo "Total R13 Satisfactory: " . $totalR13S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R13 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R13SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R13SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR13SE = sizeof($R13SE); $ProbR13SE = $totalR13SE/$totalR13S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R13 = 'Satisfactory' AND CL ='Good'") or die(mySQL_error()); $Drow = array(); $R13SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R13SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR13SG = sizeof($R13SG); $ProbR13SG = $totalR13SG/$totalR13S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R13 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R13SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R13SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR13SS = sizeof($R13SS); $ProbR13SS = $totalR13SS/$totalR13S; //Entropy of R13 $ProbR13E= $totalR13E/$totalR13; $ProbR13G= $totalR13G/$totalR13; $ProbR13S= $totalR13S/$totalR13; if($ProbR13EE == 0 || $ProbR13EG == 0 || $ProbR13ES == 0) { $EntR13 = 0; } else { $EntR13= $ProbR13E * entropy($ProbR13EE,$ProbR13EG,$ProbR13ES) + $ProbR13G * entropy($ProbR13GE,$ProbR13GG,$ProbR13GS) + $ProbR13S * entropy($ProbR13SE,$ProbR13SG,$ProbR13SS); } echo "<br>"; echo "Entropy of R13 AND CL is: " . $EntR13; echo "<br>"; //R14 $result = mySQL_Query("SELECT R14 FROM ranking") or die(mySQL_error()); $Drow = array(); $R14 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R14[$i] = $Drow[0]; $i++; } $totalR14 = sizeof($R14); echo "<br>"; print_r($R14); echo "<br>"; echo "Total R14: " . $totalR14; //R14 Prob echo "<h2>R14 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R14 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R14E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R14E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR14E = sizeof($R14E); echo "Total R14 Excellent: " . $totalR14E . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R14 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R14EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R14EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR14EE = sizeof($R14EE); $ProbR14EE = $totalR14EE/$totalR14E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R14 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R14EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R14EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR14EG = sizeof($R14EG); $ProbR14EG = $totalR14EG/$totalR14E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R14 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R14ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R14ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR14ES = sizeof($R14ES); $ProbR14ES = $totalR14ES/$totalR14E; $result = mySQL_Query("SELECT CL FROM ranking WHERE R14 = 'Good'") or die(mySQL_error()); $Drow = array(); $R14G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R14G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR14G = sizeof($R14G); echo "Total R14 Good: " . $totalR14G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE R14 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R14GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R14GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR14GE = sizeof($R14GE); $ProbR14GE = $totalR14GE/$totalR14G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R14 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $R14GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R14GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR14GG = sizeof($R14GG); $ProbR14GG = $totalR14GG/$totalR14G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R14 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R14GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R14GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR14GS = sizeof($R14GS); $ProbR14GS = $totalR14GS/$totalR14G; $result = mySQL_Query("SELECT CL FROM ranking WHERE R14 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R14S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R14S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR14S = sizeof($R14S); echo "Total R14 Satisfactory: " . $totalR14S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R14 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $R14SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R14SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR14SE = sizeof($R14SE); $ProbR14SE = $totalR14SE/$totalR14S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R14 = 'Satisfactory' AND CL ='Good'") or die(mySQL_error()); $Drow = array(); $R14SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R14SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR14SG = sizeof($R14SG); $ProbR14SG = $totalR14SG/$totalR14S; $result = mySQL_Query("SELECT CL FROM ranking WHERE R14 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $R14SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $R14SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalR14SS = sizeof($R14SS); $ProbR14SS = $totalR14SS/$totalR14S; //Entropy of R14 $ProbR14E= $totalR14E/$totalR14; $ProbR14G= $totalR14G/$totalR14; $ProbR14S= $totalR14S/$totalR14; if($ProbR14EE == 0 || $ProbR14EG == 0 || $ProbR14ES == 0) { $EntR14 = 0; } else { $EntR14= $ProbR14E * entropy($ProbR14EE,$ProbR14EG,$ProbR14ES) + $ProbR14G * entropy($ProbR14GE,$ProbR14GG,$ProbR14GS) + $ProbR14S * entropy($ProbR14SE,$ProbR14SG,$ProbR14SS); } echo "<br>"; echo "Entropy of R14 AND CL is: " . $EntR14; echo "<br>"; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Internationalization !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// $result = mySQL_Query("SELECT I1 FROM ranking") or die(mySQL_error()); $Drow = array(); $I1 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I1[$i] = $Drow[0]; $i++; } $totalI1 = sizeof($I1); echo "<br>"; print_r($I1); echo "<br>"; echo "Total I1: " . $totalI1; echo "<br>"; echo "<h2>I1 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE I1 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I1E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I1E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI1E = sizeof($I1E); echo "Total I1 Excellent: " . $totalI1E . "<br>"; $ProbI1E = $totalI1E/$totalI1; $result = mySQL_Query("SELECT CL FROM ranking WHERE I1 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I1EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I1EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI1EE = sizeof($I1EE); $ProbI1EE = $totalI1EE/$totalI1E; $result = mySQL_Query("SELECT CL FROM ranking WHERE I1 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $I1EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I1EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI1EG = sizeof($I1EG); $ProbI1EG = $totalI1EG/$totalI1E; $result = mySQL_Query("SELECT CL FROM ranking WHERE I1 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I1ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I1ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI1ES = sizeof($I1ES); $ProbI1ES = $totalI1ES/$totalI1E; $result = mySQL_Query("SELECT CL FROM ranking WHERE I1 = 'Good'") or die(mySQL_error()); $Drow = array(); $I1G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I1G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI1G = sizeof($I1G); echo "Total I1 Good: " . $totalI1G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE I1 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I1GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I1GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI1GE = sizeof($I1GE); $ProbI1GE = $totalI1GE/$totalI1G; $result = mySQL_Query("SELECT CL FROM ranking WHERE I1 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $I1GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I1GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI1GG = sizeof($I1GG); $ProbI1GG = $totalI1GG/$totalI1G; $result = mySQL_Query("SELECT CL FROM ranking WHERE I1 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I1GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I1GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI1GS = sizeof($I1GS); $ProbI1GS = $totalI1GS/$totalI1G; $result = mySQL_Query("SELECT CL FROM ranking WHERE I1 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I1S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I1S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI1S = sizeof($I1S); echo "Total I1 Satisfactory: " . $totalI1S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE I1 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I1SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I1SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI1SE = sizeof($I1SE); $ProbI1SE = $totalI1SE/$totalI1S; $result = mySQL_Query("SELECT CL FROM ranking WHERE I1 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $I1SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I1SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI1SG = sizeof($I1SG); $ProbI1SG = $totalI1SG/$totalI1S; $result = mySQL_Query("SELECT CL FROM ranking WHERE I1 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I1SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I1SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI1SS = sizeof($I1SS); $ProbI1SS = $totalI1SS/$totalI1S; //Entropy of I1 $ProbI1E= $totalI1E/$totalI1; $ProbI1G= $totalI1G/$totalI1; $ProbI1S= $totalI1S/$totalI1; if($ProbI1EE == 0 || $ProbI1EG == 0 || $ProbI1ES == 0) { $EntI1 = 0; } else { $EntI1= $ProbI1E * entropy($ProbI1EE,$ProbI1EG,$ProbI1ES) + $ProbI1G * entropy($ProbI1GE,$ProbI1GG,$ProbI1GS) + $ProbI1S * entropy($ProbI1SE,$ProbI1SG,$ProbI1SS); } echo "<br>"; echo "Entropy of I1 AND CL is: " . $EntI1; echo "<br>"; $result = mySQL_Query("SELECT I2 FROM ranking") or die(mySQL_error()); $Drow = array(); $I2 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I2[$i] = $Drow[0]; $i++; } $totalI2 = sizeof($I2); echo "<br>"; print_r($I2); echo "<br>"; echo "Total I2: " . $totalI2; echo "<br>"; echo "<h2>I2 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE I2 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I2E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I2E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI2E = sizeof($I2E); echo "Total I2 Excellent: " . $totalI2E . "<br>"; $ProbI2E = $totalI2E/$totalI2; $result = mySQL_Query("SELECT CL FROM ranking WHERE I2 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I2EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I2EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI2EE = sizeof($I2EE); $ProbI2EE = $totalI2EE/$totalI2E; $result = mySQL_Query("SELECT CL FROM ranking WHERE I2 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $I2EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I2EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI2EG = sizeof($I2EG); $ProbI2EG = $totalI2EG/$totalI2E; $result = mySQL_Query("SELECT CL FROM ranking WHERE I2 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I2ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I2ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI2ES = sizeof($I2ES); $ProbI2ES = $totalI2ES/$totalI2E; $result = mySQL_Query("SELECT CL FROM ranking WHERE I2 = 'Good'") or die(mySQL_error()); $Drow = array(); $I2G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I2G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI2G = sizeof($I2G); echo "Total I2 Good: " . $totalI2G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE I2 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I2GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I2GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI2GE = sizeof($I2GE); $ProbI2GE = $totalI2GE/$totalI2G; $result = mySQL_Query("SELECT CL FROM ranking WHERE I2 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $I2GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I2GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI2GG = sizeof($I2GG); $ProbI2GG = $totalI2GG/$totalI2G; $result = mySQL_Query("SELECT CL FROM ranking WHERE I2 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I2GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I2GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI2GS = sizeof($I2GS); $ProbI2GS = $totalI2GS/$totalI2G; $result = mySQL_Query("SELECT CL FROM ranking WHERE I2 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I2S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I2S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI2S = sizeof($I2S); echo "Total I2 Satisfactory: " . $totalI2S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE I2 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I2SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I2SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI2SE = sizeof($I2SE); $ProbI2SE = $totalI2SE/$totalI2S; $result = mySQL_Query("SELECT CL FROM ranking WHERE I2 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $I2SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I2SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI2SG = sizeof($I2SG); $ProbI2SG = $totalI2SG/$totalI2S; $result = mySQL_Query("SELECT CL FROM ranking WHERE I2 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I2SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I2SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI2SS = sizeof($I2SS); $ProbI2SS = $totalI2SS/$totalI2S; //Entropy of I2 $ProbI2E= $totalI2E/$totalI2; $ProbI2G= $totalI2G/$totalI2; $ProbI2S= $totalI2S/$totalI2; if($ProbI2EE == 0 || $ProbI2EG == 0 || $ProbI2ES == 0) { $EntI2 = 0; } else { $EntI2= $ProbI2E * entropy($ProbI2EE,$ProbI2EG,$ProbI2ES) + $ProbI2G * entropy($ProbI2GE,$ProbI2GG,$ProbI2GS) + $ProbI2S * entropy($ProbI2SE,$ProbI2SG,$ProbI2SS); } echo "<br>"; echo "Entropy of I2 AND CL is: " . $EntI2; echo "<br>"; $result = mySQL_Query("SELECT I3 FROM ranking") or die(mySQL_error()); $Drow = array(); $I3 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I3[$i] = $Drow[0]; $i++; } $totalI3 = sizeof($I3); echo "<br>"; print_r($I3); echo "<br>"; echo "Total I3: " . $totalI3; echo "<br>"; echo "<h2>I3 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE I3 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I3E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I3E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI3E = sizeof($I3E); echo "Total I3 Excellent: " . $totalI3E . "<br>"; $ProbI3E = $totalI3E/$totalI3; $result = mySQL_Query("SELECT CL FROM ranking WHERE I3 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I3EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I3EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI3EE = sizeof($I3EE); $ProbI3EE = $totalI3EE/$totalI3E; $result = mySQL_Query("SELECT CL FROM ranking WHERE I3 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $I3EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I3EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI3EG = sizeof($I3EG); $ProbI3EG = $totalI3EG/$totalI3E; $result = mySQL_Query("SELECT CL FROM ranking WHERE I3 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I3ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I3ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI3ES = sizeof($I3ES); $ProbI3ES = $totalI3ES/$totalI3E; $result = mySQL_Query("SELECT CL FROM ranking WHERE I3 = 'Good'") or die(mySQL_error()); $Drow = array(); $I3G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I3G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI3G = sizeof($I3G); echo "Total I3 Good: " . $totalI3G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE I3 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I3GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I3GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI3GE = sizeof($I3GE); $ProbI3GE = $totalI3GE/$totalI3G; $result = mySQL_Query("SELECT CL FROM ranking WHERE I3 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $I3GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I3GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI3GG = sizeof($I3GG); $ProbI3GG = $totalI3GG/$totalI3G; $result = mySQL_Query("SELECT CL FROM ranking WHERE I3 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I3GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I3GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI3GS = sizeof($I3GS); $ProbI3GS = $totalI3GS/$totalI3G; $result = mySQL_Query("SELECT CL FROM ranking WHERE I3 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I3S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I3S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI3S = sizeof($I3S); echo "Total I3 Satisfactory: " . $totalI3S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE I3 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I3SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I3SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI3SE = sizeof($I3SE); $ProbI3SE = $totalI3SE/$totalI3S; $result = mySQL_Query("SELECT CL FROM ranking WHERE I3 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $I3SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I3SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI3SG = sizeof($I3SG); $ProbI3SG = $totalI3SG/$totalI3S; $result = mySQL_Query("SELECT CL FROM ranking WHERE I3 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I3SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I3SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI3SS = sizeof($I3SS); $ProbI3SS = $totalI3SS/$totalI3S; //Entropy of I3 $ProbI3E= $totalI3E/$totalI3; $ProbI3G= $totalI3G/$totalI3; $ProbI3S= $totalI3S/$totalI3; if($ProbI3EE == 0 || $ProbI3EG == 0 || $ProbI3ES == 0) { $EntI3 = 0; } else { $EntI3= $ProbI3E * entropy($ProbI3EE,$ProbI3EG,$ProbI3ES) + $ProbI3G * entropy($ProbI3GE,$ProbI3GG,$ProbI3GS) + $ProbI3S * entropy($ProbI3SE,$ProbI3SG,$ProbI3SS); } echo "<br>"; echo "Entropy of I3 AND CL is: " . $EntI3; echo "<br>"; $result = mySQL_Query("SELECT I4 FROM ranking") or die(mySQL_error()); $Drow = array(); $I4 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I4[$i] = $Drow[0]; $i++; } $totalI4 = sizeof($I4); echo "<br>"; print_r($I4); echo "<br>"; echo "Total I4: " . $totalI4; echo "<br>"; echo "<h2>I4 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE I4 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I4E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I4E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI4E = sizeof($I4E); echo "Total I4 Excellent: " . $totalI4E . "<br>"; $ProbI4E = $totalI4E/$totalI4; $result = mySQL_Query("SELECT CL FROM ranking WHERE I4 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I4EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I4EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI4EE = sizeof($I4EE); $ProbI4EE = $totalI4EE/$totalI4E; $result = mySQL_Query("SELECT CL FROM ranking WHERE I4 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $I4EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I4EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI4EG = sizeof($I4EG); $ProbI4EG = $totalI4EG/$totalI4E; $result = mySQL_Query("SELECT CL FROM ranking WHERE I4 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I4ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I4ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI4ES = sizeof($I4ES); $ProbI4ES = $totalI4ES/$totalI4E; $result = mySQL_Query("SELECT CL FROM ranking WHERE I4 = 'Good'") or die(mySQL_error()); $Drow = array(); $I4G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I4G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI4G = sizeof($I4G); echo "Total I4 Good: " . $totalI4G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE I4 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I4GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I4GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI4GE = sizeof($I4GE); $ProbI4GE = $totalI4GE/$totalI4G; $result = mySQL_Query("SELECT CL FROM ranking WHERE I4 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $I4GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I4GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI4GG = sizeof($I4GG); $ProbI4GG = $totalI4GG/$totalI4G; $result = mySQL_Query("SELECT CL FROM ranking WHERE I4 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I4GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I4GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI4GS = sizeof($I4GS); $ProbI4GS = $totalI4GS/$totalI4G; $result = mySQL_Query("SELECT CL FROM ranking WHERE I4 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I4S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I4S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI4S = sizeof($I4S); echo "Total I4 Satisfactory: " . $totalI4S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE I4 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I4SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I4SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI4SE = sizeof($I4SE); $ProbI4SE = $totalI4SE/$totalI4S; $result = mySQL_Query("SELECT CL FROM ranking WHERE I4 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $I4SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I4SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI4SG = sizeof($I4SG); $ProbI4SG = $totalI4SG/$totalI4S; $result = mySQL_Query("SELECT CL FROM ranking WHERE I4 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I4SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I4SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI4SS = sizeof($I4SS); $ProbI4SS = $totalI4SS/$totalI4S; //Entropy of I4 $ProbI4E= $totalI4E/$totalI4; $ProbI4G= $totalI4G/$totalI4; $ProbI4S= $totalI4S/$totalI4; if($ProbI4EE == 0 || $ProbI4EG == 0 || $ProbI4ES == 0) { $EntI4 = 0; } else { $EntI4= $ProbI4E * entropy($ProbI4EE,$ProbI4EG,$ProbI4ES) + $ProbI4G * entropy($ProbI4GE,$ProbI4GG,$ProbI4GS) + $ProbI4S * entropy($ProbI4SE,$ProbI4SG,$ProbI4SS); } echo "<br>"; echo "Entropy of I4 AND CL is: " . $EntI4; echo "<br>"; $result = mySQL_Query("SELECT I5 FROM ranking") or die(mySQL_error()); $Drow = array(); $I5 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I5[$i] = $Drow[0]; $i++; } $totalI5 = sizeof($I5); echo "<br>"; print_r($I5); echo "<br>"; echo "Total I5: " . $totalI5; echo "<br>"; echo "<h2>I5 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE I5 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I5E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I5E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI5E = sizeof($I5E); echo "Total I5 Excellent: " . $totalI5E . "<br>"; $ProbI5E = $totalI5E/$totalI5; $result = mySQL_Query("SELECT CL FROM ranking WHERE I5 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I5EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I5EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI5EE = sizeof($I5EE); $ProbI5EE = $totalI5EE/$totalI5E; $result = mySQL_Query("SELECT CL FROM ranking WHERE I5 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $I5EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I5EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI5EG = sizeof($I5EG); $ProbI5EG = $totalI5EG/$totalI5E; $result = mySQL_Query("SELECT CL FROM ranking WHERE I5 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I5ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I5ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI5ES = sizeof($I5ES); $ProbI5ES = $totalI5ES/$totalI5E; $result = mySQL_Query("SELECT CL FROM ranking WHERE I5 = 'Good'") or die(mySQL_error()); $Drow = array(); $I5G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I5G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI5G = sizeof($I5G); echo "Total I5 Good: " . $totalI5G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE I5 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I5GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I5GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI5GE = sizeof($I5GE); $ProbI5GE = $totalI5GE/$totalI5G; $result = mySQL_Query("SELECT CL FROM ranking WHERE I5 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $I5GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I5GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI5GG = sizeof($I5GG); $ProbI5GG = $totalI5GG/$totalI5G; $result = mySQL_Query("SELECT CL FROM ranking WHERE I5 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I5GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I5GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI5GS = sizeof($I5GS); $ProbI5GS = $totalI5GS/$totalI5G; $result = mySQL_Query("SELECT CL FROM ranking WHERE I5 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I5S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I5S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI5S = sizeof($I5S); echo "Total I5 Satisfactory: " . $totalI5S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE I5 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $I5SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I5SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI5SE = sizeof($I5SE); $ProbI5SE = $totalI5SE/$totalI5S; $result = mySQL_Query("SELECT CL FROM ranking WHERE I5 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $I5SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I5SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI5SG = sizeof($I5SG); $ProbI5SG = $totalI5SG/$totalI5S; $result = mySQL_Query("SELECT CL FROM ranking WHERE I5 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $I5SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $I5SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalI5SS = sizeof($I5SS); $ProbI5SS = $totalI5SS/$totalI5S; //Entropy of I5 $ProbI5E= $totalI5E/$totalI5; $ProbI5G= $totalI5G/$totalI5; $ProbI5S= $totalI5S/$totalI5; if($ProbI5EE == 0 || $ProbI5EG == 0 || $ProbI5ES == 0) { $EntI5 = 0; } else { $EntI5= $ProbI5E * entropy($ProbI5EE,$ProbI5EG,$ProbI5ES) + $ProbI5G * entropy($ProbI5GE,$ProbI5GG,$ProbI5GS) + $ProbI5S * entropy($ProbI5SE,$ProbI5SG,$ProbI5SS); } echo "<br>"; echo "Entropy of I5 AND CL is: " . $EntI5; echo "<br>"; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Teaching Quality !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// $result = mySQL_Query("SELECT T1 FROM ranking") or die(mySQL_error()); $Drow = array(); $T1 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T1[$i] = $Drow[0]; $i++; } $totalT1 = sizeof($T1); echo "<br>"; print_r($T1); echo "<br>"; echo "Total T1: " . $totalT1; echo "<br>"; echo "<h2>T1 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE T1 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T1E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T1E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT1E = sizeof($T1E); echo "Total T1 Excellent: " . $totalT1E . "<br>"; $ProbT1E = $totalT1E/$totalT1; $result = mySQL_Query("SELECT CL FROM ranking WHERE T1 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T1EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T1EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT1EE = sizeof($T1EE); $ProbT1EE = $totalT1EE/$totalT1E; $result = mySQL_Query("SELECT CL FROM ranking WHERE T1 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $T1EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T1EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT1EG = sizeof($T1EG); $ProbT1EG = $totalT1EG/$totalT1E; $result = mySQL_Query("SELECT CL FROM ranking WHERE T1 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T1ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T1ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT1ES = sizeof($T1ES); $ProbT1ES = $totalT1ES/$totalT1E; $result = mySQL_Query("SELECT CL FROM ranking WHERE T1 = 'Good'") or die(mySQL_error()); $Drow = array(); $T1G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T1G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT1G = sizeof($T1G); echo "Total T1 Good: " . $totalT1G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE T1 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T1GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T1GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT1GE = sizeof($T1GE); $ProbT1GE = $totalT1GE/$totalT1G; $result = mySQL_Query("SELECT CL FROM ranking WHERE T1 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $T1GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T1GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT1GG = sizeof($T1GG); $ProbT1GG = $totalT1GG/$totalT1G; $result = mySQL_Query("SELECT CL FROM ranking WHERE T1 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T1GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T1GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT1GS = sizeof($T1GS); $ProbT1GS = $totalT1GS/$totalT1G; $result = mySQL_Query("SELECT CL FROM ranking WHERE T1 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T1S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T1S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT1S = sizeof($T1S); echo "Total T1 Satisfactory: " . $totalT1S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE T1 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T1SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T1SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT1SE = sizeof($T1SE); $ProbT1SE = $totalT1SE/$totalT1S; $result = mySQL_Query("SELECT CL FROM ranking WHERE T1 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $T1SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T1SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT1SG = sizeof($T1SG); $ProbT1SG = $totalT1SG/$totalT1S; $result = mySQL_Query("SELECT CL FROM ranking WHERE T1 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T1SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T1SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT1SS = sizeof($T1SS); $ProbT1SS = $totalT1SS/$totalT1S; //Entropy of T1 $ProbT1E= $totalT1E/$totalT1; $ProbT1G= $totalT1G/$totalT1; $ProbT1S= $totalT1S/$totalT1; if($ProbT1EE == 0 || $ProbT1EG == 0 || $ProbT1ES == 0) { $EntT1 = 0; } else { $EntT1= $ProbT1E * entropy($ProbT1EE,$ProbT1EG,$ProbT1ES) + $ProbT1G * entropy($ProbT1GE,$ProbT1GG,$ProbT1GS) + $ProbT1S * entropy($ProbT1SE,$ProbT1SG,$ProbT1SS); } echo "<br>"; echo "Entropy of T1 AND CL is: " . $EntT1; echo "<br>"; $result = mySQL_Query("SELECT T2 FROM ranking") or die(mySQL_error()); $Drow = array(); $T2 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T2[$i] = $Drow[0]; $i++; } $totalT2 = sizeof($T2); echo "<br>"; print_r($T2); echo "<br>"; echo "Total T2: " . $totalT2; echo "<br>"; echo "<h2>T2 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE T2 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T2E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T2E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT2E = sizeof($T2E); echo "Total T2 Excellent: " . $totalT2E . "<br>"; $ProbT2E = $totalT2E/$totalT2; $result = mySQL_Query("SELECT CL FROM ranking WHERE T2 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T2EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T2EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT2EE = sizeof($T2EE); $ProbT2EE = $totalT2EE/$totalT2E; $result = mySQL_Query("SELECT CL FROM ranking WHERE T2 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $T2EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T2EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT2EG = sizeof($T2EG); $ProbT2EG = $totalT2EG/$totalT2E; $result = mySQL_Query("SELECT CL FROM ranking WHERE T2 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T2ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T2ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT2ES = sizeof($T2ES); $ProbT2ES = $totalT2ES/$totalT2E; $result = mySQL_Query("SELECT CL FROM ranking WHERE T2 = 'Good'") or die(mySQL_error()); $Drow = array(); $T2G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T2G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT2G = sizeof($T2G); echo "Total T2 Good: " . $totalT2G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE T2 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T2GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T2GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT2GE = sizeof($T2GE); $ProbT2GE = $totalT2GE/$totalT2G; $result = mySQL_Query("SELECT CL FROM ranking WHERE T2 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $T2GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T2GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT2GG = sizeof($T2GG); $ProbT2GG = $totalT2GG/$totalT2G; $result = mySQL_Query("SELECT CL FROM ranking WHERE T2 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T2GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T2GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT2GS = sizeof($T2GS); $ProbT2GS = $totalT2GS/$totalT2G; $result = mySQL_Query("SELECT CL FROM ranking WHERE T2 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T2S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T2S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT2S = sizeof($T2S); echo "Total T2 Satisfactory: " . $totalT2S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE T2 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T2SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T2SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT2SE = sizeof($T2SE); $ProbT2SE = $totalT2SE/$totalT2S; $result = mySQL_Query("SELECT CL FROM ranking WHERE T2 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $T2SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T2SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT2SG = sizeof($T2SG); $ProbT2SG = $totalT2SG/$totalT2S; $result = mySQL_Query("SELECT CL FROM ranking WHERE T2 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T2SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T2SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT2SS = sizeof($T2SS); $ProbT2SS = $totalT2SS/$totalT2S; //Entropy of T2 $ProbT2E= $totalT2E/$totalT2; $ProbT2G= $totalT2G/$totalT2; $ProbT2S= $totalT2S/$totalT2; if($ProbT2EE == 0 || $ProbT2EG == 0 || $ProbT2ES == 0) { $EntT2 = 0; } else { $EntT2= $ProbT2E * entropy($ProbT2EE,$ProbT2EG,$ProbT2ES) + $ProbT2G * entropy($ProbT2GE,$ProbT2GG,$ProbT2GS) + $ProbT2S * entropy($ProbT2SE,$ProbT2SG,$ProbT2SS); } echo "<br>"; echo "Entropy of T2 AND CL is: " . $EntT2; echo "<br>"; $result = mySQL_Query("SELECT T3 FROM ranking") or die(mySQL_error()); $Drow = array(); $T3 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T3[$i] = $Drow[0]; $i++; } $totalT3 = sizeof($T3); echo "<br>"; print_r($T3); echo "<br>"; echo "Total T3: " . $totalT3; echo "<br>"; echo "<h2>T3 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE T3 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T3E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T3E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT3E = sizeof($T3E); echo "Total T3 Excellent: " . $totalT3E . "<br>"; $ProbT3E = $totalT3E/$totalT3; $result = mySQL_Query("SELECT CL FROM ranking WHERE T3 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T3EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T3EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT3EE = sizeof($T3EE); $ProbT3EE = $totalT3EE/$totalT3E; $result = mySQL_Query("SELECT CL FROM ranking WHERE T3 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $T3EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T3EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT3EG = sizeof($T3EG); $ProbT3EG = $totalT3EG/$totalT3E; $result = mySQL_Query("SELECT CL FROM ranking WHERE T3 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T3ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T3ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT3ES = sizeof($T3ES); $ProbT3ES = $totalT3ES/$totalT3E; $result = mySQL_Query("SELECT CL FROM ranking WHERE T3 = 'Good'") or die(mySQL_error()); $Drow = array(); $T3G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T3G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT3G = sizeof($T3G); echo "Total T3 Good: " . $totalT3G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE T3 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T3GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T3GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT3GE = sizeof($T3GE); $ProbT3GE = $totalT3GE/$totalT3G; $result = mySQL_Query("SELECT CL FROM ranking WHERE T3 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $T3GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T3GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT3GG = sizeof($T3GG); $ProbT3GG = $totalT3GG/$totalT3G; $result = mySQL_Query("SELECT CL FROM ranking WHERE T3 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T3GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T3GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT3GS = sizeof($T3GS); $ProbT3GS = $totalT3GS/$totalT3G; $result = mySQL_Query("SELECT CL FROM ranking WHERE T3 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T3S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T3S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT3S = sizeof($T3S); echo "Total T3 Satisfactory: " . $totalT3S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE T3 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T3SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T3SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT3SE = sizeof($T3SE); $ProbT3SE = $totalT3SE/$totalT3S; $result = mySQL_Query("SELECT CL FROM ranking WHERE T3 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $T3SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T3SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT3SG = sizeof($T3SG); $ProbT3SG = $totalT3SG/$totalT3S; $result = mySQL_Query("SELECT CL FROM ranking WHERE T3 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T3SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T3SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT3SS = sizeof($T3SS); $ProbT3SS = $totalT3SS/$totalT3S; //Entropy of T3 $ProbT3E= $totalT3E/$totalT3; $ProbT3G= $totalT3G/$totalT3; $ProbT3S= $totalT3S/$totalT3; if($ProbT3EE == 0 || $ProbT3EG == 0 || $ProbT3ES == 0) { $EntT3 = 0; } else { $EntT3= $ProbT3E * entropy($ProbT3EE,$ProbT3EG,$ProbT3ES) + $ProbT3G * entropy($ProbT3GE,$ProbT3GG,$ProbT3GS) + $ProbT3S * entropy($ProbT3SE,$ProbT3SG,$ProbT3SS); } echo "<br>"; echo "Entropy of T3 AND CL is: " . $EntT3; echo "<br>"; $result = mySQL_Query("SELECT T4 FROM ranking") or die(mySQL_error()); $Drow = array(); $T4 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T4[$i] = $Drow[0]; $i++; } $totalT4 = sizeof($T4); echo "<br>"; print_r($T4); echo "<br>"; echo "Total T4: " . $totalT4; echo "<br>"; echo "<h2>T4 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE T4 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T4E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T4E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT4E = sizeof($T4E); echo "Total T4 Excellent: " . $totalT4E . "<br>"; $ProbT4E = $totalT4E/$totalT4; $result = mySQL_Query("SELECT CL FROM ranking WHERE T4 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T4EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T4EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT4EE = sizeof($T4EE); $ProbT4EE = $totalT4EE/$totalT4E; $result = mySQL_Query("SELECT CL FROM ranking WHERE T4 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $T4EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T4EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT4EG = sizeof($T4EG); $ProbT4EG = $totalT4EG/$totalT4E; $result = mySQL_Query("SELECT CL FROM ranking WHERE T4 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T4ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T4ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT4ES = sizeof($T4ES); $ProbT4ES = $totalT4ES/$totalT4E; $result = mySQL_Query("SELECT CL FROM ranking WHERE T4 = 'Good'") or die(mySQL_error()); $Drow = array(); $T4G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T4G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT4G = sizeof($T4G); echo "Total T4 Good: " . $totalT4G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE T4 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T4GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T4GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT4GE = sizeof($T4GE); $ProbT4GE = $totalT4GE/$totalT4G; $result = mySQL_Query("SELECT CL FROM ranking WHERE T4 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $T4GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T4GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT4GG = sizeof($T4GG); $ProbT4GG = $totalT4GG/$totalT4G; $result = mySQL_Query("SELECT CL FROM ranking WHERE T4 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T4GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T4GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT4GS = sizeof($T4GS); $ProbT4GS = $totalT4GS/$totalT4G; $result = mySQL_Query("SELECT CL FROM ranking WHERE T4 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T4S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T4S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT4S = sizeof($T4S); echo "Total T4 Satisfactory: " . $totalT4S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE T4 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T4SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T4SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT4SE = sizeof($T4SE); $ProbT4SE = $totalT4SE/$totalT4S; $result = mySQL_Query("SELECT CL FROM ranking WHERE T4 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $T4SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T4SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT4SG = sizeof($T4SG); $ProbT4SG = $totalT4SG/$totalT4S; $result = mySQL_Query("SELECT CL FROM ranking WHERE T4 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T4SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T4SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT4SS = sizeof($T4SS); $ProbT4SS = $totalT4SS/$totalT4S; //Entropy of T4 $ProbT4E= $totalT4E/$totalT4; $ProbT4G= $totalT4G/$totalT4; $ProbT4S= $totalT4S/$totalT4; if($ProbT4EE == 0 || $ProbT4EG == 0 || $ProbT4ES == 0) { $EntT4 = 0; } else { $EntT4= $ProbT4E * entropy($ProbT4EE,$ProbT4EG,$ProbT4ES) + $ProbT4G * entropy($ProbT4GE,$ProbT4GG,$ProbT4GS) + $ProbT4S * entropy($ProbT4SE,$ProbT4SG,$ProbT4SS); } echo "<br>"; echo "Entropy of T4 AND CL is: " . $EntT4; echo "<br>"; $result = mySQL_Query("SELECT T5 FROM ranking") or die(mySQL_error()); $Drow = array(); $T5 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T5[$i] = $Drow[0]; $i++; } $totalT5 = sizeof($T5); echo "<br>"; print_r($T5); echo "<br>"; echo "Total T5: " . $totalT5; echo "<br>"; echo "<h2>T5 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE T5 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T5E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T5E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT5E = sizeof($T5E); echo "Total T5 Excellent: " . $totalT5E . "<br>"; $ProbT5E = $totalT5E/$totalT5; $result = mySQL_Query("SELECT CL FROM ranking WHERE T5 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T5EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T5EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT5EE = sizeof($T5EE); $ProbT5EE = $totalT5EE/$totalT5E; $result = mySQL_Query("SELECT CL FROM ranking WHERE T5 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $T5EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T5EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT5EG = sizeof($T5EG); $ProbT5EG = $totalT5EG/$totalT5E; $result = mySQL_Query("SELECT CL FROM ranking WHERE T5 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T5ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T5ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT5ES = sizeof($T5ES); $ProbT5ES = $totalT5ES/$totalT5E; $result = mySQL_Query("SELECT CL FROM ranking WHERE T5 = 'Good'") or die(mySQL_error()); $Drow = array(); $T5G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T5G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT5G = sizeof($T5G); echo "Total T5 Good: " . $totalT5G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE T5 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T5GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T5GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT5GE = sizeof($T5GE); $ProbT5GE = $totalT5GE/$totalT5G; $result = mySQL_Query("SELECT CL FROM ranking WHERE T5 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $T5GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T5GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT5GG = sizeof($T5GG); $ProbT5GG = $totalT5GG/$totalT5G; $result = mySQL_Query("SELECT CL FROM ranking WHERE T5 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T5GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T5GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT5GS = sizeof($T5GS); $ProbT5GS = $totalT5GS/$totalT5G; $result = mySQL_Query("SELECT CL FROM ranking WHERE T5 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T5S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T5S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT5S = sizeof($T5S); echo "Total T5 Satisfactory: " . $totalT5S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE T5 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $T5SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T5SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT5SE = sizeof($T5SE); $ProbT5SE = $totalT5SE/$totalT5S; $result = mySQL_Query("SELECT CL FROM ranking WHERE T5 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $T5SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T5SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT5SG = sizeof($T5SG); $ProbT5SG = $totalT5SG/$totalT5S; $result = mySQL_Query("SELECT CL FROM ranking WHERE T5 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $T5SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $T5SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalT5SS = sizeof($T5SS); $ProbT5SS = $totalT5SS/$totalT5S; //Entropy of T5 $ProbT5E= $totalT5E/$totalT5; $ProbT5G= $totalT5G/$totalT5; $ProbT5S= $totalT5S/$totalT5; if($ProbT5EE == 0 || $ProbT5EG == 0 || $ProbT5ES == 0) { $EntT5 = 0; } else { $EntT5= $ProbT5E * entropy($ProbT5EE,$ProbT5EG,$ProbT5ES) + $ProbT5G * entropy($ProbT5GE,$ProbT5GG,$ProbT5GS) + $ProbT5S * entropy($ProbT5SE,$ProbT5SG,$ProbT5SS); } echo "<br>"; echo "Entropy of T5 AND CL is: " . $EntT5; echo "<br>"; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Social Integration !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// $result = mySQL_Query("SELECT S1 FROM ranking") or die(mySQL_error()); $Drow = array(); $S1 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S1[$i] = $Drow[0]; $i++; } $totalS1 = sizeof($S1); echo "<br>"; print_r($S1); echo "<br>"; echo "Total S1: " . $totalS1; echo "<br>"; echo "<h2>S1 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE S1 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S1E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S1E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS1E = sizeof($S1E); echo "Total S1 Excellent: " . $totalS1E . "<br>"; $ProbS1E = $totalS1E/$totalS1; $result = mySQL_Query("SELECT CL FROM ranking WHERE S1 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S1EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S1EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS1EE = sizeof($S1EE); $ProbS1EE = $totalS1EE/$totalS1E; $result = mySQL_Query("SELECT CL FROM ranking WHERE S1 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $S1EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S1EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS1EG = sizeof($S1EG); $ProbS1EG = $totalS1EG/$totalS1E; $result = mySQL_Query("SELECT CL FROM ranking WHERE S1 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S1ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S1ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS1ES = sizeof($S1ES); $ProbS1ES = $totalS1ES/$totalS1E; $result = mySQL_Query("SELECT CL FROM ranking WHERE S1 = 'Good'") or die(mySQL_error()); $Drow = array(); $S1G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S1G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS1G = sizeof($S1G); echo "Total S1 Good: " . $totalS1G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE S1 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S1GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S1GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS1GE = sizeof($S1GE); $ProbS1GE = $totalS1GE/$totalS1G; $result = mySQL_Query("SELECT CL FROM ranking WHERE S1 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $S1GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S1GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS1GG = sizeof($S1GG); $ProbS1GG = $totalS1GG/$totalS1G; $result = mySQL_Query("SELECT CL FROM ranking WHERE S1 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S1GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S1GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS1GS = sizeof($S1GS); $ProbS1GS = $totalS1GS/$totalS1G; $result = mySQL_Query("SELECT CL FROM ranking WHERE S1 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S1S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S1S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS1S = sizeof($S1S); echo "Total S1 Satisfactory: " . $totalS1S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE S1 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S1SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S1SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS1SE = sizeof($S1SE); $ProbS1SE = $totalS1SE/$totalS1S; $result = mySQL_Query("SELECT CL FROM ranking WHERE S1 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $S1SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S1SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS1SG = sizeof($S1SG); $ProbS1SG = $totalS1SG/$totalS1S; $result = mySQL_Query("SELECT CL FROM ranking WHERE S1 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S1SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S1SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS1SS = sizeof($S1SS); $ProbS1SS = $totalS1SS/$totalS1S; //Entropy of S1 $ProbS1E= $totalS1E/$totalS1; $ProbS1G= $totalS1G/$totalS1; $ProbS1S= $totalS1S/$totalS1; if($ProbS1EE == 0 || $ProbS1EG == 0 || $ProbS1ES == 0) { $EntS1 = 0; } else { $EntS1= $ProbS1E * entropy($ProbS1EE,$ProbS1EG,$ProbS1ES) + $ProbS1G * entropy($ProbS1GE,$ProbS1GG,$ProbS1GS) + $ProbS1S * entropy($ProbS1SE,$ProbS1SG,$ProbS1SS); } echo "<br>"; echo "Entropy of S1 AND CL is: " . $EntS1; echo "<br>"; $result = mySQL_Query("SELECT S2 FROM ranking") or die(mySQL_error()); $Drow = array(); $S2 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S2[$i] = $Drow[0]; $i++; } $totalS2 = sizeof($S2); echo "<br>"; print_r($S2); echo "<br>"; echo "Total S2: " . $totalS2; echo "<br>"; echo "<h2>S2 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE S2 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S2E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S2E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS2E = sizeof($S2E); echo "Total S2 Excellent: " . $totalS2E . "<br>"; $ProbS2E = $totalS2E/$totalS2; $result = mySQL_Query("SELECT CL FROM ranking WHERE S2 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S2EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S2EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS2EE = sizeof($S2EE); $ProbS2EE = $totalS2EE/$totalS2E; $result = mySQL_Query("SELECT CL FROM ranking WHERE S2 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $S2EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S2EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS2EG = sizeof($S2EG); $ProbS2EG = $totalS2EG/$totalS2E; $result = mySQL_Query("SELECT CL FROM ranking WHERE S2 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S2ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S2ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS2ES = sizeof($S2ES); $ProbS2ES = $totalS2ES/$totalS2E; $result = mySQL_Query("SELECT CL FROM ranking WHERE S2 = 'Good'") or die(mySQL_error()); $Drow = array(); $S2G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S2G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS2G = sizeof($S2G); echo "Total S2 Good: " . $totalS2G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE S2 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S2GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S2GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS2GE = sizeof($S2GE); $ProbS2GE = $totalS2GE/$totalS2G; $result = mySQL_Query("SELECT CL FROM ranking WHERE S2 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $S2GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S2GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS2GG = sizeof($S2GG); $ProbS2GG = $totalS2GG/$totalS2G; $result = mySQL_Query("SELECT CL FROM ranking WHERE S2 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S2GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S2GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS2GS = sizeof($S2GS); $ProbS2GS = $totalS2GS/$totalS2G; $result = mySQL_Query("SELECT CL FROM ranking WHERE S2 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S2S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S2S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS2S = sizeof($S2S); echo "Total S2 Satisfactory: " . $totalS2S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE S2 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S2SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S2SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS2SE = sizeof($S2SE); $ProbS2SE = $totalS2SE/$totalS2S; $result = mySQL_Query("SELECT CL FROM ranking WHERE S2 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $S2SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S2SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS2SG = sizeof($S2SG); $ProbS2SG = $totalS2SG/$totalS2S; $result = mySQL_Query("SELECT CL FROM ranking WHERE S2 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S2SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S2SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS2SS = sizeof($S2SS); $ProbS2SS = $totalS2SS/$totalS2S; //Entropy of S2 $ProbS2E= $totalS2E/$totalS2; $ProbS2G= $totalS2G/$totalS2; $ProbS2S= $totalS2S/$totalS2; if($ProbS2EE == 0 || $ProbS2EG == 0 || $ProbS2ES == 0) { $EntS2 = 0; } else { $EntS2= $ProbS2E * entropy($ProbS2EE,$ProbS2EG,$ProbS2ES) + $ProbS2G * entropy($ProbS2GE,$ProbS2GG,$ProbS2GS) + $ProbS2S * entropy($ProbS2SE,$ProbS2SG,$ProbS2SS); } echo "<br>"; echo "Entropy of S2 AND CL is: " . $EntS2; echo "<br>"; $result = mySQL_Query("SELECT S3 FROM ranking") or die(mySQL_error()); $Drow = array(); $S3 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S3[$i] = $Drow[0]; $i++; } $totalS3 = sizeof($S3); echo "<br>"; print_r($S3); echo "<br>"; echo "Total S3: " . $totalS3; echo "<br>"; echo "<h2>S3 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE S3 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S3E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S3E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS3E = sizeof($S3E); echo "Total S3 Excellent: " . $totalS3E . "<br>"; $ProbS3E = $totalS3E/$totalS3; $result = mySQL_Query("SELECT CL FROM ranking WHERE S3 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S3EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S3EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS3EE = sizeof($S3EE); $ProbS3EE = $totalS3EE/$totalS3E; $result = mySQL_Query("SELECT CL FROM ranking WHERE S3 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $S3EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S3EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS3EG = sizeof($S3EG); $ProbS3EG = $totalS3EG/$totalS3E; $result = mySQL_Query("SELECT CL FROM ranking WHERE S3 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S3ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S3ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS3ES = sizeof($S3ES); $ProbS3ES = $totalS3ES/$totalS3E; $result = mySQL_Query("SELECT CL FROM ranking WHERE S3 = 'Good'") or die(mySQL_error()); $Drow = array(); $S3G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S3G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS3G = sizeof($S3G); echo "Total S3 Good: " . $totalS3G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE S3 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S3GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S3GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS3GE = sizeof($S3GE); $ProbS3GE = $totalS3GE/$totalS3G; $result = mySQL_Query("SELECT CL FROM ranking WHERE S3 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $S3GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S3GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS3GG = sizeof($S3GG); $ProbS3GG = $totalS3GG/$totalS3G; $result = mySQL_Query("SELECT CL FROM ranking WHERE S3 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S3GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S3GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS3GS = sizeof($S3GS); $ProbS3GS = $totalS3GS/$totalS3G; $result = mySQL_Query("SELECT CL FROM ranking WHERE S3 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S3S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S3S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS3S = sizeof($S3S); echo "Total S3 Satisfactory: " . $totalS3S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE S3 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S3SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S3SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS3SE = sizeof($S3SE); $ProbS3SE = $totalS3SE/$totalS3S; $result = mySQL_Query("SELECT CL FROM ranking WHERE S3 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $S3SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S3SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS3SG = sizeof($S3SG); $ProbS3SG = $totalS3SG/$totalS3S; $result = mySQL_Query("SELECT CL FROM ranking WHERE S3 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S3SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S3SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS3SS = sizeof($S3SS); $ProbS3SS = $totalS3SS/$totalS3S; //Entropy of S3 $ProbS3E= $totalS3E/$totalS3; $ProbS3G= $totalS3G/$totalS3; $ProbS3S= $totalS3S/$totalS3; if($ProbS3EE == 0 || $ProbS3EG == 0 || $ProbS3ES == 0) { $EntS3 = 0; } else { $EntS3= $ProbS3E * entropy($ProbS3EE,$ProbS3EG,$ProbS3ES) + $ProbS3G * entropy($ProbS3GE,$ProbS3GG,$ProbS3GS) + $ProbS3S * entropy($ProbS3SE,$ProbS3SG,$ProbS3SS); } echo "<br>"; echo "Entropy of S3 AND CL is: " . $EntS3; echo "<br>"; $result = mySQL_Query("SELECT S4 FROM ranking") or die(mySQL_error()); $Drow = array(); $S4 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S4[$i] = $Drow[0]; $i++; } $totalS4 = sizeof($S4); echo "<br>"; print_r($S4); echo "<br>"; echo "Total S4: " . $totalS4; echo "<br>"; echo "<h2>S4 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE S4 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S4E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S4E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS4E = sizeof($S4E); echo "Total S4 Excellent: " . $totalS4E . "<br>"; $ProbS4E = $totalS4E/$totalS4; $result = mySQL_Query("SELECT CL FROM ranking WHERE S4 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S4EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S4EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS4EE = sizeof($S4EE); $ProbS4EE = $totalS4EE/$totalS4E; $result = mySQL_Query("SELECT CL FROM ranking WHERE S4 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $S4EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S4EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS4EG = sizeof($S4EG); $ProbS4EG = $totalS4EG/$totalS4E; $result = mySQL_Query("SELECT CL FROM ranking WHERE S4 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S4ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S4ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS4ES = sizeof($S4ES); $ProbS4ES = $totalS4ES/$totalS4E; $result = mySQL_Query("SELECT CL FROM ranking WHERE S4 = 'Good'") or die(mySQL_error()); $Drow = array(); $S4G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S4G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS4G = sizeof($S4G); echo "Total S4 Good: " . $totalS4G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE S4 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S4GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S4GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS4GE = sizeof($S4GE); $ProbS4GE = $totalS4GE/$totalS4G; $result = mySQL_Query("SELECT CL FROM ranking WHERE S4 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $S4GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S4GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS4GG = sizeof($S4GG); $ProbS4GG = $totalS4GG/$totalS4G; $result = mySQL_Query("SELECT CL FROM ranking WHERE S4 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S4GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S4GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS4GS = sizeof($S4GS); $ProbS4GS = $totalS4GS/$totalS4G; $result = mySQL_Query("SELECT CL FROM ranking WHERE S4 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S4S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S4S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS4S = sizeof($S4S); echo "Total S4 Satisfactory: " . $totalS4S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE S4 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S4SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S4SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS4SE = sizeof($S4SE); $ProbS4SE = $totalS4SE/$totalS4S; $result = mySQL_Query("SELECT CL FROM ranking WHERE S4 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $S4SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S4SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS4SG = sizeof($S4SG); $ProbS4SG = $totalS4SG/$totalS4S; $result = mySQL_Query("SELECT CL FROM ranking WHERE S4 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S4SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S4SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS4SS = sizeof($S4SS); $ProbS4SS = $totalS4SS/$totalS4S; //Entropy of S4 $ProbS4E= $totalS4E/$totalS4; $ProbS4G= $totalS4G/$totalS4; $ProbS4S= $totalS4S/$totalS4; if($ProbS4EE == 0 || $ProbS4EG == 0 || $ProbS4ES == 0) { $EntS4 = 0; } else { $EntS4= $ProbS4E * entropy($ProbS4EE,$ProbS4EG,$ProbS4ES) + $ProbS4G * entropy($ProbS4GE,$ProbS4GG,$ProbS4GS) + $ProbS4S * entropy($ProbS4SE,$ProbS4SG,$ProbS4SS); } echo "<br>"; echo "Entropy of S4 AND CL is: " . $EntS4; echo "<br>"; $result = mySQL_Query("SELECT S5 FROM ranking") or die(mySQL_error()); $Drow = array(); $S5 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S5[$i] = $Drow[0]; $i++; } $totalS5 = sizeof($S5); echo "<br>"; print_r($S5); echo "<br>"; echo "Total S5: " . $totalS5; echo "<br>"; echo "<h2>S5 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE S5 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S5E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S5E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS5E = sizeof($S5E); echo "Total S5 Excellent: " . $totalS5E . "<br>"; $ProbS5E = $totalS5E/$totalS5; $result = mySQL_Query("SELECT CL FROM ranking WHERE S5 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S5EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S5EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS5EE = sizeof($S5EE); $ProbS5EE = $totalS5EE/$totalS5E; $result = mySQL_Query("SELECT CL FROM ranking WHERE S5 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $S5EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S5EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS5EG = sizeof($S5EG); $ProbS5EG = $totalS5EG/$totalS5E; $result = mySQL_Query("SELECT CL FROM ranking WHERE S5 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S5ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S5ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS5ES = sizeof($S5ES); $ProbS5ES = $totalS5ES/$totalS5E; $result = mySQL_Query("SELECT CL FROM ranking WHERE S5 = 'Good'") or die(mySQL_error()); $Drow = array(); $S5G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S5G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS5G = sizeof($S5G); echo "Total S5 Good: " . $totalS5G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE S5 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S5GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S5GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS5GE = sizeof($S5GE); $ProbS5GE = $totalS5GE/$totalS5G; $result = mySQL_Query("SELECT CL FROM ranking WHERE S5 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $S5GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S5GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS5GG = sizeof($S5GG); $ProbS5GG = $totalS5GG/$totalS5G; $result = mySQL_Query("SELECT CL FROM ranking WHERE S5 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S5GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S5GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS5GS = sizeof($S5GS); $ProbS5GS = $totalS5GS/$totalS5G; $result = mySQL_Query("SELECT CL FROM ranking WHERE S5 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S5S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S5S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS5S = sizeof($S5S); echo "Total S5 Satisfactory: " . $totalS5S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE S5 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $S5SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S5SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS5SE = sizeof($S5SE); $ProbS5SE = $totalS5SE/$totalS5S; $result = mySQL_Query("SELECT CL FROM ranking WHERE S5 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $S5SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S5SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS5SG = sizeof($S5SG); $ProbS5SG = $totalS5SG/$totalS5S; $result = mySQL_Query("SELECT CL FROM ranking WHERE S5 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $S5SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $S5SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalS5SS = sizeof($S5SS); $ProbS5SS = $totalS5SS/$totalS5S; //Entropy of S5 $ProbS5E= $totalS5E/$totalS5; $ProbS5G= $totalS5G/$totalS5; $ProbS5S= $totalS5S/$totalS5; if($ProbS5EE == 0 || $ProbS5EG == 0 || $ProbS5ES == 0) { $EntS5 = 0; } else { $EntS5= $ProbS5E * entropy($ProbS5EE,$ProbS5EG,$ProbS5ES) + $ProbS5G * entropy($ProbS5GE,$ProbS5GG,$ProbS5GS) + $ProbS5S * entropy($ProbS5SE,$ProbS5SG,$ProbS5SS); } echo "<br>"; echo "Entropy of S5 AND CL is: " . $EntS5; echo "<br>"; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Finance And Facilities !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// $result = mySQL_Query("SELECT F1 FROM ranking") or die(mySQL_error()); $Drow = array(); $F1 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F1[$i] = $Drow[0]; $i++; } $totalF1 = sizeof($F1); echo "<br>"; print_r($F1); echo "<br>"; echo "Total F1: " . $totalF1; echo "<br>"; echo "<h2>F1 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE F1 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F1E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F1E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF1E = sizeof($F1E); echo "Total F1 Excellent: " . $totalF1E . "<br>"; $ProbF1E = $totalF1E/$totalF1; $result = mySQL_Query("SELECT CL FROM ranking WHERE F1 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F1EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F1EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF1EE = sizeof($F1EE); $ProbF1EE = $totalF1EE/$totalF1E; $result = mySQL_Query("SELECT CL FROM ranking WHERE F1 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $F1EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F1EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF1EG = sizeof($F1EG); $ProbF1EG = $totalF1EG/$totalF1E; $result = mySQL_Query("SELECT CL FROM ranking WHERE F1 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F1ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F1ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF1ES = sizeof($F1ES); $ProbF1ES = $totalF1ES/$totalF1E; $result = mySQL_Query("SELECT CL FROM ranking WHERE F1 = 'Good'") or die(mySQL_error()); $Drow = array(); $F1G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F1G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF1G = sizeof($F1G); echo "Total F1 Good: " . $totalF1G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE F1 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F1GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F1GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF1GE = sizeof($F1GE); $ProbF1GE = $totalF1GE/$totalF1G; $result = mySQL_Query("SELECT CL FROM ranking WHERE F1 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $F1GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F1GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF1GG = sizeof($F1GG); $ProbF1GG = $totalF1GG/$totalF1G; $result = mySQL_Query("SELECT CL FROM ranking WHERE F1 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F1GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F1GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF1GS = sizeof($F1GS); $ProbF1GS = $totalF1GS/$totalF1G; $result = mySQL_Query("SELECT CL FROM ranking WHERE F1 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F1S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F1S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF1S = sizeof($F1S); echo "Total F1 Satisfactory: " . $totalF1S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE F1 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F1SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F1SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF1SE = sizeof($F1SE); $ProbF1SE = $totalF1SE/$totalF1S; $result = mySQL_Query("SELECT CL FROM ranking WHERE F1 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $F1SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F1SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF1SG = sizeof($F1SG); $ProbF1SG = $totalF1SG/$totalF1S; $result = mySQL_Query("SELECT CL FROM ranking WHERE F1 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F1SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F1SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF1SS = sizeof($F1SS); $ProbF1SS = $totalF1SS/$totalF1S; //Entropy of F1 $ProbF1E= $totalF1E/$totalF1; $ProbF1G= $totalF1G/$totalF1; $ProbF1S= $totalF1S/$totalF1; if($ProbF1EE == 0 || $ProbF1EG == 0 || $ProbF1ES == 0) { $EntF1 = 0; } else { $EntF1= $ProbF1E * entropy($ProbF1EE,$ProbF1EG,$ProbF1ES) + $ProbF1G * entropy($ProbF1GE,$ProbF1GG,$ProbF1GS) + $ProbF1S * entropy($ProbF1SE,$ProbF1SG,$ProbF1SS); } echo "<br>"; echo "Entropy of F1 AND CL is: " . $EntF1; echo "<br>"; $result = mySQL_Query("SELECT F2 FROM ranking") or die(mySQL_error()); $Drow = array(); $F2 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F2[$i] = $Drow[0]; $i++; } $totalF2 = sizeof($F2); echo "<br>"; print_r($F2); echo "<br>"; echo "Total F2: " . $totalF2; echo "<br>"; echo "<h2>F2 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE F2 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F2E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F2E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF2E = sizeof($F2E); echo "Total F2 Excellent: " . $totalF2E . "<br>"; $ProbF2E = $totalF2E/$totalF2; $result = mySQL_Query("SELECT CL FROM ranking WHERE F2 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F2EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F2EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF2EE = sizeof($F2EE); $ProbF2EE = $totalF2EE/$totalF2E; $result = mySQL_Query("SELECT CL FROM ranking WHERE F2 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $F2EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F2EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF2EG = sizeof($F2EG); $ProbF2EG = $totalF2EG/$totalF2E; $result = mySQL_Query("SELECT CL FROM ranking WHERE F2 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F2ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F2ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF2ES = sizeof($F2ES); $ProbF2ES = $totalF2ES/$totalF2E; $result = mySQL_Query("SELECT CL FROM ranking WHERE F2 = 'Good'") or die(mySQL_error()); $Drow = array(); $F2G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F2G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF2G = sizeof($F2G); echo "Total F2 Good: " . $totalF2G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE F2 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F2GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F2GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF2GE = sizeof($F2GE); $ProbF2GE = $totalF2GE/$totalF2G; $result = mySQL_Query("SELECT CL FROM ranking WHERE F2 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $F2GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F2GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF2GG = sizeof($F2GG); $ProbF2GG = $totalF2GG/$totalF2G; $result = mySQL_Query("SELECT CL FROM ranking WHERE F2 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F2GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F2GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF2GS = sizeof($F2GS); $ProbF2GS = $totalF2GS/$totalF2G; $result = mySQL_Query("SELECT CL FROM ranking WHERE F2 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F2S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F2S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF2S = sizeof($F2S); echo "Total F2 Satisfactory: " . $totalF2S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE F2 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F2SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F2SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF2SE = sizeof($F2SE); $ProbF2SE = $totalF2SE/$totalF2S; $result = mySQL_Query("SELECT CL FROM ranking WHERE F2 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $F2SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F2SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF2SG = sizeof($F2SG); $ProbF2SG = $totalF2SG/$totalF2S; $result = mySQL_Query("SELECT CL FROM ranking WHERE F2 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F2SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F2SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF2SS = sizeof($F2SS); $ProbF2SS = $totalF2SS/$totalF2S; //Entropy of F2 $ProbF2E= $totalF2E/$totalF2; $ProbF2G= $totalF2G/$totalF2; $ProbF2S= $totalF2S/$totalF2; if($ProbF2EE == 0 || $ProbF2EG == 0 || $ProbF2ES == 0) { $EntF2 = 0; } else { $EntF2= $ProbF2E * entropy($ProbF2EE,$ProbF2EG,$ProbF2ES) + $ProbF2G * entropy($ProbF2GE,$ProbF2GG,$ProbF2GS) + $ProbF2S * entropy($ProbF2SE,$ProbF2SG,$ProbF2SS); } echo "<br>"; echo "Entropy of F2 AND CL is: " . $EntF2; echo "<br>"; $result = mySQL_Query("SELECT F3 FROM ranking") or die(mySQL_error()); $Drow = array(); $F3 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F3[$i] = $Drow[0]; $i++; } $totalF3 = sizeof($F3); echo "<br>"; print_r($F3); echo "<br>"; echo "Total F3: " . $totalF3; echo "<br>"; echo "<h2>F3 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE F3 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F3E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F3E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF3E = sizeof($F3E); echo "Total F3 Excellent: " . $totalF3E . "<br>"; $ProbF3E = $totalF3E/$totalF3; $result = mySQL_Query("SELECT CL FROM ranking WHERE F3 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F3EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F3EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF3EE = sizeof($F3EE); $ProbF3EE = $totalF3EE/$totalF3E; $result = mySQL_Query("SELECT CL FROM ranking WHERE F3 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $F3EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F3EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF3EG = sizeof($F3EG); $ProbF3EG = $totalF3EG/$totalF3E; $result = mySQL_Query("SELECT CL FROM ranking WHERE F3 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F3ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F3ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF3ES = sizeof($F3ES); $ProbF3ES = $totalF3ES/$totalF3E; $result = mySQL_Query("SELECT CL FROM ranking WHERE F3 = 'Good'") or die(mySQL_error()); $Drow = array(); $F3G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F3G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF3G = sizeof($F3G); echo "Total F3 Good: " . $totalF3G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE F3 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F3GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F3GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF3GE = sizeof($F3GE); $ProbF3GE = $totalF3GE/$totalF3G; $result = mySQL_Query("SELECT CL FROM ranking WHERE F3 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $F3GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F3GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF3GG = sizeof($F3GG); $ProbF3GG = $totalF3GG/$totalF3G; $result = mySQL_Query("SELECT CL FROM ranking WHERE F3 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F3GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F3GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF3GS = sizeof($F3GS); $ProbF3GS = $totalF3GS/$totalF3G; $result = mySQL_Query("SELECT CL FROM ranking WHERE F3 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F3S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F3S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF3S = sizeof($F3S); echo "Total F3 Satisfactory: " . $totalF3S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE F3 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F3SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F3SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF3SE = sizeof($F3SE); $ProbF3SE = $totalF3SE/$totalF3S; $result = mySQL_Query("SELECT CL FROM ranking WHERE F3 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $F3SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F3SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF3SG = sizeof($F3SG); $ProbF3SG = $totalF3SG/$totalF3S; $result = mySQL_Query("SELECT CL FROM ranking WHERE F3 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F3SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F3SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF3SS = sizeof($F3SS); $ProbF3SS = $totalF3SS/$totalF3S; //Entropy of F3 $ProbF3E= $totalF3E/$totalF3; $ProbF3G= $totalF3G/$totalF3; $ProbF3S= $totalF3S/$totalF3; if($ProbF3EE == 0 || $ProbF3EG == 0 || $ProbF3ES == 0) { $EntF3 = 0; } else { $EntF3= $ProbF3E * entropy($ProbF3EE,$ProbF3EG,$ProbF3ES) + $ProbF3G * entropy($ProbF3GE,$ProbF3GG,$ProbF3GS) + $ProbF3S * entropy($ProbF3SE,$ProbF3SG,$ProbF3SS); } echo "<br>"; echo "Entropy of F3 AND CL is: " . $EntF3; echo "<br>"; $result = mySQL_Query("SELECT F4 FROM ranking") or die(mySQL_error()); $Drow = array(); $F4 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F4[$i] = $Drow[0]; $i++; } $totalF4 = sizeof($F4); echo "<br>"; print_r($F4); echo "<br>"; echo "Total F4: " . $totalF4; echo "<br>"; echo "<h2>F4 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE F4 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F4E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F4E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF4E = sizeof($F4E); echo "Total F4 Excellent: " . $totalF4E . "<br>"; $ProbF4E = $totalF4E/$totalF4; $result = mySQL_Query("SELECT CL FROM ranking WHERE F4 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F4EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F4EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF4EE = sizeof($F4EE); $ProbF4EE = $totalF4EE/$totalF4E; $result = mySQL_Query("SELECT CL FROM ranking WHERE F4 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $F4EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F4EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF4EG = sizeof($F4EG); $ProbF4EG = $totalF4EG/$totalF4E; $result = mySQL_Query("SELECT CL FROM ranking WHERE F4 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F4ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F4ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF4ES = sizeof($F4ES); $ProbF4ES = $totalF4ES/$totalF4E; $result = mySQL_Query("SELECT CL FROM ranking WHERE F4 = 'Good'") or die(mySQL_error()); $Drow = array(); $F4G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F4G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF4G = sizeof($F4G); echo "Total F4 Good: " . $totalF4G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE F4 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F4GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F4GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF4GE = sizeof($F4GE); $ProbF4GE = $totalF4GE/$totalF4G; $result = mySQL_Query("SELECT CL FROM ranking WHERE F4 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $F4GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F4GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF4GG = sizeof($F4GG); $ProbF4GG = $totalF4GG/$totalF4G; $result = mySQL_Query("SELECT CL FROM ranking WHERE F4 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F4GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F4GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF4GS = sizeof($F4GS); $ProbF4GS = $totalF4GS/$totalF4G; $result = mySQL_Query("SELECT CL FROM ranking WHERE F4 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F4S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F4S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF4S = sizeof($F4S); echo "Total F4 Satisfactory: " . $totalF4S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE F4 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F4SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F4SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF4SE = sizeof($F4SE); $ProbF4SE = $totalF4SE/$totalF4S; $result = mySQL_Query("SELECT CL FROM ranking WHERE F4 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $F4SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F4SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF4SG = sizeof($F4SG); $ProbF4SG = $totalF4SG/$totalF4S; $result = mySQL_Query("SELECT CL FROM ranking WHERE F4 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F4SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F4SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF4SS = sizeof($F4SS); $ProbF4SS = $totalF4SS/$totalF4S; //Entropy of F4 $ProbF4E= $totalF4E/$totalF4; $ProbF4G= $totalF4G/$totalF4; $ProbF4S= $totalF4S/$totalF4; if($ProbF4EE == 0 || $ProbF4EG == 0 || $ProbF4ES == 0) { $EntF4 = 0; } else { $EntF4= $ProbF4E * entropy($ProbF4EE,$ProbF4EG,$ProbF4ES) + $ProbF4G * entropy($ProbF4GE,$ProbF4GG,$ProbF4GS) + $ProbF4S * entropy($ProbF4SE,$ProbF4SG,$ProbF4SS); } echo "<br>"; echo "Entropy of F4 AND CL is: " . $EntF4; echo "<br>"; $result = mySQL_Query("SELECT F5 FROM ranking") or die(mySQL_error()); $Drow = array(); $F5 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F5[$i] = $Drow[0]; $i++; } $totalF5 = sizeof($F5); echo "<br>"; print_r($F5); echo "<br>"; echo "Total F5: " . $totalF5; echo "<br>"; echo "<h2>F5 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE F5 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F5E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F5E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF5E = sizeof($F5E); echo "Total F5 Excellent: " . $totalF5E . "<br>"; $ProbF5E = $totalF5E/$totalF5; $result = mySQL_Query("SELECT CL FROM ranking WHERE F5 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F5EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F5EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF5EE = sizeof($F5EE); $ProbF5EE = $totalF5EE/$totalF5E; $result = mySQL_Query("SELECT CL FROM ranking WHERE F5 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $F5EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F5EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF5EG = sizeof($F5EG); $ProbF5EG = $totalF5EG/$totalF5E; $result = mySQL_Query("SELECT CL FROM ranking WHERE F5 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F5ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F5ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF5ES = sizeof($F5ES); $ProbF5ES = $totalF5ES/$totalF5E; $result = mySQL_Query("SELECT CL FROM ranking WHERE F5 = 'Good'") or die(mySQL_error()); $Drow = array(); $F5G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F5G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF5G = sizeof($F5G); echo "Total F5 Good: " . $totalF5G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE F5 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F5GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F5GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF5GE = sizeof($F5GE); $ProbF5GE = $totalF5GE/$totalF5G; $result = mySQL_Query("SELECT CL FROM ranking WHERE F5 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $F5GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F5GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF5GG = sizeof($F5GG); $ProbF5GG = $totalF5GG/$totalF5G; $result = mySQL_Query("SELECT CL FROM ranking WHERE F5 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F5GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F5GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF5GS = sizeof($F5GS); $ProbF5GS = $totalF5GS/$totalF5G; $result = mySQL_Query("SELECT CL FROM ranking WHERE F5 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F5S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F5S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF5S = sizeof($F5S); echo "Total F5 Satisfactory: " . $totalF5S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE F5 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F5SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F5SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF5SE = sizeof($F5SE); $ProbF5SE = $totalF5SE/$totalF5S; $result = mySQL_Query("SELECT CL FROM ranking WHERE F5 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $F5SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F5SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF5SG = sizeof($F5SG); $ProbF5SG = $totalF5SG/$totalF5S; $result = mySQL_Query("SELECT CL FROM ranking WHERE F5 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F5SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F5SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF5SS = sizeof($F5SS); $ProbF5SS = $totalF5SS/$totalF5S; //Entropy of F5 $ProbF5E= $totalF5E/$totalF5; $ProbF5G= $totalF5G/$totalF5; $ProbF5S= $totalF5S/$totalF5; if($ProbF5EE == 0 || $ProbF5EG == 0 || $ProbF5ES == 0) { $EntF5 = 0; } else { $EntF5= $ProbF5E * entropy($ProbF5EE,$ProbF5EG,$ProbF5ES) + $ProbF5G * entropy($ProbF5GE,$ProbF5GG,$ProbF5GS) + $ProbF5S * entropy($ProbF5SE,$ProbF5SG,$ProbF5SS); } echo "<br>"; echo "Entropy of F5 AND CL is: " . $EntF5; echo "<br>"; $result = mySQL_Query("SELECT F6 FROM ranking") or die(mySQL_error()); $Drow = array(); $F6 = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F6[$i] = $Drow[0]; $i++; } $totalF6 = sizeof($F6); echo "<br>"; print_r($F6); echo "<br>"; echo "Total F6: " . $totalF6; echo "<br>"; echo "<h2>F6 Prob!!!</h2> <br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE F6 = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F6E = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F6E[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF6E = sizeof($F6E); echo "Total F6 Excellent: " . $totalF6E . "<br>"; $ProbF6E = $totalF6E/$totalF6; $result = mySQL_Query("SELECT CL FROM ranking WHERE F6 = 'Excellent' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F6EE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F6EE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF6EE = sizeof($F6EE); $ProbF6EE = $totalF6EE/$totalF6E; $result = mySQL_Query("SELECT CL FROM ranking WHERE F6 = 'Excellent' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $F6EG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F6EG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF6EG = sizeof($F6EG); $ProbF6EG = $totalF6EG/$totalF6E; $result = mySQL_Query("SELECT CL FROM ranking WHERE F6 = 'Excellent' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F6ES = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F6ES[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF6ES = sizeof($F6ES); $ProbF6ES = $totalF6ES/$totalF6E; $result = mySQL_Query("SELECT CL FROM ranking WHERE F6 = 'Good'") or die(mySQL_error()); $Drow = array(); $F6G = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F6G[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF6G = sizeof($F6G); echo "Total F6 Good: " . $totalF6G . "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE F6 = 'Good' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F6GE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F6GE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF6GE = sizeof($F6GE); $ProbF6GE = $totalF6GE/$totalF6G; $result = mySQL_Query("SELECT CL FROM ranking WHERE F6 = 'Good' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $F6GG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F6GG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF6GG = sizeof($F6GG); $ProbF6GG = $totalF6GG/$totalF6G; $result = mySQL_Query("SELECT CL FROM ranking WHERE F6 = 'Good' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F6GS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F6GS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF6GS = sizeof($F6GS); $ProbF6GS = $totalF6GS/$totalF6G; $result = mySQL_Query("SELECT CL FROM ranking WHERE F6 = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F6S = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F6S[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF6S = sizeof($F6S); echo "Total F6 Satisfactory: " . $totalF6S . "<br>"; echo "<br>"; $result = mySQL_Query("SELECT CL FROM ranking WHERE F6 = 'Satisfactory' AND CL = 'Excellent'") or die(mySQL_error()); $Drow = array(); $F6SE = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F6SE[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF6SE = sizeof($F6SE); $ProbF6SE = $totalF6SE/$totalF6S; $result = mySQL_Query("SELECT CL FROM ranking WHERE F6 = 'Satisfactory' AND CL = 'Good'") or die(mySQL_error()); $Drow = array(); $F6SG = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F6SG[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF6SG = sizeof($F6SG); $ProbF6SG = $totalF6SG/$totalF6S; $result = mySQL_Query("SELECT CL FROM ranking WHERE F6 = 'Satisfactory' AND CL = 'Satisfactory'") or die(mySQL_error()); $Drow = array(); $F6SS = array(); $i= 0; while($Drow = mySQL_fetch_array($result)) { $F6SS[$i] = $Drow[0]; $i++; } echo "<br>"; $totalF6SS = sizeof($F6SS); $ProbF6SS = $totalF6SS/$totalF6S; //Entropy of F6 $ProbF6E= $totalF6E/$totalF6; $ProbF6G= $totalF6G/$totalF6; $ProbF6S= $totalF6S/$totalF6; if($ProbF6EE == 0 || $ProbF6EG == 0 || $ProbF6ES == 0) { $EntF6 = 0; } else { $EntF6= $ProbF6E * entropy($ProbF6EE,$ProbF6EG,$ProbF6ES) + $ProbF6G * entropy($ProbF6GE,$ProbF6GG,$ProbF6GS) + $ProbF6S * entropy($ProbF6SE,$ProbF6SG,$ProbF6SS); } echo "<br>"; echo "Entropy of F6 AND CL is: " . $EntF6; echo "<br>"; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Information Gain !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// $gain = array(); $gain[0] = $totalEnt - $EntR1; $gain[1] = $totalEnt - $EntR2; $gain[2] = $totalEnt - $EntR3; $gain[3] = $totalEnt - $EntR4; $gain[4] = $totalEnt - $EntR5; $gain[5] = $totalEnt - $EntR6; $gain[6] = $totalEnt - $EntR7; $gain[7] = $totalEnt - $EntR8; $gain[8] = $totalEnt - $EntR9; $gain[9] = $totalEnt - $EntR10; $gain[10] = $totalEnt - $EntR11; $gain[11] = $totalEnt - $EntR12; $gain[12] = $totalEnt - $EntR13; $gain[13] = $totalEnt - $EntR14; $gain[14] = $totalEnt - $EntI1; $gain[15] = $totalEnt - $EntI2; $gain[16] = $totalEnt - $EntI3; $gain[17] = $totalEnt - $EntI4; $gain[18] = $totalEnt - $EntI5; $gain[19] = $totalEnt - $EntT1; $gain[20] = $totalEnt - $EntT2; $gain[21] = $totalEnt - $EntT3; $gain[22] = $totalEnt - $EntT4; $gain[23] = $totalEnt - $EntT5; $gain[24] = $totalEnt - $EntS1; $gain[25] = $totalEnt - $EntS2; $gain[26] = $totalEnt - $EntS3; $gain[27] = $totalEnt - $EntS4; $gain[28] = $totalEnt - $EntS5; $gain[29] = $totalEnt - $EntF1; $gain[30] = $totalEnt - $EntF2; $gain[31] = $totalEnt - $EntF3; $gain[32] = $totalEnt - $EntF4; $gain[33] = $totalEnt - $EntF5; $gain[34] = $totalEnt - $EntF6; $maxGain = 0; $maxIndex = 0; for($x=0;$x<35;$x++) { if(isset($gain[$x])) { if($gain[$x]>$maxGain) { $maxGain = $gain[$x]; $maxIndex = $x; } } } switch ($maxIndex) { case 0: echo "R1"; break; case 1: echo "R2"; break; case 2: echo "R3"; break; case 3: echo "R4"; break; case 4: echo "R5"; break; case 5: echo "R6"; break; case 6: echo "R7"; break; case 7: echo "R8"; break; case 8: echo "R9"; break; case 9: echo "R10"; break; case 10: echo "R11"; break; case 11: echo "R12"; break; case 12: echo "R13"; break; case 13: echo "R14"; break; case 14: echo "I1"; break; case 15: echo "I2"; break; case 16: echo "I3"; break; case 17: echo "I4"; break; case 18: echo "I5"; break; case 19: echo "T1"; break; case 20: echo "T2"; break; case 21: echo "T3"; break; case 22: echo "T4"; break; case 23: echo "T5"; break; case 24: echo "S1"; break; case 25: echo "S2"; break; case 26: echo "S3"; break; case 27: echo "S4"; break; case 28: echo "S5"; break; case 29: echo "F1"; break; case 30: echo "F2"; break; case 31: echo "F3"; break; case 32: echo "F4"; break; case 33: echo "F5"; break; case 34: echo "F6"; break; } } decision(); ?>
true
b3f7986905cd8049d505027c9f6709b14e891ce9
PHP
devskyfly/php56
/src/core/Cli.php
UTF-8
1,497
3
3
[]
no_license
<?php namespace devskyfly\php56\core; use devskyfly\php56\types\Vrbl; class Cli { /** * Set title to current process * @param string $title * @return boolean */ public static function setProcessTitle($title) { return cli_set_process_title($title); } /** * Return current process title * @return string */ public static function getProcessTitle() { return cli_get_process_title(); } /** * Return params array passed to script * @param string $keys_list [a-z|A-Z|0-9] "ij:k::" - "i" without value, "j" require value, "k" does not require value * @param array $dbl_keys_list [a-z|A-Z|0-9] ["i", "j:", "k::"] - "i" without value, "j" require value, "k" does not require value * @return array | false */ public static function getParams($keys_list, $dbl_keys_list="") { if (Vrbl::isEmpty($dbl_keys_list)) { return getopt($keys_list); } else { return getopt($keys_list, $dbl_keys_list); } } /** * Return number of arguments passed to script * @return int */ public static function getArgumentsNmb() { return $argc; } /** * Return arguments passed to script in array * * Zero index of array is script name. Other indexes are arguments passed to script * @return array */ public static function getArguments() { return $argv; } }
true
1ef3984aa307e17ffe355999acc15f3089e9610a
PHP
oxidmod/typed-collections
/src/TypeCheckerFactory.php
UTF-8
1,668
2.765625
3
[ "MIT" ]
permissive
<?php declare(strict_types=1); namespace Oxidmod\TypedCollections; class TypeCheckerFactory { private static array $checkers = []; public static function arrayChecker(): \Closure { return self::$checkers['array'] = self::$checkers['array'] ?? \Closure::fromCallable( fn($value) => is_array($value) ); } public static function booleanChecker(): \Closure { return self::$checkers['boolean'] = self::$checkers['boolean'] ?? \Closure::fromCallable( fn($value) => is_bool($value) ); } public static function floatChecker(): \Closure { return self::$checkers['float'] = self::$checkers['float'] ?? \Closure::fromCallable( fn($value) => is_float($value) ); } public static function integerChecker(): \Closure { return self::$checkers['integer'] = self::$checkers['integer'] ?? \Closure::fromCallable( fn($value) => is_int($value) ); } public static function objectChecker(): \Closure { return self::$checkers['object'] = self::$checkers['object'] ?? \Closure::fromCallable( fn($value) => is_object($value) ); } public static function stringChecker(): \Closure { return self::$checkers['string'] = self::$checkers['string'] ?? \Closure::fromCallable( fn($value) => is_string($value) ); } public static function customTypeChecker(string $type): \Closure { return self::$checkers[$type] = self::$checkers[$type] ?? \Closure::fromCallable( fn($value) => $value instanceof $type ); } }
true
5ea67d1ea7d2c0afed0172837dd7ff6abf830bbb
PHP
srigi/webloader-require-filter
/src/diacronos/Lilo/FsUtils.php
UTF-8
8,108
2.859375
3
[ "MIT" ]
permissive
<?php /** * Lilo - A file concatenation tool for PHP inspired by Sprockets and based in Snockets * * @author Rafael García <rafaelgarcia@profesionaldiacronos.com> * @copyright 2012 Rafael García * @link http://lilo.profesionaldiacronos.com * @license http://lilo.profesionaldiacronos.com/license * @version 1.0.0 * @package Lilo * * MIT LICENSE * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE 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. */ namespace diacronos\Lilo; /** * FsUtils * * This class groups general utilities related to working with the filesystem. * His interface has two parts, the first consists of all static methods: * * equals( string $file1, string $file2 ) * isExplicit( string $relName ) * extension( string $filePath ) * join( string $path1, string $path2... ) * normalize( string $relPath ) * getEntries( string $dir, bool $quitDots ) * * and the last, has the following instance methods: * * preppendSourcePath( string $source ) * appendSourcePath( string $source ) * addWorkExtension( string $extension ) * getWorkExtensions( ) * expand( string $relPath ) * tryExtensionsForExpand( string $relPath, array $extensions ) * stripExtension( string $filePath, array $extensions ) * * This class must be internal * * @package Lilo * @author Rafael García * @since 1.0.0 */ class FsUtils { /** * @var string */ const EXPLICIT_PATH = '/^\/|:/'; /** * @var array */ private $_sources = array(); /** * @var array */ private $_extensions = array(); /** * Preppend a load path. * Directories at the beginning of the load path have precedence over subsequent directories. * Theese paths are used for expand relative paths to absolute paths. * * @access public * @param string $path * @return void */ public function preppendPath($path) { $this->_addPath($path, true); } /** * Append a load path. * Directories at the beginning of the load path have precedence over subsequent directories. * Theese paths are used for expand relative paths to absolute paths. * * @access public * @param string $path * @return void */ public function appendPath($source) { $this->_addPath($source, false); } /** * @access private * @param $source * @param bool $prepend `true` for prepend * @internal param string $path */ private function _addPath($source, $prepend = false) { $source = self::normalize($source); $pos = array_search($source, $this->_sources); if ($pos !== false) { array_splice($this->_sources, $pos, 1); } if ($prepend) { array_unshift($this->_sources, $source); } else { array_push($this->_sources, $source); } } /** * @access public * @param string $extension * @return void */ public function addWorkExtension($extension) { if (($pos = array_search($extension, $this->_extensions)) > -1) { array_splice($this->_extensions, $pos, 1); } array_unshift($this->_extensions, $extension); } /** * Returns a array with all extensions registered for work. * @access public * @return array */ public function getWorkExtensions() { return $this->_extensions; } /** * Expand a relative path to an absolute path. * Find matches in every path load and returns the first matched. * * @access public * @param string $relPath * @return string * @throws \Exception if a $relPath doesn't exists */ public function expand($relPath) { if (preg_match(self::EXPLICIT_PATH, $relPath) > 0) { return $relPath; } foreach ($this->_sources as $source) { if (preg_match(self::EXPLICIT_PATH, $source) > 0) { $path = self::join($source, $relPath); if (file_exists($path)) { return $path; } } $path = self::join(getcwd(), $source, $relPath); if (file_exists($path)) { return $path; } } throw new \Exception("Path {$relPath} can't be expanded to an absolute path"); } /** * Expand a relative path without extension to an absolute path. * Find matches in every path load and returns the first matched. * * @access public * @param string $relPath * @return string * @throws \Exception if a $relPath doesn't exists * @internal param array $extensions extensions to try */ public function tryExtensionsForExpand($relPath) { foreach ($this->getWorkExtensions() as $ext) { try { return $this->expand($relPath . '.' . $ext); } catch (\Exception $e) { // doesn't nothing } } return $this->expand($relPath); } /** * @access public * @param string $filePath * @return string */ public function stripExtension($filePath) { $ext = self::extension($filePath); $chars = strlen($ext); if ($chars == 0 || !in_array($ext, $this->getWorkExtensions())) { return $filePath; } return substr($filePath, 0, ++$chars * (-1)); } /** * Compare two paths. Return `true` is both references the same resource. * @static * @access public * @param string $file1 * @param string $file2 * @return bool */ static public function equals($file1, $file2) { return (strcmp(realpath($file1), realpath($file2)) == 0); } /** * Return `true` if a path is absolute. * @static * @access public * @param string $relName * @return bool */ static public function isExplicit($relName) { return (preg_match(self::EXPLICIT_PATH, $relName) > 0); } /** * Return the extension from a filename * @static * @access public * @param string $filePath * @return string */ static public function extension($filePath) { return pathinfo($filePath, PATHINFO_EXTENSION); } /** * Join segments from a path. * @static * @access public * @params string * @return string */ static public function join() { return implode(DIRECTORY_SEPARATOR, func_get_args()); } /** * Strip the superfluous segment (.. , .) of a path. * @static * @access public * @param string $relPath * @return string */ static public function normalize($relPath) { $finalSegments = array(); $isAbsolute = self::isExplicit($relPath); $pathSegments = preg_split('@\\/@', $relPath); for ($i = 0, $len = count($pathSegments); $i < $len; $i++) { $segment = trim($pathSegments[$i]); if ($segment === '' || $segment === '.') { continue; } else if ($segment === '..') { $last = end($finalSegments); if ($last !== '..' && $last != '') { // intentionally != array_pop($finalSegments); continue; } } array_push($finalSegments, $segment); } $joinedPath = call_user_func_array('self::join', $finalSegments); $finalPath = ($isAbsolute && $pathSegments[0] === '') ? DIRECTORY_SEPARATOR . $joinedPath : $joinedPath; return $finalPath; } /** * Get all entries from a dir, ordered alphabetically. * @static * @access public * @param string $dir dependency identifier * @param bool $quitDots `true` for skips dot dirs * @return array */ static function getEntries($dir, $quitDots = true) { $files = scandir($dir); if ($quitDots) { array_shift($files); array_shift($files); } return $files; } }
true
83f2cffb5b6c30e4d6ee6c123ceb54e7c428de27
PHP
MOUNYA98/Blood-management-system
/updateprofile.php
UTF-8
2,486
2.578125
3
[ "MIT" ]
permissive
<?php $hostname="localhost"; $username="root"; $pwd=""; $db="rdbms"; $conn=mysqli_connect($hostname,$username,$pwd,$db); if(!$conn) { die("error:".mysqli_error()); } ?> <?php require 'core.inc.php'; ?> <?php require 'header.inc.php'; ?> <?php require 'nav.inc.php'; $id=$_SESSION['id']; $sql1="select * from bloodbank where b_id='$id';"; $query1=mysqli_query($conn,$sql1); $row1=mysqli_num_rows($query1); if($row1==1) { while($fetch=mysqli_fetch_assoc($query1)) { $email=$fetch['email']; $name=$fetch['name']; $uname=$fetch['uname']; $ph=$fetch['phone']; $loc=$fetch['location']; $city=$fetch['city']; $state=$fetch['state']; } } ?> <div class="container" style="color:red"> <div class="col-sm-3"></div> <div class="col-sm-6"> <form action="updateprofileser.php" method="post" ><!--class cointainer is used to shrink the elements clss cointainer-fluid is used to stretch the eleents--> <h2 style="color:red">Update details</h2> <div class="form-group"> <label for="name">Name:</label> <input type="text" name="name" class="form-control" id="name" value='<?php echo $name ?>' autofocus required> </div> <div class="form-group"> <label for="name">UserName:</label> <input type="text" name="uname" class="form-control" id="uname" value="<?php echo $uname ?>" autofocus required> </div> <div class="form-group"> <label for="email">Email address:</label> <input type="email" name="email" class="form-control" id="email" value="<?php echo $email ?>" autofocus required> <div class="form-group"> <label for="ph">Phone number:</label> <input type="number" name="ph" class="form-control" id="ph" value="<?php echo $ph ?>" autofocus required> </div> <div class="form-group"> <label for="location">Enter Location:</label> <input type="text" name="location" class="form-control" id="location" value="<?php echo $loc ?>" autofocus required> </div> <div class="form-group"> <label for="city">Enter City:</label> <input type="text" name="city" class="form-control" id="city" value="<?php echo $city ?>" autofocus required> </div> <div class="form-group"> <label for="state">Enter State:</label> <input type="text" name="state" class="form-control" id="state" value="<?php echo $state ?>" autofocus required> </div> <button type="submit" class="btn btn-primary" style="color:red">Submit</button> </form>
true
f23983fe420aa834a40b450c4beef41a5e858ca4
PHP
ana27c/blog_tag
/includes/connexion.inc.php
UTF-8
630
2.71875
3
[]
no_license
<?php include('varco.php'); //parametres de connexion mysql_connect($host, $user, $mdp); mysql_select_db($db); //creation de session session_start(); $connecte = false; //si on a un cookie sid if (isset($_COOKIE['sid'])) { // l'utilisateur est connecté // on recupere son sid, son email // et on passe la variable connecté en VRAI $sid = mysql_real_escape_string($_COOKIE['sid']); $sql = "SELECT email FROM utilisateurs WHERE sid='$sid'"; $req = mysql_query($sql); $infos_util = mysql_fetch_array($req); if ($infos_util) { $mail = $infos_util['email']; $connecte = true; } }
true
76f41dd9af6ee3fae88219228e82e2e0475ca399
PHP
SlayerBirden/datamigration
/src/Hashmap/ArrayHashmap.php
UTF-8
1,459
2.765625
3
[ "MIT" ]
permissive
<?php namespace Maketok\DataMigration\Hashmap; use Maketok\DataMigration\HashmapInterface; class ArrayHashmap implements HashmapInterface { /** * @var string */ private $code; /** * @var array */ private $storage; /** * @param string $code */ public function __construct($code) { $this->code = $code; } /** * {@inheritdoc} */ public function offsetExists($offset) { return isset($this->storage[$offset]); } /** * {@inheritdoc} */ public function offsetGet($offset) { return isset($this->storage[$offset]) ? $this->storage[$offset] : null; } /** * {@inheritdoc} */ public function offsetSet($offset, $value) { $this->storage[$offset] = $value; } /** * {@inheritdoc} */ public function offsetUnset($offset) { $this->storage[$offset] = null; } /** * {@inheritdoc} */ public function load(array $storage = []) { $this->storage = $storage; } /** * {@inheritdoc} */ public function __get($offset) { return $this->offsetGet($offset); } /** * {@inheritdoc} */ public function __set($offset, $value) { $this->offsetSet($offset, $value); } /** * {@inheritdoc} */ public function getCode() { return $this->code; } }
true
efd6c856e4c8d7f7346783f3952279f213663c64
PHP
xat55/spatie
/app/Http/Controllers/Site/SiteController.php
UTF-8
1,321
2.53125
3
[]
no_license
<?php namespace App\Http\Controllers\Site; use Illuminate\Support\Arr; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Repositories\Site\CategoryRepository; /** * Class SiteController * @package App\Http\Controllers\Site */ class SiteController extends Controller { protected $cat_rep; protected $post_rep; protected $single_post_rep; protected $sidebar_rep; protected $template; protected $vars = []; protected $bar; protected $contentBar; /** * SiteController constructor. * @param CategoryRepository $cat_rep */ public function __construct(CategoryRepository $cat_rep) { $this->cat_rep = $cat_rep; } /** * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View */ protected function renderOutput() { $categories = $this->getCategoriesMenu(); $navigation = view(env('THEME').'.parts.navigation')->with('categories', $categories)->render(); $this->vars = Arr::add($this->vars, 'navigation', $navigation); return view($this->template)->with($this->vars); } /** * @return mixed */ protected function getCategoriesMenu() { return $this->cat_rep->get(); } }
true
bc2b40410b650bf494a52e1dde91df8b18c28a27
PHP
franolg/shilengae_web
/private/core/model/User.php
UTF-8
7,625
2.671875
3
[]
no_license
<?php /** * User Model */ class User extends Database { protected function ListAll() { $sql = "SELECT * FROM tableusers WHERE status = 1"; $stmt = $this->c()->query($sql); // getting country list if($stmt->rowCount() > 0) { // checking if the table is not empty return $stmt->fetchAll(); }else { return []; } } public function ListAlljs() { $return_arr = array(); $query = "SELECT * FROM tableusers ORDER BY id"; $result = $this->c()->query($query); while($row = $result->fetch()){ $first_name = urldecode($row['first_name']); $last_name = urldecode($row['last_name']); $email = urldecode($row['email']); $calling_code = urldecode($row['calling_code']); $country = urldecode($row['country']); $stm = '<a href="edit?q='.$row['user_id'].'" class="btn btn-success btn-sm d-block"> <i class="material-icons">edit</i> </a> <a href="?b='.$row['user_id'].'" class="btn btn-danger btn-sm d-block"> <i class="material-icons">block</i> </a> <a href="?q='.$row['user_id'].'" class="btn btn-danger btn-sm d-block"> <i class="material-icons">close</i> </a>'; $user_id = $row['user_id']; $mobile = $row['mobile']; $last_online_at = $row['last_online_at']; $last_logged_in = $row['last_logged_in']; $login_attempt = $row['login_attempt']; $time_spent = $row['time_spent']; $last_seen_ip = $row['last_seen_ip']; $last_device = $row['last_device']; $return_arr[] = array( "id" => $user_id, "fn" => $first_name, "ln" => $last_name, "email" => $email, "calling_code" => $calling_code, "country" => $country, "action" => $stm, "mobile" => $mobile, "last_online_at" => $last_online_at, "last_logged_in" => $last_logged_in, "login_attempt" => $login_attempt, "time_spent" => $time_spent, "last_seen_ip" => $last_seen_ip, "last_device" => $last_device ); } // Encoding array in JSON format return json_encode($return_arr); } protected function Auth($mobile,$code) { $sql = "SELECT * FROM tableusers WHERE mobile = ? AND calling_code = ?"; $stmt = $this->c()->prepare($sql); $stmt->execute([$mobile,$code]); if ($stmt->rowCount() > 0) { return $stmt->fetch(); }else { return []; } } protected function Exist($code,$mobile) { $sql = "SELECT * FROM tableusers WHERE mobile = ? AND calling_code = ? AND status = ?"; $stmt = $this->c()->prepare($sql); $stmt->execute([$mobile,$code,1]); return $stmt->rowCount() == 0 ? false : true; } protected function CheckUsers() { $sql = "SELECT * FROM tableusers WHERE status = 1"; $stmt = $this->c()->query($sql); return $stmt->rowCount() == 0 ? false : true; } protected function IDExist($id) { $sql = "SELECT * FROM tableusers WHERE user_id = ? AND status = ?"; $stmt = $this->c()->prepare($sql); $stmt->execute([$id,1]); return $stmt->rowCount() == 0 ? false : true; } protected function FindEmail($email) { $sql = "SELECT * FROM tableusers WHERE email = ? AND status = ?"; $stmt = $this->c()->prepare($sql); $stmt->execute([urldecode($email),1]); return $stmt->rowCount() == 0 ? false : true; } protected function isEmailBanned($email) { $sql = "SELECT * FROM tableusers WHERE email = ? AND status = ?"; $stmt = $this->c()->prepare($sql); $stmt->execute([urldecode($email),0]); return $stmt->rowCount() == 0 ? false : true; } protected function Add($firstname,$lastname,$mobile,$password,$country,$callingcode,$language,$business,$company) { $userid = uniqid()."/".time(); $timer = time(); $sql = "INSERT INTO tableusers (user_id,first_name,last_name,mobile,password,country,calling_code,language,business,company,joined) VALUES (?,?,?,?,?,?,?,?,?,?,?)"; $stmt = $this->c()->prepare($sql); if($stmt->execute([$userid,$firstname,$lastname,$mobile,$password,$country,$callingcode,$language,$business,$company,$timer])){ return true; }else { return false; } } protected function Edit($id,$firstname,$lastname,$email,$mobile,$country,$state,$city,$gender,$birth,$career,$experience,$salary,$callingcode,$business) { $timer = time(); $sql = "UPDATE tableusers SET first_name = ?,last_name = ?,email = ?,mobile = ?,country = ?,state = ?,city = ?,gender = ?,birth = ?,career = ?,experience = ?,salary = ?,calling_code = ?,business = ?,modified_at = ? WHERE user_id = ?"; $stmt = $this->c()->prepare($sql); if($stmt->execute([$firstname,$lastname,$email,$mobile,$country,$state,$city,$gender,$birth,$career,$experience,$salary,$callingcode,$business,$timer,$id])){ return true; }else { return false; } } protected function Facebook($userid,$firstname,$lastname,$email,$img,$timer) { if(!$this->FindEmail($email)) { $sql = "INSERT INTO tableusers (user_id,first_name,last_name,email,social_profile_image,joined) VALUES (?,?,?,?,?,?)"; $stmt = $this->c()->prepare($sql); if($stmt->execute([$userid,$firstname,$lastname,urldecode($email),$img,$timer])){ return true; }else { return false; } }else { $sql = "UPDATE tableusers SET first_name = ?,last_name = ?,social_profile_image = ?,modified_at = ? WHERE email = ?"; $stmt = $this->c()->prepare($sql); if($stmt->execute([$firstname,$lastname,$img,$timer,urldecode($email)])){ return true; }else { return false; } } } protected function ChangePassword($code,$mobile,$password) { $sql = "UPDATE tableusers SET password = ? WHERE mobile = ? AND calling_code = ?"; $stmt = $this->c()->prepare($sql); if ($stmt->execute([password_hash($password, PASSWORD_BCRYPT),$mobile,$code])) { return true; }else { return false; } } protected function Delete($id) { $sql = "DELETE FROM tableusers WHERE user_id = ?"; $stmt = $this->c()->prepare($sql); if ($stmt->execute([$id])) { return true; }else { return false; } } protected function Ban($id) { $sql = "UPDATE tableusers SET status = ? WHERE user_id = ?"; $stmt = $this->c()->prepare($sql); if ($stmt->execute([0,$id])) { return true; }else { return false; } } protected function show($id,$request) { $sql = "SELECT * FROM tableusers WHERE user_id = ? AND status = ?"; $stmt = $this->c()->prepare($sql); $stmt->execute([$id,1]); $exe = $stmt->fetch(); $result = ""; switch ($request) { case 'id': $result = $exe['user_id']; break; case 'firstname': $result = $exe['first_name']; break; case 'lastname': $result = $exe['last_name']; break; case 'email': $result = $exe['email']; break; case 'mobile': $result = $exe['mobile']; break; case 'code': $result = $exe['calling_code']; break; case 'country': $result = $exe['country']; break; case 'language': $result = $exe['language']; break; case 'business': $result = $exe['business']; break; case 'company': $result = $exe['company']; break; case 'birth': $result = $exe['birth']; break; case 'career': $result = $exe['career']; break; case 'state': $result = $exe['state']; break; case 'city': $result = $exe['city']; break; case 'gender': $result = $exe['gender']; break; case 'experience': $result = $exe['experience']; break; case 'salary': $result = $exe['salary']; break; default: $result = ""; break; } return $result; } }
true
349d4e797dc7cc67bb902fcc40b47ebc9514a6ac
PHP
mkungla/aframe-php
/src/Core/Helpers/ShaderAbstract.php
UTF-8
1,795
2.703125
3
[ "MIT" ]
permissive
<?php /** @formatter:off * ****************************************************************** * Created by Marko Kungla on Jun 25, 2016 - 8:48:28 AM * Contact marko@okramlabs.com * @copyright 2016 Marko Kungla - https://github.com/mkungla * @license The MIT License (MIT) * * @category AframeVR * @package aframe-php * * Lang PHP (php version >= 7) * Encoding UTF-8 * File ShaderAbstract.php * Code format PSR-2 and 12 * @link https://github.com/mkungla/aframe-php * @issues https://github.com/mkungla/aframe-php/issues * ******************************************************************** * Contributors: * @author Marko Kungla <marko@okramlabs.com> * ******************************************************************** * Comments: * @formatter:on */ namespace AframeVR\Core\Helpers; abstract class ShaderAbstract { /** * Get default class vars * * @return array */ protected function getShaderClassDefaultVars() { return get_class_vars(get_class($this)); } /** * removeDefaultDOMAttributes * * @return void */ public function removeDefaultDOMAttributes() { $defaults = $this->getShaderClassDefaultVars(); $vars = get_object_vars($this); foreach ($vars as $name => $value) { $this->removeDOMAttributes($name, $value, $defaults); } } public function getAttributes() { $this->removeDefaultDOMAttributes(); return get_object_vars($this); } private function removeDOMAttributes($name, $value, $defaults) { if ($name === 'shader') return; if (empty($value) || $value === $defaults[$name]) { unset($this->$name); } } }
true
1bfc736399c765ebe187a5686b1b332dbdc2901c
PHP
prabhucomo/asandbox
/plugins/apostropheMysqlSearchPlugin/lib/aMysqlSearch.class.php
UTF-8
14,153
2.765625
3
[ "MIT" ]
permissive
<?php // See aSearchService for an explanation of the public methods // IMPORTANT: to use this to add searchability to additional model classes // you must set up appropriate refclasses and aliases. You can do so at // project level or in your own plugins. See schema.yml in this plugin, // specifically aPageToASearchDocument and aMediaItemToASearchDocument, as well // as the relations added to aPage and aMediaItem class aMysqlSearch extends aSearchService { // We need raw SQL to have any hope of acceptable performance, // you can't insert without array hydration in Doctrine 1. But we // *do* get a way to add a search to a doctrine query in which you // can have unrelated WHERE clauses and joins. Which means that you // don't have to search two different databases and then get stuck // with giant IN queries and awful performance. You're welcome. protected $sql; public function __construct() { } /** * This has to be checked when we really try to use the service * because there is no "after Doctrine is ready" hook from which to call * the constructor */ protected function initSql() { if (!isset($this->sql)) { $this->sql = new aMysql(); } } // Constantly checking the ids of words in the database hurts performance, cache that at least // for this request/invocation protected $wordCache = array(); /** * update(array('item' => $item, 'text' => 'this is my text', 'info' => array(some-serializable-stuff), 'culture' => 'en')) * * You may pass item_id and item_model options instead of item if you don't have a hydrated object. item_model must * be the class name, not the table name */ public function update($options) { $this->initSql(); $info = $this->getDocumentInfo($options); $document_id = $this->getDocumentId($info); $new = false; if (!$document_id) { $this->sql->query('INSERT INTO a_search_document (culture) VALUES (:culture)', $info); $document_id = $this->sql->lastInsertId(); $new = true; } if (isset($options['info'])) { $this->sql->update('a_search_document', $document_id, array('info' => serialize($options['info']))); } else { $this->sql->query('UPDATE a_search_document asd SET asd.info = NULL WHERE asd.id = :document_id', array('id' => $document_id)); } $this->deleteUsages($document_id); if ((!isset($options['texts'])) || (!is_array($options['texts']))) { $options['texts'] = array(array('weight' => 1.0, 'text' => $options['text'])); } $wordWeights = array(); foreach ($options['texts'] as $textInfo) { $weight = $textInfo['weight']; $text = $textInfo['text']; $words = $this->split($text); // Index each word just once per document but increase the weight for subsequent usages. // If we reversed the order here and multiplied by something a little less than one // at each pass we could weight early mentions more heavily foreach ($words as $word) { if (!isset($wordWeights[$word])) { $wordWeights[$word] = $weight; } else { $wordWeights[$word] += $weight; } } } foreach ($wordWeights as $word => $weight) { if (!isset($this->wordCache[$word])) { $wordInfo = $this->sql->queryOne('SELECT * FROM a_search_word asw WHERE text = :text', array('text' => $word)); if (!$wordInfo) { try { $this->sql->query('INSERT INTO a_search_word (text) VALUES (:text)', array('text' => $word)); } catch (Exception $e) { // Duplicate key errors are unfortunately common because MySQL converts // bad UTF8 sequences into shorter keys that wind up redundant. Until I // have a better idea of how to quickly validate UTF8 I need to just skip these continue; } $word_id = $this->sql->lastInsertId(); } else { $word_id = $wordInfo['id']; } $this->wordCache[$word] = $word_id; } } if (count($wordWeights)) { if ($new) { // For the sake of speed, hand-tuned SQL for a bulk insert operation $pdo = $this->sql->getConn(); $sql = 'INSERT INTO a_search_usage (word_id, document_id, weight) VALUES '; $first = true; foreach ($wordWeights as $word => $weight) { if (!$first) { $sql .= ','; } $first = false; $sql .= '(' . $this->wordCache[$word] . ',' . $document_id . ',' . $weight . ')'; } // error_log($sql); $pdo->exec($sql); } else { foreach ($wordWeights as $word => $weight) { $this->sql->insertOrUpdate('a_search_usage', array('word_id' => $this->wordCache[$word], 'document_id' => $document_id, 'weight' => $weight)); } } } // Relate the search document to a Doctrine object via an intermediate table. Do this // last so that if this document is new, nobody else can find it until we're done. This // prevents race conditions and allows us to avoid insertOrUpdate $relationTableName = $info['item_table'] . '_to_a_search_document'; $relatedId = $info['item_table'] . '_id'; $q = "select * from $relationTableName atsd INNER JOIN a_search_document asd ON asd.id = atsd.a_search_document_id WHERE atsd.$relatedId = :item_id "; if (isset($info['culture'])) { $q .= 'AND asd.culture = :culture '; } $relation = $this->sql->queryOne($q, $info); if (!$relation) { $this->sql->query("INSERT INTO $relationTableName ($relatedId, a_search_document_id) VALUES (:item_id, :a_search_document_id)", array('item_id' => $info['item_id'], 'a_search_document_id' => $document_id)); } else { $this->sql->update($relationTableName, $relation['id'], array('a_search_document_id' => $document_id)); } } /** * delete(array('item' => $item)), or item_id and item_model if you don't want to hydrate objects * If you don't specify a culture option, all matching documents are removed regardless of culture */ public function delete($options) { $this->initSql(); $info = $this->getDocumentInfo($options); $info['no-culture-means-all'] = true; $document_ids = $this->getDocumentIds($info); foreach ($document_ids as $document_id) { $this->deleteUsages($document_id); } // Careful, WHERE IN bombs on empty lists. Thanks to Paulo Ribeiro if (count($document_ids)) { $this->sql->query('DELETE FROM a_search_document WHERE id IN :document_ids', array('document_ids' => $document_ids)); } } /** * Add search to a Doctrine query. $q should be a Doctrine query object. * $search is the user's search text (don't pre-clean it for us, we've got it covered). * $options may contain 'culture' * * YOUR QUERY MUST HAVE EXPLICIT addSelect CALLS, OTHERWISE YOU WILL NOT GET RESULTS. * You don't want to hydrate all this extra stuff anyway, just your matching objects. */ public function addSearchToQuery($q, $search, $options = array()) { $alias = $q->getRootAlias(); // Uses refclass to get to the search document $q->innerJoin($alias . '.aSearchDocuments asd'); $q->innerJoin('asd.Usages asu'); // Unicode: letters and spaces only, plus wildcard * $words = $this->split($search, true); $wildcards = array(); $nwords = array(); foreach ($words as $word) { if (preg_match('/^(.*?)\*(.*)$/', $word, $matches)) { // Turn it into a LIKE pattern $wildcards[] = $matches[1] . '%' . $matches[2]; } else { $nwords[] = $word; } } $words = $nwords; $q->innerJoin('asu.Word asw'); $q->addGroupBy('asd.id'); $q->addSelect('sum(asu.weight) + (((datediff(NOW(), asd.published_at) < 31) as integer) * 100) as a_search_score, asd.info as a_search_info'); // Build an OR of the wildcard LIKE clauses and an IN clause for the straightforward matches $clause = ''; $args = array(); if (count($wildcards)) { foreach ($wildcards as $wildcard) { if (strlen($clause)) { $clause .= 'OR '; } $clause .= 'asw.text LIKE ? '; $args[] = $wildcard; } } // Don't crash on an empty IN clause if (count($words)) { if (strlen($clause)) { $clause .= 'OR '; } // We'd put this in the innerJoin call but Doctrine doesn't support automatic // parenthesization of lists anywhere but addWhere, it seems $clause .= 'asw.text IN ?'; $args[] = $words; } if (!strlen($clause)) { // Searches for nothing should not return everything $q->andWhere('0 <> 0'); return $q; } $q->andWhere($clause, $args); if (isset($options['culture'])) { $q->addWhere('asd.culture = ?', $options['culture']); } $q->addHaving('a_search_score > 0'); $q->addOrderBy('a_search_score desc'); return $q; } /** * 1. Replace everything that isn't considered a letter or whitespace by * Unicode with a space. (Otherwise, we get zillions of compound words made when * things like hyphens were removed, instead of hits for the individual words.) * * 2. Convert to lowercase (again, respecting Unicode). * * 3. Split into words on whitespace boundaries (according to Unicode). * * If wildcard is true allow * */ public function split($text, $wildcard = false) { if (!function_exists('mb_strtolower')) { // It's more than just mb_strtolower throw new sfException('You must have full unicode support in PHP to use this plugin.'); } $wildcardRegex = ''; if ($wildcard) { $wildcardRegex = '\*'; } // Always letters, sometimes numbers $extraClasses = ''; if (sfConfig::get('app_a_mysql_search_numbers')) { $extraClasses .= '\p{N}'; } $words = mb_strtolower(preg_replace('/[^\p{L}' . $extraClasses . $wildcardRegex . '\p{Z}]+/u', ' ', $text), 'UTF8'); $words = preg_split('/\p{Z}+/u', $words); $goodWords = array(); foreach ($words as $word) { if ($wildcard) { $wildcardRegex = '\*?'; } if (!preg_match('/^[\p{L}' . $extraClasses . ']+$/u', $word)) { continue; } $goodWords[] = $word; } return $goodWords; } public function deleteAll($options) { $this->initSql(); $itemTable = Doctrine::getTable($options['item_model'])->getTableName(); $relationTableName = $itemTable . '_to_a_search_document'; $relatedId = $itemTable . '_id'; // Clean up the usages and the documents in one fell swoop $cultureClause = ''; if (isset($info['culture'])) { $cultureClause = ' AND asd.culture = :culture '; } // Should be faster than the old query; our goal here is to clean up the documents and // usages without hitting mysql's 20sec limit on locks. We let ON DELETE CASCADE mop up // the a_search_usage rows $q = "DELETE asd FROM a_search_document AS asd WHERE asd.id IN (SELECT a_search_document_id FROM $relationTableName) $cultureClause"; error_log($q); $this->sql->query($q); } /** * Returns the document id matching the specified item_id, item_model and optionally culture. * If you do not specify a culture you will get a predictable result only if the * document was stored without a culture */ protected function getDocumentId($info) { $this->initSql(); $q = $this->buildDocumentIdQuery($info); return $this->sql->queryOneScalar($q, $info); } /** * Returns the document ids matching the specified item_id, item_model and optionally culture. * If you do not specify a culture you will get all document ids for this object, with or * without a culture */ protected function getDocumentIds($info) { $this->initSql(); $q = $this->buildDocumentIdQuery($info); return $this->sql->queryScalar($q, $info); } protected function buildDocumentIdQuery($info) { $relationTableName = $info['item_table'] . '_to_a_search_document'; $relatedId = $info['item_table'] . '_id'; $q = "select refclass.a_search_document_id FROM $relationTableName refclass INNER JOIN a_search_document asd ON asd.id = refclass.a_search_document_id WHERE refclass.$relatedId = :item_id "; if (isset($info['culture'])) { $q .= 'AND asd.culture = :culture '; } elseif ((!isset($info['no-culture-means-all'])) || (!$info['no-culture-means-all'])) { $q .= 'AND asd.culture IS NULL'; } return $q; } protected function getDocumentInfo($options) { if (isset($options['item_id'])) { $info = array('item_id' => $options['item_id'], 'item_model' => $options['item_model'], 'item_table' => Doctrine::getTable($options['item_model'])->getTableName()); } else { $item = $options['item']; $info = array('item_id' => $item->id, 'item_model' => get_class($item), 'item_table' => $item->getTable()->getTableName()); } if (isset($options['culture'])) { $info['culture'] = $options['culture']; } else { // Explicit null so we can insert it correctly for things that don't need a culture $info['culture'] = null; } return $info; } protected function deleteUsages($document_id) { $this->initSql(); $this->sql->query('DELETE FROM a_search_usage WHERE document_id = :document_id', array('document_id' => $document_id)); } public function optimize() { // Drop any words that no longer have a reference. It's OK if you never do this, but // your search index will be smaller and faster if you do it occasionally (nightly is nice) $this->initSql(); $this->sql->query('DELETE asw FROM a_search_word AS asw LEFT JOIN a_search_usage asu ON asu.word_id = asw.id WHERE asu.id IS NULL'); } }
true
f104f5964cbd3180beeb86c7dd8e8b7d1c72e7a3
PHP
Torann/skosh-generator
/src/Builder.php
UTF-8
15,933
2.734375
3
[ "BSD-2-Clause" ]
permissive
<?php namespace Skosh; use Symfony\Component\Finder\Finder; use Symfony\Component\Filesystem\Filesystem; use Twig_Environment; use Twig_Loader_Chain; use Twig_Loader_Filesystem; use Skosh\Content\Doc; use Skosh\Content\Content; use Skosh\Console\Application; class Builder { /** * Path to the source directory. * * @var string */ private $source; /** * Path to the target directory. * * @var string */ public $target; /** * Application instance. * * @var \Skosh\Console\Application */ public $app; /** * Site objects holds the compiled site data. * * @var \Skosh\Site */ private $site; /** * Site objects holds the compiled site data. * * @var \Skosh\AssetManifest */ private $manifest; /** * Twig template rendering. * * @var \Twig_Environment */ private $twig; /** * Initializer. * * @param Application $app * * @throws \Exception */ public function __construct(Application $app) { $this->app = $app; $this->site = new Site($app); // Set asset manifest $this->manifest = new AssetManifest($this->app->getEnvironment()); // Set system paths $this->target = $this->app->getTarget(); $this->source = $this->app->getSource(); // Check paths $fs = new Filesystem(); if ($fs->exists($this->source) === false) { throw new \Exception("Source folder not found at \"{$this->source}\"."); } // Ensure we have a target if ($fs->exists($this->target) === false) { $fs->mkdir($this->target); } // Setup a twig loader $loader = new Twig_Loader_Chain(); $loader->addLoader(new Twig\Loader($this->site)); // If a template directory exists, add a filesystem loader to resolve // templates residing within it $templateDir = $this->source . DIRECTORY_SEPARATOR . "_templates"; if (is_dir($templateDir)) { $loader->addLoader(new Twig_Loader_Filesystem($templateDir)); } $includesDir = $this->source . DIRECTORY_SEPARATOR . "_includes"; if (is_dir($includesDir)) { $loader->addLoader(new Twig_Loader_Filesystem($includesDir)); } // Full template rendering $this->twig = new Twig_Environment($loader, ['debug' => true]); // Make the site variable global $this->twig->addGlobal('site', $this->site); // Add an escaper for XML $this->twig->getExtension('core')->setEscaper('xml', function ($env, $content) { return htmlentities($content, ENT_COMPAT | ENT_XML1); }); // Add build in extensions $this->twig->addExtension(new Twig\Extension($this)); $this->registerTwigExtensions(); // Fire booted event Event::fire('builder.booted', [$this]); } /** * Register custom twig extensions. */ private function registerTwigExtensions() { foreach ($this->app->getSetting('twig_extensions', []) as $extension) { $this->twig->addExtension(new $extension($this)); } } /** * Return Twig Environment. * * @return Twig_Environment */ public function getTwigEnvironment() { return $this->twig; } /** * Return site. * * @return Site */ public function getSite() { return $this->site; } /** * Get the URL for the given page. * * @param string $url * * @return string */ public function getUrl($url) { if (empty($url) || starts_with($url, ['#', '//', 'mailto:', 'tel:', 'http'])) { return $url; } // Get URL root $root = $this->app->getSetting('url'); $url = trim($root, '/') . '/' . trim($url, '/'); // Force trailing slash if ($this->app->getSetting('url_trailing_slash', false) && ! strrchr(basename($url), '.') ) { $url = "{$url}/"; } return $url; } /** * Check asset manifest for a file * * @param string $path * * @return string */ public function getAsset($path) { // Absolute path will not be in manifest if ($path[0] === '/') { return $this->getUrl($path); } // Get manifest $asset = $this->manifest->get($path); return $this->getUrl('/assets/' . trim($asset, '/')); } /** * Renders the site * * @return void * @throws \Exception * @throws \Twig\Error\RuntimeError * @throws \Twig\Error\SyntaxError * @throws \Twig\Error\LoaderError */ public function build() { $this->app->writeln("\n<comment>Adding root pages</comment>"); $this->addPages('\\Skosh\\Content\\Page'); $this->app->writeln("\n<comment>Adding posts</comment>"); $this->addPages('\\Skosh\\Content\\Post', 'path', '_posts'); $this->app->writeln("\n<comment>Adding docs</comment>"); $this->addPages('\\Skosh\\Content\\Doc', 'path', '_doc'); // Sort pages $this->sortPosts(); // Fire event Event::fire('pages.sorted', [$this]); $this->app->writeln("\n<comment>Rendering content</comment>"); foreach ($this->site->pages as $content) { $this->renderContent($content); } // Fire event Event::fire('pages.rendered', [$this]); } /** * Renders content * * @param Content $content * * @return bool * @throws \Twig\Error\RuntimeError * @throws \Twig\Error\SyntaxError * @throws \Twig\Error\LoaderError */ private function renderContent(Content $content) { $tpl = $content->has('template') ? " <comment>($content->template)</comment>" : ""; $this->app->writeln("Rendering: <info>{$content->target}</info>{$tpl}"); // Only template files are run through Twig (template can be "none") if ($content->has('template')) { if ($content->paginate) { return $this->paginate($content); } else { $html = $this->twig->render($content->id, [ 'page' => $content, 'posts' => $this->getPosts($content), 'parent' => $this->getParent($content->parentId) ]); } } else { $template = $this->twig->createTemplate($content->content); $html = $template->render([]); } // Save Content $this->savePage($content->target, $html); return true; } /** * Save page to target file. * * @param string $html * @param string $target * * @return void */ public function savePage($target, $html) { $fs = new Filesystem(); $fs->dumpFile($this->target . DIRECTORY_SEPARATOR . $target, $html); } /** * Get parent content. * * @param string $parentId * * @return array */ public function getParent($parentId) { if ($parentId && isset($this->site->pages[$parentId])) { return $this->site->pages[$parentId]; } return []; } /** * Get posts for given content. * * @param Content $content * * @return array */ public function getPosts(Content $content) { if (isset($this->site->categories[$content->id])) { return $this->site->categories[$content->id]; } else { if (isset($content->category) && isset($this->site->categories[$content->category])) { return $this->site->categories[$content->category]; } } return []; } /** * Create a server config file * * @return void * @throws \Exception */ public function createServerConfig() { // Load config $config = new Config($this->app->getEnvironment(), '.env'); // Save to protected file $config->export($this->target . DIRECTORY_SEPARATOR . '.env.php'); } /** * Copy static files to target * Ignoring JS, CSS & LESS - Gulp handles that * * @return void */ public function copyStaticFiles() { $exclude = ['js', 'javascripts', 'stylesheets', 'less', 'sass']; // Include the excludes from the config $exclude = array_merge($exclude, (array) $this->app->getSetting('exclude', [])); // Create pattern $pattern = '/\\.(' . implode("|", $exclude) . ')$/'; // Get list of files & directories to copy $to_copy = (array) $this->app->getSetting('copy', []); // Assets folder is hardcoded into copy $to_copy = array_merge(['assets'], $to_copy); $to_copy = array_unique($to_copy); // Initialize file system $filesystem = new Filesystem(); // Fire event if ($response = Event::fire('copy.before', [$this, $to_copy])) { $to_copy = $response[0]; } // Copy foreach ($to_copy as $location) { $fileInfo = new \SplFileInfo($this->source . DIRECTORY_SEPARATOR . $location); // Copy a complete directory if ($fileInfo->isDir()) { $finder = new Finder(); $finder->files() ->exclude($exclude) ->notName($pattern) ->in($this->source . DIRECTORY_SEPARATOR . $location); foreach ($finder as $file) { $path = $location . DIRECTORY_SEPARATOR . $file->getRelativePathname(); echo "$path\n"; $source = $file->getRealPath(); $target = $this->target . DIRECTORY_SEPARATOR . $path; $filesystem->copy($source, $target); $this->app->writeln("Copied: <info>$path</info>"); } } // Copy Single File else { $filesystem->copy($fileInfo->getRealPath(), $this->target . DIRECTORY_SEPARATOR . $location); $this->app->writeln("Copied: <info>$location</info>"); } } } /** * Clean target directory * * @return void */ public function cleanTarget() { $filesystem = new Filesystem(); // Get files and directories to remove $files = array_diff(scandir($this->target), ['.', '..']); $files = preg_grep('/[^.gitignore]/i', $files); // Remove files foreach ($files as $file) { $filesystem->remove("$this->target/$file"); } // Fire event Event::fire('target.cleaned', [$this]); } /** * Add pages for rendering * * @param string $class * @param string $path * @param string $filter * * @return void * @throws \Exception */ private function addPages($class, $path = 'notPath', $filter = '_') { $finder = (new Finder()) ->files() ->in($this->source) ->$path($filter) ->name('/\\.(md|textile|xml|twig)$/'); foreach ($finder as $file) { $page = new $class($file, $this); // Skip drafts in production if ($this->app->isProduction() && $page->status === 'draft') { $this->app->writeln("Skipping draft: <info>{$page->sourcePath}/{$page->filename}</info>"); continue; } $this->app->writeln("Adding: <info>{$page->sourcePath}/{$page->filename}</info>"); $this->site->addContent($page); } } /** * Sorts posts by date (descending) or by * chapter (ascending). Assigns post.next and post.prev * * @return void */ private function sortPosts() { $this->app->writeln("\n<comment>Sorting</comment>"); $cmpFn = function (Content $one, Content $other) { // Sort by chapters if ($one instanceof Doc && $other instanceof Doc) { if ($one->chapter == $other->chapter) { return 0; } return ($one->chapter < $other->chapter) ? -1 : 1; } // Sort by date if ($one->date == $other->date) { return 0; } return ($one->date > $other->date) ? -1 : 1; }; foreach ($this->site->categories as $cat => &$posts) { // Sort posts usort($posts, $cmpFn); // Assign next and previous post within the category foreach ($posts as $key => $post) { if (isset($posts[$key - 1])) { $post->next = $posts[$key - 1]; } if (isset($posts[$key + 1])) { $post->prev = $posts[$key + 1]; } } } $this->app->writeln("Done!"); } /** * Generate pagination * * @param Content $content * * @return bool * @throws \Twig\Error\RuntimeError * @throws \Twig\Error\SyntaxError * @throws \Twig\Error\LoaderError */ private function paginate(Content $content) { $maxPerPage = $this->app->getSetting('max_per_page', 15); $posts = $this->getPosts($content); $slices = []; $slice = []; $totalItems = 0; foreach ($posts as $k => $v) { if (count($slice) === $maxPerPage) { $slices[] = $slice; $slice = []; } $slice[$k] = $v; $totalItems++; } $slices[] = $slice; // Base URL $pageRoot = '/' . dirname($content->target); // Pagination data $pagination = [ 'total_posts' => count($posts), 'total_pages' => count($slices), 'next' => null, 'prev' => null ]; $pageNumber = 0; foreach ($slices as $slice) { $pageNumber++; // Set page target filename $target = ($pageNumber > 1) ? "{$pageRoot}/page/{$pageNumber}" : $content->target; // Previous page is index if ($pageNumber === 2) { $pagination['prev'] = $this->getUrl($pageRoot); } // Set previous page elseif ($pageNumber > 1) { $pagination['prev'] = $this->getUrl("{$pageRoot}/page/" . ($pageNumber - 1)); } // No previous page else { $pagination['prev'] = null; } // Set next page if ($pageNumber + 1 <= $pagination['total_pages']) { $pagination['next'] = $this->getUrl("{$pageRoot}/page/" . ($pageNumber + 1)); } // No next page else { $pagination['next'] = null; } // Set current page $pagination['page'] = $pageNumber; // Set page URL $content->url = ($pageNumber > 1) ? $this->getUrl(dirname($target)) : $content->url; // Render content $html = $this->twig->render($content->id, [ 'page' => $content, 'posts' => $slice, 'pagination' => $pagination, 'parent' => $this->getParent($content->parentId) ]); // Fire event Event::fire('paginate.before', [$this, &$target, &$html]); // Save Content $this->savePage($target, $html); } return true; } }
true
30da0727b5de833cfdf9b750de5c798ac96750d3
PHP
tectronics/Coat-of-Arms
/app/Model/Fighter.php
UTF-8
17,024
2.671875
3
[]
no_license
<?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ App::uses('Folder', 'Utility'); App::uses('File', 'Utility'); App::uses('Surrounding', 'Model'); App::uses('Event', 'Model'); class Fighter extends AppModel { public $components = array('Session'); public $displayField = 'name'; public $belongsTo = array( 'Player' => array( 'className' => 'Player', 'foreignKey' => 'player_id', ), ); function position_aleatoire() { do { $x = rand(0, 14); $y = rand(0, 9); $resp = $this->getFighter($x, $y); $s = new Surrounding(); $resp2 = $s->getSurrounding($x, $y); } while ($resp != false && $resp2 != false); $position = array('x' => $x, 'y' => $y); return $position; } function goArena($id) { $event = new Event(); do { $x = rand(0, 14); $y = rand(0, 9); $resp = $this->getFighter($x, $y); } while ($resp != false); $data = array('coordinate_x' => $x, 'coordinate_y' => $y, 'id' => $id); $fighter = $this->findById($id); $event->createEvent($fighter['Fighter']['name'] . " entered the arena.", $x, $y); $this->save($data); } function testAvatar($id) { $dir = new Folder(IMAGES . 'avatar'); $a = $dir->find($id . '.png'); if (empty($a)) { return 0; //empty } else { return 1; }//full } function carrousselAvatar() { $dir = new Folder(IMAGES . 'avatar'); return $dir->find('.*\.png'); } function checkOccupied($x, $y) { $datas = $this->query("select * from fighters where coordinate_x ='$x' and coordinate_y='$y';"); if ($datas == null) { return true; } else { return false; } } function checkLimit($x, $y) { if ($x < 15 && $y < 10 && $x >= 0 && $y >= 0) { return true; } else { return false; } } function doMove($fighterId, $direction) { if ($this->checkTime()) { //récupérer la position et fixer l'id de travail $datas = $this->find('first', array('conditions' => array('Fighter.id' => $fighterId))); $x = $datas['Fighter']['coordinate_x']; $y = $datas['Fighter']['coordinate_y']; $surrounding = new Surrounding(); $event = new Event(); // use the Model if ($direction == 'north') { $y+=1; } elseif ($direction == 'south') { $y-=1; } elseif ($direction == 'east') { $x+=1; } elseif ($direction == 'west') { $x-=1; } $element = $surrounding->getSurrounding($x, $y); if ($this->checkOccupied($x, $y) && $this->checkLimit($x, $y)) { if ($element == false) { $this->set('coordinate_x', $datas['Fighter']['coordinate_x'] = $x); $this->set('coordinate_y', $datas['Fighter']['coordinate_y'] = $y); } elseif ($element['type'] == 'arbre') { return false; } elseif ($element['type'] == 'monster') { $position = $this->position_aleatoire(); $event->createEvent($datas['Fighter']['name'] . " has been killed by a monster !", $datas['Fighter']['coordinate_x'], $datas['Fighter']['coordinate_y']); $surrounding->set('coordinate_x', $element['coordinate_x'] = $position['x']); $surrounding->set('coordinate_y', $element['coordinate_y'] = $position['y']); $this->set('current_health', $datas['Fighter']['current_health'] = 0); } elseif ($element['type'] == 'exit') { $position = $this->position_aleatoire(); $event->createEvent($datas['Fighter']['name'] . " left the arena.", $datas['Fighter']['coordinate_x'], $datas['Fighter']['coordinate_y']); $this->set('coordinate_x', $datas['Fighter']['coordinate_x'] = -1); $this->set('coordinate_y', $datas['Fighter']['coordinate_y'] = -1); $surrounding->set('coordinate_x', $element['coordinate_x'] = $position['x']); $surrounding->set('coordinate_y', $element['coordinate_y'] = $position['y']); CakeSession::delete('fighter'); } elseif ($element['type'] == 'trap') { $position = $this->position_aleatoire(); $event->createEvent($datas['Fighter']['name'] . " has fallen into a trap !", $datas['Fighter']['coordinate_x'], $datas['Fighter']['coordinate_y']); $surrounding->set('coordinate_x', $element['coordinate_x'] = $position['x']); $surrounding->set('coordinate_y', $element['coordinate_y'] = $position['y']); $this->set('current_health', $datas['Fighter']['current_health'] = 0); } } else { return false; } $this->save($datas); $surrounding->save($element); return true; } } function doAttack($fighterId, $attack) { if ($this->checkTime()) { //récupérer la position et fixer l'id de travail $datas = $this->find('first', array('conditions' => array('Fighter.id' => $fighterId))); $x = $datas['Fighter']['coordinate_x']; $y = $datas['Fighter']['coordinate_y']; $surrounding = new Surrounding(); $event = new Event(); if ($attack == 'north') { $y+=1; } elseif ($attack == 'south') { $y-=1; } elseif ($attack == 'east') { $x+=1; } elseif ($attack == 'west') { $x-=1; } $element = $surrounding->getSurrounding($x, $y); if ($this->getFighter($x, $y) && $element == false) { $victim = $this->find('first', array('conditions' => array('coordinate_x' => $x, 'coordinate_y' => $y))); $seuil = 10 + $victim['Fighter']['level'] - $datas['Fighter']['level']; $rand = rand(0, 20); if ($rand > $seuil) { $victim['Fighter']['current_health']-=$datas['Fighter']['skill_strength']; $datas['Fighter']['xp']+=1; $event->createEvent($datas['Fighter']['name'] . " attacked " . $victim['Fighter']['name'] . " for " . $datas['Fighter']['skill_strength'] . " dammage !", $datas['Fighter']['coordinate_x'], $datas['Fighter']['coordinate_y']); if ($victim['Fighter']['current_health'] <= 0) { $datas['Fighter']['xp']+=$victim['Fighter']['level']; $victim['Fighter']['coordinate_x'] = -1; $victim['Fighter']['coordinate_y'] = -1; $event->createEvent($victim['Fighter']['name'] . " has been killed by" . $datas['Fighter']['name'] . " !", $datas['Fighter']['coordinate_x'], $datas['Fighter']['coordinate_y']); } $this->save($victim); } else { $event->createEvent($datas['Fighter']['name'] . " attacked " . $victim['Fighter']['name'] . " but it failed !", $datas['Fighter']['coordinate_x'], $datas['Fighter']['coordinate_y']); } } elseif ($element != false) { if ($element['type'] == 'monster') { $position = $this->position_aleatoire(); $event->createEvent($datas['Fighter']['name'] . " killed a monster !", $datas['Fighter']['coordinate_x'], $datas['Fighter']['coordinate_y']); $surrounding->set('coordinate_x', $element['coordinate_x'] = $position['x']); $surrounding->set('coordinate_y', $element['coordinate_y'] = $position['y']); $datas['Fighter']['xp']+=1; $surrounding->save($element); } } else { $event->createEvent($datas['Fighter']['name'] . " attacked in the wind ...", $datas['Fighter']['coordinate_x'], $datas['Fighter']['coordinate_y']); return false; } //sauver la modif $this->save($datas); return true; } } function arenaFill() { $id_joueur = CakeSession::read('nom')['id']; $id_fighter = CakeSession::read('fighter'); $data = $this->find('first', array('conditions' => array(/* 'player_id'=>$id_joueur, */'fighter.id' => $id_fighter))); $vue_tot = $data['Fighter']['skill_sight']; $x = $data['Fighter']['coordinate_x']; $y = $data['Fighter']['coordinate_y']; $s = new Surrounding(); for ($i = 0; $i < 15; $i++) { for ($j = 0; $j < 10; $j++) { $tab[$i][$j] = array("type" => 'non_vue'); } } $tab[$x][$y] = array('type' => 'me', 'data' => $data['Fighter']); for ($i = 0; $i < 10; $i++) { for ($j = 0; $j < 15; $j++) { if ((abs($i - $y) + abs($j - $x)) <= $vue_tot) { $donnee = $this->getFighter($j, $i); if ($donnee) { $tab[$j][$i] = array('type' => 'fighter', 'data' => $donnee); } else { //Recuperer surroundings $donnee = $s->getSurroundingVisible($j, $i); if (!empty($donnee)) { $tab[$j][$i] = array('type' => 'surrounding', 'data' => $donnee); } else { $tab[$j][$i] = array('type' => 'vide'); } } } else { $tab[$j][$i] = array("type" => 'non_vue'); } } } $tab[$x][$y] = array('type' => 'me', 'data' => $data['Fighter'], 'state' => $s->getDanger($x, $y)); return $tab; } function infoPerso($id_perso) { $inf = $this->query("SELECT * FROM fighters WHERE id = $id_perso"); return $inf[0]['fighters']; } function addPerso($name) { $id_joueur = CakeSession::read('nom')['id']; App::uses('CakeTime', 'Utility'); $date = new DateTime(); $date_f = $date->format('Y-m-d H:i:s'); $data = array('name' => $name, 'player_id' => $id_joueur, 'skill_health' => 3, 'current_health' => 3, 'skill_strength' => 1, "coordinate_x" => -1, "coordinate_y" => -1, "next_action_time" => $date_f); $this->save($data); return $this->id; } function evolution_perso($id_perso, $skills) { $perso = $this->infoPerso($id_perso); $vue = $perso['skill_sight'] + 1; $force = $perso['skill_strength'] + 1; $vie = $perso['skill_health'] + 3; $vie_current = $perso['current_health'] + 3; $level = $perso['level'] + 1; switch ($skills) { case 'vue' : $data = array('id' => $id_perso, 'skill_sight' => $vue, 'level' => $level); break; case 'vie' : $data = array('id' => $id_perso, 'skill_health' => $vie, 'current_health' => $vie_current, 'level' => $level); break; case 'force' : $data = array('id' => $id_perso, 'skill_strength' => $force, 'level' => $level); break; } $this->save($data); } function getFighter($i, $j) { $data = $this->find('first', array('conditions' => array('coordinate_x' => $i, 'coordinate_y' => $j))); if ($data) { return $data['Fighter']; } else { return false; } } function uploadFile2($file, $id) { if ( !empty($file['tmp_name']) && in_array(strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)), array('png'))) { $extension = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)); move_uploaded_file($file['tmp_name'], IMAGES . 'avatar' . DS . $id . '.' . $extension); return true; } else { return false; } } function tabFill() { $id_fighter = CakeSession::read('fighter'); $data = $this->find('first', array('conditions' => array('fighter.id' => $id_fighter))); $vue_tot = $data['Fighter']['skill_sight']; $x = $data['Fighter']['coordinate_x']; $y = $data['Fighter']['coordinate_y']; for ($i = 0; $i < 10; $i++) { for ($j = 0; $j < 15; $j++) { if ((abs($i - $y) + abs($j - $x)) <= $vue_tot) { $donnee = $this->getFighter($j, $i); if (!empty($donnee)) { if ($this->testAvatar($donnee['id']) == 1) { $avatar = 'avatar/' . $donnee['id'] . '.png'; } else { $avatar = "blason_def.png"; } $tab[] = array('vue' => abs($i - $y) + abs($j - $x), 'data' => $donnee, 'avatar' => $avatar, 'type' => 'fighter'); } else { //Recuperer surroundings $s = new Surrounding(); $donnee = $s->getSurroundingVisible($j, $i); if (!empty($donnee)) { $tab[] = array('vue' => abs($i - $y) + abs($j - $x), 'data' => $donnee, 'type' => 'surrounding'); } } } } } return $tab; } function afficherFighter($id) { $data = $this->find('all', array('conditions' => array('player_id' => $id))); for ($i = 0; $i < count($data); $i++) { if ($this->testAvatar($data[$i]['Fighter']['id']) == 1) { $avatar = 'avatar/' . $data[$i]['Fighter']['id'] . '.png'; } else { $avatar = "blason_def.png"; } $data[$i]['avatar'] = $avatar; } return $data; } function ptsAction() { $fighter = $this->find('first', array('conditions' => array('fighter.id' => CakeSession::read('fighter')))); $temps = $fighter['Fighter']['next_action_time']; $date_actuelle = new DateTime(); $temps_actuel = $date_actuelle->format('y-m-d H:i:s'); $max_action = 3; $temps_action = 10; //en secondes $temps = new DateTime($temps); $diff = $date_actuelle->diff($temps); $diff_sec = (int) $diff->format('%s') + (int) $diff->format('%i') * 60 + (int) $diff->format('%H') * 60 * 60 + (int) $diff->format('%d') * 24 * 60 * 60 + (int) $diff->format('%m') * 30 * 60 * 60 + (int) $diff->format('%y') * 31536000; if ($diff->invert == 1) { if ($diff_sec >= ($max_action * $temps_action)) { return $max_action; } else { return variant_int($diff_sec / $temps_action); } } else { echo 'pas de pts!'; return 0; } } function checkTime() { $fighter = $this->find('first', array('conditions' => array('fighter.id' => CakeSession::read('fighter')))); $temps = $fighter['Fighter']['next_action_time']; $date_actuelle = new DateTime(); $temps_actuel = $date_actuelle->format('y-m-d H:i:s'); $max_action = 3; $temps_action = 10; //en secondes $temps = new DateTime($temps); $diff = $date_actuelle->diff($temps); $diff_sec = (int) $diff->format('%s') + (int) $diff->format('%i') * 60 + (int) $diff->format('%H') * 60 * 60 + (int) $diff->format('%d') * 24 * 60 * 60 + (int) $diff->format('%m') * 30 * 60 * 60 + (int) $diff->format('%y') * 31536000; if (($diff_sec) >= $temps_action) { if (($diff_sec) >= ($max_action * $temps_action)) { $nb = ($max_action - 1) * $temps_action; $interval = new DateInterval('PT' . $nb . 'S'); $interval->invert = 1; $newtime = $date_actuelle->add($interval)->format('y-m-d H:i:s'); } else { $interval = new DateInterval("PT" . $temps_action . 'S'); $newtime = $temps->add($interval)->format('y-m-d H:i:s'); } $data = array('id' => CakeSession::read('fighter'), 'next_action_time' => $newtime); $this->save($data); return true; } else { return false; } } }
true
cfaeb056056765fad3c485e2adca4b96986abf2a
PHP
Ura20/phpoop
/users.php
UTF-8
4,029
2.71875
3
[]
no_license
<?php require("classes/User.php"); //Create an instance for User session_start(); $id = $_SESSION['userid']; $user = new User; $row = $user->selectOne($id); if(empty($_SESSION['userid'])){ header('location:login.php'); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"> <title>Document</title> </head> <body> <nav class="navbar fixed-top navbar_light bg-custom navbar-expand-lg"> <div class="collapse navbar-collapse" id="navbarNav"> <ul class="navbar-nav mr-auto"> <li class="nav-item"> <a class="nav-link" href="users.php">Users</a> </li> <li class="nav-item"> <a class="nav-link" href="items.php">Items</a> </li> </ul> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link" name="welcome"><?php echo "Welcome, " . $row['firstname'] . " " . $row['lastname'];?></a> </li> <li class="nav-item"> <a class="nav-link" href="logout.php" name="logout">Log Out</a> </li> </ul> </div> </nav> <div class ="container"> <div class="row"> <div class="col mt-5 pt-5"> <div class="card bg-white"> <div class="card-header"><h2>User List</h2></div> <div class="card-body"> <form action="" method="post"> <table class="table table-striped"> <thead> <th>User ID</th> <th>User Name</th> <th>First Name</th> <th>Last Name</th> <th>Action</th> </thead> <tbody> <?php //call the select method $result = $user->select(); if($result){ foreach($result as $key => $row){ $id = $row['user_id']; echo "<tr>"; echo "<td>" . $row['user_id'] . "</td>"; echo "<td>" . $row['username'] . "</td>"; echo "<td>" . $row['firstname'] . "</td>"; echo "<td>" . $row['lastname'] . "</td>"; echo "<td> <a href='edituser.php?id=$id' class='btn btn-sm btn-primary'>Edit</a> <a href='deleteuser.php?id=$id' class='btn btn-sm btn-danger'>Delete</a> </td>"; echo "</tr>"; } } else{ echo "<tr><td colspan='4' class='text-center'>No data available</td></tr>"; } ?> </tbody> </table> <a href="adduser.php" class="btn btn-sm btn-secondary">Add User</a> </form> </div> </div> </div> </div> </div> </body> </html>
true
835d7a7ec49b4638463908bb37ae361b8803e4eb
PHP
bhutanio/laravel-utilities
/src/Bhutanio/Laravel/Helpers.php
UTF-8
2,686
2.796875
3
[]
no_license
<?php // Laravel Aliases /** * @return \Bhutanio\Laravel\Services\MetaDataService */ function meta() { return app(Bhutanio\Laravel\Services\MetaDataService::class); } /** * @param $config array * * @return \Bhutanio\Laravel\Services\Guzzler */ function guzzler($config = []) { return app(Bhutanio\Laravel\Services\Guzzler::class, $config); } /** * @param null $time * @param null $tz * * @return \Carbon\Carbon */ function carbon($time = null, $tz = null) { return new \Carbon\Carbon($time, $tz); } /** * Generate directory path for saving files. * * @param $text * * @return string */ function leveled_dir($text) { $dirs = str_split($text, 1); if (count($dirs) > 2) { return $dirs[0] . DIRECTORY_SEPARATOR . $dirs[1] . DIRECTORY_SEPARATOR . $dirs[2]; } return '0' . DIRECTORY_SEPARATOR . '0' . DIRECTORY_SEPARATOR . '0'; } /** * Get IP Address, checks for cloudflare headers. * * @return string */ function get_ip() { if (getenv('HTTP_CF_CONNECTING_IP') && is_valid_ip(getenv('HTTP_CF_CONNECTING_IP'))) { return getenv('HTTP_CF_CONNECTING_IP'); } return request()->getClientIp(); } /** * Validate IP Address. * * @param string $ip IP address * @param string $which IP protocol: 'ipv4' or 'ipv6' * * @return bool */ function is_valid_ip($ip, $which = 'ipv4') { if ($ip == '0.0.0.0' || $ip == '127.0.0.1') { return false; } switch (strtolower($which)) { case 'ipv4': $which = FILTER_FLAG_IPV4; break; case 'ipv6': $which = FILTER_FLAG_IPV6; break; default: $which = null; break; } return (bool)filter_var($ip, FILTER_VALIDATE_IP, $which); } function is_valid_ipv6($ip) { return is_valid_ip($ip, 'ipv6'); } /** * Validate IPv4 Address (Check if it is a public IP). * * @param string $ip IP address * * @return bool */ function is_public_ip($ip) { if (!is_valid_ip($ip)) { return false; } return (bool)filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE); } // View Helpers /** * @param $errors \Illuminate\Support\ViewErrorBag * @param $field string * @return string */ function form_error_class($errors, $field) { if ($errors->has($field)) { return ' has-error'; } return ''; } /** * @param $errors \Illuminate\Support\ViewErrorBag * @param $field string * @return string */ function form_error($errors, $field) { if ($errors->has($field)) { return '<span class="help-block"><strong>' . $errors->first($field) . '</strong></span>'; } return ''; }
true
93c5f12a7812a972968eb7de4e910aca96a6646e
PHP
masr/smnju
/source/model/model.class.php
UTF-8
8,106
2.765625
3
[]
no_license
<?php abstract class Model { protected static $table_name = NULL; protected static $class_name = NULL; protected static $id_name = 'id'; protected static $translate = array(); protected static $require_not_null=array(); protected static $unique = array(); protected static $unchanged = array(); protected static $reg_validate = array(); public $attrs = array(); protected $is_normalized = false; protected $error_msg = ''; protected function __construct($attrs = array()) { $this->attrs = $attrs; } /** * * @param $name * @return NULL if attribute not found in attrs list */ public function __get($name) { return $this->get($name); } /** * * @param $name * @param $value * @return false if set failed. */ public function __set($name, $value) { $this->set($name, $value); } public function __isset($name) { return isset($this->attrs[$name]); } public function __unset($name) { unset($this->attrs[$name]); } public function get($name) { if (isset($this->attrs[$name])) return $this->attrs[$name]; else return NULL; } public function set($name, $value) { if ($name == static::$id_name) return false; if ($this->has_id() && in_array($name, static::$unchanged) && ($this->attrs[$name] !== NULL)) return false; else $this->attrs[$name] = $value; } public function has_id() { return isset($this->attrs[static::$id_name]); } public function merge_attrs($attrs) { $o_attrs = $this->attrs; $ret = true; foreach ($attrs as $k => $v) { $ret = $this->set($k, $v); if ($ret === false) { $this->attrs = $o_attrs; return false; } } } public function get_attrs() { return $this->attrs; } protected static function add_reg_validate($name, $reg, $notice = NULL) { if ($notice === NULL) $notice = static::$translate[$name] . '格式错误'; static::$reg_validate[$name] = array('reg' => $reg, 'notice' => $notice); } /** * If return false, you can see error_msg() for error info. * @return false if invalid. */ public function validate() { foreach (static::$require_not_null as $v) { if (isset($this->attrs[$v]) && trim($this->attrs[$v]) === '') { if (empty(static::$translate[$v])) $translate = $v; else $translate = static::$translate[$v]; $this->error_msg = $translate . '为空!'; return false; } } foreach (static::$unique as $v) { if (!isset($this->attrs[$v])) continue; if ($this->has_id()) { $id = $this->get_id(); $id_name = static::$id_name; $ret = check_if_exist(static::$table_name, "$v='{$this->attrs[$v]}' and {$id_name}<>'{$id}'"); } else { $ret = check_if_exist(static::$table_name, "$v='{$this->attrs[$v]}'"); } if ($ret) { $this->error_msg = static::$translate[$v] . '重复!'; return false; } } foreach ($this->attrs as $k => $v) { if ($v === NULL) continue; if (isset(static::$reg_validate[$k])) { $ret = preg_match(static::$reg_validate[$k]['reg'], $v); if (empty($ret)) { $this->error_msg = static::$reg_validate[$k]['notice']; return false; } } } return true; } public function error_msg() { return $this->error_msg; } public static function snormalize($objects) { if (is_array($objects)) { foreach ($objects as $k => $v) { $objects[$k]->normalize(); } } elseif (is_object($objects)) { $objects->normalize(); } return $objects; } public function normalize(){ if(!$this->is_normalized){ if(isset($this->attrs['create_time'])){ $this->attrs['create_time'] = date('Y-m-d h:i', $this->attrs['create_time']); } } $this->is_normalized=true; } public static function create($attrs = array()) { $object = new static::$class_name; $object->attrs = $attrs; $object->post_create(); return $object; } public static function load($id) { $object = new static::$class_name; $ret = get_element_by_key(static::$table_name, static::$id_name, $id, '*'); if (empty($ret)) { return false; } $object->attrs = $ret; $object->post_load(); return $object; } public function get_id() { if (isset($this->attrs[static::$id_name])) return $this->attrs[static::$id_name]; return false; } public static function get_object($arr) { $ret = get_element(static::$table_name,'*', $arr); if(empty($ret)) return false; $object = new static::$class_name; $object->attrs=$ret[0]; return $object; } public static function get_objects($where = 0, $order_by = 0, $limit = 0, $start = 0) { $ret = get_element(static::$table_name, '*', $where, $order_by, $limit, $start); $objects = array(); foreach ($ret as $v) { $object = new static::$class_name; $object->attrs = $v; $objects[] = $object; } return $objects; } public static function get_count($where = 0, $order_by = 0, $limit = 0, $start = 0){ return get_element_count(static::$table_name,$where,$order_by,$limit,$start); } /** * * @return insert id */ public final function insert() { $this->pre_insert(); $ret = $this->validate(); if ($ret === false) { return false; } $this->attrs['create_time']=time(); if(isset($_SESSION['user_id'])){ $this->attrs['creator_id']=$_SESSION['user_id']; } $ret_id = inserttable(static::$table_name, $this->attrs); if (empty($ret_id)) { $this->error_msg = '数据库出错!'; return false; } $id_name=static::$id_name; $this->attrs[$id_name]=$ret_id; $this->refresh(); $this->post_insert(); return $ret_id; } public function refresh() { if (!$this->has_id()) return false; $id = $this->get_id(); $ret = get_element_by_key(static::$table_name, static::$id_name, $id, '*'); $this->attrs = $ret; } /** * * @param array $attrs * @return false if invalid,true successful */ public final function update($attrs = array()) { if (!$this->has_id()) return false; $this->pre_update(); if (!empty($attrs)) { $ret = $this->merge_attrs($attrs); if ($ret === false) return false; } $ret = $this->validate(); if ($ret === false) return false; $ret = updatetable(static::$table_name, $this->attrs, array(static::$id_name=>$this->attrs[static::$id_name])); if ($ret === false) { $this->error_msg = '数据库出错'; return false; } $this->refresh(); $this->post_update(); } /** * * @return false if invalid,true successful */ public final function delete() { if (!$this->has_id()) return false; $this->pre_delete(); if(empty($_SESSION['user_id'])) $user_id=0; else $user_id=$_SESSION['user_id']; if(isset($this->attrs['is_delete'])){ $which_role_delete = is_admin() ? 'admin' : 'user'; updatetable(static::$table_name, array('is_delete'=>'yes','who_delete'=>$user_id,'delete_time'=>time(),'which_role_delete'=>$which_role_delete),array(static::$id_name=>$this->get_id())); }else deletetable(static::$table_name,array(static::$id_name=>$this->get_id())); } public function restore(){ if (!$this->has_id()) return false; if(!isset($this->attrs['is_delete'])) return false; $this->update(array('is_delete'=>'no','who_delete'=>null,'delete_time'=>null,'which_role_delete'=>null)); } public function dump() { write_log($this->attrs); } protected function post_load() { } protected function pre_insert() { } protected function post_insert() { } protected function pre_update() { } protected function post_update() { } protected function post_create(){ } protected function pre_delete(){} protected function post_restore(){} protected function pre_restore(){} } ?>
true
d6428863e3f9831458e6b62ea63928606ed56c71
PHP
sop/jwx
/lib/JWX/JWK/Parameter/ECCPrivateKeyParameter.php
UTF-8
743
2.796875
3
[ "MIT" ]
permissive
<?php declare(strict_types = 1); namespace Sop\JWX\JWK\Parameter; use Sop\JWX\Parameter\Feature\Base64URLValue; /** * Implements 'ECC Private Key' parameter. * * @see https://tools.ietf.org/html/rfc7518#section-6.2.2.1 */ class ECCPrivateKeyParameter extends JWKParameter { use Base64URLValue; /** * Constructor. * * @param string $key Private key in base64url encoding */ public function __construct(string $key) { $this->_validateEncoding($key); parent::__construct(self::PARAM_ECC_PRIVATE_KEY, $key); } /** * Get the EC private key in octet string representation. */ public function privateKeyOctets(): string { return $this->string(); } }
true
7d33ac54658fb7be226ef6519ed9b01d10eea8a7
PHP
josdavidmo/orion
/clases/aplicacion/CHallazgosPendientes.php
UTF-8
3,171
3.109375
3
[ "Apache-2.0" ]
permissive
<?php /** * Clase Plana Hallazgos Pendientes. * @package clases * @subpackage aplicacion * @author SERTIC SAS * @version 2014.10.30 * @copyright SERTIC */ class CHallazgosPendientes { /** Almacena el id del Hallazgo Pendiente. */ var $id; /** Almacena la observacion del Hallazgo Pendiente. */ var $observacion; /** Almacena el tipo del Hallazgo Pendiente. */ var $tipo; /** Almacena la actividad del Hallazgo Pendiente. */ var $actividad; /** Almacena la clasificacion del Hallazgo Pendiente. */ var $clasificacion; /** Almacena el archivo del Hallazgo Pendiente. */ var $archivo; /** Almacena la fecha respuesta del Hallazgo Pendiente. */ var $fechaRespuesta; /** Almacena la observacion de la respuesta del Hallazgo Pendiente. */ var $observacionRespuesta; /** Almacena el archivo de la respuesta del Hallazgo Pendiente. */ var $archivoRespuesta; function __construct($id, $observacion, $tipo, $actividad, $clasificacion, $archivo, $fechaRespuesta = NULL, $observacionRespuesta = NULL, $archivoRespuesta = NULL) { $this->id = $id; $this->observacion = $observacion; $this->tipo = $tipo; $this->actividad = $actividad; $this->clasificacion = $clasificacion; $this->archivo = $archivo; $this->fechaRespuesta = $fechaRespuesta; $this->observacionRespuesta = $observacionRespuesta; $this->archivoRespuesta = $archivoRespuesta; } function getId() { return $this->id; } function getObservacion() { return $this->observacion; } function getTipo() { return $this->tipo; } function getActividad() { return $this->actividad; } function getClasificacion() { return $this->clasificacion; } function getArchivo() { return $this->archivo; } function getFechaRespuesta() { return $this->fechaRespuesta; } function getObservacionRespuesta() { return $this->observacionRespuesta; } function getArchivoRespuesta() { return $this->archivoRespuesta; } function setId($id) { $this->id = $id; } function setObservacion($observacion) { $this->observacion = $observacion; } function setTipo($tipo) { $this->tipo = $tipo; } function setActividad($actividad) { $this->actividad = $actividad; } function setClasificacion($clasificacion) { $this->clasificacion = $clasificacion; } function setArchivo($archivo) { $this->archivo = $archivo; } function setFechaRespuesta($fechaRespuesta) { $this->fechaRespuesta = $fechaRespuesta; } function setObservacionRespuesta($observacionRespuesta) { $this->observacionRespuesta = $observacionRespuesta; } function setArchivoRespuesta($archivoRespuesta) { $this->archivoRespuesta = $archivoRespuesta; } }
true
a15982025e05a0d7df2b6c5649d46c2bf98f2a04
PHP
josemalcher/Udemy-Curso-Completo-de-php-7
/09-poo/ex10-Autoload.php
UTF-8
548
2.6875
3
[]
no_license
<?php /*function __autoload($nomedaClasse){ require_once ("$nomedaClasse.php"); }*/ function incluirClasses($nomeClasse){ if(file_exists($nomeClasse.".php")===true){ require_once ($nomeClasse.".php"); } } spl_autoload_register("incluirClasses"); spl_autoload_register(function ($nomeClasse){ if(file_exists("NomePastaDaClasses".DIRECTORY_SEPARATOR.$nomeClasse.".php")===true){ require_once ("NomePastaDaClasses".DIRECTORY_SEPARATOR.$nomeClasse.".php"); } }); $carro = new DelRey(); echo $carro->acelerar(200);
true
0ab971a314fc1cb00227a23bcae0ed8340bf2462
PHP
declanmunroe/PHP-OOP
/application/services/Config.php
UTF-8
453
2.609375
3
[]
no_license
<?php class Application_Service_Config { public static function getStripePrivateKey($source) { // Right now I am using the same keys but its ready to use a different set of api keys based on source // Good way to work with two stripe accounts in same application code $api_key = ($source == 'skills') ? STRIPE_SECRET_KEY : (($source == 'member') ? STRIPE_SECRET_KEY : ''); return $api_key; } }
true
05a972a2b23981069eb0ca57b3156b60393cab78
PHP
masv87/ZfbUser
/src/Repository/TokenRepositoryInterface.php
UTF-8
773
2.65625
3
[ "MIT" ]
permissive
<?php namespace ZfbUser\Repository; use ZfbUser\Entity\TokenInterface; use ZfbUser\Entity\UserInterface; /** * Interface TokenRepositoryInterface * * @package ZfbUser\Repository */ interface TokenRepositoryInterface { /** * @param \ZfbUser\Entity\UserInterface $user * @param string $value * @param string $type * * @return null|\ZfbUser\Entity\TokenInterface */ public function getToken(UserInterface $user, string $value, string $type): ?TokenInterface; /** * @param \ZfbUser\Entity\UserInterface $user * @param string $type * * @return array */ public function getActualTokens(UserInterface $user, string $type): array; }
true
ed28d9133f9d7ff33d345e6e9135ca5cfee9d3a1
PHP
vr-davis-group/sql_integration
/read.php
UTF-8
600
2.84375
3
[]
no_license
<?php $servername = "localhost"; $serverusername = "root"; $serverpassword = ""; $databasename = "unity"; $conn = new mysqli($servername, $serverusername, $serverpassword, $databasename); if(!$conn){ die("Connection failed! ".mysqli_connect_error()); } $sql = "SELECT user_id, username, password FROM users"; $result = mysqli_query($conn, $sql); if(mysqli_num_rows($result) > 0){ while($row = mysqli_fetch_assoc($result)){ echo "ID:".$row['user_id']."|Username:".$row['username']."|Password:".$row['password'].";"; } } ?>
true
3bc2aea9f3c6d84ec214fd44e4d58fe09ec9d0df
PHP
d-marchuk93/bank
/src/Entity/Deposit.php
UTF-8
3,435
2.546875
3
[]
no_license
<?php namespace App\Entity; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity(repositoryClass="App\Repository\DepositRepository") */ class Deposit { /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") */ private $id; /** * @ORM\ManyToOne(targetEntity="App\Entity\Client", inversedBy="deposits") * @ORM\JoinColumn(nullable=false) */ private $client; /** * @ORM\Column(type="decimal", precision=10, scale=2) */ private $balance; /** * @ORM\Column(type="decimal", precision=10, scale=2) */ private $sum; /** * @ORM\Column(type="decimal", precision=5, scale=2) */ private $percent; /** * @ORM\ManyToOne(targetEntity="App\Entity\Currency", inversedBy="deposits") * @ORM\JoinColumn(nullable=false) */ private $currency; /** * @ORM\Column(type="datetime") */ private $date_opened; /** * @ORM\OneToMany(targetEntity="App\Entity\DepositFlow", mappedBy="deposit") */ private $depositFlows; public function __construct() { $this->depositFlows = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getClient(): ?Client { return $this->client; } public function setClient(?Client $client): self { $this->client = $client; return $this; } public function getBalance() { return $this->balance; } public function setBalance($balance): self { $this->balance = $balance; return $this; } public function getPercent() { return $this->percent; } public function setPercent($percent): self { $this->percent = $percent; return $this; } public function getSum() { return $this->sum; } public function setSum($sum): self { $this->sum = $sum; return $this; } public function getCurrency(): ?Currency { return $this->currency; } public function setCurrency(?Currency $currency): self { $this->currency = $currency; return $this; } public function getDateOpened(): ?\DateTimeInterface { return $this->date_opened; } public function setDateOpened(\DateTimeInterface $date_opened): self { $this->date_opened = $date_opened; return $this; } /** * @return Collection|DepositFlow[] */ public function getDepositFlows(): Collection { return $this->depositFlows; } public function addDepositFlow(DepositFlow $depositFlow): self { if (!$this->depositFlows->contains($depositFlow)) { $this->depositFlows[] = $depositFlow; $depositFlow->setDeposit($this); } return $this; } public function removeDepositFlow(DepositFlow $depositFlow): self { if ($this->depositFlows->contains($depositFlow)) { $this->depositFlows->removeElement($depositFlow); // set the owning side to null (unless already changed) if ($depositFlow->getDeposit() === $this) { $depositFlow->setDeposit(null); } } return $this; } }
true
2d7be2b4007b34760c2aac888d99933ae5f5da70
PHP
thierryHalot/decouverte-php-mysql
/openClassroom/test/fonctionPhp.php
UTF-8
2,018
3.875
4
[]
no_license
<?php /** * Created by PhpStorm. * User: thierry * Date: 25/04/18 * Time: 13:48 */ // la fonction strlen retourne la longueur d'une chaine,c'est a dire le nombre de caractère,espace compris ! $phrase = 'Bonjour je suis une longue chaine de caractere!!'; $longueur = strlen($phrase); echo "la phrase stoquer dans la variable 'longueur' comporte ". $longueur . " caracteres <br/>"; //la fonction str_replace cherche un caractère et le remplace par celui que l'on souhaite $maVariable = str_replace('e', '3',$phrase); echo "j'ai remplacer tous les e de la phrase du haut par des 3 : <br /> ". $maVariable . "<br/>"; //la fonction str_shuffle permet de melanger les caractere d'une phrase $melangeMoi = str_shuffle($phrase); echo "maintenant je vais melanger les carateres de cette phrases : <br />". $melangeMoi . "<br/>"; //la fonction strtoupper transforme ma phrase en majuscule et strtolower fait l'inverse $majusculeMoi = strtoupper($phrase); echo "Si je souhaite que m'a phrase sois tous en majuscule : <br />". $majusculeMoi . "<br />"; //maintenant utilisons la fonction date, comme son nom l'indique elle permet de nous renvoyé la date //pour avoir juste l'année $annee = date('Y'); echo "Nous somme en : ".$annee."<br/>"; //pour le jour $jour = date('d'); echo "le jour d'aujourd'hui : ".$jour."</br>"; $mois = date('m'); echo "le mois d'aujourd'hui : ". $mois."<br>"; $heure = date('H'); echo "Il est ".$heure." heure"."<br />"; $minute = date('i'); echo "et ".$minute." minutes<br />"; // creation d 'une fonction avec pour parametre un nom !! function direBonjour($nom){ echo 'Bonjour '.$nom.' !<br />'; }; direBonjour('moi meme !'); //fonction qui calcule le volume d'un cone function volumeCone($rayon, $hauteur){ $volume = $rayon * $rayon * 3.14 * $hauteur * (1/3); // calcul du volume return $volume;//indique la valeur a renvoyer !! } $volume = volumeCone(5,2); echo "le volume d'un cone de rayon 5 et de hauteur 2 est de ". $volume."<br />";
true
28cc48d9dc597ec937492b8f4c5f6a1e863b465d
PHP
AlifArnado/project_destinasi-using-yii
/protected/views/tblPegawai/tampilkan.php
UTF-8
938
2.546875
3
[]
no_license
<style type="text/css" media="screen"> table.dataGrid { border-collapse: collapse; border: 1px solid balck; width: 100%; #font-size: 8px; } table.dataGrid td { border: 1px solid black; padding: 5px 5px 5px 5px; } </style> <h2 align="center">DAFTAR PEGAWAI</h2> <table class="dataGrid"> <tr> <th>NO</th> <th>NIP</th> <th>NAMA</th> <th>ALAMAT</th> <th>TANGGAL LAHIR</th> <th>AGAMA</th> </tr> <?php $no = 1; foreach ($row as $pegawai): ?> <tr> <td><?php echo $no++; ?></td> <td><?php echo $pegawai['nip']; ?></td> <td><?php echo $pegawai['nama']; ?></td> <td><?php echo $pegawai['alamat']; ?></td> <td><?php echo $pegawai['tanggal_lahir']; ?></td> <td><?php echo $pegawai['agama']; ?></td> </tr> <?php endforeach ?> </table>
true
7075852d45981ca7f01b6050f14c1034ba8a8780
PHP
JoelDichamp/angular_events_API
/models/User.php
UTF-8
671
2.828125
3
[]
no_license
<?php class User extends Model implements JsonSerializable { private $username; private $pwd; public function getUsername() { return $this->username; } public function setUsername($username) { $this->username = $username; return $this; } public function getPwd() { return $this->pwd; } public function setPwd($pwd) { $this->pwd = $pwd; return $this; } public function jsonSerialize() { return [ "id" => $this->id, "username" => $this->username, "pwd" => $this->pwd ]; } }
true
ce548aac2ec3e7cbc8b1fa374d7f53eba811c668
PHP
icekristal/smsint-for-laravel
/src/Services/InitTrait.php
UTF-8
3,081
2.6875
3
[ "MIT" ]
permissive
<?php namespace Icekristal\SmsintForLaravel\Services; use Carbon\Carbon; trait InitTrait { private array $params = []; private ?string $message = null; private ?array $recipients = null; private ?string $senderName = null; private bool $isOnlyValid = false; private ?Carbon $startDateTime = null; /** * @return string|null */ public function getMessage(): ?string { return $this->message; } /** * @param string|null $message * @return IceSmsintService */ public function setMessage(?string $message): IceSmsintService { $this->message = $message; return $this; } public function setParams(array $params): static { $this->params = $params; return $this; } /** * @return array */ public function getParams(): array { if (!is_null($this->getRecipients())) { $this->params['recipients'] = $this->getRecipients(); } if (!is_null($this->getSenderName())) { $this->params['source'] = $this->getSenderName(); } else { $this->params['source'] = config('smsint.default_sender_name', 'source'); } if (!is_null($this->getMessage())) { $this->params['message'] = $this->getMessage(); } $this->params['startDateTime'] = !is_null($this->getStartDateTime()) ? $this->getStartDateTime() : null; $this->params['is_only_validate'] = $this->getIsOnlyValid(); return $this->params; } /** * @return array */ public function getRecipients(): array { return $this->recipients; } /** * @param array $recipients * @return IceSmsintService */ public function setRecipients(array $recipients): IceSmsintService { $this->recipients = $recipients; return $this; } /** * @return string|null */ public function getSenderName(): ?string { return $this->senderName; } /** * @param string|null $senderName * @return IceSmsintService */ public function setSenderName(?string $senderName): IceSmsintService { $this->senderName = $senderName; return $this; } /** * @return bool */ public function getIsOnlyValid(): bool { return $this->isOnlyValid; } /** * @param bool $isOnlyValid * @return IceSmsintService */ public function setIsOnlyValid(bool $isOnlyValid): IceSmsintService { $this->isOnlyValid = $isOnlyValid; return $this; } /** * @return Carbon|string|null */ public function getStartDateTime(): Carbon|string|null { return $this->startDateTime?->format('Y-m-d H:i:s'); } /** * @param Carbon|null $startDateTime * @return IceSmsintService */ public function setStartDateTime(?Carbon $startDateTime): IceSmsintService { $this->startDateTime = $startDateTime; return $this; } }
true
0396f153adcb64ed07e7a1167cc311f9198e5182
PHP
yourant/custom-service
/modules/orders/models/OrderPackageKefu.php
UTF-8
1,130
2.59375
3
[ "BSD-3-Clause" ]
permissive
<?php namespace app\modules\orders\models; use Yii; use app\components\Model; class OrderPackageKefu extends Model { /** * 返回当前模型连接的数据库 */ public static function getDb() { return Yii::$app->db_order; } /** * 返回当前模型的表名 */ public static function tableName() { return '{{%order_package}}'; } /** * 获取订单包裹信息 */ public static function getOrderPackages($orderId) { return self::find() ->from(self::tableName()) ->where(['order_id' => $orderId]) ->asArray() ->all(); } /** * 获取仓库id * @param $orderId * @return array|\yii\db\ActiveRecord[] */ public static function getOrderPackageWareHouseId($orderId) { $warehouse_id=self::find() ->from(self::tableName()) ->select(['warehouse_id']) ->where(['order_id' => $orderId]) ->asArray() ->one(); return isset($warehouse_id)?$warehouse_id['warehouse_id']:0; } }
true
2a25d390032bbebb25655dcc64d724eea875dcea
PHP
adriftcloud/ShopCart
/app/Models/Image.php
UTF-8
840
2.5625
3
[ "MIT" ]
permissive
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; /** * App\Models\Image * * @property-read mixed $file * @mixin \Eloquent * @property int $id * @property \Carbon\Carbon|null $created_at * @property \Carbon\Carbon|null $updated_at * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Image whereCreatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Image whereFile($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Image whereId($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Image whereUpdatedAt($value) */ class Image extends Model { protected $uploads = '/images/'; protected $fillable = ['file']; public function getFileAttribute($photo) { return $this->uploads . $photo; } }
true
d32a89003d0468571d51796b8b2a0d2b02479444
PHP
niamurndc/ff-tournament
/result.php
UTF-8
1,276
2.5625
3
[]
no_license
<?php include('header.php'); ?> <h2>Results</h2> <?php $query = "SELECT * FROM matches WHERE status = 1"; $result = mysqli_query($conn, $query); $matchs = mysqli_fetch_all($result, MYSQLI_ASSOC); foreach($matchs as $match){ ?> <div class="board"> <a class="view-tag" href="view_result.php?id=<?php echo $match['id']; ?>"> <div class="board-head"> <img src="<?php echo $logo_image; ?>" class="match-logo"> <div> <h5><?php echo $match['name']; ?></h5> <p>Time <?php echo $match['time']; ?></p> </div> </div> <div class="board-body"> <div class="point"> <p>Total Price</p> <h6><?php echo $match['prize']; ?></h6> </div> <div class="point"> <p>Per Kill</p> <h6><?php echo $match['pkill']; ?></h6> </div> <div class="point"> <p>Entry Fee</p> <h6><?php echo $match['entry']; ?></h6> </div> <div class="point"> <p>Type</p> <h6><?php echo $match['mtype']; ?></h6> </div> <div class="point"> <p>Map</p> <h6><?php echo $match['map']; ?></h6> </div> </div></a> <div class="board-foot"> <a href="view_result.php?id=<?php echo $match['id']; ?>" class="btn btn-dark">View Price</a> </div> </div> <?php } ?> <?php include('footer.php'); ?>
true
0b28e21acee8940e800677dbe732d93dfb57ee90
PHP
wrong-about-everything/tindergram
/src/Infrastructure/Routing/Route/RouteByMethodAndPathPatternWithQuery.php
UTF-8
1,070
2.53125
3
[]
no_license
<?php declare(strict_types=1); namespace TG\Infrastructure\Routing\Route; use TG\Infrastructure\Http\Request\Inbound\Request; use TG\Infrastructure\Http\Request\Method; use TG\Infrastructure\Http\Request\Url\Query\FromUrl as QueryFromUrl; use TG\Infrastructure\Routing\MatchResult; use TG\Infrastructure\Routing\MatchResult\CombinedMatch; use TG\Infrastructure\Routing\MatchResult\Match; use TG\Infrastructure\Routing\Route; class RouteByMethodAndPathPatternWithQuery implements Route { private $method; private $pathPattern; public function __construct(Method $method, string $pathPattern) { $this->method = $method; $this->pathPattern = $pathPattern; } public function matchResult(Request $request): MatchResult { $matchResult = (new RouteByMethodAndPathPattern($this->method, $this->pathPattern))->matchResult($request); if (!$matchResult->matches()) { return $matchResult; } return new CombinedMatch($matchResult, new Match([new QueryFromUrl($request->url())])); } }
true
bdb97c07c80cb7638910e2cc594fb55b8c0f529f
PHP
sanjay7500/sanjay.github.io
/loop7.php
UTF-8
203
3.046875
3
[]
no_license
<?php for($i=1; $i<=5; $i++) { for($x=4; $x>=$i; $x--) { echo "&nbsp&nbsp"; } for($j=1; $j<=$i; $j++) { echo "*"; } for($j=2; $j<=$i; $j++) { echo "*"; } echo "<br>"; } ?>
true