HEX
Server: Apache
System: Linux msm5694.mjhst.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: camjab_ssh (1000)
PHP: 5.3.29
Disabled: NONE
Upload Files
File: /home/httpd/html/xdudes.com/admin/edit_api.php
<?php
require "db.php";

if (!is_numeric($_REQUEST['id'])) {
    exit();
}

$id = (int) $_REQUEST['id'];

$row = dbRow("SELECT * FROM `paysites` WHERE `record_num` = '$id'");
if (!is_array($row)) {
    setMessage("API ID $id does not exist!", 'error');
    pageNotFound(true);
}

if (isset($_POST['formSubmit'])) {
    
    $_POST = array_map_array('trim', $_POST);
    
    $_POST['name'] = strip_tags($_POST['name']);

    if ($_POST['name'] == "") {
        setMessage('"Name" is required!', 'error');
    }
    
  
   

    if (!getMessages(false, 'error')) {
        dbUpdate('paysites', array(
            'name' => $_POST['name'],
			'slug' => $_POST['slug'],
            'functionName' => $_POST['functionName'],
            'apiData' => $_POST['apiData'],
            'maxResults' => $_POST['maxResults'],
            'parameters' => $_POST['parameters'],
            'enabled' => $_POST['enabled'],
			'whitelist' => $_POST['whitelist'],
			'whitelabel_domain' => $_POST['whitelabel_domain'],
			'defaultModelText' => $_POST['defaultModelText'],
			'settings_json' => json_encode($_POST['custom']),
            'record_num' => $id,
        ));

		if(isset($_POST['preferred'])) { 
			 dbUpdate('paysites', array(
				'preferred' => $_POST['preferred'],
				'record_num' => $id,
			));
		}
		if(isset($_POST['preferredLink'])) { 
			 dbUpdate('paysites', array(
				'preferredLink' => $_POST['preferredLink'],
				'record_num' => $id,
			));
		}
		
        setMessage('API updated. <a href="apis.php">Click here to go back</a>.');
        header("Location: ".$_SERVER['REQUEST_URI']);
        exit();
    }
}

if(!empty($row['settings_json'])) { 
	$settingsJson = json_decode($row['settings_json'],true); 
}

$_POST += $row;
entities_walk($_POST);

?>

<? require "header.php"; ?>



