Esempio n. 1
0
 public static function GetFileName($file_name = '')
 {
     $dir_name = self::GetAbsoluteRoot();
     $file_name = rel2abs("/", "/" . $file_name);
     $i = 0;
     while (true) {
         $i++;
         if ($file_name == '/') {
             $dir_add = md5(mt_rand());
         } elseif ($i < 25) {
             $dir_add = substr(md5(mt_rand()), 0, 3);
         } else {
             $dir_add = md5(mt_rand());
         }
         $temp_path = $dir_name . "/" . $dir_add . $file_name;
         if (!file_exists($temp_path)) {
             //Delayed unlink
             if (empty(self::$arFiles)) {
                 register_shutdown_function(array('CTempFile', 'Cleanup'));
             }
             self::$arFiles[$temp_path] = $dir_name . "/" . $dir_add;
             //Function ends only here
             return $temp_path;
         }
     }
 }
function perfect_url($u,$b){
 $bp=parse_url($b);
 if(($bp['path']!="/" && $bp['path']!="") || $bp['path']==''){
  if($bp['scheme']==""){$scheme="http";}else{$scheme=$bp['scheme'];}
  $b=$scheme."://".$bp['host']."/";
 }
 if(substr($u,0,2)=="//"){
  $u="http:".$u;
 }
 if(substr($u,0,4)!="http"){
  $u=rel2abs($u,$b);
 }
 return $u;
}
Esempio n. 3
0
 public function quick_upload()
 {
     $assetdir = Setting::value('assets_folder', 'iu-assets') . '/' . $this->user->id;
     @mkdir($assetdir, 0777, true);
     $assetpath = realpath(trim($assetdir, '/')) . '/';
     $assetbase = rel2abs($assetdir, trim(base_url(), '/') . '/');
     // Optional: instance name (might be used to adjust the server folders for example)
     $CKEditor = $_GET['CKEditor'];
     // Required: Function number as indicated by CKEditor.
     $funcNum = $_GET['CKEditorFuncNum'];
     // Optional: To provide localized messages
     $langCode = $_GET['langCode'];
     // The returned url of the uploaded file
     $url = '';
     // Optional message to show to the user (file renamed, invalid file, not authenticated...)
     $message = '';
     // in CKEditor the file is sent as 'upload'
     if (isset($_FILES['upload'])) {
         $config = array();
         $config['upload_path'] = $assetdir;
         $config['allowed_types'] = '*';
         $this->load->library('upload', $config);
         if (!$this->upload->do_upload('upload')) {
             $message = $this->upload->display_errors();
         } else {
             $data = $this->upload->data();
             if (stripos(current_url(), 'instant-update.com') && empty($data['is_image'])) {
                 die(json_encode($result));
             }
             $url = $assetbase . '/' . $data['file_name'];
             //$result['url'] = base_url() . 'iu-assets/'.$this->user->id.'/'.$data['file_name'];
             $message = 'The file has been uploaded';
         }
     } else {
         $message = 'No file has been sent';
     }
     // ------------------------
     // Write output
     // ------------------------
     // We are in an iframe, so we must talk to the object in window.parent
     echo "<script type='text/javascript'> window.parent.CKEDITOR.tools.callFunction({$funcNum}, '{$url}', '{$message}')</script>";
 }
Esempio n. 4
0
 /**
  * Performs actions enabled by its parameters.
  *
  * @param string $message Message to show with bitrix:system.show_message component.
  * @param bool $defineConstant If true then ERROR_404 constant defined.
  * @param bool $setStatus If true sets http response status.
  * @param bool $showPage If true then work area will be cleaned and /404.php will be included.
  * @param string $pageFile Alternative file to /404.php.
  *
  * @return void
  */
 public static function process404($message = "", $defineConstant = true, $setStatus = true, $showPage = false, $pageFile = "")
 {
     /** @global \CMain $APPLICATION */
     global $APPLICATION;
     if ($message != "") {
         $APPLICATION->includeComponent("bitrix:system.show_message", ".default", array("MESSAGE" => $message, "STYLE" => "errortext"), null, array("HIDE_ICONS" => "Y"));
     }
     if ($defineConstant && !defined("ERROR_404")) {
         define("ERROR_404", "Y");
     }
     if ($setStatus) {
         \CHTTP::setStatus("404 Not Found");
     }
     if ($showPage) {
         if ($APPLICATION->RestartWorkarea()) {
             if ($pageFile) {
                 require \Bitrix\Main\Application::getDocumentRoot() . rel2abs("/", "/" . $pageFile);
             } else {
                 require \Bitrix\Main\Application::getDocumentRoot() . "/404.php";
             }
             die;
         }
     }
 }
