コード例 #1
0
 public static function ChooseNetwork($network, $app)
 {
     $app->response->headers->set('Content-Type', 'application/json');
     // l'url du html à récupérer
     $html = file_get_contents($app->rootUri . "network/edit/" . $network);
     // on créé un élément DOM
     $dom = new \DOMDocument();
     // on rempli le DOM avec le HTML précèdemment récupéré
     libxml_use_internal_errors(true);
     $dom->loadHTML($html);
     libxml_clear_errors();
     // on créé un objet Xpath avec le DOM, Xpath permet de jouer plus facilement avec les nodes
     $xpath = new \DOMXpath($dom);
     function getFormValue($query, $xpath)
     {
         $objDom = $xpath->query($query);
         $i = 0;
         $tmp = null;
         while ($i < $objDom->length) {
             $param = explode(":", trim($objDom[$i]->textContent));
             $tmp[$i]["name"] = $param[0];
             $tmp[$i]["value"] = $param[1];
             $i++;
         }
         return $tmp;
     }
     function getSelectValue($query, $xpath)
     {
         $objDom = $xpath->query($query);
         $i = 0;
         $tmp = null;
         while ($i < $objDom->length) {
             if ($objDom->length > 1) {
                 $tmp[$i] = $objDom[$i]->textContent;
             } else {
                 $tmp = $objDom[$i]->textContent;
             }
             $i++;
         }
         return $tmp;
     }
     //Network interfaces
     $tab["NetworkInterface"] = getFormValue('//table[@id="nic-details"]/tbody/*', $xpath);
     //Config interfaces
     $tab["ConfigInterfaces"] = getSelectValue('//select[@id="dhcp"]/*', $xpath);
     $tab["ConfigInterfaces"]["select"] = getSelectValue('//select[@id="dhcp"]/option[@selected=\'selected\']', $xpath);
     $app->response->setStatus(200);
     echo json_encode(array("HTTP" => 200, "message" => $tab));
 }
コード例 #2
0
ファイル: mpdController.php プロジェクト: LP-CISIIE/RuneAPI
 public static function getMpd($app)
 {
     $app->response->headers->set('Content-Type', 'application/json');
     // l'url du html à récupérer
     $html = file_get_contents($app->rootUri . "/mpd/");
     // on créé un élément DOM
     $dom = new \DOMDocument();
     // on rempli le DOM avec le HTML précèdemment récupéré
     libxml_use_internal_errors(true);
     $dom->loadHTML($html);
     libxml_clear_errors();
     // on créé un objet Xpath avec le DOM, Xpath permet de jouer plus facilement avec les nodes
     $xpath = new \DOMXpath($dom);
     function getSelectValue($query, $xpath)
     {
         $objDom = $xpath->query($query);
         $i = 0;
         $tmp = null;
         while ($i < $objDom->length) {
             if ($objDom->length > 1) {
                 $tmp[$i] = $objDom[$i]->textContent;
             } else {
                 $tmp = $objDom[$i]->textContent;
             }
             $i++;
         }
         return $tmp;
     }
     function get_input_value($query)
     {
         $value = false;
         if ($query) {
             foreach ($query as $tag) {
                 $value = trim($tag->getAttribute('value'));
             }
         }
         return $value;
     }
     $tab = array();
     //Audio output interface
     $tab["AudioOutput"] = getSelectValue('//select[@id="audio-output-interface"]/*', $xpath);
     $tab["AudioOutput"]["select"] = getSelectValue('//select[@id="audio-output-interface"]/option[@selected=\'selected\']', $xpath);
     //Volume controle
     $tab["VolumeControle"] = getSelectValue('//select[@id="mixer-type"]/*', $xpath);
     $tab["VolumeControle"]["select"] = getSelectValue('//select[@id="mixer-type"]/option[@selected=\'selected\']', $xpath);
     //Port
     $tab["Port"] = get_input_value($xpath->query('//input[@id="port"]'));
     //Daemon user : group
     $tab["DaemonUser"] = getSelectValue('//select[@name="conf[user]"]/*', $xpath);
     $tab["DaemonUser"]["select"] = getSelectValue('//select[@name="conf[user]"]/option[@selected=\'selected\']', $xpath);
     //Log level
     $tab["LogLevel"] = getSelectValue('//select[@name="conf[log_level]"]/*', $xpath);
     $tab["LogLevel"]["select"] = getSelectValue('//select[@name="conf[log_level]"]/option[@selected=\'selected\']', $xpath);
     //State file
     $tab["StateFile"] = getSelectValue('//select[@name="conf[state_file]"]/*', $xpath);
     $tab["StateFile"]["select"] = getSelectValue('//select[@name="conf[state_file]"]/option[@selected=\'selected\']', $xpath);
     //FFmpeg decoder plugin
     $tab["FFmpeg"] = getSelectValue('//select[@name="conf[ffmpeg]"]/*', $xpath);
     $tab["FFmpeg"]["select"] = getSelectValue('//select[@name="conf[ffmpeg]"]/option[@selected=\'selected\']', $xpath);
     //Gapless mp3 playback
     $tab["Gapless"] = getSelectValue('//select[@name="conf[gapless_mp3_playback]"]/*', $xpath);
     $tab["Gapless"]["select"] = getSelectValue('//select[@name="conf[gapless_mp3_playback]"]/option[@selected=\'selected\']', $xpath);
     //DSD support
     $tab["DSDSupport"] = getSelectValue('//select[@name="conf[dsd_usb]"]/*', $xpath);
     $tab["DSDSupport"]["select"] = getSelectValue('//select[@name="conf[dsd_usb]"]/option[@selected=\'selected\']', $xpath);
     //Volume normalization
     $tab["VolumeNormalization"] = getSelectValue('//select[@name="conf[volume_normalization]"]/*', $xpath);
     $tab["VolumeNormalization"]["select"] = getSelectValue('//select[@name="conf[volume_normalization]"]/option[@selected=\'selected\']', $xpath);
     //Audio buffer size
     $tab["AudioBufferSize"] = get_input_value($xpath->query('//input[@id="audio-buffer-size"]'));
     //Buffer before play
     $tab["Buffer"] = getSelectValue('//select[@name="conf[buffer_before_play]"]/*', $xpath);
     $tab["Buffer"]["select"] = getSelectValue('//select[@name="conf[buffer_before_play]"]/option[@selected=\'selected\']', $xpath);
     //Auto update
     $tab["AutoUpdate"] = getSelectValue('//select[@name="conf[auto_update]"]/*', $xpath);
     $tab["AutoUpdate"]["select"] = getSelectValue('//select[@name="conf[auto_update]"]/option[@selected=\'selected\']', $xpath);
     $app->response->setStatus(200);
     echo json_encode(array("HTTP" => 200, "message" => $tab));
 }