<div class="content-page">
    
    <div class="header-area">
        <div class="breadcrumbs">  
            <a href="index.php">Admin Home</a>          
            <span><a href="apis.php">Manage APIs</a></span>  
        </div>
    </div>
    
    <div class="content-outer">  

        <h2>Edit<strong>API</strong></h2>

        
        
        <div class="content-inner">
            <? if($_GET['id'] == 1) { ?>
			<div class="notification info">We strongly recommend using a whitelabel with Chaturbate. If you do not, Chrome will disable the iframe cam after a few seconds due to "using too many resources". It is recommended to use a whitelabel using your own domain while avoiding words like ad, chaturbate, and so forth - so for instance cbt.yourdomain.com. This will help circumvent adblock as well. Whitelabel domain should be entered without http:// - just "whatever.whatever.com".</div>
			<? } ?>
            <? echo getMessages(); ?>
            
            <form method="POST" action="" enctype="multipart/form-data" class="form" novalidate autocomplete="off">
                <table class="pagetable" id="languages">
                    <thead>
                        <tr>
                            <th colspan="2">Edit API - <? echo $_POST['name']; ?></th>
                        </tr>
                    </thead>
                    <tbody>
                       
                        <tr>
                            <td>API Name</td>
                            <td><input name="name" type="text" value="<? echo $_POST['name']; ?>" required /></td>
                        </tr>
						 <tr>
                            <td>URL Slug</td>
                            <td><input name="slug" type="text" value="<? echo $_POST['slug']; ?>" required /></td>
                        </tr>
                         <tr>
                            <td>PHP Function Call</td>
                            <td><input name="functionName" type="text" value="<? echo $_POST['functionName']; ?>" required /></td>
                        </tr>
						 <tr>
                            <td>Max Results</td>
                            <td><input name="maxResults" type="text" value="<? echo $_POST['maxResults']; ?>" required /></td>
                        </tr>
						 <tr>
                            <td><?php echo $row['apiDataFieldName']; ?></td>
                            <td><input name="apiData" type="text" value="<? echo $_POST['apiData']; ?>" required /></td>
                        </tr>
						<tr>
                            <td>Additional Parameters</td>
                            <td><input name="parameters" type="text" value="<? echo $_POST['parameters']; ?>" placeholder="<? echo $row['parametersPlaceholder']; ?>" /></td>
                        </tr>
						<?php if(isset($row['whitelabel_domain_placeholder'])) { ?>
						<tr>
                            <td>Whitelabel Domain</td>
                            <td><input name="whitelabel_domain" type="text" value="<? echo $_POST['whitelabel_domain']; ?>" placeholder="<? echo $row['whitelabel_domain_placeholder']; ?>" /></td>
                        </tr>
						<? } ?>
						<tr>
                            <td>Performer Whitelist <a href="#" title="Performer usernames, comma separated, no spaces. If this field is populated, only performers with these usernames will be added by the API *if they come online*."><i class="ion ion-help-circled"></i></a></td>
                            <td><textarea name='whitelist' placeholder="username1,username2,username3,..."><? echo $_POST['whitelist']; ?></textarea></td>
                        </tr>
						<tr>
                            <td>Default Model Text <a href="#" title="Default custom text, shown on model webcam page if no specific text is defined for that model."><i class="ion ion-help-circled"></i></a></td>
                            <td><textarea name='defaultModelText' placeholder="Hello, my name is {username}, and i'm a hot camgirl at Chaturbate..."><? echo $_POST['defaultModelText']; ?></textarea><br>
							<span style='font-size: 10px;'>Available: {username} {room_subject} {age} {spoken_languages} {gender} {race} {hair} {bust} {pubic_area} {tags} {last_online}</span><br>
							<span style='font-size: 10px; font-weight: bold;'>Not all variables are populated from every API!</span><br>
							</td>
                        </tr>
						<tr>
							<td>Enabled</td>
							<td>
								<select name="enabled">
									<option<? echo ($_POST['enabled'] == '0') ? ' selected' : ''; ?> value="0">No</option>
									<option<? echo ($_POST['enabled'] == '1') ? ' selected' : ''; ?> value="1">Yes</option>
								</select>
							</td>
						</tr>
						<? if($row['functionName'] == 'chaturbateData') { ?>
							<tr>
								<td>Preferred IFrame</td>
								<td>
									<select name="preferred">
										<option<? echo ($_POST['preferred'] == 'iframe_embed_revshare') ? ' selected' : ''; ?> value="iframe_embed_revshare">Revshare</option>
										<option<? echo ($_POST['preferred'] == 'iframe_embed') ? ' selected' : ''; ?> value="iframe_embed">Normal</option>
									</select>
								</td>
							</tr>
							<tr>
								<td>Preferred Link</td>
								<td>
									<select name="preferredLink">
										<option<? echo ($_POST['preferredLink'] == 'chat_room_url_revshare') ? ' selected' : ''; ?> value="chat_room_url_revshare">Revshare</option>
										<option<? echo ($_POST['preferredLink'] == 'chat_room_url') ? ' selected' : ''; ?> value="chat_room_url">Normal</option>
									</select>
								</td>
							</tr>
						<? } ?>
						<?php 
						$customSettings = dbQuery("SELECT * FROM paysites_settings WHERE paysite = '{$row['record_num']}'",false);
						foreach($customSettings as $cs) { ?>
							<tr>
						<td><?php echo $cs['name']; ?> <?php if($cs['description']) { ?><a href="#" title="<?php echo $cs['description']; ?>"><i class="ion ion-help-circled"></i></a><?php } ?></td>
								<td>
									<?php if(empty($cs['options'])) { ?>
										<input name="custom[<?php echo $cs['name']; ?>]" type="text" value="<?php if(isset($settingsJson[$cs['name']])) { echo htmlentities($settingsJson[$cs['name']]); } ?>" />
									<?php } else { ?>
										<?php 
											$settingsArr = json_decode(trim($cs['options']), true); 
											if(is_array($settingsArr)) { ?>
												<select name="custom[<?php echo $cs['name']; ?>]">
													<?php foreach($settingsArr as $k=>$v) { ?>
														<option <?php if($v == $settingsJson[$cs['name']]) { echo 'selected'; } ?> value="<?php echo $v; ?>"><?php echo $k; ?></option>
													<? } ?>
												</select>
											<?php } else { ?>
										<?php } ?>
									
									<?php } ?>
								</td>
							</tr>
						
						<?php } ?>
                        <tr class="item submit">
                            <td colspan="2">
                                <input type="hidden" name="id" value="<?php echo $id; ?>" />
                                <input type="hidden" name="formSubmit" value="1" />
                                <button type="submit" class="btn action-save">Save</button>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </form>
        </div>
    </div>

</div>
<? require "footer.php"; ?>