Beispiel #1
0
/*
* File: engine.php
* Functions: Старт всех служб и подключение других файлов
* Author: jadewizard
* Buryakov.su
*/
require_once 'db.php';
//Файл для соеденения с БД
require_once 'vendor/autoload.php';
//Подключаем шаблонизатор TWIG
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem('templates');
//Путь к шаблону
$twig = new Twig_Environment($loader);
//Инициализируем шаблонизатор
require_once 'class/pagination.class.php';
$pgManager = new pagination();
// Пагинация
require_once 'class/post.class.php';
$post = new post();
//Работа с постами на сайте
require_once 'class/app.class.php';
$application = new application();
//Различные функции сайта
$pgManager->getLinks();
$application->getBreadCrumbs();
// Хлебные крошки
require_once 'actionhandler.php';
//Обработка пользовательских действий
require_once 'pages.php';
//Работа со страницами сайта
foreach (range(1, 200) as $value) {
    $products[] = array('Product' => 'Product ' . $value, 'Price' => rand(100, 1000));
}
// If we have an array with items
if (count($products)) {
    // Create the pagination object
    $pagination = new pagination($products, isset($_GET['page']) ? $_GET['page'] : 1, 15);
    // Decide if the first and last links should show
    $pagination->setShowFirstAndLast(false);
    // You can overwrite the default seperator
    $pagination->setMainSeperator(' | ');
    // Parse through the pagination class
    $productPages = $pagination->getResults();
    // If we have items
    if (count($productPages) != 0) {
        // Create the page numbers
        echo $pageNumbers = '<div class="numbers">' . $pagination->getLinks($_GET) . '</div>';
        // Loop through all the items in the array
        foreach ($productPages as $productArray) {
            // Show the information about the item
            echo '<p><b>' . $productArray['Product'] . '</b> &nbsp; &pound;' . $productArray['Price'] . '</p>';
        }
        // print out the page numbers beneath the results
        echo $pageNumbers;
    }
}
?>
      <hr />
      <p><a href="http://www.lotsofcode.com/php/projects/php-array-pagination" target="_blank">PHP Array Pagination</a> provided by <a href="http://www.lotsofcode.com/" target="_blank">Lots of Code</a></p>
  </body>
