Example #1
0
function array2json($arr)
{
    //if(function_exists('json_encode')) return json_encode($arr); //Lastest versions of PHP already has this functionality.
    $parts = array();
    $is_list = false;
    //Find out if the given array is a numerical array
    $keys = array_keys($arr);
    $max_length = count($arr) - 1;
    if ($keys[0] == 0 and $keys[$max_length] == $max_length) {
        //See if the first key is 0 and last key is length - 1
        $is_list = true;
        for ($i = 0; $i < count($keys); $i++) {
            //See if each key correspondes to its position
            if ($i != $keys[$i]) {
                //A key fails at position check.
                $is_list = false;
                //It is an associative array.
                break;
            }
        }
    }
    foreach ($arr as $key => $value) {
        if (is_array($value)) {
            //Custom handling for arrays
            if ($is_list) {
                $parts[] = array2json($value);
            } else {
                $parts[] = '"' . $key . '":' . array2json($value);
            }
            /* :RECURSION: */
        } else {
            $str = '';
            if (!$is_list) {
                $str = '"' . $key . '":';
            }
            //Custom handling for multiple data types
            if (is_numeric($value)) {
                $str .= $value;
            } elseif ($value === false) {
                $str .= 'false';
            } elseif ($value === true) {
                $str .= 'true';
            } else {
                $str .= '"' . addslashes($value) . '"';
            }
            //All other things
            $parts[] = $str;
        }
    }
    $json = implode(',', $parts);
    if ($is_list) {
        return '[' . $json . ']';
    }
    //Return numerical JSON
    return '{' . $json . '}';
    //Return associative JSON
}
Example #2
0
 public function reg()
 {
     $data = $_POST;
     foreach ($data as $key => $rec) {
         if (empty($rec)) {
             $data['error'] = $key;
             break;
         }
     }
     echo array2json($data);
     exit;
 }
Example #3
0
 public static function array2json(array $arr)
 {
     $parts = array();
     $is_list = false;
     if (count($arr) > 0) {
         //Find out if the given array is a numerical array
         $keys = array_keys($arr);
         $max_length = count($arr) - 1;
         if ($keys[0] === 0 and $keys[$max_length] === $max_length) {
             //See if the first key is 0 and last key is length - 1
             $is_list = true;
             for ($i = 0; $i < count($keys); $i++) {
                 //See if each key correspondes to its position
                 if ($i !== $keys[$i]) {
                     //A key fails at position check.
                     $is_list = false;
                     //It is an associative array.
                     break;
                 }
             }
         }
         foreach ($arr as $key => $value) {
             $str = !$is_list ? '"' . $key . '":' : '';
             if (is_array($value)) {
                 //Custom handling for arrays
                 $parts[] = $str . array2json($value);
             } else {
                 //Custom handling for multiple data types
                 if (is_numeric($value) && !is_string($value)) {
                     $str .= $value;
                     //Numbers
                 } elseif (is_bool($value)) {
                     $str .= $value ? 'true' : 'false';
                 } elseif ($value === null) {
                     $str .= 'null';
                 } else {
                     $str .= '"' . addslashes($value) . '"';
                     //All other things
                 }
                 $parts[] = $str;
             }
         }
     }
     $json = implode(',', $parts);
     if ($is_list) {
         return '[' . $json . ']';
     }
     //Return numerical JSON
     return '{' . $json . '}';
     //Return associative JSON
 }
 function drawHand()
 {
     // draw HTML from class variables
     $card_html = array("H" => '&hearts;', "S" => '&spades;', "C" => '&clubs;', "D" => '&diams;');
     $ht_array = array();
     $ht_array['table_id'] = $this->table_id;
     $ht_array['dealer_position'] = $this->dealer_position;
     $ht_array['numberof_players'] = $this->numberof_players;
     $ht_array['last_error'] = $this->last_error;
     $ht_array['last_error_code'] = $this->last_error_code;
     $ht_array['last_message'] = $this->last_message;
     //			$ht_array['main_action'] = "<a class=\"actions\" onclick=\"playTurn()\"><b>Refresh</b></a>";
     $ht_array['main_action'] = $this->currentStateHtml();
     // following 3 lines was for initial testing to start game manually.
     //			$ht_array['main_action'] = "";
     //			if($this->current_state==0 || $this->current_state==H_STATE_SHOWDOWN || $this->current_state==H_STATE_CLOSED)
     //				$ht_array['main_action'] = "<a class=\"actions\" onclick=\"playTurn()\"><b>Refresh</b></a>";
     for ($i = 0; $i < 5; $i++) {
         if (isset($this->community_cards[$i])) {
             $card = $this->community_cards[$i];
             $url = '<img src="images/' . $card['value'] . $card['suit'] . '.jpg" border=0>';
         } else {
             $url = "";
         }
         $ht_array['community_cards'][] = $url;
     }
     $ht_array['pots'] = $this->pots;
     if (count($ht_array['pots']) == 0) {
         $ht_array['pots'] = array("");
     }
     // player data: $player_id $nick_name $table_stack $pocket_cards $current_share $current_state
     for ($i = 1; $i <= $this->numberof_players; $i++) {
         $pa = array();
         if (isset($this->hand_players[$i])) {
             $p = $this->hand_players[$i];
             $pa['player_id'] = $p->player_id;
             $pa['nick_name'] = $p->nick_name;
             $pa['table_stack'] = $p->table_stack;
             $pa['current_share'] = $p->current_share;
             $pa['action_url'] = "";
             $pa['pocket_cards'] = array("", "");
             $pa['current_state'] = $this->playerStateHtml($p->current_state);
             if ($this->current_state == H_STATE_SHOWDOWN) {
                 $pa['table_stack'] = $p->win_html;
             }
             if ($p->current_state == P_STATE_SITTING_OUT) {
                 $pa['table_stack'] = "Sitting Out";
             }
             $pa['action_url'] = $this->playerActionHtml($p);
             if (count($p->pocket_cards) > 0 && $p->player_id == $this->request['request_player_id'] || $this->current_state == H_STATE_SHOWDOWN && $p->current_state == P_STATE_WAITING) {
                 unset($pa['pocket_cards']);
                 for ($j = 0; $j < count($p->pocket_cards); $j++) {
                     $card = $p->pocket_cards[$j];
                     $suit = $card['suit'];
                     $pa['pocket_cards'][] = '<img src="images/' . $card['value'] . $card['suit'] . '.jpg" border=0>';
                 }
                 $this->addAnimation("pocket_cards" . $p->table_position);
             } else {
                 $pa['pocket_cards'] = array('<img src="images/back.jpg" border=0>', '<img src="images/back.jpg" border=0>');
             }
         } else {
             $pa['player_id'] = 0;
             $pa['nick_name'] = "<a class=\"actions1\" onclick=\"playSitOn(" . P_ACTION_SIT . ",{$i})\"><b>Sit On</b></a>";
             $pa['table_stack'] = "";
             $pa['pocket_cards'] = array("", "");
             $pa['current_share'] = "";
             $pa['action_url'] = "";
             $pa['current_state'] = "Empty";
         }
         $ht_array['players'][] = $pa;
     }
     $ht_array['animation_queue'] = $this->animation_queue;
     echo array2json($ht_array);
 }