function get_link_list($url)
{
    global $run_environment;
    global $max_records;
    $html = scraperWiki::scrape($url);
    $dom = new simple_html_dom();
    $dom->load($html);
    $content = $dom->find("td[id=main_content]", 0)->find("table", 0)->find("span[class=bodytext]", 1);
    $count = 1;
    foreach ($content->find("a") as $link) {
        if ($link->href && strpos($link->plaintext, 'CBs') !== FALSE) {
            $url = rel2abs($link->href, $url);
            $name = substr($link->plaintext, 0, strpos($link->plaintext, ' CBs'));
            $borough['source'] = $url;
            $borough['name'] = $name;
            $links[] = $borough;
            $count++;
        }
    }
    // Clear memory
    $dom->__destruct();
    $content->__destruct();
    return $links;
}
Esempio n. 6
0
$FILE_NAME = false;
$ABS_FILE_NAME = false;
$WORK_DIR_NAME = false;
if ($arParams["USE_TEMP_DIR"] === "Y" && strlen($_SESSION["BX_HL_IMPORT"]["TEMP_DIR"]) > 0) {
    $DIR_NAME = $_SESSION["BX_HL_IMPORT"]["TEMP_DIR"];
} else {
    $DIR_NAME = $_SERVER["DOCUMENT_ROOT"] . "/" . COption::GetOptionString("main", "upload_dir", "upload") . "/1c_highloadblock/";
}
if (isset($_GET["filename"]) && strlen($_GET["filename"]) > 0 && strlen($DIR_NAME) > 0) {
    //This check for 1c server on linux
    $filename = preg_replace("#^(/tmp/|upload/1c/webdata)#", "", $_GET["filename"]);
    $filename = trim(str_replace("\\", "/", trim($filename)), "/");
    $io = CBXVirtualIo::GetInstance();
    $bBadFile = HasScriptExtension($filename) || IsFileUnsafe($filename) || !$io->ValidatePathString("/" . $filename);
    if (!$bBadFile) {
        $FILE_NAME = rel2abs($DIR_NAME, "/" . $filename);
        if (strlen($FILE_NAME) > 1 && $FILE_NAME === "/" . $filename) {
            $ABS_FILE_NAME = $DIR_NAME . $FILE_NAME;
            $WORK_DIR_NAME = substr($ABS_FILE_NAME, 0, strrpos($ABS_FILE_NAME, "/") + 1);
        }
    }
}
ob_start();
//This is the first exchange command
if ($_GET["mode"] == "checkauth" && $USER->IsAuthorized()) {
    if (COption::GetOptionString("main", "use_session_id_ttl", "N") == "Y" && COption::GetOptionInt("main", "session_id_ttl", 0) > 0 && !defined("BX_SESSION_ID_CHANGE")) {
        echo "failure\n", GetMessage("CC_BCIH_ERROR_SESSION_ID_CHANGE");
    } else {
        echo "success\n";
        echo session_name() . "\n";
        echo session_id() . "\n";
Esempio n. 7
0
<?php

require '../rel2abs.php';
require '../url_to_absolute.php';
require 'phpuri.php';
$tests = array(array('rel' => 'g:h', 'result' => 'g:h'), array('rel' => 'g', 'result' => 'http://a/b/c/g'), array('rel' => './g', 'result' => 'http://a/b/c/g'), array('rel' => 'g/', 'result' => 'http://a/b/c/g/'), array('rel' => '/g', 'result' => 'http://a/g'), array('rel' => '//g', 'result' => 'http://g'), array('rel' => 'g?y', 'result' => 'http://a/b/c/g?y'), array('rel' => '#s', 'result' => 'http://a/b/c/d;p?q#s'), array('rel' => 'g#s', 'result' => 'http://a/b/c/g#s'), array('rel' => 'g?y#s', 'result' => 'http://a/b/c/g?y#s'), array('rel' => ';x', 'result' => 'http://a/b/c/;x'), array('rel' => 'g;x', 'result' => 'http://a/b/c/g;x'), array('rel' => 'g;x?y#s', 'result' => 'http://a/b/c/g;x?y#s'), array('rel' => '.', 'result' => 'http://a/b/c/'), array('rel' => './', 'result' => 'http://a/b/c/'), array('rel' => '..', 'result' => 'http://a/b/'), array('rel' => '../', 'result' => 'http://a/b/'), array('rel' => '../g', 'result' => 'http://a/b/g'), array('rel' => '../..', 'result' => 'http://a/'), array('rel' => '../../', 'result' => 'http://a/'), array('rel' => '../../g', 'result' => 'http://a/g'), array('rel' => 'g.', 'result' => 'http://a/b/c/g.'), array('rel' => '.g', 'result' => 'http://a/b/c/.g'), array('rel' => 'g..', 'result' => 'http://a/b/c/g..'), array('rel' => '..g', 'result' => 'http://a/b/c/..g'), array('rel' => './../g', 'result' => 'http://a/b/g'), array('rel' => './g/.', 'result' => 'http://a/b/c/g/'), array('rel' => 'g/./h', 'result' => 'http://a/b/c/g/h'), array('rel' => 'g/../h', 'result' => 'http://a/b/c/h'), array('rel' => 'g;x=1/./y', 'result' => 'http://a/b/c/g;x=1/y'), array('rel' => 'g;x=1/../y', 'result' => 'http://a/b/c/y'), array('rel' => 'g?y/./x', 'result' => 'http://a/b/c/g?y/./x'), array('rel' => 'g?y/../x', 'result' => 'http://a/b/c/g?y/../x'), array('rel' => 'g#s/./x', 'result' => 'http://a/b/c/g#s/./x'), array('rel' => 'g#s/../x', 'result' => 'http://a/b/c/g#s/../x'));
# rel2abs
$start = microtime();
$base = 'http://a/b/c/d;p?q';
list($successes, $failures) = array(0, 0);
foreach ($tests as $test) {
    if (($r = rel2abs($test['rel'], $base)) == $test['result']) {
        $successes++;
    } else {
        $failures++;
    }
}
$elapsed = microtime() - $start;
echo "rel2abs:         successes -> {$successes}, failures => {$failures}, elapsed time: {$elapsed}\n";
# url_to_absolute
$start = microtime();
$base = 'http://a/b/c/d;p?q';
list($successes, $failures) = array(0, 0);
foreach ($tests as $test) {
    if (($r = url_to_absolute($base, $test['rel'])) == $test['result']) {
        $successes++;
    } else {
        $failures++;
    }
}
$elapsed = microtime() - $start;
Esempio n. 8
0
         echo "file_limit=0\n";
     }
 } elseif ($_GET["mode"] == "file") {
     $DIR_NAME = "/" . COption::GetOptionString("main", "upload_dir", "upload") . "/1c_exchange/";
     $ABS_FILE_NAME = false;
     $WORK_DIR_NAME = false;
     if (isset($_GET["filename"]) && strlen($_GET["filename"]) > 0) {
         //This check for 1c server on linux
         $filename = preg_replace("#^(/tmp/|upload/1c/webdata)#", "", $_GET["filename"]);
         //Filter file name crap all alone
         $filename = preg_replace("/[^a-zA-Z0-9_.\\/\\\\]/", "", $filename);
         $io = CBXVirtualIo::GetInstance();
         $bBadFile = HasScriptExtension($filename) || IsFileUnsafe($filename) || !$io->ValidatePathString("/" . $filename);
         if (!$bBadFile) {
             $filename = trim(str_replace("\\", "/", trim($filename)), "/");
             $FILE_NAME = rel2abs($_SERVER["DOCUMENT_ROOT"] . $DIR_NAME, "/" . $filename);
             if (strlen($FILE_NAME) > 1 && $FILE_NAME === "/" . $filename) {
                 $ABS_FILE_NAME = $_SERVER["DOCUMENT_ROOT"] . $DIR_NAME . $FILE_NAME;
                 $WORK_DIR_NAME = substr($ABS_FILE_NAME, 0, strrpos($ABS_FILE_NAME, "/") + 1);
             }
         }
     }
     if ($ABS_FILE_NAME) {
         if (function_exists("file_get_contents")) {
             $DATA = file_get_contents("php://input");
         } elseif (isset($GLOBALS["HTTP_RAW_POST_DATA"])) {
             $DATA =& $GLOBALS["HTTP_RAW_POST_DATA"];
         } else {
             $DATA = false;
         }
         if ($DATA !== false) {
Esempio n. 9
0
 public static function UnZip($file_name, $last_zip_entry = "", $start_time = 0, $interval = 0)
 {
     global $APPLICATION;
     $io = CBXVirtualIo::GetInstance();
     //Function and securioty checks
     if (!function_exists("zip_open")) {
         return false;
     }
     $dir_name = substr($file_name, 0, strrpos($file_name, "/") + 1);
     if (strlen($dir_name) <= strlen($_SERVER["DOCUMENT_ROOT"])) {
         return false;
     }
     $hZip = zip_open($file_name);
     if (!$hZip) {
         return false;
     }
     //Skip from last step
     if ($last_zip_entry) {
         while ($entry = zip_read($hZip)) {
             if (zip_entry_name($entry) == $last_zip_entry) {
                 break;
             }
         }
     }
     $io = CBXVirtualIo::GetInstance();
     //Continue unzip
     while ($entry = zip_read($hZip)) {
         $entry_name = zip_entry_name($entry);
         //Check for directory
         zip_entry_open($hZip, $entry);
         if (zip_entry_filesize($entry)) {
             $file_name = trim(str_replace("\\", "/", trim($entry_name)), "/");
             $file_name = $APPLICATION->ConvertCharset($file_name, "cp866", LANG_CHARSET);
             $file_name = preg_replace("#^import_files/tmp/webdata/\\d+/\\d+/import_files/#", "import_files/", $file_name);
             $bBadFile = HasScriptExtension($file_name) || IsFileUnsafe($file_name) || !$io->ValidatePathString("/" . $file_name);
             if (!$bBadFile) {
                 $file_name = $io->GetPhysicalName($dir_name . rel2abs("/", $file_name));
                 CheckDirPath($file_name);
                 $fout = fopen($file_name, "wb");
                 if (!$fout) {
                     return false;
                 }
                 while ($data = zip_entry_read($entry, 102400)) {
                     $data_len = function_exists('mb_strlen') ? mb_strlen($data, 'latin1') : strlen($data);
                     $result = fwrite($fout, $data);
                     if ($result !== $data_len) {
                         return false;
                     }
                 }
             }
         }
         zip_entry_close($entry);
         //Jump to next step
         if ($interval > 0 && time() - $start_time > $interval) {
             zip_close($hZip);
             return $entry_name;
         }
     }
     zip_close($hZip);
     return true;
 }
Esempio n. 10
0
 } elseif ($_REQUEST["server_action"] == "start") {
     $bWindowsHosting = false;
     $strCurrentOS = PHP_OS;
     if (StrToUpper(substr($strCurrentOS, 0, 3)) === "WIN") {
         $bWindowsHosting = true;
     }
     $phpPath = COption::GetOptionString("xmpp", "php_path", $bWindowsHosting ? "../apache/php.exe -c ../apache/php.ini" : "php -c /etc/php.ini");
     $serverPath = COption::GetOptionString("xmpp", "server_path", "./bitrix/modules/xmpp/xmppd.php");
     //$serverLogPath = COption::GetOptionString("xmpp", "server_log_path", "xmppd.log");
     chdir($_SERVER["DOCUMENT_ROOT"]);
     if ($phpPath == "../apache/php.exe -c ../apache/php.ini" && !file_exists($_SERVER['DOCUMENT_ROOT'] . "/../apache/php.exe") && file_exists($_SERVER['DOCUMENT_ROOT'] . "/../apache2/zendserver/bin/php.exe")) {
         $phpPath = "../Apache2/zendserver/bin/php.exe -c ../Apache2/zendserver/etc/php.ini";
     }
     if (trim($phpPath) == "../Apache2/zendserver/bin/php.exe -c ../Apache2/zendserver/etc/php.ini") {
         $phpPath = "./Apache2/zendserver/bin/php.exe -c ./Apache2/zendserver/etc/php.ini";
         $serverPath = '"' . rel2abs($_SERVER['DOCUMENT_ROOT'], $serverPath) . '"';
         chdir("..");
     }
     $startErrorMessage = "";
     $p = $phpPath . " " . ($bWindowsHosting ? $serverPath : $_SERVER['DOCUMENT_ROOT'] . ltrim($serverPath, '.')) . " test_mode";
     if (!$bWindowsHosting) {
         $p .= " 2>&1";
     } else {
         $p = str_replace("/", "\\", $p);
     }
     exec($p, $execOutput, $execReturnVar);
     $s = strtolower(implode("\n", $execOutput));
     if ($execReturnVar == 0) {
         if (strlen($s) <= 0) {
             $startErrorMessage .= "Unknown error";
         } elseif (strpos($s, "server started") === false || strpos($s, "error") !== false) {
Esempio n. 11
0
/**
 * Imports an xml file into iblock. File may be an .tar.gz archive.
 *
 * @param string $file_name Name of the file to import
 * @param string $iblock_type IBlock type ID to import iblock to
 * @param string|array $site_id ID of the site or array of IDs to bind iblock to
 * @param string $section_action What to do with sections missed in the file. D - delete or A - deactivate.
 * @param string $element_action What to do with elements missed in the file. D - delete or A - deactivate.
 * @param bool $use_crc Whenever to use CRC check for optimizi=ation or force an update
 * @param bool $preview If true when use iblock settings to generate preview pictures from detail.
 * @param bool $sync If true uses alternative set of tables in order not to interfere with other import processes
 * @param bool $return_last_error If true will return string with error description in case of failure
 * @param bool $return_iblock_id If true will return iblock identifier (int) in case of success
 * @return bool|int|string
 */
function ImportXMLFile($file_name, $iblock_type = "-", $site_id = '', $section_action = "D", $element_action = "D", $use_crc = false, $preview = false, $sync = false, $return_last_error = false, $return_iblock_id = false)
{
    /** @global CMain $APPLICATION */
    global $APPLICATION;
    $ABS_FILE_NAME = false;
    if (strlen($file_name) > 0) {
        if (file_exists($file_name) && is_file($file_name) && (substr($file_name, -4) === ".xml" || substr($file_name, -7) === ".tar.gz")) {
            $ABS_FILE_NAME = $file_name;
        } else {
            $filename = trim(str_replace("\\", "/", trim($file_name)), "/");
            $FILE_NAME = rel2abs($_SERVER["DOCUMENT_ROOT"], "/" . $filename);
            if (strlen($FILE_NAME) > 1 && $FILE_NAME === "/" . $filename && $APPLICATION->GetFileAccessPermission($FILE_NAME) >= "W") {
                $ABS_FILE_NAME = $_SERVER["DOCUMENT_ROOT"] . $FILE_NAME;
            }
        }
    }
    if (!$ABS_FILE_NAME) {
        return GetMessage("IBLOCK_XML2_FILE_ERROR");
    }
    $WORK_DIR_NAME = substr($ABS_FILE_NAME, 0, strrpos($ABS_FILE_NAME, "/") + 1);
    if (substr($ABS_FILE_NAME, -7) == ".tar.gz") {
        include_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/tar_gz.php";
        $obArchiver = new CArchiver($ABS_FILE_NAME);
        if (!$obArchiver->ExtractFiles($WORK_DIR_NAME)) {
            $strError = "";
            if (is_object($APPLICATION)) {
                $arErrors = $obArchiver->GetErrors();
                if (count($arErrors)) {
                    foreach ($arErrors as $error) {
                        $strError .= $error[1] . "<br>";
                    }
                }
            }
            if ($strError != "") {
                return $strError;
            } else {
                return GetMessage("IBLOCK_XML2_FILE_ERROR");
            }
        }
        $IMP_FILE_NAME = substr($ABS_FILE_NAME, 0, -7) . ".xml";
    } else {
        $IMP_FILE_NAME = $ABS_FILE_NAME;
    }
    $fp = fopen($IMP_FILE_NAME, "rb");
    if (!$fp) {
        return GetMessage("IBLOCK_XML2_FILE_ERROR");
    }
    if ($sync) {
        $table_name = "b_xml_tree_sync";
    } else {
        $table_name = "b_xml_tree";
    }
    $NS = array("STEP" => 0);
    $obCatalog = new CIBlockCMLImport();
    $obCatalog->Init($NS, $WORK_DIR_NAME, $use_crc, $preview, false, false, false, $table_name);
    if ($sync) {
        if (!$obCatalog->StartSession(bitrix_sessid())) {
            return GetMessage("IBLOCK_XML2_TABLE_CREATE_ERROR");
        }
        $obCatalog->ReadXMLToDatabase($fp, $NS, 0, 1024);
        $xml_root = $obCatalog->GetSessionRoot();
        $bUpdateIBlock = false;
    } else {
        $obCatalog->DropTemporaryTables();
        if (!$obCatalog->CreateTemporaryTables()) {
            return GetMessage("IBLOCK_XML2_TABLE_CREATE_ERROR");
        }
        $obCatalog->ReadXMLToDatabase($fp, $NS, 0, 1024);
        if (!$obCatalog->IndexTemporaryTables()) {
            return GetMessage("IBLOCK_XML2_INDEX_ERROR");
        }
        $xml_root = 1;
        $bUpdateIBlock = true;
    }
    fclose($fp);
    $result = $obCatalog->ImportMetaData($xml_root, $iblock_type, $site_id, $bUpdateIBlock);
    if ($result !== true) {
        return GetMessage("IBLOCK_XML2_METADATA_ERROR") . implode("\n", $result);
    }
    $obCatalog->ImportSections();
    $obCatalog->DeactivateSections($section_action);
    $obCatalog->SectionsResort();
    $obCatalog = new CIBlockCMLImport();
    $obCatalog->Init($NS, $WORK_DIR_NAME, $use_crc, $preview, false, false, false, $table_name);
    if ($sync) {
        if (!$obCatalog->StartSession(bitrix_sessid())) {
            return GetMessage("IBLOCK_XML2_TABLE_CREATE_ERROR");
        }
    }
    $SECTION_MAP = false;
    $PRICES_MAP = false;
    $obCatalog->ReadCatalogData($SECTION_MAP, $PRICES_MAP);
    $obCatalog->ImportElements(time(), 0);
    $obCatalog->ImportProductSets();
    $obCatalog->DeactivateElement($element_action, time(), 0);
    if ($sync) {
        $obCatalog->EndSession();
    }
    if ($return_last_error) {
        if (strlen($obCatalog->LAST_ERROR)) {
            return $obCatalog->LAST_ERROR;
        }
    }
    if ($return_iblock_id) {
        return intval($NS["IBLOCK_ID"]);
    } else {
        return true;
    }
}
Esempio n. 12
0
 public function prepUrl($link, $url, $domain)
 {
     //basic filtering of URLs we don't need
     //filter out links starting with '#'
     if ($link[0] == '#') {
         return false;
     }
     //filter out external links
     if ((strpos($link, 'http://') !== false || strpos($link, 'https://') !== false) && strpos($ancor, $domain) === false) {
         return false;
     }
     //absolute or relative URL
     if (0 === strpos($link, "http") || 0 === strpos($link, "https") || 0 === strpos($link, "/")) {
         //absolute
         if (0 === strpos($link, "/")) {
             //absolute without domain, append domain
             return "http://" . $domain . $link;
         } else {
             //nothing to do
             return $link;
         }
     } else {
         //relative
         //echo rel2abs($link, $url)."<br>";
         return rel2abs($link, $url);
     }
 }
Esempio n. 13
0
        if ($time > date('YmdHis')) {
            continue;
        }
        $title = in_array($elem['bt_type'], array('article', 'link', 'note')) ? $elem['bt_title'] : $elem['bt_author'];
        $tag = 'tag:' . parse_url($GLOBALS['racine'], PHP_URL_HOST) . ',' . date_create_from_format('YmdHis', $time)->format('Y-m-d') . ':' . $elem['bt_type'] . '-' . $elem['bt_id'];
        // normal code
        $xml_post .= '<entry>' . "\n";
        $xml_post .= '<title>' . $title . '</title>' . "\n";
        $xml_post .= '<id>' . $tag . '</id>' . "\n";
        $xml_post .= '<updated>' . date_create_from_format('YmdHis', $time)->format('c') . '</updated>' . "\n";
        if ($elem['bt_type'] == 'link') {
            if ($invert) {
                $xml_post .= '<link href="' . $GLOBALS['racine'] . '?id=' . $elem['bt_id'] . '"/>' . "\n";
                $xml_post .= '<content type="html">' . htmlspecialchars(rel2abs($elem['bt_content']) . '<br/> — (<a href="' . $elem['bt_link'] . '">link</a>)') . '</content>' . "\n";
            } else {
                $xml_post .= '<link href="' . $elem['bt_link'] . '"/>' . "\n";
                $xml_post .= '<content type="html">' . htmlspecialchars(rel2abs($elem['bt_content']) . '<br/> — (<a href="' . $GLOBALS['racine'] . '?id=' . $elem['bt_id'] . '">permalink</a>)') . '</content>' . "\n";
            }
        } else {
            $xml_post .= '<link href="' . $elem['bt_link'] . '"/>' . "\n";
            $xml_post .= '<content type="html">' . htmlspecialchars(rel2abs($elem['bt_content'])) . '</content>' . "\n";
        }
        $xml_post .= '</entry>' . "\n";
    }
    $xml .= '<updated>' . date_create_from_format('YmdHis', $main_updated)->format('c') . '</updated>' . "\n";
    $xml .= $xml_post;
    echo $xml;
}
$end = microtime(TRUE);
echo '<!-- generated in ' . round($end - $begin, 6) . ' seconds -->' . "\n";
echo '</feed>';
Esempio n. 14
0
                $RecipArray[$RecipIndex][0] = mysql_fetch_assoc($RecipArray[$RecipIndex][1]);
            }
        }
        $RecipIndex++;
    }
    @session_start();
    $_SESSION[$EmailRef . "_Status"] = $GLOBALS[$EmailRef . "_Status"];
    $_SESSION[$EmailRef . "_Index"] = $GLOBALS[$EmailRef . "_Index"];
    $_SESSION[$EmailRef . "_From"] = $GLOBALS[$EmailRef . "_From"];
    $_SESSION[$EmailRef . "_To"] = $GLOBALS[$EmailRef . "_To"];
    $_SESSION[$EmailRef . "_Subject"] = $GLOBALS[$EmailRef . "_Subject"];
    $_SESSION[$EmailRef . "_Body"] = $GLOBALS[$EmailRef . "_Body"];
    $_SESSION[$EmailRef . "_Header"] = $GLOBALS[$EmailRef . "_Header"];
    $_SESSION[$EmailRef . "_Log"] = $GLOBALS[$EmailRef . "_Log"];
    if (function_exists("rel2abs")) {
        $GoToPage = $GoToPage ? rel2abs($GoToPage, dirname(__FILE__)) : "";
    }
    if ($GoToPage != "") {
        header("Location: " . $GoToPage);
    }
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Untitled Document</title>
</head>

