<commit_before><?php
/*

#
# Collective Knowledge (CK web service)
#
# See CK LICENSE.txt for licensing details
# See CK Copyright.txt for copyright details
#
# Developer: <NAME>, 2014-2015
#

*/

 # initalize path to CK
 $ckr=getenv("CK_ROOT"); 
 if ($ckr=="") $ckr=getcwd();

 # Load configuration 
 $pcfg=$ckr . '/repo/module/web/.cm/meta.json';

 $cfg=array();

 if (!file_exists($pcfg)) 
 {
   $er="Internal CK web service error (Can\'t find meta.json)";
   if ($xt=='json')
   {
     header("content-type: application/json; charset=UTF-8"); 
     print '{"return":1, "error":"'.$er.'"}';
   }
   else
   {
     header("content-type: text/html; charset=UTF-8"); 
     print $er;
   }
   return;
 }

 try
 {
    $x=file_get_contents($pcfg);
    $cfg=json_decode($x,true);
 } 
 catch(Exception $e)
 {
   $er="Internal CK web service error (can't parse web meta.json)";
   if ($xt=='json')
   {
     header("content-type: application/json; charset=UTF-8"); 
     print '{"return":1, "error":"'.$er.'"}';
   }
   else
   {
     header("content-type: text/html; charset=UTF-8"); 
     print $er;
   }
   exit(1);
 }

 # Load OpenME for CK
 $om=$ckr . '/repo/module/web/php/openme.php';

 # Check if library exists
 if (!file_exists($om)) {
   $er="Internal CK web service error (Can\'t find openme.php)";
   if ($xt=='json')
   {
     header("content-type: application/json; charset=UTF-8"); 
     print '{"return":1, "error":"'.$er.'"}';
   }
   else
   {
     header("content-type: text/html; charset=UTF-8"); 
     print $er;
   }
   return;
 }
 else
   require_once $om;

 # Get web environment variables
 $session=$_SESSION;
 $cookie=$_COOKIE;
 $get=openme_web_to_array($_GET, "");
 $post=openme_web_to_array($_POST, "");
 $files=openme_web_file_to_array($_FILES, "");

 $ii=$get;

 $ii=array_merge($ii, $files);

 $o="";

 # Process ck_json
 $ii=array_merge($ii, $post);

 if (array_key_exists("ck_json", $ii) && $ii['ck_json']!='')
 {
   try
   {
     $jd=json_decode(urldecode($ii["ck_json"]),TRUE);
   } 
   catch(Exception $e)
   {
     openme_web_err($cfg, $xt, 1, $e->getMessage());
     exit(1);
   }

   unset($ii["ck_json"]);
   $ii=array_merge($ii, $jd);
 }
<commit_msg>fixing remote access to server for empty arrays/list (trick in PHP)<commit_after><?php
/*

#
# Collective Knowledge (CK web service)
#
# See CK LICENSE.txt for licensing details
# See CK Copyright.txt for copyright details
#
# Developer: <NAME>, 2014-2015
#

*/

 # initalize path to CK
 $ckr=getenv("CK_ROOT"); 
 if ($ckr=="") $ckr=getcwd();

 # Load configuration 
 $pcfg=$ckr . '/repo/module/web/.cm/meta.json';

 $cfg=array();

 if (!file_exists($pcfg)) 
 {
   $er="Internal CK web service error (Can\'t find meta.json)";
   if ($xt=='json')
   {
     header("content-type: application/json; charset=UTF-8"); 
     print '{"return":1, "error":"'.$er.'"}';
   }
   else
   {
     header("content-type: text/html; charset=UTF-8"); 
     print $er;
   }
   return;
 }

 try
 {
    $x=file_get_contents($pcfg);
    $cfg=json_decode($x,true);
 } 
 catch(Exception $e)
 {
   $er="Internal CK web service error (can't parse web meta.json)";
   if ($xt=='json')
   {
     header("content-type: application/json; charset=UTF-8"); 
     print '{"return":1, "error":"'.$er.'"}';
   }
   else
   {
     header("content-type: text/html; charset=UTF-8"); 
     print $er;
   }
   exit(1);
 }

 # Load OpenME for CK
 $om=$ckr . '/repo/module/web/php/openme.php';

 # Check if library exists
 if (!file_exists($om)) {
   $er="Internal CK web service error (Can\'t find openme.php)";
   if ($xt=='json')
   {
     header("content-type: application/json; charset=UTF-8"); 
     print '{"return":1, "error":"'.$er.'"}';
   }
   else
   {
     header("content-type: text/html; charset=UTF-8"); 
     print $er;
   }
   return;
 }
 else
   require_once $om;

 # Get web environment variables
 $session=$_SESSION;
 $cookie=$_COOKIE;
 $get=openme_web_to_array($_GET, "");
 $post=openme_web_to_array($_POST, "");
 $files=openme_web_file_to_array($_FILES, "");

 $ii=$get;

 $ii=array_merge($ii, $files);

 $o="";

 # Process ck_json
 $ii=array_merge($ii, $post);

 if (array_key_exists("ck_json", $ii) && $ii['ck_json']!='')
 {
   try
   {
     $jd=json_decode(urldecode($ii["ck_json"]));//,TRUE);
   } 
   catch(Exception $e)
   {
     openme_web_err($cfg, $xt, 1, $e->getMessage());
     exit(1);
   }

   unset($ii["ck_json"]);
   $ii=array_merge($ii, get_object_vars($jd));
 }

{'fraction_non_alphanumeric': 0.20440746570721835, 'fraction_numerical': 0.008994827973915, 'mean_word_length': 3.377952755905512, 'pattern_counts': {'":': 12, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7533143', 'n_tokens_mistral': 1754, 'n_tokens_neox': 1662, 'n_words': 328}