Example #5
0
function cpjson($obj)
{
    if (ob_get_contents()) {
        ob_end_clean();
    }
    if (function_exists("json_encode")) {
        echojson(array2json($obj));
    } else {
        include_once dirname(__FILE__) . "/../pacotes/cpaint/cpaint2.inc.php";
        $cp = new cpaint();
        $cp->set_data($obj);
        $cp->return_data();
        exit;
    }
}
Example #6
0
}
$_SESSION["_current_file"] = $file;
$_level_key_name = $_SESSION['_level_key_name'];
$data = html_entity_decode(base64_decode($_POST['data']), ENT_QUOTES, "UTF-8");
if (copy($path, $path_tmp) == false) {
    echo "2###";
    exit;
}
if (@file_put_contents($path, $data, LOCK_EX) === false) {
    $error = true;
    echo "3###";
} else {
    $result = test_conf();
    if ($result !== true) {
        $error = true;
        echo "4###" . $result;
    } else {
        $xml_obj = new xml($_level_key_name);
        $xml_obj->load_file($path);
        $array_xml = $xml_obj->xml2array();
        $tree_json = array2json($array_xml, $path);
        $_SESSION['_tree_json'] = $tree_json;
        $_SESSION['_tree'] = $array_xml;
        echo "5###" . base64_encode($tree_json);
    }
}
if ($error == true) {
    @unlink($path);
    @copy($path_tmp, $path);
}
@unlink($path_tmp);
function fetchVocabularyService($task, $arg, $output = "xml")
{
    $evalParam = evalServiceParam($task, $arg);
    //Verificar servicio habilitado
    if (CFG_SIMPLE_WEB_SERVICE !== "1" || !$task) {
        $service = new XMLvocabularyServices();
        return array2xml($service->describeService());
        // Controlar parametros
    } elseif (@$evalParam["error"]) {
        $service = new XMLvocabularyServices();
        return array2xml($service->describeService($evalParam));
        // Los param esta bien
    } else {
        $task = $evalParam["task"];
        $arg = $evalParam["arg"];
        $service = new XMLvocabularyServices();
        switch ($task) {
            //array
            case 'fetch':
                $response = $service->fetchExactTerm($arg);
                break;
                //array
            //array
            case 'search':
                $response = $service->fetchTermsBySearch($arg);
                break;
                //array
            //array
            case 'searchNotes':
                $response = $service->fetchTermsBySearchNotes($arg);
                break;
                //array
            //array
            case 'suggest':
                $response = $service->fetchSuggested($arg);
                break;
                //array
            //array
            case 'suggestDetails':
                $response = $service->fetchSuggestedDetails($arg);
                break;
                //array (tema_id,tema)
            //array (tema_id,tema)
            case 'fetchSimilar':
                $response = $service->fetchSimilar($arg);
                break;
            case 'fetchRelated':
                // array (tema_id, tema,t_relacion_id)
                $response = $service->fetchRelatedTerms($arg);
                break;
            case 'fetchAlt':
                // array (tema_id, tema,t_relacion_id)
                $response = $service->fetchAltTerms($arg);
                break;
            case 'fetchDown':
                // Devuelve lista de temas especificos
                // array (tema_id, tema,t_relacion_id, hasMoreDown)
                $response = $service->fetchTermDown($arg);
                break;
            case 'fetchUp':
                // Devuelve arbol de temas genericos
                // array(tema_id,string,relation_type_id,order)
                $response = $service->fetchTermUp($arg);
                break;
            case 'fetchTermFull':
                // Devuelve detalles competos de un tema (tema + notas)
                // array(tema_id,string,hasMoreUp,term_type,date_create,date_mod,numNotes)
                break;
            case 'fetchTerm':
                // Devuelve detalles de un tema
                // array(tema_id,string)
                $response = $service->fetchTermDetailsBrief($arg);
                break;
            case 'fetchCode':
                // Devuelve detalles de un tema
                // array(tema_id,string)
                $response = $service->fetchCode($arg);
                break;
            case 'fetchNotes':
                // Devuelve notas de un tema
                // array(tema_id,string,note_id,note_type,note_lang,note_text)
                $response = $service->fetchTermNotes($arg);
                break;
            case 'fetchTopTerms':
                // Array de términos tope
                // array(tema_id,string)
                $response = $service->fetchTopTerms($arg);
                break;
            case 'fetchLast':
                // Array de últimos términos creados
                // array(tema_id,string)
                $response = $service->fetchLast();
                break;
            case 'fetchDirectTerms':
                // Array de términos vinculados directamente con el termino (TG,TR,UF)
                // array(tema_id,string,relation_type_id)
                $response = $service->fetchDirectTerms($arg);
                break;
            case 'fetchTerms':
                // Devuelve lista de términos para una lista separada por comas de tema_id
                // array(tema_id,string)
                $response = $service->fetchTermsByIds($arg);
                break;
            case 'fetchRelatedTerms':
                // Devuelve lista de términos relacionados para una lista separada por comas de tema_id
                // array(tema_id,string)
                $response = $service->fetchRelatedTermsByIds($arg);
                break;
            case 'fetchTargetTerms':
                // Devuelve lista de términos mapeados para un tema_id
                // array(tema_id,string)
                $response = $service->fetchTargetTermsById($arg);
                break;
            case 'fetchURI':
                // Devuelve lista de enlaces linkeados para un tema_id
                // list of foreign links to term
                // array(type link,link)
                $response = $service->fetchURI($arg);
                break;
                //~ case 'fetchSourceTermsURI':
                //~ // Devuelve lista de términos propios que están mapeados para una URI provista por un término externo
                //~ // list of source terms who are mapped by URI provided by target vocabulary.
                //~ // array(tema_id,string,code,lang,date_create,date_mod)
                //~ $response = $service-> fetchSourceTermsByURI(rawurldecode($arg));
                //~ break;
            //~ case 'fetchSourceTermsURI':
            //~ // Devuelve lista de términos propios que están mapeados para una URI provista por un término externo
            //~ // list of source terms who are mapped by URI provided by target vocabulary.
            //~ // array(tema_id,string,code,lang,date_create,date_mod)
            //~ $response = $service-> fetchSourceTermsByURI(rawurldecode($arg));
            //~ break;
            case 'fetchSourceTerms':
                // Devuelve lista de términos propios que están mapeados para un determinado término
                // list of source terms who are mapped for a given term  provided by ANY target vocabulary.
                // array(tema_id,string,code,lang,date_create,date_mod)
                $response = $service->fetchSourceTerms($arg);
                break;
            case 'letter':
                // Array de términos que comienzan con una letra
                // array(tema_id,string,no_term_string,relation_type_id)
                // sanitice $letter
                $arg = trim(urldecode($arg));
                // comment this line for russian chars
                //$arg=secure_data($arg,"alnum");
                $response = $service->fetchTermsByLetter($arg);
                break;
            case 'fetchVocabularyData':
                // Devuelve detalles del vocabularios
                //array(vocabulario_id,titulo,autor,idioma,cobertura,keywords,tipo,cuando,url_base)
                $response = $service->fetchVocabularyData("1");
                break;
            default:
                $response = $service->describeService();
                break;
        }
        global $CFG;
        $arrayResume['status'] = CFG_SIMPLE_WEB_SERVICE == '1' ? 'available' : 'disable';
        $arrayResume['param'] = array("task" => $task, "arg" => $arg);
        $arrayResume['web_service_version'] = $CFG["VersionWebService"];
        $arrayResume['version'] = $CFG["Version"];
        $arrayResume["cant_result"] = count($response["result"]);
        $response["resume"] = $arrayResume;
        $xml_resume = array2xml($arrayResume, $name = 'resume', $standalone = FALSE, $beginning = FALSE);
        $xml_response = array2xml($response, $name = 'terms', $standalone = TRUE, $beginning = FALSE, $nodeChildName = 'term');
        switch ($output) {
            case 'json':
                header('Content-type: application/json');
                return array2json($response, 'vocabularyservices');
                break;
            case 'skos':
                header('Content-Type: text/xml');
                return $_SESSION[$_SESSION["CFGURL"]]["_PUBLISH_SKOS"] == '1' ? array2skos($response, 'vocabularyservices') : array2xml($response, 'vocabularyservices');
                break;
            default:
                header('Content-Type: text/xml');
                return array2xml($response, 'vocabularyservices');
        }
    }
}
Example #8
0
    $output = utf8_decode($output);
    if (@file_put_contents($path, $output, LOCK_EX) === false) {
        echo "2###" . _("Failure to update XML File") . " (3)";
        $error = true;
    } else {
        $res = getTree($file);
        if (!is_array($res)) {
            echo $res;
            $error = true;
        } else {
            $tree = $res;
            $tree_json = array2json($tree, $path);
            $_SESSION['_tree_json'] = $tree_json;
            $_SESSION['_tree'] = $tree;
            $result = test_conf();
            if ($result !== true) {
                $error = true;
                echo "3###" . $result;
            }
        }
    }
}
if ($error == true) {
    @unlink($path);
    @copy($path_tmp, $path);
    $_SESSION['_tree'] = $tree_cp;
    $_SESSION['_tree_json'] = array2json($tree_cp, $path);
} else {
    echo "1###" . _("XML file update successfully") . "###" . base64_encode($tree_json);
}
@unlink($path_tmp);
Example #9
0
if (!$memm->is_login()) {
    exit("NoLogin");
}
if (!$memm->MemConnect($type, $curcon)) {
    exit("ConnectFail");
}
$thekey = str_replace("_ _rd", "'", $data[0]['key']);
$thekey = str_replace("_ _rx", "\\", $thekey);
$keylist = explode(" ", $thekey);
$list = $memm->MemGet($keylist);
$relist = array();
$relist[0] = array();
$relist[1] = array();
foreach ($list[0] as $key => $value) {
    $newkey = urlencode($key);
    $relist[0][$newkey] = array();
    if (is_array($value)) {
        $relist[0][$newkey][0] = serialize($value);
    } elseif (gettype($value) == 'object') {
        $relist[0][$newkey][0] = serialize($value);
    } else {
        $relist[0][$newkey][0] = $value;
    }
    $relist[0][$newkey][1] = gettype($value);
}
foreach ($list[1] as $key => $value) {
    $newkey = urlencode($key);
    $relist[1][$newkey] = $value;
}
echo array2json($relist, $cs);
Example #10
0
 public function update($field)
 {
     $field_value = $_POST['field_value'];
     $id = $_POST['id'];
     if ($this->isAdmin && $this->validateField($field, $field_value) && $this->validateField('id', $id)) {
         //эта часть запроса общая для всех
         $query = "UPDATE banlist SET {$field} = ?";
         $d1_return = NULL;
         $d2_return = NULL;
         $is_blocked = isset($_POST['is_blocked']) ? $_POST['is_blocked'] : NULL;
         /*  Если пользователь на данный момент разблокирован, 
          *   а мы хотим установить дату блокировки > даты разблокировки
          *   => нужно заблокировать пользователя, а дату разблокировки поставить NULL.
          *   
          *   Если же пользователь на данный момент заблокирован, а мы хотим поставить 
          *   дату разблокировки > даты блокировки
          *   => пользователя нужно разблокировать.
          */
         if (($field === 'block_date' || $field === 'unblock_date') && $this->validateField('block_date', $_POST['block_date']) && $this->validateField('unblock_date', $_POST['unblock_date'])) {
             $d1 = new DateTime($_POST['block_date']);
             $d2 = new DateTime($_POST['unblock_date']);
             if ($d1 > $d2) {
                 $query .= ", unblock_date = NULL, is_blocked = 1";
                 $is_blocked = 1;
             } else {
                 $query .= ", is_blocked = 0";
                 $is_blocked = 0;
             }
             $d1_return = $d1->format('d.m.Y H:i:s');
             $d2_return = $d2->format('d.m.Y H:i:s');
         }
         //Если пользователь разблокирован - устанавливаем дату разблокировки на текущую,
         // заблокирован - дату блокировки на текущую, дату разблокировки удаляем:
         if ($field === 'is_blocked') {
             $date = new DateTime();
             $insert_date = $date->format('Y-m-d H:i:s');
             $return_date = $date->format('d.m.Y H:i:s');
             $query = $_POST['field_value'] == 0 ? $query . ", unblock_date = '{$insert_date}'" : $query . ", block_date = '{$insert_date}', unblock_date = NULL";
         }
         $query .= " WHERE id = ?";
         if ($field === 'block_date' || $field === 'unblock_date') {
             $date = new DateTime($field_value);
             $field_value = $date->format('Y-m-d H:i:s');
         }
         $this->db->query($query, $field_value, $id);
         $this->log->write("Изменена запись id: {$id}, поле: {$field}, значение: {$field_value}");
         if ($field === 'is_blocked') {
             echo array2json(array('date' => $return_date));
         } else {
             echo array2json(array('field' => $field_value, 'block_date' => $d1_return, 'unblock_date' => $d2_return, 'is_blocked' => $is_blocked));
         }
     } else {
         echo array2json(array('error' => $this->error_msg));
     }
 }