<body>
Esempio n. 15
0
        $zip->close();
        $res = searchInDir(array('\\.(js)$'), $build_directory, TRUE);
        $zipFilename = str_replace('.min.js', '.zip', basename($res[0]));
        header('Content-Type: application/zip');
        header('Content-Disposition: attachment; filename="' . $zipFilename . '"');
        header('Content-Length: ' . filesize($pathZipFile));
        readfile($pathZipFile);
        unlink($pathZipFile);
        exit;
    } else {
        if ($format == 'code') {
            $typeFile = 'js';
            if (strtolower(param('file')) == 'css') {
                $typeFile = 'css';
            }
            $files = searchInDir(array('\\.' . $typeFile . '$'), $build_directory, TRUE);
            echo file_get_contents($files[0]);
        } else {
            if ($format == 'json') {
                // Return Json object
                echo json_encode(array('status' => 'success', 'result' => array('guid' => $guid, 'filenames' => array_map(function ($path) {
                    $relativePath = getRelativePath(WINK_DIRECTORY, $path);
                    $baseURL = 'http://' . $_SERVER['SERVER_NAME'] . '/' . basename(realpath(WINK_DIRECTORY)) . '/';
                    return rel2abs($relativePath, $baseURL);
                }, searchInDir(array('\\.(css|js)$'), $build_directory, TRUE)))));
            }
        }
    }
} catch (Exception $e) {
    echo json_encode(array('status' => 'fail', 'result' => array('code' => $e->getCode(), 'message' => $e->getMessage())));
}
Esempio n. 16
0
 public function homepage(Application $app, Request $request)
 {
     $data = array('url' => 'your url');
     $form = $app['form.factory']->createBuilder('form')->add('url', 'url', array('label' => false, 'attr' => array('placeholder' => 'Insert your URL', 'class' => 'form-control')))->add('analyze', 'submit', array('label' => 'Analyze', 'attr' => array('class' => 'btn btn-default')))->getForm();
     $form->handleRequest($request);
     if ($request->getMethod() == 'POST') {
         $date = date("Y-m-d h:i:sa");
         $data = $form->getData();
         $target = $data['url'];
         $page = new HttpCurl();
         $page->get($target);
         /*echo " Web Page Header<br>";
           print_r($page->getHeader());
           echo "<br>";
           echo " Web Page Status<br>";
           print_r($page->getStatus());
           echo "<br>";
           echo " Web Page Body<br>";*/
         $htmlContent = $page->getBody();
         //function to convert relative url to absolute
         function rel2abs($rel, $base)
         {
             // parse base URL  and convert to local variables: $scheme, $host,  $path
             extract(parse_url($base));
             if (strpos($rel, "//") === 0) {
                 return $scheme . ':' . $rel;
             }
             // return if already absolute URL
             if (parse_url($rel, PHP_URL_SCHEME) != '') {
                 return $rel;
             }
             // queries and anchors
             if ($rel[0] == '#' || $rel[0] == '?') {
                 return $base . $rel;
             }
             // remove non-directory element from path
             $path = preg_replace('#/[^/]*$#', '', $path);
             // destroy path if relative url points to root
             if ($rel[0] == '/') {
                 $path = '';
             }
             // dirty absolute URL
             $abs = $host . $path . "/" . $rel;
             // replace '//' or  '/./' or '/foo/../' with '/'
             $abs = preg_replace("/(\\/\\.?\\/)/", "/", $abs);
             $abs = preg_replace("/\\/(?!\\.\\.)[^\\/]+\\/\\.\\.\\//", "/", $abs);
             // absolute URL is ready!
             return $scheme . '://' . $abs;
         }
         //exploding contents of web page
         $dom = new DOMdocument();
         @$dom->loadHTML($htmlContent);
         $dom->preserveWhiteSpace = false;
         $xpath = new DOMXpath($dom);
         //------------------capture image-----------------------//
         //define which selector to extract
         $selector = '//img';
         $tags = $xpath->query($selector);
         //print_r($tags);
         $tagsLength = $tags->length;
         # loop over all <img> tags and convert them to data uri
         for ($i = 0; $i < $tagsLength; $i++) {
             $tag = $tags->item($i);
             $src = $tag->getAttribute('src');
             $images[] = rel2abs($src, $target);
         }
         foreach ($images as $key) {
             $url = $key;
             $path = realpath(__DIR__ . '/../../');
             $img = $path . '/files/DownloadedImages/' . basename($url);
             file_put_contents($img, file_get_contents($url));
         }
         //------------------capture css file-----------------------//
         $styleSheets = array();
         $selector = '//link[contains(@rel, "stylesheet")]';
         $cssTag = $xpath->query($selector);
         foreach ($cssTag as $tag) {
             //array('stylesheet' => $tag->getAttribute('href'));
             array_push($styleSheets, rel2abs($tag->getAttribute('href'), $target));
         }
         foreach ($styleSheets as $key => $value) {
             $path = realpath(__DIR__ . '/../../');
             $stylesheetFile = $path . '/files/DownloadedCss/' . basename($value);
             file_put_contents($stylesheetFile, file_get_contents($value));
         }
         //------------------capture js file-----------------------//
         $scripts = array();
         $selector = '//script[contains(@src, "")]';
         $jsTag = $xpath->query($selector);
         foreach ($jsTag as $key) {
             array_push($scripts, rel2abs($key->getAttribute('src'), $target));
         }
         foreach ($scripts as $script => $value) {
             $path = realpath(__DIR__ . '/../../');
             $jsFile = $path . '/files/DownloadedJs/' . basename($value);
             file_put_contents($jsFile, file_get_contents($value));
         }
         //------------------capture all html files-----------------------//
         $regexp = '<a\\s[^>]*href=(\\"??)([^\\" >]*?)\\1[^>]*>(.*)<\\/a>';
         if (preg_match_all("/{$regexp}/siU", $htmlContent, $matches, PREG_SET_ORDER)) {
             foreach ($matches as $key) {
                 $links[] = $key[2];
             }
         }
         foreach ($links as $key => $value) {
             // Create a URL handle.
             $ch = curl_init();
             // Tell curl what URL we want.
             curl_setopt($ch, CURLOPT_URL, $value);
             // We want to return the web page from curl_exec, not
             // print it.
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             // Set this if you don't want the content header.
             curl_setopt($ch, CURLOPT_HEADER, 0);
             // Download the HTML from the URL.
             $content = curl_exec($ch);
             // Check to see if there were errors.
             if (curl_errno($ch)) {
                 // We have an error. Show the error message.
                 echo curl_error($ch);
             } else {
                 // No error. Save the page content.
                 $path = realpath(__DIR__ . '/../../');
                 $file = $path . '/files/DownloadedHtml/' . basename($value) . '.html';
                 // Open a file for writing.
                 $fh = fopen($file, 'w');
                 if (!$fh) {
                     // Couldn't create the file.
                     echo "Unable to create {$file}";
                 } else {
                     // Write the retrieved html to the file.
                     fwrite($fh, $content);
                     // Close the file.
                     fclose($fh);
                 }
             }
             // Close the curl handle.
             curl_close($ch);
         }
     }
     return $app['twig']->render('@front/homepage.twig', array('form' => $form->createView()));
 }
