Пример #1
0
function processUpload()
{
    global $mysql_link;
    // TODO update
    $image_desc = getRequestParameter("imageDesc");
    $upload_user = gethostbyaddr($_SERVER['REMOTE_ADDR']);
    $image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
    //SQL Injection defence!
    $image_name = addslashes($_FILES['image']['name']);
    $uploadSql = "INSERT INTO `omnichanneldemo`.`demo_image` (`id`, `image`, `name`, `desc`, `create_dttm`, `modify_dttm`, `uploaded_by`) VALUES (NULL, '{$image}', '{$image_name}', '{$image_desc}', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '{$upload_user}');";
    $result = $mysql_link->query($uploadSql);
    $returnValue = array();
    if ($result) {
        $imgFolderUrl = "http://" . $_SERVER['SERVER_NAME'] . "/OmniChannelDemo/images/?img=";
        $returnValue["status"] = "success";
        $returnValue["message"] = "Image uploaded successfully";
        $returnValue["imageId"] = $mysql_link->insert_id;
        $returnValue["imageUrl"] = $imgFolderUrl . $mysql_link->insert_id;
    } else {
        $returnValue["status"] = "error";
        $returnValue["message"] = $mysql_link->error;
        $returnValue["imageId"] = null;
        $returnValue["imageUrl"] = null;
    }
    return $returnValue;
}
Пример #2
0
function processRequest()
{
    @header('Content-type: application/json');
    $action = getRequestParameter("action");
    if ($action == "getInfo") {
        global $jsonRaceInfo;
        echo json_encode($jsonRaceInfo);
    } else {
        // display how to use service.
        $serviceEndpoints = array(array("Name" => "Get Information", "Description" => "Returns information of the race image", "Endpoint" => "/race_service.php?action=getInfo"), array("Name" => "Example for another service", "Description" => "this service does something....", "Endpoint" => "/race_service.php?action=..."));
        $serviceEndpointDesc = array("Service Endpoints" => $serviceEndpoints);
        echo json_encode($serviceEndpointDesc);
    }
    return;
}
Пример #3
0
function processRequest()
{
    @header('Content-type: application/json');
    $action = getRequestParameter("action");
    $token = getRequestParameter("token");
    if ($action == 'getAllDemos') {
        $maxItems = getRequestParameter("maxItems");
        $userEmail = getRequestParameter("userEmail");
        logUsage($action, "", $maxItems, $userEmail);
        echo json_encode(getAllConfigsFromDatabase($userEmail, $maxItems));
    } else {
        if ($action == 'getStandardDemos') {
            logUsage($action, "", "", "");
            echo json_encode(getDefaultConfigsFromDatabase());
        } else {
            if ($action == 'saveConfig') {
                $config = getRequestParameter("config");
                $savedConfig = saveConfig(json_decode($config));
                logUsage($action, "", $savedConfig->token, $config);
                echo json_encode($savedConfig);
            } else {
                if ($action == 'copyConfig') {
                    // copy token config to a new token
                    // copy website...
                    $newToken = copyConfig($token);
                    logUsage($action, "", $newToken, "");
                    echo json_encode($newToken);
                } else {
                    if ($action == 'getConfig') {
                        logUsage($action, "", $token, "");
                        echo json_encode(getConfig($token));
                    } else {
                        // display how to use service.
                        $endpointVariables = array("Name" => "token", "Type" => "String", "Mandatory" => false);
                        $serviceEndpoints = array(array("Name" => "Reset Demo", "Description" => "....", "Endpoint" => "/api?action=resetDemo&token=...", "Variables" => $endpointVariables), array("Name" => "Get Configuration", "Description" => "....", "Endpoint" => "/api?action=getConfig[&token=...]"), array("Name" => "Save Configuration", "Description" => "....", "Endpoint" => "/api?action=saveConfig&config=..."), array("Name" => "Get Offers", "Description" => "....", "Endpoint" => "/api?action=getOffers&customer=...&maxOffer=...&token=..."), array("Name" => "Respond to Offer", "Description" => "....", "Endpoint" => "/api?action=respondToOffer&offer=...&customer=...&token=..."), array("Name" => "Get History", "Description" => "....", "Endpoint" => "/api?action=getHistory&customer=...&token=..."));
                        $serviceEndpointDesc = array("Service Endpoints" => $serviceEndpoints);
                        echo json_encode($serviceEndpointDesc);
                    }
                }
            }
        }
    }
    // log usage
    return;
}
Пример #4
0
function processRequest()
{
    $token = getRequestParameter("token");
    $page = getRequestParameter("page");
    $action = getRequestParameter("action");
    if (empty($token)) {
        die("please provide a token");
    }
    if (empty($page)) {
        $page = "start";
    }
    if (empty($action)) {
        $action = "read";
    }
    if ($action == "read") {
        echo getPageFromDatabase($token, $page);
    } else {
        if ($action == "edit") {
            displayEditor($token, $page);
        } else {
            if ($action == "save") {
                // overwrite existing page
                $options = getRequestParameter("options");
                $content = getRequestParameter("content");
                @header('Content-type: application/json');
                echo json_encode(savePageToDatabase($token, $page, $content, $options));
            } else {
                if ($action == "upload") {
                    $url = getRequestParameter("url");
                    $raw_options = getRequestParameter("uploadOptions");
                    $options = array();
                    if (!empty($raw_options)) {
                        $options = json_decode($raw_options);
                    }
                    uploadWebsiteToDatabase($token, $page, $url, $options);
                }
            }
        }
    }
}
 function getOptionParameter()
 {
     if (isset($GLOBALS['option'])) {
         return $GLOBALS['option'];
     } else {
         return getRequestParameter('option');
     }
 }