Example #11
0
function array2json($arr, $jse = 1)
{
    if ($jse == 1) {
        if (function_exists('json_encode')) {
            return json_encode($arr);
            //Lastest versions of PHP already has this functionality.
        }
    } else {
        $parts = array();
        $is_list = false;
        if (!is_array($arr)) {
            return;
        }
        if (count($arr) < 1) {
            return '{}';
        }
        //Выясняем, данный  массив это числовой массив?!
        $keys = array_keys($arr);
        $max_length = count($arr) - 1;
        if ($keys[0] == 0 and $keys[$max_length] == $max_length) {
            //See if the first key is 0 and last key is length - 1
            $is_list = true;
            for ($i = 0; $i < count($keys); $i++) {
                //See if each key correspondes to its position
                if ($i != $keys[$i]) {
                    //A key fails at position check.
                    $is_list = false;
                    //It is an associative array.
                    break;
                }
            }
        }
        foreach ($arr as $key => $value) {
            if (is_array($value)) {
                //Custom handling for arrays
                if ($is_list) {
                    $parts[] = array2json($value, $jse);
                } else {
                    $parts[] = '"' . $key . '":' . array2json($value, $jse);
                }
                /* :РЕКУРСИЯ: */
            } else {
                $str = '';
                if (!$is_list) {
                    $str = '"' . $key . '":';
                }
                //Custom handling for multiple data types
                if (is_numeric($value)) {
                    $str .= $value;
                    //Numbers
                } elseif ($value === false) {
                    $str .= 'false';
                    //The booleans
                } elseif ($value === true) {
                    $str .= 'true';
                } else {
                    $str .= '"' . addslashes($value) . '"';
                    //All other things
                    // Есть ли более типов данных мы должны быть в поиске? (объект?)
                }
                $parts[] = $str;
            }
        }
        $json = implode(',', $parts);
        if ($is_list) {
            return '[' . $json . ']';
            //Вернуть как числовой  JSON
        }
        return '{' . $json . '}';
        //Вернуть как ассоциативный JSON
    }
}
Example #12
0
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */
include_once "includes/config.php";
include_once "includes/utils.php";
$regid = intval($_GET['id']);
// Fetch available computers in the region
// Now connect to the db
$dbTrackHandler = connectDb();
// and see if we need to check any computer?
$computersQuery = $dbTrackHandler->query('SELECT id, lastsignal, name, laststatus ' . 'FROM computers ' . 'WHERE region = ' . $regid . ' ' . 'ORDER BY id; ');
//while($computersQuery->valid()) {
//	$computers[] = $computersQuery->current();
//	$computersQuery->next();
//}
$computers = $computersQuery->fetchAll();
header('Content-type: text/plain');
echo array2json($computers);
Example #13
0
function array2json($arr)
{
    $parts = array();
    $is_list = false;
    if (!is_array($arr)) {
        return;
    }
    if (count($arr) < 1) {
        return '{}';
    }
    //Find out if the given array is a numerical array
    $keys = array_keys($arr);
    $max_length = count($arr);
    if ($keys[0] == 0 and isset($keys[$max_length]) and $keys[$max_length] == $max_length) {
        //See if the first key is 0 and last key is length - 1
        $is_list = true;
        for ($i = 0; $i < count($keys); $i++) {
            //See if each key correspondes to its position
            if ($i != $keys[$i]) {
                //A key fails at position check.
                $is_list = false;
                //It is an associative array.
                break;
            }
        }
    }
    foreach ($arr as $key => $value) {
        if (is_array($value)) {
            //Custom handling for arrays
            if ($is_list) {
                $parts[] = array2json($value);
            } else {
                $parts[] = '"' . $key . '":' . array2json($value);
            }
            /* :RECURSION: */
        } else {
            $str = '';
            if (!$is_list) {
                $str = '"' . $key . '":';
            }
            //Custom handling for multiple data types
            if (is_numeric($value)) {
                $str .= $value;
            } elseif ($value === false) {
                $str .= 'false';
            } elseif ($value === true) {
                $str .= 'true';
            } else {
                $str .= '"' . addslashes($value) . '"';
            }
            //All other things
            // :TODO: Is there any more datatype we should be in the lookout for? (Object?)
            $parts[] = $str;
        }
    }
    $json = implode(',', $parts);
    if ($is_list) {
        return '[' . $json . ']';
    }
    //Return numerical JSON
    return '{' . $json . '}';
    //Return associative JSON
}
Example #14
0
 private function sendError($message)
 {
     echo array2json(array('error' => array('text' => $message)));
     die;
 }