Esempio n. 17
0
function proxifyCSS($css, $baseURL)
{
    return preg_replace_callback('/url\\((.*?)\\)/i', function ($matches) use($baseURL) {
        $url = $matches[1];
        //Remove any surrounding single or double quotes from the URL so it can be passed to rel2abs - the quotes are optional in CSS
        //Assume that if there is a leading quote then there should be a trailing quote, so just use trim() to remove them
        if (strpos($url, "'") === 0) {
            $url = trim($url, "'");
        }
        if (strpos($url, "\"") === 0) {
            $url = trim($url, "\"");
        }
        if (stripos($url, "data:") === 0) {
            return "url(" . $url . ")";
        }
        //The URL isn't an HTTP URL but is actual binary data. Don't proxify it.
        return "url(" . PROXY_PREFIX . rel2abs($url, $baseURL) . ")";
    }, $css);
}
Esempio n. 18
0
 public function SetTTFFontsPath($ttfFilesPath)
 {
     if (strlen($ttfFilesPath) > 0) {
         $filename = trim(str_replace("\\", "/", trim($ttfFilesPath)), "/");
         $FILE_NAME = rel2abs($_SERVER["DOCUMENT_ROOT"], "/" . $filename);
         if (strlen($FILE_NAME) > 1 && is_dir($_SERVER["DOCUMENT_ROOT"] . $FILE_NAME)) {
             $this->ttfFilesPath = $FILE_NAME;
         }
     }
 }
 $html = DecodeData($html, array());
 $doc = new DOMDocument();
 libxml_use_internal_errors(TRUE);
 $doc->loadHTML($html);
 libxml_use_internal_errors(FALSE);
 $xpath = new DOMXpath($doc);
 $links = $xpath->query(".//a[@class='l']/@href");
 if ($links->length != 0) {
     foreach ($links as $link) {
         $scrapedUrls[] = $link->nodeValue;
     }
 } else {
     $links = $xpath->query(".//h3[@class='r']/a/@href");
     foreach ($links as $link) {
         $theLink = $link->nodeValue;
         $theLink = rel2abs($theLink, $url);
         $parts = GetQueryParameters(trim($theLink));
         $foundUrl = "EMPTY";
         if (isset($parts['url'])) {
             $foundUrl = urldecode($parts['url']);
         } elseif (isset($parts['q'])) {
             $foundUrl = urldecode($parts['q']);
         }
         if (isValidUrl($foundUrl)) {
             //$converter = new idna_convert(); << used to decode punycode
             //$foundUrl = $converter->decode($foundUrl); << used to decode punycode
             $scrapedUrls[] = $foundUrl;
             //echo "\n$foundUrl\t$theLink\n";
         }
     }
 }