Пример #6
0
function GetFlashCode($appid, $auto_play, $file_id, $definition, $player_id)
{
    return FLASH_ADDRESS . '&' . getRequestParameter($appid, $auto_play, $file_id, $definition, $player_id);
}
Пример #7
0
$cache = new KalturaResponseCacher(null, kCacheManager::CACHE_TYPE_API_V3_FEED, $expiry);
$cache->checkOrStart();
ob_start();
// Database
DbManager::setConfig(kConf::getDB());
DbManager::initialize();
KalturaLog::debug(">------------------------------------- syndicationFeedRenderer -------------------------------------");
KalturaLog::info("syndicationFeedRenderer-start ");
KalturaLog::debug("getFeed Params [" . print_r(requestUtils::getRequestParams(), true) . "]");
kCurrentContext::$host = isset($_SERVER["HOSTNAME"]) ? $_SERVER["HOSTNAME"] : null;
kCurrentContext::$user_ip = requestUtils::getRemoteAddress();
kCurrentContext::$ps_vesion = "ps3";
$feedId = getRequestParameter('feedId');
$entryId = getRequestParameter('entryId');
$limit = getRequestParameter('limit');
$ks = getRequestParameter('ks');
$feedProcessingKey = "feedProcessing_{$feedId}_{$entryId}_{$limit}";
if (function_exists('apc_fetch')) {
    if (apc_fetch($feedProcessingKey)) {
        KExternalErrors::dieError(KExternalErrors::PROCESSING_FEED_REQUEST);
    }
}
try {
    $syndicationFeedRenderer = new KalturaSyndicationFeedRenderer($feedId, $feedProcessingKey, $ks);
    $syndicationFeedRenderer->addFlavorParamsAttachedFilter();
    kCurrentContext::$partner_id = $syndicationFeedRenderer->syndicationFeed->partnerId;
    if (isset($entryId)) {
        $syndicationFeedRenderer->addEntryAttachedFilter($entryId);
    }
    $syndicationFeedRenderer->execute($limit);
} catch (PropelException $pex) {
Пример #8
0
function processRequest()
{
    @header('Content-type: application/json');
    $action = getRequestParameter("action");
    $token = getRequestParameter("token");
    if ($action == 'getAllDemos') {
        $maxItems = getRequestParameter("maxItems");
        $userEmail = getRequestParameter("userEmail");
        logUsage($action, "", $maxItems, $userEmail);
        echo json_encode(getAllConfigsFromDatabase($userEmail, $maxItems));
    } else {
        if ($action == 'getStandardDemos') {
            logUsage($action, "", "", "");
            echo json_encode(getDefaultConfigsFromDatabase());
        } else {
            if ($action == 'resetDemo') {
                resetDemo($token);
                logUsage($action, "", $token, "");
            } else {
                if ($action == 'saveConfig') {
                    $config = getRequestParameter("config");
                    $savedConfig = saveConfig(json_decode($config));
                    logUsage($action, "", $savedConfig->token, $config);
                    echo json_encode($savedConfig);
                } else {
                    if ($action == 'copyConfig') {
                        // copy token config to a new token
                        // copy website...
                        $newToken = copyConfig($token);
                        logUsage($action, "", $newToken, "");
                        echo json_encode($newToken);
                    } else {
                        if ($action == 'getOffers') {
                            $customer = getRequestParameter("customer");
                            $channel = getRequestParameter("channel");
                            $list_size = getRequestParameter("maxOffers");
                            $do_not_track = getRequestParameter("DoNotTrack");
                            logUsage($action, "", $token, $channel);
                            echo json_encode(getOffers($token, $customer, $channel, $list_size, $do_not_track));
                        } else {
                            if ($action == 'changeAnalyticsScore') {
                                $customer = getRequestParameter("customer");
                                $scoreIndex = getRequestParameter("scoreIndex");
                                $scoreValue = getRequestParameter("scoreValue");
                                echo json_encode(changeAnalyticsScore($token, $customer, $scoreIndex, $scoreValue));
                            } else {
                                if ($action == 'respondToOffer') {
                                    $customer = getRequestParameter("customer");
                                    $offerCd = getRequestParameter("offer");
                                    $responseCd = getRequestParameter("response");
                                    $channelCd = getRequestParameter("channel");
                                    $details = getRequestParameter("details");
                                    logUsage($action, "", $token, $channelCd);
                                    echo json_encode(respondToOffer($token, $customer, $offerCd, $responseCd, $channelCd, $details));
                                } else {
                                    if ($action == 'getHistory') {
                                        $customer = getRequestParameter("customer");
                                        logUsage($action, "", $token, $customer);
                                        echo json_encode(getCustomerHistory($token, $customer));
                                    } else {
                                        if ($action == 'getConfig') {
                                            logUsage($action, "", $token, "");
                                            echo json_encode(getConfig($token));
                                        } else {
                                            // display how to use service.
                                            $endpointVariables = array("Name" => "token", "Type" => "String", "Mandatory" => false);
                                            $serviceEndpoints = array(array("Name" => "Reset Demo", "Description" => "....", "Endpoint" => "/api?action=resetDemo&token=...", "Variables" => $endpointVariables), array("Name" => "Get Configuration", "Description" => "....", "Endpoint" => "/api?action=getConfig[&token=...]"), array("Name" => "Save Configuration", "Description" => "....", "Endpoint" => "/api?action=saveConfig&config=..."), array("Name" => "Get Offers", "Description" => "....", "Endpoint" => "/api?action=getOffers&customer=...&maxOffer=...&token=..."), array("Name" => "Respond to Offer", "Description" => "....", "Endpoint" => "/api?action=respondToOffer&offer=...&customer=...&token=..."), array("Name" => "Get History", "Description" => "....", "Endpoint" => "/api?action=getHistory&customer=...&token=..."));
                                            $serviceEndpointDesc = array("Service Endpoints" => $serviceEndpoints);
                                            echo json_encode($serviceEndpointDesc);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // log usage
    return;
}