Example #15
0
function array2json($arr)
{
    $keys = array_keys($arr);
    $isarr = true;
    $json = "";
    for ($i = 0; $i < count($keys); $i++) {
        if ($keys[$i] !== $i) {
            $isarr = false;
            break;
        }
    }
    $json = $space;
    $json .= $isarr ? "[" : "{";
    for ($i = 0; $i < count($keys); $i++) {
        if ($i != 0) {
            $json .= ",";
        }
        $item = $arr[$keys[$i]];
        $json .= $isarr ? "" : $keys[$i] . ':';
        if (is_array($item)) {
            $json .= array2json($item);
        } else {
            if (is_string($item)) {
                $json .= '"' . str_replace(array("\r", "\n"), "", $item) . '"';
            } else {
                $json .= $item;
            }
        }
    }
    $json .= $isarr ? "]" : "}";
    return $json;
}
Example #16
0
function porto_product_quickview()
{
    global $post, $product;
    $post = get_post($_GET['pid']);
    $product = wc_get_product($post->ID);
    if (post_password_required()) {
        echo get_the_password_form();
        die;
        return;
    }
    $displaytypenumber = 0;
    if (function_exists('wcva_get_woo_version_number')) {
        require_once wcva_plugin_path() . '/includes/wcva_common_functions.php';
    }
    if (function_exists('wcva_return_displaytype_number')) {
        $displaytypenumber = wcva_return_displaytype_number($product, $post);
    }
    $goahead = 1;
    if (isset($_SERVER['HTTP_USER_AGENT'])) {
        $agent = $_SERVER['HTTP_USER_AGENT'];
    }
    if (preg_match('/(?i)msie [5-8]/', $agent)) {
        $goahead = 0;
    }
    ?>

    <div class="quickview-wrap quickview-wrap-<?php 
    echo $post->ID;
    ?>
 single-product">
        <div class="product product-summary-wrap">

            <div class="row">
                <div class="col-lg-6 col-md-6 col-sm-12 summary-before">
                    <?php 
    do_action('woocommerce_before_single_product_summary');
    ?>
                </div>

                <div class="col-lg-6 col-md-6 col-sm-12 summary entry-summary">
                    <?php 
    do_action('woocommerce_single_product_summary');
    ?>
                    <script type="text/javascript">
                        /* <![CDATA[ */
                        <?php 
    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
    $assets_path = esc_url(str_replace(array('http:', 'https:'), '', WC()->plugin_url())) . '/assets/';
    $frontend_script_path = $assets_path . 'js/frontend/';
    ?>
                        var wc_add_to_cart_params = <?php 
    echo array2json(apply_filters('wc_add_to_cart_params', array('ajax_url' => WC()->ajax_url(), 'ajax_loader_url' => apply_filters('woocommerce_ajax_loader_url', $assets_path . 'images/ajax-loader@2x.gif'), 'i18n_view_cart' => esc_attr__('View Cart', 'woocommerce'), 'cart_url' => get_permalink(wc_get_page_id('cart')), 'is_cart' => is_cart(), 'cart_redirect_after_add' => get_option('woocommerce_cart_redirect_after_add'))));
    ?>
;
                        var wc_single_product_params = <?php 
    echo array2json(apply_filters('wc_single_product_params', array('i18n_required_rating_text' => esc_attr__('Please select a rating', 'woocommerce'), 'review_rating_required' => get_option('woocommerce_review_rating_required'))));
    ?>
;
                        var woocommerce_params = <?php 
    echo array2json(apply_filters('woocommerce_params', array('ajax_url' => WC()->ajax_url(), 'ajax_loader_url' => apply_filters('woocommerce_ajax_loader_url', $assets_path . 'images/ajax-loader@2x.gif'))));
    ?>
;
                        var wc_cart_fragments_params = <?php 
    echo array2json(apply_filters('wc_cart_fragments_params', array('ajax_url' => WC()->ajax_url(), 'fragment_name' => apply_filters('woocommerce_cart_fragment_name', 'wc_fragments'))));
    ?>
;
                        var wc_add_to_cart_variation_params = <?php 
    echo array2json(apply_filters('wc_add_to_cart_variation_params', array('i18n_no_matching_variations_text' => esc_attr__('Sorry, no products matched your selection. Please choose a different combination.', 'woocommerce'), 'i18n_unavailable_text' => esc_attr__('Sorry, this product is unavailable. Please choose a different combination.', 'woocommerce'))));
    ?>
;
                        jQuery(document).ready(function($) {
                            $( document ).off( 'click', '.plus, .minus');
                            $( document ).off( 'click', '.add_to_cart_button');
                            $.getScript('<?php 
    echo $frontend_script_path . 'add-to-cart' . $suffix . '.js';
    ?>
');
                            $.getScript('<?php 
    echo $frontend_script_path . 'single-product' . $suffix . '.js';
    ?>
');
                            $.getScript('<?php 
    echo $frontend_script_path . 'woocommerce' . $suffix . '.js';
    ?>
');
                            <?php 
    if ($goahead == 1 && $displaytypenumber > 0) {
        ?>
                            $.getScript('<?php 
        echo porto_js . '/manage-variation-selection.js';
        ?>
');
                            <?php 
    } else {
        ?>
                            $.getScript('<?php 
        echo $frontend_script_path . 'add-to-cart-variation' . $suffix . '.js';
        ?>
');
                            <?php 
    }
    ?>
                        });
                        /* ]]> */
                    </script>
                </div><!-- .summary -->
            </div>
        </div>
    </div>

    <?php 
    die;
}
Example #17
0
function venedor_product_quickview()
{
    global $post, $product, $woocommerce, $wpdb, $venedor_quickview;
    $post = get_post($_GET['pid']);
    $product = wc_get_product($post->ID);
    $attachment_ids = $product->get_gallery_attachment_ids();
    if (post_password_required()) {
        echo get_the_password_form();
        die;
        return;
    }
    $venedor_quickview = true;
    $displaytypenumber = 0;
    if (function_exists('wcva_get_woo_version_number')) {
        require_once wcva_plugin_path() . '/includes/wcva_common_functions.php';
    }
    if (function_exists('wcva_return_displaytype_number')) {
        $displaytypenumber = wcva_return_displaytype_number($product, $post);
    }
    $goahead = 1;
    if (isset($_SERVER['HTTP_USER_AGENT'])) {
        $agent = $_SERVER['HTTP_USER_AGENT'];
    }
    if (preg_match('/(?i)msie [5-8]/', $agent) || strpos($agent, 'Trident/7.0; rv:11.0') !== false) {
        $goahead = 0;
    }
    ?>

    <div class="quickview-wrap single-product">
        <div class="column2">
            <div class="product product-essential">

                <div class="row">
                    <div class="col-lg-6 col-md-6 col-sm-12 summary-before">
                    <?php 
    if (defined('ADDTHIS_INIT')) {
        $addthis_options = get_option('addthis_settings');
        $atversion = is_array($addthis_options) && array_key_exists('addthis_profile', $addthis_options) && $addthis_options['addthis_profile'] == 1 ? $addthis_options['addthis_profile'] : 300;
        $pub = isset($addthis_options['profile']) ? $addthis_options['profile'] : false;
        if (!$pub) {
            $pub = isset($addthis_options['addthis_profile']) ? $addthis_options['addthis_profile'] : false;
        }
        if (!$pub) {
            $pub = 'wp-' . hash_hmac('md5', get_option('home'), 'addthis');
        }
        $pub = urlencode($pub);
    }
    do_action('woocommerce_before_single_product_summary');
    ?>
                    </div>

                    <div class="col-lg-6 col-md-6 col-sm-12 summary entry-summary">
                    <?php 
    /**
     * woocommerce_single_product_summary hook
     *
     * @hooked woocommerce_template_single_title - 5
     * @hooked woocommerce_template_single_rating - 10
     * @hooked woocommerce_template_single_price - 10
     * @hooked woocommerce_template_single_excerpt - 20
     * @hooked woocommerce_template_single_add_to_cart - 30
     * @hooked woocommerce_template_single_meta - 40
     * @hooked woocommerce_template_single_sharing - 50
     */
    do_action('woocommerce_single_product_summary');
    ?>
                        <script type="text/javascript">
                            /* <![CDATA[ */
                            <?php 
    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
    $assets_path = str_replace(array('http:', 'https:'), '', WC()->plugin_url()) . '/assets/';
    $frontend_script_path = $assets_path . 'js/frontend/';
    ?>
                            var wc_add_to_cart_params = <?php 
    echo array2json(apply_filters('wc_add_to_cart_params', array('ajax_url' => WC()->ajax_url(), 'ajax_loader_url' => apply_filters('woocommerce_ajax_loader_url', $assets_path . 'images/ajax-loader@2x.gif'), 'i18n_view_cart' => esc_attr__('View Cart', 'woocommerce'), 'cart_url' => get_permalink(wc_get_page_id('cart')), 'is_cart' => is_cart(), 'cart_redirect_after_add' => get_option('woocommerce_cart_redirect_after_add'))));
    ?>
;
                            var wc_single_product_params = <?php 
    echo array2json(apply_filters('wc_single_product_params', array('i18n_required_rating_text' => esc_attr__('Please select a rating', 'woocommerce'), 'review_rating_required' => get_option('woocommerce_review_rating_required'))));
    ?>
;
                            var woocommerce_params = <?php 
    echo array2json(apply_filters('woocommerce_params', array('ajax_url' => WC()->ajax_url(), 'ajax_loader_url' => apply_filters('woocommerce_ajax_loader_url', $assets_path . 'images/ajax-loader@2x.gif'))));
    ?>
;
                            var wc_cart_fragments_params = <?php 
    echo array2json(apply_filters('wc_cart_fragments_params', array('ajax_url' => WC()->ajax_url(), 'fragment_name' => apply_filters('woocommerce_cart_fragment_name', 'wc_fragments'))));
    ?>
;
                            var wc_add_to_cart_variation_params = <?php 
    echo array2json(apply_filters('wc_add_to_cart_variation_params', array('i18n_no_matching_variations_text' => esc_attr__('Sorry, no products matched your selection. Please choose a different combination.', 'woocommerce'), 'i18n_unavailable_text' => esc_attr__('Sorry, this product is unavailable. Please choose a different combination.', 'woocommerce'))));
    ?>
;
                            if (window.addthis) {
                                window.addthis = null;
                                for(var i in window) { if(i.match(/^_at/) ) { window[i]=null } }
                            }
                            jQuery(document).ready(function($) {
                                $( document ).off( 'click', '.plus, .minus');
                                $( document ).off( 'click', '.add_to_cart_button');
                                $.getScript('<?php 
    echo $frontend_script_path . 'add-to-cart' . $suffix . '.js';
    ?>
');
                                $.getScript('<?php 
    echo $frontend_script_path . 'single-product' . $suffix . '.js';
    ?>
');
                                $.getScript('<?php 
    echo $frontend_script_path . 'woocommerce' . $suffix . '.js';
    ?>
');
                                <?php 
    if ($goahead == 1 && $displaytypenumber > 0) {
        ?>
                                $.getScript('<?php 
        echo wcva_PLUGIN_URL . 'js/manage-variation-selection.js';
        ?>
');
                                <?php 
    } else {
        ?>
                                $.getScript('<?php 
        echo $frontend_script_path . 'add-to-cart-variation' . $suffix . '.js';
        ?>
');
                                <?php 
    }
    ?>
                                <?php 
    if (defined('ADDTHIS_INIT')) {
        ?>
                                $.getScript('//s7.addthis.com/js/<?php 
        echo $atversion;
        ?>
/addthis_widget.js?async=1&pubid=<?php 
        echo $pub;
        ?>
', function() {
                                    addthis.init();
                                });
                                 <?php 
    }
    ?>
                            });
                            /* ]]> */
                        </script>
                    </div><!-- .summary -->
                </div>
            </div>
        </div>
    </div>

    <?php 
    $venedor_quickview = true;
    die;
}
Example #18
0
*   This package is distributed in the hope that it will be useful,
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*   GNU General Public License for more details.
*
*   You should have received a copy of the GNU General Public License
*   along with this package; if not, write to the Free Software
*   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
*   MA  02110-1301  USA
*
*
* On Debian GNU/Linux systems, the complete text of the GNU General
* Public License can be found in `/usr/share/common-licenses/GPL-2'.
*
* Otherwise you can read it here: http://www.gnu.org/licenses/gpl-2.0.txt
****************************************************************************/
require_once 'classes/Session.inc';
require_once 'classes/Xml_parser.inc';
require_once '../utils.php';
require_once '../conf/_conf.php';
$res = getTree(POST('file'));
$filename = $rules_file . POST('file');
if (!is_array($res)) {
    echo $res;
} else {
    $tree = $res;
    $tree_json = array2json($tree, $filename);
    $_SESSION['_tree_json'] = $tree_json;
    $_SESSION['_tree'] = $tree;
    echo "1###" . _("Click on a brach to display a node") . "###" . base64_encode($tree_json);
}
Example #19
0
        $error = true;
        $link_txt = _("Configuration error in file") . " " . basename($ossec_conf) . " " . _("and/or") . " " . $editable_files[0];
        $info_conf = "<span style='font-weight: bold;'>{$link_txt}<a onclick=\"\$('#msg_errors').toggle();\"> [" . _("View errors") . "]</a><br/></span>";
        $info_conf .= "<div id='msg_errors'>{$result}</div>";
        $error_conf = "<div id='parse_errors' class='oss_error'>{$info_conf}</div>";
    } else {
        $file_xml = @file_get_contents($filename, false);
        if ($file_xml === false) {
            $error = true;
        } else {
            $_level_key_name = set_key_name($_level_key_name, $file_xml);
            $_SESSION['_level_key_name'] = $_level_key_name;
            $xml_obj = new xml($_level_key_name);
            $xml_obj->load_file($filename);
            $array_xml = $xml_obj->xml2array();
            $tree_json = array2json($array_xml, $filename);
            $_SESSION['_tree_json'] = $tree_json;
            $_SESSION['_tree'] = $array_xml;
            $file_xml = clean_string($file_xml);
        }
    }
} else {
    $error = true;
}
if ($error == true) {
    $file_xml = '';
    $tree_json = "{title:'<span>" . $filename . "</span>', icon:'../../pixmaps/theme/any.png', addClass:'size12', isFolder:'true', key:'1', children:[{title: '<span>" . _("No Valid XML File") . "</span>', icon:'../../pixmaps/theme/ltError.gif', addClass:'bold_red', key:'load_error'}]}";
    $_SESSION['_tree_json'] = $tree_json;
    $_SESSION['_tree'] = array();
} else {
    $info = "<div id='msg_init'><div class='oss_info'><span>" . _("Click on a brach to display a node") . "</span></div></div>";
Example #20
0
if (!$SMObj->isUserLoggedIn()) {
    die($LangUI->_('You must be logged into perform the requested action.'));
}
$searchText = isset($_GET['term']) ? $_GET['term'] : ".*";
$searchLimit = 100;
//isset ($_GET['limit'] ) ? $_GET['limit'] : 100;
$count = 0;
$sResult = "";
$sql = "SELECT C.Id as core_id, C.description FROM {$db_table_core_ingredients} C WHERE C.description LIKE '%" . $DB_LINK->addq($searchText, get_magic_quotes_gpc()) . "%' \n\t   AND NOT EXISTS (SELECT ingredient_core FROM recipe_ingredients WHERE ingredient_user = "******" AND C.Id = ingredient_core);";
$ingredients = $DB_LINK->Execute($sql);
$searchResults = array();
while (!$ingredients->EOF) {
    $key = $ingredients->fields['description'];
    $value = $ingredients->fields['core_id'];
    array_push($searchResults, array("id" => $value, "label" => $key, "value" => strip_tags($key)));
    if (count($searchResults) >= $searchLimit) {
        break;
    }
    $ingredients->MoveNext();
}
// return a friendly no-found message
if (count($searchResults) == 0) {
    $key = "No Results for '{$searchText}' Found";
    $value = "";
    array_push($searchResults, array("id" => $value, "label" => $key, "value" => strip_tags($key)));
    $searchResults[] = "";
}
echo array2json($searchResults);
?>

Example #21
0
?>
",
	close    : "<?php 
echo $lang["bs"]["exit"];
?>
",
	open     : "",
	title    : "",
	alt      : "<?php 
echo $lang["bs"]["alt"];
?>
"	//replace tag A's title and tag IMG's alt
}

var lang = <?php 
echo array2json($lang["js"]);
?>


function search()
{
	var html = "<div style='font-size:16px;font-weight:bold;margin:5px;color:#FF6600'>"+lang.search+"</div>";
	html+="<form style='margin:10px' action='' onsubmit='search_do(this);return false;'>";
	html+="<textarea name='s' cols=20 rows=3>"+window.search_content+"</textarea><br/>";
	html+="<input type=checkbox checked name='filename' />"+lang.search_filename+"<br/>";
	html+="<input type=checkbox checked name='content' />"+lang.search_content+"<br/>";
	html+="<input type=checkbox name='casebig' />"+lang.care_case+"<br/>";
	html+="<div id='search_charset' style='display:none;border:1px solid red;'>"+lang.search_charset+"<select name='charset'><option value='gb2312'>GB2312<option value='utf-8'>UTF-8</select></div>";
	html+="<br/><input type=submit value='Search' />&nbsp;<input type=reset value='Reset' />";
	html+="</form><br/><a href='javascript:search_close();'>"+lang.close+"</a>";
	window.movenotice = 0;
Example #22
0
require "php/functions.php";
require "../config/flyCRM.db.php";
//edump($_SERVER);
session_start();
$user = isset($_SESSION['PHP_AUTH_USER']) ? $_SESSION['PHP_AUTH_USER'] : '******';
$basePath = preg_replace("/index.php\$/", "", $_SERVER['PHP_SELF']);
$base = "{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}{$basePath}";
$actionPath = preg_replace("|^{$basePath}|", "", $_SERVER['REQUEST_URI']);
$action = $actionParam = '';
if ($actionPath) {
    $actionParam = preg_split("/\\//", $actionPath);
    #edump($actionParam);
    $action = array_pop($actionParam);
    #exit(printf("<div><pre>%s</pre></div>",print_r($actionParam,1)));
}
$params = array2json($actionParam);
?>
<!DOCTYPE html>
<html lang="de">
  	<head>
    	<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=0">
		<link rel="stylesheet" href="css/jquery-ui.css">
		<link rel="stylesheet" href="css/app.css">
		<base href="<?php 
echo $base;
?>
">
	</head>
	<body>
Example #23
0
			latest = false;
		
		text = '<b>' + { <?php 
array2json($versions, 'filename');
?>
 }[ plugin ] + '</b> ';
		text += { <?php 
array2json($versions, 'version');
?>
 }[ plugin ] + '<br/>';
		text += '<span style="font-size: 8pt">' + { <?php 
array2json($versions, 'desc');
?>
 }[ plugin ] + '</span><br/>';
		url = { <?php 
array2json($versions, 'url');
?>
 }[ plugin ];
		text += '<a href="' + url + "' />" + url + '</a>';
		
		
		popup = document.getElementById( 'popup' );
		popup.innerHTML = text;
		popup.style.left = ( el.offsetLeft + 19 ) + "px";
		popup.style.top = ( el.offsetTop + 82 ) + "px";
		popup.style.display = 'block';
		
	}
	
	function hide( plugin ) {