Esempio n. 20
0
function proxifyJS($js, $baseURL)
{
    return preg_replace_callback('#([\'"])([^\'"]*[\\.](php|txt|xml))[\'"]#i', function ($matches) use($baseURL) {
        $path = $matches[2];
        return "'" . PROXY_PREFIX . rel2abs($path, $baseURL) . "'";
    }, htmlentities($js));
}
Esempio n. 21
0
require_once "../../Connections/bikes_db.php";
//Security
chdir($startKFMDir);
$kfm_hidden_sidebar = false;
if (isset($_GET['showsidebar']) && $_GET['showsidebar'] == 'false') {
    $kfm_hidden_sidebar = true;
}
$kfm_db_type = 'mysql';
$kfm_db_prefix = 'wafm2_';
$kfm_db_host = $hostname_bikes_db;
$kfm_db_name = $database_bikes_db;
$kfm_db_username = $username_bikes_db;
$kfm_db_password = $password_bikes_db;
$kfm_db_port = '';
$use_kfm_security = false;
$kfm_userfiles_address = '../../admin/media';
if (isset($_SESSION['useOverrideRoot'])) {
    $kfm_userfiles_address = abs2rel($_SESSION['useOverrideRoot'], dirname(__FILE__));
}
$kfm_userfiles_output = rel2abs($kfm_userfiles_address, dirname(__FILE__));
$kfm_workdirectory = '.thumbnails';
$kfm_imagemagick_path = '/usr/bin/convert';
$kfm_dont_send_metrics = 1;
$kfm_server_hours_offset = 1;
/**
 * This function is called in the admin area. To specify your own admin requirements or security, un-comment and edit this function
 */