</html>
Beispiel #3
0
function search_question($query, $cid, $count, $page = 1)
{
    //Search questions by post title and post body
    $output = '';
    $uid = isset($_SESSION['uid']) ? $_SESSION['uid'] : 0;
    $posts = array();
    if (isset($_SESSION['rid']) && $_SESSION['rid'] != 2) {
        $result = mysql_query("SELECT * FROM " . PREFIX . "POST WHERE (Post_Title LIKE '%" . $query . "%' OR Post_Question LIKE '%" . $query . "%' OR Post_Answer LIKE '%" . $query . "%' OR Post_URL LIKE '%" . $query . "%')");
    } elseif (!isset($_SESSION['rid']) || $_SESSION['rid'] == 2) {
        $result = mysql_query("SELECT * FROM " . PREFIX . "POST WHERE Post_Current=1 AND (Post_Title LIKE '%" . $query . "%' OR Post_Question LIKE '%" . $query . "%' OR Post_Answer LIKE '%" . $query . "%' OR Post_URL LIKE '%" . $query . "%')");
    }
    if ($result) {
        while ($row = mysql_fetch_assoc($result)) {
            $posts[] = $row;
        }
    }
    if ($cid != 0) {
        $posts = array_filter($posts, array(new Filter($cid), 'filter_cid'));
    }
    usort($posts, 'sort_post_date_descend');
    $pagination = new pagination($posts, $page, $count, 5);
    $pagination->setShowFirstAndLast(true);
    $pagination->setMainSeperator('');
    $posts = $pagination->getResults();
    $output .= '<div class="paging">' . $pagination->getLinks() . '</div>';
    $output .= '<div class="posts">';
    for ($i = 0; $i < count($posts); $i++) {
        if (isset($posts[$i])) {
            $pid = $posts[$i]['Post_ID'];
            $output .= view_post($pid, $uid);
            $output .= $i != count($posts) - 1 ? '<hr>' : '';
        }
    }
    $output .= '</div>';
    $output .= '<div class="paging">' . $pagination->getLinks() . '</div>';
    $output .= '<script>
				function turnPage(page) {
					$("#feeds").load("triggers/paging_search.php",{count:' . $count . ',cid:' . $cid . ',page:page,keyword:"' . $query . '"});
				}
				</script>';
    if (count($posts) == 0) {
        $output .= '<h3>There is no results for this search criteria.</h3>';
    }
    return $output;
}
function SocialAuth_WP_contacts()
{
    ini_set("display_errors", 0);
    $noContactMsg = "Either you do not have any contact(s) or your login provider is not supporting this feature at the moment.";
    echo '<div class="wrap">';
    echo '<div class="icon32 icon32-posts-post" id="icon-edit"><br></div>';
    echo "<h2>My Contacts</h2> <br/>";
    // load hybridauth
    require_once dirname(__FILE__) . "/hybridauth/Hybrid/Auth.php";
    // load wp-load.php
    $wp_load = dirname(dirname(dirname(dirname(__FILE__)))) . '/wp-load.php';
    require_once $wp_load;
    include_once 'common.php';
    $user_id = get_current_user_id();
    $provider = null;
    if ($user_id != 0) {
        $provider = get_user_meta($user_id, 'ha_login_provider', true);
    }
    // selected provider name
    if ($provider == null) {
        echo $noContactMsg;
        return;
    }
    //global $HA_PROVIDER_CONFIG;
    $SocialAuth_WP_providers = get_option('SocialAuth_WP_providers');
    if (is_array($SocialAuth_WP_providers) && count($SocialAuth_WP_providers)) {
        $config = array();
        if (isset($SocialAuth_WP_providers[$provider])) {
            $config["base_url"] = plugin_dir_url(__FILE__) . 'hybridauth/';
            $config["providers"] = array();
            //this si same as orig config, no need to amke config again
            $config["providers"][$provider] = $SocialAuth_WP_providers[$provider];
        } else {
            echo "Current Provider is unknowun to system.";
            return;
        }
    } else {
        echo "It seems SocialAuth-WP plugin is not configured properly. Please contact site administrator.";
        return;
    }
    // create an instance for Hybridauth
    $hybridauth = new Hybrid_Auth($config);
    $adapter = null;
    // try to check is provider still authenticated
    if ($hybridauth->isConnectedWith($provider)) {
        $adapter = $hybridauth->getAdapter($provider);
    } else {
        echo "It seems your session with Login provider has expired. Please logout and login again to system to continue.";
        return;
    }
    $contacts = array();
    try {
        $contacts = $adapter->getUserContacts();
    } catch (exception $e) {
        echo $noContactMsg;
        return;
    }
    if (count($contacts)) {
        require SOCIALAUTH_WP_PLUGIN_PATH . '/pagination.class.php';
        $pagination = new pagination($contacts, isset($_GET['pageNum']) ? $_GET['pageNum'] : 1, 15);
        $ContactPages = $pagination->getResults();
        $tbHeaders = array('Name', 'Profile URL', 'Email');
        ?>
        <?php 
        if (count($ContactPages) != 0) {
            echo $pageNumbers = '<div class="numbers" style="text-align:right;" >' . $pagination->getLinks(array('page' => 'SocialAuth-WP-contacts')) . '</div>';
            ?>
    
    <table class="wp-list-table widefat fixed users">
    <thead>
    <tr>
        <?php 
            foreach ($tbHeaders as $header) {
                echo '<th style="" class="manage-column column-username" id="" scope="col">' . $header . '</th>';
            }
            ?>
        
        </tr>
    </thead>
    
    <tfoot>
    <tr>
        <?php 
            foreach ($tbHeaders as $header) {
                echo '<th style="" class="manage-column column-username" id="" scope="col">' . $header . '</th>';
            }
            ?>
        
        </tr>
    </tfoot>
    
    <tbody class="list:user" id="the-list">
    <?php 
            foreach ($ContactPages as $index => $contact) {
                $alternate = $index % 2 == 0 ? "alternate" : "";
                ?>
    
    <tr class="<?php 
                echo $alternate;
                ?>
" id="user-12">
        <td class="column-username">
            <?php 
                if (strlen($contact->photoURL)) {
                    ?>
            <img height="32" width="32" src="<?php 
                    echo $contact->photoURL;
                    ?>
" >
            <?php 
                } else {
                    ?>
            <img height="32" width="32" class="avatar avatar-32 photo" src="http://0.gravatar.com/avatar/8af77eb212190822af34f1725a01922d?s=32&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&amp;r=G" alt="">
            
            <?php 
                }
                ?>
            <?php 
                echo $contact->displayName;
                ?>
        </td>
                
        <td class="posts">
            <a href="<?php 
                echo $contact->profileURL;
                ?>
">
                <?php 
                echo $contact->profileURL;
                ?>
            </a>
        </td>
        
        <td class="posts">
            <?php 
                echo empty($contact->email) ? "&nbsp;" : $contact->email;
                ?>
        </td>
    </tr>
    
    <?php 
            }
            ?>
    </tbody>
    </table>
    <?php 
            echo $pageNumbers = '<div class="numbers" style="text-align:right;" >' . $pagination->getLinks(array('page' => 'SocialAuth-WP-contacts')) . '</div>';
        }
        ?>
    <?php 
    } else {
        echo $noContactMsg;
        return;
    }
    echo '</div>';
}