コード例 #3
0
 public static function EditSource($app, $id)
 {
     $app->response->headers->set('Content-Type', 'application/json');
     // l'url du html à récupérer
     $html = file_get_contents($app->rootUri . "/sources/edit/" . $id);
     // on créé un élément DOM
     $dom = new \DOMDocument();
     // on rempli le DOM avec le HTML précèdemment récupéré
     libxml_use_internal_errors(true);
     $dom->loadHTML($html);
     libxml_clear_errors();
     // on créé un objet Xpath avec le DOM, Xpath permet de jouer plus facilement avec les nodes
     $xpath = new \DOMXpath($dom);
     //var_dump($html);
     function getSelectValue($query, $xpath)
     {
         $objDom = $xpath->query($query);
         $i = 0;
         $tmp = null;
         while ($i < $objDom->length) {
             if ($objDom->length > 1) {
                 $tmp[$i] = $objDom[$i]->textContent;
             } else {
                 $tmp = $objDom[$i]->textContent;
             }
             $i++;
         }
         return $tmp;
     }
     //var_dump($html);
     function get_input_value($query)
     {
         $value = false;
         if ($query) {
             foreach ($query as $tag) {
                 $value = trim($tag->getAttribute('value'));
             }
         }
         return $value;
     }
     $tab = array();
     //NAS name
     $tab["nas-name"] = get_input_value($xpath->query('//input[@id="nas-name"]'));
     //FileShare protocol
     $tab["mount-type"] = getSelectValue('//select[@id="mount-type"]/*', $xpath);
     $tab["mount-type"]["select"] = getSelectValue('//select[@id="mount-type"]/option[@selected=\'selected\']', $xpath);
     //IP adress
     $tab["nas-ip"] = get_input_value($xpath->query('//input[@id="nas-ip"]'));
     //Remote directory
     $tab["nas-dir"] = get_input_value($xpath->query('//input[@id="nas-dir"]'));
     //Guest access
     if (get_input_value($xpath->query('//input[@id="nas-guest" and @checked]')) === false) {
         $tab["nas-guest"] = "no";
         //Login
         $tab["nas-usr"] = get_input_value($xpath->query('//input[@id="nas-usr"]'));
         //Password
         $tab["nas-pasw"] = get_input_value($xpath->query('//input[@id="nas-pasw"]'));
     } else {
         $tab["nas-guest"] = "yes";
     }
     //Charset
     $tab["log-level"] = getSelectValue('//select[@id="log-level"]/*', $xpath);
     $tab["log-level"]["select"] = getSelectValue('//select[@id="log-level"]/option[@selected=\'selected\']', $xpath);
     //Rsize
     $tab["nas-rsize"] = get_input_value($xpath->query('//input[@id="nas-rsize"]'));
     //Wsize
     $tab["nas-wsize"] = get_input_value($xpath->query('//input[@id="nas-wsize"]'));
     //Mount flag
     $tab["options"] = get_input_value($xpath->query('//input[@id="options"]'));
     $app->response->setStatus(200);
     echo json_encode(array("HTTP" => 200, "message" => $tab));
 }