function kfm_admin_check()
{
    return false;
}
Esempio n. 22
0
 public function UpdatePaths($origStr, $endDir, $startDir)
 {
     if ($startDir == ".") {
         $startDir = $endDir;
     }
     if ($startDir == "..") {
         $startDir = "../";
     }
     $props = array();
     $props[] = 'href';
     $props[] = 'action';
     $props[] = 'src';
     //  @import url("css/common.css");
     $subStr = $origStr;
     $matchpat = '/(url|Image|MM_preloadImages|MM_swapImage)(\\(\\s*|\\s*=\\s*)([\'"])?([^)\'"\\r\\n]*)\\3(\\s*\\)|\\s*[;\\,])/i';
     //echo($origStr);
     preg_match($matchpat, $subStr, $subPats);
     $ignore = '/^(https?%3A%2F%2F|https?:\\/\\/|mailto:|javascript:|#|\\/)/i';
     $combineDir = rel2abs($startDir, $endDir);
     while (sizeof($subPats) > 0) {
         if ($subPats[1] == "MM_swapImage") {
             preg_match('/(MM_swapImage)((?:\\(\\s*|\\s*=\\s*)[^\\r\\n,]*,[^\\r\\n,]*,)([\'"])?([^)\\r\\n]*)\\3(\\s*\\)|\\s*[;\\,])/i', $subStr, $subPats);
         }
         if ($subPats[1] == "MM_preloadImages") {
             preg_match('/MM_preloadImages\\(((?:[^\\),],?){1,})\\)/i', $subStr, $subPats2);
             $pieces = explode(",", $subPats2[1]);
             $subPats[0] = $subPats2[0];
             $subPats[1] = substr($subPats2[0], 0, strrpos($subPats2[0], $pieces[sizeof($pieces) - 1]));
             $subPats[2] = "";
             $subPats[5] = ")";
             for ($x = 0; $x < sizeof($pieces); $x++) {
                 preg_match('/\\s*([\'"])?([^)\\r\\n]*)\\1/', $pieces[$x], $linkAtts);
                 $subPats[3] = $linkAtts[1];
                 $subPats[4] = $linkAtts[2];
                 if (preg_match($ignore, $linkAtts[2]) == 0 && $linkAtts[2] != "" && $x < sizeof($pieces) - 1) {
                     $absDir = rel2abs($linkAtts[2], $combineDir);
                     $relDir = abs2rel($absDir, $endDir);
                     $subPats[1] = str_replace($pieces[$x], $subPats[3] . $relDir . $subPats[3], $subPats[1]);
                 }
             }
         }
         if (preg_match($ignore, $subPats[4]) == 0 && $subPats[4] != "") {
             $absDir = rel2abs($subPats[4], $combineDir);
             $relDir = abs2rel($absDir, $endDir);
             $origStr = str_replace($subPats[0], $subPats[1] . $subPats[2] . $subPats[3] . $relDir . $subPats[3] . $subPats[5], $origStr);
         }
         $subStr = str_replace($subPats[0], '', $subStr);
         preg_match($matchpat, $subStr, $subPats);
     }
     $ignoreTags["fb:like"] = array();
     $ignoreTags["fb:like"][] = "action";
     for ($x = 0; $x < sizeof($props); $x++) {
         $beforeMatch = "";
         $afterMatch = $origStr;
         $matchptn = $props[$x];
         preg_match('/' . $matchptn . '=([\'"])([^"\']*)["\']/i', $origStr, $subPats);
         while (sizeof($subPats) > 0) {
             $beforeMatch .= substr($afterMatch, 0, strpos($afterMatch, $subPats[0]));
             $afterMatch = substr($afterMatch, strpos($afterMatch, $subPats[0]) + strlen($subPats[0]));
             $skipIt = false;
             $tagMatch = substr($beforeMatch, strpos($beforeMatch, "<") + 1);
             $tagMatch = substr($tagMatch, 0, strpos($tagMatch, ">"));
             if (strpos($tagMatch, " ") !== false) {
                 $tagMatch = substr($tagMatch, 0, strpos($tagMatch, " "));
             }
             if (isset($ignoreTags[$tagMatch]) && in_array($matchptn, $ignoreTags[$tagMatch])) {
                 $skipIt = true;
             }
             if (preg_match($ignore, $subPats[2]) == 0 && !$skipIt) {
                 $absDir = rel2abs($subPats[2], $combineDir);
                 $relDir = abs2rel($absDir, $endDir);
                 $beforeMatch .= $matchptn . '=' . $subPats[1] . $relDir . $subPats[1];
             } else {
                 $beforeMatch .= $subPats[0];
             }
             preg_match('/' . $matchptn . '=([\'"])([^"\']*)["\']/i', $afterMatch, $subPats);
         }
         $origStr = $beforeMatch . $afterMatch;
     }
     return $origStr;
 }
Esempio n. 23
0
function readlinks1($content)
{
$file=$content;
$file= removetags($file,"<script","</script>");
$file= removetags($file,"<SCRIPT","</SCRIPT>");
$file= removetags($file,"<style","</style>");
$file= removetags($file,"<link",">");
$file= removetags($file,"<LINK",">");
$file= removetags($file,"{","}");
$file=strip_tags($file,"<br/>,<br>,<p>,<div>,<P>,<h1>,<h2>,<h3>,<h4>,<h5>,<h6>,<span>,</h1>,</div>,</h2>,</h3>,</h4>,</h5>,</h6>,<a>,</a>,<B>,</B>,<body>");
        
    preg_match_all ("/a[\s]+[^>]*?href[\s]?=[\s\"\']+"."(.*?)[\"\']+.*?>"."([^<]+|.*?)?<\/a>/", $file, $matches);
$k=15;
	$match1=($matches[1]);
    $match2=($matches[2]); 

	//echo "<pre>";
	//print_r($matches);
	foreach($match1 as $url)
       {    
	       $match4=strip_tags($match2[$i]);
		   if($j>10)
		   {
		   
		      //break;
		      
		    }
			else
			{
			   if((strlen($match4))>30)
			   {
					$match3=trim($match4); 
					$a1=preg_match("#http#",$url,$a2);
					if($a1<=0)
					{
						$url=rel2abs($url, $base);
					}	
					$link1=$url;
					$title1=$match3;		
					$c3=strlen(trim($link1));			 
					$c4=strlen(trim($title1));
					 if(($c3>0)&&($c4>0))
					{
					$text1=$link1."666".$title1."11111111111";
					$text2=$text2.$text1;
					}	
					/*
					$text1=$link1."666".$title1."11111111111";
					$text2=$text2.$text1;
					*/
					$j=$j+1;
			   }		
			   $i=$i+1;
				if($j>$k)
				{
				  //break;		
				}
		    }
		}
		return $text2;
		//exit();
}
function get_district_data($district)
{
    global $run_environment;
    $html = scraperWiki::scrape($district['source']);
    $dom = new simple_html_dom();
    $dom->load($html);
    $count = 1;
    // ################# Get Photo #################
    $photo = $dom->find("td[class=inside_top_image]", 0)->find("img", 0)->src;
    $district['image_url'] = rel2abs($photo, $district['source']);
    // ################# Check for Contact URL #################
    $navlist = $dom->find("ul[class=members_subnav]", 0)->innertext;
    $navlist = get_between($navlist, 'NAV_NODES_MEMBERS = ', '];') . ']';
    $navlist = str_replace("','", "'###'", $navlist);
    $navlist = str_replace('[', '', $navlist);
    $navlist = str_replace(']', '', $navlist);
    $navlist = trim($navlist, ',');
    $navlist = explode(',', $navlist);
    foreach ($navlist as $item) {
        $item = explode('###', $item);
        if (strpos($item[0], 'Contact Council') && !empty($item[1])) {
            $link = '../..' . trim($item[1], "'");
            $link = rel2abs($link, $district['source']);
            $district['contact_url'] = $link;
        }
    }
    if (empty($district['contact_url'])) {
        $district['contact_url'] = null;
    }
    // ################# Get Contact info #################
    $contacts = $dom->find("td[class=nav_text]", 0)->innertext;
    $contacts = explode("<b>", $contacts);
    foreach ($contacts as $val) {
        $val = str_replace("</b>", "", $val);
        $val = trim($val);
        $val = trim($val, "<br>");
        $val = trim($val);
        $val = explode("<br>", $val);
        array_walk($val, create_function('&$val', '$val = trim($val);'));
        if ($val[0]) {
            $val[0] = strtolower(str_replace(' ', '_', $val[0]));
            // Make sure the field wasn't misspelld :)
            if (strpos($val[0], 'legistlative') !== false) {
                $val[0] = str_replace('legistlative', 'legislative', $val[0]);
            }
            $field[$val[0]] = $val[1];
        }
    }
    // check if we have a non-empty email address and strip away html
    if (!empty($field['email']) && strpos($field['email'], 'mailto') && strpos($field['email'], '><') === false) {
        $field['email'] = get_between($field['email'], 'mailto:', '">');
    } else {
        $field['email'] = null;
    }
    $district = array_merge($district, $field);
    if ($run_environment == 'dev') {
        return $district;
    } else {
        scraperwiki::save_sqlite(array('name', 'source'), $district);
        return true;
    }
}
$row_WADAadvertising = mysql_fetch_assoc($WADAadvertising);
$totalRows_WADAadvertising = mysql_num_rows($WADAadvertising);
// get image types (placed in ad_prioity column)
$cat_image_id = "-1";
mysql_select_db($database_bikes_db, $bikes_db);
$query_cats_image = sprintf("SELECT* FROM advertisingtype");
$cats_image = mysql_query($query_cats_image, $bikes_db) or die(mysql_error());
$row_cats_image = mysql_fetch_assoc($cats_image);
$totalRows_cats_image = mysql_num_rows($cats_image);
// WA DataAssist Update
if (isset($_POST["Update"]) || isset($_POST["Update_x"])) {
    $WA_connection = $bikes_db;
    $WA_table = "advertising";
    $WA_redirectURL = "advertising_detail.php?ad_id=" . (isset($_POST["WADAUpdateRecordID"]) ? $_POST["WADAUpdateRecordID"] : "") . "" . (isset($_GET["pageNum_WADAadvertising"]) ? "&pageNum_WADAadvertising=" . intval($_GET["pageNum_WADAadvertising"]) : "") . "";
    if (function_exists("rel2abs")) {
        $WA_redirectURL = $WA_redirectURL ? rel2abs($WA_redirectURL, dirname(__FILE__)) : "";
    }
    $WA_keepQueryString = false;
    $WA_indexField = "ad_id";
    $WA_fieldNamesStr = "ad_title|ad_expire|ad_live|ad_priority|ad_notes";
    $WA_fieldValuesStr = "" . (isset($_POST["ad_title"]) ? $_POST["ad_title"] : "") . "" . $WA_AB_Split . "" . (isset($_POST["ad_expire"]) ? $_POST["ad_expire"] : "") . "" . $WA_AB_Split . "" . (isset($_POST["ad_live"]) ? $_POST["ad_live"] : "") . "" . $WA_AB_Split . "" . (isset($_POST["ad_priority"]) ? $_POST["ad_priority"] : "") . "" . $WA_AB_Split . "" . (isset($_POST["ad_notes"]) ? $_POST["ad_notes"] : "") . "";
    $WA_columnTypesStr = "',none,''|',none,''|',none,''|',none,''|',none,''";
    $WA_comparisonStr = "=|=|=|=|=";
    $WA_fieldNames = explode("|", $WA_fieldNamesStr);
    $WA_fieldValues = explode($WA_AB_Split, $WA_fieldValuesStr);
    $WA_columns = explode("|", $WA_columnTypesStr);
    $WA_where_fieldValuesStr = "" . (isset($_POST["WADAUpdateRecordID"]) ? $_POST["WADAUpdateRecordID"] : "") . "";
    $WA_where_columnTypesStr = "',none,''";
    $WA_where_comparisonStr = "=";
    $WA_where_fieldNames = explode("|", $WA_indexField);
    $WA_where_fieldValues = explode($WA_AB_Split, $WA_where_fieldValuesStr);
Esempio n. 26
0
        $time = isset($elem['bt_date']) ? $elem['bt_date'] : $elem['bt_id'];
        if ($time > date('YmdHis')) {
            continue;
        }
        $title = in_array($elem['bt_type'], array('article', 'link', 'note')) ? $elem['bt_title'] : $elem['bt_author'];
        // normal code
        $xml_post = '<item>' . "\n";
        $xml_post .= '<title>' . $title . '</title>' . "\n";
        $xml_post .= '<guid isPermaLink="false">' . $GLOBALS['racine'] . '?mode=links&amp;id=' . $elem['bt_id'] . '</guid>' . "\n";
        $xml_post .= '<pubDate>' . date_create_from_format('YmdHis', $time)->format('r') . '</pubDate>' . "\n";
        if ($elem['bt_type'] == 'link') {
            if ($invert) {
                $xml_post .= '<link>' . $GLOBALS['racine'] . '?id=' . $elem['bt_id'] . '</link>' . "\n";
                $xml_post .= '<description><![CDATA[' . rel2abs($elem['bt_content']) . '<br/> — (<a href="' . $elem['bt_link'] . '">link</a>)]]></description>' . "\n";
            } else {
                $xml_post .= '<link>' . $elem['bt_link'] . '</link>' . "\n";
                $xml_post .= '<description><![CDATA[' . rel2abs($elem['bt_content']) . '<br/> — (<a href="' . $GLOBALS['racine'] . '?id=' . $elem['bt_id'] . '">permalink</a>)]]></description>' . "\n";
            }
        } else {
            $xml_post .= '<link>' . $elem['bt_link'] . '</link>' . "\n";
            $xml_post .= '<description><![CDATA[' . rel2abs($elem['bt_content']) . ']]></description>' . "\n";
        }
        $xml_post .= '</item>' . "\n";
        $xml .= $xml_post;
    }
}
$end = microtime(TRUE);
$xml .= '<!-- generated in ' . round($end - $begin, 6) . ' seconds -->' . "\n";
$xml .= '</channel>' . "\n";
$xml .= '</rss>';
echo $xml;
Esempio n. 27
0
if ($_GET['mode'] == 'native') {
    if (!$enable_native) {
        $contents = 'ERROR: invalid mode';
        $status = array('http_code' => 'ERROR');
    }
    // Propagate headers to response.
    $html = false;
    foreach ($header_text as $header) {
        if (preg_match('/text\\/html/i', $header)) {
            $html = true;
        }
        if (preg_match('/^(?:Content-Type|Content-Language|Set-Cookie):/i', $header)) {
            header($header);
        }
    }
    $contents = preg_replace('/url\\((["|\']?(.*)["|\']?)\\)/i', 'url(' . rel2abs('${1}', $url) . ')', $contents);
    $contents = preg_replace('/href=\\"([^\\"]*)\\"/ie', "'href=\"'.rel2abs('\\1','{$url}').'\"'", $contents);
    $contents = preg_replace('/src=\\"([^\\"]*)\\"/ie', "'src=\"'.rel2abs('\\1','{$url}').'\"'", $contents);
    $contents = preg_replace('/(<\\/head>)/i', '<script type="text/javascript" src="js/proxy.js"></script>${1}', $contents);
    $contents = preg_replace('/<object?.*width="(.*?)".*object>/smi', '<div style="width:$1px;min-height:150px;background:#fff url(img/flash_lego_block.png) 50% 50% no-repeat"></div>', $contents);
    $contents = preg_replace('/(<body)/i', '<body onload="load()"', $contents);
    //write to cache
    if ($html) {
        $fh = fopen($filename, 'w') or die('something went terribly wrong');
        fwrite($fh, $contents);
        fclose($fh);
    }
    print $contents;
} else {
    // $data will be serialized into JSON data.
    $data = array();
Esempio n. 28
0
function proxify_url($url, $base_url = '')
{
    $url = htmlspecialchars_decode($url);
    if ($base_url) {
        $base_url = add_http($base_url);
        $url = rel2abs($url, $base_url);
    }
    return app_url() . '?q=' . url_encrypt($url);
}
Esempio n. 29
0
    function NewMediaObject($params)
    {
        global $USER, $DB;
        $blogId = IntVal(CBlogMetaWeblog::DecodeParams($params[0]["#"]["value"][0]["#"]));
        $user = CBlogMetaWeblog::DecodeParams($params[1]["#"]["value"][0]["#"]);
        $password = CBlogMetaWeblog::DecodeParams($params[2]["#"]["value"][0]["#"]);
        $arImage = $params[3]["#"]["value"][0]["#"]["struct"][0]["#"]["member"];
        foreach ($arImage as $val) {
            $arImageInfo[$val["#"]["name"][0]["#"]] = CBlogMetaWeblog::DecodeParams($val["#"]["value"][0]["#"]);
        }
        if (CBlogMetaWeblog::Authorize($user, $password)) {
            $result = '';
            $userId = $USER->GetID();
            if (IntVal($blogId) > 0) {
                $dbBlog = CBlog::GetList(array(), array("GROUP_SITE_ID" => SITE_ID, "ACTIVE" => "Y", "ID" => $blogId), false, false, array("ID", "URL", "NAME"));
                if ($arBlog = $dbBlog->GetNext()) {
                    $filename = trim(str_replace("\\", "/", trim($arImageInfo["name"])), "/");
                    $DIR_NAME = CTempFile::GetDirectoryName(12);
                    $FILE_NAME = rel2abs($DIR_NAME, "/" . $filename);
                    if (strlen($FILE_NAME) > 1 && $FILE_NAME === "/" . $filename) {
                        $ABS_FILE_NAME = $DIR_NAME . $FILE_NAME;
                    } else {
                        $ABS_FILE_NAME = "";
                    }
                    CheckDirPath($DIR_NAME);
                    if (strlen($ABS_FILE_NAME) > 0 && ($fp = fopen($ABS_FILE_NAME, "ab"))) {
                        $result = fwrite($fp, $arImageInfo["bits"]);
                        if ($result !== (function_exists("mb_strlen") ? mb_strlen($arImageInfo["bits"], 'latin1') : strlen($arImageInfo["bits"]))) {
                            return '<fault>
									<value>
										<struct>
											<member>
												<name>faultCode</name>
												<value><int>3</int></value>
												</member>
											<member>
												<name>faultString</name>
												<value><string>Error on saving media object</string></value>
												</member>
											</struct>
										</value>
									</fault>';
                        }
                        fclose($fp);
                    } else {
                        return '<fault>
								<value>
									<struct>
										<member>
											<name>faultCode</name>
											<value><int>3</int></value>
											</member>
										<member>
											<name>faultString</name>
											<value><string>Error on saving media object</string></value>
											</member>
										</struct>
									</value>
								</fault>';
                    }
                    $arFields = array("BLOG_ID" => $arBlog["ID"], "USER_ID" => $userId, "=TIMESTAMP_X" => $DB->GetNowFunction(), "FILE_ID" => array("name" => $arImageInfo["name"], "tmp_name" => $ABS_FILE_NAME, "MODULE_ID" => "blog", "type" => $arImageInfo["type"]));
                    $imageId = CBlogImage::Add($arFields);
                    $arImg = CBlogImage::GetByID($imageId);
                    $arFile = CFile::GetFileArray($arImg["FILE_ID"]);
                    $path = $arFile["SRC"];
                    $dbSite = CSite::GetByID(SITE_ID);
                    $arSite = $dbSite->Fetch();
                    $serverName = htmlspecialcharsEx($arSite["SERVER_NAME"]);
                    if (strlen($serverName) <= 0) {
                        if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) {
                            $serverName = SITE_SERVER_NAME;
                        } else {
                            $serverName = COption::GetOptionString("main", "server_name", "www.bitrixsoft.com");
                        }
                    }
                    if (strlen($path) > 0) {
                        return '<params>
							<param>
								<value>
									<struct>
									<member>
									<name>url</name>
									<value>
									<string>' . CHTTP::URN2URI($path, $serverName) . '</string>
									</value>
									</member>
									</struct>
								</value>
							</param>
						</params>';
                    }
                }
            }
            return '<fault>
				<value>
					<struct>
						<member>
							<name>faultCode</name>
							<value><int>3</int></value>
							</member>
						<member>
							<name>faultString</name>
							<value><string>Error on saving media object</string></value>
							</member>
						</struct>
					</value>
				</fault>';
        } else {
            return '<fault>
				<value>
					<struct>
						<member>
							<name>faultCode</name>
							<value><int>3</int></value>
							</member>
						<member>
							<name>faultString</name>
							<value><string>' . $arAuthResult["MESSAGE"] . '</string></value>
							</member>
						</struct>
					</value>
				</fault>';
        }
    }