コード例 #4
0
ファイル: edit-post-rows.php プロジェクト: hewu/blogwp
function jcl_post_row($this_table_obj, $post)
{
    global $wpdb;
    static $rowclass;
    $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
    global $current_user;
    ?>
	
	<tr id='post-<?php 
    echo $post->ID;
    ?>
' class='<?php 
    echo trim($rowclass . ' author-' . $post_owner . ' status-' . $post->post_status);
    ?>
 iedit' valign="top">

	<th scope="row" class="check-column"><input type="checkbox" class="rowID" value="<?php 
    echo $post->ID;
    ?>
" /></th>

	<?php 
    $columns = $this_table_obj->get_rowdef();
    for ($i = 1; $i <= sizeof($columns); $i++) {
        if (isset($columns[$i]["extra"]) && $columns[$i]["extra"] == "AUTO_INCREMENT") {
            continue;
        }
        if (isset($columns[$i]["field"]) && $columns[$i]["field"] == "title" || isset($columns[$i]["action"]) && $columns[$i]["action"] == "title") {
            $attributes = 'class="post-title column-title"';
            $title = isset($columns[$i]["field"]) ? $post->{$columns}[$i]["field"] : ($columns[$i]["field"] = "");
            ?>
		<td <?php 
            echo $attributes;
            ?>
><strong><a class="row-title" href="<?php 
            jcl_get_link($this_table_obj, $post->ID);
            ?>
" title="<?php 
            echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title));
            ?>
"><?php 
            echo $title;
            ?>
</a></strong>
		<?php 
            $actions = array();
            $actions['edit'] = '<a href="' . jcl_get_link($this_table_obj, $post->ID, "edit") . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>';
            $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post')) . "' href='" . jcl_get_link($this_table_obj, $post->ID, "delete") . "' onclick=\"if ( confirm('" . esc_js(sprintf(__("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $columns[$i]["field"])) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
            $actions = apply_filters('post_row_actions', $actions, $post);
            $action_count = count($actions);
            $j = 0;
            echo '<div class="row-actions">';
            foreach ($actions as $action => $link) {
                ++$j;
                $j == $action_count ? $sep = '' : ($sep = ' | ');
                echo "<span class='{$action}'>{$link}{$sep}</span>";
            }
            echo '</div>';
            ?>
		</td>
		<?php 
        } else {
            if (isset($columns[$i]["textalign"])) {
                $textalign = "text-align:" . $columns[$i]["textalign"] . ";";
            } else {
                $textalign = "";
            }
            if (isset($columns[$i]["cell"])) {
                if ($columns[$i]["cell"] == "start") {
                    echo '<td style=\'' . $textalign . '\'><div>';
                } else {
                    echo '<div>';
                }
            } else {
                echo '<td style=\'' . $textalign . '\'>';
            }
            if (!isset($columns[$i]["htmlelement"])) {
                $columns[$i]["htmlelement"] = "";
            }
            switch ($columns[$i]["htmlelement"]) {
                case "selectvalue":
                    $selectfield = getSelectValue($columns[$i]["selectfield"]);
                    if (isset($post->{$selectfield})) {
                        echo $post->{$selectfield};
                    } else {
                        echo $post->{$columns}[$i]["field"];
                    }
                    break;
                case "no:yes":
                    if ($post->{$columns}[$i]["field"] == "0") {
                        echo "no";
                    } else {
                        echo "yes";
                    }
                    break;
                default:
                    $output = str_replace("<br/>", " ", $post->{$columns}[$i]["field"]);
                    $output = strip_tags($output);
                    if (isset($columns[$i]["truncate"])) {
                        if (strlen($output) > $columns[$i]["truncate"]) {
                            $output = esc_html(substr($output, 0, $columns[$i]["truncate"])) . "...";
                        }
                    } else {
                        $output = esc_html($output);
                    }
                    echo $output;
                    if (isset($columns[$i]["cell"])) {
                        if ($columns[$i]["cell"] == "end") {
                            echo '</div></td>';
                        } else {
                            echo '</div>';
                        }
                    } else {
                        echo '</td>';
                    }
            }
        }
    }
    ?>
	</tr>
<?php 
    //$post = $global_post;
}