Esempio n. 30
0
		</td>
	</tr>

	<tr class="heading">
		<td colspan="2"><?php 
    echo GetMessage("IBLOCK_ADM_IMP_DATA_SAMPLES");
    ?>
</td>
	</tr>
	<tr>
		<td colspan="2" align="center">
			<?php 
    $sContent = "";
    if (strlen($DATA_FILE_NAME) > 0) {
        $DATA_FILE_NAME = trim(str_replace("\\", "/", trim($DATA_FILE_NAME)), "/");
        $FILE_NAME = rel2abs($_SERVER["DOCUMENT_ROOT"], "/" . $DATA_FILE_NAME);
        if (strlen($FILE_NAME) > 1 && $FILE_NAME == "/" . $DATA_FILE_NAME && $APPLICATION->GetFileAccessPermission($FILE_NAME) >= "W") {
            $f = $io->GetFile($_SERVER["DOCUMENT_ROOT"] . $FILE_NAME);
            $file_id = $f->open("rb");
            $sContent = fread($file_id, 10000);
            fclose($file_id);
        }
    }
    ?>
			<textarea name="data" wrap="OFF" rows="10" cols="80" style="width:100%"><?php 
    echo htmlspecialcharsbx($sContent);
    ?>
</textarea>
		</td>
	</tr>
	<?php